diff --git a/cadence/contract.cdc b/cadence/contract.cdc deleted file mode 120000 index b64184f..0000000 --- a/cadence/contract.cdc +++ /dev/null @@ -1 +0,0 @@ -./cadence/contracts/Recipe.cdc \ No newline at end of file diff --git a/cadence/contracts/Recipe.cdc b/cadence/contracts/Recipe.cdc deleted file mode 100644 index a559beb..0000000 --- a/cadence/contracts/Recipe.cdc +++ /dev/null @@ -1,205 +0,0 @@ -import "TopShot" -import "NonFungibleToken" - -access(all) contract Recipe { - // This is a snippet extracting the relevant logic from the TopShot contract for demonstration purposes - // TopShot Contract Code Above - - // Variable size dictionary of SetData structs - access(self) var setDatas: {UInt32: SetData} - - // Variable size dictionary of Set resources - access(self) var sets: @{UInt32: Set} - - // The ID used to create Sets - access(self) var nextSetID: UInt32 - - access(all) var playDatas: {UInt32: Recipe.Play} - access(all) var nextPlayID: UInt32 - - // Events - access(all) event PlayAddedToSet(setID: UInt32, playID: UInt32) - access(all) event PlayRetiredFromSet(setID: UInt32, playID: UInt32, numMoments: UInt32) - access(all) event SetLocked(setID: UInt32) - access(all) event SetCreated(setID: UInt32, series: UInt32) - - init() { - self.setDatas = {} - self.sets <- {} - self.nextSetID = 0 - self.playDatas = {} - self.nextPlayID = 0 - } - - // Play is a Struct that holds metadata associated - // with a specific NBA play, like the legendary moment when - // Ray Allen hit the 3 to tie the Heat and Spurs in the 2013 finals game 6 - // or when Lance Stephenson blew in the ear of Lebron James. - // - // Moment NFTs will all reference a single play as the owner of - // its metadata. The plays are publicly accessible, so anyone can - // read the metadata associated with a specific play ID - // - access(all) struct Play { - // The unique ID for the Play - access(all) let playID: UInt32 - - // Stores all the metadata about the play as a string mapping - // This is not the long-term way NFT metadata will be stored. - access(all) let metadata: {String: String} - - init(metadata: {String: String}) { - pre { - metadata.length != 0: "New Play metadata cannot be empty" - } - self.playID = TopShot.nextPlayID - self.metadata = metadata - } - } - - // A Set is a grouping of Plays that have occurred in the real world - // that make up a related group of collectibles, like sets of baseball - // or Magic cards. A Play can exist in multiple different sets. - // - // SetData is a struct that is stored in a field of the contract. - // Anyone can query the constant information - // about a set by calling various getters located - // at the end of the contract. Only the admin has the ability - // to modify any data in the private Set resource. - // - access(all) struct SetData { - - // Unique ID for the Set - access(all) let setID: UInt32 - - // Name of the Set - access(all) let name: String - - // Series that this Set belongs to. - access(all) let series: UInt32 - - init(name: String) { - pre { - name.length > 0: "New Set name cannot be empty" - } - self.setID = Recipe.nextSetID - self.name = name - self.series = TopShot.currentSeries - } - } - - access(all) resource Set { - - // Unique ID for the set - access(all) let setID: UInt32 - - // Array of plays that are a part of this set. - access(contract) var plays: [UInt32] - - // Map of Play IDs that Indicates if a Play in this Set can be minted. - access(contract) var retired: {UInt32: Bool} - - // Indicates if the Set is currently locked. - access(all) var locked: Bool - - // Mapping of Play IDs that indicates the number of Moments - access(contract) var numberMintedPerPlay: {UInt32: UInt32} - - init(name: String) { - self.setID = Recipe.nextSetID - self.plays = [] - self.retired = {} - self.locked = false - self.numberMintedPerPlay = {} - - Recipe.setDatas[self.setID] = Recipe.SetData(name: name) - } - - // Get the list of Plays in the Set - access(all) view fun getPlays(): [UInt32] { - return self.plays - } - - // Get the retired status of Plays in the Set - access(all) view fun getRetired(): {UInt32: Bool} { - return self.retired - } - - // Get the number of Moments minted for each Play - access(all) view fun getNumMintedPerPlay(): {UInt32: UInt32} { - return self.numberMintedPerPlay - } - - // Add a Play to the Set - access(all) fun addPlay(playID: UInt32) { - pre { - Recipe.playDatas[playID] != nil: "Cannot add Play: Play doesn't exist." - !self.locked: "Cannot add Play: Set is locked." - self.numberMintedPerPlay[playID] == nil: "Play already added." - } - - self.plays.append(playID) - self.retired[playID] = false - self.numberMintedPerPlay[playID] = 0 - - emit PlayAddedToSet(setID: self.setID, playID: playID) - } - - // Retire a Play from the Set - access(all) fun retirePlay(playID: UInt32) { - pre { - self.retired[playID] != nil: "Cannot retire Play: Play doesn't exist in set." - } - - if !self.retired[playID]! { - self.retired[playID] = true - emit PlayRetiredFromSet( - setID: self.setID, - playID: playID, - numMoments: self.numberMintedPerPlay[playID]! - ) - } - } - - // Lock the Set to prevent further modifications - access(all) fun lock() { - if !self.locked { - self.locked = true - emit SetLocked(setID: self.setID) - } - } - - // Mint a Moment from a Play in the Set - access(all) fun mintMoment(playID: UInt32): @TopShot.NFT { - pre { - self.retired[playID] != nil: "Cannot mint: Play doesn't exist." - !self.retired[playID]!: "Cannot mint: Play retired." - } - - let numInPlay = self.numberMintedPerPlay[playID]! - let newMoment: @TopShot.NFT <- create TopShot.NFT( - serialNumber: numInPlay + 1, - playID: playID, - setID: self.setID, - subeditionID: 0 - ) - self.numberMintedPerPlay[playID] = numInPlay + 1 - return <-newMoment - } - } - - // Admin resource to manage the contract - access(all) resource Admin { - - // Create a new Set - access(all) fun createSet(name: String): UInt32 { - var newSet <- create Set(name: name) - Recipe.nextSetID = Recipe.nextSetID + 1 - - let newID = newSet.setID - emit SetCreated(setID: newID, series: TopShot.currentSeries) - Recipe.sets[newID] <-! newSet - return newID - } - } -} diff --git a/cadence/tests/Recipe_test.cdc b/cadence/tests/Recipe_test.cdc deleted file mode 100644 index 986e8fe..0000000 --- a/cadence/tests/Recipe_test.cdc +++ /dev/null @@ -1,6 +0,0 @@ -import Test - -access(all) fun testExample() { - let array = [1, 2, 3] - Test.expect(array.length, Test.equal(3)) -} diff --git a/flow.json b/flow.json index 65e216e..a2df076 100644 --- a/flow.json +++ b/flow.json @@ -1,126 +1,115 @@ { - "contracts": { - "Recipe": { - "source": "./cadence/contracts/Recipe.cdc", - "aliases": { - "emulator": "f8d6e0586b0a20c7" - } - } - }, - "dependencies": { - "Burner": { - "source": "mainnet://f233dcee88fe0abe.Burner", - "hash": "71af18e227984cd434a3ad00bb2f3618b76482842bae920ee55662c37c8bf331", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "f233dcee88fe0abe", - "testnet": "9a0766d93b6608b7" - } - }, - "FlowToken": { - "source": "mainnet://1654653399040a61.FlowToken", - "hash": "cefb25fd19d9fc80ce02896267eb6157a6b0df7b1935caa8641421fe34c0e67a", - "aliases": { - "emulator": "0ae53cb6e3f42a79", - "mainnet": "1654653399040a61", - "testnet": "7e60df042a9c0868" - } - }, - "FungibleToken": { - "source": "mainnet://f233dcee88fe0abe.FungibleToken", - "hash": "050328d01c6cde307fbe14960632666848d9b7ea4fef03ca8c0bbfb0f2884068", - "aliases": { - "emulator": "ee82856bf20e2aa6", - "mainnet": "f233dcee88fe0abe", - "testnet": "9a0766d93b6608b7" - } - }, - "FungibleTokenMetadataViews": { - "source": "mainnet://f233dcee88fe0abe.FungibleTokenMetadataViews", - "hash": "dff704a6e3da83997ed48bcd244aaa3eac0733156759a37c76a58ab08863016a", - "aliases": { - "emulator": "ee82856bf20e2aa6", - "mainnet": "f233dcee88fe0abe", - "testnet": "9a0766d93b6608b7" - } - }, - "FungibleTokenSwitchboard": { - "source": "mainnet://f233dcee88fe0abe.FungibleTokenSwitchboard", - "hash": "10f94fe8803bd1c2878f2323bf26c311fb4fb2beadba9f431efdb1c7fa46c695", - "aliases": { - "emulator": "ee82856bf20e2aa6", - "mainnet": "f233dcee88fe0abe", - "testnet": "9a0766d93b6608b7" - } - }, - "MetadataViews": { - "source": "mainnet://1d7e57aa55817448.MetadataViews", - "hash": "10a239cc26e825077de6c8b424409ae173e78e8391df62750b6ba19ffd048f51", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "1d7e57aa55817448", - "testnet": "631e88ae7f1d7c20" - } - }, - "NonFungibleToken": { - "source": "mainnet://1d7e57aa55817448.NonFungibleToken", - "hash": "b63f10e00d1a814492822652dac7c0574428a200e4c26cb3c832c4829e2778f0", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "1d7e57aa55817448", - "testnet": "631e88ae7f1d7c20" - } - }, - "TopShot": { - "source": "mainnet://0b2a3299cc857e29.TopShot", - "hash": "804d7381441bea4ed1a0c74e91e0c7c54322b353d236af911f67783263f177f9", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "0b2a3299cc857e29", - "testnet": "877931736ee77cff" - } - }, - "TopShotLocking": { - "source": "mainnet://0b2a3299cc857e29.TopShotLocking", - "hash": "f9b527269a947bbbf5e120ae05ecdb38b8e5f9a6be704e73f5a2e36d33b687b1", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "0b2a3299cc857e29", - "testnet": "877931736ee77cff" - } - }, - "ViewResolver": { - "source": "mainnet://1d7e57aa55817448.ViewResolver", - "hash": "374a1994046bac9f6228b4843cb32393ef40554df9bd9907a702d098a2987bde", - "aliases": { - "emulator": "f8d6e0586b0a20c7", - "mainnet": "1d7e57aa55817448", - "testnet": "631e88ae7f1d7c20" - } - } - }, - "networks": { - "emulator": "127.0.0.1:3569", - "mainnet": "access.mainnet.nodes.onflow.org:9000", - "testing": "127.0.0.1:3569", - "testnet": "access.devnet.nodes.onflow.org:9000" - }, - "accounts": { - "emulator-account": { - "address": "f8d6e0586b0a20c7", - "key": { - "type": "file", - "location": "emulator-account.pkey" - } - } - }, - "deployments": { - "emulator": { - "emulator-account": [ - "Recipe", - "TopShot", - "TopShotLocking" - ] - } - } -} \ No newline at end of file + "contracts": {}, + "dependencies": { + "Burner": { + "source": "mainnet://f233dcee88fe0abe.Burner", + "hash": "71af18e227984cd434a3ad00bb2f3618b76482842bae920ee55662c37c8bf331", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "f233dcee88fe0abe", + "testnet": "9a0766d93b6608b7" + } + }, + "FlowToken": { + "source": "mainnet://1654653399040a61.FlowToken", + "hash": "cefb25fd19d9fc80ce02896267eb6157a6b0df7b1935caa8641421fe34c0e67a", + "aliases": { + "emulator": "0ae53cb6e3f42a79", + "mainnet": "1654653399040a61", + "testnet": "7e60df042a9c0868" + } + }, + "FungibleToken": { + "source": "mainnet://f233dcee88fe0abe.FungibleToken", + "hash": "050328d01c6cde307fbe14960632666848d9b7ea4fef03ca8c0bbfb0f2884068", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenMetadataViews": { + "source": "mainnet://f233dcee88fe0abe.FungibleTokenMetadataViews", + "hash": "dff704a6e3da83997ed48bcd244aaa3eac0733156759a37c76a58ab08863016a", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenSwitchboard": { + "source": "mainnet://f233dcee88fe0abe.FungibleTokenSwitchboard", + "hash": "10f94fe8803bd1c2878f2323bf26c311fb4fb2beadba9f431efdb1c7fa46c695", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "testnet": "9a0766d93b6608b7" + } + }, + "MetadataViews": { + "source": "mainnet://1d7e57aa55817448.MetadataViews", + "hash": "10a239cc26e825077de6c8b424409ae173e78e8391df62750b6ba19ffd048f51", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "testnet": "631e88ae7f1d7c20" + } + }, + "NonFungibleToken": { + "source": "mainnet://1d7e57aa55817448.NonFungibleToken", + "hash": "b63f10e00d1a814492822652dac7c0574428a200e4c26cb3c832c4829e2778f0", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "testnet": "631e88ae7f1d7c20" + } + }, + "TopShot": { + "source": "mainnet://0b2a3299cc857e29.TopShot", + "hash": "804d7381441bea4ed1a0c74e91e0c7c54322b353d236af911f67783263f177f9", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "0b2a3299cc857e29", + "testnet": "877931736ee77cff" + } + }, + "TopShotLocking": { + "source": "mainnet://0b2a3299cc857e29.TopShotLocking", + "hash": "f9b527269a947bbbf5e120ae05ecdb38b8e5f9a6be704e73f5a2e36d33b687b1", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "0b2a3299cc857e29", + "testnet": "877931736ee77cff" + } + }, + "ViewResolver": { + "source": "mainnet://1d7e57aa55817448.ViewResolver", + "hash": "374a1994046bac9f6228b4843cb32393ef40554df9bd9907a702d098a2987bde", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "testnet": "631e88ae7f1d7c20" + } + } + }, + "networks": { + "emulator": "127.0.0.1:3569", + "mainnet": "access.mainnet.nodes.onflow.org:9000", + "testing": "127.0.0.1:3569", + "testnet": "access.devnet.nodes.onflow.org:9000" + }, + "accounts": { + "emulator-account": { + "address": "f8d6e0586b0a20c7", + "key": { + "type": "file", + "location": "emulator-account.pkey" + } + } + }, + "deployments": { + "emulator": { + "emulator-account": ["TopShot", "TopShotLocking"] + } + } +}