@algorandfoundation/algokit-utils 10.0.0-alpha.11 → 10.0.0-alpha.13
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.
- package/algod-client/index.d.ts +2 -3
- package/algod-client/index.js +2 -5
- package/algod-client/index.mjs +2 -2
- package/indexer-client/index.d.ts +1 -2
- package/indexer-client/index.js +0 -5
- package/indexer-client/index.mjs +1 -2
- package/kmd-client/index.d.ts +1 -2
- package/kmd-client/index.js +0 -5
- package/kmd-client/index.mjs +1 -2
- package/package.json +1 -1
- package/packages/algod_client/src/apis/api-service.js +2 -2
- package/packages/algod_client/src/apis/api-service.mjs +2 -2
- package/packages/algod_client/src/core/model-runtime.js +2 -2
- package/packages/algod_client/src/core/model-runtime.js.map +1 -1
- package/packages/algod_client/src/core/model-runtime.mjs +2 -2
- package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/algod_client/src/models/block.d.ts +17 -17
- package/packages/algod_client/src/models/block.js +18 -18
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs +18 -18
- package/packages/algod_client/src/models/block.mjs.map +1 -1
- package/packages/algod_client/src/models/simulate-request.js +1 -1
- package/packages/algod_client/src/models/simulate-request.mjs +1 -1
- package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
- package/packages/algod_client/src/models/simulate-response.js +6 -1
- package/packages/algod_client/src/models/simulate-response.js.map +1 -1
- package/packages/algod_client/src/models/simulate-response.mjs +6 -2
- package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.js +0 -15
- package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
- package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/indexer_client/src/models/block.d.ts +5 -5
- package/packages/indexer_client/src/models/block.js +5 -5
- package/packages/indexer_client/src/models/block.js.map +1 -1
- package/packages/indexer_client/src/models/block.mjs +5 -5
- package/packages/indexer_client/src/models/block.mjs.map +1 -1
- package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
- package/packages/indexer_client/src/models/participation-updates.js +2 -2
- package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
- package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
- package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.js +2 -12
- package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
- package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
- package/transactions/app-call.d.ts +1 -1
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/method-call.d.ts +1 -1
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +19 -19
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +18 -18
- package/types/app-client.d.ts +65 -65
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +1 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +25 -25
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs.map +1 -1
- package/types/app.d.ts +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +3 -6
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +1 -1
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +1 -1
- package/types/composer.js +3 -3
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +3 -3
- package/types/composer.mjs.map +1 -1
- package/types/debugging.d.ts +13 -9
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +0 -1
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/transaction.d.ts +1 -1
- package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
- package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
- package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
- package/types/expand.d.ts +0 -9
- package/types/expand.js +0 -0
- package/types/expand.mjs +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.mjs","names":["BlockMeta: ObjectModelMetadata<Block>"],"sources":["../../../../../packages/indexer_client/src/models/block.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n stringCodec,\n numberCodec,\n bigIntCodec,\n addressCodec,\n ArrayCodec,\n ObjectModelCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n} from '@algorandfoundation/algokit-common'\nimport type { BlockRewards } from './block-rewards'\nimport { BlockRewardsMeta } from './block-rewards'\nimport type { BlockUpgradeState } from './block-upgrade-state'\nimport { BlockUpgradeStateMeta } from './block-upgrade-state'\nimport type { BlockUpgradeVote } from './block-upgrade-vote'\nimport { BlockUpgradeVoteMeta } from './block-upgrade-vote'\nimport type { ParticipationUpdates } from './participation-updates'\nimport { ParticipationUpdatesMeta } from './participation-updates'\nimport type { StateProofTracking } from './state-proof-tracking'\nimport { StateProofTrackingMeta } from './state-proof-tracking'\nimport type { Transaction } from './transaction'\nimport { TransactionMeta } from './transaction'\n\n/**\n * Block information.\n *\n * Definition:\n * data/bookkeeping/block.go : Block\n */\nexport type Block = {\n /**\n * the proposer of this block.\n */\n proposer?: Address\n\n /**\n * the sum of all fees paid by transactions in this block.\n */\n feesCollected?: number\n\n /**\n * the potential bonus payout for this block.\n */\n bonus?: number\n\n /**\n * the actual amount transferred to the proposer from the fee sink.\n */\n proposerPayout?: number\n\n /**\n * \\[gh\\] hash to which this block belongs.\n */\n genesisHash: Uint8Array\n\n /**\n * \\[gen\\] ID to which this block belongs.\n */\n genesisId: string\n\n /**\n * \\[prev\\] Previous block hash.\n */\n previousBlockHash: Uint8Array\n\n /**\n * \\[prev512\\] Previous block hash, using SHA-512.\n */\n previousBlockHash512?: Uint8Array\n rewards
|
|
1
|
+
{"version":3,"file":"block.mjs","names":["BlockMeta: ObjectModelMetadata<Block>"],"sources":["../../../../../packages/indexer_client/src/models/block.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport {\n stringCodec,\n numberCodec,\n bigIntCodec,\n addressCodec,\n ArrayCodec,\n ObjectModelCodec,\n fixedBytes32Codec,\n fixedBytes64Codec,\n} from '@algorandfoundation/algokit-common'\nimport type { BlockRewards } from './block-rewards'\nimport { BlockRewardsMeta } from './block-rewards'\nimport type { BlockUpgradeState } from './block-upgrade-state'\nimport { BlockUpgradeStateMeta } from './block-upgrade-state'\nimport type { BlockUpgradeVote } from './block-upgrade-vote'\nimport { BlockUpgradeVoteMeta } from './block-upgrade-vote'\nimport type { ParticipationUpdates } from './participation-updates'\nimport { ParticipationUpdatesMeta } from './participation-updates'\nimport type { StateProofTracking } from './state-proof-tracking'\nimport { StateProofTrackingMeta } from './state-proof-tracking'\nimport type { Transaction } from './transaction'\nimport { TransactionMeta } from './transaction'\n\n/**\n * Block information.\n *\n * Definition:\n * data/bookkeeping/block.go : Block\n */\nexport type Block = {\n /**\n * the proposer of this block.\n */\n proposer?: Address\n\n /**\n * the sum of all fees paid by transactions in this block.\n */\n feesCollected?: number\n\n /**\n * the potential bonus payout for this block.\n */\n bonus?: number\n\n /**\n * the actual amount transferred to the proposer from the fee sink.\n */\n proposerPayout?: number\n\n /**\n * \\[gh\\] hash to which this block belongs.\n */\n genesisHash: Uint8Array\n\n /**\n * \\[gen\\] ID to which this block belongs.\n */\n genesisId: string\n\n /**\n * \\[prev\\] Previous block hash.\n */\n previousBlockHash: Uint8Array\n\n /**\n * \\[prev512\\] Previous block hash, using SHA-512.\n */\n previousBlockHash512?: Uint8Array\n rewards: BlockRewards\n\n /**\n * \\[rnd\\] Current round on which this block was appended to the chain.\n */\n round: bigint\n\n /**\n * \\[seed\\] Sortition seed.\n */\n seed: Uint8Array\n\n /**\n * Tracks the status of state proofs.\n */\n stateProofTracking?: StateProofTracking[]\n\n /**\n * \\[ts\\] Block creation timestamp in seconds since epoch\n */\n timestamp: number\n\n /**\n * \\[txns\\] list of transactions corresponding to a given round.\n */\n transactions: Transaction[]\n\n /**\n * \\[txn\\] TransactionsRoot authenticates the set of transactions appearing in the block. More specifically, it's the root of a merkle tree whose leaves are the block's Txids, in lexicographic order. For the empty block, it's 0. Note that the TxnRoot does not authenticate the signatures on the transactions, only the transactions themselves. Two blocks with the same transactions but in a different order and with different signatures will have the same TxnRoot.\n */\n transactionsRoot: Uint8Array\n\n /**\n * \\[txn256\\] TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a vector commitment instead of a merkle tree, and SHA256 hash function instead of the default SHA512_256. This commitment can be used on environments where only the SHA256 function exists.\n */\n transactionsRootSha256?: Uint8Array\n\n /**\n * \\[txn512\\] TransactionsRootSHA512 is an auxiliary TransactionRoot, built using a vector commitment instead of a merkle tree, and SHA512 hash function instead of the default SHA512_256.\n */\n transactionsRootSha512?: Uint8Array\n\n /**\n * \\[tc\\] TxnCounter counts the number of transactions committed in the ledger, from the time at which support for this feature was introduced.\n *\n * Specifically, TxnCounter is the number of the next transaction that will be committed after this block. It is 0 when no transactions have ever been committed (since TxnCounter started being supported).\n */\n txnCounter?: number\n upgradeState: BlockUpgradeState\n upgradeVote?: BlockUpgradeVote\n participationUpdates: ParticipationUpdates\n}\n\nexport const BlockMeta: ObjectModelMetadata<Block> = {\n name: 'Block',\n kind: 'object',\n fields: [\n {\n name: 'proposer',\n wireKey: 'proposer',\n optional: true,\n codec: addressCodec,\n },\n {\n name: 'feesCollected',\n wireKey: 'fees-collected',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'bonus',\n wireKey: 'bonus',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'proposerPayout',\n wireKey: 'proposer-payout',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'genesisHash',\n wireKey: 'genesis-hash',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'genesisId',\n wireKey: 'genesis-id',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'previousBlockHash',\n wireKey: 'previous-block-hash',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'previousBlockHash512',\n wireKey: 'previous-block-hash-512',\n optional: true,\n codec: fixedBytes64Codec,\n },\n {\n name: 'rewards',\n wireKey: 'rewards',\n optional: false,\n codec: new ObjectModelCodec(BlockRewardsMeta),\n },\n {\n name: 'round',\n wireKey: 'round',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'seed',\n wireKey: 'seed',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'stateProofTracking',\n wireKey: 'state-proof-tracking',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(StateProofTrackingMeta)),\n },\n {\n name: 'timestamp',\n wireKey: 'timestamp',\n optional: false,\n codec: numberCodec,\n },\n {\n name: 'transactions',\n wireKey: 'transactions',\n optional: false,\n codec: new ArrayCodec(new ObjectModelCodec(TransactionMeta)),\n },\n {\n name: 'transactionsRoot',\n wireKey: 'transactions-root',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'transactionsRootSha256',\n wireKey: 'transactions-root-sha256',\n optional: true,\n codec: fixedBytes32Codec,\n },\n {\n name: 'transactionsRootSha512',\n wireKey: 'transactions-root-sha512',\n optional: true,\n codec: fixedBytes64Codec,\n },\n {\n name: 'txnCounter',\n wireKey: 'txn-counter',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'upgradeState',\n wireKey: 'upgrade-state',\n optional: false,\n codec: new ObjectModelCodec(BlockUpgradeStateMeta),\n },\n {\n name: 'upgradeVote',\n wireKey: 'upgrade-vote',\n optional: true,\n codec: new ObjectModelCodec(BlockUpgradeVoteMeta),\n },\n {\n name: 'participationUpdates',\n wireKey: 'participation-updates',\n optional: false,\n codec: new ObjectModelCodec(ParticipationUpdatesMeta),\n },\n ],\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2HA,MAAaA,YAAwC;CACnD,MAAM;CACN,MAAM;CACN,QAAQ;EACN;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,iBAAiB;GAC9C;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,WAAW,IAAI,iBAAiB,uBAAuB,CAAC;GACpE;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,gBAAgB,CAAC;GAC7D;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,IAAI,iBAAiB,qBAAqB;GAClD;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,iBAAiB,yBAAyB;GACtD;EACF;CACF"}
|
|
@@ -6,11 +6,11 @@ type ParticipationUpdates = {
|
|
|
6
6
|
/**
|
|
7
7
|
* \[partupdrmv\] a list of online accounts that needs to be converted to offline since their participation key expired.
|
|
8
8
|
*/
|
|
9
|
-
expiredParticipationAccounts
|
|
9
|
+
expiredParticipationAccounts: string[];
|
|
10
10
|
/**
|
|
11
11
|
* \[partupabs\] a list of online accounts that need to be suspended.
|
|
12
12
|
*/
|
|
13
|
-
absentParticipationAccounts
|
|
13
|
+
absentParticipationAccounts: string[];
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ParticipationUpdates };
|
|
@@ -7,12 +7,12 @@ const ParticipationUpdatesMeta = {
|
|
|
7
7
|
fields: [{
|
|
8
8
|
name: "expiredParticipationAccounts",
|
|
9
9
|
wireKey: "expired-participation-accounts",
|
|
10
|
-
optional:
|
|
10
|
+
optional: false,
|
|
11
11
|
codec: require_array.stringArrayCodec
|
|
12
12
|
}, {
|
|
13
13
|
name: "absentParticipationAccounts",
|
|
14
14
|
wireKey: "absent-participation-accounts",
|
|
15
|
-
optional:
|
|
15
|
+
optional: false,
|
|
16
16
|
codec: require_array.stringArrayCodec
|
|
17
17
|
}]
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participation-updates.js","names":["ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates>","stringArrayCodec"],"sources":["../../../../../packages/indexer_client/src/models/participation-updates.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringArrayCodec } from '@algorandfoundation/algokit-common'\n\n/**\n * Participation account data that needs to be checked/acted on by the network.\n */\nexport type ParticipationUpdates = {\n /**\n * \\[partupdrmv\\] a list of online accounts that needs to be converted to offline since their participation key expired.\n */\n expiredParticipationAccounts
|
|
1
|
+
{"version":3,"file":"participation-updates.js","names":["ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates>","stringArrayCodec"],"sources":["../../../../../packages/indexer_client/src/models/participation-updates.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringArrayCodec } from '@algorandfoundation/algokit-common'\n\n/**\n * Participation account data that needs to be checked/acted on by the network.\n */\nexport type ParticipationUpdates = {\n /**\n * \\[partupdrmv\\] a list of online accounts that needs to be converted to offline since their participation key expired.\n */\n expiredParticipationAccounts: string[]\n\n /**\n * \\[partupabs\\] a list of online accounts that need to be suspended.\n */\n absentParticipationAccounts: string[]\n}\n\nexport const ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates> = {\n name: 'ParticipationUpdates',\n kind: 'object',\n fields: [\n {\n name: 'expiredParticipationAccounts',\n wireKey: 'expired-participation-accounts',\n optional: false,\n codec: stringArrayCodec,\n },\n {\n name: 'absentParticipationAccounts',\n wireKey: 'absent-participation-accounts',\n optional: false,\n codec: stringArrayCodec,\n },\n ],\n}\n"],"mappings":";;;AAkBA,MAAaA,2BAAsE;CACjF,MAAM;CACN,MAAM;CACN,QAAQ,CACN;EACE,MAAM;EACN,SAAS;EACT,UAAU;EACV,OAAOC;EACR,EACD;EACE,MAAM;EACN,SAAS;EACT,UAAU;EACV,OAAOA;EACR,CACF;CACF"}
|
|
@@ -7,12 +7,12 @@ const ParticipationUpdatesMeta = {
|
|
|
7
7
|
fields: [{
|
|
8
8
|
name: "expiredParticipationAccounts",
|
|
9
9
|
wireKey: "expired-participation-accounts",
|
|
10
|
-
optional:
|
|
10
|
+
optional: false,
|
|
11
11
|
codec: stringArrayCodec
|
|
12
12
|
}, {
|
|
13
13
|
name: "absentParticipationAccounts",
|
|
14
14
|
wireKey: "absent-participation-accounts",
|
|
15
|
-
optional:
|
|
15
|
+
optional: false,
|
|
16
16
|
codec: stringArrayCodec
|
|
17
17
|
}]
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participation-updates.mjs","names":["ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates>"],"sources":["../../../../../packages/indexer_client/src/models/participation-updates.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringArrayCodec } from '@algorandfoundation/algokit-common'\n\n/**\n * Participation account data that needs to be checked/acted on by the network.\n */\nexport type ParticipationUpdates = {\n /**\n * \\[partupdrmv\\] a list of online accounts that needs to be converted to offline since their participation key expired.\n */\n expiredParticipationAccounts
|
|
1
|
+
{"version":3,"file":"participation-updates.mjs","names":["ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates>"],"sources":["../../../../../packages/indexer_client/src/models/participation-updates.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringArrayCodec } from '@algorandfoundation/algokit-common'\n\n/**\n * Participation account data that needs to be checked/acted on by the network.\n */\nexport type ParticipationUpdates = {\n /**\n * \\[partupdrmv\\] a list of online accounts that needs to be converted to offline since their participation key expired.\n */\n expiredParticipationAccounts: string[]\n\n /**\n * \\[partupabs\\] a list of online accounts that need to be suspended.\n */\n absentParticipationAccounts: string[]\n}\n\nexport const ParticipationUpdatesMeta: ObjectModelMetadata<ParticipationUpdates> = {\n name: 'ParticipationUpdates',\n kind: 'object',\n fields: [\n {\n name: 'expiredParticipationAccounts',\n wireKey: 'expired-participation-accounts',\n optional: false,\n codec: stringArrayCodec,\n },\n {\n name: 'absentParticipationAccounts',\n wireKey: 'absent-participation-accounts',\n optional: false,\n codec: stringArrayCodec,\n },\n ],\n}\n"],"mappings":";;;AAkBA,MAAaA,2BAAsE;CACjF,MAAM;CACN,MAAM;CACN,QAAQ,CACN;EACE,MAAM;EACN,SAAS;EACT,UAAU;EACV,OAAO;EACR,EACD;EACE,MAAM;EACN,SAAS;EACT,UAAU;EACV,OAAO;EACR,CACF;CACF"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
const require_object_model = require('../../../common/src/codecs/models/object-model.js');
|
|
2
2
|
const require_json = require('../../../common/src/json.js');
|
|
3
|
-
const require_msgpack = require('../../../common/src/msgpack.js');
|
|
4
3
|
|
|
5
4
|
//#region packages/kmd_client/src/core/model-runtime.ts
|
|
6
|
-
function encodeJson(value, meta) {
|
|
7
|
-
return require_json.stringifyJson(new require_object_model.ObjectModelCodec(meta).encode(value, "json"));
|
|
8
|
-
}
|
|
9
|
-
function encodeMsgpack(value, meta) {
|
|
10
|
-
return require_msgpack.encodeMsgpack(new require_object_model.ObjectModelCodec(meta).encode(value, "msgpack"));
|
|
5
|
+
function encodeJson(value, meta, space) {
|
|
6
|
+
return require_json.stringifyJson(new require_object_model.ObjectModelCodec(meta).encode(value, "json"), void 0, space);
|
|
11
7
|
}
|
|
12
8
|
function decodeJson(value, meta) {
|
|
13
9
|
return new require_object_model.ObjectModelCodec(meta).decode(value, "json");
|
|
14
10
|
}
|
|
15
|
-
function decodeMsgpack(value, meta) {
|
|
16
|
-
const wire = require_msgpack.decodeMsgpack(value);
|
|
17
|
-
return new require_object_model.ObjectModelCodec(meta).decode(wire, "msgpack");
|
|
18
|
-
}
|
|
19
11
|
|
|
20
12
|
//#endregion
|
|
21
13
|
exports.decodeJson = decodeJson;
|
|
22
|
-
exports.decodeMsgpack = decodeMsgpack;
|
|
23
14
|
exports.encodeJson = encodeJson;
|
|
24
|
-
exports.encodeMsgpack = encodeMsgpack;
|
|
25
15
|
//# sourceMappingURL=model-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.js","names":["stringifyJson","ObjectModelCodec"
|
|
1
|
+
{"version":3,"file":"model-runtime.js","names":["stringifyJson","ObjectModelCodec"],"sources":["../../../../../packages/kmd_client/src/core/model-runtime.ts"],"sourcesContent":["import {\n ObjectModelCodec,\n decodeMsgpack as rawDecodeMsgpack,\n encodeMsgpack as rawEncodeMsgpack,\n stringifyJson,\n type ObjectModelMetadata,\n} from '@algorandfoundation/algokit-common'\n\nexport function encodeJson<T extends Record<string, unknown>>(value: T, meta: ObjectModelMetadata<T>, space?: string | number): string {\n const wire = new ObjectModelCodec(meta).encode(value, 'json')\n return stringifyJson(wire, undefined, space)\n}\nexport function encodeMsgpack<T extends Record<string, unknown>>(value: T, meta: ObjectModelMetadata<T>): Uint8Array {\n const wire = new ObjectModelCodec(meta).encode(value, 'msgpack')\n return rawEncodeMsgpack(wire)\n}\nexport function decodeJson<T extends Record<string, unknown>>(value: Record<string, unknown>, meta: ObjectModelMetadata<T>): T {\n return new ObjectModelCodec<T>(meta).decode(value, 'json')\n}\nexport function decodeMsgpack<T extends Record<string, unknown>>(value: Uint8Array, meta: ObjectModelMetadata<T>): T {\n const wire = rawDecodeMsgpack(value)\n return new ObjectModelCodec<T>(meta).decode(wire, 'msgpack')\n}\n"],"mappings":";;;;AAQA,SAAgB,WAA8C,OAAU,MAA8B,OAAiC;AAErI,QAAOA,2BADM,IAAIC,sCAAiB,KAAK,CAAC,OAAO,OAAO,OAAO,EAClC,QAAW,MAAM;;AAM9C,SAAgB,WAA8C,OAAgC,MAAiC;AAC7H,QAAO,IAAIA,sCAAoB,KAAK,CAAC,OAAO,OAAO,OAAO"}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { ObjectModelCodec } from "../../../common/src/codecs/models/object-model.mjs";
|
|
2
2
|
import { stringifyJson } from "../../../common/src/json.mjs";
|
|
3
|
-
import { decodeMsgpack as decodeMsgpack$1, encodeMsgpack as encodeMsgpack$1 } from "../../../common/src/msgpack.mjs";
|
|
4
3
|
|
|
5
4
|
//#region packages/kmd_client/src/core/model-runtime.ts
|
|
6
|
-
function encodeJson(value, meta) {
|
|
7
|
-
return stringifyJson(new ObjectModelCodec(meta).encode(value, "json"));
|
|
8
|
-
}
|
|
9
|
-
function encodeMsgpack(value, meta) {
|
|
10
|
-
return encodeMsgpack$1(new ObjectModelCodec(meta).encode(value, "msgpack"));
|
|
5
|
+
function encodeJson(value, meta, space) {
|
|
6
|
+
return stringifyJson(new ObjectModelCodec(meta).encode(value, "json"), void 0, space);
|
|
11
7
|
}
|
|
12
8
|
function decodeJson(value, meta) {
|
|
13
9
|
return new ObjectModelCodec(meta).decode(value, "json");
|
|
14
10
|
}
|
|
15
|
-
function decodeMsgpack(value, meta) {
|
|
16
|
-
const wire = decodeMsgpack$1(value);
|
|
17
|
-
return new ObjectModelCodec(meta).decode(wire, "msgpack");
|
|
18
|
-
}
|
|
19
11
|
|
|
20
12
|
//#endregion
|
|
21
|
-
export { decodeJson,
|
|
13
|
+
export { decodeJson, encodeJson };
|
|
22
14
|
//# sourceMappingURL=model-runtime.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-runtime.mjs","names":[
|
|
1
|
+
{"version":3,"file":"model-runtime.mjs","names":[],"sources":["../../../../../packages/kmd_client/src/core/model-runtime.ts"],"sourcesContent":["import {\n ObjectModelCodec,\n decodeMsgpack as rawDecodeMsgpack,\n encodeMsgpack as rawEncodeMsgpack,\n stringifyJson,\n type ObjectModelMetadata,\n} from '@algorandfoundation/algokit-common'\n\nexport function encodeJson<T extends Record<string, unknown>>(value: T, meta: ObjectModelMetadata<T>, space?: string | number): string {\n const wire = new ObjectModelCodec(meta).encode(value, 'json')\n return stringifyJson(wire, undefined, space)\n}\nexport function encodeMsgpack<T extends Record<string, unknown>>(value: T, meta: ObjectModelMetadata<T>): Uint8Array {\n const wire = new ObjectModelCodec(meta).encode(value, 'msgpack')\n return rawEncodeMsgpack(wire)\n}\nexport function decodeJson<T extends Record<string, unknown>>(value: Record<string, unknown>, meta: ObjectModelMetadata<T>): T {\n return new ObjectModelCodec<T>(meta).decode(value, 'json')\n}\nexport function decodeMsgpack<T extends Record<string, unknown>>(value: Uint8Array, meta: ObjectModelMetadata<T>): T {\n const wire = rawDecodeMsgpack(value)\n return new ObjectModelCodec<T>(meta).decode(wire, 'msgpack')\n}\n"],"mappings":";;;;AAQA,SAAgB,WAA8C,OAAU,MAA8B,OAAiC;AAErI,QAAO,cADM,IAAI,iBAAiB,KAAK,CAAC,OAAO,OAAO,OAAO,EAClC,QAAW,MAAM;;AAM9C,SAAgB,WAA8C,OAAgC,MAAiC;AAC7H,QAAO,IAAI,iBAAoB,KAAK,CAAC,OAAO,OAAO,OAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReadableAddress } from "../packages/common/src/address.js";
|
|
2
|
+
import { Expand } from "../packages/common/src/expand.js";
|
|
2
3
|
import { OnApplicationComplete, ResourceReference } from "../packages/transact/src/transactions/app-call.js";
|
|
3
4
|
import { BoxIdentifier, BoxReference } from "../types/app-manager.js";
|
|
4
|
-
import { Expand } from "../types/expand.js";
|
|
5
5
|
import { CommonTransactionParams } from "./common.js";
|
|
6
6
|
|
|
7
7
|
//#region src/transactions/app-call.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-call.js","names":["buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","getAddress","AppManager","MAX_OVERALL_REFERENCES","appCall","getApplicationAddress","MAX_ACCOUNT_REFERENCES","groupIndex"],"sources":["../../src/transactions/app-call.ts"],"sourcesContent":["import { SimulateUnnamedResourcesAccessed, SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_OVERALL_REFERENCES,\n ReadableAddress,\n getAddress,\n getApplicationAddress,\n} from '@algorandfoundation/algokit-common'\nimport {\n HoldingReference,\n LocalsReference,\n OnApplicationComplete,\n ResourceReference,\n BoxReference as TransactBoxReference,\n Transaction,\n TransactionType,\n} from '@algorandfoundation/algokit-transact'\nimport { AppManager, BoxIdentifier, BoxReference as UtilsBoxReference } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Common parameters for defining an application call transaction. */\nexport type CommonAppCallParams = CommonTransactionParams & {\n /** ID of the application; 0 if the application is being created. */\n appId: bigint\n /** The [on-complete](https://dev.algorand.co/concepts/smart-contracts/avm#oncomplete) action of the call; defaults to no-op. */\n onComplete?: OnApplicationComplete\n /** Any [arguments to pass to the smart contract call](/concepts/smart-contracts/languages/teal/#argument-passing). */\n args?: Uint8Array[]\n /** Any account addresses to add to the [accounts array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n accountReferences?: ReadableAddress[]\n /** The ID of any apps to load to the [foreign apps array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n appReferences?: bigint[]\n /** The ID of any assets to load to the [foreign assets array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n assetReferences?: bigint[]\n /** Any boxes to load to the [boxes array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays).\n *\n * Either the name identifier (which will be set against app ID of `0` i.e.\n * the current app), or a box identifier with the name identifier and app ID.\n */\n boxReferences?: (UtilsBoxReference | BoxIdentifier)[]\n /** Access references unifies `accountReferences`, `appReferences`, `assetReferences`, and `boxReferences` under a single list. If non-empty, these other reference lists must be empty. If access is empty, those other reference lists may be non-empty. */\n accessReferences?: ResourceReference[]\n /** If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check. */\n rejectVersion?: number\n}\n\n/** Parameters to define an app create transaction */\nexport type AppCreateParams = Expand<\n Omit<CommonAppCallParams, 'appId'> & {\n appId?: 0\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** The program to execute for all OnCompletes other than ClearState as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n clearStateProgram: string | Uint8Array\n /** The state schema for the app. This is immutable once the app is created. */\n schema?: {\n /** The number of integers saved in global state. */\n globalInts: number\n /** The number of byte slices saved in global state. */\n globalByteSlices: number\n /** The number of integers saved in local state. */\n localInts: number\n /** The number of byte slices saved in local state. */\n localByteSlices: number\n }\n /** Number of extra pages required for the programs.\n * Defaults to the number needed for the programs in this call if not specified.\n * This is immutable once the app is created. */\n extraProgramPages?: number\n }\n>\n\n/** Parameters to define an app update transaction */\nexport type AppUpdateParams = Expand<\n CommonAppCallParams & {\n onComplete?: OnApplicationComplete.UpdateApplication\n /** The program to execute for all OnCompletes other than ClearState as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n clearStateProgram: string | Uint8Array\n }\n>\n\n/** Parameters to define an application call transaction. */\nexport type AppCallParams = CommonAppCallParams & { onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication> }\n\n/** Common parameters to define an ABI method call transaction. */\nexport type AppMethodCallParams = CommonAppCallParams & {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication | OnApplicationComplete.ClearState>\n}\n\n/** Parameters to define an application delete call transaction. */\nexport type AppDeleteParams = CommonAppCallParams & { onComplete?: OnApplicationComplete.DeleteApplication }\n\nexport const buildAppCreate = async (\n params: AppCreateParams,\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 ? { numByteSlices: params.schema?.globalByteSlices ?? 0, numUints: params.schema?.globalInts ?? 0 }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? { numByteSlices: params.schema?.localByteSlices ?? 0, numUints: params.schema?.localInts ?? 0 }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\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, // App creation always uses ID 0\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: params.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 buildAppUpdate = async (\n params: AppUpdateParams,\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\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: params.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 buildAppCall = (\n params: AppCallParams | AppDeleteParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\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: params.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\n/**\n * Populate transaction-level resources for app call transactions\n */\nexport function populateTransactionResources(\n transaction: Transaction, // NOTE: transaction is mutated in place\n resourcesAccessed: SimulateUnnamedResourcesAccessed,\n groupIndex: number,\n): void {\n if (transaction.type !== TransactionType.AppCall || transaction.appCall === undefined) {\n return\n }\n\n // Check for unexpected resources at transaction level\n if (resourcesAccessed.boxes || resourcesAccessed.extraBoxRefs) {\n throw new Error('Unexpected boxes at the transaction level')\n }\n if (resourcesAccessed.appLocals) {\n throw new Error('Unexpected app locals at the transaction level')\n }\n if (resourcesAccessed.assetHoldings) {\n throw new Error('Unexpected asset holdings at the transaction level')\n }\n\n let accountsCount = 0\n let appsCount = 0\n let assetsCount = 0\n const boxesCount = transaction.appCall.boxReferences?.length ?? 0\n\n // Populate accounts\n if (resourcesAccessed.accounts) {\n transaction.appCall.accountReferences = transaction.appCall.accountReferences ?? []\n for (const account of resourcesAccessed.accounts) {\n const address = account\n if (!transaction.appCall.accountReferences.some((a) => a.equals(address))) {\n transaction.appCall.accountReferences.push(address)\n }\n }\n accountsCount = transaction.appCall.accountReferences.length\n }\n\n // Populate apps\n if (resourcesAccessed.apps) {\n transaction.appCall.appReferences = transaction.appCall.appReferences ?? []\n for (const appId of resourcesAccessed.apps) {\n if (!transaction.appCall.appReferences.includes(appId)) {\n transaction.appCall.appReferences.push(appId)\n }\n }\n appsCount = transaction.appCall.appReferences.length\n }\n\n // Populate assets\n if (resourcesAccessed.assets) {\n transaction.appCall.assetReferences = transaction.appCall.assetReferences ?? []\n for (const assetId of resourcesAccessed.assets) {\n if (!transaction.appCall.assetReferences.includes(assetId)) {\n transaction.appCall.assetReferences.push(assetId)\n }\n }\n assetsCount = transaction.appCall.assetReferences.length\n }\n\n if (accountsCount + assetsCount + appsCount + boxesCount > MAX_OVERALL_REFERENCES) {\n throw new Error(`Resource reference limit of ${MAX_OVERALL_REFERENCES} exceeded in transaction ${groupIndex}`)\n }\n}\n\nenum GroupResourceType {\n Account,\n App,\n Asset,\n Box,\n ExtraBoxRef,\n AssetHolding,\n AppLocal,\n}\n\n/**\n * Populate group-level resources for app call transactions\n */\nexport function populateGroupResources(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n groupResources: SimulateUnnamedResourcesAccessed,\n): void {\n let remainingAccounts = [...(groupResources.accounts ?? [])]\n let remainingApps = [...(groupResources.apps ?? [])]\n let remainingAssets = [...(groupResources.assets ?? [])]\n const remainingBoxes = [...(groupResources.boxes ?? [])]\n\n // Process cross-reference resources first (app locals and asset holdings) as they are most restrictive\n if (groupResources.appLocals) {\n groupResources.appLocals.forEach((appLocal) => {\n populateGroupResource(transactions, { type: GroupResourceType.AppLocal, data: appLocal })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== appLocal.address)\n remainingApps = remainingApps.filter((app) => app !== appLocal.appId)\n })\n }\n\n if (groupResources.assetHoldings) {\n groupResources.assetHoldings.forEach((assetHolding) => {\n populateGroupResource(transactions, { type: GroupResourceType.AssetHolding, data: assetHolding })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== assetHolding.address)\n remainingAssets = remainingAssets.filter((asset) => asset !== assetHolding.assetId)\n })\n }\n\n // Process accounts next because account limit is 4\n remainingAccounts.forEach((account) => {\n populateGroupResource(transactions, { type: GroupResourceType.Account, data: account })\n })\n\n // Process boxes\n remainingBoxes.forEach((boxRef) => {\n populateGroupResource(transactions, { type: GroupResourceType.Box, data: { appId: boxRef.appId, name: boxRef.name } })\n // Remove apps as resource if we're adding it here\n remainingApps = remainingApps.filter((app) => app !== boxRef.appId)\n })\n\n // Process assets\n remainingAssets.forEach((asset) => {\n populateGroupResource(transactions, { type: GroupResourceType.Asset, data: asset })\n })\n\n // Process remaining apps\n remainingApps.forEach((app) => {\n populateGroupResource(transactions, { type: GroupResourceType.App, data: app })\n })\n\n // Handle extra box refs\n if (groupResources.extraBoxRefs) {\n for (let i = 0; i < groupResources.extraBoxRefs; i++) {\n populateGroupResource(transactions, { type: GroupResourceType.ExtraBoxRef })\n }\n }\n}\n\n/**\n * Helper function to check if an app call transaction is below resource limit\n */\nfunction isAppCallBelowResourceLimit(txn: Transaction): boolean {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const accountsCount = txn.appCall?.accountReferences?.length || 0\n const assetsCount = txn.appCall?.assetReferences?.length || 0\n const appsCount = txn.appCall?.appReferences?.length || 0\n const boxesCount = txn.appCall?.boxReferences?.length || 0\n\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n}\n\ntype GroupResourceToPopulate =\n | { type: GroupResourceType.Account; data: Address }\n | { type: GroupResourceType.App; data: bigint }\n | { type: GroupResourceType.Asset; data: bigint }\n | { type: GroupResourceType.Box; data: TransactBoxReference }\n | { type: GroupResourceType.ExtraBoxRef }\n | { type: GroupResourceType.AssetHolding; data: HoldingReference }\n | { type: GroupResourceType.AppLocal; data: LocalsReference }\n\n/**\n * Helper function to populate a specific resource into a transaction group\n */\nfunction populateGroupResource(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n resource: GroupResourceToPopulate,\n): void {\n // For asset holdings and app locals, first try to find a transaction that already has the account available\n if (resource.type === GroupResourceType.AssetHolding || resource.type === GroupResourceType.AppLocal) {\n const address = resource.data.address\n\n // Try to find a transaction that already has the account available\n const groupIndex1 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n\n // Check if account is in foreign accounts array\n if (appCall.accountReferences?.some((a) => a.equals(address))) {\n return true\n }\n\n // Check if account is available as an app account\n if (appCall.appReferences) {\n for (const appId of appCall.appReferences) {\n if (address === getApplicationAddress(appId)) {\n return true\n }\n }\n }\n\n // Check if account appears in any app call transaction fields\n if (txn.sender.equals(address)) {\n return true\n }\n\n return false\n })\n\n if (groupIndex1 !== -1) {\n const appCall = transactions[groupIndex1].appCall!\n if (resource.type === GroupResourceType.AssetHolding) {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n } else {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n return\n }\n\n // Try to find a transaction that has the asset/app available and space for account\n const groupIndex2 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n if ((appCall.accountReferences?.length ?? 0) >= MAX_ACCOUNT_REFERENCES) {\n return false\n }\n\n if (resource.type === GroupResourceType.AssetHolding) {\n return appCall.assetReferences?.includes(resource.data.assetId) || false\n } else {\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n }\n })\n\n if (groupIndex2 !== -1) {\n const appCall = transactions[groupIndex2].appCall!\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.includes(address)) {\n appCall.accountReferences.push(address)\n }\n return\n }\n }\n\n // For boxes, first try to find a transaction that already has the app available\n if (resource.type === GroupResourceType.Box) {\n const groupIndex = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n })\n\n if (groupIndex !== -1) {\n const appCall = transactions[groupIndex].appCall!\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n return\n }\n }\n\n // Find the first transaction that can accommodate the resource\n const groupIndex = transactions.findIndex((txn) => {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const appCall = txn.appCall!\n const accountsCount = appCall.accountReferences?.length ?? 0\n const assetsCount = appCall.assetReferences?.length ?? 0\n const appsCount = appCall.appReferences?.length ?? 0\n const boxesCount = appCall.boxReferences?.length ?? 0\n\n switch (resource.type) {\n case GroupResourceType.Account:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n case GroupResourceType.AssetHolding:\n case GroupResourceType.AppLocal:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n case GroupResourceType.Box:\n if (resource.data.appId !== 0n) {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n } else {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n default:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n })\n\n if (groupIndex === -1) {\n throw new Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n const appCall = transactions[groupIndex].appCall!\n\n switch (resource.type) {\n case GroupResourceType.Account: {\n appCall.accountReferences = appCall.accountReferences ?? []\n const address = resource.data\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.App:\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data)) {\n appCall.appReferences.push(resource.data)\n }\n break\n case GroupResourceType.Box: {\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n if (resource.data.appId !== 0n) {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n break\n }\n case GroupResourceType.ExtraBoxRef:\n appCall.boxReferences = appCall.boxReferences ?? []\n appCall.boxReferences.push({ appId: 0n, name: new Uint8Array(0) })\n break\n case GroupResourceType.AssetHolding: {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.AppLocal: {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.Asset:\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data)) {\n appCall.assetReferences.push(resource.data)\n }\n break\n }\n}\n"],"mappings":";;;;;;;;;;AAkGA,MAAa,iBAAiB,OAC5B,QACA,YACA,iBACA,0BACyB;CACzB,MAAM,aAAaA,0CAA2B,QAAQ,iBAAiB,sBAAsB;CAC7F,MAAM,kBACJ,OAAO,OAAO,oBAAoB,YAC7B,MAAM,WAAW,YAAY,OAAO,gBAAgB,EAAE,wBACvD,OAAO;CACb,MAAM,oBACJ,OAAO,OAAO,sBAAsB,YAC/B,MAAM,WAAW,YAAY,OAAO,kBAAkB,EAAE,wBACzD,OAAO;CACb,MAAM,oBACJ,OAAO,QAAQ,qBAAqB,UAAa,OAAO,QAAQ,eAAe,SAC3E;EAAE,eAAe,OAAO,QAAQ,oBAAoB;EAAG,UAAU,OAAO,QAAQ,cAAc;EAAG,GACjG;CACN,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,UAAa,OAAO,QAAQ,cAAc,SACzE;EAAE,eAAe,OAAO,QAAQ,mBAAmB;EAAG,UAAU,OAAO,QAAQ,aAAa;EAAG,GAC/F;CACN,MAAM,oBACJ,OAAO,sBAAsB,SAAY,OAAO,oBAAoBC,wCAA2B,iBAAkB,kBAAmB;CAGtI,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIC,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO;GACP,YAAY,OAAO,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AAQ;GAErD,MAAM,UAAU,SAAS,KAAK;AAC9B,WAAQ,oBAAoB,QAAQ,qBAAqB,EAAE;AAC3D,OAAI,CAAC,QAAQ,kBAAkB,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,CAC3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB,UAAU;AAC/B,WAAQ,gBAAgB,QAAQ,iBAAiB,EAAE;AACnD,OAAI,CAAC,QAAQ,cAAc,SAAS,SAAS,KAAK,MAAM,CACtD,SAAQ,cAAc,KAAK,SAAS,KAAK,MAAM;GAEjD,MAAM,UAAU,SAAS,KAAK;AAC9B,WAAQ,oBAAoB,QAAQ,qBAAqB,EAAE;AAC3D,OAAI,CAAC,QAAQ,kBAAkB,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,CAC3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB;AACrB,WAAQ,kBAAkB,QAAQ,mBAAmB,EAAE;AACvD,OAAI,CAAC,QAAQ,gBAAgB,SAAS,SAAS,KAAK,CAClD,SAAQ,gBAAgB,KAAK,SAAS,KAAK;AAE7C"}
|
|
1
|
+
{"version":3,"file":"app-call.js","names":["buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","getAddress","AppManager","MAX_OVERALL_REFERENCES","appCall","getApplicationAddress","MAX_ACCOUNT_REFERENCES","groupIndex"],"sources":["../../src/transactions/app-call.ts"],"sourcesContent":["import { SimulateUnnamedResourcesAccessed, SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport {\n Address,\n Expand,\n MAX_ACCOUNT_REFERENCES,\n MAX_OVERALL_REFERENCES,\n ReadableAddress,\n getAddress,\n getApplicationAddress,\n} from '@algorandfoundation/algokit-common'\nimport {\n HoldingReference,\n LocalsReference,\n OnApplicationComplete,\n ResourceReference,\n BoxReference as TransactBoxReference,\n Transaction,\n TransactionType,\n} from '@algorandfoundation/algokit-transact'\nimport { AppManager, BoxIdentifier, BoxReference as UtilsBoxReference } from '../types/app-manager'\nimport { calculateExtraProgramPages } from '../util'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Common parameters for defining an application call transaction. */\nexport type CommonAppCallParams = CommonTransactionParams & {\n /** ID of the application; 0 if the application is being created. */\n appId: bigint\n /** The [on-complete](https://dev.algorand.co/concepts/smart-contracts/avm#oncomplete) action of the call; defaults to no-op. */\n onComplete?: OnApplicationComplete\n /** Any [arguments to pass to the smart contract call](/concepts/smart-contracts/languages/teal/#argument-passing). */\n args?: Uint8Array[]\n /** Any account addresses to add to the [accounts array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n accountReferences?: ReadableAddress[]\n /** The ID of any apps to load to the [foreign apps array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n appReferences?: bigint[]\n /** The ID of any assets to load to the [foreign assets array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n assetReferences?: bigint[]\n /** Any boxes to load to the [boxes array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays).\n *\n * Either the name identifier (which will be set against app ID of `0` i.e.\n * the current app), or a box identifier with the name identifier and app ID.\n */\n boxReferences?: (UtilsBoxReference | BoxIdentifier)[]\n /** Access references unifies `accountReferences`, `appReferences`, `assetReferences`, and `boxReferences` under a single list. If non-empty, these other reference lists must be empty. If access is empty, those other reference lists may be non-empty. */\n accessReferences?: ResourceReference[]\n /** If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check. */\n rejectVersion?: number\n}\n\n/** Parameters to define an app create transaction */\nexport type AppCreateParams = Expand<\n Omit<CommonAppCallParams, 'appId'> & {\n appId?: 0\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** The program to execute for all OnCompletes other than ClearState as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n clearStateProgram: string | Uint8Array\n /** The state schema for the app. This is immutable once the app is created. */\n schema?: {\n /** The number of integers saved in global state. */\n globalInts: number\n /** The number of byte slices saved in global state. */\n globalByteSlices: number\n /** The number of integers saved in local state. */\n localInts: number\n /** The number of byte slices saved in local state. */\n localByteSlices: number\n }\n /** Number of extra pages required for the programs.\n * Defaults to the number needed for the programs in this call if not specified.\n * This is immutable once the app is created. */\n extraProgramPages?: number\n }\n>\n\n/** Parameters to define an app update transaction */\nexport type AppUpdateParams = Expand<\n CommonAppCallParams & {\n onComplete?: OnApplicationComplete.UpdateApplication\n /** The program to execute for all OnCompletes other than ClearState as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n clearStateProgram: string | Uint8Array\n }\n>\n\n/** Parameters to define an application call transaction. */\nexport type AppCallParams = CommonAppCallParams & { onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication> }\n\n/** Common parameters to define an ABI method call transaction. */\nexport type AppMethodCallParams = CommonAppCallParams & {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication | OnApplicationComplete.ClearState>\n}\n\n/** Parameters to define an application delete call transaction. */\nexport type AppDeleteParams = CommonAppCallParams & { onComplete?: OnApplicationComplete.DeleteApplication }\n\nexport const buildAppCreate = async (\n params: AppCreateParams,\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 ? { numByteSlices: params.schema?.globalByteSlices ?? 0, numUints: params.schema?.globalInts ?? 0 }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? { numByteSlices: params.schema?.localByteSlices ?? 0, numUints: params.schema?.localInts ?? 0 }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\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, // App creation always uses ID 0\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: params.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 buildAppUpdate = async (\n params: AppUpdateParams,\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\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: params.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 buildAppCall = (\n params: AppCallParams | AppDeleteParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\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: params.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\n/**\n * Populate transaction-level resources for app call transactions\n */\nexport function populateTransactionResources(\n transaction: Transaction, // NOTE: transaction is mutated in place\n resourcesAccessed: SimulateUnnamedResourcesAccessed,\n groupIndex: number,\n): void {\n if (transaction.type !== TransactionType.AppCall || transaction.appCall === undefined) {\n return\n }\n\n // Check for unexpected resources at transaction level\n if (resourcesAccessed.boxes || resourcesAccessed.extraBoxRefs) {\n throw new Error('Unexpected boxes at the transaction level')\n }\n if (resourcesAccessed.appLocals) {\n throw new Error('Unexpected app locals at the transaction level')\n }\n if (resourcesAccessed.assetHoldings) {\n throw new Error('Unexpected asset holdings at the transaction level')\n }\n\n let accountsCount = 0\n let appsCount = 0\n let assetsCount = 0\n const boxesCount = transaction.appCall.boxReferences?.length ?? 0\n\n // Populate accounts\n if (resourcesAccessed.accounts) {\n transaction.appCall.accountReferences = transaction.appCall.accountReferences ?? []\n for (const account of resourcesAccessed.accounts) {\n const address = account\n if (!transaction.appCall.accountReferences.some((a) => a.equals(address))) {\n transaction.appCall.accountReferences.push(address)\n }\n }\n accountsCount = transaction.appCall.accountReferences.length\n }\n\n // Populate apps\n if (resourcesAccessed.apps) {\n transaction.appCall.appReferences = transaction.appCall.appReferences ?? []\n for (const appId of resourcesAccessed.apps) {\n if (!transaction.appCall.appReferences.includes(appId)) {\n transaction.appCall.appReferences.push(appId)\n }\n }\n appsCount = transaction.appCall.appReferences.length\n }\n\n // Populate assets\n if (resourcesAccessed.assets) {\n transaction.appCall.assetReferences = transaction.appCall.assetReferences ?? []\n for (const assetId of resourcesAccessed.assets) {\n if (!transaction.appCall.assetReferences.includes(assetId)) {\n transaction.appCall.assetReferences.push(assetId)\n }\n }\n assetsCount = transaction.appCall.assetReferences.length\n }\n\n if (accountsCount + assetsCount + appsCount + boxesCount > MAX_OVERALL_REFERENCES) {\n throw new Error(`Resource reference limit of ${MAX_OVERALL_REFERENCES} exceeded in transaction ${groupIndex}`)\n }\n}\n\nenum GroupResourceType {\n Account,\n App,\n Asset,\n Box,\n ExtraBoxRef,\n AssetHolding,\n AppLocal,\n}\n\n/**\n * Populate group-level resources for app call transactions\n */\nexport function populateGroupResources(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n groupResources: SimulateUnnamedResourcesAccessed,\n): void {\n let remainingAccounts = [...(groupResources.accounts ?? [])]\n let remainingApps = [...(groupResources.apps ?? [])]\n let remainingAssets = [...(groupResources.assets ?? [])]\n const remainingBoxes = [...(groupResources.boxes ?? [])]\n\n // Process cross-reference resources first (app locals and asset holdings) as they are most restrictive\n if (groupResources.appLocals) {\n groupResources.appLocals.forEach((appLocal) => {\n populateGroupResource(transactions, { type: GroupResourceType.AppLocal, data: appLocal })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== appLocal.address)\n remainingApps = remainingApps.filter((app) => app !== appLocal.appId)\n })\n }\n\n if (groupResources.assetHoldings) {\n groupResources.assetHoldings.forEach((assetHolding) => {\n populateGroupResource(transactions, { type: GroupResourceType.AssetHolding, data: assetHolding })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== assetHolding.address)\n remainingAssets = remainingAssets.filter((asset) => asset !== assetHolding.assetId)\n })\n }\n\n // Process accounts next because account limit is 4\n remainingAccounts.forEach((account) => {\n populateGroupResource(transactions, { type: GroupResourceType.Account, data: account })\n })\n\n // Process boxes\n remainingBoxes.forEach((boxRef) => {\n populateGroupResource(transactions, { type: GroupResourceType.Box, data: { appId: boxRef.appId, name: boxRef.name } })\n // Remove apps as resource if we're adding it here\n remainingApps = remainingApps.filter((app) => app !== boxRef.appId)\n })\n\n // Process assets\n remainingAssets.forEach((asset) => {\n populateGroupResource(transactions, { type: GroupResourceType.Asset, data: asset })\n })\n\n // Process remaining apps\n remainingApps.forEach((app) => {\n populateGroupResource(transactions, { type: GroupResourceType.App, data: app })\n })\n\n // Handle extra box refs\n if (groupResources.extraBoxRefs) {\n for (let i = 0; i < groupResources.extraBoxRefs; i++) {\n populateGroupResource(transactions, { type: GroupResourceType.ExtraBoxRef })\n }\n }\n}\n\n/**\n * Helper function to check if an app call transaction is below resource limit\n */\nfunction isAppCallBelowResourceLimit(txn: Transaction): boolean {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const accountsCount = txn.appCall?.accountReferences?.length || 0\n const assetsCount = txn.appCall?.assetReferences?.length || 0\n const appsCount = txn.appCall?.appReferences?.length || 0\n const boxesCount = txn.appCall?.boxReferences?.length || 0\n\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n}\n\ntype GroupResourceToPopulate =\n | { type: GroupResourceType.Account; data: Address }\n | { type: GroupResourceType.App; data: bigint }\n | { type: GroupResourceType.Asset; data: bigint }\n | { type: GroupResourceType.Box; data: TransactBoxReference }\n | { type: GroupResourceType.ExtraBoxRef }\n | { type: GroupResourceType.AssetHolding; data: HoldingReference }\n | { type: GroupResourceType.AppLocal; data: LocalsReference }\n\n/**\n * Helper function to populate a specific resource into a transaction group\n */\nfunction populateGroupResource(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n resource: GroupResourceToPopulate,\n): void {\n // For asset holdings and app locals, first try to find a transaction that already has the account available\n if (resource.type === GroupResourceType.AssetHolding || resource.type === GroupResourceType.AppLocal) {\n const address = resource.data.address\n\n // Try to find a transaction that already has the account available\n const groupIndex1 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n\n // Check if account is in foreign accounts array\n if (appCall.accountReferences?.some((a) => a.equals(address))) {\n return true\n }\n\n // Check if account is available as an app account\n if (appCall.appReferences) {\n for (const appId of appCall.appReferences) {\n if (address === getApplicationAddress(appId)) {\n return true\n }\n }\n }\n\n // Check if account appears in any app call transaction fields\n if (txn.sender.equals(address)) {\n return true\n }\n\n return false\n })\n\n if (groupIndex1 !== -1) {\n const appCall = transactions[groupIndex1].appCall!\n if (resource.type === GroupResourceType.AssetHolding) {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n } else {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n return\n }\n\n // Try to find a transaction that has the asset/app available and space for account\n const groupIndex2 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n if ((appCall.accountReferences?.length ?? 0) >= MAX_ACCOUNT_REFERENCES) {\n return false\n }\n\n if (resource.type === GroupResourceType.AssetHolding) {\n return appCall.assetReferences?.includes(resource.data.assetId) || false\n } else {\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n }\n })\n\n if (groupIndex2 !== -1) {\n const appCall = transactions[groupIndex2].appCall!\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.includes(address)) {\n appCall.accountReferences.push(address)\n }\n return\n }\n }\n\n // For boxes, first try to find a transaction that already has the app available\n if (resource.type === GroupResourceType.Box) {\n const groupIndex = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n })\n\n if (groupIndex !== -1) {\n const appCall = transactions[groupIndex].appCall!\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n return\n }\n }\n\n // Find the first transaction that can accommodate the resource\n const groupIndex = transactions.findIndex((txn) => {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const appCall = txn.appCall!\n const accountsCount = appCall.accountReferences?.length ?? 0\n const assetsCount = appCall.assetReferences?.length ?? 0\n const appsCount = appCall.appReferences?.length ?? 0\n const boxesCount = appCall.boxReferences?.length ?? 0\n\n switch (resource.type) {\n case GroupResourceType.Account:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n case GroupResourceType.AssetHolding:\n case GroupResourceType.AppLocal:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n case GroupResourceType.Box:\n if (resource.data.appId !== 0n) {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n } else {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n default:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n })\n\n if (groupIndex === -1) {\n throw new Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n const appCall = transactions[groupIndex].appCall!\n\n switch (resource.type) {\n case GroupResourceType.Account: {\n appCall.accountReferences = appCall.accountReferences ?? []\n const address = resource.data\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.App:\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data)) {\n appCall.appReferences.push(resource.data)\n }\n break\n case GroupResourceType.Box: {\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n if (resource.data.appId !== 0n) {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n break\n }\n case GroupResourceType.ExtraBoxRef:\n appCall.boxReferences = appCall.boxReferences ?? []\n appCall.boxReferences.push({ appId: 0n, name: new Uint8Array(0) })\n break\n case GroupResourceType.AssetHolding: {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.AppLocal: {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.Asset:\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data)) {\n appCall.assetReferences.push(resource.data)\n }\n break\n }\n}\n"],"mappings":";;;;;;;;;;AAkGA,MAAa,iBAAiB,OAC5B,QACA,YACA,iBACA,0BACyB;CACzB,MAAM,aAAaA,0CAA2B,QAAQ,iBAAiB,sBAAsB;CAC7F,MAAM,kBACJ,OAAO,OAAO,oBAAoB,YAC7B,MAAM,WAAW,YAAY,OAAO,gBAAgB,EAAE,wBACvD,OAAO;CACb,MAAM,oBACJ,OAAO,OAAO,sBAAsB,YAC/B,MAAM,WAAW,YAAY,OAAO,kBAAkB,EAAE,wBACzD,OAAO;CACb,MAAM,oBACJ,OAAO,QAAQ,qBAAqB,UAAa,OAAO,QAAQ,eAAe,SAC3E;EAAE,eAAe,OAAO,QAAQ,oBAAoB;EAAG,UAAU,OAAO,QAAQ,cAAc;EAAG,GACjG;CACN,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,UAAa,OAAO,QAAQ,cAAc,SACzE;EAAE,eAAe,OAAO,QAAQ,mBAAmB;EAAG,UAAU,OAAO,QAAQ,aAAa;EAAG,GAC/F;CACN,MAAM,oBACJ,OAAO,sBAAsB,SAAY,OAAO,oBAAoBC,wCAA2B,iBAAkB,kBAAmB;CAGtI,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIC,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO;GACP,YAAY,OAAO,cAAcC,uCAAsB;GACtC;GACE;GACA;GACD;GACC;GACnB,MAAM,OAAO;GACb,GAAI,sBACA,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AAE;AAC3D,OAAI,CAAC,QAAQ,kBAAkB,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,CAC3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB,UAAU;AAC/B,WAAQ,gBAAgB,QAAQ,iBAAiB,EAAE;AACnD,OAAI,CAAC,QAAQ,cAAc,SAAS,SAAS,KAAK,MAAM,CACtD,SAAQ,cAAc,KAAK,SAAS,KAAK,MAAM;GAEjD,MAAM,UAAU,SAAS,KAAK;AAC9B,WAAQ,oBAAoB,QAAQ,qBAAqB,EAAE;AAC3D,OAAI,CAAC,QAAQ,kBAAkB,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,CAC3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB;AACrB,WAAQ,kBAAkB,QAAQ,mBAAmB,EAAE;AACvD,OAAI,CAAC,QAAQ,gBAAgB,SAAS,SAAS,KAAK,CAClD,SAAQ,gBAAgB,KAAK,SAAS,KAAK;AAE7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-call.mjs","names":["appCall","groupIndex"],"sources":["../../src/transactions/app-call.ts"],"sourcesContent":["import { SimulateUnnamedResourcesAccessed, SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport {\n Address,\n MAX_ACCOUNT_REFERENCES,\n MAX_OVERALL_REFERENCES,\n ReadableAddress,\n getAddress,\n getApplicationAddress,\n} from '@algorandfoundation/algokit-common'\nimport {\n HoldingReference,\n LocalsReference,\n OnApplicationComplete,\n ResourceReference,\n BoxReference as TransactBoxReference,\n Transaction,\n TransactionType,\n} from '@algorandfoundation/algokit-transact'\nimport { AppManager, BoxIdentifier, BoxReference as UtilsBoxReference } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Common parameters for defining an application call transaction. */\nexport type CommonAppCallParams = CommonTransactionParams & {\n /** ID of the application; 0 if the application is being created. */\n appId: bigint\n /** The [on-complete](https://dev.algorand.co/concepts/smart-contracts/avm#oncomplete) action of the call; defaults to no-op. */\n onComplete?: OnApplicationComplete\n /** Any [arguments to pass to the smart contract call](/concepts/smart-contracts/languages/teal/#argument-passing). */\n args?: Uint8Array[]\n /** Any account addresses to add to the [accounts array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n accountReferences?: ReadableAddress[]\n /** The ID of any apps to load to the [foreign apps array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n appReferences?: bigint[]\n /** The ID of any assets to load to the [foreign assets array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n assetReferences?: bigint[]\n /** Any boxes to load to the [boxes array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays).\n *\n * Either the name identifier (which will be set against app ID of `0` i.e.\n * the current app), or a box identifier with the name identifier and app ID.\n */\n boxReferences?: (UtilsBoxReference | BoxIdentifier)[]\n /** Access references unifies `accountReferences`, `appReferences`, `assetReferences`, and `boxReferences` under a single list. If non-empty, these other reference lists must be empty. If access is empty, those other reference lists may be non-empty. */\n accessReferences?: ResourceReference[]\n /** If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check. */\n rejectVersion?: number\n}\n\n/** Parameters to define an app create transaction */\nexport type AppCreateParams = Expand<\n Omit<CommonAppCallParams, 'appId'> & {\n appId?: 0\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** The program to execute for all OnCompletes other than ClearState as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n clearStateProgram: string | Uint8Array\n /** The state schema for the app. This is immutable once the app is created. */\n schema?: {\n /** The number of integers saved in global state. */\n globalInts: number\n /** The number of byte slices saved in global state. */\n globalByteSlices: number\n /** The number of integers saved in local state. */\n localInts: number\n /** The number of byte slices saved in local state. */\n localByteSlices: number\n }\n /** Number of extra pages required for the programs.\n * Defaults to the number needed for the programs in this call if not specified.\n * This is immutable once the app is created. */\n extraProgramPages?: number\n }\n>\n\n/** Parameters to define an app update transaction */\nexport type AppUpdateParams = Expand<\n CommonAppCallParams & {\n onComplete?: OnApplicationComplete.UpdateApplication\n /** The program to execute for all OnCompletes other than ClearState as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n clearStateProgram: string | Uint8Array\n }\n>\n\n/** Parameters to define an application call transaction. */\nexport type AppCallParams = CommonAppCallParams & { onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication> }\n\n/** Common parameters to define an ABI method call transaction. */\nexport type AppMethodCallParams = CommonAppCallParams & {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication | OnApplicationComplete.ClearState>\n}\n\n/** Parameters to define an application delete call transaction. */\nexport type AppDeleteParams = CommonAppCallParams & { onComplete?: OnApplicationComplete.DeleteApplication }\n\nexport const buildAppCreate = async (\n params: AppCreateParams,\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 ? { numByteSlices: params.schema?.globalByteSlices ?? 0, numUints: params.schema?.globalInts ?? 0 }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? { numByteSlices: params.schema?.localByteSlices ?? 0, numUints: params.schema?.localInts ?? 0 }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\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, // App creation always uses ID 0\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: params.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 buildAppUpdate = async (\n params: AppUpdateParams,\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\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: params.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 buildAppCall = (\n params: AppCallParams | AppDeleteParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\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: params.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\n/**\n * Populate transaction-level resources for app call transactions\n */\nexport function populateTransactionResources(\n transaction: Transaction, // NOTE: transaction is mutated in place\n resourcesAccessed: SimulateUnnamedResourcesAccessed,\n groupIndex: number,\n): void {\n if (transaction.type !== TransactionType.AppCall || transaction.appCall === undefined) {\n return\n }\n\n // Check for unexpected resources at transaction level\n if (resourcesAccessed.boxes || resourcesAccessed.extraBoxRefs) {\n throw new Error('Unexpected boxes at the transaction level')\n }\n if (resourcesAccessed.appLocals) {\n throw new Error('Unexpected app locals at the transaction level')\n }\n if (resourcesAccessed.assetHoldings) {\n throw new Error('Unexpected asset holdings at the transaction level')\n }\n\n let accountsCount = 0\n let appsCount = 0\n let assetsCount = 0\n const boxesCount = transaction.appCall.boxReferences?.length ?? 0\n\n // Populate accounts\n if (resourcesAccessed.accounts) {\n transaction.appCall.accountReferences = transaction.appCall.accountReferences ?? []\n for (const account of resourcesAccessed.accounts) {\n const address = account\n if (!transaction.appCall.accountReferences.some((a) => a.equals(address))) {\n transaction.appCall.accountReferences.push(address)\n }\n }\n accountsCount = transaction.appCall.accountReferences.length\n }\n\n // Populate apps\n if (resourcesAccessed.apps) {\n transaction.appCall.appReferences = transaction.appCall.appReferences ?? []\n for (const appId of resourcesAccessed.apps) {\n if (!transaction.appCall.appReferences.includes(appId)) {\n transaction.appCall.appReferences.push(appId)\n }\n }\n appsCount = transaction.appCall.appReferences.length\n }\n\n // Populate assets\n if (resourcesAccessed.assets) {\n transaction.appCall.assetReferences = transaction.appCall.assetReferences ?? []\n for (const assetId of resourcesAccessed.assets) {\n if (!transaction.appCall.assetReferences.includes(assetId)) {\n transaction.appCall.assetReferences.push(assetId)\n }\n }\n assetsCount = transaction.appCall.assetReferences.length\n }\n\n if (accountsCount + assetsCount + appsCount + boxesCount > MAX_OVERALL_REFERENCES) {\n throw new Error(`Resource reference limit of ${MAX_OVERALL_REFERENCES} exceeded in transaction ${groupIndex}`)\n }\n}\n\nenum GroupResourceType {\n Account,\n App,\n Asset,\n Box,\n ExtraBoxRef,\n AssetHolding,\n AppLocal,\n}\n\n/**\n * Populate group-level resources for app call transactions\n */\nexport function populateGroupResources(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n groupResources: SimulateUnnamedResourcesAccessed,\n): void {\n let remainingAccounts = [...(groupResources.accounts ?? [])]\n let remainingApps = [...(groupResources.apps ?? [])]\n let remainingAssets = [...(groupResources.assets ?? [])]\n const remainingBoxes = [...(groupResources.boxes ?? [])]\n\n // Process cross-reference resources first (app locals and asset holdings) as they are most restrictive\n if (groupResources.appLocals) {\n groupResources.appLocals.forEach((appLocal) => {\n populateGroupResource(transactions, { type: GroupResourceType.AppLocal, data: appLocal })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== appLocal.address)\n remainingApps = remainingApps.filter((app) => app !== appLocal.appId)\n })\n }\n\n if (groupResources.assetHoldings) {\n groupResources.assetHoldings.forEach((assetHolding) => {\n populateGroupResource(transactions, { type: GroupResourceType.AssetHolding, data: assetHolding })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== assetHolding.address)\n remainingAssets = remainingAssets.filter((asset) => asset !== assetHolding.assetId)\n })\n }\n\n // Process accounts next because account limit is 4\n remainingAccounts.forEach((account) => {\n populateGroupResource(transactions, { type: GroupResourceType.Account, data: account })\n })\n\n // Process boxes\n remainingBoxes.forEach((boxRef) => {\n populateGroupResource(transactions, { type: GroupResourceType.Box, data: { appId: boxRef.appId, name: boxRef.name } })\n // Remove apps as resource if we're adding it here\n remainingApps = remainingApps.filter((app) => app !== boxRef.appId)\n })\n\n // Process assets\n remainingAssets.forEach((asset) => {\n populateGroupResource(transactions, { type: GroupResourceType.Asset, data: asset })\n })\n\n // Process remaining apps\n remainingApps.forEach((app) => {\n populateGroupResource(transactions, { type: GroupResourceType.App, data: app })\n })\n\n // Handle extra box refs\n if (groupResources.extraBoxRefs) {\n for (let i = 0; i < groupResources.extraBoxRefs; i++) {\n populateGroupResource(transactions, { type: GroupResourceType.ExtraBoxRef })\n }\n }\n}\n\n/**\n * Helper function to check if an app call transaction is below resource limit\n */\nfunction isAppCallBelowResourceLimit(txn: Transaction): boolean {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const accountsCount = txn.appCall?.accountReferences?.length || 0\n const assetsCount = txn.appCall?.assetReferences?.length || 0\n const appsCount = txn.appCall?.appReferences?.length || 0\n const boxesCount = txn.appCall?.boxReferences?.length || 0\n\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n}\n\ntype GroupResourceToPopulate =\n | { type: GroupResourceType.Account; data: Address }\n | { type: GroupResourceType.App; data: bigint }\n | { type: GroupResourceType.Asset; data: bigint }\n | { type: GroupResourceType.Box; data: TransactBoxReference }\n | { type: GroupResourceType.ExtraBoxRef }\n | { type: GroupResourceType.AssetHolding; data: HoldingReference }\n | { type: GroupResourceType.AppLocal; data: LocalsReference }\n\n/**\n * Helper function to populate a specific resource into a transaction group\n */\nfunction populateGroupResource(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n resource: GroupResourceToPopulate,\n): void {\n // For asset holdings and app locals, first try to find a transaction that already has the account available\n if (resource.type === GroupResourceType.AssetHolding || resource.type === GroupResourceType.AppLocal) {\n const address = resource.data.address\n\n // Try to find a transaction that already has the account available\n const groupIndex1 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n\n // Check if account is in foreign accounts array\n if (appCall.accountReferences?.some((a) => a.equals(address))) {\n return true\n }\n\n // Check if account is available as an app account\n if (appCall.appReferences) {\n for (const appId of appCall.appReferences) {\n if (address === getApplicationAddress(appId)) {\n return true\n }\n }\n }\n\n // Check if account appears in any app call transaction fields\n if (txn.sender.equals(address)) {\n return true\n }\n\n return false\n })\n\n if (groupIndex1 !== -1) {\n const appCall = transactions[groupIndex1].appCall!\n if (resource.type === GroupResourceType.AssetHolding) {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n } else {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n return\n }\n\n // Try to find a transaction that has the asset/app available and space for account\n const groupIndex2 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n if ((appCall.accountReferences?.length ?? 0) >= MAX_ACCOUNT_REFERENCES) {\n return false\n }\n\n if (resource.type === GroupResourceType.AssetHolding) {\n return appCall.assetReferences?.includes(resource.data.assetId) || false\n } else {\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n }\n })\n\n if (groupIndex2 !== -1) {\n const appCall = transactions[groupIndex2].appCall!\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.includes(address)) {\n appCall.accountReferences.push(address)\n }\n return\n }\n }\n\n // For boxes, first try to find a transaction that already has the app available\n if (resource.type === GroupResourceType.Box) {\n const groupIndex = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n })\n\n if (groupIndex !== -1) {\n const appCall = transactions[groupIndex].appCall!\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n return\n }\n }\n\n // Find the first transaction that can accommodate the resource\n const groupIndex = transactions.findIndex((txn) => {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const appCall = txn.appCall!\n const accountsCount = appCall.accountReferences?.length ?? 0\n const assetsCount = appCall.assetReferences?.length ?? 0\n const appsCount = appCall.appReferences?.length ?? 0\n const boxesCount = appCall.boxReferences?.length ?? 0\n\n switch (resource.type) {\n case GroupResourceType.Account:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n case GroupResourceType.AssetHolding:\n case GroupResourceType.AppLocal:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n case GroupResourceType.Box:\n if (resource.data.appId !== 0n) {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n } else {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n default:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n })\n\n if (groupIndex === -1) {\n throw new Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n const appCall = transactions[groupIndex].appCall!\n\n switch (resource.type) {\n case GroupResourceType.Account: {\n appCall.accountReferences = appCall.accountReferences ?? []\n const address = resource.data\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.App:\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data)) {\n appCall.appReferences.push(resource.data)\n }\n break\n case GroupResourceType.Box: {\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n if (resource.data.appId !== 0n) {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n break\n }\n case GroupResourceType.ExtraBoxRef:\n appCall.boxReferences = appCall.boxReferences ?? []\n appCall.boxReferences.push({ appId: 0n, name: new Uint8Array(0) })\n break\n case GroupResourceType.AssetHolding: {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.AppLocal: {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.Asset:\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data)) {\n appCall.assetReferences.push(resource.data)\n }\n break\n }\n}\n"],"mappings":";;;;;;;;;;AAkGA,MAAa,iBAAiB,OAC5B,QACA,YACA,iBACA,0BACyB;CACzB,MAAM,aAAa,2BAA2B,QAAQ,iBAAiB,sBAAsB;CAC7F,MAAM,kBACJ,OAAO,OAAO,oBAAoB,YAC7B,MAAM,WAAW,YAAY,OAAO,gBAAgB,EAAE,wBACvD,OAAO;CACb,MAAM,oBACJ,OAAO,OAAO,sBAAsB,YAC/B,MAAM,WAAW,YAAY,OAAO,kBAAkB,EAAE,wBACzD,OAAO;CACb,MAAM,oBACJ,OAAO,QAAQ,qBAAqB,UAAa,OAAO,QAAQ,eAAe,SAC3E;EAAE,eAAe,OAAO,QAAQ,oBAAoB;EAAG,UAAU,OAAO,QAAQ,cAAc;EAAG,GACjG;CACN,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,UAAa,OAAO,QAAQ,cAAc,SACzE;EAAE,eAAe,OAAO,QAAQ,mBAAmB;EAAG,UAAU,OAAO,QAAQ,aAAa;EAAG,GAC/F;CACN,MAAM,oBACJ,OAAO,sBAAsB,SAAY,OAAO,oBAAoB,2BAA2B,iBAAkB,kBAAmB;CAGtI,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,MAAM,gBAAgB;EACtB,SAAS;GACP,OAAO;GACP,YAAY,OAAO,cAAc,sBAAsB;GACtC;GACE;GACA;GACD;GACC;GACnB,MAAM,OAAO;GACb,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,OAAO,mBAAmB,KAAK,MAAM,WAAW,EAAE,CAAC;IACtE,eAAe,OAAO;IACtB,iBAAiB,OAAO;IACxB,eAAe,OAAO,eAAe,IAAI,WA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,CAAC,QAAQ,cAAc,SAAS,SAAS,KAAK,MAAM,CACtD,SAAQ,cAAc,KAAK,SAAS,KAAK,MAAM;GAEjD,MAAM,UAAU,SAAS,KAAK;AAC9B,WAAQ,oBAAoB,QAAQ,qBAAqB,EAAE;AAC3D,OAAI,CAAC,QAAQ,kBAAkB,MAAM,MAAM,EAAE,OAAO,QAAQ,CAAC,CAC3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB;AACrB,WAAQ,kBAAkB,QAAQ,mBAAmB,EAAE;AACvD,OAAI,CAAC,QAAQ,gBAAgB,SAAS,SAAS,KAAK,CAClD,SAAQ,gBAAgB,KAAK,SAAS,KAAK;AAE7C"}
|
|
1
|
+
{"version":3,"file":"app-call.mjs","names":["appCall","groupIndex"],"sources":["../../src/transactions/app-call.ts"],"sourcesContent":["import { SimulateUnnamedResourcesAccessed, SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport {\n Address,\n Expand,\n MAX_ACCOUNT_REFERENCES,\n MAX_OVERALL_REFERENCES,\n ReadableAddress,\n getAddress,\n getApplicationAddress,\n} from '@algorandfoundation/algokit-common'\nimport {\n HoldingReference,\n LocalsReference,\n OnApplicationComplete,\n ResourceReference,\n BoxReference as TransactBoxReference,\n Transaction,\n TransactionType,\n} from '@algorandfoundation/algokit-transact'\nimport { AppManager, BoxIdentifier, BoxReference as UtilsBoxReference } from '../types/app-manager'\nimport { calculateExtraProgramPages } from '../util'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Common parameters for defining an application call transaction. */\nexport type CommonAppCallParams = CommonTransactionParams & {\n /** ID of the application; 0 if the application is being created. */\n appId: bigint\n /** The [on-complete](https://dev.algorand.co/concepts/smart-contracts/avm#oncomplete) action of the call; defaults to no-op. */\n onComplete?: OnApplicationComplete\n /** Any [arguments to pass to the smart contract call](/concepts/smart-contracts/languages/teal/#argument-passing). */\n args?: Uint8Array[]\n /** Any account addresses to add to the [accounts array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n accountReferences?: ReadableAddress[]\n /** The ID of any apps to load to the [foreign apps array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n appReferences?: bigint[]\n /** The ID of any assets to load to the [foreign assets array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays). */\n assetReferences?: bigint[]\n /** Any boxes to load to the [boxes array](https://dev.algorand.co/concepts/smart-contracts/resource-usage#what-are-reference-arrays).\n *\n * Either the name identifier (which will be set against app ID of `0` i.e.\n * the current app), or a box identifier with the name identifier and app ID.\n */\n boxReferences?: (UtilsBoxReference | BoxIdentifier)[]\n /** Access references unifies `accountReferences`, `appReferences`, `assetReferences`, and `boxReferences` under a single list. If non-empty, these other reference lists must be empty. If access is empty, those other reference lists may be non-empty. */\n accessReferences?: ResourceReference[]\n /** If set, the transaction will be rejected when the app's version is greater than or equal to this value. This can be used to prevent calling an app after it has been updated. Set to 0 or leave undefined to skip the version check. */\n rejectVersion?: number\n}\n\n/** Parameters to define an app create transaction */\nexport type AppCreateParams = Expand<\n Omit<CommonAppCallParams, 'appId'> & {\n appId?: 0\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n /** The program to execute for all OnCompletes other than ClearState as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). */\n clearStateProgram: string | Uint8Array\n /** The state schema for the app. This is immutable once the app is created. */\n schema?: {\n /** The number of integers saved in global state. */\n globalInts: number\n /** The number of byte slices saved in global state. */\n globalByteSlices: number\n /** The number of integers saved in local state. */\n localInts: number\n /** The number of byte slices saved in local state. */\n localByteSlices: number\n }\n /** Number of extra pages required for the programs.\n * Defaults to the number needed for the programs in this call if not specified.\n * This is immutable once the app is created. */\n extraProgramPages?: number\n }\n>\n\n/** Parameters to define an app update transaction */\nexport type AppUpdateParams = Expand<\n CommonAppCallParams & {\n onComplete?: OnApplicationComplete.UpdateApplication\n /** The program to execute for all OnCompletes other than ClearState as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n approvalProgram: string | Uint8Array\n /** The program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) */\n clearStateProgram: string | Uint8Array\n }\n>\n\n/** Parameters to define an application call transaction. */\nexport type AppCallParams = CommonAppCallParams & { onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication> }\n\n/** Common parameters to define an ABI method call transaction. */\nexport type AppMethodCallParams = CommonAppCallParams & {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication | OnApplicationComplete.ClearState>\n}\n\n/** Parameters to define an application delete call transaction. */\nexport type AppDeleteParams = CommonAppCallParams & { onComplete?: OnApplicationComplete.DeleteApplication }\n\nexport const buildAppCreate = async (\n params: AppCreateParams,\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 ? { numByteSlices: params.schema?.globalByteSlices ?? 0, numUints: params.schema?.globalInts ?? 0 }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? { numByteSlices: params.schema?.localByteSlices ?? 0, numUints: params.schema?.localInts ?? 0 }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\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, // App creation always uses ID 0\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: params.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 buildAppUpdate = async (\n params: AppUpdateParams,\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\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: params.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 buildAppCall = (\n params: AppCallParams | AppDeleteParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\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: params.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\n/**\n * Populate transaction-level resources for app call transactions\n */\nexport function populateTransactionResources(\n transaction: Transaction, // NOTE: transaction is mutated in place\n resourcesAccessed: SimulateUnnamedResourcesAccessed,\n groupIndex: number,\n): void {\n if (transaction.type !== TransactionType.AppCall || transaction.appCall === undefined) {\n return\n }\n\n // Check for unexpected resources at transaction level\n if (resourcesAccessed.boxes || resourcesAccessed.extraBoxRefs) {\n throw new Error('Unexpected boxes at the transaction level')\n }\n if (resourcesAccessed.appLocals) {\n throw new Error('Unexpected app locals at the transaction level')\n }\n if (resourcesAccessed.assetHoldings) {\n throw new Error('Unexpected asset holdings at the transaction level')\n }\n\n let accountsCount = 0\n let appsCount = 0\n let assetsCount = 0\n const boxesCount = transaction.appCall.boxReferences?.length ?? 0\n\n // Populate accounts\n if (resourcesAccessed.accounts) {\n transaction.appCall.accountReferences = transaction.appCall.accountReferences ?? []\n for (const account of resourcesAccessed.accounts) {\n const address = account\n if (!transaction.appCall.accountReferences.some((a) => a.equals(address))) {\n transaction.appCall.accountReferences.push(address)\n }\n }\n accountsCount = transaction.appCall.accountReferences.length\n }\n\n // Populate apps\n if (resourcesAccessed.apps) {\n transaction.appCall.appReferences = transaction.appCall.appReferences ?? []\n for (const appId of resourcesAccessed.apps) {\n if (!transaction.appCall.appReferences.includes(appId)) {\n transaction.appCall.appReferences.push(appId)\n }\n }\n appsCount = transaction.appCall.appReferences.length\n }\n\n // Populate assets\n if (resourcesAccessed.assets) {\n transaction.appCall.assetReferences = transaction.appCall.assetReferences ?? []\n for (const assetId of resourcesAccessed.assets) {\n if (!transaction.appCall.assetReferences.includes(assetId)) {\n transaction.appCall.assetReferences.push(assetId)\n }\n }\n assetsCount = transaction.appCall.assetReferences.length\n }\n\n if (accountsCount + assetsCount + appsCount + boxesCount > MAX_OVERALL_REFERENCES) {\n throw new Error(`Resource reference limit of ${MAX_OVERALL_REFERENCES} exceeded in transaction ${groupIndex}`)\n }\n}\n\nenum GroupResourceType {\n Account,\n App,\n Asset,\n Box,\n ExtraBoxRef,\n AssetHolding,\n AppLocal,\n}\n\n/**\n * Populate group-level resources for app call transactions\n */\nexport function populateGroupResources(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n groupResources: SimulateUnnamedResourcesAccessed,\n): void {\n let remainingAccounts = [...(groupResources.accounts ?? [])]\n let remainingApps = [...(groupResources.apps ?? [])]\n let remainingAssets = [...(groupResources.assets ?? [])]\n const remainingBoxes = [...(groupResources.boxes ?? [])]\n\n // Process cross-reference resources first (app locals and asset holdings) as they are most restrictive\n if (groupResources.appLocals) {\n groupResources.appLocals.forEach((appLocal) => {\n populateGroupResource(transactions, { type: GroupResourceType.AppLocal, data: appLocal })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== appLocal.address)\n remainingApps = remainingApps.filter((app) => app !== appLocal.appId)\n })\n }\n\n if (groupResources.assetHoldings) {\n groupResources.assetHoldings.forEach((assetHolding) => {\n populateGroupResource(transactions, { type: GroupResourceType.AssetHolding, data: assetHolding })\n // Remove resources from remaining if we're adding them here\n remainingAccounts = remainingAccounts.filter((acc) => acc !== assetHolding.address)\n remainingAssets = remainingAssets.filter((asset) => asset !== assetHolding.assetId)\n })\n }\n\n // Process accounts next because account limit is 4\n remainingAccounts.forEach((account) => {\n populateGroupResource(transactions, { type: GroupResourceType.Account, data: account })\n })\n\n // Process boxes\n remainingBoxes.forEach((boxRef) => {\n populateGroupResource(transactions, { type: GroupResourceType.Box, data: { appId: boxRef.appId, name: boxRef.name } })\n // Remove apps as resource if we're adding it here\n remainingApps = remainingApps.filter((app) => app !== boxRef.appId)\n })\n\n // Process assets\n remainingAssets.forEach((asset) => {\n populateGroupResource(transactions, { type: GroupResourceType.Asset, data: asset })\n })\n\n // Process remaining apps\n remainingApps.forEach((app) => {\n populateGroupResource(transactions, { type: GroupResourceType.App, data: app })\n })\n\n // Handle extra box refs\n if (groupResources.extraBoxRefs) {\n for (let i = 0; i < groupResources.extraBoxRefs; i++) {\n populateGroupResource(transactions, { type: GroupResourceType.ExtraBoxRef })\n }\n }\n}\n\n/**\n * Helper function to check if an app call transaction is below resource limit\n */\nfunction isAppCallBelowResourceLimit(txn: Transaction): boolean {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const accountsCount = txn.appCall?.accountReferences?.length || 0\n const assetsCount = txn.appCall?.assetReferences?.length || 0\n const appsCount = txn.appCall?.appReferences?.length || 0\n const boxesCount = txn.appCall?.boxReferences?.length || 0\n\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n}\n\ntype GroupResourceToPopulate =\n | { type: GroupResourceType.Account; data: Address }\n | { type: GroupResourceType.App; data: bigint }\n | { type: GroupResourceType.Asset; data: bigint }\n | { type: GroupResourceType.Box; data: TransactBoxReference }\n | { type: GroupResourceType.ExtraBoxRef }\n | { type: GroupResourceType.AssetHolding; data: HoldingReference }\n | { type: GroupResourceType.AppLocal; data: LocalsReference }\n\n/**\n * Helper function to populate a specific resource into a transaction group\n */\nfunction populateGroupResource(\n transactions: Transaction[], // NOTE: transactions are mutated in place\n resource: GroupResourceToPopulate,\n): void {\n // For asset holdings and app locals, first try to find a transaction that already has the account available\n if (resource.type === GroupResourceType.AssetHolding || resource.type === GroupResourceType.AppLocal) {\n const address = resource.data.address\n\n // Try to find a transaction that already has the account available\n const groupIndex1 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n\n // Check if account is in foreign accounts array\n if (appCall.accountReferences?.some((a) => a.equals(address))) {\n return true\n }\n\n // Check if account is available as an app account\n if (appCall.appReferences) {\n for (const appId of appCall.appReferences) {\n if (address === getApplicationAddress(appId)) {\n return true\n }\n }\n }\n\n // Check if account appears in any app call transaction fields\n if (txn.sender.equals(address)) {\n return true\n }\n\n return false\n })\n\n if (groupIndex1 !== -1) {\n const appCall = transactions[groupIndex1].appCall!\n if (resource.type === GroupResourceType.AssetHolding) {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n } else {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n return\n }\n\n // Try to find a transaction that has the asset/app available and space for account\n const groupIndex2 = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n if ((appCall.accountReferences?.length ?? 0) >= MAX_ACCOUNT_REFERENCES) {\n return false\n }\n\n if (resource.type === GroupResourceType.AssetHolding) {\n return appCall.assetReferences?.includes(resource.data.assetId) || false\n } else {\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n }\n })\n\n if (groupIndex2 !== -1) {\n const appCall = transactions[groupIndex2].appCall!\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.includes(address)) {\n appCall.accountReferences.push(address)\n }\n return\n }\n }\n\n // For boxes, first try to find a transaction that already has the app available\n if (resource.type === GroupResourceType.Box) {\n const groupIndex = transactions.findIndex((txn) => {\n if (!isAppCallBelowResourceLimit(txn)) {\n return false\n }\n\n const appCall = txn.appCall!\n return appCall.appReferences?.includes(resource.data.appId) || appCall.appId === resource.data.appId\n })\n\n if (groupIndex !== -1) {\n const appCall = transactions[groupIndex].appCall!\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n return\n }\n }\n\n // Find the first transaction that can accommodate the resource\n const groupIndex = transactions.findIndex((txn) => {\n if (txn.type !== TransactionType.AppCall) {\n return false\n }\n if (txn.appCall?.accessReferences?.length) {\n return false\n }\n\n const appCall = txn.appCall!\n const accountsCount = appCall.accountReferences?.length ?? 0\n const assetsCount = appCall.assetReferences?.length ?? 0\n const appsCount = appCall.appReferences?.length ?? 0\n const boxesCount = appCall.boxReferences?.length ?? 0\n\n switch (resource.type) {\n case GroupResourceType.Account:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n case GroupResourceType.AssetHolding:\n case GroupResourceType.AppLocal:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n case GroupResourceType.Box:\n if (resource.data.appId !== 0n) {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES - 1\n } else {\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n default:\n return accountsCount + assetsCount + appsCount + boxesCount < MAX_OVERALL_REFERENCES\n }\n })\n\n if (groupIndex === -1) {\n throw new Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n const appCall = transactions[groupIndex].appCall!\n\n switch (resource.type) {\n case GroupResourceType.Account: {\n appCall.accountReferences = appCall.accountReferences ?? []\n const address = resource.data\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.App:\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data)) {\n appCall.appReferences.push(resource.data)\n }\n break\n case GroupResourceType.Box: {\n appCall.boxReferences = appCall.boxReferences ?? []\n const exists = appCall.boxReferences.some(\n (b) =>\n b.appId === resource.data.appId &&\n b.name.length === resource.data.name.length &&\n b.name.every((byte, i) => byte === resource.data.name[i]),\n )\n if (!exists) {\n appCall.boxReferences.push({ appId: resource.data.appId, name: resource.data.name })\n }\n if (resource.data.appId !== 0n) {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n }\n break\n }\n case GroupResourceType.ExtraBoxRef:\n appCall.boxReferences = appCall.boxReferences ?? []\n appCall.boxReferences.push({ appId: 0n, name: new Uint8Array(0) })\n break\n case GroupResourceType.AssetHolding: {\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data.assetId)) {\n appCall.assetReferences.push(resource.data.assetId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.AppLocal: {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.appId)) {\n appCall.appReferences.push(resource.data.appId)\n }\n const address = resource.data.address\n appCall.accountReferences = appCall.accountReferences ?? []\n if (!appCall.accountReferences.some((a) => a.equals(address))) {\n appCall.accountReferences.push(address)\n }\n break\n }\n case GroupResourceType.Asset:\n appCall.assetReferences = appCall.assetReferences ?? []\n if (!appCall.assetReferences.includes(resource.data)) {\n appCall.assetReferences.push(resource.data)\n }\n break\n }\n}\n"],"mappings":";;;;;;;;;;AAkGA,MAAa,iBAAiB,OAC5B,QACA,YACA,iBACA,0BACyB;CACzB,MAAM,aAAa,2BA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C3D,SAAQ,kBAAkB,KAAK,QAAQ;AAEzC;;EAEF,KAAK,kBAAkB;AACrB,WAAQ,kBAAkB,QAAQ,mBAAmB,EAAE;AACvD,OAAI,CAAC,QAAQ,gBAAgB,SAAS,SAAS,KAAK,CAClD,SAAQ,gBAAgB,KAAK,SAAS,KAAK;AAE7C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Expand } from "../packages/common/src/expand.js";
|
|
1
2
|
import { ABIValue } from "../packages/abi/src/abi-value.js";
|
|
2
3
|
import { ABIMethod } from "../packages/abi/src/abi-method.js";
|
|
3
4
|
import { Transaction } from "../packages/transact/src/transactions/transaction.js";
|
|
4
|
-
import { Expand } from "../types/expand.js";
|
|
5
5
|
import { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from "./app-call.js";
|
|
6
6
|
import { TransactionWithSigner } from "../transaction/transaction.js";
|
|
7
7
|
|