Skip to content

Commit de98710

Browse files
committed
fix update tagline transaction
1 parent a4d5709 commit de98710

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/go/test/topshot_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func TestMintNFTs(t *testing.T) {
197197
result := executeScriptAndCheck(t, b, templates.GenerateGetPlayMetadataFieldScript(env), [][]byte{jsoncdc.MustEncode(cadence.UInt32(1)), jsoncdc.MustEncode(cadence.String("FullName"))})
198198
assert.Equal(t, CadenceString("Lebron"), result)
199199

200-
tb.UpdateTagline(t, 1, "lorem ipsum")
200+
tb.UpdateTagline(t, []cadence.KeyValuePair{{Key: cadence.UInt32(1), Value: CadenceString("lorem ipsum")}})
201201
result = executeScriptAndCheck(t, b, templates.GenerateGetPlayMetadataFieldScript(env), [][]byte{jsoncdc.MustEncode(cadence.UInt32(1)), jsoncdc.MustEncode(cadence.String("tagline"))})
202202
assert.Equal(t, CadenceString("lorem ipsum"), result)
203203
})
@@ -617,11 +617,10 @@ func (b *topshotTestBlockchain) CreatePlay(t *testing.T, metadata []cadence.KeyV
617617
)
618618
}
619619

620-
func (b *topshotTestBlockchain) UpdateTagline(t *testing.T, id uint32, tagline string) {
620+
func (b *topshotTestBlockchain) UpdateTagline(t *testing.T, plays []cadence.KeyValuePair) {
621621
tx := createTxWithTemplateAndAuthorizer(b.Blockchain, templates.GenerateUpdateTaglineScript(b.env), b.topshotAdminAddr)
622-
tag := CadenceString(tagline)
623-
_ = tx.AddArgument(cadence.NewUInt32(id))
624-
_ = tx.AddArgument(tag)
622+
tags := cadence.NewDictionary(plays)
623+
_ = tx.AddArgument(tags)
625624

626625
signAndSubmit(
627626
t, b.Blockchain, tx,

transactions/admin/update_tagline.cdc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TopShot from 0xTOPSHOTADDRESS
99
//
1010
// metadata: A dictionary of all the play metadata associated
1111

12-
transaction(id: UInt32, tagline: String) {
12+
transaction(plays: {UInt32: String}) {
1313

1414
// Local variable for the topshot Admin object
1515
let adminRef: &TopShot.Admin
@@ -23,11 +23,15 @@ transaction(id: UInt32, tagline: String) {
2323

2424
execute {
2525
// update a play with the specified metadata
26-
self.adminRef.updatePlayTagline(playID: id, tagline: tagline)
26+
for key in plays.keys {
27+
self.adminRef.updatePlayTagline(playID: key, tagline: plays[key] ?? panic("No tagline for play"))
28+
}
2729
}
2830

2931
post {
30-
TopShot.getPlayMetaDataByField(playID: id, field: "tagline") != nil:
31-
"tagline doesnt exist"
32+
for key in plays.keys {
33+
TopShot.getPlayMetaDataByField(playID: key, field: "tagline") != nil:
34+
"tagline doesnt exist"
35+
}
3236
}
33-
}
37+
}

0 commit comments

Comments
 (0)