Page MenuHomePhabricator

[Cashtab] Show XECX balance
ClosedPublic

Authored by bytesofman on Fri, Jan 10, 00:57.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCf6a1d08dc55a: [Cashtab] Show XECX balance
Summary

Show XECX balance in balance header, if it is non-zero, with link to token page on ticker

Include XECX balance in total fiat balance

Test Plan

npm test, screenshot

image.png (157×482 px, 25 KB)

Diff Detail

Repository
rABC Bitcoin ABC
Branch
xecx-in-balanceheader
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32025
Build 63542: Build Diffcashtab-tests
Build 63541: arc lint + arc unit

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: <BalanceHeader /> Renders the loader if balanceSats is not an integer ======
Error: Input param satoshis must be an integer
    at toXec (/work/cashtab/src/wallet/index.ts:172:15)
    at BalanceHeader (/work/cashtab/src/components/Common/BalanceHeader.tsx:73:29)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:13:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <BalanceHeader /> Renders the BalanceHeader component correctly with default locale en-US ======
TypeError: Cannot read properties of undefined (reading 'toLocaleString')
    at toLocaleString (/work/cashtab/src/components/Common/BalanceHeader.tsx:80:46)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:28:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <BalanceHeader /> Renders the BalanceHeader component correctly with fr-FR locale ======
TypeError: Cannot read properties of undefined (reading 'toLocaleString')
    at toLocaleString (/work/cashtab/src/components/Common/BalanceHeader.tsx:80:46)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:61:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <BalanceHeader /> Balance is hidden if cashtabSettings.balanceVisible is false ======
TypeError: Cannot read properties of undefined (reading 'toLocaleString')
    at toLocaleString (/work/cashtab/src/components/Common/BalanceHeader.tsx:80:46)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:95:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <BalanceHeader /> Renders fiat price for a non-USD currency ======
TypeError: Cannot read properties of undefined (reading 'toLocaleString')
    at toLocaleString (/work/cashtab/src/components/Common/BalanceHeader.tsx:80:46)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:128:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <BalanceHeader /> Fiat price and forex are not displayed if fiatPrice is unavailable ======
TypeError: Cannot read properties of undefined (reading 'toLocaleString')
    at toLocaleString (/work/cashtab/src/components/Common/BalanceHeader.tsx:80:46)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:15486:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20103:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21626:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27465:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26599:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26505:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26473:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25889:20)
    at performConcurrentWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25789:22)
    at flushActQueue (/work/cashtab/node_modules/react/cjs/react.development.js:2667:24)
    at act (/work/cashtab/node_modules/react/cjs/react.development.js:2582:11)
    at /work/cashtab/node_modules/@testing-library/react/dist/act-compat.js:47:25
    at renderRoot (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:180:26)
    at render (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:271:10)
    at Object.<anonymous> (/work/cashtab/src/components/Common/__tests__/BalanceHeader.test.js:159:15)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:121:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:444:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:106:12)
====== CashTab Unit Tests: <Token /> Renders the burn token success notification upon successful burn tx broadcast ======
Error: expect(received).toHaveProperty(path, value)

Expected path: "checked"

Expected value: true
Received value: false
    at Object.toHaveProperty (/work/cashtab/src/components/Etokens/__tests__/Token.test.js:438:56)
====== CashTab Unit Tests: <Agora /> We can see multiple offers, some we made, others we did not, and we can cancel an offer ======
Error: expect(received).toBeInTheDocument()

received value must be an HTMLElement or an SVGElement.
Received has value: undefined
    at __EXTERNAL_MATCHER_TRAP__ (/work/cashtab/node_modules/expect/build/index.js:325:30)
    at Object.throwingMatcher [as toBeInTheDocument] (/work/cashtab/node_modules/expect/build/index.js:326:15)
    at Object.toBeInTheDocument (/work/cashtab/src/components/Agora/__tests__/index.test.js:647:11)

Each failure log is accessible here:
CashTab Unit Tests: <BalanceHeader /> Renders the loader if balanceSats is not an integer
CashTab Unit Tests: <BalanceHeader /> Renders the BalanceHeader component correctly with default locale en-US
CashTab Unit Tests: <BalanceHeader /> Renders the BalanceHeader component correctly with fr-FR locale
CashTab Unit Tests: <BalanceHeader /> Balance is hidden if cashtabSettings.balanceVisible is false
CashTab Unit Tests: <BalanceHeader /> Renders fiat price for a non-USD currency
CashTab Unit Tests: <BalanceHeader /> Fiat price and forex are not displayed if fiatPrice is unavailable
CashTab Unit Tests: <Token /> Renders the burn token success notification upon successful burn tx broadcast
CashTab Unit Tests: <Agora /> We can see multiple offers, some we made, others we did not, and we can cancel an offer

use mocks now that they are available

bytesofman edited the test plan for this revision. (Show Details)
emack requested changes to this revision.Fri, Jan 10, 08:31
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/App/App.tsx
106 ↗(On Diff #52103)

isn't this conditional || 0 the same as the : 0 below?

This revision now requires changes to proceed.Fri, Jan 10, 08:31
bytesofman added inline comments.
cashtab/src/components/App/App.tsx
106 ↗(On Diff #52103)

kind of but not quite

mb this would work:

const balanceXecx = Number(
                  wallet.state.tokens.get(appConfig.vipTokens.xecx.tokenId),
              ) || 0;

But, we know that wallet can be false sometimes (only on this App parent screen, which renders OnBoarding in this case). So imo if we know that wallet is false, we should not even try to check wallet.state.tokens.get(<tokenId>) -- if wallet is false, we know the balance is 0

We do not know tho if wallet.state.tokens.get(<tokenId>) is a decimalized string (wallet has this token) or zero (wallet does not have this token) without checking. So the || 0` is handling the "user has a wallet but not this token" case.

Another issue worth noting here -- this only works with Number because XECX supply is known to be less than Number.MAX_SAFE_INTEGER. Any arbitrary token and we may have to use BigNumber or string methods.

bytesofman marked an inline comment as done.

comment on balanceXecx getter

This revision is now accepted and ready to land.Fri, Jan 10, 13:59
This revision was automatically updated to reflect the committed changes.