Skip to content

Commit af808a6

Browse files
committed
update dependencies
1 parent e696a8e commit af808a6

18 files changed

+291
-267
lines changed

lib/go/contracts/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.18
55
require (
66
github.com/kevinburke/go-bindata v3.24.0+incompatible
77
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9
8-
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e
9-
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140
8+
github.com/onflow/flow-ft/lib/go/contracts v1.0.0
9+
github.com/onflow/flow-nft/lib/go/contracts v1.2.0
1010
github.com/stretchr/testify v1.8.4
1111
)
1212

lib/go/contracts/go.sum

+4-8
Original file line numberDiff line numberDiff line change
@@ -1617,18 +1617,14 @@ github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
16171617
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
16181618
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9 h1:rTemckPWir+N/m1GyhT8jdiETj0RiWc8FiwItE2Nxyg=
16191619
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9/go.mod h1:PZrrCsllIt/Bu4HlJtisXfvDrOt1aLKU5R70vsZHKRc=
1620-
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424142855-b518689a350b h1:HutxHvyc06UbJncEUieAwt7Nf1lG5uiIGVok6w031LM=
1621-
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424142855-b518689a350b/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
1622-
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e h1:2LO6Rtmz2PVfH+ZXnMwvTwVeIz3PCy0fs3lQraqog14=
1623-
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240424211859-3ff4c0fe2a1e/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
1620+
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
1621+
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
16241622
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240213220156-959b70719876 h1:fZj39XxayIL7uvKvonNI3MtQM3wsFJ8oRl/XW/0rn7A=
16251623
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240213220156-959b70719876/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
16261624
github.com/onflow/flow-go-sdk v1.0.0-M1 h1:mke/ebYwNRRWPZqcwCV56Alx0A8psew43ZbSEUQ4TL8=
16271625
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
1628-
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240424144730-4a6f42d2a372 h1:jVrUFQ5Fn3gBKZ3Q6OVhceF2vKiHg1la6g3DuRKvdoo=
1629-
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240424144730-4a6f42d2a372/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
1630-
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140 h1:oTj4RGgfuJSSBE1aDVrlh6avxKBMraucpNtRg0K+yhg=
1631-
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240429184308-40c3de711140/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
1626+
github.com/onflow/flow-nft/lib/go/contracts v1.2.0 h1:TFH7GCJKcGi0+x14SCvF7Gbnxp68gJOGNV8PSIAM2J0=
1627+
github.com/onflow/flow-nft/lib/go/contracts v1.2.0/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
16321628
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240213205729-48f42d9896f8 h1:BqgQgXktxVFv8erjCaSHpL0CP+pa5M8g655GyF/t4JM=
16331629
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240213205729-48f42d9896f8/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
16341630
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2 h1:qZjl4wSTG/E9znEjkHF0nNaEdlBLJoOEAtr7xUsTNqc=

lib/go/templates/delegator_templates.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import (
55
)
66

77
const (
8-
createDelegationFilename = "idTableStaking/delegation/del_create_delegation.cdc"
9-
delegatorAddCapabilityFilename = "idTableStaking/delegation/delegator_add_capability.cdc"
8+
createDelegationFilename = "idTableStaking/delegation/del_create_delegation.cdc"
109

1110
delegatorRegisterFilename = "idTableStaking/delegation/register_delegator.cdc"
1211
delegatorStakeNewFilename = "idTableStaking/delegation/del_stake_new_tokens.cdc"
@@ -77,12 +76,6 @@ func GenerateDelegatorWithdrawRewardsScript(env Environment) []byte {
7776
return []byte(ReplaceAddresses(code, env))
7877
}
7978

80-
func GenerateAddPublicDelegatorCapabilityScript(env Environment) []byte {
81-
code := assets.MustAssetString(delegatorAddCapabilityFilename)
82-
83-
return []byte(ReplaceAddresses(code, env))
84-
}
85-
8679
// Scripts
8780

8881
func GenerateGetDelegatorInfoScript(env Environment) []byte {

lib/go/templates/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ go 1.18
55
require (
66
github.com/kevinburke/go-bindata v3.24.0+incompatible
77
github.com/onflow/cadence v1.0.0-M3
8-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e
8+
github.com/onflow/flow-ft/lib/go/templates v1.0.0
99
github.com/onflow/flow-go-sdk v1.0.0-M1
10-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140
10+
github.com/onflow/flow-nft/lib/go/templates v1.2.0
1111
github.com/psiemens/sconfig v0.1.0
1212
github.com/spf13/cobra v1.5.0
1313
)

lib/go/templates/go.sum

+4-8
Original file line numberDiff line numberDiff line change
@@ -1615,16 +1615,12 @@ github.com/onflow/cadence v1.0.0-M3 h1:bSydJise9pU4aALloUKv/EWmDLITRlbBpuG8OPByd
16151615
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
16161616
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
16171617
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
1618-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424142855-b518689a350b h1:Z/Fn+7ysdfuv8yKzhPlZ+HrADm3zaUi+zb6BP4JWLfU=
1619-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424142855-b518689a350b/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
1620-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e h1:jl7SYAui/gYRmBofrY//Ln8ixRJwvLzvwLstNfRKmWY=
1621-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240424211859-3ff4c0fe2a1e/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
1618+
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
1619+
github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
16221620
github.com/onflow/flow-go-sdk v1.0.0-M1 h1:mke/ebYwNRRWPZqcwCV56Alx0A8psew43ZbSEUQ4TL8=
16231621
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
1624-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240424144730-4a6f42d2a372 h1:zjEANfSuCctAQ79IotaP6+v0jZiJsDAlikcZC++BTpc=
1625-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240424144730-4a6f42d2a372/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
1626-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140 h1:7NwSIG4SEdm+96gr+Aaqx291jZ/Bqkxk/ghVnens9CU=
1627-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240429184308-40c3de711140/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
1622+
github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc=
1623+
github.com/onflow/flow-nft/lib/go/templates v1.2.0/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
16281624
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2 h1:qZjl4wSTG/E9znEjkHF0nNaEdlBLJoOEAtr7xUsTNqc=
16291625
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
16301626
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=

lib/go/templates/idtable_staking_templates.go

-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const (
4646
withdrawUnstakedTokensFilename = "idTableStaking/node/withdraw_unstaked_tokens.cdc"
4747
withdrawRewardedTokensFilename = "idTableStaking/node/withdraw_rewarded_tokens.cdc"
4848
updateNetworkingAddressFilename = "idTableStaking/node/update_networking_address.cdc"
49-
addPublicNodeCapabilityFilename = "idTableStaking/node/node_add_capability.cdc"
5049

5150
registerManyNodesFilename = "idTableStaking/node/register_many_nodes.cdc"
5251

@@ -343,12 +342,6 @@ func GenerateUpdateNetworkingAddressScript(env Environment) []byte {
343342
return []byte(ReplaceAddresses(code, env))
344343
}
345344

346-
func GenerateAddPublicNodeCapabilityScript(env Environment) []byte {
347-
code := assets.MustAssetString(addPublicNodeCapabilityFilename)
348-
349-
return []byte(ReplaceAddresses(code, env))
350-
}
351-
352345
// GenerateReturnTableScript creates a script that returns
353346
// the the whole ID table nodeIDs
354347
func GenerateReturnTableScript(env Environment) []byte {

lib/go/test/epoch_test_helpers.go

+54-52
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,31 @@ type EpochStart struct {
8181
type EpochStartEvent flow.Event
8282

8383
func (evt EpochStartEvent) Counter() cadence.UInt64 {
84-
return evt.Value.Fields[0].(cadence.UInt64)
84+
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
8585
}
8686

8787
func (evt EpochStartEvent) firstView() cadence.UInt64 {
88-
return evt.Value.Fields[1].(cadence.UInt64)
88+
return cadence.SearchFieldByName(evt.Value, "firstView").(cadence.UInt64)
8989
}
9090

9191
func (evt EpochStartEvent) stakingEndView() cadence.UInt64 {
92-
return evt.Value.Fields[2].(cadence.UInt64)
92+
return cadence.SearchFieldByName(evt.Value, "stakingAuctionEndView").(cadence.UInt64)
9393
}
9494

9595
func (evt EpochStartEvent) finalView() cadence.UInt64 {
96-
return evt.Value.Fields[3].(cadence.UInt64)
96+
return cadence.SearchFieldByName(evt.Value, "finalView").(cadence.UInt64)
9797
}
9898

9999
func (evt EpochStartEvent) totalStaked() cadence.UFix64 {
100-
return evt.Value.Fields[4].(cadence.UFix64)
100+
return cadence.SearchFieldByName(evt.Value, "totalStaked").(cadence.UFix64)
101101
}
102102

103103
func (evt EpochStartEvent) totalSupply() cadence.UFix64 {
104-
return evt.Value.Fields[5].(cadence.UFix64)
104+
return cadence.SearchFieldByName(evt.Value, "totalFlowSupply").(cadence.UFix64)
105105
}
106106

107107
func (evt EpochStartEvent) rewards() cadence.UFix64 {
108-
return evt.Value.Fields[6].(cadence.UFix64)
108+
return cadence.SearchFieldByName(evt.Value, "totalRewards").(cadence.UFix64)
109109
}
110110

111111
// / Used to verify the EpochSetup event fields in tests
@@ -136,54 +136,54 @@ type EpochCommit struct {
136136
type EpochSetupEvent flow.Event
137137

138138
func (evt EpochSetupEvent) Counter() cadence.UInt64 {
139-
return evt.Value.Fields[0].(cadence.UInt64)
139+
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
140140
}
141141

142142
func (evt EpochSetupEvent) NodeInfo() cadence.Array {
143-
return evt.Value.Fields[1].(cadence.Array)
143+
return cadence.SearchFieldByName(evt.Value, "nodeInfo").(cadence.Array)
144144
}
145145

146146
func (evt EpochSetupEvent) firstView() cadence.UInt64 {
147-
return evt.Value.Fields[2].(cadence.UInt64)
147+
return cadence.SearchFieldByName(evt.Value, "firstView").(cadence.UInt64)
148148
}
149149

150150
func (evt EpochSetupEvent) finalView() cadence.UInt64 {
151-
return evt.Value.Fields[3].(cadence.UInt64)
151+
return cadence.SearchFieldByName(evt.Value, "finalView").(cadence.UInt64)
152152
}
153153

154154
func (evt EpochSetupEvent) collectorClusters() cadence.Array {
155-
return evt.Value.Fields[4].(cadence.Array)
155+
return cadence.SearchFieldByName(evt.Value, "collectorClusters").(cadence.Array)
156156
}
157157

158158
func (evt EpochSetupEvent) randomSource() cadence.String {
159-
return evt.Value.Fields[5].(cadence.String)
159+
return cadence.SearchFieldByName(evt.Value, "randomSource").(cadence.String)
160160
}
161161

162162
func (evt EpochSetupEvent) dkgFinalViews() (cadence.UInt64, cadence.UInt64, cadence.UInt64) {
163-
fields := evt.Value.Fields
164-
return fields[6].(cadence.UInt64), fields[7].(cadence.UInt64), fields[8].(cadence.UInt64)
163+
fields := cadence.FieldsMappedByName(evt.Value)
164+
return fields["DKGPhase1FinalView"].(cadence.UInt64), fields["DKGPhase2FinalView"].(cadence.UInt64), fields["DKGPhase3FinalView"].(cadence.UInt64)
165165
}
166166

167167
func (evt EpochSetupEvent) targetDuration() cadence.UInt64 {
168-
return evt.Value.Fields[9].(cadence.UInt64)
168+
return cadence.SearchFieldByName(evt.Value, "targetDuration").(cadence.UInt64)
169169
}
170170

171171
func (evt EpochSetupEvent) targetEndTime() cadence.UInt64 {
172-
return evt.Value.Fields[10].(cadence.UInt64)
172+
return cadence.SearchFieldByName(evt.Value, "targetEndTime").(cadence.UInt64)
173173
}
174174

175175
type EpochCommitEvent flow.Event
176176

177177
func (evt EpochCommitEvent) Counter() cadence.UInt64 {
178-
return evt.Value.Fields[0].(cadence.UInt64)
178+
return cadence.SearchFieldByName(evt.Value, "counter").(cadence.UInt64)
179179
}
180180

181181
func (evt EpochCommitEvent) clusterQCs() cadence.Array {
182-
return evt.Value.Fields[1].(cadence.Array)
182+
return cadence.SearchFieldByName(evt.Value, "clusterQCs").(cadence.Array)
183183
}
184184

185185
func (evt EpochCommitEvent) dkgPubKeys() cadence.Array {
186-
return evt.Value.Fields[2].(cadence.Array)
186+
return cadence.SearchFieldByName(evt.Value, "dkgPubKeys").(cadence.Array)
187187
}
188188

189189
// / Deploys the Quroum Certificate and Distributed Key Generation contracts to the provided account
@@ -427,13 +427,14 @@ func verifyClusters(
427427
found := false
428428

429429
for _, actualCluster := range actualClusters {
430-
cluster := actualCluster.(cadence.Struct).Fields
430+
cluster := actualCluster.(cadence.Struct)
431+
clusterFields := cadence.FieldsMappedByName(cluster)
431432

432-
totalWeight := cluster[2]
433+
totalWeight := clusterFields["totalWeight"]
433434
if cadence.NewUInt64(expectedCluster.totalWeight) == totalWeight {
434435
found = true
435436
assertEqual(t, cadence.NewUInt64(expectedCluster.totalWeight), totalWeight)
436-
size := len(cluster[1].(cadence.Dictionary).Pairs)
437+
size := len(clusterFields["nodeWeights"].(cadence.Dictionary).Pairs)
437438
assertEqual(t, cadence.NewUInt16(expectedCluster.size), cadence.NewUInt16(uint16(size)))
438439
}
439440
}
@@ -458,9 +459,10 @@ func verifyClusterQCs(
458459
i := 0
459460
for _, qc := range actualQCs {
460461
found := false
461-
qcStructSignatures := qc.(cadence.Struct).Fields[1].(cadence.Array).Values
462-
qcStructMessage := qc.(cadence.Struct).Fields[2].(cadence.String)
463-
qcVoterIDs := qc.(cadence.Struct).Fields[3].(cadence.Array).Values
462+
qcStructFields := cadence.FieldsMappedByName(qc.(cadence.Struct))
463+
qcStructSignatures := qcStructFields["voteSignatures"].(cadence.Array).Values
464+
qcStructMessage := qcStructFields["voteMessage"].(cadence.String)
465+
qcVoterIDs := qcStructFields["voterIDs"].(cadence.Array).Values
464466

465467
assertEqual(t, len(qcVoterIDs), len(qcStructSignatures))
466468

@@ -494,47 +496,47 @@ func verifyEpochMetadata(
494496
expectedMetadata EpochMetadata) {
495497

496498
result := executeScriptAndCheck(t, b, templates.GenerateGetEpochMetadataScript(env), [][]byte{jsoncdc.MustEncode(cadence.UInt64(expectedMetadata.counter))})
497-
metadataFields := result.(cadence.Struct).Fields
499+
metadataFields := cadence.FieldsMappedByName(result.(cadence.Struct))
498500

499-
counter := metadataFields[0]
501+
counter := metadataFields["counter"]
500502
assertEqual(t, cadence.NewUInt64(expectedMetadata.counter), counter)
501503

502504
if len(expectedMetadata.seed) != 0 {
503-
seed := metadataFields[1]
505+
seed := metadataFields["seed"]
504506
cadenceSeed, _ := cadence.NewString(expectedMetadata.seed)
505507
assertEqual(t, cadenceSeed, seed)
506508
}
507509

508-
startView := metadataFields[2]
510+
startView := metadataFields["startView"]
509511
assertEqual(t, cadence.NewUInt64(expectedMetadata.startView), startView)
510512

511-
endView := metadataFields[3]
513+
endView := metadataFields["endView"]
512514
assertEqual(t, cadence.NewUInt64(expectedMetadata.endView), endView)
513515

514-
stakingEndView := metadataFields[4]
516+
stakingEndView := metadataFields["stakingEndView"]
515517
assertEqual(t, cadence.NewUInt64(expectedMetadata.stakingEndView), stakingEndView)
516518

517-
totalRewards := metadataFields[5]
519+
totalRewards := metadataFields["totalRewards"]
518520
assertEqual(t, CadenceUFix64(expectedMetadata.totalRewards), totalRewards)
519521

520-
rewardsArray := metadataFields[6].(cadence.Array).Values
522+
rewardsArray := metadataFields["rewardAmounts"].(cadence.Array).Values
521523
if expectedMetadata.rewardsBreakdownArray == 0 {
522524
assertEqual(t, len(rewardsArray), 0)
523525
}
524526

525-
rewardsPaid := metadataFields[7]
527+
rewardsPaid := metadataFields["rewardsPaid"]
526528
assertEqual(t, cadence.NewBool(expectedMetadata.rewardsPaid), rewardsPaid)
527529

528530
if expectedMetadata.collectorClusters != nil {
529-
clusters := metadataFields[8].(cadence.Array).Values
531+
clusters := metadataFields["collectorClusters"].(cadence.Array).Values
530532

531533
verifyClusters(t, expectedMetadata.collectorClusters, clusters)
532534
}
533535

534-
clusterQCs := metadataFields[9].(cadence.Array).Values
536+
clusterQCs := metadataFields["clusterQCs"].(cadence.Array).Values
535537
verifyClusterQCs(t, expectedMetadata.clusterQCs, clusterQCs)
536538

537-
dkgKeys := metadataFields[10].(cadence.Array).Values
539+
dkgKeys := metadataFields["dkgKeys"].(cadence.Array).Values
538540
if expectedMetadata.dkgKeys == nil {
539541
assert.Empty(t, dkgKeys)
540542
} else {
@@ -558,12 +560,12 @@ func verifyEpochTimingConfig(
558560
) {
559561

560562
result := executeScriptAndCheck(t, b, templates.GenerateGetEpochTimingConfigScript(env), nil)
561-
timingConfigFields := result.(cadence.Struct).Fields
563+
timingConfigFields := cadence.FieldsMappedByName(result.(cadence.Struct))
562564

563565
// A default epoch timing config should be set in the constructor
564-
assertEqual(t, cadence.NewUInt64(expectedConfig.duration), timingConfigFields[0])
565-
assertEqual(t, cadence.NewUInt64(expectedConfig.refCounter), timingConfigFields[1])
566-
assert.InDelta(t, expectedConfig.refTimestamp, timingConfigFields[2].ToGoValue().(uint64), 30)
566+
assertEqual(t, cadence.NewUInt64(expectedConfig.duration), timingConfigFields["duration"])
567+
assertEqual(t, cadence.NewUInt64(expectedConfig.refCounter), timingConfigFields["refCounter"])
568+
assert.InDelta(t, expectedConfig.refTimestamp, uint64(timingConfigFields["refTimestamp"].(cadence.UInt64)), 30)
567569
}
568570

569571
// / Verifies that the configurable epoch metadata is equal to the provided values
@@ -580,16 +582,16 @@ func verifyConfigMetadata(
580582
assertEqual(t, cadence.NewUInt64(expectedMetadata.proposedEpochCounter), result)
581583

582584
result = executeScriptAndCheck(t, b, templates.GenerateGetEpochConfigMetadataScript(env), nil)
583-
metadataFields := result.(cadence.Struct).Fields
585+
metadataFields := cadence.FieldsMappedByName(result.(cadence.Struct))
584586

585-
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInEpoch), metadataFields[0])
586-
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInStakingAuction), metadataFields[1])
587-
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInDKGPhase), metadataFields[2])
587+
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInEpoch), metadataFields["numViewsInEpoch"])
588+
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInStakingAuction), metadataFields["numViewsInStakingAuction"])
589+
assertEqual(t, cadence.NewUInt64(expectedMetadata.numViewsInDKGPhase), metadataFields["numViewsInDKGPhase"])
588590

589-
clusters := metadataFields[3]
591+
clusters := metadataFields["numCollectorClusters"]
590592
assertEqual(t, cadence.NewUInt16(expectedMetadata.numCollectorClusters), clusters)
591593

592-
apy := metadataFields[4]
594+
apy := metadataFields["FLOWsupplyIncreasePercentage"]
593595
assertEqual(t, CadenceUFix64(expectedMetadata.rewardPercentage), apy)
594596

595597
result = executeScriptAndCheck(t, b, templates.GenerateGetEpochPhaseScript(env), nil)
@@ -715,10 +717,10 @@ func verifyEpochCommit(
715717
// expectedTargetEndTime returns the expected `targetEndTime` for the given target epoch,
716718
// as a second-precision Unix time.
717719
func expectedTargetEndTime(timingConfig cadence.Value, targetEpoch uint64) uint64 {
718-
fields := timingConfig.(cadence.Struct).Fields
719-
duration := fields[0].ToGoValue().(uint64)
720-
refCounter := fields[1].ToGoValue().(uint64)
721-
refTimestamp := fields[2].ToGoValue().(uint64)
720+
fields := cadence.FieldsMappedByName(timingConfig.(cadence.Struct))
721+
duration := uint64(fields["duration"].(cadence.UInt64))
722+
refCounter := uint64(fields["refCounter"].(cadence.UInt64))
723+
refTimestamp := uint64(fields["refTimestamp"].(cadence.UInt64))
722724

723725
return refTimestamp + duration*(targetEpoch-refCounter)
724726
}

0 commit comments

Comments
 (0)