Page MenuHomePhabricator

[Cashtab] Get token info from cache in airdrop calc screen
ClosedPublic

Authored by bytesofman on Apr 12 2024, 22:47.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC0fa38e98935e: [Cashtab] Get token info from cache in airdrop calc screen
Summary

Every time we need token info that can be cached, we should get it from the cache. If it is not from the cache, we add it to the cache.

The airdrop calculator is still getting this info manually.

Implement standardized Cashtab practice.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
no-more-getMintAddress
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28538
Build 56617: Build Diffcashtab-tests
Build 56616: arc lint + arc unit

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: <Airdrop /> We can send a pro-rata airdrop and equal tx to a tokenId not in our cache using custom settings ======
TestingLibraryElementError: Unable to find an element with the placeholder text of: Enter the eToken ID

Ignored nodes: comments, script, style
<body>
  <div />
</body>
    at Object.getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:37:19)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:76:38
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:52:17
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:95:19
    at Object.getByPlaceholderText (/work/cashtab/src/components/Airdrop/__tests__/Airdrop.test.js:120:20)
====== CashTab Unit Tests: <Airdrop /> We can ignore addresses with less than a token balance for a token with decimals ======
TestingLibraryElementError: Unable to find an element with the placeholder text of: Enter the eToken ID

Ignored nodes: comments, script, style
<body>
  <div />
</body>
    at Object.getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:37:19)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:76:38
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:52:17
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:95:19
    at Object.getByPlaceholderText (/work/cashtab/src/components/Airdrop/__tests__/Airdrop.test.js:224:20)
====== CashTab Unit Tests: <App /> Navigation menu routes to expected components ======
ReferenceError: Cannot access 'formData' before initialization
    at formData (/work/cashtab/src/components/Airdrop/Airdrop.js:93:9)
    at renderWithHooks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:16305:18)
    at mountIndeterminateComponent (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:20074:13)
    at beginWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:21587:16)
    at beginWork$1 (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:27426:14)
    at performUnitOfWork (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26560:12)
    at workLoopSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26466:5)
    at renderRootSync (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26434:7)
    at recoverFromConcurrentError (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:25850:20)
    at performSyncWorkOnRoot (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:26096:20)
    at flushSyncCallbacks (/work/cashtab/node_modules/react-dom/cjs/react-dom.development.js:12042: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:46:25
    at Object.eventWrapper (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:107:28)
    at Object.wrapEvent (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/event/wrapEvent.js:6:28)
    at Object.dispatchEvent (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/event/dispatchEvent.js:45:22)
    at Object.dispatchUIEvent (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/event/dispatchEvent.js:22:26)
    at Mouse.up (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/system/pointer/mouse.js:100:30)
    at PointerHost.release (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/system/pointer/index.js:84:28)
    at pointerAction (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/pointer/index.js:59:47)
    at Object.pointer (/work/cashtab/node_modules/@testing-library/user-event/dist/cjs/pointer/index.js:32:9)
    at Object.asyncWrapper (/work/cashtab/node_modules/@testing-library/react/dist/pure.js:88:22)
    at Object.<anonymous> (/work/cashtab/src/components/App/__tests__/App.test.js:267:9)

Each failure log is accessible here:
CashTab Unit Tests: <Airdrop /> We can send a pro-rata airdrop and equal tx to a tokenId not in our cache using custom settings
CashTab Unit Tests: <Airdrop /> We can ignore addresses with less than a token balance for a token with decimals
CashTab Unit Tests: <App /> Navigation menu routes to expected components

cleaning up and testing with uncachced tokens

Failed tests logs:

====== CashTab Unit Tests: <Airdrop /> We can ignore addresses with less than a token balance for a token with decimals ======
Error: expect(element).toHaveValue(ecash:qp6qkpeg5xmpcqtu6uc5qkhzexg4sq009sfeekcfk2, 499905.84
ecash:qpmytrdsakt0axrrlswvaj069nat3p9s7cjctmjasj, 94.15)

Expected the element to have value:
  ecash:qp6qkpeg5xmpcqtu6uc5qkhzexg4sq009sfeekcfk2, 499905.84
  ecash:qpmytrdsakt0axrrlswvaj069nat3p9s7cjctmjasj, 94.15
Received:
  ecash:qp6qkpeg5xmpcqtu6uc5qkhzexg4sq009sfeekcfk2, 499894.34
  ecash:qpmytrdsakt0axrrlswvaj069nat3p9s7cjctmjasj, 94.15
  ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6, 11.49
    at Object.toHaveValue (/work/cashtab/src/components/Airdrop/__tests__/Airdrop.test.js:274:11)

Each failure log is accessible here:
CashTab Unit Tests: <Airdrop /> We can ignore addresses with less than a token balance for a token with decimals

get decimals from the right place

bytesofman added inline comments.
cashtab/src/components/Airdrop/Airdrop.js
62 ↗(On Diff #47121)

we move all the useEffect blocks under the state variables

128 ↗(On Diff #47121)

This is useful to know. Esp now that this input can be used by a dev to just add any token info to cache.

154 ↗(On Diff #47121)

also interesting info for anyone checking the dev log

171 ↗(On Diff #47121)

again, useful info if you are looking at the dev log

This revision is now accepted and ready to land.Apr 13 2024, 02:31