-
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
06dd44d
commit 9212ebd
Showing
9 changed files
with
239 additions
and
165 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
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 +1,3 @@ | ||
.DS_Store | ||
.DS_Store | ||
/imports/ | ||
/.idea/ |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./cadence/contracts/Recipe.cdc |
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,57 @@ | ||
import "TopShot" | ||
|
||
access(all) contract Recipe { | ||
// This is a snippet extracting the relevant logic from the TopShot contract for demonstration purposes | ||
// More TopShot Code Above | ||
access(all) event PlayAddedToSet(setID: UInt32, playID: UInt32) | ||
|
||
access(all) resource Set { | ||
|
||
// addPlay adds a play to the set | ||
// | ||
// Parameters: playID: The ID of the Play that is being added | ||
// | ||
// Pre-Conditions: | ||
// The Play needs to be an existing play | ||
// The Set needs to be not locked | ||
// The Play can't have already been added to the Set | ||
// | ||
/// Resource fields | ||
access(all) var locked: Bool | ||
access(all) let plays: [UInt32] | ||
access(all) let retired: {UInt32: Bool} | ||
access(all) let numberMintedPerPlay: {UInt32: UInt32} | ||
access(all) let setID: UInt32 | ||
|
||
// Resource initializer | ||
init(setID: UInt32) { | ||
self.locked = false | ||
self.plays = [] | ||
self.retired = {} | ||
self.numberMintedPerPlay = {} | ||
self.setID = setID | ||
} | ||
|
||
access(all) fun addPlay(playID: UInt32) { | ||
pre { | ||
TopShot.getPlayMetaData(playID: playID) != nil: "Cannot add the Play to Set: Play doesn't exist." | ||
!self.locked: "Cannot add the play to the Set after the set has been locked." | ||
self.numberMintedPerPlay[playID] == nil: "The play has already been added to the set." | ||
} | ||
|
||
// Add the Play to the array of Plays | ||
self.plays.append(playID) | ||
|
||
// Open the Play up for minting | ||
self.retired[playID] = false | ||
|
||
// Initialize the Moment count to zero | ||
self.numberMintedPerPlay[playID] = 0 | ||
|
||
emit PlayAddedToSet(setID: self.setID, playID: playID) | ||
} | ||
} | ||
// More TopShot Code Below | ||
} |
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,6 @@ | ||
import Test | ||
|
||
access(all) fun testExample() { | ||
let array = [1, 2, 3] | ||
Test.expect(array.length, Test.equal(3)) | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./cadence/transactions/mint_moment.cdc |
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,32 @@ | ||
import "TopShot" | ||
|
||
transaction { | ||
|
||
let admin: auth(AdminEntitlement) &TopShot.Admin | ||
let borrowedSet: &TopShot.Set | ||
|
||
prepare(acct: auth(Storage, Capabilities) &Account) { | ||
// Borrow the admin resource | ||
self.admin = acct.capabilities.storage.borrow<&TopShot.Admin>( | ||
from: /storage/TopShotAdmin | ||
) ?? panic("Can't borrow admin resource") | ||
|
||
// Borrow the Set resource | ||
self.borrowedSet = self.admin.borrowSet(setID: 1) | ||
|
||
// Borrow the recipient's MomentCollectionPublic capability | ||
let receiverRef = acct.capabilities.borrow<&{TopShot.MomentCollectionPublic}>( | ||
/public/MomentCollection | ||
) ?? panic("Can't borrow collection reference") | ||
|
||
// Mint moments and return them as a collection | ||
let collection <- self.borrowedSet.batchMintMoment(playID: 3, quantity: 3) | ||
|
||
// Deposit the minted moments into the recipient's collection | ||
receiverRef.batchDeposit(tokens: <-collection) | ||
} | ||
|
||
execute { | ||
log("Plays minted") | ||
} | ||
} |
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 @@ | ||
0xdc07d83a937644ff362b279501b7f7a3735ac91a0f3647147acf649dda804e28 |
Oops, something went wrong.