Page MenuHomePhabricator

[Cashtab] [bugfix] Patch genesis supply validation for ALP tokens in create token form and ensure large number input fields are string
ClosedPublic

Authored by bytesofman on Thu, Jan 2, 20:27.

Details

Summary

The necessary functions to do this were written as part of a broader refactor for better supporting multiple token types. But they were not implemented on the create token screen.

Note: The issue of large number input field was discovered in this diff. I considered splitting it out. However I think this diff is a good demonstration of the issue, and the test here confirms the implementation.

So I think it is worth landing this as a single diff. If we revert, the prod app already has bad alp validation, and we need the precision fix to confirm that with a (good) test.

Test Plan

npm test

Diff Detail

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

Event Timeline

bytesofman published this revision for review.Thu, Jan 2, 20:32
bytesofman retitled this revision from [Cashtab] Patch genesis supply validation for ALP tokens in create token form to [Cashtab] [bugfix] genesis supply validation for ALP tokens in create token form.Thu, Jan 2, 21:08
emack requested changes to this revision.Thu, Jan 2, 22:34
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/Etokens/__tests__/CreateTokenForm.test.js
526 ↗(On Diff #51935)

SLP max here 18446744073709551615 does not match the SLP max inputted above 18446744073709552000. How is this expect() passing?

This revision now requires changes to proceed.Thu, Jan 2, 22:34
bytesofman added inline comments.
cashtab/src/components/Etokens/__tests__/CreateTokenForm.test.js
526 ↗(On Diff #51935)

good catch.

this is coming from JS failing to render the precise number.

html input fields must be a number or a string. This field is a number.

really tho..it should be a string, because it is expected to occasionally have numbers that are too big for JS.

Updated and updated this test (and others) as appropriate.

I thought about splitting out that change from this diff (i.e., make sure all of our token qty input fields are string instead of number, then correct the bug here). imo it makes sense to combine them, since the issues are related.

bytesofman marked an inline comment as done.

make sure input fields that take amounts larger than JS max safe number are actually string fields

bytesofman retitled this revision from [Cashtab] [bugfix] genesis supply validation for ALP tokens in create token form to [Cashtab] [bugfix] Patch genesis supply validation for ALP tokens in create token form and ensure large number input fields are string.Thu, Jan 2, 23:34
bytesofman edited the summary of this revision. (Show Details)

Tail of the build log:

Run `npm audit` for details.

> ecash-lib@1.2.0 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.2.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 1489 packages, and audited 3310 packages in 25s

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

8 vulnerabilities (6 moderate, 2 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.9.1 build
> node scripts/build.js

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

TS2322: Type '{ placeholder: string; name: string; value: string; decimals: SlpDecimals; handleInput: (e: ChangeEvent<HTMLInputElement>) => void; error: string | false; handleOnMax: () => void; }' is not assignable to type 'IntrinsicAttributes & SendTokenInputProps'.
  Property 'decimals' does not exist on type 'IntrinsicAttributes & SendTokenInputProps'.
    1009 |                             name="genesisQty"
    1010 |                             value={formData.genesisQty}
  > 1011 |                             decimals={
         |                             ^^^^^^^^
    1012 |                                 parseInt(formData.decimals) as SlpDecimals
    1013 |                             }
    1014 |                             handleInput={handleInput}


Build cashtab-tests failed with exit code 1

Tail of the build log:

  npm audit fix

Run `npm audit` for details.

> ecash-lib@1.2.0 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.2.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 1489 packages, and audited 3310 packages in 24s

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

8 vulnerabilities (6 moderate, 2 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.9.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/Common/Inputs.tsx
  Line 10:10:  'SlpDecimals' is defined but never used  @typescript-eslint/no-unused-vars


Build cashtab-tests failed with exit code 1
emack requested changes to this revision.Fri, Jan 3, 03:00

Remove SlpDecimals import in Inputs.tsx to get the build working

This revision now requires changes to proceed.Fri, Jan 3, 03:00
This revision is now accepted and ready to land.Fri, Jan 3, 05:57