-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
071bf02
commit acc1dba
Showing
2 changed files
with
20 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
Once you have a set created and you've created some plays, you can then add a play to your set by calling the addPlay function in your set. | ||
The Recipe contract demonstrates how to interact with TopShot Sets by allowing Plays to be added to a specific Set. This functionality is essential for enabling Plays to be minted as Moments later in the lifecycle of the application. The core logic for adding Plays is implemented in the addPlay function within the Set resource. | ||
|
||
You would need to pass in the playId's to have them available in the set. Before the function goes through it will check to see if the playID actually exists. If not you'll need to use another one, or create on. | ||
To add a Play to a Set, one must call the addPlay function with the ID of the Play (playID) you want to include. The function ensures that certain preconditions are met before proceeding. First, it checks whether the playID exists in the TopShot contract by querying its metadata. If the Play does not exist, the function will fail, and you will need to either use an existing playID or create a new Play. This step ensures that only valid Plays are added to the Set. | ||
|
||
It will also check if the Set has been locked, meaning no more plays can be added, or if the play has already been added to the set. | ||
The function also verifies that the Set is not locked. A locked Set cannot have new Plays added to it, which helps maintain the integrity of finalized Sets. Additionally, the function checks whether the playID has already been added to the Set. This prevents duplicate entries, ensuring each Play is unique within the Set. | ||
|
||
Once that check is complete, it will add the play to the array of play ID's in the set. The function will also include the play ID in a retired dictionary and set the boolean as false. The number minted per play ID will also be included in a dictionary and initialized as 0. | ||
Once these checks are complete, the playID is added to the array of Plays (plays) associated with the Set. The function also updates a dictionary called retired, setting the status of the playID to false, meaning it is active and can be used for minting Moments. Another dictionary, numberMintedPerPlay, is updated to initialize the count of Moments minted for this Play at zero. | ||
|
||
Finally you would emit an event that the play has been added to the set. | ||
Finally, the addPlay function emits an event, PlayAddedToSet, which signals that a Play has been successfully added to the Set. This event includes the setID and playID and provides an auditable record of the action. | ||
|
||
The Set resource also includes several fields that store important information. The plays array keeps track of all the Plays added to the Set. The retired dictionary indicates whether a Play has been retired (i.e., no longer available for minting Moments), while the numberMintedPerPlay dictionary tracks how many Moments have been minted for each Play in the Set. The locked field determines whether the Set can still accept new Plays, and the setID uniquely identifies the Set. |
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
To add a play to a set you will need to borrow a reference to the admin resource from the Auth Account. | ||
This transaction focuses on adding Plays to a TopShot Set. It follows a structured process to ensure that both the Set and the Plays exist and are correctly updated. | ||
|
||
Once you do, you will need to borrow the set that you would like access to by calling the borrowSet function. This gets whatever setID is created that you want to have access to. | ||
First, the transaction begins by borrowing a reference to the Admin resource from the account’s storage. This resource provides administrative access to manage Sets and Plays. Without this reference, the transaction cannot proceed, as the Admin resource is essential for creating Sets or Plays. | ||
|
||
When that happens you would just use the addPlay function to add whichever plays you have already created to this set. | ||
Next, the transaction checks if a specific Set exists in the account’s storage. If the Set is not present, it creates a new one using the createSet function provided by the Admin resource. This ensures that there is always a valid Set available for managing Plays. Once the Set is confirmed or created, the transaction borrows a reference to it by specifying its setID. | ||
|
||
The transaction then moves on to ensure that the Plays to be added to the Set exist. It does this by iterating through a predefined list of playIDs. For each playID, it checks if the Play's metadata exists. If the Play is missing, it creates the Play using the createPlay function, passing dynamically generated metadata such as the player’s name and play description. This step guarantees that only valid Plays are added to the Set. | ||
|
||
Finally, the transaction uses the addPlay function on the borrowed Set to add each Play by its playID. This function performs several checks: | ||
|
||
- It ensures the Play exists. | ||
- It verifies the Set is not locked, meaning it can still accept new Plays. | ||
- It checks that the Play has not already been added to the Set. | ||
|
||
Once these conditions are met, the Play is added to the Set, and its retired status and minted count are initialized. After all Plays have been added, a success message is logged to indicate the operation has completed. |