Page MenuHomePhabricator

[ecash-lib] [ecash-agora] Remove unneeded `ecc` parameters
ClosedPublic

Authored by tobias_ruck on Thu, Feb 6, 00:52.

Details

Summary

Now that we have a global Ecc instance, and new Ecc is basically a no-op, we can remove a lot of the ecc: Ecc params that are needed to use ecash-lib, simplifiying usage quite a bit.

The TxBuilder.sign function now receives a params object instead of a parameter list, which makes the code more readable.

This is a breaking change for both ecash-lib and ecash-agora, which we bundle in with the initWasm removal.

Depends on D17639.

Test Plan

CI

Event Timeline

Tail of the build log:

Run `npm audit` for details.

> ecash-lib@1.5.1 build
> tsc && tsc -p ./tsconfig.build.json && cp -r ./src/ffi ./dist

/work/modules/ecash-agora /work/abc-ci-builds/cashtab-tests

added 364 packages, and audited 367 packages in 1s

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

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated eslint@8.56.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 1494 packages, and audited 3315 packages in 25s

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

8 vulnerabilities (4 moderate, 4 high)

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.

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

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

TS2345: Argument of type '{ ecc: Ecc; covenantSk: Uint8Array; covenantPk: Uint8Array; fuelInputs: { input: { prevOut: { txid: string; outIdx: number; }; signData: { value: number; outputScript: Script; }; }; signatory: (ecc: Ecc, input: UnsignedTxInput) => Script; }[]; recipientScript: Script; feePerKb: number; }' is not assignable to parameter of type '{ covenantSk: Uint8Array; covenantPk: Uint8Array; fuelInputs: TxBuilderInput[]; recipientScript: Script; acceptedTokens?: bigint | undefined; dustAmount?: number | undefined; feePerKb?: number | undefined; allowUnspendable?: boolean | undefined; }'.
  Object literal may only specify known properties, and 'ecc' does not exist in type '{ covenantSk: Uint8Array; covenantPk: Uint8Array; fuelInputs: TxBuilderInput[]; recipientScript: Script; acceptedTokens?: bigint | undefined; dustAmount?: number | undefined; feePerKb?: number | undefined; allowUnspendable?: boolean | undefined; }'.
    250 |         const acceptTxSer = agoraOneshot
    251 |             .acceptTx({
  > 252 |                 ecc,
        |                 ^^^
    253 |                 covenantSk: DUMMY_KEYPAIR.sk,
    254 |                 covenantPk: DUMMY_KEYPAIR.pk,
    255 |                 fuelInputs: signedFuelInputs,


Build cashtab-tests failed with exit code 1

Tail of the build log:

> ecash-lib@1.5.1 build
> tsc && tsc -p ./tsconfig.build.json && cp -r ./src/ffi ./dist

/work/modules/ecash-agora /work/abc-ci-builds/cashtab-tests

added 364 packages, and audited 367 packages in 2s

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

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated eslint@8.56.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 1494 packages, and audited 3315 packages in 25s

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

8 vulnerabilities (4 moderate, 4 high)

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.

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

Creating an optimized production build...

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

[eslint] 
src/components/Agora/Collection/index.tsx
  Line 52:5:  'Ecc' is defined but never used  @typescript-eslint/no-unused-vars

src/components/Nfts/index.tsx
  Line 30:9:  'ecc' is assigned a value but never used  @typescript-eslint/no-unused-vars


Build cashtab-tests failed with exit code 1
bytesofman requested changes to this revision.EditedThu, Feb 6, 05:37

nice, step change in UX. much much much better for app devs.

although we are ahead of BTC in many respects already on the app dev side, this adds something else. BTC is still dealing with [[ https://github.com/bitcoinjs/bip32#readme | weird ecc injection issues ]] in bip32

punchlist

  • major version bump for ecash-lib + update changelog to reference this diff and D17640
  • major version bump for ecash-agora + update changelog to reference this diff and D17640
  • cashtab npm version patch
modules/ecash-agora/README.md
115

🔥

This revision now requires changes to proceed.Thu, Feb 6, 05:37
bytesofman requested changes to this revision.Thu, Feb 6, 17:55

changelog update to explain major version bump in ecash-agora

This revision now requires changes to proceed.Thu, Feb 6, 17:55

also update README.md in ecash-agora

This revision is now accepted and ready to land.Thu, Feb 6, 18:23