@algorandfoundation/algokit-utils 10.0.0-alpha.3 → 10.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/packages/abi/src/abi-method.d.ts +1 -1
  3. package/packages/abi/src/abi-method.js.map +1 -1
  4. package/packages/abi/src/abi-method.mjs.map +1 -1
  5. package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
  6. package/packages/algod_client/src/models/application-state-schema.js +2 -2
  7. package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
  8. package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
  9. package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
  10. package/packages/common/src/json.mjs +2 -2
  11. package/packages/common/src/json.mjs.map +1 -1
  12. package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
  13. package/packages/indexer_client/src/models/application-state-schema.js +2 -2
  14. package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
  15. package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
  16. package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
  17. package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
  18. package/packages/indexer_client/src/models/state-schema.js +2 -2
  19. package/packages/indexer_client/src/models/state-schema.js.map +1 -1
  20. package/packages/indexer_client/src/models/state-schema.mjs +2 -2
  21. package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
  22. package/packages/indexer_client/src/models/transaction.d.ts +2 -2
  23. package/packages/indexer_client/src/models/transaction.js +2 -2
  24. package/packages/indexer_client/src/models/transaction.js.map +1 -1
  25. package/packages/indexer_client/src/models/transaction.mjs +2 -2
  26. package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
  27. package/packages/sdk/src/utils/utils.mjs +2 -2
  28. package/packages/sdk/src/utils/utils.mjs.map +1 -1
  29. package/transactions/method-call.js +12 -12
  30. package/transactions/method-call.js.map +1 -1
  31. package/transactions/method-call.mjs +12 -12
  32. package/transactions/method-call.mjs.map +1 -1
  33. package/types/algorand-client-transaction-creator.d.ts +44 -44
  34. package/types/algorand-client-transaction-sender.d.ts +46 -46
  35. package/types/app-client.d.ts +99 -99
  36. package/types/app-factory.d.ts +36 -36
  37. package/types/app-manager.d.ts +1 -1
  38. package/types/app-manager.js +10 -5
  39. package/types/app-manager.js.map +1 -1
  40. package/types/app-manager.mjs +10 -5
  41. package/types/app-manager.mjs.map +1 -1
  42. package/types/composer.js +3 -6
  43. package/types/composer.js.map +1 -1
  44. package/types/composer.mjs +3 -6
  45. package/types/composer.mjs.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","names":["TransactionMeta: ObjectModelMetadata<Transaction>"],"sources":["../../../../../packages/indexer_client/src/models/transaction.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n stringCodec,\n numberCodec,\n bigIntCodec,\n bytesCodec,\n addressCodec,\n ArrayCodec,\n bytesArrayCodec,\n ObjectModelCodec,\n ArrayModelCodec,\n} from '@algorandfoundation/algokit-common'\nimport type { AccountStateDelta } from './account-state-delta'\nimport { AccountStateDeltaMeta } from './account-state-delta'\nimport type { StateDelta } from './state-delta'\nimport { StateDeltaMeta } from './state-delta'\nimport type { TransactionApplication } from './transaction-application'\nimport { TransactionApplicationMeta } from './transaction-application'\nimport type { TransactionAssetConfig } from './transaction-asset-config'\nimport { TransactionAssetConfigMeta } from './transaction-asset-config'\nimport type { TransactionAssetFreeze } from './transaction-asset-freeze'\nimport { TransactionAssetFreezeMeta } from './transaction-asset-freeze'\nimport type { TransactionAssetTransfer } from './transaction-asset-transfer'\nimport { TransactionAssetTransferMeta } from './transaction-asset-transfer'\nimport type { TransactionHeartbeat } from './transaction-heartbeat'\nimport { TransactionHeartbeatMeta } from './transaction-heartbeat'\nimport type { TransactionKeyreg } from './transaction-keyreg'\nimport { TransactionKeyregMeta } from './transaction-keyreg'\nimport type { TransactionPayment } from './transaction-payment'\nimport { TransactionPaymentMeta } from './transaction-payment'\nimport type { TransactionSignature } from './transaction-signature'\nimport { TransactionSignatureMeta } from './transaction-signature'\nimport type { TransactionStateProof } from './transaction-state-proof'\nimport { TransactionStateProofMeta } from './transaction-state-proof'\n\n/**\n * Contains all fields common to all transactions and serves as an envelope to all transactions type. Represents both regular and inner transactions.\n *\n * Definition:\n * data/transactions/signedtxn.go : SignedTxn\n * data/transactions/transaction.go : Transaction\n */\nexport type Transaction = {\n applicationTransaction?: TransactionApplication\n assetConfigTransaction?: TransactionAssetConfig\n assetFreezeTransaction?: TransactionAssetFreeze\n assetTransferTransaction?: TransactionAssetTransfer\n stateProofTransaction?: TransactionStateProof\n heartbeatTransaction?: TransactionHeartbeat\n\n /**\n * \\[sgnr\\] this is included with signed transactions when the signing address does not equal the sender. The backend can use this to ensure that auth addr is equal to the accounts auth addr.\n */\n authAddr?: Address\n\n /**\n * \\[rc\\] rewards applied to close-remainder-to account.\n */\n closeRewards?: bigint\n\n /**\n * \\[ca\\] closing amount for transaction.\n */\n closingAmount?: bigint\n\n /**\n * Round when the transaction was confirmed.\n */\n confirmedRound?: bigint\n\n /**\n * Specifies an application index (ID) if an application was created with this transaction.\n */\n createdAppId?: bigint\n\n /**\n * Specifies an asset index (ID) if an asset was created with this transaction.\n */\n createdAssetId?: bigint\n\n /**\n * \\[fee\\] Transaction fee.\n */\n fee: bigint\n\n /**\n * \\[fv\\] First valid round for this transaction.\n */\n firstValid: number\n\n /**\n * \\[gh\\] Hash of genesis block.\n */\n genesisHash?: Uint8Array\n\n /**\n * \\[gen\\] genesis block ID.\n */\n genesisId?: string\n\n /**\n * \\[grp\\] Base64 encoded byte array of a sha512/256 digest. When present indicates that this transaction is part of a transaction group and the value is the sha512/256 hash of the transactions in that group.\n */\n group?: Uint8Array\n\n /**\n * Transaction ID\n */\n id?: string\n\n /**\n * Offset into the round where this transaction was confirmed.\n */\n intraRoundOffset?: number\n keyregTransaction?: TransactionKeyreg\n\n /**\n * \\[lv\\] Last valid round for this transaction.\n */\n lastValid: number\n\n /**\n * \\[lx\\] Base64 encoded 32-byte array. Lease enforces mutual exclusion of transactions. If this field is nonzero, then once the transaction is confirmed, it acquires the lease identified by the (Sender, Lease) pair of the transaction until the LastValid round passes. While this transaction possesses the lease, no other transaction specifying this lease can be confirmed.\n */\n lease?: Uint8Array\n\n /**\n * \\[note\\] Free form data.\n */\n note?: Uint8Array\n paymentTransaction?: TransactionPayment\n\n /**\n * \\[rr\\] rewards applied to receiver account.\n */\n receiverRewards?: bigint\n\n /**\n * \\[rekey\\] when included in a valid transaction, the accounts auth addr will be updated with this value and future signatures must be signed with the key represented by this address.\n */\n rekeyTo?: Address\n\n /**\n * Time when the block this transaction is in was confirmed.\n */\n roundTime?: number\n\n /**\n * \\[snd\\] Sender's address.\n */\n sender: string\n\n /**\n * \\[rs\\] rewards applied to sender account.\n */\n senderRewards?: bigint\n signature?: TransactionSignature\n\n /**\n * \\[type\\] Indicates what type of transaction this is. Different types have different fields.\n *\n * Valid types, and where their fields are stored:\n * * \\[pay\\] payment-transaction\n * * \\[keyreg\\] keyreg-transaction\n * * \\[acfg\\] asset-config-transaction\n * * \\[axfer\\] asset-transfer-transaction\n * * \\[afrz\\] asset-freeze-transaction\n * * \\[appl\\] application-transaction\n * * \\[stpf\\] state-proof-transaction\n * * \\[hb\\] heartbeat-transaction\n */\n txType: 'pay' | 'keyreg' | 'acfg' | 'axfer' | 'afrz' | 'appl' | 'stpf' | 'hb'\n\n /**\n * \\[ld\\] Local state key/value changes for the application being executed by this transaction.\n */\n localStateDelta?: AccountStateDelta[]\n globalStateDelta?: StateDelta\n\n /**\n * \\[lg\\] Logs for the application being executed by this transaction.\n */\n logs?: Uint8Array[]\n\n /**\n * Inner transactions produced by application execution.\n */\n innerTxns?: Transaction[]\n}\n\nexport const TransactionMeta: ObjectModelMetadata<Transaction> = {\n name: 'Transaction',\n kind: 'object',\n fields: [\n {\n name: 'applicationTransaction',\n wireKey: 'application-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionApplicationMeta),\n },\n {\n name: 'assetConfigTransaction',\n wireKey: 'asset-config-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetConfigMeta),\n },\n {\n name: 'assetFreezeTransaction',\n wireKey: 'asset-freeze-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetFreezeMeta),\n },\n {\n name: 'assetTransferTransaction',\n wireKey: 'asset-transfer-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetTransferMeta),\n },\n {\n name: 'stateProofTransaction',\n wireKey: 'state-proof-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionStateProofMeta),\n },\n {\n name: 'heartbeatTransaction',\n wireKey: 'heartbeat-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionHeartbeatMeta),\n },\n {\n name: 'authAddr',\n wireKey: 'auth-addr',\n optional: true,\n codec: addressCodec,\n },\n {\n name: 'closeRewards',\n wireKey: 'close-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'closingAmount',\n wireKey: 'closing-amount',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'confirmedRound',\n wireKey: 'confirmed-round',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'createdAppId',\n wireKey: 'created-application-index',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'createdAssetId',\n wireKey: 'created-asset-index',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'fee',\n wireKey: 'fee',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'firstValid',\n wireKey: 'first-valid',\n optional: false,\n codec: numberCodec,\n },\n {\n name: 'genesisHash',\n wireKey: 'genesis-hash',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'genesisId',\n wireKey: 'genesis-id',\n optional: true,\n codec: stringCodec,\n },\n {\n name: 'group',\n wireKey: 'group',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'id',\n wireKey: 'id',\n optional: true,\n codec: stringCodec,\n },\n {\n name: 'intraRoundOffset',\n wireKey: 'intra-round-offset',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'keyregTransaction',\n wireKey: 'keyreg-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionKeyregMeta),\n },\n {\n name: 'lastValid',\n wireKey: 'last-valid',\n optional: false,\n codec: numberCodec,\n },\n {\n name: 'lease',\n wireKey: 'lease',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'note',\n wireKey: 'note',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'paymentTransaction',\n wireKey: 'payment-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionPaymentMeta),\n },\n {\n name: 'receiverRewards',\n wireKey: 'receiver-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'rekeyTo',\n wireKey: 'rekey-to',\n optional: true,\n codec: addressCodec,\n },\n {\n name: 'roundTime',\n wireKey: 'round-time',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'sender',\n wireKey: 'sender',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'senderRewards',\n wireKey: 'sender-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'signature',\n wireKey: 'signature',\n optional: true,\n codec: new ObjectModelCodec(TransactionSignatureMeta),\n },\n {\n name: 'txType',\n wireKey: 'tx-type',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'localStateDelta',\n wireKey: 'local-state-delta',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(AccountStateDeltaMeta)),\n },\n {\n name: 'globalStateDelta',\n wireKey: 'global-state-delta',\n optional: true,\n codec: new ArrayModelCodec(StateDeltaMeta),\n },\n {\n name: 'logs',\n wireKey: 'logs',\n optional: true,\n codec: bytesArrayCodec,\n },\n {\n name: 'innerTxns',\n wireKey: 'inner-txns',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(() => TransactionMeta)),\n },\n ],\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8LA,MAAaA,kBAAoD;CAC/D,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,6BAA6B;GAC1D;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,0BAA0B;GACvD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,yBAAyB;GACtD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,sBAAsB;GACnD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,uBAAuB;GACpD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,yBAAyB;GACtD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,sBAAsB,CAAC;GACnE;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,gBAAgB,eAAe;GAC3C;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,uBAAuB,gBAAgB,CAAC;GACnE;EACF;CACF"}
1
+ {"version":3,"file":"transaction.mjs","names":["TransactionMeta: ObjectModelMetadata<Transaction>"],"sources":["../../../../../packages/indexer_client/src/models/transaction.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n stringCodec,\n numberCodec,\n bigIntCodec,\n bytesCodec,\n addressCodec,\n ArrayCodec,\n bytesArrayCodec,\n ObjectModelCodec,\n ArrayModelCodec,\n} from '@algorandfoundation/algokit-common'\nimport type { AccountStateDelta } from './account-state-delta'\nimport { AccountStateDeltaMeta } from './account-state-delta'\nimport type { StateDelta } from './state-delta'\nimport { StateDeltaMeta } from './state-delta'\nimport type { TransactionApplication } from './transaction-application'\nimport { TransactionApplicationMeta } from './transaction-application'\nimport type { TransactionAssetConfig } from './transaction-asset-config'\nimport { TransactionAssetConfigMeta } from './transaction-asset-config'\nimport type { TransactionAssetFreeze } from './transaction-asset-freeze'\nimport { TransactionAssetFreezeMeta } from './transaction-asset-freeze'\nimport type { TransactionAssetTransfer } from './transaction-asset-transfer'\nimport { TransactionAssetTransferMeta } from './transaction-asset-transfer'\nimport type { TransactionHeartbeat } from './transaction-heartbeat'\nimport { TransactionHeartbeatMeta } from './transaction-heartbeat'\nimport type { TransactionKeyreg } from './transaction-keyreg'\nimport { TransactionKeyregMeta } from './transaction-keyreg'\nimport type { TransactionPayment } from './transaction-payment'\nimport { TransactionPaymentMeta } from './transaction-payment'\nimport type { TransactionSignature } from './transaction-signature'\nimport { TransactionSignatureMeta } from './transaction-signature'\nimport type { TransactionStateProof } from './transaction-state-proof'\nimport { TransactionStateProofMeta } from './transaction-state-proof'\n\n/**\n * Contains all fields common to all transactions and serves as an envelope to all transactions type. Represents both regular and inner transactions.\n *\n * Definition:\n * data/transactions/signedtxn.go : SignedTxn\n * data/transactions/transaction.go : Transaction\n */\nexport type Transaction = {\n applicationTransaction?: TransactionApplication\n assetConfigTransaction?: TransactionAssetConfig\n assetFreezeTransaction?: TransactionAssetFreeze\n assetTransferTransaction?: TransactionAssetTransfer\n stateProofTransaction?: TransactionStateProof\n heartbeatTransaction?: TransactionHeartbeat\n\n /**\n * \\[sgnr\\] this is included with signed transactions when the signing address does not equal the sender. The backend can use this to ensure that auth addr is equal to the accounts auth addr.\n */\n authAddr?: Address\n\n /**\n * \\[rc\\] rewards applied to close-remainder-to account.\n */\n closeRewards?: bigint\n\n /**\n * \\[ca\\] closing amount for transaction.\n */\n closingAmount?: bigint\n\n /**\n * Round when the transaction was confirmed.\n */\n confirmedRound?: bigint\n\n /**\n * Specifies an application index (ID) if an application was created with this transaction.\n */\n createdAppId?: bigint\n\n /**\n * Specifies an asset index (ID) if an asset was created with this transaction.\n */\n createdAssetId?: bigint\n\n /**\n * \\[fee\\] Transaction fee.\n */\n fee: bigint\n\n /**\n * \\[fv\\] First valid round for this transaction.\n */\n firstValid: bigint\n\n /**\n * \\[gh\\] Hash of genesis block.\n */\n genesisHash?: Uint8Array\n\n /**\n * \\[gen\\] genesis block ID.\n */\n genesisId?: string\n\n /**\n * \\[grp\\] Base64 encoded byte array of a sha512/256 digest. When present indicates that this transaction is part of a transaction group and the value is the sha512/256 hash of the transactions in that group.\n */\n group?: Uint8Array\n\n /**\n * Transaction ID\n */\n id?: string\n\n /**\n * Offset into the round where this transaction was confirmed.\n */\n intraRoundOffset?: number\n keyregTransaction?: TransactionKeyreg\n\n /**\n * \\[lv\\] Last valid round for this transaction.\n */\n lastValid: bigint\n\n /**\n * \\[lx\\] Base64 encoded 32-byte array. Lease enforces mutual exclusion of transactions. If this field is nonzero, then once the transaction is confirmed, it acquires the lease identified by the (Sender, Lease) pair of the transaction until the LastValid round passes. While this transaction possesses the lease, no other transaction specifying this lease can be confirmed.\n */\n lease?: Uint8Array\n\n /**\n * \\[note\\] Free form data.\n */\n note?: Uint8Array\n paymentTransaction?: TransactionPayment\n\n /**\n * \\[rr\\] rewards applied to receiver account.\n */\n receiverRewards?: bigint\n\n /**\n * \\[rekey\\] when included in a valid transaction, the accounts auth addr will be updated with this value and future signatures must be signed with the key represented by this address.\n */\n rekeyTo?: Address\n\n /**\n * Time when the block this transaction is in was confirmed.\n */\n roundTime?: number\n\n /**\n * \\[snd\\] Sender's address.\n */\n sender: string\n\n /**\n * \\[rs\\] rewards applied to sender account.\n */\n senderRewards?: bigint\n signature?: TransactionSignature\n\n /**\n * \\[type\\] Indicates what type of transaction this is. Different types have different fields.\n *\n * Valid types, and where their fields are stored:\n * * \\[pay\\] payment-transaction\n * * \\[keyreg\\] keyreg-transaction\n * * \\[acfg\\] asset-config-transaction\n * * \\[axfer\\] asset-transfer-transaction\n * * \\[afrz\\] asset-freeze-transaction\n * * \\[appl\\] application-transaction\n * * \\[stpf\\] state-proof-transaction\n * * \\[hb\\] heartbeat-transaction\n */\n txType: 'pay' | 'keyreg' | 'acfg' | 'axfer' | 'afrz' | 'appl' | 'stpf' | 'hb'\n\n /**\n * \\[ld\\] Local state key/value changes for the application being executed by this transaction.\n */\n localStateDelta?: AccountStateDelta[]\n globalStateDelta?: StateDelta\n\n /**\n * \\[lg\\] Logs for the application being executed by this transaction.\n */\n logs?: Uint8Array[]\n\n /**\n * Inner transactions produced by application execution.\n */\n innerTxns?: Transaction[]\n}\n\nexport const TransactionMeta: ObjectModelMetadata<Transaction> = {\n name: 'Transaction',\n kind: 'object',\n fields: [\n {\n name: 'applicationTransaction',\n wireKey: 'application-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionApplicationMeta),\n },\n {\n name: 'assetConfigTransaction',\n wireKey: 'asset-config-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetConfigMeta),\n },\n {\n name: 'assetFreezeTransaction',\n wireKey: 'asset-freeze-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetFreezeMeta),\n },\n {\n name: 'assetTransferTransaction',\n wireKey: 'asset-transfer-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionAssetTransferMeta),\n },\n {\n name: 'stateProofTransaction',\n wireKey: 'state-proof-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionStateProofMeta),\n },\n {\n name: 'heartbeatTransaction',\n wireKey: 'heartbeat-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionHeartbeatMeta),\n },\n {\n name: 'authAddr',\n wireKey: 'auth-addr',\n optional: true,\n codec: addressCodec,\n },\n {\n name: 'closeRewards',\n wireKey: 'close-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'closingAmount',\n wireKey: 'closing-amount',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'confirmedRound',\n wireKey: 'confirmed-round',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'createdAppId',\n wireKey: 'created-application-index',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'createdAssetId',\n wireKey: 'created-asset-index',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'fee',\n wireKey: 'fee',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'firstValid',\n wireKey: 'first-valid',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'genesisHash',\n wireKey: 'genesis-hash',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'genesisId',\n wireKey: 'genesis-id',\n optional: true,\n codec: stringCodec,\n },\n {\n name: 'group',\n wireKey: 'group',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'id',\n wireKey: 'id',\n optional: true,\n codec: stringCodec,\n },\n {\n name: 'intraRoundOffset',\n wireKey: 'intra-round-offset',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'keyregTransaction',\n wireKey: 'keyreg-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionKeyregMeta),\n },\n {\n name: 'lastValid',\n wireKey: 'last-valid',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'lease',\n wireKey: 'lease',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'note',\n wireKey: 'note',\n optional: true,\n codec: bytesCodec,\n },\n {\n name: 'paymentTransaction',\n wireKey: 'payment-transaction',\n optional: true,\n codec: new ObjectModelCodec(TransactionPaymentMeta),\n },\n {\n name: 'receiverRewards',\n wireKey: 'receiver-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'rekeyTo',\n wireKey: 'rekey-to',\n optional: true,\n codec: addressCodec,\n },\n {\n name: 'roundTime',\n wireKey: 'round-time',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'sender',\n wireKey: 'sender',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'senderRewards',\n wireKey: 'sender-rewards',\n optional: true,\n codec: bigIntCodec,\n },\n {\n name: 'signature',\n wireKey: 'signature',\n optional: true,\n codec: new ObjectModelCodec(TransactionSignatureMeta),\n },\n {\n name: 'txType',\n wireKey: 'tx-type',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'localStateDelta',\n wireKey: 'local-state-delta',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(AccountStateDeltaMeta)),\n },\n {\n name: 'globalStateDelta',\n wireKey: 'global-state-delta',\n optional: true,\n codec: new ArrayModelCodec(StateDeltaMeta),\n },\n {\n name: 'logs',\n wireKey: 'logs',\n optional: true,\n codec: bytesArrayCodec,\n },\n {\n name: 'innerTxns',\n wireKey: 'inner-txns',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(() => TransactionMeta)),\n },\n ],\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8LA,MAAaA,kBAAoD;CAC/D,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,2BAA2B;GACxD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,6BAA6B;GAC1D;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,0BAA0B;GACvD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,yBAAyB;GACtD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,sBAAsB;GACnD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,uBAAuB;GACpD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,yBAAyB;GACtD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,sBAAsB,CAAC;GACnE;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,gBAAgB,eAAe;GAC3C;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,uBAAuB,gBAAgB,CAAC;GACnE;EACF;CACF"}
@@ -1,8 +1,8 @@
1
1
  import intDecoding_default from "../types/intDecoding.mjs";
2
- import JSONbigWithoutConfig from "json-bigint";
2
+ import JSONbigFactory from "json-bigint";
3
3
 
4
4
  //#region packages/sdk/src/utils/utils.ts
5
- const JSONbig = JSONbigWithoutConfig({
5
+ const JSONbig = JSONbigFactory({
6
6
  useNativeBigInt: true,
7
7
  strict: true
8
8
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["IntDecoding"],"sources":["../../../../../packages/sdk/src/utils/utils.ts"],"sourcesContent":["import JSONbigWithoutConfig from 'json-bigint'\nimport IntDecoding from '../types/intDecoding.js'\n\nconst JSONbig = JSONbigWithoutConfig({\n useNativeBigInt: true,\n strict: true,\n})\n\nexport interface ParseJSONOptions {\n intDecoding: IntDecoding\n}\n\n/**\n * Parse JSON with additional options.\n * @param str - The JSON string to parse.\n * @param options - Configures how integers in this JSON string will be decoded. See the\n * `IntDecoding` enum for more details.\n */\nexport function parseJSON(str: string, { intDecoding }: ParseJSONOptions) {\n if (\n intDecoding !== IntDecoding.SAFE &&\n intDecoding !== IntDecoding.UNSAFE &&\n intDecoding !== IntDecoding.BIGINT &&\n intDecoding !== IntDecoding.MIXED\n ) {\n throw new Error(`Invalid intDecoding option: ${intDecoding}`)\n }\n return JSONbig.parse(str, (_: string, value: any): any => {\n if (value != null && typeof value === 'object' && Object.getPrototypeOf(value) == null) {\n // JSONbig.parse objects are created with Object.create(null) and thus have a null prototype\n // let us remedy that\n Object.setPrototypeOf(value, Object.prototype)\n }\n\n if (typeof value === 'bigint') {\n if (intDecoding === IntDecoding.SAFE && value > Number.MAX_SAFE_INTEGER) {\n throw new Error(`Integer exceeds maximum safe integer: ${value.toString()}. Try parsing with a different intDecoding option.`)\n }\n if (intDecoding === IntDecoding.BIGINT || (intDecoding === IntDecoding.MIXED && value > Number.MAX_SAFE_INTEGER)) {\n return value\n }\n // JSONbig.parse converts number to BigInts if they are >= 10**15. This is smaller than\n // Number.MAX_SAFE_INTEGER, so we can convert some BigInts back to normal numbers.\n return Number(value)\n }\n\n if (typeof value === 'number') {\n if (intDecoding === IntDecoding.BIGINT && Number.isInteger(value)) {\n return BigInt(value)\n }\n }\n\n return value\n })\n}\n\n/**\n * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.\n *\n * This functions differs from the built-in JSON.stringify in that it supports serializing BigInts.\n *\n * This function takes the same arguments as the built-in JSON.stringify function.\n *\n * @param value - A JavaScript value, usually an object or array, to be converted.\n * @param replacer - A function that transforms the results.\n * @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.\n */\nexport function stringifyJSON(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string {\n return JSONbig.stringify(value, replacer, space)\n}\n\n/**\n * ArrayEqual takes two arrays and return true if equal, false otherwise\n */\nexport function arrayEqual<T>(a: ArrayLike<T>, b: ArrayLike<T>): boolean {\n if (a.length !== b.length) {\n return false\n }\n return Array.from(a).every((val, i) => val === b[i])\n}\n\n/**\n * ConcatArrays takes n number arrays and returns a joint Uint8Array\n * @param arrs - An arbitrary number of n array-like number list arguments\n * @returns [a,b]\n */\nexport function concatArrays(...arrs: ArrayLike<number>[]) {\n const size = arrs.reduce((sum, arr) => sum + arr.length, 0)\n const c = new Uint8Array(size)\n\n let offset = 0\n for (let i = 0; i < arrs.length; i++) {\n c.set(arrs[i], offset)\n offset += arrs[i].length\n }\n\n return c\n}\n\n/**\n * Remove undefined properties from an object\n * @param obj - An object, preferably one with some undefined properties\n * @returns A copy of the object with undefined properties removed\n */\nexport function removeUndefinedProperties(obj: Record<string | number | symbol, any>) {\n const mutableCopy = { ...obj }\n Object.keys(mutableCopy).forEach((key) => {\n if (typeof mutableCopy[key] === 'undefined') delete mutableCopy[key]\n })\n return mutableCopy\n}\n\n/**\n * Check whether the environment is Node.js (as opposed to the browser)\n * @returns True if Node.js environment, false otherwise\n */\nexport function isNode() {\n return (\n // @ts-ignore\n typeof process === 'object' &&\n // @ts-ignore\n typeof process.versions === 'object' &&\n // @ts-ignore\n typeof process.versions.node !== 'undefined'\n )\n}\n\n/**\n * Check whether the environment is ReactNative\n * @returns True if ReactNative, false otherwise\n */\nexport function isReactNative() {\n const { navigator } = globalThis as { navigator?: { product?: string } }\n if (typeof navigator === 'object' && navigator.product === 'ReactNative') {\n return true\n }\n return false\n}\n\nexport function ensureSafeInteger(value: unknown): number {\n if (typeof value === 'undefined') {\n throw new Error('Value is undefined')\n }\n if (typeof value === 'bigint') {\n if (value > BigInt(Number.MAX_SAFE_INTEGER) || value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new Error(`BigInt value ${value} is not a safe integer`)\n }\n return Number(value)\n }\n if (typeof value === 'number') {\n if (Number.isSafeInteger(value)) {\n return value\n }\n throw new Error(`Value ${value} is not a safe integer`)\n }\n throw new Error(`Unexpected type ${typeof value}, ${value}`)\n}\n\nexport function ensureSafeUnsignedInteger(value: unknown): number {\n const intValue = ensureSafeInteger(value)\n if (intValue < 0) {\n throw new Error(`Value ${intValue} is negative`)\n }\n return intValue\n}\n\nexport function ensureBigInt(value: unknown): bigint {\n if (typeof value === 'undefined') {\n throw new Error('Value is undefined')\n }\n if (typeof value === 'bigint') {\n return value\n }\n if (typeof value === 'number') {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Value ${value} is not a safe integer`)\n }\n return BigInt(value)\n }\n throw new Error(`Unexpected type ${typeof value}, ${value}`)\n}\n\nexport function ensureUint64(value: unknown): bigint {\n const bigIntValue = ensureBigInt(value)\n if (bigIntValue < 0 || bigIntValue > BigInt('0xffffffffffffffff')) {\n throw new Error(`Value ${bigIntValue} is not a uint64`)\n }\n return bigIntValue\n}\n"],"mappings":";;;;AAGA,MAAM,UAAU,qBAAqB;CACnC,iBAAiB;CACjB,QAAQ;CACT,CAAC;;;;;;;AAYF,SAAgB,UAAU,KAAa,EAAE,eAAiC;AACxE,KACE,gBAAgBA,oBAAY,QAC5B,gBAAgBA,oBAAY,UAC5B,gBAAgBA,oBAAY,UAC5B,gBAAgBA,oBAAY,MAE5B,OAAM,IAAI,MAAM,+BAA+B,cAAc;AAE/D,QAAO,QAAQ,MAAM,MAAM,GAAW,UAAoB;AACxD,MAAI,SAAS,QAAQ,OAAO,UAAU,YAAY,OAAO,eAAe,MAAM,IAAI,KAGhF,QAAO,eAAe,OAAO,OAAO,UAAU;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC7B,OAAI,gBAAgBA,oBAAY,QAAQ,QAAQ,OAAO,iBACrD,OAAM,IAAI,MAAM,yCAAyC,MAAM,UAAU,CAAC,oDAAoD;AAEhI,OAAI,gBAAgBA,oBAAY,UAAW,gBAAgBA,oBAAY,SAAS,QAAQ,OAAO,iBAC7F,QAAO;AAIT,UAAO,OAAO,MAAM;;AAGtB,MAAI,OAAO,UAAU,UACnB;OAAI,gBAAgBA,oBAAY,UAAU,OAAO,UAAU,MAAM,CAC/D,QAAO,OAAO,MAAM;;AAIxB,SAAO;GACP;;;;;;;;;;;;;AAcJ,SAAgB,cAAc,OAAY,UAAwD,OAAiC;AACjI,QAAO,QAAQ,UAAU,OAAO,UAAU,MAAM;;;;;AAMlD,SAAgB,WAAc,GAAiB,GAA0B;AACvE,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,QAAO,MAAM,KAAK,EAAE,CAAC,O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AW,kBAAkB,MAAM;AACzC,KAAI,WAAW,EACb,OAAM,IAAI,MAAM,SAAS,SAAS,cAAc;AAElD,QAAO;;AAGT,SAAgB,aAAa,OAAwB;AACnD,KAAI,OAAO,UAAU,YACnB,OAAM,IAAI,MAAM,qBAAqB;AAEvC,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,OAAO,cAAc,MAAM,CAC9B,OAAM,IAAI,MAAM,SAAS,MAAM,wBAAwB;AAEzD,SAAO,OAAO,MAAM;;AAEtB,OAAM,IAAI,MAAM,mBAAmB,OAAO,MAAM,IAAI,QAAQ;;AAG9D,SAAgB,aAAa,OAAwB;CACnD,MAAM,cAAc,aAAa,MAAM;AACvC,KAAI,cAAc,KAAK,cAAc,OAAO,qBAAqB,CAC/D,OAAM,IAAI,MAAM,SAAS,YAAY,kBAAkB;AAEzD,QAAO"}
1
+ {"version":3,"file":"utils.mjs","names":["JSONbigWithoutConfig","IntDecoding"],"sources":["../../../../../packages/sdk/src/utils/utils.ts"],"sourcesContent":["import JSONbigWithoutConfig from 'json-bigint'\nimport IntDecoding from '../types/intDecoding.js'\n\nconst JSONbig = JSONbigWithoutConfig({\n useNativeBigInt: true,\n strict: true,\n})\n\nexport interface ParseJSONOptions {\n intDecoding: IntDecoding\n}\n\n/**\n * Parse JSON with additional options.\n * @param str - The JSON string to parse.\n * @param options - Configures how integers in this JSON string will be decoded. See the\n * `IntDecoding` enum for more details.\n */\nexport function parseJSON(str: string, { intDecoding }: ParseJSONOptions) {\n if (\n intDecoding !== IntDecoding.SAFE &&\n intDecoding !== IntDecoding.UNSAFE &&\n intDecoding !== IntDecoding.BIGINT &&\n intDecoding !== IntDecoding.MIXED\n ) {\n throw new Error(`Invalid intDecoding option: ${intDecoding}`)\n }\n return JSONbig.parse(str, (_: string, value: any): any => {\n if (value != null && typeof value === 'object' && Object.getPrototypeOf(value) == null) {\n // JSONbig.parse objects are created with Object.create(null) and thus have a null prototype\n // let us remedy that\n Object.setPrototypeOf(value, Object.prototype)\n }\n\n if (typeof value === 'bigint') {\n if (intDecoding === IntDecoding.SAFE && value > Number.MAX_SAFE_INTEGER) {\n throw new Error(`Integer exceeds maximum safe integer: ${value.toString()}. Try parsing with a different intDecoding option.`)\n }\n if (intDecoding === IntDecoding.BIGINT || (intDecoding === IntDecoding.MIXED && value > Number.MAX_SAFE_INTEGER)) {\n return value\n }\n // JSONbig.parse converts number to BigInts if they are >= 10**15. This is smaller than\n // Number.MAX_SAFE_INTEGER, so we can convert some BigInts back to normal numbers.\n return Number(value)\n }\n\n if (typeof value === 'number') {\n if (intDecoding === IntDecoding.BIGINT && Number.isInteger(value)) {\n return BigInt(value)\n }\n }\n\n return value\n })\n}\n\n/**\n * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.\n *\n * This functions differs from the built-in JSON.stringify in that it supports serializing BigInts.\n *\n * This function takes the same arguments as the built-in JSON.stringify function.\n *\n * @param value - A JavaScript value, usually an object or array, to be converted.\n * @param replacer - A function that transforms the results.\n * @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.\n */\nexport function stringifyJSON(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string {\n return JSONbig.stringify(value, replacer, space)\n}\n\n/**\n * ArrayEqual takes two arrays and return true if equal, false otherwise\n */\nexport function arrayEqual<T>(a: ArrayLike<T>, b: ArrayLike<T>): boolean {\n if (a.length !== b.length) {\n return false\n }\n return Array.from(a).every((val, i) => val === b[i])\n}\n\n/**\n * ConcatArrays takes n number arrays and returns a joint Uint8Array\n * @param arrs - An arbitrary number of n array-like number list arguments\n * @returns [a,b]\n */\nexport function concatArrays(...arrs: ArrayLike<number>[]) {\n const size = arrs.reduce((sum, arr) => sum + arr.length, 0)\n const c = new Uint8Array(size)\n\n let offset = 0\n for (let i = 0; i < arrs.length; i++) {\n c.set(arrs[i], offset)\n offset += arrs[i].length\n }\n\n return c\n}\n\n/**\n * Remove undefined properties from an object\n * @param obj - An object, preferably one with some undefined properties\n * @returns A copy of the object with undefined properties removed\n */\nexport function removeUndefinedProperties(obj: Record<string | number | symbol, any>) {\n const mutableCopy = { ...obj }\n Object.keys(mutableCopy).forEach((key) => {\n if (typeof mutableCopy[key] === 'undefined') delete mutableCopy[key]\n })\n return mutableCopy\n}\n\n/**\n * Check whether the environment is Node.js (as opposed to the browser)\n * @returns True if Node.js environment, false otherwise\n */\nexport function isNode() {\n return (\n // @ts-ignore\n typeof process === 'object' &&\n // @ts-ignore\n typeof process.versions === 'object' &&\n // @ts-ignore\n typeof process.versions.node !== 'undefined'\n )\n}\n\n/**\n * Check whether the environment is ReactNative\n * @returns True if ReactNative, false otherwise\n */\nexport function isReactNative() {\n const { navigator } = globalThis as { navigator?: { product?: string } }\n if (typeof navigator === 'object' && navigator.product === 'ReactNative') {\n return true\n }\n return false\n}\n\nexport function ensureSafeInteger(value: unknown): number {\n if (typeof value === 'undefined') {\n throw new Error('Value is undefined')\n }\n if (typeof value === 'bigint') {\n if (value > BigInt(Number.MAX_SAFE_INTEGER) || value < BigInt(Number.MIN_SAFE_INTEGER)) {\n throw new Error(`BigInt value ${value} is not a safe integer`)\n }\n return Number(value)\n }\n if (typeof value === 'number') {\n if (Number.isSafeInteger(value)) {\n return value\n }\n throw new Error(`Value ${value} is not a safe integer`)\n }\n throw new Error(`Unexpected type ${typeof value}, ${value}`)\n}\n\nexport function ensureSafeUnsignedInteger(value: unknown): number {\n const intValue = ensureSafeInteger(value)\n if (intValue < 0) {\n throw new Error(`Value ${intValue} is negative`)\n }\n return intValue\n}\n\nexport function ensureBigInt(value: unknown): bigint {\n if (typeof value === 'undefined') {\n throw new Error('Value is undefined')\n }\n if (typeof value === 'bigint') {\n return value\n }\n if (typeof value === 'number') {\n if (!Number.isSafeInteger(value)) {\n throw new Error(`Value ${value} is not a safe integer`)\n }\n return BigInt(value)\n }\n throw new Error(`Unexpected type ${typeof value}, ${value}`)\n}\n\nexport function ensureUint64(value: unknown): bigint {\n const bigIntValue = ensureBigInt(value)\n if (bigIntValue < 0 || bigIntValue > BigInt('0xffffffffffffffff')) {\n throw new Error(`Value ${bigIntValue} is not a uint64`)\n }\n return bigIntValue\n}\n"],"mappings":";;;;AAGA,MAAM,UAAUA,eAAqB;CACnC,iBAAiB;CACjB,QAAQ;CACT,CAAC;;;;;;;AAYF,SAAgB,UAAU,KAAa,EAAE,eAAiC;AACxE,KACE,gBAAgBC,oBAAY,QAC5B,gBAAgBA,oBAAY,UAC5B,gBAAgBA,oBAAY,UAC5B,gBAAgBA,oBAAY,MAE5B,OAAM,IAAI,MAAM,+BAA+B,cAAc;AAE/D,QAAO,QAAQ,MAAM,MAAM,GAAW,UAAoB;AACxD,MAAI,SAAS,QAAQ,OAAO,UAAU,YAAY,OAAO,eAAe,MAAM,IAAI,KAGhF,QAAO,eAAe,OAAO,OAAO,UAAU;AAGhD,MAAI,OAAO,UAAU,UAAU;AAC7B,OAAI,gBAAgBA,oBAAY,QAAQ,QAAQ,OAAO,iBACrD,OAAM,IAAI,MAAM,yCAAyC,MAAM,UAAU,CAAC,oDAAoD;AAEhI,OAAI,gBAAgBA,oBAAY,UAAW,gBAAgBA,oBAAY,SAAS,QAAQ,OAAO,iBAC7F,QAAO;AAIT,UAAO,OAAO,MAAM;;AAGtB,MAAI,OAAO,UAAU,UACnB;OAAI,gBAAgBA,oBAAY,UAAU,OAAO,UAAU,MAAM,CAC/D,QAAO,OAAO,MAAM;;AAIxB,SAAO;GACP;;;;;;;;;;;;;AAcJ,SAAgB,cAAc,OAAY,UAAwD,OAAiC;AACjI,QAAO,QAAQ,UAAU,OAAO,UAAU,MAAM;;;;;AAMlD,SAAgB,WAAc,GAAiB,GAA0B;AACvE,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,QAAO,MAAM,KAAK,EAAE,CAAC,OAAO,KAAK,MAAM,QAAQ,EAAE,GAAG;;;;;;;AAQtD,SAAgB,aAAa,GAAG,MAA2B;CACzD,MAAM,OAAO,KAAK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gB,aAAa,OAAwB;AACnD,KAAI,OAAO,UAAU,YACnB,OAAM,IAAI,MAAM,qBAAqB;AAEvC,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,OAAO,cAAc,MAAM,CAC9B,OAAM,IAAI,MAAM,SAAS,MAAM,wBAAwB;AAEzD,SAAO,OAAO,MAAM;;AAEtB,OAAM,IAAI,MAAM,mBAAmB,OAAO,MAAM,IAAI,QAAQ;;AAG9D,SAAgB,aAAa,OAAwB;CACnD,MAAM,cAAc,aAAa,MAAM;AACvC,KAAI,cAAc,KAAK,cAAc,OAAO,qBAAqB,CAC/D,OAAM,IAAI,MAAM,SAAS,YAAY,kBAAkB;AAEzD,QAAO"}
@@ -85,9 +85,9 @@ const isAbiValue = (x) => {
85
85
  * Populate reference arrays from processed ABI method call arguments
86
86
  */
87
87
  function populateMethodArgsIntoReferenceArrays(sender, appId, method, methodArgs, accountReferences, appReferences, assetReferences) {
88
- const accounts = accountReferences ?? [];
89
- const assets = assetReferences ?? [];
90
- const apps = appReferences ?? [];
88
+ const accounts = [...accountReferences ?? []];
89
+ const assets = [...assetReferences ?? []];
90
+ const apps = [...appReferences ?? []];
91
91
  methodArgs.forEach((arg, i) => {
92
92
  const argType = method.args[i].type;
93
93
  if (require_abi_method.argTypeIsReference(argType)) switch (argType) {
@@ -245,9 +245,9 @@ const buildAppCreateMethodCall = async (params, appManager, suggestedParams, def
245
245
  extraProgramPages,
246
246
  args: common.args,
247
247
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
248
- accountReferences: params.accountReferences?.map((a) => require_address.getAddress(a)),
249
- appReferences: params.appReferences,
250
- assetReferences: params.assetReferences,
248
+ accountReferences: common.accountReferences,
249
+ appReferences: common.appReferences,
250
+ assetReferences: common.assetReferences,
251
251
  boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
252
252
  },
253
253
  rejectVersion: params.rejectVersion
@@ -278,9 +278,9 @@ const buildAppUpdateMethodCall = async (params, appManager, suggestedParams, def
278
278
  clearStateProgram,
279
279
  args: common.args,
280
280
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
281
- accountReferences: params.accountReferences?.map((a) => require_address.getAddress(a)),
282
- appReferences: params.appReferences,
283
- assetReferences: params.assetReferences,
281
+ accountReferences: common.accountReferences,
282
+ appReferences: common.appReferences,
283
+ assetReferences: common.assetReferences,
284
284
  boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
285
285
  },
286
286
  rejectVersion: params.rejectVersion
@@ -307,9 +307,9 @@ const buildAppCallMethodCall = async (params, suggestedParams, defaultValidityWi
307
307
  onComplete: params.onComplete ?? require_app_call.OnApplicationComplete.NoOp,
308
308
  args: common.args,
309
309
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
310
- accountReferences: params.accountReferences?.map((a) => require_address.getAddress(a)),
311
- appReferences: params.appReferences,
312
- assetReferences: params.assetReferences,
310
+ accountReferences: common.accountReferences,
311
+ appReferences: common.appReferences,
312
+ assetReferences: common.assetReferences,
313
313
  boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
314
314
  },
315
315
  rejectVersion: params.rejectVersion
@@ -1 +1 @@
1
- {"version":3,"file":"method-call.js","names":["Address","argTypeIsReference","getAddress","argTypeIsTransaction","ABIUintType","encodedArgs: Uint8Array[]","ABITupleType","buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","AppManager"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = accountReferences ?? []\n const assets = assetReferences ?? []\n const apps = appReferences ?? []\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3B,MAAI,QAAQ,OAEV;AAEF,MAAI,WAAW,IAAI,CAEjB;AAGF,MAAI,2BAA2B,IAAI,EAAE;AACnC,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK,IAAI;KACT,QAAQ,IAAI;KACb;IACD,MAAM;IACP,CAAC;AAEF;;AAEF,MAAI,uBAAuB,IAAI,EAAE;GAE/B,MAAM,6BAA6B,mDAAmD,KAAK,cAAc;AACzG,wBAAqB,KAAK,GAAG,2BAA2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O;IACxB,eAAe,OAAO,eAAe,IAAIU,+BAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
1
+ {"version":3,"file":"method-call.js","names":["Address","argTypeIsReference","getAddress","argTypeIsTransaction","ABIUintType","encodedArgs: Uint8Array[]","ABITupleType","buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","AppManager"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = [...(accountReferences ?? [])]\n const assets = [...(assetReferences ?? [])]\n const apps = [...(appReferences ?? [])]\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;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,EAAE,CAAC;CAC7E,MAAM,SAAS,sBACb;EACE,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,MAAM,OAAO,QAAQ,EAAE;EACJ;EACnB,eAAe,OAAO;EACtB,iBAAiB,OAAO;EACzB,EACD,WACD;CAGD,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIO,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAY,OAAO,cAAcC,uCAAsB;GACvD,MAAM,OAAO;GACb,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,OAAO;IAC1B,eAAe,OAAO;IACtB,iBAAiB,OAAO;IACxB,eAAe,OAAO,eAAe,IAAIC,+BAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
@@ -85,9 +85,9 @@ const isAbiValue = (x) => {
85
85
  * Populate reference arrays from processed ABI method call arguments
86
86
  */
87
87
  function populateMethodArgsIntoReferenceArrays(sender, appId, method, methodArgs, accountReferences, appReferences, assetReferences) {
88
- const accounts = accountReferences ?? [];
89
- const assets = assetReferences ?? [];
90
- const apps = appReferences ?? [];
88
+ const accounts = [...accountReferences ?? []];
89
+ const assets = [...assetReferences ?? []];
90
+ const apps = [...appReferences ?? []];
91
91
  methodArgs.forEach((arg, i) => {
92
92
  const argType = method.args[i].type;
93
93
  if (argTypeIsReference(argType)) switch (argType) {
@@ -245,9 +245,9 @@ const buildAppCreateMethodCall = async (params, appManager, suggestedParams, def
245
245
  extraProgramPages,
246
246
  args: common.args,
247
247
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
248
- accountReferences: params.accountReferences?.map((a) => getAddress(a)),
249
- appReferences: params.appReferences,
250
- assetReferences: params.assetReferences,
248
+ accountReferences: common.accountReferences,
249
+ appReferences: common.appReferences,
250
+ assetReferences: common.assetReferences,
251
251
  boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
252
252
  },
253
253
  rejectVersion: params.rejectVersion
@@ -278,9 +278,9 @@ const buildAppUpdateMethodCall = async (params, appManager, suggestedParams, def
278
278
  clearStateProgram,
279
279
  args: common.args,
280
280
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
281
- accountReferences: params.accountReferences?.map((a) => getAddress(a)),
282
- appReferences: params.appReferences,
283
- assetReferences: params.assetReferences,
281
+ accountReferences: common.accountReferences,
282
+ appReferences: common.appReferences,
283
+ assetReferences: common.assetReferences,
284
284
  boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
285
285
  },
286
286
  rejectVersion: params.rejectVersion
@@ -307,9 +307,9 @@ const buildAppCallMethodCall = async (params, suggestedParams, defaultValidityWi
307
307
  onComplete: params.onComplete ?? OnApplicationComplete.NoOp,
308
308
  args: common.args,
309
309
  ...hasAccessReferences ? { accessReferences: params.accessReferences } : {
310
- accountReferences: params.accountReferences?.map((a) => getAddress(a)),
311
- appReferences: params.appReferences,
312
- assetReferences: params.assetReferences,
310
+ accountReferences: common.accountReferences,
311
+ appReferences: common.appReferences,
312
+ assetReferences: common.assetReferences,
313
313
  boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
314
314
  },
315
315
  rejectVersion: params.rejectVersion
@@ -1 +1 @@
1
- {"version":3,"file":"method-call.mjs","names":["encodedArgs: Uint8Array[]"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = accountReferences ?? []\n const assets = assetReferences ?? []\n const apps = appReferences ?? []\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3B,MAAI,QAAQ,OAEV;AAEF,MAAI,WAAW,IAAI,CAEjB;AAGF,MAAI,2BAA2B,IAAI,EAAE;AACnC,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK,IAAI;KACT,QAAQ,IAAI;KACb;IACD,MAAM;IACP,CAAC;AAEF;;AAEF,MAAI,uBAAuB,IAAI,EAAE;GAE/B,MAAM,6BAA6B,mDAAmD,KAAK,cAAc;AACzG,wBAAqB,KAAK,GAAG,2BAA2B;AACxD,wBAAqB,KAAK;IACxB,MAAM;KACJ,GAAG;KACH,QAAQ,IAAI,UAAU;KACtB,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s: Uint8Array[]"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = [...(accountReferences ?? [])]\n const assets = [...(assetReferences ?? [])]\n const apps = [...(appReferences ?? [])]\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3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