Skip to content
Open
Changes from all commits
Commits
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
17 changes: 6 additions & 11 deletions cadence-transactions/packNFT/create_new_packNFT_collection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import NonFungibleToken from 0x{{.NonFungibleToken}}
transaction() {
prepare (issuer: AuthAccount) {

// Check if account already have a PackIssuer resource, if so destroy it
if issuer.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath) != nil {
issuer.unlink(PackNFT.CollectionPublicPath)
let p <- issuer.load<@PackNFT.Collection>(from: PackNFT.CollectionStoragePath)
destroy p
// Only initialize account if doesn't have a PackNFT.Collection resource
if issuer.borrow<&PackNFT.Collection>(from: PackNFT.CollectionStoragePath) == nil {
issuer.save(<-PackNFT.createEmptyCollection(), to: PackNFT.CollectionStoragePath);
issuer.link<&{NonFungibleToken.CollectionPublic}>(PackNFT.CollectionPublicPath, target: PackNFT.CollectionStoragePath)
?? panic("Could not link PackNFT.Collection Pub Path");
}

issuer.save(<- PackNFT.createEmptyCollection(), to: PackNFT.CollectionStoragePath);

issuer.link<&{NonFungibleToken.CollectionPublic}>(PackNFT.CollectionPublicPath, target: PackNFT.CollectionStoragePath)
?? panic("Could not link Collection Pub Path");
}
}
}