Last active
March 16, 2021 20:56
-
-
Save polluterofminds/0cc4e3b18c18a9095783561dd0099043 to your computer and use it in GitHub Desktop.
3 - PinataPartyContract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub resource Collection: NFTReceiver { | |
pub var ownedNFTs: @{UInt64: NFT} | |
pub var metadataObjs: {UInt64: { String : String }} | |
init () { | |
self.ownedNFTs <- {} | |
self.metadataObjs = {} | |
} | |
pub fun withdraw(withdrawID: UInt64): @NFT { | |
let token <- self.ownedNFTs.remove(key: withdrawID)! | |
return <-token | |
} | |
pub fun deposit(token: @NFT, metadata: {String : String}) { | |
self.metadataObjs[token.id] = metadata | |
self.ownedNFTs[token.id] <-! token | |
} | |
pub fun idExists(id: UInt64): Bool { | |
return self.ownedNFTs[id] != nil | |
} | |
pub fun getIDs(): [UInt64] { | |
return self.ownedNFTs.keys | |
} | |
pub fun updateMetadata(id: UInt64, metadata: {String: String}) { | |
self.metadataObjs[id] = metadata | |
} | |
pub fun getMetadata(id: UInt64): {String : String} { | |
return self.metadataObjs[id]! | |
} | |
destroy() { | |
destroy self.ownedNFTs | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment