Skip to content
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

Recommendation: Include NFT Collection Public Interface Methods in Type-Specific Public Interface #55

Closed
rheaplex opened this issue Sep 28, 2021 · 0 comments

Comments

@rheaplex
Copy link

This makes it easier to use the public functions via a single interface.

e.g.:

https://github.com/dapperlabs/nba-smart-contracts/blob/master/contracts/TopShot.cdc#L525

https://github.com/onflow/kitty-items/blob/master/cadence/contracts/KittyItems.cdc#L46

For PackNFT, this would be:

    pub resource interface PackNFTCollectionPublic {
        pub fun deposit(token: @NonFungibleToken.NFT)
        pub fun getIDs(): [UInt64]
        pub fun borrowNFT(id: UInt64): &NonFungibleToken.NFT
        pub fun borrowPackNFT(id: UInt64): &PackNFT.NFT? {
            // If the result isn't nil, the id of the returned reference
            // should be the same as the argument to the function
            post {
                (result == nil) || (result?.id == id):
                    "Cannot borrow PackNFT reference: The ID of the returned reference is incorrect"
            }
        }
    }
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

No branches or pull requests

1 participant