-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c976fb4
commit 291b9c9
Showing
1 changed file
with
17 additions
and
18 deletions.
There are no files selected for viewing
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
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.") | ||
} | ||
} |