Conversation
|
|
||
| execute { | ||
| let listingResourceIDs: [Uint64] = [{{.listingResourceIDs}}] | ||
| let listingResourceIDs: [Uint64] = {{.ListingResourceIDs}} |
There was a problem hiding this comment.
why are you removing the array?
There was a problem hiding this comment.
because I'm passing in an array, not a string with ids.
There was a problem hiding this comment.
|
|
||
| execute { | ||
| let listingResourceIDs: [Uint64] = [{{.listingResourceIDs}}] | ||
| let listingResourceIDs: [Uint64] = {{.ListingResourceIDs}} |
| let nftIds: [UInt64] | ||
|
|
||
| prepare(acct: auth(Storage, Capabilities) &Account) { | ||
| self.nftIds = {{.NftIds}} |
There was a problem hiding this comment.
| self.nftIds = {{.NftIds}} | |
| self.nftIds = [{{.NftIds}}] |
There was a problem hiding this comment.
Even though I'm passing in a []uint64? same as above? Or would you rather it be a connected list of ids in a string?
| let PrivateCollectionPath = /storage/{{.NFTProductName}}CollectionProviderForNFTStorefront | ||
|
|
||
| // Temporary variable to handle capability assignment | ||
| var provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? = | ||
| acct.storage.copy<Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>>(from: PrivateCollectionPath) | ||
|
|
||
| if provider == nil { | ||
| provider = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>({{.NFTProductName}}.CollectionStoragePath) | ||
| acct.capabilities.storage.getController(byCapabilityID: provider!.id)!.setTag("{{.NFTProductName}}CollectionProviderForNFTStorefront") | ||
| // Save the capability to the account storage | ||
| acct.storage.save(provider!, to: PrivateCollectionPath) | ||
| } | ||
|
|
||
| self.nftProvider = provider | ||
| assert(self.nftProvider?.borrow() != nil, message: "Missing or mis-typed {{.NFTProductName}}.Collection provider") |
There was a problem hiding this comment.
we should use cap controllers https://github.com/onflow/nft-storefront/blob/main/transactions-v1/sell_item.cdc#L23
| let PrivateCollectionPath = /storage/{{.NFTProductName}}CollectionProviderForNFTStorefront | |
| // Temporary variable to handle capability assignment | |
| var provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? = | |
| acct.storage.copy<Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>>(from: PrivateCollectionPath) | |
| if provider == nil { | |
| provider = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>({{.NFTProductName}}.CollectionStoragePath) | |
| acct.capabilities.storage.getController(byCapabilityID: provider!.id)!.setTag("{{.NFTProductName}}CollectionProviderForNFTStorefront") | |
| // Save the capability to the account storage | |
| acct.storage.save(provider!, to: PrivateCollectionPath) | |
| } | |
| self.nftProvider = provider | |
| assert(self.nftProvider?.borrow() != nil, message: "Missing or mis-typed {{.NFTProductName}}.Collection provider") | |
| var nftProviderCap: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? = nil | |
| // check if there is an existing capability/capability controller for the storage path | |
| let nftCollectionControllers = acct.capabilities.storage.getControllers(forPath: collectionData.storagePath) | |
| for controller in nftCollectionControllers { | |
| if let maybeProviderCap = controller.capability as? Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? { | |
| nftProviderCap = maybeProviderCap | |
| break | |
| } | |
| } | |
| // if there are no capabilities created for that storage path | |
| // or if existing capability is no longer valid, issue a new one | |
| if nftProviderCap == nil || nftProviderCap?.check() ?? false { | |
| nftProviderCap = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>( | |
| collectionData.storagePath | |
| ) | |
| } | |
| assert(nftProviderCap?.check() ?? false, message: "Could not assign Provider Capability") | |
| self.nftProvider = nftProviderCap! |
| if !acct.capabilities.get<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionPublicPath)!.check() { | ||
| acct.capabilities.unpublish({{.NFTProductName}}.CollectionPublicPath) | ||
| acct.capabilities.publish( | ||
| acct.capabilities.storage.issue<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionStoragePath), | ||
| at: {{.NFTProductName}}.CollectionPublicPath | ||
| ) | ||
| } |
There was a problem hiding this comment.
| if !acct.capabilities.get<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionPublicPath)!.check() { | |
| acct.capabilities.unpublish({{.NFTProductName}}.CollectionPublicPath) | |
| acct.capabilities.publish( | |
| acct.capabilities.storage.issue<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionStoragePath), | |
| at: {{.NFTProductName}}.CollectionPublicPath | |
| ) | |
| } | |
| if !acct.capabilities.get<&{{.NFTProductName}}.Collection>(collectionData.publicPath)!.check() { | |
| acct.capabilities.unpublish(collectionData.publicPath) | |
| acct.capabilities.publish( | |
| acct.capabilities.storage.issue<&{{.NFTProductName}}.Collection>(collectionData.storagePath), | |
| at: collectionData.publicPath | |
| ) | |
| } |
|
|
||
|
|
||
| let collectionRef = acct | ||
| .capabilities.borrow<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionPublicPath) |
There was a problem hiding this comment.
| .capabilities.borrow<&{{.NFTProductName}}.Collection>({{.NFTProductName}}.CollectionPublicPath) | |
| .capabilities.borrow<&{{.NFTProductName}}.Collection>(collectionData.publicPath) |
atlas/embed.go
Outdated
| NFTProductName string | ||
| NFTContractAddress string | ||
| NFTStorefrontV2ContractAddress string | ||
| NFTIDs string // comma-separated, e.g. "123,456" |
There was a problem hiding this comment.
should be an array of uint64, you do the conversion to comma-separated string in ListNFTStorefrontV2TxScript. Same with the prices below. should be an array of integers(price in cents) and you do the conversion in the same function. SaleCommissionAmount should also be an integer(price in cent)
| } | ||
| } | ||
|
|
||
| func TestDelistNFTStorefrontOutput(t *testing.T) { |
There was a problem hiding this comment.
these tests are not actually testing anything. It just logs stuff
There was a problem hiding this comment.
I know, it helps see what is getting inputted
Changes