Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More functions need to allow bigints as args #525

Open
jeapostrophe opened this issue Feb 22, 2022 · 1 comment
Open

More functions need to allow bigints as args #525

jeapostrophe opened this issue Feb 22, 2022 · 1 comment
Labels

Comments

@jeapostrophe
Copy link

jeapostrophe commented Feb 22, 2022

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 jeapostrophe added the new-bug Bug report that needs triage label Feb 22, 2022
@jeapostrophe jeapostrophe changed the title makeAssetTransferTxnWithSuggestedParams should allow bigints More functions need to allow bigints as args Feb 22, 2022
@barnjamin barnjamin added the good first issue Good for newcomers label Feb 23, 2022
@michaeldiamant
Copy link
Contributor

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:
    if (txn.appForeignApps !== undefined) {
    if (!Array.isArray(txn.appForeignApps))
    throw Error('appForeignApps must be an Array of integers.');
    txn.appForeignApps = txn.appForeignApps.slice();
    txn.appForeignApps.forEach((foreignAppIndex) => {
    if (!Number.isSafeInteger(foreignAppIndex) || foreignAppIndex < 0)
    throw Error(
    'each foreign application index must be a positive number and smaller than 2^53-1'
    );
    });

@algoanne algoanne removed the new-bug Bug report that needs triage label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@jeapostrophe @barnjamin @michaeldiamant @algochoi @algoanne and others