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

More functions need to allow bigints as args

Open jeapostrophe opened this issue 3 years ago • 1 comments

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 the assetIndex could be a bigint
  • makeApplicationXYZ --- specifically the app id, foreign, and asset ids
  • indexer.lookupApplications
  • indexer.searchForTransactions().minRound()

jeapostrophe avatar Feb 22 '22 22:02 jeapostrophe

Summarizing outcomes from a group brainstorm:

  • Philosophically, it feels most correct to change fields from number to bigint everywhere that go-algorand defines a uint64 data type. In practice, it causes a backwards incompatibility and adds some friction to developer ergonomics (can't perform arithmetic with number and bigint).
  • 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 to number.
  • We confirmed via visual inspection that Transaction construction defends against unsafe conversions to number using Number.isSafeInteger. Here's an example check: https://github.com/algorand/js-algorand-sdk/blob/894e2871c2c41500716074052e3ffdc3f409e099/src/transaction.ts#L402-L411

michaeldiamant avatar Sep 08 '22 21:09 michaeldiamant