Page MenuHomePhabricator

[Cashtab] Change wallet structure to store balanceSats as number instead of balances as object
AbandonedPublic

Authored by bytesofman on Mar 8 2024, 18:17.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Summary

Cashtab wallets store balances in a cumbersome custom object, with strings for both xec balance and sats balance.

Instead, just store sats as a number. This is a simpler implementation and makes it easier to perform calculations, for example now we can render notification amounts with locale string easily.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cashtab-to-balancesats
Lint
Lint Errors
SeverityLocationCodeMessage
Errorcashtab/src/components/Etokens/CreateToken.js:13ESLINTno-unused-vars
Errorcashtab/src/utils/cashMethods.js:5ESLINTno-unused-vars
Errorcashtab/src/utils/cashMethods.js:7ESLINTno-unused-vars
Unit
No Test Coverage
Build Status
Buildable 27750
Build 55062: Build Diffcashtab-tests
Build 55061: arc lint + arc unit

Event Timeline

Tail of the build log:

Installing mock-chronik-client dependencies...
/work/modules/mock-chronik-client /work/abc-ci-builds/cashtab-tests

added 236 packages, and audited 237 packages in 2s

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

found 0 vulnerabilities
/work/cashtab /work/modules/mock-chronik-client /work/abc-ci-builds/cashtab-tests
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-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-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 rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
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-private-property-in-object@7.21.11: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated domexception@4.0.0: Use your platform's native DOMException instead
npm WARN deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
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 workbox-cacheable-response@6.6.0: workbox-background-sync@6.6.0

added 1722 packages, and audited 1723 packages in 35s

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

found 0 vulnerabilities

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

Creating an optimized production build...
Failed to compile.

[eslint] 
src/components/Etokens/CreateToken.js
  Line 13:10:  'BN' is defined but never used  no-unused-vars

src/utils/cashMethods.js
  Line 5:10:  'BN' is defined but never used     no-unused-vars
  Line 7:10:  'toXec' 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
bytesofman published this revision for review.Mar 8 2024, 19:14
bytesofman added inline comments.
cashtab/src/hooks/useWallet.js
685 ↗(On Diff #46044)

note: this if block is unreachable. I noticed while doing this diff. see D15663 which depends on this and will remove it

minor version bump for supported wallet migration

emack requested changes to this revision.Mar 9 2024, 05:44
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/Configure/Configure.js
1588 ↗(On Diff #46076)

Saved wallet balance off by 2 decimals:

image.png (61×436 px, 5 KB)

image.png (198×494 px, 14 KB)

Worth doing a full sweep of all instances where balances.totalBalance was replaced by state.balanceSats without conversion via appConfig.cashDecimals

This revision now requires changes to proceed.Mar 9 2024, 05:44
bytesofman marked an inline comment as done.

remove tech debt in sendxec validation functions

had to do some refactoring of existing validation functions to properly implement this. that work should be split out in its own diff, then this can land after.