Currently JS types every numeric field as number | bigint. This isn't very useful, since you can't operate directly against this union type.
This PR allows the generated types to use either number or bigint, depending mostly on the x-algorand-format: uint64 tag on fields. Previously this tag was only used to decided whether the Java SDK should use Long or BigInteger for a field.
However, there are two reasons why that approach can only go so far:
JS numbers are a unique size, so it's necessary to upgrade to bigint in cases where Java's Long would be sufficient.
The existing usage of the x-algorand-format: uint64 tag is lacking/inconsistent in some places.
To address these issues, I added the ability to manually override types by adding to one of the property files.
For consistency, I made the following quantities always have type bigint, even if they weren't declared with x-algorand-format: uint64 in the REST spec:
Algo balances/fees/rewards
Asset balances
Application and asset IDs
Round numbers and ranges of rounds (like upgradeDelay)
Currently JS types every numeric field as
number | bigint
. This isn't very useful, since you can't operate directly against this union type.This PR allows the generated types to use either
number
orbigint
, depending mostly on thex-algorand-format: uint64
tag on fields. Previously this tag was only used to decided whether the Java SDK should useLong
orBigInteger
for a field.However, there are two reasons why that approach can only go so far:
bigint
in cases where Java'sLong
would be sufficient.x-algorand-format: uint64
tag is lacking/inconsistent in some places.To address these issues, I added the ability to manually override types by adding to one of the property files.
For consistency, I made the following quantities always have type
bigint
, even if they weren't declared withx-algorand-format: uint64
in the REST spec:upgradeDelay
)These changes are present in this JS SDK PR: https://github.com/algorand/js-algorand-sdk/pull/852