Page MenuHomePhabricator

[Cashtab] Refactor and implement parseAddressForParams
AbandonedPublicDraft

Authored by bytesofman on Jan 11 2024, 04:31.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Supporting bip21, aliases, and fiat send amounts from one screen demands complex validation. This validation should be handled in a function that can be unit tested automatically.

Move address validation logic from SendXec and SendToken components into parseAddressInput function, which is called anyway, and already performs other types of validation.

Return error messages specific to bip21 parameters, if present.

Return error message specific to queryString, if present.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
improve-validation-paramparsing
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26257
Build 52086: Build Diffcashtab-tests
Build 52085: arc lint + arc unit

Event Timeline

TODO

  • Deprecate parseAddressForParams from the SignAndVerify screen in a separate diff D15135
  • Refactor parseAddressForParams unit tests to use fixtures / vectors approach (separate diff) D15137
  • Update parseAddressForParams and its unit tests. Apply in Send and SendToken screens.

Tail of the build log:

npm WARN deprecated @babel/plugin-proposal-private-methods@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
npm WARN deprecated @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
npm WARN deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm WARN deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm WARN deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm WARN deprecated ts-custom-error@2.2.2: npm package tarball contains useless codeclimate-reporter binary, please update to version 3.1.1. See https://github.com/adriengibrat/ts-custom-error/issues/32

added 1935 packages, and audited 1936 packages in 24s

265 packages are looking for funding
  run `npm fund` for details

5 moderate severity vulnerabilities

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

> cashtab@1.0.0 build
> node scripts/build.js

Creating an optimized production build...
One of your dependencies, babel-preset-react-app, is importing the
"@babel/plugin-proposal-private-property-in-object" package without
declaring it in its dependencies. This is currently working because
"@babel/plugin-proposal-private-property-in-object" is already in your
node_modules folder for unrelated reasons, but it may break at any time.

babel-preset-react-app is part of the create-react-app project, which
is not maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
your devDependencies to work around this error. This will make this message
go away.
  
Failed to compile.

[eslint] 
src/components/Common/ScanQRCode.js
  Line 9:10:  'isValidXecAddress' is defined but never used  no-unused-vars

src/components/Send/SendToken.js
  Line 45:5:  'isValidXecAddress' is defined but never used  no-unused-vars
  Line 48:5:  'isAliasFormat' is defined but never used      no-unused-vars

src/components/Send/SendXec.js
  Line 31:5:  'isValidXecAddress' is defined but never used     no-unused-vars
  Line 32:5:  'isValidEtokenAddress' is defined but never used  no-unused-vars
  Line 33:5:  'isAliasFormat' is defined but never used         no-unused-vars

src/utils/cashMethods.js
  Line 10:10:  'queryAliasServer' is defined but never used  no-unused-vars

Search for the keywords to learn more about each error.


Build cashtab-tests failed with exit code 1