TransactionSEALED
▪□◇*▫^╲$?╱$■@?!▒?▓%@▫○$▪▒■▪#^%?○□#╲@*◆▓^█■?╳◇◇▒&◆%~$?▒▪╳░▓●▓▒□○&
Transaction ID
Execution Fee
0.00106 FLOWExecution Error
Error Code: 1101
panic: nft not found
Error ContextLine 49
44
45 // Borrow the listing
46 self.listing = self.storefront.borrowListing(listingResourceID: listingResourceID)
47 ?? panic("Listing not found")
48 let listingDetails = self.listing.getDetails()
49 let nftRef = self.listing.borrowNFT() ?? panic("nft not found")
50
51 if nftReceiverAddress == buyer.address {
52 self.collectionCap = buyer.capabilities.get<&{NonFungibleToken.CollectionPublic}>(value.collectionData.publicPath)
53 // unlink and relink first, if it still isn't working, then we will try to save it!
54 if !self.collectionCap.check() {Call Stack
→
Raw Error
[Error Code: 1101] error caused by: 1 error occurred: * transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed: error: panic: nft not found --> 3fe8665bb379b1cc5a9bce050a6aae830ac3c8f66483e8db7c3200b76d5f79a5:49:49 | 49 | let nftRef = self.listing.borrowNFT() ?? panic("nft not found") | ^^^^^^^^^^^^^^^^^^^^^^ Was this error unhelpful? Consider suggesting an improvement here: https://github.com/onflow/cadence/issues.
Transaction Summary
Contract CallCalled DapperUtilityCoin, FungibleToken, NonFungibleToken +4 more
Script Arguments
0storefrontAddressAddress
1listingResourceIDUInt64
204509165276623
2commissionRecipientAddress
3collectionIdentifierString
NBATopShot
4nftReceiverAddressAddress
Cadence Script
1import DapperUtilityCoin from 0xead892083b3e2c6c
2import FungibleToken from 0xf233dcee88fe0abe
3import NonFungibleToken from 0x1d7e57aa55817448
4import MetadataViews from 0x1d7e57aa55817448
5import NFTCatalog from 0x49a7cda3a1eecc29
6import NFTStorefrontV2 from 0x3cdbb3d569211ff3
7import HybridCustody from 0xd8a7e05a7ac670c0
8
9// Purchase a listing from Flowty's NFT Storefront
10
11transaction(storefrontAddress: Address, listingResourceID: UInt64, commissionRecipient: Address, collectionIdentifier: String, nftReceiverAddress: Address) {
12 let paymentVault: @{FungibleToken.Vault}
13 let collection: &{NonFungibleToken.CollectionPublic}
14 var collectionCap: Capability<&{NonFungibleToken.CollectionPublic}>
15 let storefront: &NFTStorefrontV2.Storefront
16 let listing: &{NFTStorefrontV2.ListingPublic}
17 var commissionRecipientCap: Capability<&{FungibleToken.Receiver}>?
18 let balanceBeforeTransfer: UFix64
19 let mainPaymentVault: auth(FungibleToken.Withdraw) &DapperUtilityCoin.Vault
20 let listingAcceptor: auth(NFTStorefrontV2.Acceptor) &NFTStorefrontV2.Storefront
21
22 prepare(dapper: auth(BorrowValue) &Account, buyer: auth(Storage, Capabilities) &Account) {
23 if buyer.storage.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil {
24 // Create a new empty Storefront
25 let storefront <- NFTStorefrontV2.createStorefront()
26 // save it to the account
27 buyer.storage.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath)
28 // create a public capability for the Storefront, first unlinking to ensure we remove anything that's already present
29 buyer.capabilities.unpublish(NFTStorefrontV2.StorefrontPublicPath)
30 buyer.capabilities.publish(
31 buyer.capabilities.storage.issue<&NFTStorefrontV2.Storefront>(NFTStorefrontV2.StorefrontStoragePath),
32 at: NFTStorefrontV2.StorefrontPublicPath
33 )
34 }
35
36 self.listingAcceptor = buyer.storage.borrow<auth(NFTStorefrontV2.Acceptor) &NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) ?? panic("Buyer storefront is invalid")
37
38 let value = NFTCatalog.getCatalogEntry(collectionIdentifier: collectionIdentifier) ?? panic("Provided collection is not in the NFT Catalog.")
39
40 self.commissionRecipientCap = nil
41 // Access the storefront public resource of the seller to purchase the listing.
42 self.storefront = getAccount(storefrontAddress).capabilities.get<&NFTStorefrontV2.Storefront>(NFTStorefrontV2.StorefrontPublicPath)!.borrow()
43 ?? panic("Could not borrow Storefront from provided address")
44
45 // Borrow the listing
46 self.listing = self.storefront.borrowListing(listingResourceID: listingResourceID)
47 ?? panic("Listing not found")
48 let listingDetails = self.listing.getDetails()
49 let nftRef = self.listing.borrowNFT() ?? panic("nft not found")
50
51 if nftReceiverAddress == buyer.address {
52 self.collectionCap = buyer.capabilities.get<&{NonFungibleToken.CollectionPublic}>(value.collectionData.publicPath)
53 // unlink and relink first, if it still isn't working, then we will try to save it!
54 if !self.collectionCap.check() {
55 if buyer.storage.borrow<&AnyResource>(from: value.collectionData.storagePath) == nil {
56 // pull the metdata resolver for this listing's nft and use it to configure this account's collection
57 // if it is not already configured.
58 let collectionData = nftRef.resolveView(Type<MetadataViews.NFTCollectionData>())! as! MetadataViews.NFTCollectionData
59 buyer.storage.save(<-collectionData.createEmptyCollection(), to: value.collectionData.storagePath)
60 }
61
62 buyer.capabilities.unpublish(value.collectionData.publicPath)
63 buyer.capabilities.publish(
64 buyer.capabilities.storage.issue<&{NonFungibleToken.Collection}>(value.collectionData.storagePath),
65 at: value.collectionData.publicPath
66 )
67 self.collectionCap = buyer.capabilities.get<&{NonFungibleToken.CollectionPublic}>(value.collectionData.publicPath)
68 }
69 } else {
70 // signer is the parent account and nftProvider is child Account
71 // get the manager resource and borrow proxyAccount
72 let manager = buyer.storage.borrow<auth(HybridCustody.Manage) &HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath)
73 ?? panic("manager does not exist")
74 let childAcct = manager.borrowAccount(addr: nftReceiverAddress) ?? panic("nft receiver address is not a child account")
75 self.collectionCap = getAccount(nftReceiverAddress).capabilities.get<&{NonFungibleToken.CollectionPublic}>(value.collectionData.publicPath)
76 // We can't change child account links in any way
77 }
78
79 // Access the buyer's NFT collection to store the purchased NFT.
80 self.collection = self.collectionCap.borrow() ?? panic("Cannot borrow NFT collection receiver from account")
81
82 let price = listingDetails.salePrice
83
84 // Access the vault of the buyer to pay the sale price of the listing.
85 self.mainPaymentVault = dapper.storage.borrow<auth(FungibleToken.Withdraw) &DapperUtilityCoin.Vault>(from: /storage/dapperUtilityCoinVault)
86 ?? panic("Cannot borrow DapperUtilityCoin vault from buyer storage")
87 self.balanceBeforeTransfer = self.mainPaymentVault.balance
88 self.paymentVault <- self.mainPaymentVault.withdraw(amount: price)
89
90 let commissionAmount = self.listing.getDetails().commissionAmount
91 if commissionRecipient != nil && commissionAmount != 0.0 {
92 let _commissionRecipientCap = getAccount(commissionRecipient).capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
93 assert(_commissionRecipientCap.check(), message: "Commission Recipient doesn't have DapperUtilityCoin receiving capability")
94 self.commissionRecipientCap = _commissionRecipientCap
95 } else if commissionAmount == 0.0 {
96 self.commissionRecipientCap = nil
97 } else {
98 panic("Commission recipient can not be empty when commission amount is non zero")
99 }
100
101 }
102
103 execute {
104 // Purchase the NFT
105 let item <- self.listing.purchase(
106 payment: <-self.paymentVault,
107 commissionRecipient: self.commissionRecipientCap,
108 privateListingAcceptor: self.listingAcceptor
109 )
110 // Deposit the NFT in the buyer's collection.
111 self.collection.deposit(token: <-item)
112 }
113
114 post {
115 self.mainPaymentVault.balance == self.balanceBeforeTransfer: "DapperUtilityCoin leakage"
116 }
117
118}