Page MenuHomePhabricator

[Cashtab] Support send token txs with bip21 query strings
ClosedPublic

Authored by bytesofman on Thu, Nov 28, 00:47.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCabf17c6cc86e: [Cashtab] Support send token txs with bip21 query strings
Summary

Support token send txs with bip21 query strings in Cashtab

Test Plan

npm test

This is deployed at the test site. You can also confirm that bip21 link fwding works, e.g.

https://cashtab-local-dev.netlify.app/#/send?bip21=ecash:qphlhe78677sz227k83hrh542qeehh8el5lcjwk72y?token_id=21c5d17f37e96279da21fd24ff4d15be2dd146b7fa59ef77f7d84546477199d2&token_decimalized_qty=1

image.png (602×1 px, 51 KB)

this is also tested with npm test now tho

Diff Detail

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

Event Timeline

add tests, improve token caching

back out unrelated linebreak

emack requested changes to this revision.Fri, Nov 29, 10:24
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/Send/SendXec.tsx
389 ↗(On Diff #51160)

needs an extra check for > '0' quantity

389 ↗(On Diff #51160)

on 2nd thought, is this because you're expecting the UI to guard against 0 quantity? I think given this is a bip21 it could come from anywhere, where we can't control the pre-validation.

cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
854 ↗(On Diff #51160)

add test where token_decimalized_qty is 0

cashtab/src/validation/index.ts
802 ↗(On Diff #51160)

as above, add check for '0'

This revision now requires changes to proceed.Fri, Nov 29, 10:24
bytesofman marked 4 inline comments as done.
bytesofman added inline comments.
cashtab/src/components/Send/SendXec.tsx
389 ↗(On Diff #51160)

This is handled by form validation. '0' is technically a valid bip21 amount. But cashtab correctly shows that we can't send this tx.

image.png (262×781 px, 20 KB)

desired behavior is to render this as if the user is trying to validly send a token, but show that the tx cannot be sent bc the amount is invalid.

389 ↗(On Diff #51160)

right -- there's another layer here in that the wallet must determine token decimals to validate the quantity. But as long as the bip21 is valid, we can infer this is supposed to be a token send tx, then validate why it is or is not valid.

cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
854 ↗(On Diff #51160)

this is already covered with the extensively tested isValidTokenSendOrBurnAmount

cashtab/src/validation/index.ts
802 ↗(On Diff #51160)

we're ok adding 0 here for the reasons outlined above

This revision is now accepted and ready to land.Sat, Nov 30, 10:23
This revision was automatically updated to reflect the committed changes.
bytesofman marked 4 inline comments as done.