Page MenuHomePhabricator

[Cashtab] [Alias] pt 10 - Enable alias inputs for one to one Send XEC txs
ClosedPublic

Authored by emack on Feb 22 2023, 11:38.

Details

Summary

T2551

This is a standalone diff that enables the use of aliases for one to one XEC txs. When the address input is parsed to be an alias (ends in .xec) it will override the existing ecash address validation logic and check whether this alias exists in cashtabCache. If it exists, the corresponding ecash address is retrieved.

[Cashtab] [Alias] pt 1 - Create scaffold for new Alias component
[Cashtab] [Alias] pt 2 - Upgrade sendXec() to handle alias registration
[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function
[Cashtab] [Alias] pt 4 - Implement isAddressRegistered function
[Cashtab] [Alias] pt 5 - Implement getAddressFromAlias function
[Cashtab] [Alias] pt 6.1 - Get latest alias tx count from payment address
[Cashtab] [Alias] pt 6.1.1 - Apply Promise.All approach for alias history retrieval
[Cashtab] [Alias] pt 6.2 - Implement getAliasesFromLocalForage
[Cashtab] [Alias] pt 6.3 - Implement updateAliases
[Cashtab] [Alias] pt 6.4 - Update getAliases() to extract both alias and address
[Cashtab] [Alias] pt 6.5 - Optimize getAllTxHistory to only make API calls for uncached tx history pages
[Cashtab] [Alias] pt 6.6 - Render list of Aliases owned by active wallet in Alias.js
[Cashtab] [Alias] pt 7 - Mitigate edge cases for registration records
[Cashtab] [Alias] pt 8 - Activation flag in prod
[Cashtab] [Alias] pt 9 - Retain tokenInfoById upon alias validation
--stacked diff cutoff--
[Cashtab] [Alias] pt 10 - Enable alias inputs for one to one Send XEC txs
[Cashtab] [Alias] pt 11 - Enable alias lookup for Send Token txs
[Cashtab] [Alias] pt 12 - Upgrade tx history to recognize alias registration txs
[Cashtab] [Alias] pt 13 - Port Alias feature to Cashtab extension
[Cashtab] [Alias] pt 14 - Pre-prod update (Set final registration fees, remove residual dev logs and enable prod flag)

Test Plan
  • npm test
  • npm start
  • if your aliasCache is empty, update currency.aliasSettings.aliasEnabled to true in Ticker.js and navigate to Alias.js
  • navigate to Send component, input an alias address (with .xec) that is registered onchain, then verify validation passes and parsed address is displayed in the console log. Send an Xec amount with this input and verify successful broadcast via explorer
  • repeat with a send XEC tx along with an unencrypted message
  • repeat with a send XEC tx along with an encrypted message
  • input a valid alias address (with .xec) that has yet to be registered onchain, then verify validation fails with the eCash Alias does not exist message displayed in the address input field UI.
  • input foo.xec (already registered), then immediately change it to an invalid alias format and ensure it fails validation
  • input foo.xec, then immediately change it to an unregistered alias format and ensure it fails validation

Diff Detail

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

Event Timeline

emack requested review of this revision.Feb 22 2023, 11:38

Had this issue.

  1. Set aliasEnabled to true in Ticker.js
  2. npm start
  3. Navigate to Send.js and type chicken.xec -- says that the alias is not registered

It is -- but the alias cache is empty because I have not navigated to the aliases page. We need to update the aliases cache on app load, not just on checking the aliases page.

image.png (270×480 px, 14 KB)

I think we can change the input text here to "address or alias" ... i guess need to make it conditional on aliases being enabled, but that's not too much of a complication.

inline comments related to handleAddressChange function. High level, I don't think we should require people to type .xec for aliases. But we also need to support recognizing aliases that include this if they do.

I think the best solution is a new function, parseInputForValidAlias, and call this for all inputs where length <= 21 ...er...i guess length <= 21 + '.xec'.length. The parseInputForValidAlias function determines if the input includes .xec (if so, removes it), and determines if the input corresponds to a registered alias. If yes, return it. If no, validation error for alias not registered.

For inputs of length > 21 + '.xec'.length, parse for an ecash address.

web/cashtab/src/components/Send/Send.js
428 ↗(On Diff #37992)

let's get rid of the isAliasFormat function

430 ↗(On Diff #37992)

delete this if block

432 ↗(On Diff #37992)

we don't want to make people type .xec. But we also want to allow people to type it if they really want to.

455 ↗(On Diff #37992)

here is where we want to put the logic for checking user input for an alias.

If the input is not a valid cashaddress, check if it's a valid alias.

If it's not a valid alias, display "alias unregistered" msg

Nuance in that we do want to preserve the "invalid ecash address" error. I think it's enough to check the input length. If the input char length is <= 21, then parse it for an alias. If it's >= 21 and an invalid ecash address, then it's an invalid ecash address.

web/cashtab/src/utils/validation.js
7 ↗(On Diff #37992)

I don't think we need to make everyone type ".xec" -- this would be especially annoying for mobile users.

If a user is typing at all (and not copy pasting), they are probably putting in an alias. The app should treat it that way anyway.

This revision now requires changes to proceed.Feb 22 2023, 23:11
emack marked an inline comment as done.
  • alias cache synchronization now executes upon app load in useWallet. Its corresponding logic has also been moved into useWallet to be reused by both initial app load and the alias.js component.
  • address input validation now moved so the ecash address validation error message takes precedence
  • per tg chat, the option to allow alias inputs without the .xec will be handled post-mvp
  • double extensions chicken.xec.xec is now invalidated in the frontend for the registration screen
  • address input placeholder now conditionally renders 'or Alias' depending on the alias flag

typo nit

web/cashtab/src/components/Alias/Alias.js
64 ↗(On Diff #38019)

synchronize not synchornize

88 ↗(On Diff #38019)

synchronize not synchornize

web/cashtab/src/hooks/useWallet.js
1125 ↗(On Diff #38019)

synchronize not synchornize

1128 ↗(On Diff #38019)

synchronize not synchornize

1135 ↗(On Diff #38019)

synchronize not synchornize

1640 ↗(On Diff #38019)

synchronize not synchornize

This revision now requires changes to proceed.Feb 24 2023, 00:58
emack marked 6 inline comments as done.

fixed typos

bytesofman added inline comments.
web/cashtab/src/hooks/useWallet.js
1125 ↗(On Diff #38020)

We should do this conditionally on the aliasEnabled setting

There's a chance we will introduce some bugs at the test address before we get this to prod, so we don't want to be running this for all prod users on our test aliases.

This revision now requires changes to proceed.Feb 24 2023, 04:04

alias cache synchronization now only triggers when the alias feature is enabled in Ticker.js

This revision is now accepted and ready to land.Feb 24 2023, 04:23