Skip to content

NFL NFT contract #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bf5d67c
feat:update genies contract for NFL, first pass
sadief Sep 22, 2021
e201aa7
rename accidental Showdown to Genies
sadief Sep 28, 2021
a400059
use nextSeriesID instead of currentSeriesID
sadief Sep 28, 2021
bcbadc1
remove unnecessary comment
sadief Sep 28, 2021
33f526a
use a member function to check if max edition size has been reached
sadief Sep 28, 2021
76517a1
remove numMinted from EventCreated event
sadief Sep 28, 2021
4c67b13
use an optional for maxMintSize
sadief Sep 28, 2021
3d00f45
update precondition logic
sadief Sep 29, 2021
9d8fdc5
update precondition logic
sadief Sep 29, 2021
72d05b2
remove unnecessary variable
sadief Sep 29, 2021
561efe4
remove unnecessary if statement
sadief Sep 29, 2021
3b3db35
add setPlaysInEditions dictionary, check & insert
sadief Sep 29, 2021
9154126
remove duplicate statement
sadief Sep 29, 2021
41d5114
add check for max size
sadief Sep 30, 2021
95fb7b2
rename to maxMintSize
sadief Sep 30, 2021
bbef8a5
remove metadata for series, sets, editions
sadief Oct 5, 2021
50fea09
add admin functions for creations
sadief Oct 5, 2021
e735a74
remove old Genies files
sadief Oct 15, 2021
5c00cf6
Add new Showdown smart contract
sadief Oct 15, 2021
b6e20e4
add new ShowdownShardedCollection contract
sadief Oct 15, 2021
1360d3b
update deps
sadief Oct 15, 2021
1a7d95f
update scripts
sadief Oct 15, 2021
aceab58
add new test suite for Showdown contract
sadief Oct 15, 2021
1d5af3a
update templates with showdown paths
sadief Oct 15, 2021
931ae3e
update test with showdown references
sadief Oct 15, 2021
4822c49
update transactions with showdown related tx
sadief Oct 15, 2021
988e1ee
update types for showdown
sadief Oct 15, 2021
1cfbff0
add new scripts
sadief Oct 15, 2021
2356067
add new transactions
sadief Oct 15, 2021
45bd1bb
return `Showdown.` struct
sadief Oct 22, 2021
aca1164
make test function public
sadief Oct 22, 2021
41d7a0e
improve logging
sadief Oct 22, 2021
f9a7b43
add new line to make unix happy
sadief Oct 22, 2021
30fb426
fix spacing
sadief Oct 22, 2021
b9ad6c5
new line?
sadief Oct 22, 2021
2c848ee
actual new lines this time
sadief Oct 22, 2021
b37ad37
rename Showdown -> AllDay
sadief Oct 22, 2021
7e08cad
Fix indentation
sadief Oct 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
837 changes: 837 additions & 0 deletions contracts/AllDay.cdc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
Description: Central Collection for a large number of Genies NFTs
Description: Central Collection for a large number of Moment NFTs

Adapted from: TopShotShardedCollection.cdc
Adapted from: GeniesShardedCollection.cdc
Authors: Joshua Hannan [email protected]
Bastian Muller [email protected]
Rhea Myers [email protected]

[...]

Expand All @@ -12,25 +13,25 @@
*/

import NonFungibleToken from "./NonFungibleToken.cdc"
import Genies from "./Genies.cdc"
import AllDay from "./AllDay.cdc"

pub contract GeniesShardedCollection {
pub contract AllDayShardedCollection {
// Named Paths
//
pub let CollectionStoragePath: StoragePath

// ShardedCollection stores a dictionary of Genies Collections
// A Genies NFT is stored in the field that corresponds to its id % numBuckets
// ShardedCollection stores a dictionary of AllDay Collections
// A AllDay NFT is stored in the field that corresponds to its id % numBuckets
pub resource ShardedCollection:
Genies.GeniesNFTCollectionPublic,
AllDay.MomentNFTCollectionPublic,
NonFungibleToken.Provider,
NonFungibleToken.Receiver,
NonFungibleToken.CollectionPublic
{
// Dictionary of Genies collections
pub var collections: @{UInt64: Genies.Collection}
// Dictionary of AllDay collections
pub var collections: @{UInt64: AllDay.Collection}

// The number of buckets to split Genies NFTs into
// The number of buckets to split AllDay NFTs into
// This makes storage more efficient and performant
pub let numBuckets: UInt64

Expand All @@ -42,13 +43,13 @@ pub contract GeniesShardedCollection {
var i: UInt64 = 0
while i < numBuckets {

self.collections[i] <-! Genies.createEmptyCollection() as! @Genies.Collection
self.collections[i] <-! AllDay.createEmptyCollection() as! @AllDay.Collection

i = i + (1 as UInt64)
}
}

// withdraw removes a Genies NFT from one of the Collections
// withdraw removes a AllDay NFT from one of the Collections
// and moves it to the caller
pub fun withdraw(withdrawID: UInt64): @NonFungibleToken.NFT {
post {
Expand All @@ -57,7 +58,7 @@ pub contract GeniesShardedCollection {
// Find the bucket it should be withdrawn from
let bucket = withdrawID % self.numBuckets

// Withdraw the Genies NFT
// Withdraw the AllDay NFT
let token <- self.collections[bucket]?.withdraw(withdrawID: withdrawID)!

return <-token
Expand All @@ -67,10 +68,10 @@ pub contract GeniesShardedCollection {
//
// Parameters: ids: an array of the IDs to be withdrawn from the Collection
//
// Returns: @NonFungibleToken.Collection a Collection containing the Genies NFTs
// Returns: @NonFungibleToken.Collection a Collection containing the AllDay NFTs
// that were withdrawn
pub fun batchWithdraw(ids: [UInt64]): @NonFungibleToken.Collection {
var batchCollection <- Genies.createEmptyCollection()
var batchCollection <- AllDay.createEmptyCollection()

// Iterate through the ids and withdraw them from the Collection
for id in ids {
Expand All @@ -79,7 +80,7 @@ pub contract GeniesShardedCollection {
return <-batchCollection
}

// deposit takes a Genies NFT and adds it to the Collections dictionary
// deposit takes a AllDay NFT and adds it to the Collections dictionary
pub fun deposit(token: @NonFungibleToken.NFT) {

// Find the bucket this corresponds to
Expand Down Expand Up @@ -120,7 +121,7 @@ pub contract GeniesShardedCollection {
return ids
}

// borrowNFT Returns a borrowed reference to a Genies NFT in the Collection
// borrowNFT Returns a borrowed reference to a AllDay NFT in the Collection
// so that the caller can read data and call methods from it
pub fun borrowNFT(id: UInt64): &NonFungibleToken.NFT {
post {
Expand All @@ -134,7 +135,7 @@ pub contract GeniesShardedCollection {
return self.collections[bucket]?.borrowNFT(id: id)!
}

// borrowGeniesNFT Returns a borrowed reference to a Genies NFT in the Collection
// borrowMomentNFT Returns a borrowed reference to a AllDay NFT in the Collection
// so that the caller can read data and call methods from it
// They can use this to read its setID, playID, serialNumber,
// or any of the setData or Play Data associated with it by
Expand All @@ -144,12 +145,12 @@ pub contract GeniesShardedCollection {
// Parameters: id: The ID of the NFT to get the reference for
//
// Returns: A reference to the NFT
pub fun borrowGeniesNFT(id: UInt64): &Genies.NFT? {
pub fun borrowMomentNFT(id: UInt64): &AllDay.NFT? {

// Get the bucket of the nft to be borrowed
let bucket = id % self.numBuckets

return self.collections[bucket]?.borrowGeniesNFT(id: id) ?? nil
return self.collections[bucket]?.borrowMomentNFT(id: id) ?? nil
}

// If a transaction destroys the Collection object,
Expand All @@ -166,7 +167,7 @@ pub contract GeniesShardedCollection {

init() {
// Set the named paths
self.CollectionStoragePath = /storage/GeniesShardedNFTCollection
self.CollectionStoragePath = /storage/AllDayShardedNFTCollection
}
}

Loading