nft-storefront icon indicating copy to clipboard operation
nft-storefront copied to clipboard

Listing via Catalog Multiple Collections Will Conflict

Open alliu930410 opened this issue 3 years ago • 0 comments

The sell_item_via_catalog tx here https://github.com/onflow/nft-storefront/blob/main/transactions/sell_item_via_catalog.cdc looks a bit confusing.

On line 39 it specifies a private path for capability by

// We need a provider capability, but one is not provided by default so we create one if needed.
let nftCollectionProviderPrivatePath = /private/nftCollectionProviderForNFTStorefront

and on line 50 it's checking if the capability exists and links the current collection identifier's collection storage to /private/nftCollectionProviderForNFTStorefront if not found.

if !acct.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic, MetadataViews.ResolverCollection}>(nftCollectionProviderPrivatePath).check() {
    acct.link<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic, MetadataViews.ResolverCollection}>(nftCollectionProviderPrivatePath, target: value.collectionData.storagePath)
}

How does this support multiple collections? As if collection A is linked to /private/nftCollectionProviderForNFTStorefront in the first transaction and we try to list collection B, the check on line 50 will always return true as the capability exists already (but for collection A) and hence collection B will not be linked to /private/nftCollectionProviderForNFTStorefront in the second transaction.

Furthermore, if a user is trying to sell tokenId 0 of both collection A and collection B, a user will end up selling tokenId 0 in collection A twice with the above process.

alliu930410 avatar Nov 04 '22 19:11 alliu930410