Skip to content

Commit c016478

Browse files
Update fungible token contract to v0.7.0 (#362)
* update fungible token contract * update fungible token contract in test * fix tests with flow-ft dependency --------- Co-authored-by: Josh Hannan <[email protected]>
1 parent 28fe222 commit c016478

16 files changed

+115
-154
lines changed

lib/go/contracts/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/kevinburke/go-bindata v3.23.0+incompatible
7-
github.com/onflow/flow-ft/lib/go/contracts v0.5.0
7+
github.com/onflow/flow-ft/lib/go/contracts v0.7.0
88
github.com/stretchr/testify v1.8.0
99
)
1010

lib/go/contracts/go.sum

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1212
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1313
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1414
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
15-
github.com/onflow/flow-ft/lib/go/contracts v0.5.0 h1:Cg4gHGVblxcejfNNG5Mfj98Wf4zbY76O0Y28QB0766A=
16-
github.com/onflow/flow-ft/lib/go/contracts v0.5.0/go.mod h1:1zoTjp1KzNnOPkyqKmWKerUyf0gciw+e6tAEt0Ks3JE=
15+
github.com/onflow/flow-ft/lib/go/contracts v0.7.0 h1:XEKE6qJUw3luhsYmIOteXP53gtxNxrwTohgxJXCYqBE=
16+
github.com/onflow/flow-ft/lib/go/contracts v0.7.0/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU=
1717
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1818
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1919
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
2020
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
2121
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2222
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
23-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2423
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2524
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
2625
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=

lib/go/templates/internal/assets/assets.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/go/templates/service_templates.go

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66

77
const (
88

9+
// FlowToken Templates
10+
mintFlowFilename = "flowToken/mint_tokens.cdc"
11+
getFlowBalanceFilename = "flowToken/scripts/get_balance.cdc"
12+
913
// FlowStorageFees templates
1014

1115
changeStorageFeeParametersFilename = "storageFees/admin/set_parameters.cdc"
@@ -36,6 +40,19 @@ const (
3640
setExecutionMemoryLimit = "FlowServiceAccount/set_execution_memory_limit.cdc"
3741
)
3842

43+
// FlowToken Templates
44+
func GenerateMintFlowScript(env Environment) []byte {
45+
code := assets.MustAssetString(mintFlowFilename)
46+
47+
return []byte(ReplaceAddresses(code, env))
48+
}
49+
50+
func GenerateGetFlowBalanceScript(env Environment) []byte {
51+
code := assets.MustAssetString(getFlowBalanceFilename)
52+
53+
return []byte(ReplaceAddresses(code, env))
54+
}
55+
3956
// StorageFees Templates
4057

4158
func GenerateChangeStorageFeeParametersScript(env Environment) []byte {

lib/go/test/flow_epoch_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestEpochClusters(t *testing.T) {
108108
})
109109

110110
// create new user accounts, mint tokens for them, and register them for staking
111-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
111+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
112112
ids, _, _ := generateNodeIDs(numEpochAccounts)
113113
_, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
114114
registerNodesForStaking(t, b, env,
@@ -290,7 +290,7 @@ func TestEpochPhaseMetadataChange(t *testing.T) {
290290
})
291291

292292
// create new user accounts, mint tokens for them, and register them for staking
293-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
293+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
294294
ids, _, _ := generateNodeIDs(numEpochAccounts)
295295
_, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
296296
registerNodesForStaking(t, b, env,
@@ -412,7 +412,7 @@ func TestEpochAdvance(t *testing.T) {
412412
})
413413

414414
// create new user accounts, mint tokens for them, and register them for staking
415-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
415+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
416416
ids, _, dkgIDs := generateNodeIDs(numEpochAccounts)
417417
_, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
418418
registerNodesForStaking(t, b, env,
@@ -552,7 +552,7 @@ func TestEpochQCDKGNodeRegistration(t *testing.T) {
552552
rewardIncreaseFactor)
553553

554554
// create new user accounts, mint tokens for them, and register them for staking
555-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
555+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
556556
ids, _, _ := generateNodeIDs(numEpochAccounts)
557557
_, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
558558
registerNodesForStaking(t, b, env,
@@ -644,7 +644,7 @@ func TestEpochFullNodeRegistration(t *testing.T) {
644644
rewardIncreaseFactor)
645645

646646
// create new user accounts, mint tokens for them, and register them for staking
647-
addresses, publicKeys, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
647+
addresses, publicKeys, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
648648
ids, _, _ := generateNodeIDs(numEpochAccounts)
649649
_, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
650650
registerNodesForEpochs(t, b, env,
@@ -676,7 +676,7 @@ func TestEpochQCDKG(t *testing.T) {
676676
rewardIncreaseFactor)
677677

678678
// create new user accounts, mint tokens for them, and register them for staking
679-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
679+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
680680
ids, _, _ := generateNodeIDs(numEpochAccounts)
681681
stakingPrivateKeys, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
682682
registerNodesForStaking(t, b, env,
@@ -979,7 +979,7 @@ func TestEpochQCDKG(t *testing.T) {
979979

980980
t.Run("Can set the rewards with high fee amount, which should not increase the supply at all", func(t *testing.T) {
981981

982-
mintTokensForAccount(t, b, idTableAddress, "6572144.3875")
982+
mintTokensForAccount(t, b, env, idTableAddress, "6572144.3875")
983983

984984
tx = createTxWithTemplateAndAuthorizer(b, templates.GenerateDepositFeesScript(env), idTableAddress)
985985

@@ -1052,7 +1052,7 @@ func TestEpochReset(t *testing.T) {
10521052
rewardIncreaseFactor)
10531053

10541054
// create new user accounts, mint tokens for them, and register them for staking
1055-
addresses, _, signers := registerAndMintManyAccounts(t, b, accountKeys, numEpochAccounts)
1055+
addresses, _, signers := registerAndMintManyAccounts(t, b, env, accountKeys, numEpochAccounts)
10561056
ids, _, _ := generateNodeIDs(numEpochAccounts)
10571057
stakingPrivateKeys, stakingPublicKeys, _, networkingPublicKeys := generateManyNodeKeys(t, numEpochAccounts)
10581058
registerNodesForStaking(t, b, env,

lib/go/test/flow_idtable_nodes_test.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"github.com/onflow/flow-go-sdk/crypto"
1414
"github.com/onflow/flow-go-sdk/test"
1515

16-
ft_templates "github.com/onflow/flow-ft/lib/go/templates"
17-
1816
"github.com/onflow/flow-core-contracts/lib/go/templates"
1917
)
2018

@@ -78,11 +76,7 @@ func TestManyNodesIDTable(t *testing.T) {
7876
totalMint := numberOfNodes * nodeMintAmount
7977
mintAmount := fmt.Sprintf("%d.0", totalMint)
8078

81-
script := ft_templates.GenerateMintTokensScript(
82-
flow.HexToAddress(emulatorFTAddress),
83-
flow.HexToAddress(emulatorFlowTokenAddress),
84-
"FlowToken",
85-
)
79+
script := templates.GenerateMintFlowScript(env)
8680

8781
tx := createTxWithTemplateAndAuthorizer(b, script, b.ServiceKey().Address)
8882

@@ -396,11 +390,7 @@ func TestUnstakeAllManyDelegatorsIDTable(t *testing.T) {
396390

397391
for i := 0; i < unstakeAllNumNodes; i++ {
398392

399-
script := ft_templates.GenerateMintTokensScript(
400-
flow.HexToAddress(emulatorFTAddress),
401-
flow.HexToAddress(emulatorFlowTokenAddress),
402-
"FlowToken",
403-
)
393+
script := templates.GenerateMintFlowScript(env)
404394
tx := createTxWithTemplateAndAuthorizer(b, script, b.ServiceKey().Address)
405395

406396
_ = tx.AddArgument(cadence.NewAddress(nodeAddresses[i]))

0 commit comments

Comments
 (0)