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

NFL NFT contract #1

merged 38 commits into from
Nov 2, 2021

Conversation

sadief
Copy link
Contributor

@sadief sadief commented Sep 22, 2021

First pass at updating the Genies contract for NFL. A few main things:

  • Renamed Genies -> Showdown (working title for NFL project, not finalized yet)
  • Removed advancing of a series as we can now have multiple series open at once.
  • Remove Set/Collection IDs from Series
  • Added new entity -> Plays
  • Updated Editions to require a SeriesID, SetID, PlayID
  • Update Moment minting to only happen when the maxMintSize has not been exceeded

I haven't built in the logic for validating that the SetID/PlayID combo has not been used in a previous Edition, or the logic for properly keeping track of minted moments, but wanted to get a sense check of how this looks so far. I've added some comments to a few things I'm a little hazy on.

Copy link

@rheaplex rheaplex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entity hierarchy and the member variables look good!

The Genies file should be renamed. 🙂

I've added comments, if any of them are useful that's great and if any aren't let me know how I can improve on them. 😺

}
}

// An Edition (NFT type) within a Genies collection
// A top level Edition that contains a Series, Set, and Play
//
pub resource Edition {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we do not currently enforce unique set/play for Editions. This can be implemented by adding a dictionary of Plays in a Set and checking that before creating, or by creating a UInt64 from the SetID and PlayID then storing in a contract-level dictionary if they need to be checked on-chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a stab at this (though using similar logic to the edition function so let me know if it's wacky). I think it makes sense to store the dictionary on a Set to avoid a large global dictionary which could be huge/never-ending. Here's what I added: 3b3db35

My intent was to create the dictionary on the set, then add two functions - one to check if we already have that Play within the dictionary, and one to insert a new Play. Then call these - the check in the pre-condition for creating a new Edition, and the insert before we emit the event.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that all sounds great.

When testing, keep an eye on storage usage by these structures. They shouldn't get tooooooo big, but it's good to have a benchmark for how much they may cost over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! How do you usually test how much storage a dictionary entry would take up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rheaplex just noticed this comment from a little while back! Is there a good way of testing storage costs of a dictionary?

@sadief sadief changed the title NFL NFT contract, first pass NFL NFT contract Oct 15, 2021
Comment on lines 814 to 817
self.nextSeriesID = 1
self.nextSetID = 1
self.nextPlayID = 1
self.nextEditionID = 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started the FlowIDs at 1 instead of 0 for better ease when dealing with our backend. (eg. entities that we create before minting can legit have a null FlowID, but there's a higher margin of error when we use 0 if it converts from null). Please shout if you feel strongly that this is bad practise!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rheaplex we have discussed about this before in Genies. Let us know if you have any opinions about this.

Copy link

@EricLin2004 EricLin2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't had a good chunk of time to go through everything but overall looks good

I'll probably poke around more when I have time but I shouldn't be the blocker on this one.

Copy link

@rheaplex rheaplex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Just a few comments (and an answer).

@sadief
Copy link
Contributor Author

sadief commented Oct 22, 2021

@EricLin2004 @rheaplex @judezhu Addressed comments and updated! I've also re-named the contract to AllDay which is the confirmed name for NFL (and following "TopShot" naming convention.

Copy link

@rheaplex rheaplex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Just a couple of cosmetic notes.

return &self.ownedNFTs[id] as &NonFungibleToken.NFT
}

// borrowMomentNFT gets a reference to an NFT in the collection

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly borrowAllDayNFT , although this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Product is keen on keeping Moment as our identifier - (they also might change it to something else 😅 ) but I think this way we have a bit more differentiation between a packNFT and momentNFT

Copy link
Contributor

@judezhu judezhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 GREEEEEAT work!

@sadief sadief merged commit 0bb113a into main Nov 2, 2021
@rheaplex
Copy link

rheaplex commented Nov 5, 2021

👍👍👍👍👍🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants