Page MenuHomePhabricator

[ecash-lib] Publish 1.4.0, expose HD wallet and mnemonic functionality
ClosedPublic

Authored by tobias_ruck on Fri, Jan 31, 13:45.

Details

Summary
  • Expose HdNode, entropyToMnemonic, mnemonicToEntropy and mnemonicToSeed, this allows users to build a complete eCash wallet without needing external dependencies (other than ecash-lib and chronik-client).
  • Add the /src folder to the published NPM. This is because some bundlers like webpack expect them, and it allows users to browse the source on npm. This not-quite doubles the package size (compressed: 150.4 kB -> 245.0 kB, uncompressed: 564.2 kB -> 934.9 kB), but since we still stay below 1 MB even uncompressed this doesn't seem to be a big issue. @bytesofman verified that these files are tree-shakable, so the CashTab bundle size doesn't increase.
  • Bump the version number to 1.4.0
Test Plan

Ideally, publish an RC on NPM and import, alternatively build locally and import. Or just trust the CI.

Diff Detail

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

Event Timeline

This not-quite doubles the package size (compressed: 150.4 kB -> 245.0 kB, uncompressed: 564.2 kB -> 934.9 kB), but since we still stay below 1 MB even uncompressed this doesn't seem to be a big issue

imo this would be a pretty big issue if the lib were not "tree-shakeable." The lib does seem to be this way though.

Most bundlers, when you have a lib, will only actually install what you are using from the lib. So you might have ecash-lib as a dependency but if all you use is toHex then the size of your app bundle is only incrementally increasing by the size of the files needed for that function.

this test seems to confirm that we're ok here

arc patch D17619
cd cashtab/
npm run build

output

File sizes after gzip:

  800.02 kB  build/static/js/main.5711722f.js
  4.33 kB    build/static/css/main.beca7903.css

the cashtab bundle is arguably too big -- but the important thing to note here is that when you run npm run build, it tells you if the bundle sized changed -- and in this case there is no change. So even though ecash-lib is exposing more things, because Cashtab is not using them, its bundle size did not change (which is what we expect from a tree-shakeable lib).

modules/ecash-lib/README.md
111 ↗(On Diff #52467)

nit

modules/ecash-lib/package.json
3 ↗(On Diff #52467)

for version bumps, instead of manually editing package.json, do

cd modules/ecash-lib
npm version minor

This will update both package.json and package-lock.json

the other bumps are npm version patch and npm version major

modules/ecash-lib/src/index.ts
11 ↗(On Diff #52467)

we should not include the .js suffix; this resolves without the extension

the .js files do not exist in the codebase, only in dist -- so it's confusing to have them in this file

this is an issue throughout ecash-lib. so ... not really a blocker here, but should be a diff to fix it everywhere though

This revision is now accepted and ready to land.Fri, Jan 31, 14:23

bump version using npm, add link to diff