Page MenuHomePhabricator

[Cashtab] Upgrade NFT Page and add support for sending NFTs
ClosedPublic

Authored by bytesofman on Fri, Apr 26, 19:43.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCf780718fe47e: [Cashtab] Upgrade NFT Page and add support for sending NFTs
Summary

Upgrade token cache to get groupTokenId for NFTs. This info is available in the tx call and never changes, so it should be cached.

Modify the token/ page so that, if a user visits without groupTokenId in cache, Cashtab will fetch this info and update the cache with it. Also ensure that Cashtab will fetch cached token info for the nft parent token (now that we support sends, it is possible for a Cashtab user to receive an NFT child while not having the parent in cache).

The cache changes could have stood alone, but I started this diff to add the NFT send feature, and discovered these would be needed first in the process of adding. Since the functions for sending already exist, and we are already upgrading the NFT UI, go ahead and implement Send here as well.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

back out unrelated dep changes

bytesofman retitled this revision from [Cashtab] Support sending NFTs to [Cashtab] Upgrade NFT Page and add support for sending NFTs.Fri, Apr 26, 19:48
bytesofman edited the summary of this revision. (Show Details)

add unit test for adding an NFT to cache

remove debug logs, do not link to an NFT if you do not have it in your wallet

bytesofman added inline comments.
cashtab/src/components/Etokens/Token/index.js
1177 ↗(On Diff #47449)

we only link to the action page for this NFT if the user has this NFT in their wallet

(we render all NFTs in a collection)

1184 ↗(On Diff #47449)

image.png (518×461 px, 129 KB)

after sending an NFT

378 ↗(On Diff #47447)

add isNftParent -- this changes when we navigate from a child NFT to its parent. In this case, we also want to load and render the child NFTs of this collection.

cashtab/src/slpv1/index.js
722 ↗(On Diff #47448)

mistake that we did not have a param for address here before, as this function is for sending, not minting / genesis

emack requested changes to this revision.Sat, Apr 27, 15:11
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/chronik/index.js
482–484 ↗(On Diff #47449)

I can see further down the useEffect() block updates the token cache if there is no collection ID, but in this segment it reads where if the tx type for this NFT child is a normal send (i.e. txType !== 'GENESIS', the groupTokenId is not updated in cache?

cashtab/src/components/Etokens/__tests__/TokenActions.test.js
733 ↗(On Diff #47449)

don't think you need this, it'll clog up an already bloated the test suite output

cashtab/src/slpv1/index.js
733 ↗(On Diff #47449)

value: 546

Will the VIP min fee changes from D16057 apply here too?

This revision now requires changes to proceed.Sat, Apr 27, 15:11
bytesofman marked 3 inline comments as done.

rebase, remove debug log

cashtab/src/chronik/index.js
482–484 ↗(On Diff #47449)

This function only handles the genesis tx of a given token id. We are using txType === 'GENESIS' here to make sure we are looking at the right tokenEntry -- i.e. the one that covers the minting of this NFT -- as that is the tokenEntry that will have groupTokenId.

The other tokenEntry will be about burning the NFT Mint input.

A summary of how we are changing this function. If we see a tokenId for the first time, and we see that it is an SLP1 NFT child -- make sure to get its groupTokenId and save that in cache.

in this segment it reads where if the tx type for this NFT child is a normal send (i.e. txType !== 'GENESIS', the groupTokenId is not updated in cache?

Because this function is only getting a GENESIS tx, we don't expect to see this. Potentially we could be dealing with an ALP tx that is both a genesis and a send tx. In this case, filtering for the tokenEntry with GENESIS should give us the same impact (tho we will never have an ALP tx with SLP_TOKEN_TYPE_NFT1_CHILD so kind of moot).

cashtab/src/slpv1/index.js
733 ↗(On Diff #47449)

yes, tho this is implemented at the sendXec callsite, so not relevant to functions that create target outputs.

This revision is now accepted and ready to land.Sat, Apr 27, 22:53

minor version bump, extension version bump, rebase