perun-network / erdstall-ts-sdk

TypeScript client SDK to interact with Erdstall.
Apache License 2.0
5 stars 2 forks source link

`target` property issue? #24

Open ndzik opened 3 years ago

ndzik commented 3 years ago

Looking at this and the fact we have es2020 as a target set in our tsconfig.json, we expect no problems.

However, including our lib in front end applications throws an error, in which bigint ** bigint falsely throws an Uncaught TypeError: Cannot convert a BigInt value to a number. Exponentiation like this is clearly supported as can be seen here, so we either have a problem with our project setup or this is a bug.

Further investigation needed. For the time being, we can just replace 2n ** 256n - 1n with the following:

const prettyNumber = 1n << 256n;
export const MAX_AMOUNT_VALUE = prettyNumber - 1n;

Using a temporary variable because prettier does not allow to use ( ) here to ensure correct operator precedence...