Skip to content

Commit

Permalink
Debugging tx
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 11, 2024
1 parent c976fb4 commit 291b9c9
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions cadence/transactions/mint_moment.cdc
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import "TopShot"

transaction {

let admin: auth(AdminEntitlement) &TopShot.Admin
let admin: &TopShot.Admin
let borrowedSet: &TopShot.Set
let receiverRef: &{TopShot.MomentCollectionPublic}

prepare(acct: auth(Storage, Capabilities) &Account) {
// Borrow the admin resource
self.admin = acct.capabilities.storage.borrow<&TopShot.Admin>(
from: /storage/TopShotAdmin
) ?? panic("Can't borrow admin resource")
prepare(acct: AuthAccount) {
// Borrow the admin resource from the account's storage
self.admin = acct.borrow<&TopShot.Admin>(from: /storage/TopShotAdmin)
?? panic("Cannot borrow admin resource from storage")

// Borrow the Set resource
// Borrow the Set resource using the admin's borrowSet function
self.borrowedSet = self.admin.borrowSet(setID: 1)

// Borrow the recipient's MomentCollectionPublic capability
let receiverRef = acct.capabilities.borrow<&{TopShot.MomentCollectionPublic}>(
/public/MomentCollection
) ?? panic("Can't borrow collection reference")
// Borrow the recipient's MomentCollectionPublic reference
self.receiverRef = acct.getCapability<&{TopShot.MomentCollectionPublic}>(/public/MomentCollection)
.borrow()
?? panic("Cannot borrow the MomentCollection reference")
}

// Mint moments and return them as a collection
let collection <- self.borrowedSet.batchMintMoment(playID: 3, quantity: 3)
execute {
// Mint moments using the borrowed set
let mintedMoments <- self.borrowedSet.batchMintMoment(playID: 3, quantity: 3)

// Deposit the minted moments into the recipient's collection
receiverRef.batchDeposit(tokens: <-collection)
}
self.receiverRef.batchDeposit(tokens: <-mintedMoments)

execute {
log("Plays minted")
log("Minted and deposited moments into the recipient's collection.")
}
}

0 comments on commit 291b9c9

Please sign in to comment.