onflow / flow-nft

The non-fungible token standard on the Flow blockchain
https://onflow.org
The Unlicense
465 stars 169 forks source link

Add NFT Storage Requirement to Collection and `forEachID()` #211

Closed joshuahannan closed 7 months ago

joshuahannan commented 7 months ago

Description

FLIP

Based on this discussion in discord and this comment on the NFT standard PR, we have come to the conclusion that it probably makes sense to enforce how NFTs are stored for standardization and in this specific case, to allow projects to easily iterate through IDs in a collection that has many stored NFTs.

Enforcing the ownedNFTs field does not restrict projects who want to store their NFTs in unique ways because they can just ignore the field if they want, so having it for the 99% of projects who do and will follow it is very useful.


For contributor use:

cody-evaluate commented 7 months ago

looks great, one thing i would add is a default implementation for Collection.getLength() as:

return self.ownedNFTs.length

then you could remove the getLength() implementation from ExampleNFT.cdc to make it more concise

@joshuahannan