-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backfill play tagline for NFT Catalog (#180)
* add contract updates first * add transaction template * add tests * change file name * fix update tagline transaction * fix test * use prebuilt description if tagline is empty string * capitalize Tagline * adding more comments to tagline backfill related functions * addressing comments * more concise description code
- Loading branch information
Showing
6 changed files
with
127 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import TopShot from 0xTOPSHOTADDRESS | ||
|
||
// This transaction updates multiple existing plays' taglines | ||
// and stores them in the Top Shot smart contract | ||
// Parameters: | ||
// | ||
// plays: A dictionary of {playID: tagline} pairs | ||
transaction(plays: {UInt32: String}) { | ||
|
||
// Local variable for the topshot Admin object | ||
let adminRef: &TopShot.Admin | ||
let firstKey: UInt32 | ||
let lastKey: UInt32 | ||
|
||
prepare(acct: AuthAccount) { | ||
|
||
// borrow a reference to the admin resource | ||
self.adminRef = acct.borrow<&TopShot.Admin>(from: /storage/TopShotAdmin) | ||
?? panic("No admin resource in storage") | ||
self.firstKey = plays.keys[0] | ||
self.lastKey = plays.keys[plays.keys.length - 1] | ||
} | ||
|
||
execute { | ||
// update multiple plays with the specified metadata | ||
for key in plays.keys { | ||
self.adminRef.updatePlayTagline(playID: key, tagline: plays[key] ?? panic("No tagline for play")) | ||
} | ||
} | ||
|
||
post { | ||
TopShot.getPlayMetaDataByField(playID: self.firstKey, field: "Tagline") != nil: | ||
"First play's tagline does not exist" | ||
TopShot.getPlayMetaDataByField(playID: self.lastKey, field: "Tagline") != nil: | ||
"Last play's tagline does not exist" | ||
} | ||
} |