leather-io / extension

Leather browser extension
https://leather.io
MIT License
305 stars 143 forks source link

(Recently) Bought Stacks NFT's not showing up in Leather, while displayed on gamma.io #4812

Closed 314159265359879 closed 9 months ago

314159265359879 commented 10 months ago

I thought it could be related to a specific series but some of these series are showing up in another wallet without issue. Whereas this wallet has no Stacks NFT's loading in the collectables area. On gamma, looking at the profile they do show. Edge Browser, Wallet version 6.22.0

image

Reinstalling the extension made no difference. There are no console reports

pete-watters commented 9 months ago

Linking original Stacks NFT PR

I checked this and I can confirm that for our test account:

If I log I can see that in useGetNonFungibleTokenHoldingsQuery I get this data object with data.results containing the NFT:

{
    "status": "success",
    "fetchStatus": "idle",
    "isLoading": false,
    "isSuccess": true,
    "isError": false,
    "isInitialLoading": false,
    "data": {
        "limit": 50,
        "offset": 0,
        "total": 1,
        "results": [
            {
                "asset_identifier": "SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music::worry-nft-music",
                "value": {
                    "hex": "0x010000000000000000000000000000004b",
                    "repr": "u75"
                },
                "block_height": 135761,
                "tx_id": "0x2efafda6c6e46f5b86091e86a00bf8ab138dba58dcfdaed4941cdefbba8f89d1"
            }
        ]
    },
    "dataUpdatedAt": 1705481440940,
    "error": null,
    "errorUpdatedAt": 0,
    "failureCount": 0,
    "failureReason": null,
    "errorUpdateCount": 0,
    "isFetched": true,
    "isFetchedAfterMount": false,
    "isFetching": false,
    "isRefetching": false,
    "isLoadingError": false,
    "isPaused": false,
    "isPlaceholderData": false,
    "isPreviousData": false,
    "isRefetchError": false,
    "isStale": false
}

It seems to fail then when moving on to calling fetchNonFungibleTokenMetadata(client, limiter)(principal, tokenId) with no result returned.

I think this bug relates to how fetchNonFungibleTokenMetadata is being called and the curried function not working properly:

function fetchNonFungibleTokenMetadata(client: TokenMetadataClient, limiter: RateLimiter) {
  return (principal: string, tokenId: number) => async () => {
    await limiter.removeTokens(1);
    return client.tokensApi.getNftMetadata(principal, tokenId);
  };
}

I can't spend more time on it now but can check later. Do you have any ideas here @fbwoolf ?

fbwoolf commented 9 months ago

I would be surprised if that curried fn is broken 🤔 only bc it has been in use for a long time. It def has been a prob in the past where the metadata api just doesn't have the data we need, or is broken in some way on its own, is that possible here?

fbwoolf commented 9 months ago

Yeah, the api is returning Token not found here: https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/0x010000000000000000000000000000004b

fbwoolf commented 9 months ago

@314159265359879 do you want to close the issue here and reopen in the Hiro metadata api repo to let them know?

pete-watters commented 9 months ago

Yeah, the api is returning Token not found here: https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/0x010000000000000000000000000000004b

That's great, thanks @fbwoolf ! I wasn't sure of the next part of the logic / if it was working before

314159265359879 commented 9 months ago

Yeah, the api is returning Token not found here: https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/0x010000000000000000000000000000004b or https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/75

I expect some of them not to show like the worry nft (due to this issue https://github.com/hirosystems/token-metadata-api/issues/140)... but none at all showing is what surprises me the most. These tokens in the wallet will return some metadata for example: https://api.hiro.so/metadata/v1/nft/SP3N7Y3K01Y24G9JC1XXA13RQXXCY721WAVBMMD38.alex-anniversary-series/1452 https://api.hiro.so/metadata/v1/nft/SP3QSAJQ4EA8WXEDSRRKMZZ29NH91VZ6C5X88FGZQ.crashpunks-v2/5559

fbwoolf commented 9 months ago

https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/75

I expect some of them not to show like the worry nft (due to this issue hirosystems/token-metadata-api#140)... but none at all showing is what surprises me the most. These tokens in the wallet will return some metadata for example: https://api.hiro.so/metadata/v1/nft/SP3N7Y3K01Y24G9JC1XXA13RQXXCY721WAVBMMD38.alex-anniversary-series/1452 https://api.hiro.so/metadata/v1/nft/SP3QSAJQ4EA8WXEDSRRKMZZ29NH91VZ6C5X88FGZQ.crashpunks-v2/5559

Thx, I forgot to do hexToCV for the tokenId. Def seems a bit odd as I've been looking into it. The nft holdings endpoint is only returning 1 in the query but multiple when executed with the address here: https://docs.hiro.so/api/non-fungible-token-holdings. I will reassign this to myself and keep looking into it.

314159265359879 commented 9 months ago

https://api.hiro.so/metadata/v1/nft/SPGGAEQWA7Y9HRZY5T0XJCEYEZ28J6RKCCC1HP9M.worry-nft-music/75

I expect some of them not to show like the worry nft (due to this issue hirosystems/token-metadata-api#140)... but none at all showing is what surprises me the most. These tokens in the wallet will return some metadata for example: https://api.hiro.so/metadata/v1/nft/SP3N7Y3K01Y24G9JC1XXA13RQXXCY721WAVBMMD38.alex-anniversary-series/1452 https://api.hiro.so/metadata/v1/nft/SP3QSAJQ4EA8WXEDSRRKMZZ29NH91VZ6C5X88FGZQ.crashpunks-v2/5559

Thx, I forgot to do hexToCV for the tokenId. Def seems a bit odd as I've been looking into it. The nft holdings endpoint is only returning 1 in the query but multiple when executed with the address here: https://docs.hiro.so/api/non-fungible-token-holdings. I will reassign this to myself and keep looking into it.

NFT's in the explorer look odd too, I noticed when Rafael asked for more info on the API issue. He's having He1Dar take a look https://github.com/hirosystems/explorer/issues/1436

fbwoolf commented 9 months ago

@kyranjamie any thoughts here? It appears the last work done in these hooks was in this commit by you: https://github.com/leather-wallet/extension/commit/559fba678bcb67cb0218f7862a44c629d9fe47cf

I am struggling to figure out where the bug would be on our end. If I put the test address in this I do get back 12 items in the array, but our only gets 1 and doesn't display anything... 🤔

https://docs.hiro.so/api/non-fungible-token-holdings

kyranjamie commented 9 months ago

test address?

fbwoolf commented 9 months ago

test address?

It is our shared test account.

314159265359879 commented 9 months ago

I have asked some more questions, looks like Hiro did some more investigating too. https://github.com/hirosystems/explorer/issues/1436#issuecomment-1905824237

Account 1 and Account 2 both also have a BNS name now. 1 with out zonefile, 2 with zonefile... to see if that mattered. No difference.

kyranjamie commented 9 months ago

The API returns different results than we expect.

Anchored https://api.hiro.so/extended/v1/tokens/nft/holdings?principal=SP2417H88DQFN7FNDMSKM9N0B3Q6GNGEM40W7ZAZW

With unanchored=true param https://api.hiro.so/extended/v1/tokens/nft/holdings?principal=SP2417H88DQFN7FNDMSKM9N0B3Q6GNGEM40W7ZAZW&limit=50&unanchored=true

We're querying with the unanchored flag in the wallet, to reflect updates more quickly. My understanding the unanchored param should return the same, in addition to any NFTs in unanchored blocks?

cc/ @zone117x @rafaelcr, can you confirm?

rafaelcr commented 9 months ago

Might be related to https://github.com/hirosystems/stacks-blockchain-api/issues/1843

I'm investigating