Page MenuHomePhabricator

[Cashtab] Paginated tx history
ClosedPublic

Authored by bytesofman on Sep 14 2025, 20:32.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC8c62b1aa8fc3: [Cashtab] Paginated tx history
Summary

Implement paginated tx history in Cashtab

Test Plan

npm test, this is live at cashtab.io

Diff Detail

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

Event Timeline

update tests, lose magic numbers

improved component organization

Failed tests logs:

====== CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:262:49)
    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:105: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: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:301:53)
    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:105: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 _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)

Each failure log is accessible here:
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history

version bump, reset pagination on wallet change

bytesofman edited the test plan for this revision. (Show Details)

Failed tests logs:

====== CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:262:49)
    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:105: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: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:301:53)
    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:105: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 _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)

Each failure log is accessible here:
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history

Failed tests logs:

====== CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:262:49)
    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:105: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: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history ======
TypeError: (0 , _chronik.getHistory) is not a function
    at Object.<anonymous> (/work/cashtab/src/chronik/__tests__/index.test.js:301:53)
    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:105: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 _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)

Each failure log is accessible here:
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899, and update the token cache at the same time
CashTab Unit Tests: Cashtab chronik.js functions We can get and parse tx history from path 1899. If there is an error in getting cached token data, we still parse tx history. We add to token cache and get parsed tx history

failure related to earlier state of this diff

PiRK added a subscriber: PiRK.
PiRK added inline comments.
cashtab/src/components/Home/TxHistoryPagination.tsx
115–148 ↗(On Diff #55712)

nit: could factor out pages.push(0) and pages.push(totalPages - 1) which are called in all cases.

Not sure if simpler (less lines but weirder syntax), Grok gives me this:

const getVisiblePages = (currentPage, totalPages, maxVisible = 5) => {
    // Helper to generate range of pages
    const range = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i);

    // If total pages are less than or equal to maxVisible, show all
    if (totalPages <= maxVisible) {
        return range(0, totalPages - 1);
    }

    // Determine start and end based on currentPage position
    if (currentPage <= 2) {
        // Start: [0, 1, 2, 3, ..., last]
        return [...range(0, Math.min(3, totalPages - 1)), -1, totalPages - 1];
    } else if (currentPage >= totalPages - 3) {
        // End: [0, ..., last-3, last-2, last-1, last]
        return [0, -1, ...range(Math.max(1, totalPages - 4), totalPages - 1)];
    } else {
        // Middle: [0, ..., current-1, current, current+1, ..., last]
        return [0, -1, ...range(currentPage - 1, currentPage + 1), -1, totalPages - 1];
    }
};
This revision is now accepted and ready to land.Sep 17 2025, 06:43
bytesofman added inline comments.
cashtab/src/components/Home/TxHistoryPagination.tsx
115–148 ↗(On Diff #55712)

nice, yes this is a bit better. in testing, UI looks the same, implemented

Still some work to go after this diff

  • the TxHistory component should own the whole tx history, not take anything from parsedTxHistory in the wallet
  • but, this also means we need it to own avalanche finality updates and pass some info about txs to the Home component

so, this stuff will need to come later as the wallet is refactored for simplicity and the ecash-wallet drop-in

This revision was automatically updated to reflect the committed changes.
bytesofman marked an inline comment as done.