diff --git a/src/client/client.ts b/src/client/client.ts index 21db84ec4..7dbde5c48 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -120,9 +120,6 @@ export default class HTTPClient { jsonOptions: utils.JSONOptions = {} ) { try { - if (Object.keys(jsonOptions).length === 0) { - return text && JSON.parse(text); - } return text && utils.parseJSON(text, jsonOptions); } catch (err_) { const err: ErrorWithAdditionalInfo = err_; @@ -150,7 +147,7 @@ export default class HTTPClient { return new Uint8Array(0); // empty Uint8Array } if (requestHeaders['content-type'] === 'application/json') { - return new TextEncoder().encode(JSON.stringify(data)); + return new TextEncoder().encode(utils.stringifyJSON(data)); } if (typeof data === 'string') { return new TextEncoder().encode(data); diff --git a/src/client/v2/algod/accountApplicationInformation.ts b/src/client/v2/algod/accountApplicationInformation.ts index 26ec531c5..6499da0aa 100644 --- a/src/client/v2/algod/accountApplicationInformation.ts +++ b/src/client/v2/algod/accountApplicationInformation.ts @@ -1,15 +1,13 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class AccountApplicationInformation extends JSONRequest { constructor( c: HTTPClient, - intDecoding: IntDecoding, private account: string, private applicationID: number ) { - super(c, intDecoding); + super(c); this.account = account; this.applicationID = applicationID; } diff --git a/src/client/v2/algod/accountAssetInformation.ts b/src/client/v2/algod/accountAssetInformation.ts index f05e2f8da..ee92246ca 100644 --- a/src/client/v2/algod/accountAssetInformation.ts +++ b/src/client/v2/algod/accountAssetInformation.ts @@ -1,15 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class AccountAssetInformation extends JSONRequest { - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string, - private assetID: number - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string, private assetID: number) { + super(c); this.account = account; this.assetID = assetID; } diff --git a/src/client/v2/algod/accountInformation.ts b/src/client/v2/algod/accountInformation.ts index bbff87182..09d4542fa 100644 --- a/src/client/v2/algod/accountInformation.ts +++ b/src/client/v2/algod/accountInformation.ts @@ -1,14 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class AccountInformation extends JSONRequest { - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/algod/algod.ts b/src/client/v2/algod/algod.ts index 6a8a1a46f..5e81dfcc1 100644 --- a/src/client/v2/algod/algod.ts +++ b/src/client/v2/algod/algod.ts @@ -153,7 +153,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ accountInformation(account: string) { - return new AccountInformation(this.c, this.intDecoding, account); + return new AccountInformation(this.c, account); } /** @@ -172,12 +172,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ accountAssetInformation(account: string, index: number) { - return new AccountAssetInformation( - this.c, - this.intDecoding, - account, - index - ); + return new AccountAssetInformation(this.c, account, index); } /** @@ -196,12 +191,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ accountApplicationInformation(account: string, index: number) { - return new AccountApplicationInformation( - this.c, - this.intDecoding, - account, - index - ); + return new AccountApplicationInformation(this.c, account, index); } /** @@ -235,7 +225,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getBlockHash(roundNumber: number) { - return new GetBlockHash(this.c, this.intDecoding, roundNumber); + return new GetBlockHash(this.c, roundNumber); } /** @@ -330,7 +320,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ status() { - return new Status(this.c, this.intDecoding); + return new Status(this.c); } /** @@ -347,7 +337,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ statusAfterBlock(round: number) { - return new StatusAfterBlock(this.c, this.intDecoding, round); + return new StatusAfterBlock(this.c, round); } /** @@ -388,7 +378,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ supply() { - return new Supply(this.c, this.intDecoding); + return new Supply(this.c); } /** @@ -459,7 +449,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getAssetByID(index: number) { - return new GetAssetByID(this.c, this.intDecoding, index); + return new GetAssetByID(this.c, index); } /** @@ -477,7 +467,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getApplicationByID(index: number) { - return new GetApplicationByID(this.c, this.intDecoding, index); + return new GetApplicationByID(this.c, index); } /** @@ -496,12 +486,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getApplicationBoxByName(index: number, boxName: Uint8Array) { - return new GetApplicationBoxByName( - this.c, - this.intDecoding, - index, - boxName - ); + return new GetApplicationBoxByName(this.c, index, boxName); } /** @@ -519,7 +504,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getApplicationBoxes(index: number) { - return new GetApplicationBoxes(this.c, this.intDecoding, index); + return new GetApplicationBoxes(this.c, index); } /** @@ -534,7 +519,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ genesis() { - return new Genesis(this.c, this.intDecoding); + return new Genesis(this.c); } /** @@ -553,7 +538,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getTransactionProof(round: number, txID: string) { - return new GetTransactionProof(this.c, this.intDecoding, round, txID); + return new GetTransactionProof(this.c, round, txID); } /** @@ -569,7 +554,7 @@ export default class AlgodClient extends ServiceClient { * @param round */ getLightBlockHeaderProof(round: number) { - return new LightBlockHeaderProof(this.c, this.intDecoding, round); + return new LightBlockHeaderProof(this.c, round); } /** @@ -585,7 +570,7 @@ export default class AlgodClient extends ServiceClient { * @param round */ getStateProof(round: number) { - return new StateProof(this.c, this.intDecoding, round); + return new StateProof(this.c, round); } /** @@ -675,7 +660,7 @@ export default class AlgodClient extends ServiceClient { * @category POST */ setBlockOffsetTimestamp(offset: number) { - return new SetBlockOffsetTimestamp(this.c, this.intDecoding, offset); + return new SetBlockOffsetTimestamp(this.c, offset); } /** @@ -690,7 +675,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getBlockOffsetTimestamp() { - return new GetBlockOffsetTimestamp(this.c, this.intDecoding); + return new GetBlockOffsetTimestamp(this.c); } /** @@ -707,7 +692,7 @@ export default class AlgodClient extends ServiceClient { * @category POST */ setSyncRound(round: number) { - return new SetSyncRound(this.c, this.intDecoding, round); + return new SetSyncRound(this.c, round); } /** @@ -722,7 +707,7 @@ export default class AlgodClient extends ServiceClient { * @category DELETE */ unsetSyncRound() { - return new UnsetSyncRound(this.c, this.intDecoding); + return new UnsetSyncRound(this.c); } /** @@ -737,7 +722,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getSyncRound() { - return new GetSyncRound(this.c, this.intDecoding); + return new GetSyncRound(this.c); } /** @@ -752,7 +737,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ ready() { - return new Ready(this.c, this.intDecoding); + return new Ready(this.c); } /** @@ -769,11 +754,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getLedgerStateDeltaForTransactionGroup(id: string) { - return new GetLedgerStateDeltaForTransactionGroup( - this.c, - this.intDecoding, - id - ); + return new GetLedgerStateDeltaForTransactionGroup(this.c, id); } /** @@ -790,7 +771,7 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getLedgerStateDelta(round: bigint) { - return new GetLedgerStateDelta(this.c, this.intDecoding, round); + return new GetLedgerStateDelta(this.c, round); } /** @@ -807,10 +788,6 @@ export default class AlgodClient extends ServiceClient { * @category GET */ getTransactionGroupLedgerStateDeltasForRound(round: bigint) { - return new GetTransactionGroupLedgerStateDeltasForRound( - this.c, - this.intDecoding, - round - ); + return new GetTransactionGroupLedgerStateDeltasForRound(this.c, round); } } diff --git a/src/client/v2/algod/dryrun.ts b/src/client/v2/algod/dryrun.ts index 23089d977..86c00d985 100644 --- a/src/client/v2/algod/dryrun.ts +++ b/src/client/v2/algod/dryrun.ts @@ -9,7 +9,7 @@ export default class Dryrun extends JSONRequest { constructor(c: HTTPClient, dr: modelsv2.DryrunRequest) { super(c); - this.blob = encoding.encode(dr.get_obj_for_encoding(true)); + this.blob = encoding.encode(dr.get_obj_for_encoding(true, true)); } // eslint-disable-next-line class-methods-use-this diff --git a/src/client/v2/algod/getApplicationBoxByName.ts b/src/client/v2/algod/getApplicationBoxByName.ts index 246c3ba0d..efb81616f 100644 --- a/src/client/v2/algod/getApplicationBoxByName.ts +++ b/src/client/v2/algod/getApplicationBoxByName.ts @@ -1,5 +1,4 @@ import { bytesToBase64 } from '../../../encoding/binarydata'; -import IntDecoding from '../../../types/intDecoding'; import HTTPClient from '../../client'; import JSONRequest from '../jsonrequest'; import { Box } from './models/types'; @@ -23,13 +22,8 @@ export default class GetApplicationBoxByName extends JSONRequest< Box, Record > { - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private index: number, - name: Uint8Array - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number, name: Uint8Array) { + super(c); this.index = index; // Encode name in base64 format and append the encoding prefix. const encodedName = bytesToBase64(name); diff --git a/src/client/v2/algod/getApplicationBoxes.ts b/src/client/v2/algod/getApplicationBoxes.ts index 68f6f0447..3409f368c 100644 --- a/src/client/v2/algod/getApplicationBoxes.ts +++ b/src/client/v2/algod/getApplicationBoxes.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; import { BoxesResponse } from './models/types'; /** @@ -21,8 +20,8 @@ export default class GetApplicationBoxes extends JSONRequest< BoxesResponse, Record > { - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; this.query.max = 0; } diff --git a/src/client/v2/algod/getApplicationByID.ts b/src/client/v2/algod/getApplicationByID.ts index 91e1c12e1..3565c8731 100644 --- a/src/client/v2/algod/getApplicationByID.ts +++ b/src/client/v2/algod/getApplicationByID.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetApplicationByID extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/algod/getAssetByID.ts b/src/client/v2/algod/getAssetByID.ts index 3abb5696d..b6b540560 100644 --- a/src/client/v2/algod/getAssetByID.ts +++ b/src/client/v2/algod/getAssetByID.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetAssetByID extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/algod/getBlockHash.ts b/src/client/v2/algod/getBlockHash.ts index 40d01b499..ddd90dbeb 100644 --- a/src/client/v2/algod/getBlockHash.ts +++ b/src/client/v2/algod/getBlockHash.ts @@ -1,12 +1,11 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetBlockHash extends JSONRequest { round: number; - constructor(c: HTTPClient, intDecoding: IntDecoding, roundNumber: number) { - super(c, intDecoding); + constructor(c: HTTPClient, roundNumber: number) { + super(c); if (!Number.isInteger(roundNumber)) throw Error('roundNumber should be an integer'); this.round = roundNumber; diff --git a/src/client/v2/algod/getLedgerStateDelta.ts b/src/client/v2/algod/getLedgerStateDelta.ts index ac69daeab..371d44b09 100644 --- a/src/client/v2/algod/getLedgerStateDelta.ts +++ b/src/client/v2/algod/getLedgerStateDelta.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetLedgerStateDelta extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: bigint) { + super(c); this.round = round; this.query = { format: 'json' }; } diff --git a/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts b/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts index 4186232dc..fb69cd8c3 100644 --- a/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts +++ b/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetLedgerStateDeltaForTransactionGroup extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private id: string) { - super(c, intDecoding); + constructor(c: HTTPClient, private id: string) { + super(c); this.id = id; this.query = { format: 'json' }; } diff --git a/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts b/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts index 1c1776034..2f6b4d6ba 100644 --- a/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts +++ b/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts @@ -1,14 +1,13 @@ import JSONRequest from '../jsonrequest'; import { TransactionGroupLedgerStateDeltasForRoundResponse } from './models/types'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetTransactionGroupLedgerStateDeltasForRound extends JSONRequest< TransactionGroupLedgerStateDeltasForRoundResponse, Record > { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: bigint) { + super(c); this.round = round; this.query = { format: 'json' }; } diff --git a/src/client/v2/algod/getTransactionProof.ts b/src/client/v2/algod/getTransactionProof.ts index 398039a43..294be8311 100644 --- a/src/client/v2/algod/getTransactionProof.ts +++ b/src/client/v2/algod/getTransactionProof.ts @@ -1,15 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class GetTransactionProof extends JSONRequest { - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private round: number, - private txID: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number, private txID: string) { + super(c); this.round = round; this.txID = txID; diff --git a/src/client/v2/algod/lightBlockHeaderProof.ts b/src/client/v2/algod/lightBlockHeaderProof.ts index ac3794c36..3f9376bc8 100644 --- a/src/client/v2/algod/lightBlockHeaderProof.ts +++ b/src/client/v2/algod/lightBlockHeaderProof.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LightBlockHeaderProof extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number) { + super(c); this.round = round; } diff --git a/src/client/v2/algod/models/types.ts b/src/client/v2/algod/models/types.ts index 020d176ca..e6c011a45 100644 --- a/src/client/v2/algod/models/types.ts +++ b/src/client/v2/algod/models/types.ts @@ -22,34 +22,34 @@ export class Account extends BaseModel { /** * (algo) total number of MicroAlgos in the account */ - public amount: number | bigint; + public amount: bigint; /** * specifies the amount of MicroAlgos in the account, without the pending rewards. */ - public amountWithoutPendingRewards: number | bigint; + public amountWithoutPendingRewards: bigint; /** * MicroAlgo balance required by the account. * The requirement grows based on asset and application usage. */ - public minBalance: number | bigint; + public minBalance: bigint; /** * amount of MicroAlgos of pending rewards in this account. */ - public pendingRewards: number | bigint; + public pendingRewards: bigint; /** * (ern) total rewards of MicroAlgos the account has received, including pending * rewards. */ - public rewards: number | bigint; + public rewards: bigint; /** * The round for which this information is relevant. */ - public round: number | bigint; + public round: bigint; /** * (onl) delegation status of the account's MicroAlgos @@ -65,23 +65,23 @@ export class Account extends BaseModel { * The count of all applications that have been opted in, equivalent to the count * of application local data (AppLocalState objects) stored in this account. */ - public totalAppsOptedIn: number | bigint; + public totalAppsOptedIn: bigint; /** * The count of all assets that have been opted in, equivalent to the count of * AssetHolding objects held by this account. */ - public totalAssetsOptedIn: number | bigint; + public totalAssetsOptedIn: bigint; /** * The count of all apps (AppParams objects) created by this account. */ - public totalCreatedApps: number | bigint; + public totalCreatedApps: bigint; /** * The count of all assets (AssetParams objects) created by this account. */ - public totalCreatedAssets: number | bigint; + public totalCreatedAssets: bigint; /** * (appl) applications local data stored in this account. @@ -92,7 +92,7 @@ export class Account extends BaseModel { /** * (teap) the sum of all extra application program pages for this account. */ - public appsTotalExtraPages?: number | bigint; + public appsTotalExtraPages?: bigint; /** * (tsch) stores the sum of all of the local schemas and global schemas in this @@ -137,7 +137,7 @@ export class Account extends BaseModel { * (ebase) used as part of the rewards computation. Only applicable to accounts * which are participating. */ - public rewardBase?: number | bigint; + public rewardBase?: bigint; /** * Indicates what type of signature is used by this account, must be one of: @@ -151,12 +151,12 @@ export class Account extends BaseModel { * (tbxb) The total number of bytes used by this account's app's box keys and * values. */ - public totalBoxBytes?: number | bigint; + public totalBoxBytes?: bigint; /** * (tbx) The number of existing boxes created by this account's app. */ - public totalBoxes?: number | bigint; + public totalBoxes?: bigint; /** * Creates a new `Account` object. @@ -262,29 +262,35 @@ export class Account extends BaseModel { }) { super(); this.address = address; - this.amount = amount; - this.amountWithoutPendingRewards = amountWithoutPendingRewards; - this.minBalance = minBalance; - this.pendingRewards = pendingRewards; - this.rewards = rewards; - this.round = round; + this.amount = BigInt(amount); + this.amountWithoutPendingRewards = BigInt(amountWithoutPendingRewards); + this.minBalance = BigInt(minBalance); + this.pendingRewards = BigInt(pendingRewards); + this.rewards = BigInt(rewards); + this.round = BigInt(round); this.status = status; - this.totalAppsOptedIn = totalAppsOptedIn; - this.totalAssetsOptedIn = totalAssetsOptedIn; - this.totalCreatedApps = totalCreatedApps; - this.totalCreatedAssets = totalCreatedAssets; + this.totalAppsOptedIn = BigInt(totalAppsOptedIn); + this.totalAssetsOptedIn = BigInt(totalAssetsOptedIn); + this.totalCreatedApps = BigInt(totalCreatedApps); + this.totalCreatedAssets = BigInt(totalCreatedAssets); this.appsLocalState = appsLocalState; - this.appsTotalExtraPages = appsTotalExtraPages; + this.appsTotalExtraPages = + typeof appsTotalExtraPages === 'undefined' + ? undefined + : BigInt(appsTotalExtraPages); this.appsTotalSchema = appsTotalSchema; this.assets = assets; this.authAddr = authAddr; this.createdApps = createdApps; this.createdAssets = createdAssets; this.participation = participation; - this.rewardBase = rewardBase; + this.rewardBase = + typeof rewardBase === 'undefined' ? undefined : BigInt(rewardBase); this.sigType = sigType; - this.totalBoxBytes = totalBoxBytes; - this.totalBoxes = totalBoxes; + this.totalBoxBytes = + typeof totalBoxBytes === 'undefined' ? undefined : BigInt(totalBoxBytes); + this.totalBoxes = + typeof totalBoxes === 'undefined' ? undefined : BigInt(totalBoxes); this.attribute_map = { address: 'address', @@ -417,7 +423,7 @@ export class AccountApplicationResponse extends BaseModel { /** * The round for which this information is relevant. */ - public round: number | bigint; + public round: bigint; /** * (appl) the application local data stored in this account. @@ -451,7 +457,7 @@ export class AccountApplicationResponse extends BaseModel { createdApp?: ApplicationParams; }) { super(); - this.round = round; + this.round = BigInt(round); this.appLocalState = appLocalState; this.createdApp = createdApp; @@ -493,7 +499,7 @@ export class AccountAssetResponse extends BaseModel { /** * The round for which this information is relevant. */ - public round: number | bigint; + public round: bigint; /** * (asset) Details about the asset held by this account. @@ -525,7 +531,7 @@ export class AccountAssetResponse extends BaseModel { createdAsset?: AssetParams; }) { super(); - this.round = round; + this.round = BigInt(round); this.assetHolding = assetHolding; this.createdAsset = createdAsset; @@ -571,17 +577,17 @@ export class AccountParticipation extends BaseModel { /** * (voteFst) First round for which this participation is valid. */ - public voteFirstValid: number | bigint; + public voteFirstValid: bigint; /** * (voteKD) Number of subkeys in each batch of participation keys. */ - public voteKeyDilution: number | bigint; + public voteKeyDilution: bigint; /** * (voteLst) Last round for which this participation is valid. */ - public voteLastValid: number | bigint; + public voteLastValid: bigint; /** * (vote) root participation public key (if any) currently registered for this @@ -624,9 +630,9 @@ export class AccountParticipation extends BaseModel { typeof selectionParticipationKey === 'string' ? base64ToBytes(selectionParticipationKey) : selectionParticipationKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; + this.voteFirstValid = BigInt(voteFirstValid); + this.voteKeyDilution = BigInt(voteKeyDilution); + this.voteLastValid = BigInt(voteLastValid); this.voteParticipationKey = typeof voteParticipationKey === 'string' ? base64ToBytes(voteParticipationKey) @@ -740,7 +746,7 @@ export class Application extends BaseModel { /** * (appidx) application index. */ - public id: number | bigint; + public id: bigint; /** * (appparams) application parameters. @@ -760,7 +766,7 @@ export class Application extends BaseModel { params: ApplicationParams; }) { super(); - this.id = id; + this.id = BigInt(id); this.params = params; this.attribute_map = { @@ -784,6 +790,53 @@ export class Application extends BaseModel { } } +/** + * References an account's local state for an application. + */ +export class ApplicationLocalReference extends BaseModel { + /** + * Address of the account with the local state. + */ + public account: string; + + /** + * Application ID of the local state application. + */ + public app: bigint; + + /** + * Creates a new `ApplicationLocalReference` object. + * @param account - Address of the account with the local state. + * @param app - Application ID of the local state application. + */ + constructor({ account, app }: { account: string; app: number | bigint }) { + super(); + this.account = account; + this.app = BigInt(app); + + this.attribute_map = { + account: 'account', + app: 'app', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding( + data: Record + ): ApplicationLocalReference { + /* eslint-disable dot-notation */ + if (typeof data['account'] === 'undefined') + throw new Error(`Response is missing required field 'account': ${data}`); + if (typeof data['app'] === 'undefined') + throw new Error(`Response is missing required field 'app': ${data}`); + return new ApplicationLocalReference({ + account: data['account'], + app: data['app'], + }); + /* eslint-enable dot-notation */ + } +} + /** * Stores local state associated with an application. */ @@ -791,7 +844,7 @@ export class ApplicationLocalState extends BaseModel { /** * The application which this local state is for. */ - public id: number | bigint; + public id: bigint; /** * (hsch) schema. @@ -819,7 +872,7 @@ export class ApplicationLocalState extends BaseModel { keyValue?: TealKeyValue[]; }) { super(); - this.id = id; + this.id = BigInt(id); this.schema = schema; this.keyValue = keyValue; @@ -874,7 +927,7 @@ export class ApplicationParams extends BaseModel { /** * (epp) the amount of extra program pages available to this app. */ - public extraProgramPages?: number | bigint; + public extraProgramPages?: bigint; /** * (gs) global state @@ -929,7 +982,10 @@ export class ApplicationParams extends BaseModel { ? base64ToBytes(clearStateProgram) : clearStateProgram; this.creator = creator; - this.extraProgramPages = extraProgramPages; + this.extraProgramPages = + typeof extraProgramPages === 'undefined' + ? undefined + : BigInt(extraProgramPages); this.globalState = globalState; this.globalStateSchema = globalStateSchema; this.localStateSchema = localStateSchema; @@ -991,12 +1047,12 @@ export class ApplicationStateSchema extends BaseModel { /** * (nui) num of uints. */ - public numUint: number | bigint; + public numUint: bigint; /** * (nbs) num of byte slices. */ - public numByteSlice: number | bigint; + public numByteSlice: bigint; /** * Creates a new `ApplicationStateSchema` object. @@ -1011,8 +1067,8 @@ export class ApplicationStateSchema extends BaseModel { numByteSlice: number | bigint; }) { super(); - this.numUint = numUint; - this.numByteSlice = numByteSlice; + this.numUint = BigInt(numUint); + this.numByteSlice = BigInt(numByteSlice); this.attribute_map = { numUint: 'num-uint', @@ -1046,7 +1102,7 @@ export class Asset extends BaseModel { /** * unique asset identifier */ - public index: number | bigint; + public index: bigint; /** * AssetParams specifies the parameters for an asset. @@ -1072,7 +1128,7 @@ export class Asset extends BaseModel { params: AssetParams; }) { super(); - this.index = index; + this.index = BigInt(index); this.params = params; this.attribute_map = { @@ -1105,12 +1161,12 @@ export class AssetHolding extends BaseModel { /** * (a) number of units held. */ - public amount: number | bigint; + public amount: bigint; /** * Asset ID of the holding. */ - public assetId: number | bigint; + public assetId: bigint; /** * (f) whether or not the holding is frozen. @@ -1133,8 +1189,8 @@ export class AssetHolding extends BaseModel { isFrozen: boolean; }) { super(); - this.amount = amount; - this.assetId = assetId; + this.amount = BigInt(amount); + this.assetId = BigInt(assetId); this.isFrozen = isFrozen; this.attribute_map = { @@ -1164,6 +1220,53 @@ export class AssetHolding extends BaseModel { } } +/** + * References an asset held by an account. + */ +export class AssetHoldingReference extends BaseModel { + /** + * Address of the account holding the asset. + */ + public account: string; + + /** + * Asset ID of the holding. + */ + public asset: bigint; + + /** + * Creates a new `AssetHoldingReference` object. + * @param account - Address of the account holding the asset. + * @param asset - Asset ID of the holding. + */ + constructor({ account, asset }: { account: string; asset: number | bigint }) { + super(); + this.account = account; + this.asset = BigInt(asset); + + this.attribute_map = { + account: 'account', + asset: 'asset', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding( + data: Record + ): AssetHoldingReference { + /* eslint-disable dot-notation */ + if (typeof data['account'] === 'undefined') + throw new Error(`Response is missing required field 'account': ${data}`); + if (typeof data['asset'] === 'undefined') + throw new Error(`Response is missing required field 'asset': ${data}`); + return new AssetHoldingReference({ + account: data['account'], + asset: data['asset'], + }); + /* eslint-enable dot-notation */ + } +} + /** * AssetParams specifies the parameters for an asset. * (apar) when part of an AssetConfig transaction. @@ -1184,12 +1287,12 @@ export class AssetParams extends BaseModel { * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value * must be between 0 and 19 (inclusive). */ - public decimals: number | bigint; + public decimals: bigint; /** * (t) The total number of units of this asset. */ - public total: number | bigint; + public total: bigint; /** * (c) Address of account used to clawback holdings of this asset. If empty, @@ -1321,8 +1424,8 @@ export class AssetParams extends BaseModel { }) { super(); this.creator = creator; - this.decimals = decimals; - this.total = total; + this.decimals = BigInt(decimals); + this.total = BigInt(total); this.clawback = clawback; this.defaultFrozen = defaultFrozen; this.freeze = freeze; @@ -1392,6 +1495,66 @@ export class AssetParams extends BaseModel { } } +/** + * Represents an AVM value. + */ +export class AvmValue extends BaseModel { + /** + * value type. Value `1` refers to **bytes**, value `2` refers to **uint64** + */ + public type: bigint; + + /** + * bytes value. + */ + public bytes?: Uint8Array; + + /** + * uint value. + */ + public uint?: bigint; + + /** + * Creates a new `AvmValue` object. + * @param type - value type. Value `1` refers to **bytes**, value `2` refers to **uint64** + * @param bytes - bytes value. + * @param uint - uint value. + */ + constructor({ + type, + bytes, + uint, + }: { + type: number | bigint; + bytes?: string | Uint8Array; + uint?: number | bigint; + }) { + super(); + this.type = BigInt(type); + this.bytes = typeof bytes === 'string' ? base64ToBytes(bytes) : bytes; + this.uint = typeof uint === 'undefined' ? undefined : BigInt(uint); + + this.attribute_map = { + type: 'type', + bytes: 'bytes', + uint: 'uint', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding(data: Record): AvmValue { + /* eslint-disable dot-notation */ + if (typeof data['type'] === 'undefined') + throw new Error(`Response is missing required field 'type': ${data}`); + return new AvmValue({ + type: data['type'], + bytes: data['bytes'], + uint: data['uint'], + }); + /* eslint-enable dot-notation */ + } +} + /** * Hash of a block header. */ @@ -1479,6 +1642,42 @@ export class BlockResponse extends BaseModel { } } +/** + * Top level transaction IDs in a block. + */ +export class BlockTxidsResponse extends BaseModel { + /** + * Block transaction IDs. + */ + public blocktxids: string[]; + + /** + * Creates a new `BlockTxidsResponse` object. + * @param blocktxids - Block transaction IDs. + */ + constructor({ blocktxids }: { blocktxids: string[] }) { + super(); + this.blocktxids = blocktxids; + + this.attribute_map = { + blocktxids: 'blockTxids', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding(data: Record): BlockTxidsResponse { + /* eslint-disable dot-notation */ + if (!Array.isArray(data['blockTxids'])) + throw new Error( + `Response is missing required array field 'blockTxids': ${data}` + ); + return new BlockTxidsResponse({ + blocktxids: data['blockTxids'], + }); + /* eslint-enable dot-notation */ + } +} + /** * Box name and its content. */ @@ -1491,7 +1690,7 @@ export class Box extends BaseModel { /** * The round for which this information is relevant */ - public round: number | bigint; + public round: bigint; /** * (value) box value, base64 encoded. @@ -1515,7 +1714,7 @@ export class Box extends BaseModel { }) { super(); this.name = typeof name === 'string' ? base64ToBytes(name) : name; - this.round = round; + this.round = BigInt(round); this.value = typeof value === 'string' ? base64ToBytes(value) : value; this.attribute_map = { @@ -1577,6 +1776,57 @@ export class BoxDescriptor extends BaseModel { } } +/** + * References a box of an application. + */ +export class BoxReference extends BaseModel { + /** + * Application ID which this box belongs to + */ + public app: bigint; + + /** + * Base64 encoded box name + */ + public name: Uint8Array; + + /** + * Creates a new `BoxReference` object. + * @param app - Application ID which this box belongs to + * @param name - Base64 encoded box name + */ + constructor({ + app, + name, + }: { + app: number | bigint; + name: string | Uint8Array; + }) { + super(); + this.app = BigInt(app); + this.name = typeof name === 'string' ? base64ToBytes(name) : name; + + this.attribute_map = { + app: 'app', + name: 'name', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding(data: Record): BoxReference { + /* eslint-disable dot-notation */ + if (typeof data['app'] === 'undefined') + throw new Error(`Response is missing required field 'app': ${data}`); + if (typeof data['name'] === 'undefined') + throw new Error(`Response is missing required field 'name': ${data}`); + return new BoxReference({ + app: data['app'], + name: data['name'], + }); + /* eslint-enable dot-notation */ + } +} + /** * Box names of an application */ @@ -1613,15 +1863,15 @@ export class BoxesResponse extends BaseModel { export class BuildVersion extends BaseModel { public branch: string; - public buildNumber: number | bigint; + public buildNumber: bigint; public channel: string; public commitHash: string; - public major: number | bigint; + public major: bigint; - public minor: number | bigint; + public minor: bigint; /** * Creates a new `BuildVersion` object. @@ -1649,11 +1899,11 @@ export class BuildVersion extends BaseModel { }) { super(); this.branch = branch; - this.buildNumber = buildNumber; + this.buildNumber = BigInt(buildNumber); this.channel = channel; this.commitHash = commitHash; - this.major = major; - this.minor = minor; + this.major = BigInt(major); + this.minor = BigInt(minor); this.attribute_map = { branch: 'branch', @@ -1805,7 +2055,7 @@ export class DryrunRequest extends BaseModel { * LatestTimestamp is available to some TEAL scripts. Defaults to the latest * confirmed timestamp this algod is attached to. */ - public latestTimestamp: number | bigint; + public latestTimestamp: bigint; /** * ProtocolVersion specifies a specific version string to operate under, otherwise @@ -1817,7 +2067,7 @@ export class DryrunRequest extends BaseModel { * Round is available to some TEAL scripts. Defaults to the current round on the * network this algod is attached to. */ - public round: number | bigint; + public round: bigint; public sources: DryrunSource[]; @@ -1856,9 +2106,9 @@ export class DryrunRequest extends BaseModel { super(); this.accounts = accounts; this.apps = apps; - this.latestTimestamp = latestTimestamp; + this.latestTimestamp = BigInt(latestTimestamp); this.protocolVersion = protocolVersion; - this.round = round; + this.round = BigInt(round); this.sources = sources; this.txns = txns; @@ -1991,9 +2241,9 @@ export class DryrunSource extends BaseModel { public source: string; - public txnIndex: number | bigint; + public txnIndex: bigint; - public appIndex: number | bigint; + public appIndex: bigint; /** * Creates a new `DryrunSource` object. @@ -2018,8 +2268,8 @@ export class DryrunSource extends BaseModel { super(); this.fieldName = fieldName; this.source = source; - this.txnIndex = txnIndex; - this.appIndex = appIndex; + this.txnIndex = BigInt(txnIndex); + this.appIndex = BigInt(appIndex); this.attribute_map = { fieldName: 'field-name', @@ -2063,12 +2313,12 @@ export class DryrunState extends BaseModel { /** * Line number */ - public line: number | bigint; + public line: bigint; /** * Program counter */ - public pc: number | bigint; + public pc: bigint; public stack: TealValue[]; @@ -2101,8 +2351,8 @@ export class DryrunState extends BaseModel { scratch?: TealValue[]; }) { super(); - this.line = line; - this.pc = pc; + this.line = BigInt(line); + this.pc = BigInt(pc); this.stack = stack; this.error = error; this.scratch = scratch; @@ -2158,12 +2408,12 @@ export class DryrunTxnResult extends BaseModel { /** * Budget added during execution of app call transaction. */ - public budgetAdded?: number | bigint; + public budgetAdded?: bigint; /** * Budget consumed during execution of app call transaction. */ - public budgetConsumed?: number | bigint; + public budgetConsumed?: bigint; /** * Application state delta. @@ -2226,8 +2476,12 @@ export class DryrunTxnResult extends BaseModel { this.disassembly = disassembly; this.appCallMessages = appCallMessages; this.appCallTrace = appCallTrace; - this.budgetAdded = budgetAdded; - this.budgetConsumed = budgetConsumed; + this.budgetAdded = + typeof budgetAdded === 'undefined' ? undefined : BigInt(budgetAdded); + this.budgetConsumed = + typeof budgetConsumed === 'undefined' + ? undefined + : BigInt(budgetConsumed); this.globalDelta = globalDelta; this.localDeltas = localDeltas; this.logicSigDisassembly = logicSigDisassembly; @@ -2336,7 +2590,7 @@ export class EvalDelta extends BaseModel { /** * (at) delta action. */ - public action: number | bigint; + public action: bigint; /** * (bs) bytes value. @@ -2346,7 +2600,7 @@ export class EvalDelta extends BaseModel { /** * (ui) uint value. */ - public uint?: number | bigint; + public uint?: bigint; /** * Creates a new `EvalDelta` object. @@ -2364,9 +2618,9 @@ export class EvalDelta extends BaseModel { uint?: number | bigint; }) { super(); - this.action = action; + this.action = BigInt(action); this.bytes = bytes; - this.uint = uint; + this.uint = typeof uint === 'undefined' ? undefined : BigInt(uint); this.attribute_map = { action: 'action', @@ -2438,7 +2692,7 @@ export class GetBlockTimeStampOffsetResponse extends BaseModel { /** * Timestamp offset in seconds. */ - public offset: number | bigint; + public offset: bigint; /** * Creates a new `GetBlockTimeStampOffsetResponse` object. @@ -2446,7 +2700,7 @@ export class GetBlockTimeStampOffsetResponse extends BaseModel { */ constructor({ offset }: { offset: number | bigint }) { super(); - this.offset = offset; + this.offset = BigInt(offset); this.attribute_map = { offset: 'offset', @@ -2474,7 +2728,7 @@ export class GetSyncRoundResponse extends BaseModel { /** * The minimum sync round for the ledger. */ - public round: number | bigint; + public round: bigint; /** * Creates a new `GetSyncRoundResponse` object. @@ -2482,7 +2736,7 @@ export class GetSyncRoundResponse extends BaseModel { */ constructor({ round }: { round: number | bigint }) { super(); - this.round = round; + this.round = BigInt(round); this.attribute_map = { round: 'round', @@ -2604,7 +2858,7 @@ export class LightBlockHeaderProof extends BaseModel { /** * The index of the light block header in the vector commitment tree */ - public index: number | bigint; + public index: bigint; /** * The encoded proof. @@ -2615,7 +2869,7 @@ export class LightBlockHeaderProof extends BaseModel { * Represents the depth of the tree that is being proven, i.e. the number of edges * from a leaf to the root. */ - public treedepth: number | bigint; + public treedepth: bigint; /** * Creates a new `LightBlockHeaderProof` object. @@ -2634,9 +2888,9 @@ export class LightBlockHeaderProof extends BaseModel { treedepth: number | bigint; }) { super(); - this.index = index; + this.index = BigInt(index); this.proof = typeof proof === 'string' ? base64ToBytes(proof) : proof; - this.treedepth = treedepth; + this.treedepth = BigInt(treedepth); this.attribute_map = { index: 'index', @@ -2674,12 +2928,12 @@ export class NodeStatusResponse extends BaseModel { /** * CatchupTime in nanoseconds */ - public catchupTime: number | bigint; + public catchupTime: bigint; /** * LastRound indicates the last round seen */ - public lastRound: number | bigint; + public lastRound: bigint; /** * LastVersion indicates the last consensus version supported @@ -2694,7 +2948,7 @@ export class NodeStatusResponse extends BaseModel { /** * NextVersionRound is the round at which the next consensus version will apply */ - public nextVersionRound: number | bigint; + public nextVersionRound: bigint; /** * NextVersionSupported indicates whether the next consensus version is supported @@ -2711,7 +2965,7 @@ export class NodeStatusResponse extends BaseModel { /** * TimeSinceLastRound in nanoseconds */ - public timeSinceLastRound: number | bigint; + public timeSinceLastRound: bigint; /** * The current catchpoint that is being caught up to @@ -2722,47 +2976,47 @@ export class NodeStatusResponse extends BaseModel { * The number of blocks that have already been obtained by the node as part of the * catchup */ - public catchpointAcquiredBlocks?: number | bigint; + public catchpointAcquiredBlocks?: bigint; /** * The number of accounts from the current catchpoint that have been processed so * far as part of the catchup */ - public catchpointProcessedAccounts?: number | bigint; + public catchpointProcessedAccounts?: bigint; /** * The number of key-values (KVs) from the current catchpoint that have been * processed so far as part of the catchup */ - public catchpointProcessedKvs?: number | bigint; + public catchpointProcessedKvs?: bigint; /** * The total number of accounts included in the current catchpoint */ - public catchpointTotalAccounts?: number | bigint; + public catchpointTotalAccounts?: bigint; /** * The total number of blocks that are required to complete the current catchpoint * catchup */ - public catchpointTotalBlocks?: number | bigint; + public catchpointTotalBlocks?: bigint; /** * The total number of key-values (KVs) included in the current catchpoint */ - public catchpointTotalKvs?: number | bigint; + public catchpointTotalKvs?: bigint; /** * The number of accounts from the current catchpoint that have been verified so * far as part of the catchup */ - public catchpointVerifiedAccounts?: number | bigint; + public catchpointVerifiedAccounts?: bigint; /** * The number of key-values (KVs) from the current catchpoint that have been * verified so far as part of the catchup */ - public catchpointVerifiedKvs?: number | bigint; + public catchpointVerifiedKvs?: bigint; /** * The last catchpoint seen by the node @@ -2772,17 +3026,17 @@ export class NodeStatusResponse extends BaseModel { /** * Upgrade delay */ - public upgradeDelay?: number | bigint; + public upgradeDelay?: bigint; /** * Next protocol round */ - public upgradeNextProtocolVoteBefore?: number | bigint; + public upgradeNextProtocolVoteBefore?: bigint; /** * No votes cast for consensus upgrade */ - public upgradeNoVotes?: number | bigint; + public upgradeNoVotes?: bigint; /** * This node's upgrade vote @@ -2792,22 +3046,22 @@ export class NodeStatusResponse extends BaseModel { /** * Total voting rounds for current upgrade */ - public upgradeVoteRounds?: number | bigint; + public upgradeVoteRounds?: bigint; /** * Total votes cast for consensus upgrade */ - public upgradeVotes?: number | bigint; + public upgradeVotes?: bigint; /** * Yes votes required for consensus upgrade */ - public upgradeVotesRequired?: number | bigint; + public upgradeVotesRequired?: bigint; /** * Yes votes cast for consensus upgrade */ - public upgradeYesVotes?: number | bigint; + public upgradeYesVotes?: bigint; /** * Creates a new `NodeStatusResponse` object. @@ -2902,32 +3156,73 @@ export class NodeStatusResponse extends BaseModel { upgradeYesVotes?: number | bigint; }) { super(); - this.catchupTime = catchupTime; - this.lastRound = lastRound; + this.catchupTime = BigInt(catchupTime); + this.lastRound = BigInt(lastRound); this.lastVersion = lastVersion; this.nextVersion = nextVersion; - this.nextVersionRound = nextVersionRound; + this.nextVersionRound = BigInt(nextVersionRound); this.nextVersionSupported = nextVersionSupported; this.stoppedAtUnsupportedRound = stoppedAtUnsupportedRound; - this.timeSinceLastRound = timeSinceLastRound; + this.timeSinceLastRound = BigInt(timeSinceLastRound); this.catchpoint = catchpoint; - this.catchpointAcquiredBlocks = catchpointAcquiredBlocks; - this.catchpointProcessedAccounts = catchpointProcessedAccounts; - this.catchpointProcessedKvs = catchpointProcessedKvs; - this.catchpointTotalAccounts = catchpointTotalAccounts; - this.catchpointTotalBlocks = catchpointTotalBlocks; - this.catchpointTotalKvs = catchpointTotalKvs; - this.catchpointVerifiedAccounts = catchpointVerifiedAccounts; - this.catchpointVerifiedKvs = catchpointVerifiedKvs; + this.catchpointAcquiredBlocks = + typeof catchpointAcquiredBlocks === 'undefined' + ? undefined + : BigInt(catchpointAcquiredBlocks); + this.catchpointProcessedAccounts = + typeof catchpointProcessedAccounts === 'undefined' + ? undefined + : BigInt(catchpointProcessedAccounts); + this.catchpointProcessedKvs = + typeof catchpointProcessedKvs === 'undefined' + ? undefined + : BigInt(catchpointProcessedKvs); + this.catchpointTotalAccounts = + typeof catchpointTotalAccounts === 'undefined' + ? undefined + : BigInt(catchpointTotalAccounts); + this.catchpointTotalBlocks = + typeof catchpointTotalBlocks === 'undefined' + ? undefined + : BigInt(catchpointTotalBlocks); + this.catchpointTotalKvs = + typeof catchpointTotalKvs === 'undefined' + ? undefined + : BigInt(catchpointTotalKvs); + this.catchpointVerifiedAccounts = + typeof catchpointVerifiedAccounts === 'undefined' + ? undefined + : BigInt(catchpointVerifiedAccounts); + this.catchpointVerifiedKvs = + typeof catchpointVerifiedKvs === 'undefined' + ? undefined + : BigInt(catchpointVerifiedKvs); this.lastCatchpoint = lastCatchpoint; - this.upgradeDelay = upgradeDelay; - this.upgradeNextProtocolVoteBefore = upgradeNextProtocolVoteBefore; - this.upgradeNoVotes = upgradeNoVotes; + this.upgradeDelay = + typeof upgradeDelay === 'undefined' ? undefined : BigInt(upgradeDelay); + this.upgradeNextProtocolVoteBefore = + typeof upgradeNextProtocolVoteBefore === 'undefined' + ? undefined + : BigInt(upgradeNextProtocolVoteBefore); + this.upgradeNoVotes = + typeof upgradeNoVotes === 'undefined' + ? undefined + : BigInt(upgradeNoVotes); this.upgradeNodeVote = upgradeNodeVote; - this.upgradeVoteRounds = upgradeVoteRounds; - this.upgradeVotes = upgradeVotes; - this.upgradeVotesRequired = upgradeVotesRequired; - this.upgradeYesVotes = upgradeYesVotes; + this.upgradeVoteRounds = + typeof upgradeVoteRounds === 'undefined' + ? undefined + : BigInt(upgradeVoteRounds); + this.upgradeVotes = + typeof upgradeVotes === 'undefined' ? undefined : BigInt(upgradeVotes); + this.upgradeVotesRequired = + typeof upgradeVotesRequired === 'undefined' + ? undefined + : BigInt(upgradeVotesRequired); + this.upgradeYesVotes = + typeof upgradeYesVotes === 'undefined' + ? undefined + : BigInt(upgradeYesVotes); this.attribute_map = { catchupTime: 'catchup-time', @@ -3047,32 +3342,32 @@ export class PendingTransactionResponse extends BaseModel { * The application index if the transaction was found and it created an * application. */ - public applicationIndex?: number | bigint; + public applicationIndex?: bigint; /** * The number of the asset's unit that were transferred to the close-to address. */ - public assetClosingAmount?: number | bigint; + public assetClosingAmount?: bigint; /** * The asset index if the transaction was found and it created an asset. */ - public assetIndex?: number | bigint; + public assetIndex?: bigint; /** * Rewards in microalgos applied to the close remainder to account. */ - public closeRewards?: number | bigint; + public closeRewards?: bigint; /** * Closing amount for the transaction. */ - public closingAmount?: number | bigint; + public closingAmount?: bigint; /** * The round where this transaction was confirmed, if present. */ - public confirmedRound?: number | bigint; + public confirmedRound?: bigint; /** * Global state key/value changes for the application being executed by this @@ -3099,12 +3394,12 @@ export class PendingTransactionResponse extends BaseModel { /** * Rewards in microalgos applied to the receiver account. */ - public receiverRewards?: number | bigint; + public receiverRewards?: bigint; /** * Rewards in microalgos applied to the sender account. */ - public senderRewards?: number | bigint; + public senderRewards?: bigint; /** * Creates a new `PendingTransactionResponse` object. @@ -3162,18 +3457,34 @@ export class PendingTransactionResponse extends BaseModel { super(); this.poolError = poolError; this.txn = txn; - this.applicationIndex = applicationIndex; - this.assetClosingAmount = assetClosingAmount; - this.assetIndex = assetIndex; - this.closeRewards = closeRewards; - this.closingAmount = closingAmount; - this.confirmedRound = confirmedRound; + this.applicationIndex = + typeof applicationIndex === 'undefined' + ? undefined + : BigInt(applicationIndex); + this.assetClosingAmount = + typeof assetClosingAmount === 'undefined' + ? undefined + : BigInt(assetClosingAmount); + this.assetIndex = + typeof assetIndex === 'undefined' ? undefined : BigInt(assetIndex); + this.closeRewards = + typeof closeRewards === 'undefined' ? undefined : BigInt(closeRewards); + this.closingAmount = + typeof closingAmount === 'undefined' ? undefined : BigInt(closingAmount); + this.confirmedRound = + typeof confirmedRound === 'undefined' + ? undefined + : BigInt(confirmedRound); this.globalStateDelta = globalStateDelta; this.innerTxns = innerTxns; this.localStateDelta = localStateDelta; this.logs = logs; - this.receiverRewards = receiverRewards; - this.senderRewards = senderRewards; + this.receiverRewards = + typeof receiverRewards === 'undefined' + ? undefined + : BigInt(receiverRewards); + this.senderRewards = + typeof senderRewards === 'undefined' ? undefined : BigInt(senderRewards); this.attribute_map = { poolError: 'pool-error', @@ -3253,7 +3564,7 @@ export class PendingTransactionsResponse extends BaseModel { /** * Total number of transactions in the pool. */ - public totalTransactions: number | bigint; + public totalTransactions: bigint; /** * Creates a new `PendingTransactionsResponse` object. @@ -3269,7 +3580,7 @@ export class PendingTransactionsResponse extends BaseModel { }) { super(); this.topTransactions = topTransactions; - this.totalTransactions = totalTransactions; + this.totalTransactions = BigInt(totalTransactions); this.attribute_map = { topTransactions: 'top-transactions', @@ -3334,6 +3645,59 @@ export class PostTransactionsResponse extends BaseModel { } } +/** + * A write operation into a scratch slot. + */ +export class ScratchChange extends BaseModel { + /** + * Represents an AVM value. + */ + public newValue: AvmValue; + + /** + * The scratch slot written. + */ + public slot: bigint; + + /** + * Creates a new `ScratchChange` object. + * @param newValue - Represents an AVM value. + * @param slot - The scratch slot written. + */ + constructor({ + newValue, + slot, + }: { + newValue: AvmValue; + slot: number | bigint; + }) { + super(); + this.newValue = newValue; + this.slot = BigInt(slot); + + this.attribute_map = { + newValue: 'new-value', + slot: 'slot', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding(data: Record): ScratchChange { + /* eslint-disable dot-notation */ + if (typeof data['new-value'] === 'undefined') + throw new Error( + `Response is missing required field 'new-value': ${data}` + ); + if (typeof data['slot'] === 'undefined') + throw new Error(`Response is missing required field 'slot': ${data}`); + return new ScratchChange({ + newValue: AvmValue.from_obj_for_encoding(data['new-value']), + slot: data['slot'], + }); + /* eslint-enable dot-notation */ + } +} + /** * Request type for simulation endpoint. */ @@ -3344,7 +3708,7 @@ export class SimulateRequest extends BaseModel { public txnGroups: SimulateRequestTransactionGroup[]; /** - * Allow transactions without signatures to be simulated as if they had correct + * Allows transactions without signatures to be simulated as if they had correct * signatures. */ public allowEmptySignatures?: boolean; @@ -3354,40 +3718,63 @@ export class SimulateRequest extends BaseModel { */ public allowMoreLogging?: boolean; + /** + * Allows access to unnamed resources during simulation. + */ + public allowUnnamedResources?: boolean; + + /** + * An object that configures simulation execution trace. + */ + public execTraceConfig?: SimulateTraceConfig; + /** * Applies extra opcode budget during simulation for each transaction group. */ - public extraOpcodeBudget?: number | bigint; + public extraOpcodeBudget?: bigint; /** * Creates a new `SimulateRequest` object. * @param txnGroups - The transaction groups to simulate. - * @param allowEmptySignatures - Allow transactions without signatures to be simulated as if they had correct + * @param allowEmptySignatures - Allows transactions without signatures to be simulated as if they had correct * signatures. * @param allowMoreLogging - Lifts limits on log opcode usage during simulation. + * @param allowUnnamedResources - Allows access to unnamed resources during simulation. + * @param execTraceConfig - An object that configures simulation execution trace. * @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group. */ constructor({ txnGroups, allowEmptySignatures, allowMoreLogging, + allowUnnamedResources, + execTraceConfig, extraOpcodeBudget, }: { txnGroups: SimulateRequestTransactionGroup[]; allowEmptySignatures?: boolean; allowMoreLogging?: boolean; + allowUnnamedResources?: boolean; + execTraceConfig?: SimulateTraceConfig; extraOpcodeBudget?: number | bigint; }) { super(); this.txnGroups = txnGroups; this.allowEmptySignatures = allowEmptySignatures; this.allowMoreLogging = allowMoreLogging; - this.extraOpcodeBudget = extraOpcodeBudget; + this.allowUnnamedResources = allowUnnamedResources; + this.execTraceConfig = execTraceConfig; + this.extraOpcodeBudget = + typeof extraOpcodeBudget === 'undefined' + ? undefined + : BigInt(extraOpcodeBudget); this.attribute_map = { txnGroups: 'txn-groups', allowEmptySignatures: 'allow-empty-signatures', allowMoreLogging: 'allow-more-logging', + allowUnnamedResources: 'allow-unnamed-resources', + execTraceConfig: 'exec-trace-config', extraOpcodeBudget: 'extra-opcode-budget', }; } @@ -3405,6 +3792,11 @@ export class SimulateRequest extends BaseModel { ), allowEmptySignatures: data['allow-empty-signatures'], allowMoreLogging: data['allow-more-logging'], + allowUnnamedResources: data['allow-unnamed-resources'], + execTraceConfig: + typeof data['exec-trace-config'] !== 'undefined' + ? SimulateTraceConfig.from_obj_for_encoding(data['exec-trace-config']) + : undefined, extraOpcodeBudget: data['extra-opcode-budget'], }); /* eslint-enable dot-notation */ @@ -3457,7 +3849,7 @@ export class SimulateResponse extends BaseModel { * The round immediately preceding this simulation. State changes through this * round were used to run this simulation. */ - public lastRound: number | bigint; + public lastRound: bigint; /** * A result object for each transaction group that was simulated. @@ -3467,7 +3859,7 @@ export class SimulateResponse extends BaseModel { /** * The version of this response object. */ - public version: number | bigint; + public version: bigint; /** * The set of parameters and limits override during simulation. If this set of @@ -3476,6 +3868,11 @@ export class SimulateResponse extends BaseModel { */ public evalOverrides?: SimulationEvalOverrides; + /** + * An object that configures simulation execution trace. + */ + public execTraceConfig?: SimulateTraceConfig; + /** * Creates a new `SimulateResponse` object. * @param lastRound - The round immediately preceding this simulation. State changes through this @@ -3485,29 +3882,34 @@ export class SimulateResponse extends BaseModel { * @param evalOverrides - The set of parameters and limits override during simulation. If this set of * parameters is present, then evaluation parameters may differ from standard * evaluation in certain ways. + * @param execTraceConfig - An object that configures simulation execution trace. */ constructor({ lastRound, txnGroups, version, evalOverrides, + execTraceConfig, }: { lastRound: number | bigint; txnGroups: SimulateTransactionGroupResult[]; version: number | bigint; evalOverrides?: SimulationEvalOverrides; + execTraceConfig?: SimulateTraceConfig; }) { super(); - this.lastRound = lastRound; + this.lastRound = BigInt(lastRound); this.txnGroups = txnGroups; - this.version = version; + this.version = BigInt(version); this.evalOverrides = evalOverrides; + this.execTraceConfig = execTraceConfig; this.attribute_map = { lastRound: 'last-round', txnGroups: 'txn-groups', version: 'version', evalOverrides: 'eval-overrides', + execTraceConfig: 'exec-trace-config', }; } @@ -3536,6 +3938,72 @@ export class SimulateResponse extends BaseModel { data['eval-overrides'] ) : undefined, + execTraceConfig: + typeof data['exec-trace-config'] !== 'undefined' + ? SimulateTraceConfig.from_obj_for_encoding(data['exec-trace-config']) + : undefined, + }); + /* eslint-enable dot-notation */ + } +} + +/** + * An object that configures simulation execution trace. + */ +export class SimulateTraceConfig extends BaseModel { + /** + * A boolean option for opting in execution trace features simulation endpoint. + */ + public enable?: boolean; + + /** + * A boolean option enabling returning scratch slot changes together with execution + * trace during simulation. + */ + public scratchChange?: boolean; + + /** + * A boolean option enabling returning stack changes together with execution trace + * during simulation. + */ + public stackChange?: boolean; + + /** + * Creates a new `SimulateTraceConfig` object. + * @param enable - A boolean option for opting in execution trace features simulation endpoint. + * @param scratchChange - A boolean option enabling returning scratch slot changes together with execution + * trace during simulation. + * @param stackChange - A boolean option enabling returning stack changes together with execution trace + * during simulation. + */ + constructor({ + enable, + scratchChange, + stackChange, + }: { + enable?: boolean; + scratchChange?: boolean; + stackChange?: boolean; + }) { + super(); + this.enable = enable; + this.scratchChange = scratchChange; + this.stackChange = stackChange; + + this.attribute_map = { + enable: 'enable', + scratchChange: 'scratch-change', + stackChange: 'stack-change', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding(data: Record): SimulateTraceConfig { + /* eslint-disable dot-notation */ + return new SimulateTraceConfig({ + enable: data['enable'], + scratchChange: data['scratch-change'], + stackChange: data['stack-change'], }); /* eslint-enable dot-notation */ } @@ -3553,12 +4021,12 @@ export class SimulateTransactionGroupResult extends BaseModel { /** * Total budget added during execution of app calls in the transaction group. */ - public appBudgetAdded?: number | bigint; + public appBudgetAdded?: bigint; /** * Total budget consumed during execution of app calls in the transaction group. */ - public appBudgetConsumed?: number | bigint; + public appBudgetConsumed?: bigint; /** * If present, indicates which transaction in this group caused the failure. This @@ -3566,7 +4034,7 @@ export class SimulateTransactionGroupResult extends BaseModel { * the first element indicates the top-level transaction, and successive elements * indicate deeper inner transactions. */ - public failedAt?: (number | bigint)[]; + public failedAt?: bigint[]; /** * If present, indicates that the transaction group failed and specifies why that @@ -3574,6 +4042,19 @@ export class SimulateTransactionGroupResult extends BaseModel { */ public failureMessage?: string; + /** + * These are resources that were accessed by this group that would normally have + * caused failure, but were allowed in simulation. Depending on where this object + * is in the response, the unnamed resources it contains may or may not qualify for + * group resource sharing. If this is a field in SimulateTransactionGroupResult, + * the resources do qualify, but if this is a field in SimulateTransactionResult, + * they do not qualify. In order to make this group valid for actual submission, + * resources that qualify for group sharing can be made available by any + * transaction of the group; otherwise, resources must be placed in the same + * transaction which accessed them. + */ + public unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; + /** * Creates a new `SimulateTransactionGroupResult` object. * @param txnResults - Simulation result for individual transactions @@ -3585,6 +4066,15 @@ export class SimulateTransactionGroupResult extends BaseModel { * indicate deeper inner transactions. * @param failureMessage - If present, indicates that the transaction group failed and specifies why that * happened + * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have + * caused failure, but were allowed in simulation. Depending on where this object + * is in the response, the unnamed resources it contains may or may not qualify for + * group resource sharing. If this is a field in SimulateTransactionGroupResult, + * the resources do qualify, but if this is a field in SimulateTransactionResult, + * they do not qualify. In order to make this group valid for actual submission, + * resources that qualify for group sharing can be made available by any + * transaction of the group; otherwise, resources must be placed in the same + * transaction which accessed them. */ constructor({ txnResults, @@ -3592,19 +4082,28 @@ export class SimulateTransactionGroupResult extends BaseModel { appBudgetConsumed, failedAt, failureMessage, + unnamedResourcesAccessed, }: { txnResults: SimulateTransactionResult[]; appBudgetAdded?: number | bigint; appBudgetConsumed?: number | bigint; failedAt?: (number | bigint)[]; failureMessage?: string; + unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; }) { super(); this.txnResults = txnResults; - this.appBudgetAdded = appBudgetAdded; - this.appBudgetConsumed = appBudgetConsumed; - this.failedAt = failedAt; + this.appBudgetAdded = + typeof appBudgetAdded === 'undefined' + ? undefined + : BigInt(appBudgetAdded); + this.appBudgetConsumed = + typeof appBudgetConsumed === 'undefined' + ? undefined + : BigInt(appBudgetConsumed); + this.failedAt = failedAt.map(BigInt); this.failureMessage = failureMessage; + this.unnamedResourcesAccessed = unnamedResourcesAccessed; this.attribute_map = { txnResults: 'txn-results', @@ -3612,6 +4111,7 @@ export class SimulateTransactionGroupResult extends BaseModel { appBudgetConsumed: 'app-budget-consumed', failedAt: 'failed-at', failureMessage: 'failure-message', + unnamedResourcesAccessed: 'unnamed-resources-accessed', }; } @@ -3632,6 +4132,12 @@ export class SimulateTransactionGroupResult extends BaseModel { appBudgetConsumed: data['app-budget-consumed'], failedAt: data['failed-at'], failureMessage: data['failure-message'], + unnamedResourcesAccessed: + typeof data['unnamed-resources-accessed'] !== 'undefined' + ? SimulateUnnamedResourcesAccessed.from_obj_for_encoding( + data['unnamed-resources-accessed'] + ) + : undefined, }); /* eslint-enable dot-notation */ } @@ -3651,12 +4157,31 @@ export class SimulateTransactionResult extends BaseModel { * Budget used during execution of an app call transaction. This value includes * budged used by inner app calls spawned by this transaction. */ - public appBudgetConsumed?: number | bigint; + public appBudgetConsumed?: bigint; + + /** + * The execution trace of calling an app or a logic sig, containing the inner app + * call trace in a recursive way. + */ + public execTrace?: SimulationTransactionExecTrace; /** * Budget used during execution of a logic sig transaction. */ - public logicSigBudgetConsumed?: number | bigint; + public logicSigBudgetConsumed?: bigint; + + /** + * These are resources that were accessed by this group that would normally have + * caused failure, but were allowed in simulation. Depending on where this object + * is in the response, the unnamed resources it contains may or may not qualify for + * group resource sharing. If this is a field in SimulateTransactionGroupResult, + * the resources do qualify, but if this is a field in SimulateTransactionResult, + * they do not qualify. In order to make this group valid for actual submission, + * resources that qualify for group sharing can be made available by any + * transaction of the group; otherwise, resources must be placed in the same + * transaction which accessed them. + */ + public unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; /** * Creates a new `SimulateTransactionResult` object. @@ -3664,26 +4189,51 @@ export class SimulateTransactionResult extends BaseModel { * includes confirmation details like the round and reward details. * @param appBudgetConsumed - Budget used during execution of an app call transaction. This value includes * budged used by inner app calls spawned by this transaction. + * @param execTrace - The execution trace of calling an app or a logic sig, containing the inner app + * call trace in a recursive way. * @param logicSigBudgetConsumed - Budget used during execution of a logic sig transaction. + * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have + * caused failure, but were allowed in simulation. Depending on where this object + * is in the response, the unnamed resources it contains may or may not qualify for + * group resource sharing. If this is a field in SimulateTransactionGroupResult, + * the resources do qualify, but if this is a field in SimulateTransactionResult, + * they do not qualify. In order to make this group valid for actual submission, + * resources that qualify for group sharing can be made available by any + * transaction of the group; otherwise, resources must be placed in the same + * transaction which accessed them. */ constructor({ txnResult, appBudgetConsumed, + execTrace, logicSigBudgetConsumed, + unnamedResourcesAccessed, }: { txnResult: PendingTransactionResponse; appBudgetConsumed?: number | bigint; + execTrace?: SimulationTransactionExecTrace; logicSigBudgetConsumed?: number | bigint; + unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; }) { super(); this.txnResult = txnResult; - this.appBudgetConsumed = appBudgetConsumed; - this.logicSigBudgetConsumed = logicSigBudgetConsumed; + this.appBudgetConsumed = + typeof appBudgetConsumed === 'undefined' + ? undefined + : BigInt(appBudgetConsumed); + this.execTrace = execTrace; + this.logicSigBudgetConsumed = + typeof logicSigBudgetConsumed === 'undefined' + ? undefined + : BigInt(logicSigBudgetConsumed); + this.unnamedResourcesAccessed = unnamedResourcesAccessed; this.attribute_map = { txnResult: 'txn-result', appBudgetConsumed: 'app-budget-consumed', + execTrace: 'exec-trace', logicSigBudgetConsumed: 'logic-sig-budget-consumed', + unnamedResourcesAccessed: 'unnamed-resources-accessed', }; } @@ -3701,7 +4251,155 @@ export class SimulateTransactionResult extends BaseModel { data['txn-result'] ), appBudgetConsumed: data['app-budget-consumed'], + execTrace: + typeof data['exec-trace'] !== 'undefined' + ? SimulationTransactionExecTrace.from_obj_for_encoding( + data['exec-trace'] + ) + : undefined, logicSigBudgetConsumed: data['logic-sig-budget-consumed'], + unnamedResourcesAccessed: + typeof data['unnamed-resources-accessed'] !== 'undefined' + ? SimulateUnnamedResourcesAccessed.from_obj_for_encoding( + data['unnamed-resources-accessed'] + ) + : undefined, + }); + /* eslint-enable dot-notation */ + } +} + +/** + * These are resources that were accessed by this group that would normally have + * caused failure, but were allowed in simulation. Depending on where this object + * is in the response, the unnamed resources it contains may or may not qualify for + * group resource sharing. If this is a field in SimulateTransactionGroupResult, + * the resources do qualify, but if this is a field in SimulateTransactionResult, + * they do not qualify. In order to make this group valid for actual submission, + * resources that qualify for group sharing can be made available by any + * transaction of the group; otherwise, resources must be placed in the same + * transaction which accessed them. + */ +export class SimulateUnnamedResourcesAccessed extends BaseModel { + /** + * The unnamed accounts that were referenced. The order of this array is arbitrary. + */ + public accounts?: string[]; + + /** + * The unnamed application local states that were referenced. The order of this + * array is arbitrary. + */ + public appLocals?: ApplicationLocalReference[]; + + /** + * The unnamed applications that were referenced. The order of this array is + * arbitrary. + */ + public apps?: bigint[]; + + /** + * The unnamed asset holdings that were referenced. The order of this array is + * arbitrary. + */ + public assetHoldings?: AssetHoldingReference[]; + + /** + * The unnamed assets that were referenced. The order of this array is arbitrary. + */ + public assets?: bigint[]; + + /** + * The unnamed boxes that were referenced. The order of this array is arbitrary. + */ + public boxes?: BoxReference[]; + + /** + * The number of extra box references used to increase the IO budget. This is in + * addition to the references defined in the input transaction group and any + * referenced to unnamed boxes. + */ + public extraBoxRefs?: bigint; + + /** + * Creates a new `SimulateUnnamedResourcesAccessed` object. + * @param accounts - The unnamed accounts that were referenced. The order of this array is arbitrary. + * @param appLocals - The unnamed application local states that were referenced. The order of this + * array is arbitrary. + * @param apps - The unnamed applications that were referenced. The order of this array is + * arbitrary. + * @param assetHoldings - The unnamed asset holdings that were referenced. The order of this array is + * arbitrary. + * @param assets - The unnamed assets that were referenced. The order of this array is arbitrary. + * @param boxes - The unnamed boxes that were referenced. The order of this array is arbitrary. + * @param extraBoxRefs - The number of extra box references used to increase the IO budget. This is in + * addition to the references defined in the input transaction group and any + * referenced to unnamed boxes. + */ + constructor({ + accounts, + appLocals, + apps, + assetHoldings, + assets, + boxes, + extraBoxRefs, + }: { + accounts?: string[]; + appLocals?: ApplicationLocalReference[]; + apps?: (number | bigint)[]; + assetHoldings?: AssetHoldingReference[]; + assets?: (number | bigint)[]; + boxes?: BoxReference[]; + extraBoxRefs?: number | bigint; + }) { + super(); + this.accounts = accounts; + this.appLocals = appLocals; + this.apps = apps.map(BigInt); + this.assetHoldings = assetHoldings; + this.assets = assets.map(BigInt); + this.boxes = boxes; + this.extraBoxRefs = + typeof extraBoxRefs === 'undefined' ? undefined : BigInt(extraBoxRefs); + + this.attribute_map = { + accounts: 'accounts', + appLocals: 'app-locals', + apps: 'apps', + assetHoldings: 'asset-holdings', + assets: 'assets', + boxes: 'boxes', + extraBoxRefs: 'extra-box-refs', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding( + data: Record + ): SimulateUnnamedResourcesAccessed { + /* eslint-disable dot-notation */ + return new SimulateUnnamedResourcesAccessed({ + accounts: data['accounts'], + appLocals: + typeof data['app-locals'] !== 'undefined' + ? data['app-locals'].map( + ApplicationLocalReference.from_obj_for_encoding + ) + : undefined, + apps: data['apps'], + assetHoldings: + typeof data['asset-holdings'] !== 'undefined' + ? data['asset-holdings'].map( + AssetHoldingReference.from_obj_for_encoding + ) + : undefined, + assets: data['assets'], + boxes: + typeof data['boxes'] !== 'undefined' + ? data['boxes'].map(BoxReference.from_obj_for_encoding) + : undefined, + extraBoxRefs: data['extra-box-refs'], }); /* eslint-enable dot-notation */ } @@ -3719,48 +4417,63 @@ export class SimulationEvalOverrides extends BaseModel { */ public allowEmptySignatures?: boolean; + /** + * If true, allows access to unnamed resources during simulation. + */ + public allowUnnamedResources?: boolean; + /** * The extra opcode budget added to each transaction group during simulation */ - public extraOpcodeBudget?: number | bigint; + public extraOpcodeBudget?: bigint; /** * The maximum log calls one can make during simulation */ - public maxLogCalls?: number | bigint; + public maxLogCalls?: bigint; /** * The maximum byte number to log during simulation */ - public maxLogSize?: number | bigint; + public maxLogSize?: bigint; /** * Creates a new `SimulationEvalOverrides` object. * @param allowEmptySignatures - If true, transactions without signatures are allowed and simulated as if they * were properly signed. + * @param allowUnnamedResources - If true, allows access to unnamed resources during simulation. * @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation * @param maxLogCalls - The maximum log calls one can make during simulation * @param maxLogSize - The maximum byte number to log during simulation */ constructor({ allowEmptySignatures, + allowUnnamedResources, extraOpcodeBudget, maxLogCalls, maxLogSize, }: { allowEmptySignatures?: boolean; + allowUnnamedResources?: boolean; extraOpcodeBudget?: number | bigint; maxLogCalls?: number | bigint; maxLogSize?: number | bigint; }) { super(); this.allowEmptySignatures = allowEmptySignatures; - this.extraOpcodeBudget = extraOpcodeBudget; - this.maxLogCalls = maxLogCalls; - this.maxLogSize = maxLogSize; + this.allowUnnamedResources = allowUnnamedResources; + this.extraOpcodeBudget = + typeof extraOpcodeBudget === 'undefined' + ? undefined + : BigInt(extraOpcodeBudget); + this.maxLogCalls = + typeof maxLogCalls === 'undefined' ? undefined : BigInt(maxLogCalls); + this.maxLogSize = + typeof maxLogSize === 'undefined' ? undefined : BigInt(maxLogSize); this.attribute_map = { allowEmptySignatures: 'allow-empty-signatures', + allowUnnamedResources: 'allow-unnamed-resources', extraOpcodeBudget: 'extra-opcode-budget', maxLogCalls: 'max-log-calls', maxLogSize: 'max-log-size', @@ -3774,6 +4487,7 @@ export class SimulationEvalOverrides extends BaseModel { /* eslint-disable dot-notation */ return new SimulationEvalOverrides({ allowEmptySignatures: data['allow-empty-signatures'], + allowUnnamedResources: data['allow-unnamed-resources'], extraOpcodeBudget: data['extra-opcode-budget'], maxLogCalls: data['max-log-calls'], maxLogSize: data['max-log-size'], @@ -3782,6 +4496,191 @@ export class SimulationEvalOverrides extends BaseModel { } } +/** + * The set of trace information and effect from evaluating a single opcode. + */ +export class SimulationOpcodeTraceUnit extends BaseModel { + /** + * The program counter of the current opcode being evaluated. + */ + public pc: bigint; + + /** + * The writes into scratch slots. + */ + public scratchChanges?: ScratchChange[]; + + /** + * The indexes of the traces for inner transactions spawned by this opcode, if any. + */ + public spawnedInners?: bigint[]; + + /** + * The values added by this opcode to the stack. + */ + public stackAdditions?: AvmValue[]; + + /** + * The number of deleted stack values by this opcode. + */ + public stackPopCount?: bigint; + + /** + * Creates a new `SimulationOpcodeTraceUnit` object. + * @param pc - The program counter of the current opcode being evaluated. + * @param scratchChanges - The writes into scratch slots. + * @param spawnedInners - The indexes of the traces for inner transactions spawned by this opcode, if any. + * @param stackAdditions - The values added by this opcode to the stack. + * @param stackPopCount - The number of deleted stack values by this opcode. + */ + constructor({ + pc, + scratchChanges, + spawnedInners, + stackAdditions, + stackPopCount, + }: { + pc: number | bigint; + scratchChanges?: ScratchChange[]; + spawnedInners?: (number | bigint)[]; + stackAdditions?: AvmValue[]; + stackPopCount?: number | bigint; + }) { + super(); + this.pc = BigInt(pc); + this.scratchChanges = scratchChanges; + this.spawnedInners = spawnedInners.map(BigInt); + this.stackAdditions = stackAdditions; + this.stackPopCount = + typeof stackPopCount === 'undefined' ? undefined : BigInt(stackPopCount); + + this.attribute_map = { + pc: 'pc', + scratchChanges: 'scratch-changes', + spawnedInners: 'spawned-inners', + stackAdditions: 'stack-additions', + stackPopCount: 'stack-pop-count', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding( + data: Record + ): SimulationOpcodeTraceUnit { + /* eslint-disable dot-notation */ + if (typeof data['pc'] === 'undefined') + throw new Error(`Response is missing required field 'pc': ${data}`); + return new SimulationOpcodeTraceUnit({ + pc: data['pc'], + scratchChanges: + typeof data['scratch-changes'] !== 'undefined' + ? data['scratch-changes'].map(ScratchChange.from_obj_for_encoding) + : undefined, + spawnedInners: data['spawned-inners'], + stackAdditions: + typeof data['stack-additions'] !== 'undefined' + ? data['stack-additions'].map(AvmValue.from_obj_for_encoding) + : undefined, + stackPopCount: data['stack-pop-count'], + }); + /* eslint-enable dot-notation */ + } +} + +/** + * The execution trace of calling an app or a logic sig, containing the inner app + * call trace in a recursive way. + */ +export class SimulationTransactionExecTrace extends BaseModel { + /** + * Program trace that contains a trace of opcode effects in an approval program. + */ + public approvalProgramTrace?: SimulationOpcodeTraceUnit[]; + + /** + * Program trace that contains a trace of opcode effects in a clear state program. + */ + public clearStateProgramTrace?: SimulationOpcodeTraceUnit[]; + + /** + * An array of SimulationTransactionExecTrace representing the execution trace of + * any inner transactions executed. + */ + public innerTrace?: SimulationTransactionExecTrace[]; + + /** + * Program trace that contains a trace of opcode effects in a logic sig. + */ + public logicSigTrace?: SimulationOpcodeTraceUnit[]; + + /** + * Creates a new `SimulationTransactionExecTrace` object. + * @param approvalProgramTrace - Program trace that contains a trace of opcode effects in an approval program. + * @param clearStateProgramTrace - Program trace that contains a trace of opcode effects in a clear state program. + * @param innerTrace - An array of SimulationTransactionExecTrace representing the execution trace of + * any inner transactions executed. + * @param logicSigTrace - Program trace that contains a trace of opcode effects in a logic sig. + */ + constructor({ + approvalProgramTrace, + clearStateProgramTrace, + innerTrace, + logicSigTrace, + }: { + approvalProgramTrace?: SimulationOpcodeTraceUnit[]; + clearStateProgramTrace?: SimulationOpcodeTraceUnit[]; + innerTrace?: SimulationTransactionExecTrace[]; + logicSigTrace?: SimulationOpcodeTraceUnit[]; + }) { + super(); + this.approvalProgramTrace = approvalProgramTrace; + this.clearStateProgramTrace = clearStateProgramTrace; + this.innerTrace = innerTrace; + this.logicSigTrace = logicSigTrace; + + this.attribute_map = { + approvalProgramTrace: 'approval-program-trace', + clearStateProgramTrace: 'clear-state-program-trace', + innerTrace: 'inner-trace', + logicSigTrace: 'logic-sig-trace', + }; + } + + // eslint-disable-next-line camelcase + static from_obj_for_encoding( + data: Record + ): SimulationTransactionExecTrace { + /* eslint-disable dot-notation */ + return new SimulationTransactionExecTrace({ + approvalProgramTrace: + typeof data['approval-program-trace'] !== 'undefined' + ? data['approval-program-trace'].map( + SimulationOpcodeTraceUnit.from_obj_for_encoding + ) + : undefined, + clearStateProgramTrace: + typeof data['clear-state-program-trace'] !== 'undefined' + ? data['clear-state-program-trace'].map( + SimulationOpcodeTraceUnit.from_obj_for_encoding + ) + : undefined, + innerTrace: + typeof data['inner-trace'] !== 'undefined' + ? data['inner-trace'].map( + SimulationTransactionExecTrace.from_obj_for_encoding + ) + : undefined, + logicSigTrace: + typeof data['logic-sig-trace'] !== 'undefined' + ? data['logic-sig-trace'].map( + SimulationOpcodeTraceUnit.from_obj_for_encoding + ) + : undefined, + }); + /* eslint-enable dot-notation */ + } +} + /** * Represents a state proof and its corresponding message */ @@ -3849,18 +4748,18 @@ export class StateProofMessage extends BaseModel { /** * The first round the message attests to. */ - public firstattestedround: number | bigint; + public firstattestedround: bigint; /** * The last round the message attests to. */ - public lastattestedround: number | bigint; + public lastattestedround: bigint; /** * An integer value representing the natural log of the proven weight with 16 bits * of precision. This value would be used to verify the next state proof. */ - public lnprovenweight: number | bigint; + public lnprovenweight: bigint; /** * The vector commitment root of the top N accounts to sign the next StateProof. @@ -3895,9 +4794,9 @@ export class StateProofMessage extends BaseModel { typeof blockheaderscommitment === 'string' ? base64ToBytes(blockheaderscommitment) : blockheaderscommitment; - this.firstattestedround = firstattestedround; - this.lastattestedround = lastattestedround; - this.lnprovenweight = lnprovenweight; + this.firstattestedround = BigInt(firstattestedround); + this.lastattestedround = BigInt(lastattestedround); + this.lnprovenweight = BigInt(lnprovenweight); this.voterscommitment = typeof voterscommitment === 'string' ? base64ToBytes(voterscommitment) @@ -3953,17 +4852,17 @@ export class SupplyResponse extends BaseModel { /** * Round */ - public currentRound: number | bigint; + public currentRound: bigint; /** * OnlineMoney */ - public onlineMoney: number | bigint; + public onlineMoney: bigint; /** * TotalMoney */ - public totalMoney: number | bigint; + public totalMoney: bigint; /** * Creates a new `SupplyResponse` object. @@ -3981,9 +4880,9 @@ export class SupplyResponse extends BaseModel { totalMoney: number | bigint; }) { super(); - this.currentRound = currentRound; - this.onlineMoney = onlineMoney; - this.totalMoney = totalMoney; + this.currentRound = BigInt(currentRound); + this.onlineMoney = BigInt(onlineMoney); + this.totalMoney = BigInt(totalMoney); this.attribute_map = { currentRound: 'current_round', @@ -4065,7 +4964,7 @@ export class TealValue extends BaseModel { /** * (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** */ - public type: number | bigint; + public type: bigint; /** * (tb) bytes value. @@ -4075,7 +4974,7 @@ export class TealValue extends BaseModel { /** * (ui) uint value. */ - public uint: number | bigint; + public uint: bigint; /** * Creates a new `TealValue` object. @@ -4093,9 +4992,9 @@ export class TealValue extends BaseModel { uint: number | bigint; }) { super(); - this.type = type; + this.type = BigInt(type); this.bytes = bytes; - this.uint = uint; + this.uint = BigInt(uint); this.attribute_map = { type: 'type', @@ -4177,7 +5076,7 @@ export class TransactionParametersResponse extends BaseModel { * Fee may fall to zero but transactions must still have a fee of * at least MinTxnFee for the current network protocol. */ - public fee: number | bigint; + public fee: bigint; /** * GenesisHash is the hash of the genesis block. @@ -4192,13 +5091,13 @@ export class TransactionParametersResponse extends BaseModel { /** * LastRound indicates the last round seen */ - public lastRound: number | bigint; + public lastRound: bigint; /** * The minimum transaction fee (not per byte) required for the * txn to validate for the current network protocol. */ - public minFee: number | bigint; + public minFee: bigint; /** * Creates a new `TransactionParametersResponse` object. @@ -4231,14 +5130,14 @@ export class TransactionParametersResponse extends BaseModel { }) { super(); this.consensusVersion = consensusVersion; - this.fee = fee; + this.fee = BigInt(fee); this.genesisHash = typeof genesisHash === 'string' ? base64ToBytes(genesisHash) : genesisHash; this.genesisId = genesisId; - this.lastRound = lastRound; - this.minFee = minFee; + this.lastRound = BigInt(lastRound); + this.minFee = BigInt(minFee); this.attribute_map = { consensusVersion: 'consensus-version', @@ -4294,7 +5193,7 @@ export class TransactionProofResponse extends BaseModel { /** * Index of the transaction in the block's payset. */ - public idx: number | bigint; + public idx: bigint; /** * Proof of transaction membership. @@ -4310,7 +5209,7 @@ export class TransactionProofResponse extends BaseModel { * Represents the depth of the tree that is being proven, i.e. the number of edges * from a leaf to the root. */ - public treedepth: number | bigint; + public treedepth: bigint; /** * The type of hash function used to create the proof, must be one of: @@ -4344,11 +5243,11 @@ export class TransactionProofResponse extends BaseModel { hashtype?: string; }) { super(); - this.idx = idx; + this.idx = BigInt(idx); this.proof = typeof proof === 'string' ? base64ToBytes(proof) : proof; this.stibhash = typeof stibhash === 'string' ? base64ToBytes(stibhash) : stibhash; - this.treedepth = treedepth; + this.treedepth = BigInt(treedepth); this.hashtype = hashtype; this.attribute_map = { diff --git a/src/client/v2/algod/setBlockOffsetTimestamp.ts b/src/client/v2/algod/setBlockOffsetTimestamp.ts index 840228132..6f6ebac5d 100644 --- a/src/client/v2/algod/setBlockOffsetTimestamp.ts +++ b/src/client/v2/algod/setBlockOffsetTimestamp.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class SetBlockOffsetTimestamp extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private offset: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private offset: number) { + super(c); this.offset = offset; } diff --git a/src/client/v2/algod/setSyncRound.ts b/src/client/v2/algod/setSyncRound.ts index fdc32c75c..d9d1c418c 100644 --- a/src/client/v2/algod/setSyncRound.ts +++ b/src/client/v2/algod/setSyncRound.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class SetSyncRound extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number) { + super(c); this.round = round; } diff --git a/src/client/v2/algod/simulateTransaction.ts b/src/client/v2/algod/simulateTransaction.ts index 471b40855..b07e1f665 100644 --- a/src/client/v2/algod/simulateTransaction.ts +++ b/src/client/v2/algod/simulateTransaction.ts @@ -29,7 +29,9 @@ export default class SimulateRawTransactions extends JSONRequest< constructor(c: HTTPClient, request: SimulateRequest) { super(c); this.query.format = 'msgpack'; - this.requestBytes = encoding.rawEncode(request.get_obj_for_encoding(true)); + this.requestBytes = encoding.rawEncode( + request.get_obj_for_encoding(true, true) + ); } // eslint-disable-next-line class-methods-use-this diff --git a/src/client/v2/algod/stateproof.ts b/src/client/v2/algod/stateproof.ts index 98bab12a7..3bcb1187e 100644 --- a/src/client/v2/algod/stateproof.ts +++ b/src/client/v2/algod/stateproof.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class StateProof extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number) { + super(c); this.round = round; } diff --git a/src/client/v2/algod/statusAfterBlock.ts b/src/client/v2/algod/statusAfterBlock.ts index 5d340c6fd..18409df40 100644 --- a/src/client/v2/algod/statusAfterBlock.ts +++ b/src/client/v2/algod/statusAfterBlock.ts @@ -1,10 +1,9 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class StatusAfterBlock extends JSONRequest { - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number) { + super(c); if (!Number.isInteger(round)) throw Error('round should be an integer'); this.round = round; } diff --git a/src/client/v2/algod/suggestedParams.ts b/src/client/v2/algod/suggestedParams.ts index dde16b550..adf097174 100644 --- a/src/client/v2/algod/suggestedParams.ts +++ b/src/client/v2/algod/suggestedParams.ts @@ -15,7 +15,7 @@ export default class SuggestedParamsRequest extends JSONRequest; -function _get_obj_for_encoding(val: any[], binary: boolean): any[]; +function _get_obj_for_encoding( + val: any[], + binary: boolean, + omitEmpty: boolean +): any[]; function _get_obj_for_encoding( val: Record, - binary: boolean + binary: boolean, + omitEmpty: boolean ): Record; -function _get_obj_for_encoding(val: any, binary: boolean): any { +function _get_obj_for_encoding( + val: any, + binary: boolean, + omitEmpty: boolean +): any { /* eslint-enable no-underscore-dangle,camelcase,no-redeclare,no-unused-vars */ - let targetPropValue: any; - if (val instanceof Uint8Array) { - targetPropValue = binary ? val : bytesToBase64(val); - } else if (typeof val.get_obj_for_encoding === 'function') { - targetPropValue = val.get_obj_for_encoding(binary); - } else if (Array.isArray(val)) { - targetPropValue = []; + if (omitEmpty && val.byteLength === 0) { + return undefined; + } + return binary ? val : bytesToBase64(val); + } + if (typeof val.get_obj_for_encoding === 'function') { + return val.get_obj_for_encoding(binary); + } + if (Array.isArray(val)) { + if (omitEmpty && val.length === 0) { + return undefined; + } + const targetPropValue = []; for (const elem of val) { - targetPropValue.push(_get_obj_for_encoding(elem, binary)); + targetPropValue.push(_get_obj_for_encoding(elem, binary, omitEmpty)); } - } else if (typeof val === 'object') { + return targetPropValue; + } + if (typeof val === 'object') { + let keyCount = 0; const obj = {}; for (const prop of Object.keys(val)) { - obj[prop] = _get_obj_for_encoding(val[prop], binary); + const forEncoding = _get_obj_for_encoding(val[prop], binary, omitEmpty); + if (omitEmpty && typeof forEncoding === 'undefined') { + continue; + } + obj[prop] = forEncoding; + keyCount += 1; + } + if (omitEmpty && keyCount === 0) { + return undefined; + } + return obj; + } + if (_is_primitive(val)) { + if (omitEmpty && !val) { + return undefined; } - targetPropValue = obj; - } else if (_is_primitive(val)) { - targetPropValue = val; - } else { - throw new Error(`Unsupported value: ${String(val)}`); + return val; } - return targetPropValue; + throw new Error(`Unsupported value: ${String(val)}`); } export default class BaseModel { @@ -61,21 +90,32 @@ export default class BaseModel { * (Uint8Arrays). Use false to indicate that raw binary objects should be converted to base64 * strings. True should be used for objects that will be encoded with msgpack, and false should * be used for objects that will be encoded with JSON. + * @param omitEmpty - Use true to omit all properties with falsy or empty values. This is useful + * for encoding objects for msgpack, since our encoder will error if it encounters any empty or + * falsy values. */ - get_obj_for_encoding(binary = false) { + get_obj_for_encoding(binary: boolean = false, omitEmpty: boolean = false) { /* eslint-enable no-underscore-dangle,camelcase */ + let keyCount = 0; const obj: Record = {}; for (const prop of Object.keys(this.attribute_map)) { const name = this.attribute_map[prop]; const value = this[prop]; - - if (typeof value !== 'undefined') { - obj[name] = - value === null ? null : _get_obj_for_encoding(value, binary); + if (typeof value === 'undefined') { + continue; } + const valueForEncoding = _get_obj_for_encoding(value, binary, omitEmpty); + if (omitEmpty && typeof valueForEncoding === 'undefined') { + continue; + } + obj[name] = valueForEncoding; + keyCount += 1; } + if (omitEmpty && keyCount === 0) { + return undefined; + } return obj; } } diff --git a/src/client/v2/indexer/indexer.ts b/src/client/v2/indexer/indexer.ts index b767343d6..7521e2b5e 100644 --- a/src/client/v2/indexer/indexer.ts +++ b/src/client/v2/indexer/indexer.ts @@ -87,7 +87,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ makeHealthCheck() { - return new MakeHealthCheck(this.c, this.intDecoding); + return new MakeHealthCheck(this.c); } /** @@ -104,7 +104,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAssetBalances(index: number) { - return new LookupAssetBalances(this.c, this.intDecoding, index); + return new LookupAssetBalances(this.c, index); } /** @@ -121,7 +121,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAssetTransactions(index: number) { - return new LookupAssetTransactions(this.c, this.intDecoding, index); + return new LookupAssetTransactions(this.c, index); } /** @@ -138,7 +138,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountTransactions(account: string) { - return new LookupAccountTransactions(this.c, this.intDecoding, account); + return new LookupAccountTransactions(this.c, account); } /** @@ -155,7 +155,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupBlock(round: number) { - return new LookupBlock(this.c, this.intDecoding, round); + return new LookupBlock(this.c, round); } /** @@ -172,7 +172,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupTransactionByID(txID: string) { - return new LookupTransactionByID(this.c, this.intDecoding, txID); + return new LookupTransactionByID(this.c, txID); } /** @@ -189,7 +189,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountByID(account: string) { - return new LookupAccountByID(this.c, this.intDecoding, account); + return new LookupAccountByID(this.c, account); } /** @@ -206,7 +206,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountAssets(account: string) { - return new LookupAccountAssets(this.c, this.intDecoding, account); + return new LookupAccountAssets(this.c, account); } /** @@ -223,7 +223,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountCreatedAssets(account: string) { - return new LookupAccountCreatedAssets(this.c, this.intDecoding, account); + return new LookupAccountCreatedAssets(this.c, account); } /** @@ -240,7 +240,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountAppLocalStates(account: string) { - return new LookupAccountAppLocalStates(this.c, this.intDecoding, account); + return new LookupAccountAppLocalStates(this.c, account); } /** @@ -257,11 +257,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAccountCreatedApplications(account: string) { - return new LookupAccountCreatedApplications( - this.c, - this.intDecoding, - account - ); + return new LookupAccountCreatedApplications(this.c, account); } /** @@ -278,7 +274,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupAssetByID(index: number) { - return new LookupAssetByID(this.c, this.intDecoding, index); + return new LookupAssetByID(this.c, index); } /** @@ -295,7 +291,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupApplications(index: number) { - return new LookupApplications(this.c, this.intDecoding, index); + return new LookupApplications(this.c, index); } /** @@ -312,7 +308,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupApplicationLogs(appID: number) { - return new LookupApplicationLogs(this.c, this.intDecoding, appID); + return new LookupApplicationLogs(this.c, appID); } /** @@ -327,7 +323,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ searchAccounts() { - return new SearchAccounts(this.c, this.intDecoding); + return new SearchAccounts(this.c); } /** @@ -342,7 +338,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ searchForTransactions() { - return new SearchForTransactions(this.c, this.intDecoding); + return new SearchForTransactions(this.c); } /** @@ -357,7 +353,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ searchForAssets() { - return new SearchForAssets(this.c, this.intDecoding); + return new SearchForAssets(this.c); } /** @@ -372,7 +368,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ searchForApplications() { - return new SearchForApplications(this.c, this.intDecoding); + return new SearchForApplications(this.c); } /** @@ -402,7 +398,7 @@ export default class IndexerClient extends ServiceClient { * @category GET */ searchForApplicationBoxes(appID: number) { - return new SearchForApplicationBoxes(this.c, this.intDecoding, appID); + return new SearchForApplicationBoxes(this.c, appID); } /** @@ -422,11 +418,6 @@ export default class IndexerClient extends ServiceClient { * @category GET */ lookupApplicationBoxByIDandName(appID: number, boxName: Uint8Array) { - return new LookupApplicationBoxByIDandName( - this.c, - this.intDecoding, - appID, - boxName - ); + return new LookupApplicationBoxByIDandName(this.c, appID, boxName); } } diff --git a/src/client/v2/indexer/lookupAccountAppLocalStates.ts b/src/client/v2/indexer/lookupAccountAppLocalStates.ts index 4a2c2da76..c3e327cf0 100644 --- a/src/client/v2/indexer/lookupAccountAppLocalStates.ts +++ b/src/client/v2/indexer/lookupAccountAppLocalStates.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAccountAppLocalStates extends JSONRequest { /** @@ -16,12 +15,8 @@ export default class LookupAccountAppLocalStates extends JSONRequest { * @param account - The address of the account to look up. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupAccountAssets.ts b/src/client/v2/indexer/lookupAccountAssets.ts index 2d6194f4f..d3299b499 100644 --- a/src/client/v2/indexer/lookupAccountAssets.ts +++ b/src/client/v2/indexer/lookupAccountAssets.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAccountAssets extends JSONRequest { /** @@ -16,12 +15,8 @@ export default class LookupAccountAssets extends JSONRequest { * @param account - The address of the account to look up. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupAccountByID.ts b/src/client/v2/indexer/lookupAccountByID.ts index 8c024ec31..0793443e4 100644 --- a/src/client/v2/indexer/lookupAccountByID.ts +++ b/src/client/v2/indexer/lookupAccountByID.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAccountByID extends JSONRequest { /** @@ -16,12 +15,8 @@ export default class LookupAccountByID extends JSONRequest { * @param account - The address of the account to look up. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupAccountCreatedApplications.ts b/src/client/v2/indexer/lookupAccountCreatedApplications.ts index 187ab3363..4b455f21f 100644 --- a/src/client/v2/indexer/lookupAccountCreatedApplications.ts +++ b/src/client/v2/indexer/lookupAccountCreatedApplications.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAccountCreatedApplications extends JSONRequest { /** @@ -16,12 +15,8 @@ export default class LookupAccountCreatedApplications extends JSONRequest { * @param account - The address of the account to look up. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupAccountCreatedAssets.ts b/src/client/v2/indexer/lookupAccountCreatedAssets.ts index f64a4e1e8..a04f80bc6 100644 --- a/src/client/v2/indexer/lookupAccountCreatedAssets.ts +++ b/src/client/v2/indexer/lookupAccountCreatedAssets.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAccountCreatedAssets extends JSONRequest { /** @@ -16,12 +15,8 @@ export default class LookupAccountCreatedAssets extends JSONRequest { * @param account - The address of the account to look up. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupAccountTransactions.ts b/src/client/v2/indexer/lookupAccountTransactions.ts index 961e06368..457f92b58 100644 --- a/src/client/v2/indexer/lookupAccountTransactions.ts +++ b/src/client/v2/indexer/lookupAccountTransactions.ts @@ -1,5 +1,4 @@ import { bytesToBase64 } from '../../../encoding/binarydata'; -import IntDecoding from '../../../types/intDecoding'; import HTTPClient from '../../client'; import JSONRequest from '../jsonrequest'; @@ -28,12 +27,8 @@ export default class LookupAccountTransactions extends JSONRequest { * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) * @param account - The address of the account. */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private account: string - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private account: string) { + super(c); this.account = account; } diff --git a/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts b/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts index fdc1c25ee..74e953562 100644 --- a/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts +++ b/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts @@ -1,5 +1,4 @@ import { bytesToBase64 } from '../../../encoding/binarydata'; -import IntDecoding from '../../../types/intDecoding'; import HTTPClient from '../../client'; import JSONRequest from '../jsonrequest'; import { Box } from './models/types'; @@ -24,13 +23,8 @@ export default class LookupApplicationBoxByIDandName extends JSONRequest< * @oaram index - application index. * @category GET */ - constructor( - c: HTTPClient, - intDecoding: IntDecoding, - private index: number, - boxName: Uint8Array - ) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number, boxName: Uint8Array) { + super(c); this.index = index; // Encode query in base64 format and append the encoding prefix. const encodedName = bytesToBase64(boxName); diff --git a/src/client/v2/indexer/lookupApplicationLogs.ts b/src/client/v2/indexer/lookupApplicationLogs.ts index 2b945ba7a..305119b2e 100644 --- a/src/client/v2/indexer/lookupApplicationLogs.ts +++ b/src/client/v2/indexer/lookupApplicationLogs.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupApplicationLogs extends JSONRequest { /** @@ -16,8 +15,8 @@ export default class LookupApplicationLogs extends JSONRequest { * @param appID - The ID of the application which generated the logs. * @category GET */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private appID: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private appID: number) { + super(c); this.appID = appID; } diff --git a/src/client/v2/indexer/lookupApplications.ts b/src/client/v2/indexer/lookupApplications.ts index 8fb44291f..b3af598be 100644 --- a/src/client/v2/indexer/lookupApplications.ts +++ b/src/client/v2/indexer/lookupApplications.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupApplications extends JSONRequest { /** @@ -16,8 +15,8 @@ export default class LookupApplications extends JSONRequest { * @param index - The ID of the application to look up. * @category GET */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/indexer/lookupAssetBalances.ts b/src/client/v2/indexer/lookupAssetBalances.ts index d11795bcb..5607a07a3 100644 --- a/src/client/v2/indexer/lookupAssetBalances.ts +++ b/src/client/v2/indexer/lookupAssetBalances.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAssetBalances extends JSONRequest { /** @@ -15,8 +14,8 @@ export default class LookupAssetBalances extends JSONRequest { * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idbalances) * @param index - The asset ID to look up. */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/indexer/lookupAssetByID.ts b/src/client/v2/indexer/lookupAssetByID.ts index 76331fb2c..834bd19a8 100644 --- a/src/client/v2/indexer/lookupAssetByID.ts +++ b/src/client/v2/indexer/lookupAssetByID.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupAssetByID extends JSONRequest { /** @@ -15,8 +14,8 @@ export default class LookupAssetByID extends JSONRequest { * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) * @param index - The asset ID to look up. */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/indexer/lookupAssetTransactions.ts b/src/client/v2/indexer/lookupAssetTransactions.ts index 27b95b6f4..af934147e 100644 --- a/src/client/v2/indexer/lookupAssetTransactions.ts +++ b/src/client/v2/indexer/lookupAssetTransactions.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; import { base64StringFunnel } from './lookupAccountTransactions'; export default class LookupAssetTransactions extends JSONRequest { @@ -16,8 +15,8 @@ export default class LookupAssetTransactions extends JSONRequest { * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idtransactions) * @param index - The asset ID to look up. */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/indexer/lookupBlock.ts b/src/client/v2/indexer/lookupBlock.ts index 3b5030712..59e936ac1 100644 --- a/src/client/v2/indexer/lookupBlock.ts +++ b/src/client/v2/indexer/lookupBlock.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupBlock extends JSONRequest { /** @@ -16,8 +15,8 @@ export default class LookupBlock extends JSONRequest { * @param round - The number of the round to look up. * @category GET */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private round: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private round: number) { + super(c); this.round = round; } diff --git a/src/client/v2/indexer/lookupTransactionByID.ts b/src/client/v2/indexer/lookupTransactionByID.ts index d834db3ff..82be1d1f9 100644 --- a/src/client/v2/indexer/lookupTransactionByID.ts +++ b/src/client/v2/indexer/lookupTransactionByID.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; export default class LookupTransactionByID extends JSONRequest { /** @@ -16,8 +15,8 @@ export default class LookupTransactionByID extends JSONRequest { * @param txID - The ID of the transaction to look up. * @category GET */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private txID: string) { - super(c, intDecoding); + constructor(c: HTTPClient, private txID: string) { + super(c); this.txID = txID; } diff --git a/src/client/v2/indexer/models/types.ts b/src/client/v2/indexer/models/types.ts index 76c48ae7c..9b38f02a8 100644 --- a/src/client/v2/indexer/models/types.ts +++ b/src/client/v2/indexer/models/types.ts @@ -20,28 +20,28 @@ export class Account extends BaseModel { /** * (algo) total number of MicroAlgos in the account */ - public amount: number | bigint; + public amount: bigint; /** * specifies the amount of MicroAlgos in the account, without the pending rewards. */ - public amountWithoutPendingRewards: number | bigint; + public amountWithoutPendingRewards: bigint; /** * amount of MicroAlgos of pending rewards in this account. */ - public pendingRewards: number | bigint; + public pendingRewards: bigint; /** * (ern) total rewards of MicroAlgos the account has received, including pending * rewards. */ - public rewards: number | bigint; + public rewards: bigint; /** * The round for which this information is relevant. */ - public round: number | bigint; + public round: bigint; /** * (onl) delegation status of the account's MicroAlgos @@ -57,35 +57,35 @@ export class Account extends BaseModel { * The count of all applications that have been opted in, equivalent to the count * of application local data (AppLocalState objects) stored in this account. */ - public totalAppsOptedIn: number | bigint; + public totalAppsOptedIn: bigint; /** * The count of all assets that have been opted in, equivalent to the count of * AssetHolding objects held by this account. */ - public totalAssetsOptedIn: number | bigint; + public totalAssetsOptedIn: bigint; /** * For app-accounts only. The total number of bytes allocated for the keys and * values of boxes which belong to the associated application. */ - public totalBoxBytes: number | bigint; + public totalBoxBytes: bigint; /** * For app-accounts only. The total number of boxes which belong to the associated * application. */ - public totalBoxes: number | bigint; + public totalBoxes: bigint; /** * The count of all apps (AppParams objects) created by this account. */ - public totalCreatedApps: number | bigint; + public totalCreatedApps: bigint; /** * The count of all assets (AssetParams objects) created by this account. */ - public totalCreatedAssets: number | bigint; + public totalCreatedAssets: bigint; /** * (appl) applications local data stored in this account. @@ -96,7 +96,7 @@ export class Account extends BaseModel { /** * (teap) the sum of all extra application program pages for this account. */ - public appsTotalExtraPages?: number | bigint; + public appsTotalExtraPages?: bigint; /** * (tsch) stores the sum of all of the local schemas and global schemas in this @@ -121,7 +121,7 @@ export class Account extends BaseModel { /** * Round during which this account was most recently closed. */ - public closedAtRound?: number | bigint; + public closedAtRound?: bigint; /** * (appp) parameters of applications created by this account including app global @@ -139,7 +139,7 @@ export class Account extends BaseModel { /** * Round during which this account first appeared in a transaction. */ - public createdAtRound?: number | bigint; + public createdAtRound?: bigint; /** * Whether or not this account is currently closed. @@ -156,7 +156,7 @@ export class Account extends BaseModel { * (ebase) used as part of the rewards computation. Only applicable to accounts * which are participating. */ - public rewardBase?: number | bigint; + public rewardBase?: bigint; /** * Indicates what type of signature is used by this account, must be one of: @@ -278,30 +278,38 @@ export class Account extends BaseModel { }) { super(); this.address = address; - this.amount = amount; - this.amountWithoutPendingRewards = amountWithoutPendingRewards; - this.pendingRewards = pendingRewards; - this.rewards = rewards; - this.round = round; + this.amount = BigInt(amount); + this.amountWithoutPendingRewards = BigInt(amountWithoutPendingRewards); + this.pendingRewards = BigInt(pendingRewards); + this.rewards = BigInt(rewards); + this.round = BigInt(round); this.status = status; - this.totalAppsOptedIn = totalAppsOptedIn; - this.totalAssetsOptedIn = totalAssetsOptedIn; - this.totalBoxBytes = totalBoxBytes; - this.totalBoxes = totalBoxes; - this.totalCreatedApps = totalCreatedApps; - this.totalCreatedAssets = totalCreatedAssets; + this.totalAppsOptedIn = BigInt(totalAppsOptedIn); + this.totalAssetsOptedIn = BigInt(totalAssetsOptedIn); + this.totalBoxBytes = BigInt(totalBoxBytes); + this.totalBoxes = BigInt(totalBoxes); + this.totalCreatedApps = BigInt(totalCreatedApps); + this.totalCreatedAssets = BigInt(totalCreatedAssets); this.appsLocalState = appsLocalState; - this.appsTotalExtraPages = appsTotalExtraPages; + this.appsTotalExtraPages = + typeof appsTotalExtraPages === 'undefined' + ? undefined + : BigInt(appsTotalExtraPages); this.appsTotalSchema = appsTotalSchema; this.assets = assets; this.authAddr = authAddr; - this.closedAtRound = closedAtRound; + this.closedAtRound = + typeof closedAtRound === 'undefined' ? undefined : BigInt(closedAtRound); this.createdApps = createdApps; this.createdAssets = createdAssets; - this.createdAtRound = createdAtRound; + this.createdAtRound = + typeof createdAtRound === 'undefined' + ? undefined + : BigInt(createdAtRound); this.deleted = deleted; this.participation = participation; - this.rewardBase = rewardBase; + this.rewardBase = + typeof rewardBase === 'undefined' ? undefined : BigInt(rewardBase); this.sigType = sigType; this.attribute_map = { @@ -446,17 +454,17 @@ export class AccountParticipation extends BaseModel { /** * (voteFst) First round for which this participation is valid. */ - public voteFirstValid: number | bigint; + public voteFirstValid: bigint; /** * (voteKD) Number of subkeys in each batch of participation keys. */ - public voteKeyDilution: number | bigint; + public voteKeyDilution: bigint; /** * (voteLst) Last round for which this participation is valid. */ - public voteLastValid: number | bigint; + public voteLastValid: bigint; /** * (vote) root participation public key (if any) currently registered for this @@ -499,9 +507,9 @@ export class AccountParticipation extends BaseModel { typeof selectionParticipationKey === 'string' ? base64ToBytes(selectionParticipationKey) : selectionParticipationKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; + this.voteFirstValid = BigInt(voteFirstValid); + this.voteKeyDilution = BigInt(voteKeyDilution); + this.voteLastValid = BigInt(voteLastValid); this.voteParticipationKey = typeof voteParticipationKey === 'string' ? base64ToBytes(voteParticipationKey) @@ -572,7 +580,7 @@ export class AccountResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Creates a new `AccountResponse` object. @@ -590,7 +598,7 @@ export class AccountResponse extends BaseModel { }) { super(); this.account = account; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.attribute_map = { account: 'account', @@ -674,7 +682,7 @@ export class AccountsResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -700,7 +708,7 @@ export class AccountsResponse extends BaseModel { }) { super(); this.accounts = accounts; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -737,7 +745,7 @@ export class Application extends BaseModel { /** * (appidx) application index. */ - public id: number | bigint; + public id: bigint; /** * (appparams) application parameters. @@ -747,7 +755,7 @@ export class Application extends BaseModel { /** * Round when this application was created. */ - public createdAtRound?: number | bigint; + public createdAtRound?: bigint; /** * Whether or not this application is currently deleted. @@ -757,7 +765,7 @@ export class Application extends BaseModel { /** * Round when this application was deleted. */ - public deletedAtRound?: number | bigint; + public deletedAtRound?: bigint; /** * Creates a new `Application` object. @@ -781,11 +789,17 @@ export class Application extends BaseModel { deletedAtRound?: number | bigint; }) { super(); - this.id = id; + this.id = BigInt(id); this.params = params; - this.createdAtRound = createdAtRound; + this.createdAtRound = + typeof createdAtRound === 'undefined' + ? undefined + : BigInt(createdAtRound); this.deleted = deleted; - this.deletedAtRound = deletedAtRound; + this.deletedAtRound = + typeof deletedAtRound === 'undefined' + ? undefined + : BigInt(deletedAtRound); this.attribute_map = { id: 'id', @@ -821,7 +835,7 @@ export class ApplicationLocalState extends BaseModel { /** * The application which this local state is for. */ - public id: number | bigint; + public id: bigint; /** * (hsch) schema. @@ -831,7 +845,7 @@ export class ApplicationLocalState extends BaseModel { /** * Round when account closed out of the application. */ - public closedOutAtRound?: number | bigint; + public closedOutAtRound?: bigint; /** * Whether or not the application local state is currently deleted from its @@ -847,7 +861,7 @@ export class ApplicationLocalState extends BaseModel { /** * Round when the account opted into the application. */ - public optedInAtRound?: number | bigint; + public optedInAtRound?: bigint; /** * Creates a new `ApplicationLocalState` object. @@ -875,12 +889,18 @@ export class ApplicationLocalState extends BaseModel { optedInAtRound?: number | bigint; }) { super(); - this.id = id; + this.id = BigInt(id); this.schema = schema; - this.closedOutAtRound = closedOutAtRound; + this.closedOutAtRound = + typeof closedOutAtRound === 'undefined' + ? undefined + : BigInt(closedOutAtRound); this.deleted = deleted; this.keyValue = keyValue; - this.optedInAtRound = optedInAtRound; + this.optedInAtRound = + typeof optedInAtRound === 'undefined' + ? undefined + : BigInt(optedInAtRound); this.attribute_map = { id: 'id', @@ -925,7 +945,7 @@ export class ApplicationLocalStatesResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -951,7 +971,7 @@ export class ApplicationLocalStatesResponse extends BaseModel { }) { super(); this.appsLocalStates = appsLocalStates; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -1039,12 +1059,12 @@ export class ApplicationLogsResponse extends BaseModel { /** * (appidx) application index. */ - public applicationId: number | bigint; + public applicationId: bigint; /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; public logData?: ApplicationLogData[]; @@ -1074,8 +1094,8 @@ export class ApplicationLogsResponse extends BaseModel { nextToken?: string; }) { super(); - this.applicationId = applicationId; - this.currentRound = currentRound; + this.applicationId = BigInt(applicationId); + this.currentRound = BigInt(currentRound); this.logData = logData; this.nextToken = nextToken; @@ -1136,7 +1156,7 @@ export class ApplicationParams extends BaseModel { /** * (epp) the amount of extra program pages available to this app. */ - public extraProgramPages?: number | bigint; + public extraProgramPages?: bigint; /** * [\gs) global schema @@ -1191,7 +1211,10 @@ export class ApplicationParams extends BaseModel { ? base64ToBytes(clearStateProgram) : clearStateProgram; this.creator = creator; - this.extraProgramPages = extraProgramPages; + this.extraProgramPages = + typeof extraProgramPages === 'undefined' + ? undefined + : BigInt(extraProgramPages); this.globalState = globalState; this.globalStateSchema = globalStateSchema; this.localStateSchema = localStateSchema; @@ -1251,7 +1274,7 @@ export class ApplicationResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Application index and its parameters @@ -1271,7 +1294,7 @@ export class ApplicationResponse extends BaseModel { application?: Application; }) { super(); - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.application = application; this.attribute_map = { @@ -1305,12 +1328,12 @@ export class ApplicationStateSchema extends BaseModel { /** * (nbs) num of byte slices. */ - public numByteSlice: number | bigint; + public numByteSlice: bigint; /** * (nui) num of uints. */ - public numUint: number | bigint; + public numUint: bigint; /** * Creates a new `ApplicationStateSchema` object. @@ -1325,8 +1348,8 @@ export class ApplicationStateSchema extends BaseModel { numUint: number | bigint; }) { super(); - this.numByteSlice = numByteSlice; - this.numUint = numUint; + this.numByteSlice = BigInt(numByteSlice); + this.numUint = BigInt(numUint); this.attribute_map = { numByteSlice: 'num-byte-slice', @@ -1362,7 +1385,7 @@ export class ApplicationsResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -1388,7 +1411,7 @@ export class ApplicationsResponse extends BaseModel { }) { super(); this.applications = applications; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -1427,7 +1450,7 @@ export class Asset extends BaseModel { /** * unique asset identifier */ - public index: number | bigint; + public index: bigint; /** * AssetParams specifies the parameters for an asset. @@ -1440,7 +1463,7 @@ export class Asset extends BaseModel { /** * Round during which this asset was created. */ - public createdAtRound?: number | bigint; + public createdAtRound?: bigint; /** * Whether or not this asset is currently deleted. @@ -1450,7 +1473,7 @@ export class Asset extends BaseModel { /** * Round during which this asset was destroyed. */ - public destroyedAtRound?: number | bigint; + public destroyedAtRound?: bigint; /** * Creates a new `Asset` object. @@ -1477,11 +1500,17 @@ export class Asset extends BaseModel { destroyedAtRound?: number | bigint; }) { super(); - this.index = index; + this.index = BigInt(index); this.params = params; - this.createdAtRound = createdAtRound; + this.createdAtRound = + typeof createdAtRound === 'undefined' + ? undefined + : BigInt(createdAtRound); this.deleted = deleted; - this.destroyedAtRound = destroyedAtRound; + this.destroyedAtRound = + typeof destroyedAtRound === 'undefined' + ? undefined + : BigInt(destroyedAtRound); this.attribute_map = { index: 'index', @@ -1519,7 +1548,7 @@ export class AssetBalancesResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -1545,7 +1574,7 @@ export class AssetBalancesResponse extends BaseModel { }) { super(); this.balances = balances; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -1586,12 +1615,12 @@ export class AssetHolding extends BaseModel { /** * (a) number of units held. */ - public amount: number | bigint; + public amount: bigint; /** * Asset ID of the holding. */ - public assetId: number | bigint; + public assetId: bigint; /** * (f) whether or not the holding is frozen. @@ -1606,12 +1635,12 @@ export class AssetHolding extends BaseModel { /** * Round during which the account opted into this asset holding. */ - public optedInAtRound?: number | bigint; + public optedInAtRound?: bigint; /** * Round during which the account opted out of this asset holding. */ - public optedOutAtRound?: number | bigint; + public optedOutAtRound?: bigint; /** * Creates a new `AssetHolding` object. @@ -1638,12 +1667,18 @@ export class AssetHolding extends BaseModel { optedOutAtRound?: number | bigint; }) { super(); - this.amount = amount; - this.assetId = assetId; + this.amount = BigInt(amount); + this.assetId = BigInt(assetId); this.isFrozen = isFrozen; this.deleted = deleted; - this.optedInAtRound = optedInAtRound; - this.optedOutAtRound = optedOutAtRound; + this.optedInAtRound = + typeof optedInAtRound === 'undefined' + ? undefined + : BigInt(optedInAtRound); + this.optedOutAtRound = + typeof optedOutAtRound === 'undefined' + ? undefined + : BigInt(optedOutAtRound); this.attribute_map = { amount: 'amount', @@ -1687,7 +1722,7 @@ export class AssetHoldingsResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -1713,7 +1748,7 @@ export class AssetHoldingsResponse extends BaseModel { }) { super(); this.assets = assets; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -1765,12 +1800,12 @@ export class AssetParams extends BaseModel { * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value * must be between 0 and 19 (inclusive). */ - public decimals: number | bigint; + public decimals: bigint; /** * (t) The total number of units of this asset. */ - public total: number | bigint; + public total: bigint; /** * (c) Address of account used to clawback holdings of this asset. If empty, @@ -1902,8 +1937,8 @@ export class AssetParams extends BaseModel { }) { super(); this.creator = creator; - this.decimals = decimals; - this.total = total; + this.decimals = BigInt(decimals); + this.total = BigInt(total); this.clawback = clawback; this.defaultFrozen = defaultFrozen; this.freeze = freeze; @@ -1985,7 +2020,7 @@ export class AssetResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Creates a new `AssetResponse` object. @@ -2001,7 +2036,7 @@ export class AssetResponse extends BaseModel { }) { super(); this.asset = asset; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.attribute_map = { asset: 'asset', @@ -2035,7 +2070,7 @@ export class AssetsResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Used for pagination, when making another request provide this token with the @@ -2061,7 +2096,7 @@ export class AssetsResponse extends BaseModel { }) { super(); this.assets = assets; - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.nextToken = nextToken; this.attribute_map = { @@ -2115,7 +2150,7 @@ export class Block extends BaseModel { /** * (rnd) Current round on which this block was appended to the chain. */ - public round: number | bigint; + public round: bigint; /** * (seed) Sortition seed. @@ -2125,7 +2160,7 @@ export class Block extends BaseModel { /** * (ts) Block creation timestamp in seconds since eposh */ - public timestamp: number | bigint; + public timestamp: bigint; /** * (txn) TransactionsRoot authenticates the set of transactions appearing in the @@ -2172,7 +2207,7 @@ export class Block extends BaseModel { * committed after this block. It is 0 when no transactions have ever been * committed (since TxnCounter started being supported). */ - public txnCounter?: number | bigint; + public txnCounter?: bigint; /** * Fields relating to a protocol upgrade. @@ -2257,9 +2292,9 @@ export class Block extends BaseModel { typeof previousBlockHash === 'string' ? base64ToBytes(previousBlockHash) : previousBlockHash; - this.round = round; + this.round = BigInt(round); this.seed = typeof seed === 'string' ? base64ToBytes(seed) : seed; - this.timestamp = timestamp; + this.timestamp = BigInt(timestamp); this.transactionsRoot = typeof transactionsRoot === 'string' ? base64ToBytes(transactionsRoot) @@ -2272,7 +2307,8 @@ export class Block extends BaseModel { this.rewards = rewards; this.stateProofTracking = stateProofTracking; this.transactions = transactions; - this.txnCounter = txnCounter; + this.txnCounter = + typeof txnCounter === 'undefined' ? undefined : BigInt(txnCounter); this.upgradeState = upgradeState; this.upgradeVote = upgradeVote; @@ -2382,13 +2418,13 @@ export class BlockRewards extends BaseModel { * (rwcalr) number of leftover MicroAlgos after the distribution of rewards-rate * MicroAlgos for every reward unit in the next round. */ - public rewardsCalculationRound: number | bigint; + public rewardsCalculationRound: bigint; /** * (earn) How many rewards, in MicroAlgos, have been distributed to each RewardUnit * of MicroAlgos since genesis. */ - public rewardsLevel: number | bigint; + public rewardsLevel: bigint; /** * (rwd) accepts periodic injections from the fee-sink and continually @@ -2400,13 +2436,13 @@ export class BlockRewards extends BaseModel { * (rate) Number of new MicroAlgos added to the participation stake from rewards at * the next round. */ - public rewardsRate: number | bigint; + public rewardsRate: bigint; /** * (frac) Number of leftover MicroAlgos after the distribution of * RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. */ - public rewardsResidue: number | bigint; + public rewardsResidue: bigint; /** * Creates a new `BlockRewards` object. @@ -2439,11 +2475,11 @@ export class BlockRewards extends BaseModel { }) { super(); this.feeSink = feeSink; - this.rewardsCalculationRound = rewardsCalculationRound; - this.rewardsLevel = rewardsLevel; + this.rewardsCalculationRound = BigInt(rewardsCalculationRound); + this.rewardsLevel = BigInt(rewardsLevel); this.rewardsPool = rewardsPool; - this.rewardsRate = rewardsRate; - this.rewardsResidue = rewardsResidue; + this.rewardsRate = BigInt(rewardsRate); + this.rewardsResidue = BigInt(rewardsResidue); this.attribute_map = { feeSink: 'fee-sink', @@ -2509,18 +2545,18 @@ export class BlockUpgradeState extends BaseModel { /** * (nextyes) Number of blocks which approved the protocol upgrade. */ - public nextProtocolApprovals?: number | bigint; + public nextProtocolApprovals?: bigint; /** * (nextswitch) Round on which the protocol upgrade will take effect. */ - public nextProtocolSwitchOn?: number | bigint; + public nextProtocolSwitchOn?: bigint; /** * (nextbefore) Deadline round for this protocol upgrade (No votes will be consider * after this round). */ - public nextProtocolVoteBefore?: number | bigint; + public nextProtocolVoteBefore?: bigint; /** * Creates a new `BlockUpgradeState` object. @@ -2547,9 +2583,18 @@ export class BlockUpgradeState extends BaseModel { super(); this.currentProtocol = currentProtocol; this.nextProtocol = nextProtocol; - this.nextProtocolApprovals = nextProtocolApprovals; - this.nextProtocolSwitchOn = nextProtocolSwitchOn; - this.nextProtocolVoteBefore = nextProtocolVoteBefore; + this.nextProtocolApprovals = + typeof nextProtocolApprovals === 'undefined' + ? undefined + : BigInt(nextProtocolApprovals); + this.nextProtocolSwitchOn = + typeof nextProtocolSwitchOn === 'undefined' + ? undefined + : BigInt(nextProtocolSwitchOn); + this.nextProtocolVoteBefore = + typeof nextProtocolVoteBefore === 'undefined' + ? undefined + : BigInt(nextProtocolVoteBefore); this.attribute_map = { currentProtocol: 'current-protocol', @@ -2590,7 +2635,7 @@ export class BlockUpgradeVote extends BaseModel { /** * (upgradedelay) Indicates the time between acceptance and execution. */ - public upgradeDelay?: number | bigint; + public upgradeDelay?: bigint; /** * (upgradeprop) Indicates a proposed upgrade. @@ -2614,7 +2659,8 @@ export class BlockUpgradeVote extends BaseModel { }) { super(); this.upgradeApprove = upgradeApprove; - this.upgradeDelay = upgradeDelay; + this.upgradeDelay = + typeof upgradeDelay === 'undefined' ? undefined : BigInt(upgradeDelay); this.upgradePropose = upgradePropose; this.attribute_map = { @@ -2645,11 +2691,6 @@ export class Box extends BaseModel { */ public name: Uint8Array; - /** - * The round for which this information is relevant - */ - public round: number | bigint; - /** * (value) box value, base64 encoded. */ @@ -2658,26 +2699,21 @@ export class Box extends BaseModel { /** * Creates a new `Box` object. * @param name - (name) box name, base64 encoded - * @param round - The round for which this information is relevant * @param value - (value) box value, base64 encoded. */ constructor({ name, - round, value, }: { name: string | Uint8Array; - round: number | bigint; value: string | Uint8Array; }) { super(); this.name = typeof name === 'string' ? base64ToBytes(name) : name; - this.round = round; this.value = typeof value === 'string' ? base64ToBytes(value) : value; this.attribute_map = { name: 'name', - round: 'round', value: 'value', }; } @@ -2687,13 +2723,10 @@ export class Box extends BaseModel { /* eslint-disable dot-notation */ if (typeof data['name'] === 'undefined') throw new Error(`Response is missing required field 'name': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); if (typeof data['value'] === 'undefined') throw new Error(`Response is missing required field 'value': ${data}`); return new Box({ name: data['name'], - round: data['round'], value: data['value'], }); /* eslint-enable dot-notation */ @@ -2741,7 +2774,7 @@ export class BoxesResponse extends BaseModel { /** * (appidx) application index. */ - public applicationId: number | bigint; + public applicationId: bigint; public boxes: BoxDescriptor[]; @@ -2768,7 +2801,7 @@ export class BoxesResponse extends BaseModel { nextToken?: string; }) { super(); - this.applicationId = applicationId; + this.applicationId = BigInt(applicationId); this.boxes = boxes; this.nextToken = nextToken; @@ -2849,7 +2882,7 @@ export class EvalDelta extends BaseModel { /** * (at) delta action. */ - public action: number | bigint; + public action: bigint; /** * (bs) bytes value. @@ -2859,7 +2892,7 @@ export class EvalDelta extends BaseModel { /** * (ui) uint value. */ - public uint?: number | bigint; + public uint?: bigint; /** * Creates a new `EvalDelta` object. @@ -2877,9 +2910,9 @@ export class EvalDelta extends BaseModel { uint?: number | bigint; }) { super(); - this.action = action; + this.action = BigInt(action); this.bytes = bytes; - this.uint = uint; + this.uint = typeof uint === 'undefined' ? undefined : BigInt(uint); this.attribute_map = { action: 'action', @@ -2948,7 +2981,7 @@ export class HashFactory extends BaseModel { /** * (t) */ - public hashType?: number | bigint; + public hashType?: bigint; /** * Creates a new `HashFactory` object. @@ -2956,7 +2989,8 @@ export class HashFactory extends BaseModel { */ constructor({ hashType }: { hashType?: number | bigint }) { super(); - this.hashType = hashType; + this.hashType = + typeof hashType === 'undefined' ? undefined : BigInt(hashType); this.attribute_map = { hashType: 'hash-type', @@ -2983,7 +3017,7 @@ export class HealthCheck extends BaseModel { public message: string; - public round: number | bigint; + public round: bigint; /** * Current version. @@ -3025,7 +3059,7 @@ export class HealthCheck extends BaseModel { this.dbAvailable = dbAvailable; this.isMigrating = isMigrating; this.message = message; - this.round = round; + this.round = BigInt(round); this.version = version; this.data = data; this.errors = errors; @@ -3080,17 +3114,17 @@ export class IndexerStateProofMessage extends BaseModel { /** * (f) */ - public firstAttestedRound?: number | bigint; + public firstAttestedRound?: bigint; /** * (l) */ - public latestAttestedRound?: number | bigint; + public latestAttestedRound?: bigint; /** * (P) */ - public lnProvenWeight?: number | bigint; + public lnProvenWeight?: bigint; /** * (v) @@ -3123,9 +3157,18 @@ export class IndexerStateProofMessage extends BaseModel { typeof blockHeadersCommitment === 'string' ? base64ToBytes(blockHeadersCommitment) : blockHeadersCommitment; - this.firstAttestedRound = firstAttestedRound; - this.latestAttestedRound = latestAttestedRound; - this.lnProvenWeight = lnProvenWeight; + this.firstAttestedRound = + typeof firstAttestedRound === 'undefined' + ? undefined + : BigInt(firstAttestedRound); + this.latestAttestedRound = + typeof latestAttestedRound === 'undefined' + ? undefined + : BigInt(latestAttestedRound); + this.lnProvenWeight = + typeof lnProvenWeight === 'undefined' + ? undefined + : BigInt(lnProvenWeight); this.votersCommitment = typeof votersCommitment === 'string' ? base64ToBytes(votersCommitment) @@ -3167,7 +3210,7 @@ export class MerkleArrayProof extends BaseModel { /** * (td) */ - public treeDepth?: number | bigint; + public treeDepth?: bigint; /** * Creates a new `MerkleArrayProof` object. @@ -3187,7 +3230,8 @@ export class MerkleArrayProof extends BaseModel { super(); this.hashFactory = hashFactory; this.path = path; - this.treeDepth = treeDepth; + this.treeDepth = + typeof treeDepth === 'undefined' ? undefined : BigInt(treeDepth); this.attribute_map = { hashFactory: 'hash-factory', @@ -3217,7 +3261,7 @@ export class MerkleArrayProof extends BaseModel { export class MiniAssetHolding extends BaseModel { public address: string; - public amount: number | bigint; + public amount: bigint; public isFrozen: boolean; @@ -3229,12 +3273,12 @@ export class MiniAssetHolding extends BaseModel { /** * Round during which the account opted into the asset. */ - public optedInAtRound?: number | bigint; + public optedInAtRound?: bigint; /** * Round during which the account opted out of the asset. */ - public optedOutAtRound?: number | bigint; + public optedOutAtRound?: bigint; /** * Creates a new `MiniAssetHolding` object. @@ -3262,11 +3306,17 @@ export class MiniAssetHolding extends BaseModel { }) { super(); this.address = address; - this.amount = amount; + this.amount = BigInt(amount); this.isFrozen = isFrozen; this.deleted = deleted; - this.optedInAtRound = optedInAtRound; - this.optedOutAtRound = optedOutAtRound; + this.optedInAtRound = + typeof optedInAtRound === 'undefined' + ? undefined + : BigInt(optedInAtRound); + this.optedOutAtRound = + typeof optedOutAtRound === 'undefined' + ? undefined + : BigInt(optedOutAtRound); this.attribute_map = { address: 'address', @@ -3355,7 +3405,7 @@ export class StateProofFields extends BaseModel { /** * (pr) Sequence of reveal positions. */ - public positionsToReveal?: (number | bigint)[]; + public positionsToReveal?: bigint[]; /** * (r) Note that this is actually stored as a map[uint64] - Reveal in the actual @@ -3366,7 +3416,7 @@ export class StateProofFields extends BaseModel { /** * (v) Salt version of the merkle signature. */ - public saltVersion?: number | bigint; + public saltVersion?: bigint; /** * (c) @@ -3381,7 +3431,7 @@ export class StateProofFields extends BaseModel { /** * (w) */ - public signedWeight?: number | bigint; + public signedWeight?: bigint; /** * Creates a new `StateProofFields` object. @@ -3413,13 +3463,15 @@ export class StateProofFields extends BaseModel { }) { super(); this.partProofs = partProofs; - this.positionsToReveal = positionsToReveal; + this.positionsToReveal = positionsToReveal.map(BigInt); this.reveals = reveals; - this.saltVersion = saltVersion; + this.saltVersion = + typeof saltVersion === 'undefined' ? undefined : BigInt(saltVersion); this.sigCommit = typeof sigCommit === 'string' ? base64ToBytes(sigCommit) : sigCommit; this.sigProofs = sigProofs; - this.signedWeight = signedWeight; + this.signedWeight = + typeof signedWeight === 'undefined' ? undefined : BigInt(signedWeight); this.attribute_map = { partProofs: 'part-proofs', @@ -3466,7 +3518,7 @@ export class StateProofParticipant extends BaseModel { /** * (w) */ - public weight?: number | bigint; + public weight?: bigint; /** * Creates a new `StateProofParticipant` object. @@ -3482,7 +3534,7 @@ export class StateProofParticipant extends BaseModel { }) { super(); this.verifier = verifier; - this.weight = weight; + this.weight = typeof weight === 'undefined' ? undefined : BigInt(weight); this.attribute_map = { verifier: 'verifier', @@ -3516,7 +3568,7 @@ export class StateProofReveal extends BaseModel { * The position in the signature and participants arrays corresponding to this * entry. */ - public position?: number | bigint; + public position?: bigint; /** * (s) @@ -3541,7 +3593,8 @@ export class StateProofReveal extends BaseModel { }) { super(); this.participant = participant; - this.position = position; + this.position = + typeof position === 'undefined' ? undefined : BigInt(position); this.sigSlot = sigSlot; this.attribute_map = { @@ -3573,7 +3626,7 @@ export class StateProofSigSlot extends BaseModel { /** * (l) The total weight of signatures in the lower-numbered slots. */ - public lowerSigWeight?: number | bigint; + public lowerSigWeight?: bigint; public signature?: StateProofSignature; @@ -3590,7 +3643,10 @@ export class StateProofSigSlot extends BaseModel { signature?: StateProofSignature; }) { super(); - this.lowerSigWeight = lowerSigWeight; + this.lowerSigWeight = + typeof lowerSigWeight === 'undefined' + ? undefined + : BigInt(lowerSigWeight); this.signature = signature; this.attribute_map = { @@ -3616,7 +3672,7 @@ export class StateProofSigSlot extends BaseModel { export class StateProofSignature extends BaseModel { public falconSignature?: Uint8Array; - public merkleArrayIndex?: number | bigint; + public merkleArrayIndex?: bigint; public proof?: MerkleArrayProof; @@ -3648,7 +3704,10 @@ export class StateProofSignature extends BaseModel { typeof falconSignature === 'string' ? base64ToBytes(falconSignature) : falconSignature; - this.merkleArrayIndex = merkleArrayIndex; + this.merkleArrayIndex = + typeof merkleArrayIndex === 'undefined' + ? undefined + : BigInt(merkleArrayIndex); this.proof = proof; this.verifyingKey = typeof verifyingKey === 'string' @@ -3683,18 +3742,18 @@ export class StateProofTracking extends BaseModel { /** * (n) Next round for which we will accept a state proof transaction. */ - public nextRound?: number | bigint; + public nextRound?: bigint; /** * (t) The total number of microalgos held by the online accounts during the * StateProof round. */ - public onlineTotalWeight?: number | bigint; + public onlineTotalWeight?: bigint; /** * State Proof Type. Note the raw object uses map with this as key. */ - public type?: number | bigint; + public type?: bigint; /** * (v) Root of a vector commitment containing online accounts that will help sign @@ -3723,9 +3782,13 @@ export class StateProofTracking extends BaseModel { votersCommitment?: string | Uint8Array; }) { super(); - this.nextRound = nextRound; - this.onlineTotalWeight = onlineTotalWeight; - this.type = type; + this.nextRound = + typeof nextRound === 'undefined' ? undefined : BigInt(nextRound); + this.onlineTotalWeight = + typeof onlineTotalWeight === 'undefined' + ? undefined + : BigInt(onlineTotalWeight); + this.type = typeof type === 'undefined' ? undefined : BigInt(type); this.votersCommitment = typeof votersCommitment === 'string' ? base64ToBytes(votersCommitment) @@ -3761,7 +3824,7 @@ export class StateProofVerifier extends BaseModel { /** * (lf) Key lifetime. */ - public keyLifetime?: number | bigint; + public keyLifetime?: bigint; /** * Creates a new `StateProofVerifier` object. @@ -3778,7 +3841,8 @@ export class StateProofVerifier extends BaseModel { super(); this.commitment = typeof commitment === 'string' ? base64ToBytes(commitment) : commitment; - this.keyLifetime = keyLifetime; + this.keyLifetime = + typeof keyLifetime === 'undefined' ? undefined : BigInt(keyLifetime); this.attribute_map = { commitment: 'commitment', @@ -3807,12 +3871,12 @@ export class StateSchema extends BaseModel { /** * Maximum number of TEAL byte slices that may be stored in the key/value store. */ - public numByteSlice: number | bigint; + public numByteSlice: bigint; /** * Maximum number of TEAL uints that may be stored in the key/value store. */ - public numUint: number | bigint; + public numUint: bigint; /** * Creates a new `StateSchema` object. @@ -3827,8 +3891,8 @@ export class StateSchema extends BaseModel { numUint: number | bigint; }) { super(); - this.numByteSlice = numByteSlice; - this.numUint = numUint; + this.numByteSlice = BigInt(numByteSlice); + this.numUint = BigInt(numUint); this.attribute_map = { numByteSlice: 'num-byte-slice', @@ -3907,12 +3971,12 @@ export class TealValue extends BaseModel { /** * (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** */ - public type: number | bigint; + public type: bigint; /** * (ui) uint value. */ - public uint: number | bigint; + public uint: bigint; /** * Creates a new `TealValue` object. @@ -3931,8 +3995,8 @@ export class TealValue extends BaseModel { }) { super(); this.bytes = bytes; - this.type = type; - this.uint = uint; + this.type = BigInt(type); + this.uint = BigInt(uint); this.attribute_map = { bytes: 'bytes', @@ -3970,17 +4034,17 @@ export class Transaction extends BaseModel { /** * (fee) Transaction fee. */ - public fee: number | bigint; + public fee: bigint; /** * (fv) First valid round for this transaction. */ - public firstValid: number | bigint; + public firstValid: bigint; /** * (lv) Last valid round for this transaction. */ - public lastValid: number | bigint; + public lastValid: bigint; /** * (snd) Sender's address. @@ -4027,28 +4091,28 @@ export class Transaction extends BaseModel { /** * (rc) rewards applied to close-remainder-to account. */ - public closeRewards?: number | bigint; + public closeRewards?: bigint; /** * (ca) closing amount for transaction. */ - public closingAmount?: number | bigint; + public closingAmount?: bigint; /** * Round when the transaction was confirmed. */ - public confirmedRound?: number | bigint; + public confirmedRound?: bigint; /** * Specifies an application index (ID) if an application was created with this * transaction. */ - public createdApplicationIndex?: number | bigint; + public createdApplicationIndex?: bigint; /** * Specifies an asset index (ID) if an asset was created with this transaction. */ - public createdAssetIndex?: number | bigint; + public createdAssetIndex?: bigint; /** * (gh) Hash of genesis block. @@ -4086,7 +4150,7 @@ export class Transaction extends BaseModel { /** * Offset into the round where this transaction was confirmed. */ - public intraRoundOffset?: number | bigint; + public intraRoundOffset?: bigint; /** * Fields for a keyreg transaction. @@ -4130,7 +4194,7 @@ export class Transaction extends BaseModel { /** * (rr) rewards applied to receiver account. */ - public receiverRewards?: number | bigint; + public receiverRewards?: bigint; /** * (rekey) when included in a valid transaction, the accounts auth addr will be @@ -4142,12 +4206,12 @@ export class Transaction extends BaseModel { /** * Time when the block this transaction is in was confirmed. */ - public roundTime?: number | bigint; + public roundTime?: bigint; /** * (rs) rewards applied to sender account. */ - public senderRewards?: number | bigint; + public senderRewards?: bigint; /** * Validation signature associated with some data. Only one of the signatures @@ -4324,20 +4388,31 @@ export class Transaction extends BaseModel { txType?: string; }) { super(); - this.fee = fee; - this.firstValid = firstValid; - this.lastValid = lastValid; + this.fee = BigInt(fee); + this.firstValid = BigInt(firstValid); + this.lastValid = BigInt(lastValid); this.sender = sender; this.applicationTransaction = applicationTransaction; this.assetConfigTransaction = assetConfigTransaction; this.assetFreezeTransaction = assetFreezeTransaction; this.assetTransferTransaction = assetTransferTransaction; this.authAddr = authAddr; - this.closeRewards = closeRewards; - this.closingAmount = closingAmount; - this.confirmedRound = confirmedRound; - this.createdApplicationIndex = createdApplicationIndex; - this.createdAssetIndex = createdAssetIndex; + this.closeRewards = + typeof closeRewards === 'undefined' ? undefined : BigInt(closeRewards); + this.closingAmount = + typeof closingAmount === 'undefined' ? undefined : BigInt(closingAmount); + this.confirmedRound = + typeof confirmedRound === 'undefined' + ? undefined + : BigInt(confirmedRound); + this.createdApplicationIndex = + typeof createdApplicationIndex === 'undefined' + ? undefined + : BigInt(createdApplicationIndex); + this.createdAssetIndex = + typeof createdAssetIndex === 'undefined' + ? undefined + : BigInt(createdAssetIndex); this.genesisHash = typeof genesisHash === 'string' ? base64ToBytes(genesisHash) @@ -4347,17 +4422,25 @@ export class Transaction extends BaseModel { this.group = typeof group === 'string' ? base64ToBytes(group) : group; this.id = id; this.innerTxns = innerTxns; - this.intraRoundOffset = intraRoundOffset; + this.intraRoundOffset = + typeof intraRoundOffset === 'undefined' + ? undefined + : BigInt(intraRoundOffset); this.keyregTransaction = keyregTransaction; this.lease = typeof lease === 'string' ? base64ToBytes(lease) : lease; this.localStateDelta = localStateDelta; this.logs = logs; this.note = typeof note === 'string' ? base64ToBytes(note) : note; this.paymentTransaction = paymentTransaction; - this.receiverRewards = receiverRewards; + this.receiverRewards = + typeof receiverRewards === 'undefined' + ? undefined + : BigInt(receiverRewards); this.rekeyTo = rekeyTo; - this.roundTime = roundTime; - this.senderRewards = senderRewards; + this.roundTime = + typeof roundTime === 'undefined' ? undefined : BigInt(roundTime); + this.senderRewards = + typeof senderRewards === 'undefined' ? undefined : BigInt(senderRewards); this.signature = signature; this.stateProofTransaction = stateProofTransaction; this.txType = txType; @@ -4513,7 +4596,7 @@ export class TransactionApplication extends BaseModel { /** * (apid) ID of the application being configured or empty if creating. */ - public applicationId: number | bigint; + public applicationId: bigint; /** * (apat) List of accounts in addition to the sender that may be accessed from the @@ -4546,20 +4629,20 @@ export class TransactionApplication extends BaseModel { /** * (epp) specifies the additional app program len requested in pages. */ - public extraProgramPages?: number | bigint; + public extraProgramPages?: bigint; /** * (apfa) Lists the applications in addition to the application-id whose global * states may be accessed by this application's approval-program and * clear-state-program. The access is read-only. */ - public foreignApps?: (number | bigint)[]; + public foreignApps?: bigint[]; /** * (apas) lists the assets whose parameters may be accessed by this application's * ApprovalProgram and ClearStateProgram. The access is read-only. */ - public foreignAssets?: (number | bigint)[]; + public foreignAssets?: bigint[]; /** * Represents a (apls) local-state or (apgs) global-state schema. These schemas @@ -4655,7 +4738,7 @@ export class TransactionApplication extends BaseModel { onCompletion?: string; }) { super(); - this.applicationId = applicationId; + this.applicationId = BigInt(applicationId); this.accounts = accounts; this.applicationArgs = applicationArgs; this.approvalProgram = @@ -4666,9 +4749,12 @@ export class TransactionApplication extends BaseModel { typeof clearStateProgram === 'string' ? base64ToBytes(clearStateProgram) : clearStateProgram; - this.extraProgramPages = extraProgramPages; - this.foreignApps = foreignApps; - this.foreignAssets = foreignAssets; + this.extraProgramPages = + typeof extraProgramPages === 'undefined' + ? undefined + : BigInt(extraProgramPages); + this.foreignApps = foreignApps.map(BigInt); + this.foreignAssets = foreignAssets.map(BigInt); this.globalStateSchema = globalStateSchema; this.localStateSchema = localStateSchema; this.onCompletion = onCompletion; @@ -4731,7 +4817,7 @@ export class TransactionAssetConfig extends BaseModel { /** * (xaid) ID of the asset being configured or empty if creating. */ - public assetId?: number | bigint; + public assetId?: bigint; /** * AssetParams specifies the parameters for an asset. @@ -4757,7 +4843,7 @@ export class TransactionAssetConfig extends BaseModel { params?: AssetParams; }) { super(); - this.assetId = assetId; + this.assetId = typeof assetId === 'undefined' ? undefined : BigInt(assetId); this.params = params; this.attribute_map = { @@ -4796,7 +4882,7 @@ export class TransactionAssetFreeze extends BaseModel { /** * (faid) ID of the asset being frozen or thawed. */ - public assetId: number | bigint; + public assetId: bigint; /** * (afrz) The new freeze status. @@ -4820,7 +4906,7 @@ export class TransactionAssetFreeze extends BaseModel { }) { super(); this.address = address; - this.assetId = assetId; + this.assetId = BigInt(assetId); this.newFreezeStatus = newFreezeStatus; this.attribute_map = { @@ -4862,12 +4948,12 @@ export class TransactionAssetTransfer extends BaseModel { * (aamt) Amount of asset to transfer. A zero amount transferred to self allocates * that asset in the account's Assets map. */ - public amount: number | bigint; + public amount: bigint; /** * (xaid) ID of the asset being transferred. */ - public assetId: number | bigint; + public assetId: bigint; /** * (arcv) Recipient address of the transfer. @@ -4875,9 +4961,9 @@ export class TransactionAssetTransfer extends BaseModel { public receiver: string; /** - * Number of assets transferred to the close-to account as part of the transaction. + * Number of assets transfered to the close-to account as part of the transaction. */ - public closeAmount?: number | bigint; + public closeAmount?: bigint; /** * (aclose) Indicates that the asset should be removed from the account's Assets @@ -4899,7 +4985,7 @@ export class TransactionAssetTransfer extends BaseModel { * that asset in the account's Assets map. * @param assetId - (xaid) ID of the asset being transferred. * @param receiver - (arcv) Recipient address of the transfer. - * @param closeAmount - Number of assets transferred to the close-to account as part of the transaction. + * @param closeAmount - Number of assets transfered to the close-to account as part of the transaction. * @param closeTo - (aclose) Indicates that the asset should be removed from the account's Assets * map, and specifies where the remaining asset holdings should be transferred. * It's always valid to transfer remaining asset holdings to the creator account. @@ -4923,10 +5009,11 @@ export class TransactionAssetTransfer extends BaseModel { sender?: string; }) { super(); - this.amount = amount; - this.assetId = assetId; + this.amount = BigInt(amount); + this.assetId = BigInt(assetId); this.receiver = receiver; - this.closeAmount = closeAmount; + this.closeAmount = + typeof closeAmount === 'undefined' ? undefined : BigInt(closeAmount); this.closeTo = closeTo; this.sender = sender; @@ -4988,17 +5075,17 @@ export class TransactionKeyreg extends BaseModel { /** * (votefst) First round this participation key is valid. */ - public voteFirstValid?: number | bigint; + public voteFirstValid?: bigint; /** * (votekd) Number of subkeys in each batch of participation keys. */ - public voteKeyDilution?: number | bigint; + public voteKeyDilution?: bigint; /** * (votelst) Last round this participation key is valid. */ - public voteLastValid?: number | bigint; + public voteLastValid?: bigint; /** * (votekey) Participation public key used in key registration transactions. @@ -5043,9 +5130,16 @@ export class TransactionKeyreg extends BaseModel { typeof stateProofKey === 'string' ? base64ToBytes(stateProofKey) : stateProofKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; + this.voteFirstValid = + typeof voteFirstValid === 'undefined' + ? undefined + : BigInt(voteFirstValid); + this.voteKeyDilution = + typeof voteKeyDilution === 'undefined' + ? undefined + : BigInt(voteKeyDilution); + this.voteLastValid = + typeof voteLastValid === 'undefined' ? undefined : BigInt(voteLastValid); this.voteParticipationKey = typeof voteParticipationKey === 'string' ? base64ToBytes(voteParticipationKey) @@ -5087,7 +5181,7 @@ export class TransactionPayment extends BaseModel { /** * (amt) number of MicroAlgos intended to be transferred. */ - public amount: number | bigint; + public amount: bigint; /** * (rcv) receiver's address. @@ -5098,7 +5192,7 @@ export class TransactionPayment extends BaseModel { * Number of MicroAlgos that were sent to the close-remainder-to address when * closing the sender account. */ - public closeAmount?: number | bigint; + public closeAmount?: bigint; /** * (close) when set, indicates that the sending account should be closed and all @@ -5127,9 +5221,10 @@ export class TransactionPayment extends BaseModel { closeRemainderTo?: string; }) { super(); - this.amount = amount; + this.amount = BigInt(amount); this.receiver = receiver; - this.closeAmount = closeAmount; + this.closeAmount = + typeof closeAmount === 'undefined' ? undefined : BigInt(closeAmount); this.closeRemainderTo = closeRemainderTo; this.attribute_map = { @@ -5164,7 +5259,7 @@ export class TransactionResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; /** * Contains all fields common to all transactions and serves as an envelope to all @@ -5192,7 +5287,7 @@ export class TransactionResponse extends BaseModel { transaction: Transaction; }) { super(); - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.transaction = transaction; this.attribute_map = { @@ -5396,12 +5491,12 @@ export class TransactionSignatureMultisig extends BaseModel { /** * (thr) */ - public threshold?: number | bigint; + public threshold?: bigint; /** * (v) */ - public version?: number | bigint; + public version?: bigint; /** * Creates a new `TransactionSignatureMultisig` object. @@ -5420,8 +5515,9 @@ export class TransactionSignatureMultisig extends BaseModel { }) { super(); this.subsignature = subsignature; - this.threshold = threshold; - this.version = version; + this.threshold = + typeof threshold === 'undefined' ? undefined : BigInt(threshold); + this.version = typeof version === 'undefined' ? undefined : BigInt(version); this.attribute_map = { subsignature: 'subsignature', @@ -5519,7 +5615,7 @@ export class TransactionStateProof extends BaseModel { * (sptype) Type of the state proof. Integer representing an entry defined in * protocol/stateproof.go */ - public stateProofType?: number | bigint; + public stateProofType?: bigint; /** * Creates a new `TransactionStateProof` object. @@ -5542,7 +5638,10 @@ export class TransactionStateProof extends BaseModel { super(); this.message = message; this.stateProof = stateProof; - this.stateProofType = stateProofType; + this.stateProofType = + typeof stateProofType === 'undefined' + ? undefined + : BigInt(stateProofType); this.attribute_map = { message: 'message', @@ -5578,7 +5677,7 @@ export class TransactionsResponse extends BaseModel { /** * Round at which the results were computed. */ - public currentRound: number | bigint; + public currentRound: bigint; public transactions: Transaction[]; @@ -5605,7 +5704,7 @@ export class TransactionsResponse extends BaseModel { nextToken?: string; }) { super(); - this.currentRound = currentRound; + this.currentRound = BigInt(currentRound); this.transactions = transactions; this.nextToken = nextToken; diff --git a/src/client/v2/indexer/searchForApplicationBoxes.ts b/src/client/v2/indexer/searchForApplicationBoxes.ts index b881de422..94e56b31d 100644 --- a/src/client/v2/indexer/searchForApplicationBoxes.ts +++ b/src/client/v2/indexer/searchForApplicationBoxes.ts @@ -1,6 +1,5 @@ import JSONRequest from '../jsonrequest'; import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; import { BoxesResponse } from './models/types'; export default class SearchForApplicationBoxes extends JSONRequest< @@ -33,8 +32,8 @@ export default class SearchForApplicationBoxes extends JSONRequest< * @oaram index - application index. * @category GET */ - constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { - super(c, intDecoding); + constructor(c: HTTPClient, private index: number) { + super(c); this.index = index; } diff --git a/src/client/v2/jsonrequest.ts b/src/client/v2/jsonrequest.ts index 5b1062d6b..ca901576e 100644 --- a/src/client/v2/jsonrequest.ts +++ b/src/client/v2/jsonrequest.ts @@ -1,5 +1,4 @@ import HTTPClient from '../client'; -import IntDecoding from '../../types/intDecoding'; /** * Base abstract class for JSON requests. @@ -14,18 +13,13 @@ export default abstract class JSONRequest< > { c: HTTPClient; query: Record; - intDecoding: IntDecoding; /** * @param client - HTTPClient object. - * @param intDecoding - The method to use - * for decoding integers from this request's response. See the setIntDecoding method for more - * details. */ - constructor(client: HTTPClient, intDecoding?: IntDecoding) { + constructor(client: HTTPClient) { this.c = client; this.query = {}; - this.intDecoding = intDecoding || IntDecoding.DEFAULT; } /** @@ -54,11 +48,7 @@ export default abstract class JSONRequest< * @category JSONRequest */ async do(headers: Record = {}): Promise { - const jsonOptions: Record = {}; - if (this.intDecoding !== 'default') { - jsonOptions.intDecoding = this.intDecoding; - } - const res = await this.c.get(this.path(), this.query, headers, jsonOptions); + const res = await this.c.get(this.path(), this.query, headers); return this.prepare(res.body); } @@ -72,32 +62,4 @@ export default abstract class JSONRequest< const res = await this.c.get(this.path(), this.query, headers, {}, false); return res.body; } - - /** - * Configure how integers in this request's JSON response will be decoded. - * - * The options are: - * * "default": Integers will be decoded according to JSON.parse, meaning they will all be - * Numbers and any values greater than Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * @param method - The method to use when parsing the - * response for this request. Must be one of "default", "safe", "mixed", or "bigint". - * @category JSONRequest - */ - setIntDecoding(method: IntDecoding) { - if ( - method !== 'default' && - method !== 'safe' && - method !== 'mixed' && - method !== 'bigint' - ) - throw new Error(`Invalid method for int decoding: ${method}`); - this.intDecoding = method; - return this; - } } diff --git a/src/client/v2/serviceClient.ts b/src/client/v2/serviceClient.ts index 14fae2922..b40d83d75 100644 --- a/src/client/v2/serviceClient.ts +++ b/src/client/v2/serviceClient.ts @@ -1,5 +1,4 @@ import HTTPClient from '../client'; -import IntDecoding from '../../types/intDecoding'; import { BaseHTTPClient } from '../baseHTTPClient'; import { TokenHeader } from '../urlTokenBaseHTTPClient'; @@ -38,8 +37,6 @@ function isBaseHTTPClient( export default abstract class ServiceClient { /** @ignore */ c: HTTPClient; - /** @ignore */ - intDecoding: IntDecoding; constructor( tokenHeaderIdentifier: TokenHeaderIdentifier, @@ -66,24 +63,5 @@ export default abstract class ServiceClient { this.c = new HTTPClient(tokenHeader, baseServer, port, defaultHeaders); } - - this.intDecoding = IntDecoding.DEFAULT; - } - - /** - * Set the default int decoding method for all JSON requests this client creates. - * @param method - \{"default" | "safe" | "mixed" | "bigint"\} method The method to use when parsing the - * response for request. Must be one of "default", "safe", "mixed", or "bigint". See - * JSONRequest.setIntDecoding for more details about what each method does. - */ - setIntEncoding(method: IntDecoding) { - this.intDecoding = method; - } - - /** - * Get the default int decoding method for all JSON requests this client creates. - */ - getIntEncoding() { - return this.intDecoding; } } diff --git a/src/main.ts b/src/main.ts index be5b92d12..9df42ca4f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -147,6 +147,7 @@ export { hexToBytes, } from './encoding/binarydata'; export { encodeUint64, decodeUint64 } from './encoding/uint64'; +export { parseJSON, stringifyJSON, JSONOptions } from './utils/utils'; export { default as generateAccount } from './account'; export * as modelsv2 from './client/v2/algod/models/types'; export * as indexerModels from './client/v2/indexer/models/types'; diff --git a/src/types/intDecoding.ts b/src/types/intDecoding.ts index e974b050a..e15659c16 100644 --- a/src/types/intDecoding.ts +++ b/src/types/intDecoding.ts @@ -6,7 +6,7 @@ enum IntDecoding { * All integers will be decoded as Numbers, meaning any values greater than * Number.MAX_SAFE_INTEGER will lose precision. */ - DEFAULT = 'default', + UNSAFE = 'unsafe', /** * All integers will be decoded as Numbers, but if any values are greater than diff --git a/src/types/transactions/base.ts b/src/types/transactions/base.ts index e39973ec7..cc9fb3cdf 100644 --- a/src/types/transactions/base.ts +++ b/src/types/transactions/base.ts @@ -107,17 +107,17 @@ export interface SuggestedParams { /** * Integer fee per byte, in microAlgos. For a flat fee, set flatFee to true */ - fee: number; + fee: number | bigint; /** * First protocol round on which this txn is valid */ - firstValid: number; + firstValid: number | bigint; /** * Last protocol round on which this txn is valid */ - lastValid: number; + lastValid: number | bigint; /** * Specifies genesis ID of network in use @@ -134,7 +134,7 @@ export type SuggestedParamsWithMinFee = SuggestedParams & { /** * Minimum fee (not per byte) required for the transaction to be confirmed */ - minFee: number; + minFee: bigint; }; /** diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 620644b3a..5380e45ca 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -10,23 +10,13 @@ export interface JSONOptions { /** * Parse JSON with additional options. * @param str - The JSON string to parse. - * @param options - Options object to configure how integers in - * this request's JSON response will be decoded. Use the `intDecoding` - * property with one of the following options: - * - * * "default": All integers will be decoded as Numbers, meaning any values greater than - * Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * Defaults to "default" if not included. + * @param options - Options object to configure how integers in this request's JSON response will be + * decoded. If options.intDecoding is not provided, IntDecoding.BIGINT will be used, meaning all + * numeric values will be decoded as BigInts. See the IntDecoding enum for more details. */ export function parseJSON(str: string, options?: JSONOptions) { const intDecoding = - options && options.intDecoding ? options.intDecoding : IntDecoding.DEFAULT; + options && options.intDecoding ? options.intDecoding : IntDecoding.BIGINT; return JSONbig.parse(str, (_, value) => { if ( value != null && @@ -39,14 +29,14 @@ export function parseJSON(str: string, options?: JSONOptions) { } if (typeof value === 'bigint') { - if (intDecoding === 'safe' && value > Number.MAX_SAFE_INTEGER) { + if (intDecoding === IntDecoding.SAFE && value > Number.MAX_SAFE_INTEGER) { throw new Error( `Integer exceeds maximum safe integer: ${value.toString()}. Try parsing with a different intDecoding option.` ); } if ( - intDecoding === 'bigint' || - (intDecoding === 'mixed' && value > Number.MAX_SAFE_INTEGER) + intDecoding === IntDecoding.BIGINT || + (intDecoding === IntDecoding.MIXED && value > Number.MAX_SAFE_INTEGER) ) { return value; } @@ -56,7 +46,7 @@ export function parseJSON(str: string, options?: JSONOptions) { } if (typeof value === 'number') { - if (intDecoding === 'bigint' && Number.isInteger(value)) { + if (intDecoding === IntDecoding.BIGINT && Number.isInteger(value)) { return BigInt(value); } } @@ -65,6 +55,23 @@ export function parseJSON(str: string, options?: JSONOptions) { }); } +/** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * + * This functions differs from the built-in JSON.stringify in that it supports serializing BigInts. + * + * @param value - A JavaScript value, usually an object or array, to be converted. + * @param replacer - A function that transforms the results. + * @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ +export function stringifyJSON( + value: any, + replacer?: (this: any, key: string, value: any) => any, + space?: string | number +): string { + return JSONbig.stringify(value, replacer, space); +} + /** * ArrayEqual takes two arrays and return true if equal, false otherwise */ diff --git a/tests/2.Encoding.js b/tests/2.Encoding.js index 0a861e561..0a6477c2f 100644 --- a/tests/2.Encoding.js +++ b/tests/2.Encoding.js @@ -353,11 +353,16 @@ describe('encoding', () => { }); }); - describe('JSON parse BigInt', () => { + describe('JSON BigInt', () => { it('should parse null', () => { const input = 'null'; - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); const expected = null; @@ -366,21 +371,43 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } }); it('should parse number', () => { const inputs = ['17', '9007199254740991']; for (const input of inputs) { - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); const expected = - intDecoding === 'bigint' ? BigInt(input) : Number(input); + intDecoding === algosdk.IntDecoding.BIGINT + ? BigInt(input) + : Number(input); + assert.deepStrictEqual( actual, expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } } }); @@ -388,7 +415,12 @@ describe('encoding', () => { it('should parse empty object', () => { const input = '{}'; - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); const expected = {}; @@ -397,17 +429,29 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } }); it('should parse populated object', () => { const input = '{"a":1,"b":"value","c":[1,2,3],"d":null,"e":{},"f":true}'; - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); let expected; - if (intDecoding === 'bigint') { + if (intDecoding === algosdk.IntDecoding.BIGINT) { expected = { a: 1n, b: 'value', @@ -432,6 +476,13 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } }); @@ -439,20 +490,26 @@ describe('encoding', () => { const input = '{"a":0,"b":9007199254740991,"c":9007199254740992,"d":9223372036854775807}'; - assert.throws(() => utils.parseJSON(input, { intDecoding: 'safe' })); + assert.throws(() => + utils.parseJSON(input, { intDecoding: algosdk.IntDecoding.SAFE }) + ); - for (const intDecoding of ['default', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); let expected; - if (intDecoding === 'bigint') { + if (intDecoding === algosdk.IntDecoding.BIGINT) { expected = { a: 0n, b: 9007199254740991n, c: 9007199254740992n, d: 9223372036854775807n, }; - } else if (intDecoding === 'mixed') { + } else if (intDecoding === algosdk.IntDecoding.MIXED) { expected = { a: 0, b: 9007199254740991, @@ -473,13 +530,27 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + if (intDecoding !== algosdk.IntDecoding.UNSAFE) { + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); + } } }); it('should parse empty array', () => { const input = '[]'; - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); const expected = []; @@ -488,17 +559,29 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } }); it('should parse populated array', () => { const input = '["test",2,null,[7],{"a":9.5},true]'; - for (const intDecoding of ['default', 'safe', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.SAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); let expected; - if (intDecoding === 'bigint') { + if (intDecoding === algosdk.IntDecoding.BIGINT) { expected = ['test', 2n, null, [7n], { a: 9.5 }, true]; } else { expected = ['test', 2, null, [7], { a: 9.5 }, true]; @@ -509,6 +592,13 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); } }); @@ -517,18 +607,22 @@ describe('encoding', () => { assert.throws(() => utils.parseJSON(input, { intDecoding: 'safe' })); - for (const intDecoding of ['default', 'mixed', 'bigint']) { + for (const intDecoding of [ + algosdk.IntDecoding.UNSAFE, + algosdk.IntDecoding.MIXED, + algosdk.IntDecoding.BIGINT, + ]) { const actual = utils.parseJSON(input, { intDecoding }); let expected; - if (intDecoding === 'bigint') { + if (intDecoding === algosdk.IntDecoding.BIGINT) { expected = [ 0n, 9007199254740991n, 9007199254740992n, 9223372036854775807n, ]; - } else if (intDecoding === 'mixed') { + } else if (intDecoding === algosdk.IntDecoding.MIXED) { expected = [ 0, 9007199254740991, @@ -549,8 +643,35 @@ describe('encoding', () => { expected, `Error when intDecoding = ${intDecoding}` ); + + if (intDecoding !== algosdk.IntDecoding.UNSAFE) { + const roundtrip = utils.stringifyJSON(actual); + assert.deepStrictEqual( + roundtrip, + input, + `Error when intDecoding = ${intDecoding}` + ); + } } }); + + it('should stringify with spacing', () => { + const input = { a: 1, b: 'value', c: [1, 2, 3], d: null, e: {}, f: true }; + const actual = utils.stringifyJSON(input, null, 2); + const expected = `{ + "a": 1, + "b": "value", + "c": [ + 1, + 2, + 3 + ], + "d": null, + "e": {}, + "f": true +}`; + assert.deepStrictEqual(actual, expected); + }); }); describe('Base64 decoding utilities', () => { diff --git a/tests/7.AlgoSDK.js b/tests/7.AlgoSDK.js index 37885440e..75442b181 100644 --- a/tests/7.AlgoSDK.js +++ b/tests/7.AlgoSDK.js @@ -2,7 +2,7 @@ const assert = require('assert'); const algosdk = require('../src/index'); const nacl = require('../src/nacl/naclWrappers'); -const utils = require('../src/utils/utils'); +const { concatArrays } = require('../src/utils/utils'); describe('Algosdk (AKA end to end)', () => { describe('#mnemonic', () => { @@ -555,7 +555,7 @@ describe('Algosdk (AKA end to end)', () => { tx2.group = gid; stx1 = algosdk.encodeObj({ txn: tx1.get_obj_for_encoding() }); stx2 = algosdk.encodeObj({ txn: tx2.get_obj_for_encoding() }); - const concat = utils.concatArrays(stx1, stx2); + const concat = concatArrays(stx1, stx2); assert.deepStrictEqual(concat, algosdk.base64ToBytes(goldenTxg)); } @@ -566,7 +566,7 @@ describe('Algosdk (AKA end to end)', () => { tx2.group = gid; stx1 = algosdk.encodeObj({ txn: tx1.get_obj_for_encoding() }); stx2 = algosdk.encodeObj({ txn: tx2.get_obj_for_encoding() }); - const concat = utils.concatArrays(stx1, stx2); + const concat = concatArrays(stx1, stx2); assert.deepStrictEqual(concat, algosdk.base64ToBytes(goldenTxg)); } @@ -944,11 +944,8 @@ describe('Algosdk (AKA end to end)', () => { it('should produce a verifiable signature', () => { const sig = algosdk.tealSign(sk, data, addr); - const parts = utils.concatArrays( - algosdk.decodeAddress(addr).publicKey, - data - ); - const toBeVerified = utils.concatArrays( + const parts = concatArrays(algosdk.decodeAddress(addr).publicKey, data); + const toBeVerified = concatArrays( new TextEncoder().encode('ProgData'), parts ); @@ -980,11 +977,16 @@ describe('Algosdk (AKA end to end)', () => { address: 'UAPJE355K7BG7RQVMTZOW7QW4ICZJEIC3RZGYG5LSHZ65K6LCNFPJDSR7M', amount: 5002280000000000, amountWithoutPendingRewards: 5000000000000000, + minBalance: 100000, pendingRewards: 2280000000000, rewardBase: 456, rewards: 2280000000000, round: 18241, status: 'Online', + totalAppsOptedIn: 0, + totalAssetsOptedIn: 0, + totalCreatedApps: 0, + totalCreatedAssets: 0, }); const params = new algosdk.modelsv2.ApplicationParams({ creator: 'UAPJE355K7BG7RQVMTZOW7QW4ICZJEIC3RZGYG5LSHZ65K6LCNFPJDSR7M', @@ -1000,10 +1002,10 @@ describe('Algosdk (AKA end to end)', () => { // make a raw txn const txn = { apsu: 'AiABASI=', - fee: 1000, - fv: 18242, + fee: BigInt(1000), + fv: BigInt(18242), gh: 'ZIkPs8pTDxbRJsFB1yJ7gvnpDu0Q85FRkl2NCkEAQLU=', - lv: 19242, + lv: BigInt(19242), note: 'tjpNge78JD8=', snd: 'UAPJE355K7BG7RQVMTZOW7QW4ICZJEIC3RZGYG5LSHZ65K6LCNFPJDSR7M', type: 'appl', @@ -1021,20 +1023,21 @@ describe('Algosdk (AKA end to end)', () => { const actual = req.get_obj_for_encoding(); const golden = - 'ewogICJhY2NvdW50cyI6IFsKICAgIHsKICAgICAgImFkZHJlc3MiOiAiVUFQSkUzNTVLN0JHN1JRVk1UWk9XN1FXNElDWkpFSUMzUlpHWUc1TFNIWjY1SzZMQ05GUEpEU1I3TSIsCiAgICAgICJhbW91bnQiOiA1MDAyMjgwMDAwMDAwMDAwLAogICAgICAiYW1vdW50LXdpdGhvdXQtcGVuZGluZy1yZXdhcmRzIjogNTAwMDAwMDAwMDAwMDAwMCwKICAgICAgInBlbmRpbmctcmV3YXJkcyI6IDIyODAwMDAwMDAwMDAsCiAgICAgICJyZXdhcmQtYmFzZSI6IDQ1NiwKICAgICAgInJld2FyZHMiOiAyMjgwMDAwMDAwMDAwLAogICAgICAicm91bmQiOiAxODI0MSwKICAgICAgInN0YXR1cyI6ICJPbmxpbmUiCiAgICB9CiAgXSwKICAiYXBwcyI6IFsKICAgIHsKICAgICAgImlkIjogMTM4MDAxMTU4OCwKICAgICAgInBhcmFtcyI6IHsKICAgICAgICAiY3JlYXRvciI6ICJVQVBKRTM1NUs3Qkc3UlFWTVRaT1c3UVc0SUNaSkVJQzNSWkdZRzVMU0haNjVLNkxDTkZQSkRTUjdNIiwKICAgICAgICAiYXBwcm92YWwtcHJvZ3JhbSI6ICJBaUFCQVNJPSIsCiAgICAgICAgImNsZWFyLXN0YXRlLXByb2dyYW0iOiAiQWlBQkFTST0iLAogICAgICAgICJnbG9iYWwtc3RhdGUtc2NoZW1hIjogewogICAgICAgICAgIm51bS1ieXRlLXNsaWNlIjogNSwKICAgICAgICAgICJudW0tdWludCI6IDUKICAgICAgICB9LAogICAgICAgICJsb2NhbC1zdGF0ZS1zY2hlbWEiOiB7CiAgICAgICAgICAibnVtLWJ5dGUtc2xpY2UiOiA1LAogICAgICAgICAgIm51bS11aW50IjogNQogICAgICAgIH0KICAgICAgfQogICAgfQogIF0sCiAgImxhdGVzdC10aW1lc3RhbXAiOiAxNTkyNTM3NzU3LAogICJwcm90b2NvbC12ZXJzaW9uIjogImZ1dHVyZSIsCiAgInJvdW5kIjogMTgyNDEsCiAgInR4bnMiOiBbCiAgICB7CiAgICAgICJ0eG4iOiB7CiAgICAgICAgImFwc3UiOiAiQWlBQkFTST0iLAogICAgICAgICJmZWUiOiAxMDAwLAogICAgICAgICJmdiI6IDE4MjQyLAogICAgICAgICJnaCI6ICJaSWtQczhwVER4YlJKc0ZCMXlKN2d2bnBEdTBRODVGUmtsMk5Da0VBUUxVPSIsCiAgICAgICAgImx2IjogMTkyNDIsCiAgICAgICAgIm5vdGUiOiAidGpwTmdlNzhKRDg9IiwKICAgICAgICAic25kIjogIlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN00iLAogICAgICAgICJ0eXBlIjogImFwcGwiCiAgICAgIH0KICAgIH0KICBdCn0K'; + 'ewogICJhY2NvdW50cyI6IFsKICAgIHsKICAgICAgImFkZHJlc3MiOiAiVUFQSkUzNTVLN0JHN1JRVk1UWk9XN1FXNElDWkpFSUMzUlpHWUc1TFNIWjY1SzZMQ05GUEpEU1I3TSIsCiAgICAgICJhbW91bnQiOiA1MDAyMjgwMDAwMDAwMDAwLAogICAgICAiYW1vdW50LXdpdGhvdXQtcGVuZGluZy1yZXdhcmRzIjogNTAwMDAwMDAwMDAwMDAwMCwKICAgICAgIm1pbi1iYWxhbmNlIjogMTAwMDAwLAogICAgICAicGVuZGluZy1yZXdhcmRzIjogMjI4MDAwMDAwMDAwMCwKICAgICAgInJld2FyZC1iYXNlIjogNDU2LAogICAgICAicmV3YXJkcyI6IDIyODAwMDAwMDAwMDAsCiAgICAgICJyb3VuZCI6IDE4MjQxLAogICAgICAic3RhdHVzIjogIk9ubGluZSIsCiAgICAgICJ0b3RhbC1hcHBzLW9wdGVkLWluIjogMCwKICAgICAgInRvdGFsLWFzc2V0cy1vcHRlZC1pbiI6IDAsCiAgICAgICJ0b3RhbC1jcmVhdGVkLWFwcHMiOiAwLAogICAgICAidG90YWwtY3JlYXRlZC1hc3NldHMiOiAwCiAgICB9CiAgXSwKICAiYXBwcyI6IFsKICAgIHsKICAgICAgImlkIjogMTM4MDAxMTU4OCwKICAgICAgInBhcmFtcyI6IHsKICAgICAgICAiY3JlYXRvciI6ICJVQVBKRTM1NUs3Qkc3UlFWTVRaT1c3UVc0SUNaSkVJQzNSWkdZRzVMU0haNjVLNkxDTkZQSkRTUjdNIiwKICAgICAgICAiYXBwcm92YWwtcHJvZ3JhbSI6ICJBaUFCQVNJPSIsCiAgICAgICAgImNsZWFyLXN0YXRlLXByb2dyYW0iOiAiQWlBQkFTST0iLAogICAgICAgICJnbG9iYWwtc3RhdGUtc2NoZW1hIjogewogICAgICAgICAgIm51bS1ieXRlLXNsaWNlIjogNSwKICAgICAgICAgICJudW0tdWludCI6IDUKICAgICAgICB9LAogICAgICAgICJsb2NhbC1zdGF0ZS1zY2hlbWEiOiB7CiAgICAgICAgICAibnVtLWJ5dGUtc2xpY2UiOiA1LAogICAgICAgICAgIm51bS11aW50IjogNQogICAgICAgIH0KICAgICAgfQogICAgfQogIF0sCiAgImxhdGVzdC10aW1lc3RhbXAiOiAxNTkyNTM3NzU3LAogICJwcm90b2NvbC12ZXJzaW9uIjogImZ1dHVyZSIsCiAgInJvdW5kIjogMTgyNDEsCiAgInR4bnMiOiBbCiAgICB7CiAgICAgICJ0eG4iOiB7CiAgICAgICAgImFwc3UiOiAiQWlBQkFTST0iLAogICAgICAgICJmZWUiOiAxMDAwLAogICAgICAgICJmdiI6IDE4MjQyLAogICAgICAgICJnaCI6ICJaSWtQczhwVER4YlJKc0ZCMXlKN2d2bnBEdTBRODVGUmtsMk5Da0VBUUxVPSIsCiAgICAgICAgImx2IjogMTkyNDIsCiAgICAgICAgIm5vdGUiOiAidGpwTmdlNzhKRDg9IiwKICAgICAgICAic25kIjogIlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN00iLAogICAgICAgICJ0eXBlIjogImFwcGwiCiAgICAgIH0KICAgIH0KICBdCn0K'; const goldenString = algosdk.base64ToString(golden, 'base64'); - const expected = JSON.parse(goldenString); + const expected = algosdk.parseJSON(goldenString, { + intDecoding: algosdk.IntDecoding.BIGINT, + }); assert.deepStrictEqual(actual, expected); }); it('should be properly serialized to msgpack', () => { - const actual = req.get_obj_for_encoding(true); - const golden = - 'hqhhY2NvdW50c5GIp2FkZHJlc3PZOlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN02mYW1vdW50zwARxYwSd5AAvmFtb3VudC13aXRob3V0LXBlbmRpbmctcmV3YXJkc88AEcN5N+CAAK9wZW5kaW5nLXJld2FyZHPPAAACEtqXEACrcmV3YXJkLWJhc2XNAcincmV3YXJkc88AAAIS2pcQAKVyb3VuZM1HQaZzdGF0dXOmT25saW5lpGFwcHORgqJpZM5SQU5EpnBhcmFtc4WwYXBwcm92YWwtcHJvZ3JhbcQFAiABASKzY2xlYXItc3RhdGUtcHJvZ3JhbcQFAiABASKnY3JlYXRvctk6VUFQSkUzNTVLN0JHN1JRVk1UWk9XN1FXNElDWkpFSUMzUlpHWUc1TFNIWjY1SzZMQ05GUEpEU1I3TbNnbG9iYWwtc3RhdGUtc2NoZW1hgq5udW0tYnl0ZS1zbGljZQWobnVtLXVpbnQFsmxvY2FsLXN0YXRlLXNjaGVtYYKubnVtLWJ5dGUtc2xpY2UFqG51bS11aW50BbBsYXRlc3QtdGltZXN0YW1wzl7sMp2wcHJvdG9jb2wtdmVyc2lvbqZmdXR1cmWlcm91bmTNR0GkdHhuc5GBo3R4boikYXBzdahBaUFCQVNJPaNmZWXNA+iiZnbNR0KiZ2jZLFpJa1BzOHBURHhiUkpzRkIxeUo3Z3ZucER1MFE4NUZSa2wyTkNrRUFRTFU9omx2zUsqpG5vdGWsdGpwTmdlNzhKRDg9o3NuZNk6VUFQSkUzNTVLN0JHN1JRVk1UWk9XN1FXNElDWkpFSUMzUlpHWUc1TFNIWjY1SzZMQ05GUEpEU1I3TaR0eXBlpGFwcGw='; - const goldenBinary = new Uint8Array(algosdk.base64ToBytes(golden)); - const expected = algosdk.decodeObj(goldenBinary); - + const forEncoding = req.get_obj_for_encoding(true, true); + const actual = algosdk.encodeObj(forEncoding); + const expected = algosdk.base64ToBytes( + 'hqhhY2NvdW50c5GNp2FkZHJlc3PZOlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN02mYW1vdW50zwARxYwSd5AAvmFtb3VudC13aXRob3V0LXBlbmRpbmctcmV3YXJkc88AEcN5N+CAAKttaW4tYmFsYW5jZc4AAYagr3BlbmRpbmctcmV3YXJkc88AAAIS2pcQAKtyZXdhcmQtYmFzZc0ByKdyZXdhcmRzzwAAAhLalxAApXJvdW5kzUdBpnN0YXR1c6ZPbmxpbmWzdG90YWwtYXBwcy1vcHRlZC1pbgC1dG90YWwtYXNzZXRzLW9wdGVkLWluALJ0b3RhbC1jcmVhdGVkLWFwcHMAtHRvdGFsLWNyZWF0ZWQtYXNzZXRzAKRhcHBzkYKiaWTOUkFORKZwYXJhbXOFsGFwcHJvdmFsLXByb2dyYW3EBQIgAQEis2NsZWFyLXN0YXRlLXByb2dyYW3EBQIgAQEip2NyZWF0b3LZOlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN02zZ2xvYmFsLXN0YXRlLXNjaGVtYYKubnVtLWJ5dGUtc2xpY2UFqG51bS11aW50BbJsb2NhbC1zdGF0ZS1zY2hlbWGCrm51bS1ieXRlLXNsaWNlBahudW0tdWludAWwbGF0ZXN0LXRpbWVzdGFtcM5e7DKdsHByb3RvY29sLXZlcnNpb26mZnV0dXJlpXJvdW5kzUdBpHR4bnORgaN0eG6IpGFwc3WoQWlBQkFTST2jZmVlzQPoomZ2zUdComdo2SxaSWtQczhwVER4YlJKc0ZCMXlKN2d2bnBEdTBRODVGUmtsMk5Da0VBUUxVPaJsds1LKqRub3RlrHRqcE5nZTc4SkQ4PaNzbmTZOlVBUEpFMzU1SzdCRzdSUVZNVFpPVzdRVzRJQ1pKRUlDM1JaR1lHNUxTSFo2NUs2TENORlBKRFNSN02kdHlwZaRhcHBs' + ); assert.deepStrictEqual(actual, expected); }); }); diff --git a/tests/9.Client.ts b/tests/9.Client.ts index f47e36838..4819d4f5e 100644 --- a/tests/9.Client.ts +++ b/tests/9.Client.ts @@ -69,12 +69,13 @@ describe('client', () => { const j = '{"total":18446744073709551615, "base":42}'; let options = { - // intDecoding: IntDecoding.DEFAULT, + // Should default to IntDecoding.BIGINT, }; let actual = HTTPClient.parseJSON(j, 200, options); - let expected = JSON.parse(j); + let expected = utils.parseJSON(j, options); assert.strictEqual(actual.total, expected.total); - assert.strictEqual(typeof actual.total, 'number'); + assert.strictEqual(typeof actual.total, 'bigint'); + assert.strictEqual(typeof actual.base, 'bigint'); options = { intDecoding: IntDecoding.BIGINT, @@ -83,6 +84,7 @@ describe('client', () => { expected = utils.parseJSON(j, options); assert.strictEqual(actual.total, expected.total); assert.strictEqual(typeof actual.total, 'bigint'); + assert.strictEqual(typeof actual.base, 'bigint'); options = { intDecoding: IntDecoding.MIXED, @@ -93,6 +95,15 @@ describe('client', () => { assert.strictEqual(typeof actual.total, 'bigint'); assert.strictEqual(typeof actual.base, 'number'); + options = { + intDecoding: IntDecoding.UNSAFE, + }; + actual = HTTPClient.parseJSON(j, 200, options); + expected = JSON.parse(j); + assert.strictEqual(actual.total, expected.total); + assert.strictEqual(typeof actual.total, 'number'); + assert.strictEqual(typeof actual.base, 'number'); + options = { intDecoding: IntDecoding.SAFE, }; diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 248c322ee..a0dd24ce9 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -1573,8 +1573,8 @@ module.exports = function getSteps(options) { // them before comparing, which is why we chain encoding/decoding below. if (responseFormat === 'json') { assert.strictEqual( - JSON.stringify(JSON.parse(expectedMockResponse)), - JSON.stringify(this.actualMockResponse) + algosdk.stringifyJSON(algosdk.parseJSON(expectedMockResponse)), + algosdk.stringifyJSON(this.actualMockResponse) ); } else { assert.deepStrictEqual( @@ -1897,7 +1897,10 @@ module.exports = function getSteps(options) { Then( 'the parsed Node Status response should have a last round of {int}', (lastRound) => { - assert.strictEqual(lastRound, anyNodeStatusResponse['last-round']); + assert.strictEqual( + BigInt(lastRound), + anyNodeStatusResponse['last-round'] + ); } ); @@ -1910,9 +1913,15 @@ module.exports = function getSteps(options) { Then( 'the parsed Ledger Supply response should have totalMoney {int} onlineMoney {int} on round {int}', (totalMoney, onlineMoney, round) => { - assert.strictEqual(totalMoney, anyLedgerSupplyResponse['total-money']); - assert.strictEqual(onlineMoney, anyLedgerSupplyResponse['online-money']); - assert.strictEqual(round, anyLedgerSupplyResponse.current_round); + assert.strictEqual( + BigInt(totalMoney), + anyLedgerSupplyResponse['total-money'] + ); + assert.strictEqual( + BigInt(onlineMoney), + anyLedgerSupplyResponse['online-money'] + ); + assert.strictEqual(BigInt(round), anyLedgerSupplyResponse.current_round); } ); @@ -1923,7 +1932,10 @@ module.exports = function getSteps(options) { Then( 'the parsed Status After Block response should have a last round of {int}', (lastRound) => { - assert.strictEqual(lastRound, anyNodeStatusResponse['last-round']); + assert.strictEqual( + BigInt(lastRound), + anyNodeStatusResponse['last-round'] + ); } ); @@ -1970,7 +1982,7 @@ module.exports = function getSteps(options) { 'the parsed Suggested Transaction Parameters response should have first round valid of {int}', (firstValid) => { assert.strictEqual( - firstValid, + BigInt(firstValid), anySuggestedTransactionsResponse.firstValid ); } @@ -2422,7 +2434,6 @@ module.exports = function getSteps(options) { When('we make any LookupAssetBalances call', async function () { anyLookupAssetBalancesResponse = await this.indexerClient .lookupAssetBalances() - .setIntDecoding('mixed') .do(); }); @@ -2430,7 +2441,7 @@ module.exports = function getSteps(options) { 'the parsed LookupAssetBalances response should be valid on round {int}, and contain an array of len {int} and element number {int} should have address {string} amount {int} and frozen state {string}', (round, length, idx, address, amount, frozenStateAsString) => { assert.strictEqual( - round, + BigInt(round), anyLookupAssetBalancesResponse['current-round'] ); assert.strictEqual( @@ -2445,7 +2456,7 @@ module.exports = function getSteps(options) { frozenState = true; } assert.strictEqual( - amount, + BigInt(amount), anyLookupAssetBalancesResponse.balances[idx].amount ); assert.strictEqual( @@ -2512,7 +2523,6 @@ module.exports = function getSteps(options) { When('we make any LookupAssetTransactions call', async function () { anyLookupAssetTransactionsResponse = await this.indexerClient .lookupAssetTransactions() - .setIntDecoding('mixed') .do(); }); @@ -2520,7 +2530,7 @@ module.exports = function getSteps(options) { 'the parsed LookupAssetTransactions response should be valid on round {int}, and contain an array of len {int} and element number {int} should have sender {string}', (round, length, idx, sender) => { assert.strictEqual( - round, + BigInt(round), anyLookupAssetTransactionsResponse['current-round'] ); assert.strictEqual( @@ -2549,7 +2559,7 @@ module.exports = function getSteps(options) { 'the parsed LookupAccountTransactions response should be valid on round {int}, and contain an array of len {int} and element number {int} should have sender {string}', (round, length, idx, sender) => { assert.strictEqual( - round, + BigInt(round), anyLookupAccountTransactionsResponse['current-round'] ); assert.strictEqual( @@ -2602,12 +2612,11 @@ module.exports = function getSteps(options) { When('we make any LookupAssetByID call', async function () { anyLookupAssetByIDResponse = await this.indexerClient .lookupAssetByID() - .setIntDecoding('mixed') .do(); }); Then('the parsed LookupAssetByID response should have index {int}', (idx) => { - assert.strictEqual(idx, anyLookupAssetByIDResponse.asset.index); + assert.strictEqual(BigInt(idx), anyLookupAssetByIDResponse.asset.index); }); let anySearchAccountsResponse; @@ -2619,7 +2628,10 @@ module.exports = function getSteps(options) { Then( 'the parsed SearchAccounts response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have address {string}', (round, length, idx, address) => { - assert.strictEqual(round, anySearchAccountsResponse['current-round']); + assert.strictEqual( + BigInt(round), + anySearchAccountsResponse['current-round'] + ); assert.strictEqual(length, anySearchAccountsResponse.accounts.length); if (length === 0) { return; @@ -2634,7 +2646,10 @@ module.exports = function getSteps(options) { Then( 'the parsed SearchAccounts response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have authorizing address {string}', (round, length, idx, authAddress) => { - assert.strictEqual(round, anySearchAccountsResponse['current-round']); + assert.strictEqual( + BigInt(round), + anySearchAccountsResponse['current-round'] + ); assert.strictEqual(length, anySearchAccountsResponse.accounts.length); if (length === 0) { return; @@ -2658,7 +2673,7 @@ module.exports = function getSteps(options) { 'the parsed SearchForTransactions response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have sender {string}', (round, length, idx, sender) => { assert.strictEqual( - round, + BigInt(round), anySearchForTransactionsResponse['current-round'] ); assert.strictEqual( @@ -2679,7 +2694,7 @@ module.exports = function getSteps(options) { 'the parsed SearchForTransactions response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have rekey-to {string}', (round, length, idx, rekeyTo) => { assert.strictEqual( - round, + BigInt(round), anySearchForTransactionsResponse['current-round'] ); assert.strictEqual( @@ -2707,13 +2722,16 @@ module.exports = function getSteps(options) { Then( 'the parsed SearchForAssets response should be valid on round {int} and the array should be of len {int} and the element at index {int} should have asset index {int}', (round, length, idx, assetIndex) => { - assert.strictEqual(round, anySearchForAssetsResponse['current-round']); + assert.strictEqual( + BigInt(round), + anySearchForAssetsResponse['current-round'] + ); assert.strictEqual(length, anySearchForAssetsResponse.assets.length); if (length === 0) { return; } assert.strictEqual( - assetIndex, + BigInt(assetIndex), anySearchForAssetsResponse.assets[idx].index ); } @@ -2743,7 +2761,15 @@ module.exports = function getSteps(options) { let dryrunResponse; When('we make any Dryrun call', async function () { - const dr = new algosdk.modelsv2.DryrunRequest({}); + const dr = new algosdk.modelsv2.DryrunRequest({ + accounts: [], + apps: [], + latestTimestamp: 0, + protocolVersion: '', + round: 0, + sources: [], + txns: [], + }); dryrunResponse = await this.v2Client.dryrun(dr).do(); }); @@ -2752,8 +2778,8 @@ module.exports = function getSteps(options) { (key, action) => { assert.strictEqual(dryrunResponse.txns[0]['global-delta'][0].key, key); assert.strictEqual( - dryrunResponse.txns[0]['global-delta'][0].value.action, - action + BigInt(action), + dryrunResponse.txns[0]['global-delta'][0].value.action ); } ); diff --git a/tests/mocha.js b/tests/mocha.js index d2202ea72..37b3db40a 100644 --- a/tests/mocha.js +++ b/tests/mocha.js @@ -121,7 +121,7 @@ async function testRunner() { } else { console.log('Testing in Node'); - const mocha = new Mocha(); + const mocha = new Mocha({ diff: false }); testFiles.forEach((file) => mocha.addFile(file)); mocha.run((failures) => {