XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

Representation of `uint64` types #2789

Open ckeshava opened 1 week ago

ckeshava commented 1 week ago

I'd like clarification on the representation of UINT64 type in the xrpl.js library. This data type needs to support a maximum value of 18446744073709551615 (in base-10 representation) or 0xffffffffffffffff in base-16 format.

  1. The former input causes regular-expression failures in the below unit tests.
  2. What are the acceptable forms of BigInt representation? As explained in the comments, 18446744073709551615n causes a typescript compiler error. Whereas BigInt(18446744073709551615) causes a loss of precision. It appears that only BigInt('0xffffffffffffffff') is the format of input.

Reference unit tests: https://github.com/XRPLF/xrpl.js/compare/main...ckeshava:xrpl.js:uint_tests?expand=1