aepp-sdk-js icon indicating copy to clipboard operation
aepp-sdk-js copied to clipboard

rethink & consolidate usage of BigInt / BigNumber throughout the SDK

Open marc0olo opened this issue 3 years ago • 8 comments

known related issues / PRs:

  • https://github.com/aeternity/aepp-sdk-js/issues/1251
  • https://github.com/aeternity/aepp-sdk-js/pull/1259

we should maybe also consult with @dincho here.

marc0olo avatar Oct 11 '21 13:10 marc0olo

we should make a proposal how to proceed here.

marc0olo avatar Oct 11 '21 13:10 marc0olo

here the calldata-lib implementation:

  • https://github.com/aeternity/aepp-calldata-js

one important note here:

  • we can change code in both repositories! ... we should decide how to proceed with each component (SDK and calldata-lib)
  • we don't have to adapt everything in one repo of course ;-)

marc0olo avatar Oct 11 '21 13:10 marc0olo

another library related to that which is included in the SDK right now:

  • https://github.com/aeternity/json-bigint

marc0olo avatar Oct 11 '21 13:10 marc0olo

Some time before I was investigating the ability to implement a custom wrapper around bigint to represent ae coints, but this feature on TS side is missed https://github.com/microsoft/TypeScript/issues/2361

davidyuk avatar Feb 08 '23 18:02 davidyuk

Approximate roadmap (each step may be done separately):

  • [ ] don't use strings as numbers
  • [ ] use BigInt instead of BigNumber (drop BigNumber completely)
  • [ ] implement Ae wrapper around BigInt (uncertain)

I've touched on this topic in #1762 but it is too heavy for sdk@13

davidyuk avatar Feb 28 '23 04:02 davidyuk

almost forgot about this one 😅 good to see it being tackled 👍

marc0olo avatar Feb 28 '23 07:02 marc0olo

Optionally we can have a fancy way to define ae amounts

const aeAmount = ae`42.4`;
const fee = aettos`19320000000000`;

Also, may be useful to define something between ae and aettos, a multiple of MIN_GAS_PRICE (1e9). Because in the protocol amounts less than MIN_GAS_PRICE don't make sense.

davidyuk avatar Sep 22 '23 03:09 davidyuk

Some time before I was investigating the ability to implement a custom wrapper around bigint to represent ae coints, but this feature on TS side is missed microsoft/TypeScript#2361

That's the right way to go IMO

dincho avatar Sep 25 '23 06:09 dincho