Page MenuHomePhabricator

[ecash-lib, cashtab, ecash-herald] Recreate ecash-script methods with ecash-lib consts to support deprecation of ecash-script
ClosedPublic

Authored by bytesofman on Sep 21 2025, 13:42.

Details

Summary

Roadmap

  • Re-create the methods of ecash-script still used by monorepo apps in ecash-lib (this diff)
  • Deprecate ecash-script
  • Move Cashtab's tx parsing functions into ecash-lib, standardize them to be portable
  • Implement the now-standardized tx (and app) parsing functions in ecash-herald, so we parse everything in Cashtab and ecash-herald the same
  • Implement in explorer (if practical to use the JS lib, should be doable; get Tx[] from chronik in the backend and parse for rendering with JS)

Background
Cashtab has powerful parsing functions for tx history that is useful for wallet devs. This logic should be made standardized and portable. In this way we could have a standard way of updating app parsing.

Right now, ecash-herald and cashtab both have distinct and custom parsing methods. They rely on the comparatively obsolete (compared to ecash-lib) ecash-script lib.

App devs should have a standard way of parsing ecash txs. Ideally, they should not have to do with low-level methods like getStackArray or consumeNextPush. However, we need these building blocks to complete parsing logic (like what we have in Cashtab's parseTx), and we need to recreate them in ecash-lib so that we can deprecate ecash-script without breaking Cashtab or ecash-herald.

So, this is a first step toward the end goal.

Test Plan

npm test, CI test for ecash-herald and cashtab confirm we can deprecate ecash-script

Diff Detail

Repository
rABC Bitcoin ABC
Branch
init-ecash-parse
Lint
Lint Errors
SeverityLocationCodeMessage
Errorcontrib/teamcity/build-configurations.yml:1116new-line-at-end-of-fileyamllint found an issue:
Errorcontrib/teamcity/build-configurations.yml:1116trailing-spacesyamllint found an issue:
Unit
No Test Coverage
Build Status
Buildable 34519
Build 68505: Build Diffecash-wallet-integration-tests · ecash-agora-integration-tests · ecash-wallet-tests · ecash-lib-integration-tests · ecash-agora-tests · ecash-lib-tests · ecash-herald-tests · cashtab-tests · cashtab-faucet-tests
Build 68504: arc lint + arc unit

Event Timeline

Tail of the build log:

> tsc


added 171 packages, and audited 173 packages in 4s

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

6 vulnerabilities (1 low, 3 moderate, 1 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

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

Run `npm audit` for details.

> chronik-client@3.4.0 build
> tsc

/work/modules/mock-chronik-client /work/abc-ci-builds/cashtab-tests
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported

added 267 packages, and audited 270 packages in 2s

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

5 vulnerabilities (1 low, 3 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> mock-chronik-client@3.1.0 build
> tsc

/work/modules/ecash-parse /work/abc-ci-builds/cashtab-tests
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

added 237 packages, and audited 239 packages in 1s

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

found 0 vulnerabilities

> ecash-parse@0.1.0 build
> tsc

src/opreturn.ts(5,44): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
src/opreturn.ts(30,8): error TS2307: Cannot find module 'ecash-lib' or its corresponding type declarations.
Build cashtab-tests failed with exit code 2

do it in ecash-lib instead of using a new lib

bytesofman retitled this revision from [ecash-parse, cashtab, ecash-herald] Init new npm module ecash-parse to standardize app-level parsing of ecash txs to [ecash-lib, cashtab, ecash-herald] Init new npm module ecash-parse to standardize app-level parsing of ecash txs.Sep 22 2025, 13:23
bytesofman edited the summary of this revision. (Show Details)

remove extended conversion and reconversions

bytesofman retitled this revision from [ecash-lib, cashtab, ecash-herald] Init new npm module ecash-parse to standardize app-level parsing of ecash txs to [ecash-lib, cashtab, ecash-herald] Recreate ecash-script methods with ecash-lib consts to support deprecation of ecash-script.Sep 22 2025, 23:13
Fabien requested changes to this revision.Sep 23 2025, 06:41
Fabien added a subscriber: Fabien.
Fabien added inline comments.
apps/ecash-herald/package-lock.json
113 ↗(On Diff #55780)

that's obsolete

cashtab/package-lock.json
9920 ↗(On Diff #55780)

dito

modules/ecash-lib/src/index.ts
33 ↗(On Diff #55780)

Is there a way to start exporting with narrower namespaces ? It would look better and be more readable to write something like import consume from 'ecash-lib.parse'. Not sure if that's a thing in js/ts

This revision now requires changes to proceed.Sep 23 2025, 06:41
bytesofman added inline comments.
modules/ecash-lib/src/index.ts
33 ↗(On Diff #55780)

This can be done but if we opt to do it this way imo should be its own diff

my preference is to keep everything as is, i.e. "import it from ecash-lib" -- when users build their deps with stuff like webpack or vite (as almost all JS apps do), the unused lib functions are automatically not added to the bundle

So, typically these types of special-path imports are only used in npm modules for cases where the user wants some special version, i.e. they need to import a certain function for a certain browser environment, so they import from that special path

In our case that isn't necessary, so more likely to cause confusion having to remember all the different special paths

update package-lock.json for herald and cashtab, rebase

Tail of the build log:

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

7 vulnerabilities (1 low, 5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> ecash-agora@2.1.0 build
> tsc && tsc -p ./tsconfig.build.json

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
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-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-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-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 rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated workbox-cacheable-response@6.6.0: workbox-background-sync@6.6.0
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 workbox-google-analytics@6.6.0: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
npm warn deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec 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 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 @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 source-map@0.8.0-beta.0: The work that was done in this beta branch won't be included in future versions

added 1441 packages, and audited 1447 packages in 7s

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

1 moderate severity vulnerability

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

Run `npm audit` for details.

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

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

Module not found: Error: Can't resolve '/work/cashtab/node_modules/node-stdlib-browser/cjs/proxy/process' in '/work/cashtab/node_modules/react-tooltip/dist'
Did you mean 'process.js'?
BREAKING CHANGE: The request '/work/cashtab/node_modules/node-stdlib-browser/cjs/proxy/process' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.


Build cashtab-tests failed with exit code 1

clean up package-lock changes, CI

clean up package-lock changes, lint, rebase

apps/ecash-herald/package-lock.json
5833 ↗(On Diff #55805)

see D18667

This revision is now accepted and ready to land.Sep 23 2025, 14:36
modules/ecash-lib/src/index.ts
33 ↗(On Diff #55780)

I was only thinking about this regarding the readability, not packaging nor optimization. The consume() example is a good one, in the context of ecash-script it makes sense but in the context of ecash-lib it's not immediately obvious what this does. If it was script.consume() it would be much more obvious.