js-algorand-sdk
js-algorand-sdk copied to clipboard
More functions need to allow bigints as args
I am modifying Reach to always use bigint int decoding, but there are some problems...
- SuggestParams doesn't allow bigints in its fields
-
makeAssetTransferTxnWithSuggestedParams
-- specifically theassetIndex
could be a bigint -
makeApplicationXYZ
--- specifically the app id, foreign, and asset ids -
indexer.lookupApplications
-
indexer.searchForTransactions().minRound()
Summarizing outcomes from a group brainstorm:
- Philosophically, it feels most correct to change fields from
number
tobigint
everywhere that go-algorand defines auint64
data type. In practice, it causes a backwards incompatibility and adds some friction to developer ergonomics (can't perform arithmetic withnumber
andbigint
). - Given that changing field types feels out of reach, we agreed it'd be reasonable to expand function types to accept
number | bigint
+ perform safe coercion tonumber
. - We confirmed via visual inspection that Transaction construction defends against unsafe conversions to
number
usingNumber.isSafeInteger
. Here's an example check: https://github.com/algorand/js-algorand-sdk/blob/894e2871c2c41500716074052e3ffdc3f409e099/src/transaction.ts#L402-L411