@@ -15,7 +15,7 @@ transaction() {
1515 let userStorefront : auth (NFTStorefront.CreateListing ) &NFTStorefront.Storefront
1616
1717 // Capability to withdraw user's NFTs for listing
18- let userNFTWithdrawCap : Capability <auth (NonFungibleToken.Withdraw ) &{{. NFTProductName }}. Collection >?
18+ let userNFTWithdrawCap : Capability <auth (NonFungibleToken.Withdraw ) &{NonFungibleToken . Collection } >?
1919
2020 // Capability to receive DUC payment
2121 let userDUCReceiverCap : Capability <&{FungibleToken .Receiver }>
@@ -24,9 +24,8 @@ transaction() {
2424 let dapperVault : auth (FungibleToken.Withdraw ) &DapperUtilityCoin.Vault
2525 let initialDapperBalance : UFix64
2626
27- // Issuer's NFT collection and address
28- let issuerCollection : &NonFungibleToken.Collection
29- let issuerAddress : Address
27+ // Issuer's NFT collection
28+ let issuerCollection : &{NonFungibleToken .Collection }
3029
3130 prepare (user : auth (Storage , Capabilities ) &Account , dapper : auth (BorrowValue ) &Account ) {
3231 // Initialize NFT IDs and buyback prices
@@ -67,26 +66,22 @@ transaction() {
6766 // Record Dapper's DUC balance
6867 self .initialDapperBalance = self .dapperVault .balance
6968
70- // Record issuer's address
71- self .issuerAddress = issuer .address
72-
7369 // Borrow issuer's NFT collection
74- self .issuerCollection = getAccount (self . issuerAddress ).capabilities .borrow <&NonFungibleToken.Collection >({{.NFTProductName }}.CollectionPublicPath )
70+ self .issuerCollection = getAccount (0x{{. NFTContractAddress }} ).capabilities .borrow <&{ NonFungibleToken .Collection } >({{.NFTProductName }}.CollectionPublicPath )
7571 ?? panic (" Missing issuer NFT collection" )
7672 }
7773
7874 pre {
7975 self .nftIDs .length == self .prices .length : " NFTs/prices length mismatch"
80- self .issuerAddress == 0x{{.NFTContractAddress }}: " Must be NFT contract owner"
8176 }
8277
8378 execute {
8479 // Gather active listings in user's storefront
8580 let listingIDsByNFTID : {UInt64 : UInt64 } = {}
86- for id in self .userStorefront .getListingIDs () {
87- let details = self .userStorefront .borrowListing (listingResourceID : id )! .getDetails ()
81+ for listingID in self .userStorefront .getListingIDs () {
82+ let details = self .userStorefront .borrowListing (listingResourceID : listingID )! .getDetails ()
8883 if ! details .purchased {
89- listingIDsByNFTID [details .nftID ] = id
84+ listingIDsByNFTID [details .nftID ] = listingID
9085 }
9186 }
9287
@@ -108,7 +103,7 @@ transaction() {
108103 // Dapper purchases NFT and deposits in issuer's collection
109104 let listing = self .userStorefront .borrowListing (listingResourceID : listingID )!
110105 self .issuerCollection .deposit (token : <- listing .purchase (payment : <- self .dapperVault .withdraw (amount : self .prices [i ])))
111- NFTStorefront .cleanup (listingResourceID : listingID )
106+ self . userStorefront .cleanup (listingResourceID : listingID )
112107 }
113108 }
114109
0 commit comments