Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions pds/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var (
PDSOpenPackNFT []byte
//go:embed transactions/pds/reveal_packNFT.cdc
PDSRevealPackNFT []byte
//go:embed transactions/pds/reveal_packNFT_as_box.cdc
PDSRevealPackNFTAsBox []byte
//go:embed transactions/pds/create_distribution.cdc
PDSCreateDistribution []byte
//go:embed transactions/pds/update_distribution.cdc
Expand Down
50 changes: 50 additions & 0 deletions pds/transactions/pds/reveal_packNFT_as_box.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import PDS from "PDS"
import PackNFT from "PackNFT"
import NonFungibleToken from "NonFungibleToken"
import MetadataViews from "MetadataViews"

transaction (
distId: UInt64,
packId: UInt64,
nftContractAddrs: [Address],
nftContractNames: [String],
nftIds: [UInt64],
salt: String,
owner: Address,
openRequest: Bool,
collectionStoragePath: StoragePath?
) {
prepare(pds: auth(BorrowValue) &Account) {
let collectionData = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
?? panic("ViewResolver does not resolve NFTCollectionData view")

let cap = pds.storage.borrow<auth(PDS.Operate) &PDS.DistributionManager>(from: PDS.DistManagerStoragePath)
?? panic("pds does not have Dist manager")
let p = PackNFT.borrowPackRepresentation(id: packId)
?? panic ("No such pack")

if openRequest && p.status == PackNFT.Status.Revealed {
let recvAcct = getAccount(owner)
let recv = recvAcct.capabilities.borrow<&{NonFungibleToken.CollectionPublic}>(collectionData.publicPath)
?? panic("Unable to borrow Collection Public reference for recipient")
cap.openPackNFT(
distId: distId,
packId: packId,
nftContractAddrs: nftContractAddrs,
nftContractNames: nftContractNames,
nftIds: nftIds,
recvCap: recv,
collectionStoragePath: collectionStoragePath
)
} else {
cap.revealPackNFT(
distId: distId,
packId: packId,
nftContractAddrs: nftContractAddrs,
nftContractNames: nftContractNames,
nftIds: nftIds,
salt: salt
)
}
}
}