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

Storefront get_listing_details script does not work as written

Open bm-nJoi opened this issue 4 years ago • 2 comments

NFT Storefront contract function for ListingDetails is not called correctly by scripts

pub fun getDetails(): ListingDetails {
    return self.details
}

the script in this repo:

pub fun main(account: Address, listingResourceID: UInt64): [UInt64] {
    let storefrontRef = account
        .getCapability<&NFTStorefront.Storefront{NFTStorefront.StorefrontPublic}>(
            NFTStorefront.StorefrontPublicPath
        )
        .borrow()
        ?? panic("Could not borrow public storefront from address")

    let listing = storefrontRef.borrowListing(listingResourceID: listingResourceID)
        ?? panic("No item with that ID")
    
    return listing.getDetails()
}

it returns an array of uint64s? that doesnt work.

bm-nJoi avatar Oct 20 '21 19:10 bm-nJoi

and this comment is a remnant from the kitty version of this contract:

        // borrowSaleItem
        // Returns a read-only view of the SaleItem for the given listingID if it is contained by this collection.
        //
        pub fun borrowListing(listingResourceID: UInt64): &Listing{ListingPublic}? {
            if self.listings[listingResourceID] != nil {
                return &self.listings[listingResourceID] as! &Listing{ListingPublic}
            } else {
                return nil
            }
        }

bm-nJoi avatar Oct 21 '21 00:10 bm-nJoi

Thanks @bm-nJoi. In both cases, these look like typos in the Cadence source code. We'll work on a fix.

psiemens avatar Oct 22 '21 16:10 psiemens