@algorandfoundation/algokit-utils 10.0.0-alpha.1 → 10.0.0-alpha.10
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/README.md +27 -5
- package/_virtual/rolldown_runtime.js +20 -11
- package/_virtual/rolldown_runtime.mjs +10 -5
- package/algo25/index.d.ts +2 -0
- package/algo25/index.js +9 -0
- package/algo25/index.mjs +3 -0
- package/algod-client/index.d.ts +2 -5
- package/package.json +1 -1
- package/packages/abi/src/abi-method.d.ts +1 -1
- package/packages/abi/src/abi-method.js.map +1 -1
- package/packages/abi/src/abi-method.mjs.map +1 -1
- package/packages/abi/src/abi-type.d.ts +1 -1
- package/packages/abi/src/abi-type.js +2 -1
- package/packages/abi/src/abi-type.js.map +1 -1
- package/packages/abi/src/abi-type.mjs +2 -1
- package/packages/abi/src/abi-type.mjs.map +1 -1
- package/packages/abi/src/arc56-contract.js +1 -0
- package/packages/abi/src/arc56-contract.js.map +1 -1
- package/packages/abi/src/arc56-contract.mjs +1 -0
- package/packages/abi/src/arc56-contract.mjs.map +1 -1
- package/packages/algo25/src/english.js.map +1 -1
- package/packages/algo25/src/english.mjs.map +1 -1
- package/packages/algo25/src/index.d.ts +40 -0
- package/packages/algo25/src/index.js +44 -0
- package/packages/algo25/src/index.js.map +1 -1
- package/packages/algo25/src/index.mjs +39 -1
- package/packages/algo25/src/index.mjs.map +1 -1
- package/packages/algod_client/src/apis/api-service.d.ts +44 -44
- package/packages/algod_client/src/apis/api-service.js +153 -153
- package/packages/algod_client/src/apis/api-service.js.map +1 -1
- package/packages/algod_client/src/apis/api-service.mjs +153 -153
- package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
- package/packages/algod_client/src/core/api-error.js +3 -1
- package/packages/algod_client/src/core/api-error.js.map +1 -1
- package/packages/algod_client/src/core/api-error.mjs +3 -1
- package/packages/algod_client/src/core/api-error.mjs.map +1 -1
- package/packages/algod_client/src/core/model-runtime.js +4 -4
- package/packages/algod_client/src/core/model-runtime.js.map +1 -1
- package/packages/algod_client/src/core/model-runtime.mjs +6 -6
- package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/algod_client/src/models/account-participation.js +4 -4
- package/packages/algod_client/src/models/account-participation.js.map +1 -1
- package/packages/algod_client/src/models/account-participation.mjs +4 -4
- package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/algod_client/src/models/application-state-schema.js +2 -2
- package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
- package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/algod_client/src/models/asset-params.js +2 -1
- package/packages/algod_client/src/models/asset-params.js.map +1 -1
- package/packages/algod_client/src/models/asset-params.mjs +2 -1
- package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
- package/packages/algod_client/src/models/block-response.js +1 -2
- package/packages/algod_client/src/models/block-response.js.map +1 -1
- package/packages/algod_client/src/models/block-response.mjs +2 -3
- package/packages/algod_client/src/models/block-response.mjs.map +1 -1
- package/packages/algod_client/src/models/block.d.ts +49 -29
- package/packages/algod_client/src/models/block.js +174 -98
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs +174 -98
- package/packages/algod_client/src/models/block.mjs.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
- package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
- package/packages/common/src/address.js +0 -14
- package/packages/common/src/address.js.map +1 -1
- package/packages/common/src/address.mjs +1 -14
- package/packages/common/src/address.mjs.map +1 -1
- package/packages/common/src/codecs/composite/map.js +7 -4
- package/packages/common/src/codecs/composite/map.js.map +1 -1
- package/packages/common/src/codecs/composite/map.mjs +7 -4
- package/packages/common/src/codecs/composite/map.mjs.map +1 -1
- package/packages/common/src/codecs/composite/record.js +0 -1
- package/packages/common/src/codecs/composite/record.js.map +1 -1
- package/packages/common/src/codecs/primitives/address.js +0 -1
- package/packages/common/src/codecs/primitives/address.js.map +1 -1
- package/packages/common/src/codecs/primitives/bytes.js +0 -1
- package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
- package/packages/common/src/codecs/wire.js +0 -1
- package/packages/common/src/codecs/wire.js.map +1 -1
- package/packages/common/src/json.mjs +2 -2
- package/packages/common/src/json.mjs.map +1 -1
- package/packages/common/src/msgpack.js +0 -1
- package/packages/common/src/msgpack.js.map +1 -1
- package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
- package/packages/indexer_client/src/apis/api-service.js +12 -12
- package/packages/indexer_client/src/apis/api-service.js.map +1 -1
- package/packages/indexer_client/src/apis/api-service.mjs +12 -12
- package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
- package/packages/indexer_client/src/core/api-error.js +3 -1
- package/packages/indexer_client/src/core/api-error.js.map +1 -1
- package/packages/indexer_client/src/core/api-error.mjs +3 -1
- package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.js +4 -4
- package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.mjs +6 -6
- package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/indexer_client/src/models/account-participation.js +4 -4
- package/packages/indexer_client/src/models/account-participation.js.map +1 -1
- package/packages/indexer_client/src/models/account-participation.mjs +4 -4
- package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/asset-params.js +2 -1
- package/packages/indexer_client/src/models/asset-params.js.map +1 -1
- package/packages/indexer_client/src/models/asset-params.mjs +2 -1
- package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
- package/packages/indexer_client/src/models/block.js +8 -8
- package/packages/indexer_client/src/models/block.js.map +1 -1
- package/packages/indexer_client/src/models/block.mjs +8 -8
- package/packages/indexer_client/src/models/block.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta.js +2 -2
- package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/state-schema.js +2 -2
- package/packages/indexer_client/src/models/state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/teal-key-value.js +2 -2
- package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction.d.ts +2 -2
- package/packages/indexer_client/src/models/transaction.js +6 -5
- package/packages/indexer_client/src/models/transaction.js.map +1 -1
- package/packages/indexer_client/src/models/transaction.mjs +6 -5
- package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
- package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
- package/packages/kmd_client/src/apis/api-service.js +32 -32
- package/packages/kmd_client/src/apis/api-service.js.map +1 -1
- package/packages/kmd_client/src/apis/api-service.mjs +32 -32
- package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
- package/packages/kmd_client/src/core/api-error.js +3 -1
- package/packages/kmd_client/src/core/api-error.js.map +1 -1
- package/packages/kmd_client/src/core/api-error.mjs +3 -1
- package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.js +4 -4
- package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.mjs +6 -6
- package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/sdk/src/encoding/encoding.js +12 -2
- package/packages/sdk/src/encoding/encoding.js.map +1 -1
- package/packages/sdk/src/encoding/encoding.mjs +12 -1
- package/packages/sdk/src/encoding/encoding.mjs.map +1 -1
- package/packages/sdk/src/encoding/schema/map.js +0 -2
- package/packages/sdk/src/encoding/schema/map.js.map +1 -1
- package/packages/sdk/src/utils/utils.mjs +2 -2
- package/packages/sdk/src/utils/utils.mjs.map +1 -1
- package/packages/transact/src/logicsig.d.ts +3 -15
- package/packages/transact/src/logicsig.js +16 -36
- package/packages/transact/src/logicsig.js.map +1 -1
- package/packages/transact/src/logicsig.mjs +18 -36
- package/packages/transact/src/logicsig.mjs.map +1 -1
- package/packages/transact/src/multisig.d.ts +7 -115
- package/packages/transact/src/multisig.js +86 -136
- package/packages/transact/src/multisig.js.map +1 -1
- package/packages/transact/src/multisig.mjs +87 -117
- package/packages/transact/src/multisig.mjs.map +1 -1
- package/packages/transact/src/transactions/app-call.d.ts +10 -10
- package/packages/transact/src/transactions/app-call.js.map +1 -1
- package/packages/transact/src/transactions/app-call.mjs.map +1 -1
- package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
- package/packages/transact/src/transactions/reference-types-meta.js +71 -0
- package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
- package/packages/transact/src/transactions/signed-transaction-meta.js +2 -3
- package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction-meta.mjs +3 -3
- package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.d.ts +2 -2
- package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction-meta.js +29 -23
- package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
- package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction.js +1 -0
- package/packages/transact/src/transactions/transaction.js.map +1 -1
- package/packages/transact/src/transactions/transaction.mjs +1 -0
- package/packages/transact/src/transactions/transaction.mjs.map +1 -1
- package/sdk/index.js +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +3 -3
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/transact/index.d.ts +5 -4
- package/transact/index.js +4 -22
- package/transact/index.mjs +4 -3
- package/transaction/transaction.js +2 -2
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +2 -2
- package/transaction/transaction.mjs.map +1 -1
- package/transactions/app-call.d.ts +4 -3
- package/transactions/app-call.js +15 -15
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +15 -15
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/asset-config.d.ts +1 -1
- package/transactions/asset-config.js +1 -1
- package/transactions/asset-config.js.map +1 -1
- package/transactions/asset-config.mjs +1 -1
- package/transactions/asset-config.mjs.map +1 -1
- package/transactions/method-call.js +12 -12
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +12 -12
- package/transactions/method-call.mjs.map +1 -1
- package/types/account-manager.js +2 -2
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +2 -2
- package/types/account-manager.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +97 -83
- package/types/algorand-client-transaction-creator.js +8 -0
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +8 -0
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +100 -86
- package/types/algorand-client-transaction-sender.js +8 -1
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +8 -0
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/app-client.d.ts +265 -260
- package/types/app-client.js +0 -1
- package/types/app-client.js.map +1 -1
- package/types/app-deployer.js +1 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +1 -1
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +91 -88
- package/types/app-manager.d.ts +3 -1
- package/types/app-manager.js +16 -10
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +16 -10
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.js +12 -5
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +12 -5
- package/types/app-spec.mjs.map +1 -1
- package/types/asset-manager.js +1 -1
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +1 -1
- package/types/asset-manager.mjs.map +1 -1
- package/types/composer.d.ts +9 -0
- package/types/composer.js +28 -13
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +28 -12
- package/types/composer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +1 -0
- package/types/kmd-account-manager.js +21 -10
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +22 -11
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/testing.d.ts +2 -2
- package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
- package/packages/algod_client/src/models/application-local-reference.js +0 -23
- package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
- package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
- package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
- package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/box-reference.d.ts +0 -17
- package/packages/algod_client/src/models/box-reference.js +0 -23
- package/packages/algod_client/src/models/box-reference.js.map +0 -1
- package/packages/algod_client/src/models/box-reference.mjs +0 -23
- package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-call.mjs","names":["appCall","groupIndex"],"sources":["../../src/transactions/app-call.ts"],"sourcesContent":["import {\n ApplicationLocalReference,\n AssetHoldingReference,\n SimulateUnnamedResourcesAccessed,\n SuggestedParams,\n} 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 AccessReference,\n OnApplicationComplete,\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?: AccessReference[]\n /** The lowest application version for which this transaction should immediately fail. 0 indicates that no version check should be performed. */\n rejectVersion?: number\n}\n\n/** Parameters to define an app create transaction */\nexport type AppCreateParams = Expand<\n Omit<CommonAppCallParams, 'appId'> & {\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 & {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.UpdateApplication>\n}\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 & {\n onComplete?: OnApplicationComplete.DeleteApplication\n}\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 ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n\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.account)\n remainingApps = remainingApps.filter((app) => app !== appLocal.app)\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.account)\n remainingAssets = remainingAssets.filter((asset) => asset !== assetHolding.asset)\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, {\n type: GroupResourceType.Box,\n data: {\n appId: boxRef.app,\n name: boxRef.name,\n },\n })\n // Remove apps as resource if we're adding it here\n remainingApps = remainingApps.filter((app) => app !== boxRef.app)\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: AssetHoldingReference }\n | { type: GroupResourceType.AppLocal; data: ApplicationLocalReference }\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.account\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.asset)) {\n appCall.assetReferences.push(resource.data.asset)\n }\n } else {\n appCall.appReferences = appCall.appReferences ?? []\n if (!appCall.appReferences.includes(resource.data.app)) {\n appCall.appReferences.push(resource.data.app)\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.asset) || false\n } else {\n return appCall.appReferences?.includes(resource.data.app) || appCall.appId === resource.data.app\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.asset)) {\n appCall.assetReferences.push(resource.data.asset)\n }\n const address = resource.data.account\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.app)) {\n appCall.appReferences.push(resource.data.app)\n }\n const address = resource.data.account\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":";;;;;;;;;;AAwGA,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;EACE,eAAe,OAAO,QAAQ,oBAAoB;EAClD,UAAU,OAAO,QAAQ,cAAc;EACxC,GACD;CACN,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,UAAa,OAAO,QAAQ,cAAc,SACzE;EACE,eAAe,OAAO,QAAQ,mBAAmB;EACjD,UAAU,OAAO,QAAQ,aAAa;EACvC,GACD;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,sB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AM,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,IAAI,CACpD,SAAQ,cAAc,KAAK,SAAS,KAAK,IAAI;GAE/C,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 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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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"}
|
|
@@ -160,7 +160,7 @@ type AssetFreezeParams = CommonTransactionParams & {
|
|
|
160
160
|
/** The ID of the asset to freeze/unfreeze */
|
|
161
161
|
assetId: bigint;
|
|
162
162
|
/** The address of the account to freeze or unfreeze */
|
|
163
|
-
|
|
163
|
+
freezeTarget: ReadableAddress;
|
|
164
164
|
/** Whether the assets in the account should be frozen */
|
|
165
165
|
frozen: boolean;
|
|
166
166
|
};
|
|
@@ -43,7 +43,7 @@ const buildAssetFreeze = (params, suggestedParams, defaultValidityWindow) => {
|
|
|
43
43
|
type: require_transaction_type.TransactionType.AssetFreeze,
|
|
44
44
|
assetFreeze: {
|
|
45
45
|
assetId: params.assetId,
|
|
46
|
-
freezeTarget: require_address.getAddress(params.
|
|
46
|
+
freezeTarget: require_address.getAddress(params.freezeTarget),
|
|
47
47
|
frozen: params.frozen
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-config.js","names":["Transaction","buildTransactionCommonData","TransactionType","ensureString","getOptionalAddress","getAddress"],"sources":["../../src/transactions/asset-config.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData, ensureString } from './common'\n\n/** Parameters to define an asset create transaction.\n *\n * The account that sends this transaction will automatically be opted in to the asset and will hold all units after creation.\n */\nexport type AssetCreateParams = CommonTransactionParams & {\n /** The total amount of the smallest divisible (decimal) unit to create.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there would be 1 whole unit.\n *\n * This field can only be specified upon asset creation.\n */\n total: bigint\n\n /** The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /** Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /** 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: string | Uint8Array\n\n /** Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the `manager` the asset becomes permanently immutable.\n */\n manager?: ReadableAddress\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n reserve?: ReadableAddress\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n freeze?: ReadableAddress\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset reconfiguration transaction.\n *\n * **Note:** The manager, reserve, freeze, and clawback addresses\n * are immutably empty if they are not set. If manager is not set then\n * all fields are immutable from that point forward.\n */\nexport type AssetConfigParams = CommonTransactionParams & {\n /** ID of the asset to reconfigure */\n assetId: bigint\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) the asset will become permanently immutable.\n */\n manager?: ReadableAddress\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n reserve?: ReadableAddress\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n freeze?: ReadableAddress\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset freeze transaction. */\nexport type AssetFreezeParams = CommonTransactionParams & {\n /** The ID of the asset to freeze/unfreeze */\n assetId: bigint\n /** The address of the account to freeze or unfreeze */\n account: ReadableAddress\n /** Whether the assets in the account should be frozen */\n frozen: boolean\n}\n\n/** Parameters to define an asset destroy transaction.\n *\n * Created assets can be destroyed only by the asset manager account. All of the assets must be owned by the creator of the asset before the asset can be deleted.\n */\nexport type AssetDestroyParams = CommonTransactionParams & {\n /** ID of the asset to destroy */\n assetId: bigint\n}\n\nexport const buildAssetCreate = (\n params: AssetCreateParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: 0n, // Asset creation always uses ID 0\n total: params.total,\n decimals: params.decimals,\n defaultFrozen: params.defaultFrozen,\n assetName: params.assetName,\n unitName: params.unitName,\n url: params.url,\n metadataHash: ensureString(params.metadataHash),\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetConfig = (\n params: AssetConfigParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetFreeze = (\n params: AssetFreezeParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetFreeze,\n assetFreeze: {\n assetId: params.assetId,\n freezeTarget: getAddress(params.account),\n frozen: params.frozen,\n },\n })\n}\n\nexport const buildAssetDestroy = (\n params: AssetDestroyParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n },\n })\n}\n"],"mappings":";;;;;;AA4LA,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIA,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS;GACT,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,eAAe,OAAO;GACtB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,KAAK,OAAO;GACZ,cAAcC,4BAAa,OAAO,aAAa;GAC/C,SAASC,mCAAmB,OAAO,QAAQ;GAC3C,SAASA,mCAAmB,OAAO,QAAQ;GAC3C,QAAQA,mCAAmB,OAAO,OAAO;GACzC,UAAUA,mCAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIJ,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,SAASE,mCAAmB,OAAO,QAAQ;GAC3C,SAASA,mCAAmB,OAAO,QAAQ;GAC3C,QAAQA,mCAAmB,OAAO,OAAO;GACzC,UAAUA,mCAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIJ,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,cAAcG,2BAAW,OAAO,QAAQ;GACxC,QAAQ,OAAO;GAChB;EACF,CAAC;;AAGJ,MAAa,qBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIL,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa,EACX,SAAS,OAAO,SACjB;EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"asset-config.js","names":["Transaction","buildTransactionCommonData","TransactionType","ensureString","getOptionalAddress","getAddress"],"sources":["../../src/transactions/asset-config.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData, ensureString } from './common'\n\n/** Parameters to define an asset create transaction.\n *\n * The account that sends this transaction will automatically be opted in to the asset and will hold all units after creation.\n */\nexport type AssetCreateParams = CommonTransactionParams & {\n /** The total amount of the smallest divisible (decimal) unit to create.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there would be 1 whole unit.\n *\n * This field can only be specified upon asset creation.\n */\n total: bigint\n\n /** The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /** Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /** 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: string | Uint8Array\n\n /** Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the `manager` the asset becomes permanently immutable.\n */\n manager?: ReadableAddress\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n reserve?: ReadableAddress\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n freeze?: ReadableAddress\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset reconfiguration transaction.\n *\n * **Note:** The manager, reserve, freeze, and clawback addresses\n * are immutably empty if they are not set. If manager is not set then\n * all fields are immutable from that point forward.\n */\nexport type AssetConfigParams = CommonTransactionParams & {\n /** ID of the asset to reconfigure */\n assetId: bigint\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) the asset will become permanently immutable.\n */\n manager?: ReadableAddress\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n reserve?: ReadableAddress\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n freeze?: ReadableAddress\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset freeze transaction. */\nexport type AssetFreezeParams = CommonTransactionParams & {\n /** The ID of the asset to freeze/unfreeze */\n assetId: bigint\n /** The address of the account to freeze or unfreeze */\n freezeTarget: ReadableAddress\n /** Whether the assets in the account should be frozen */\n frozen: boolean\n}\n\n/** Parameters to define an asset destroy transaction.\n *\n * Created assets can be destroyed only by the asset manager account. All of the assets must be owned by the creator of the asset before the asset can be deleted.\n */\nexport type AssetDestroyParams = CommonTransactionParams & {\n /** ID of the asset to destroy */\n assetId: bigint\n}\n\nexport const buildAssetCreate = (\n params: AssetCreateParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: 0n, // Asset creation always uses ID 0\n total: params.total,\n decimals: params.decimals,\n defaultFrozen: params.defaultFrozen,\n assetName: params.assetName,\n unitName: params.unitName,\n url: params.url,\n metadataHash: ensureString(params.metadataHash),\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetConfig = (\n params: AssetConfigParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetFreeze = (\n params: AssetFreezeParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetFreeze,\n assetFreeze: {\n assetId: params.assetId,\n freezeTarget: getAddress(params.freezeTarget),\n frozen: params.frozen,\n },\n })\n}\n\nexport const buildAssetDestroy = (\n params: AssetDestroyParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n },\n })\n}\n"],"mappings":";;;;;;AA4LA,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIA,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS;GACT,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,eAAe,OAAO;GACtB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,KAAK,OAAO;GACZ,cAAcC,4BAAa,OAAO,aAAa;GAC/C,SAASC,mCAAmB,OAAO,QAAQ;GAC3C,SAASA,mCAAmB,OAAO,QAAQ;GAC3C,QAAQA,mCAAmB,OAAO,OAAO;GACzC,UAAUA,mCAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIJ,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,SAASE,mCAAmB,OAAO,QAAQ;GAC3C,SAASA,mCAAmB,OAAO,QAAQ;GAC3C,QAAQA,mCAAmB,OAAO,OAAO;GACzC,UAAUA,mCAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIJ,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,cAAcG,2BAAW,OAAO,aAAa;GAC7C,QAAQ,OAAO;GAChB;EACF,CAAC;;AAGJ,MAAa,qBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAIL,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,aAAa,EACX,SAAS,OAAO,SACjB;EACF,CAAC"}
|
|
@@ -43,7 +43,7 @@ const buildAssetFreeze = (params, suggestedParams, defaultValidityWindow) => {
|
|
|
43
43
|
type: TransactionType.AssetFreeze,
|
|
44
44
|
assetFreeze: {
|
|
45
45
|
assetId: params.assetId,
|
|
46
|
-
freezeTarget: getAddress(params.
|
|
46
|
+
freezeTarget: getAddress(params.freezeTarget),
|
|
47
47
|
frozen: params.frozen
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-config.mjs","names":[],"sources":["../../src/transactions/asset-config.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData, ensureString } from './common'\n\n/** Parameters to define an asset create transaction.\n *\n * The account that sends this transaction will automatically be opted in to the asset and will hold all units after creation.\n */\nexport type AssetCreateParams = CommonTransactionParams & {\n /** The total amount of the smallest divisible (decimal) unit to create.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there would be 1 whole unit.\n *\n * This field can only be specified upon asset creation.\n */\n total: bigint\n\n /** The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /** Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /** 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: string | Uint8Array\n\n /** Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the `manager` the asset becomes permanently immutable.\n */\n manager?: ReadableAddress\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n reserve?: ReadableAddress\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n freeze?: ReadableAddress\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset reconfiguration transaction.\n *\n * **Note:** The manager, reserve, freeze, and clawback addresses\n * are immutably empty if they are not set. If manager is not set then\n * all fields are immutable from that point forward.\n */\nexport type AssetConfigParams = CommonTransactionParams & {\n /** ID of the asset to reconfigure */\n assetId: bigint\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) the asset will become permanently immutable.\n */\n manager?: ReadableAddress\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n reserve?: ReadableAddress\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n freeze?: ReadableAddress\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset freeze transaction. */\nexport type AssetFreezeParams = CommonTransactionParams & {\n /** The ID of the asset to freeze/unfreeze */\n assetId: bigint\n /** The address of the account to freeze or unfreeze */\n account: ReadableAddress\n /** Whether the assets in the account should be frozen */\n frozen: boolean\n}\n\n/** Parameters to define an asset destroy transaction.\n *\n * Created assets can be destroyed only by the asset manager account. All of the assets must be owned by the creator of the asset before the asset can be deleted.\n */\nexport type AssetDestroyParams = CommonTransactionParams & {\n /** ID of the asset to destroy */\n assetId: bigint\n}\n\nexport const buildAssetCreate = (\n params: AssetCreateParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: 0n, // Asset creation always uses ID 0\n total: params.total,\n decimals: params.decimals,\n defaultFrozen: params.defaultFrozen,\n assetName: params.assetName,\n unitName: params.unitName,\n url: params.url,\n metadataHash: ensureString(params.metadataHash),\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetConfig = (\n params: AssetConfigParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetFreeze = (\n params: AssetFreezeParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetFreeze,\n assetFreeze: {\n assetId: params.assetId,\n freezeTarget: getAddress(params.account),\n frozen: params.frozen,\n },\n })\n}\n\nexport const buildAssetDestroy = (\n params: AssetDestroyParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n },\n })\n}\n"],"mappings":";;;;;;AA4LA,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS;GACT,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,eAAe,OAAO;GACtB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,KAAK,OAAO;GACZ,cAAc,aAAa,OAAO,aAAa;GAC/C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,QAAQ,mBAAmB,OAAO,OAAO;GACzC,UAAU,mBAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,QAAQ,mBAAmB,OAAO,OAAO;GACzC,UAAU,mBAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,cAAc,WAAW,OAAO,QAAQ;GACxC,QAAQ,OAAO;GAChB;EACF,CAAC;;AAGJ,MAAa,qBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa,EACX,SAAS,OAAO,SACjB;EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"asset-config.mjs","names":[],"sources":["../../src/transactions/asset-config.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData, ensureString } from './common'\n\n/** Parameters to define an asset create transaction.\n *\n * The account that sends this transaction will automatically be opted in to the asset and will hold all units after creation.\n */\nexport type AssetCreateParams = CommonTransactionParams & {\n /** The total amount of the smallest divisible (decimal) unit to create.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there would be 1 whole unit.\n *\n * This field can only be specified upon asset creation.\n */\n total: bigint\n\n /** The amount of decimal places the asset should have.\n *\n * If unspecified then the asset will be in whole units (i.e. `0`).\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n *\n * This field can only be specified upon asset creation.\n */\n decimals?: number\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n assetName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n unitName?: string\n\n /** Specifies an optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n *\n * This field can only be specified upon asset creation.\n */\n url?: string\n\n /** 32-byte hash of some metadata that is relevant to your asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n *\n * This field can only be specified upon asset creation.\n */\n metadataHash?: string | Uint8Array\n\n /** Whether the asset is frozen by default for all accounts.\n * Defaults to `false`.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account, which must be set on creation.\n *\n * This field can only be specified upon asset creation.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the `manager` the asset becomes permanently immutable.\n */\n manager?: ReadableAddress\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n reserve?: ReadableAddress\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n freeze?: ReadableAddress\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) at asset creation or subsequently set to empty by the manager the field is permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset reconfiguration transaction.\n *\n * **Note:** The manager, reserve, freeze, and clawback addresses\n * are immutably empty if they are not set. If manager is not set then\n * all fields are immutable from that point forward.\n */\nexport type AssetConfigParams = CommonTransactionParams & {\n /** ID of the asset to reconfigure */\n assetId: bigint\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * The configuration fields it can change are `manager`, `reserve`, `clawback`, and `freeze`.\n *\n * If not set (`undefined` or `\"\"`) the asset will become permanently immutable.\n */\n manager?: ReadableAddress\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n reserve?: ReadableAddress\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n freeze?: ReadableAddress\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * **This field should be used with caution** as the clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set (`undefined` or `\"\"`) the field will become permanently empty.\n */\n clawback?: ReadableAddress\n}\n\n/** Parameters to define an asset freeze transaction. */\nexport type AssetFreezeParams = CommonTransactionParams & {\n /** The ID of the asset to freeze/unfreeze */\n assetId: bigint\n /** The address of the account to freeze or unfreeze */\n freezeTarget: ReadableAddress\n /** Whether the assets in the account should be frozen */\n frozen: boolean\n}\n\n/** Parameters to define an asset destroy transaction.\n *\n * Created assets can be destroyed only by the asset manager account. All of the assets must be owned by the creator of the asset before the asset can be deleted.\n */\nexport type AssetDestroyParams = CommonTransactionParams & {\n /** ID of the asset to destroy */\n assetId: bigint\n}\n\nexport const buildAssetCreate = (\n params: AssetCreateParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: 0n, // Asset creation always uses ID 0\n total: params.total,\n decimals: params.decimals,\n defaultFrozen: params.defaultFrozen,\n assetName: params.assetName,\n unitName: params.unitName,\n url: params.url,\n metadataHash: ensureString(params.metadataHash),\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetConfig = (\n params: AssetConfigParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n manager: getOptionalAddress(params.manager),\n reserve: getOptionalAddress(params.reserve),\n freeze: getOptionalAddress(params.freeze),\n clawback: getOptionalAddress(params.clawback),\n },\n })\n}\n\nexport const buildAssetFreeze = (\n params: AssetFreezeParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetFreeze,\n assetFreeze: {\n assetId: params.assetId,\n freezeTarget: getAddress(params.freezeTarget),\n frozen: params.frozen,\n },\n })\n}\n\nexport const buildAssetDestroy = (\n params: AssetDestroyParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.AssetConfig,\n assetConfig: {\n assetId: params.assetId,\n },\n })\n}\n"],"mappings":";;;;;;AA4LA,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS;GACT,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,eAAe,OAAO;GACtB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,KAAK,OAAO;GACZ,cAAc,aAAa,OAAO,aAAa;GAC/C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,QAAQ,mBAAmB,OAAO,OAAO;GACzC,UAAU,mBAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,SAAS,mBAAmB,OAAO,QAAQ;GAC3C,QAAQ,mBAAmB,OAAO,OAAO;GACzC,UAAU,mBAAmB,OAAO,SAAS;GAC9C;EACF,CAAC;;AAGJ,MAAa,oBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa;GACX,SAAS,OAAO;GAChB,cAAc,WAAW,OAAO,aAAa;GAC7C,QAAQ,OAAO;GAChB;EACF,CAAC;;AAGJ,MAAa,qBACX,QACA,iBACA,0BACgB;AAEhB,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,aAAa,EACX,SAAS,OAAO,SACjB;EACF,CAAC"}
|
|
@@ -85,9 +85,9 @@ const isAbiValue = (x) => {
|
|
|
85
85
|
* Populate reference arrays from processed ABI method call arguments
|
|
86
86
|
*/
|
|
87
87
|
function populateMethodArgsIntoReferenceArrays(sender, appId, method, methodArgs, accountReferences, appReferences, assetReferences) {
|
|
88
|
-
const accounts = accountReferences ?? [];
|
|
89
|
-
const assets = assetReferences ?? [];
|
|
90
|
-
const apps = appReferences ?? [];
|
|
88
|
+
const accounts = [...accountReferences ?? []];
|
|
89
|
+
const assets = [...assetReferences ?? []];
|
|
90
|
+
const apps = [...appReferences ?? []];
|
|
91
91
|
methodArgs.forEach((arg, i) => {
|
|
92
92
|
const argType = method.args[i].type;
|
|
93
93
|
if (require_abi_method.argTypeIsReference(argType)) switch (argType) {
|
|
@@ -245,9 +245,9 @@ const buildAppCreateMethodCall = async (params, appManager, suggestedParams, def
|
|
|
245
245
|
extraProgramPages,
|
|
246
246
|
args: common.args,
|
|
247
247
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
248
|
-
accountReferences:
|
|
249
|
-
appReferences:
|
|
250
|
-
assetReferences:
|
|
248
|
+
accountReferences: common.accountReferences,
|
|
249
|
+
appReferences: common.appReferences,
|
|
250
|
+
assetReferences: common.assetReferences,
|
|
251
251
|
boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
|
|
252
252
|
},
|
|
253
253
|
rejectVersion: params.rejectVersion
|
|
@@ -278,9 +278,9 @@ const buildAppUpdateMethodCall = async (params, appManager, suggestedParams, def
|
|
|
278
278
|
clearStateProgram,
|
|
279
279
|
args: common.args,
|
|
280
280
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
281
|
-
accountReferences:
|
|
282
|
-
appReferences:
|
|
283
|
-
assetReferences:
|
|
281
|
+
accountReferences: common.accountReferences,
|
|
282
|
+
appReferences: common.appReferences,
|
|
283
|
+
assetReferences: common.assetReferences,
|
|
284
284
|
boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
|
|
285
285
|
},
|
|
286
286
|
rejectVersion: params.rejectVersion
|
|
@@ -307,9 +307,9 @@ const buildAppCallMethodCall = async (params, suggestedParams, defaultValidityWi
|
|
|
307
307
|
onComplete: params.onComplete ?? require_app_call.OnApplicationComplete.NoOp,
|
|
308
308
|
args: common.args,
|
|
309
309
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
310
|
-
accountReferences:
|
|
311
|
-
appReferences:
|
|
312
|
-
assetReferences:
|
|
310
|
+
accountReferences: common.accountReferences,
|
|
311
|
+
appReferences: common.appReferences,
|
|
312
|
+
assetReferences: common.assetReferences,
|
|
313
313
|
boxReferences: params.boxReferences?.map(require_app_manager.AppManager.getBoxReference)
|
|
314
314
|
},
|
|
315
315
|
rejectVersion: params.rejectVersion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-call.js","names":["Address","argTypeIsReference","getAddress","argTypeIsTransaction","ABIUintType","encodedArgs: Uint8Array[]","ABITupleType","buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","AppManager"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = accountReferences ?? []\n const assets = assetReferences ?? []\n const apps = appReferences ?? []\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: params.accountReferences?.map((a) => getAddress(a)),\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,c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BAAsB;CAC7F,MAAM,oBAAoB,OAAO,mBAAmB,KAAK,MAAML,2BAAW,EAAE,CAAC;CAC7E,MAAM,SAAS,sBACb;EACE,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,MAAM,OAAO,QAAQ,EAAE;EACJ;EACnB,eAAe,OAAO;EACtB,iBAAiB,OAAO;EACzB,EACD,WACD;CAGD,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIO,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAY,OAAO,cAAcC,uCAAsB;GACvD,MAAM,OAAO;GACb,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,OAAO,mBAAmB,KAAK,MAAMT,2BAAW,EAAE,CAAC;IACtE,eAAe,OAAO;IACtB,iBAAiB,OAAO;IACxB,eAAe,OAAO,eAAe,IAAIU,+BAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"method-call.js","names":["Address","argTypeIsReference","getAddress","argTypeIsTransaction","ABIUintType","encodedArgs: Uint8Array[]","ABITupleType","buildTransactionCommonData","calculateExtraProgramPages","Transaction","TransactionType","OnApplicationComplete","AppManager"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIReferenceType,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { Expand } from '../types/expand'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { TransactionCommonData, buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 14 // 14+ args trigger tuple packing, excluding the method selector\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Populate reference arrays from processed ABI method call arguments\n */\nfunction populateMethodArgsIntoReferenceArrays(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: AppMethodCallArg[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const accounts = [...(accountReferences ?? [])]\n const assets = [...(assetReferences ?? [])]\n const apps = [...(appReferences ?? [])]\n\n methodArgs.forEach((arg, i) => {\n const argType = method.args[i].type\n if (argTypeIsReference(argType)) {\n switch (argType) {\n case 'account':\n if (typeof arg === 'string' && arg !== sender.toString() && !accounts.some((a) => a.toString() === arg)) {\n accounts.push(getAddress(arg))\n }\n break\n case 'asset':\n if (typeof arg === 'bigint' && !assets.includes(arg)) {\n assets.push(arg)\n }\n break\n case 'application':\n if (typeof arg === 'bigint' && arg !== appId && !apps.includes(arg)) {\n apps.push(arg)\n }\n break\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets }\n}\n\n/**\n * Calculate array index for ABI reference values\n */\nfunction calculateMethodArgReferenceArrayIndex(\n refValue: string | bigint,\n referenceType: ABIReferenceType,\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): number {\n switch (referenceType) {\n case 'account':\n if (typeof refValue === 'string') {\n // If address is the same as sender, use index 0\n if (refValue === sender.toString()) return 0\n const index = accountReferences.findIndex((a) => a.toString() === refValue)\n if (index === -1) throw new Error(`Account ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Account reference must be a string')\n case 'asset':\n if (typeof refValue === 'bigint') {\n const index = assetReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Asset ${refValue} not found in reference array`)\n return index\n }\n throw new Error('Asset reference must be a bigint')\n case 'application':\n if (typeof refValue === 'bigint') {\n // If app ID is the same as the current app, use index 0\n if (refValue === appId) return 0\n const index = appReferences.indexOf(refValue)\n if (index === -1) throw new Error(`Application ${refValue} not found in reference array`)\n return index + 1\n }\n throw new Error('Application reference must be a bigint')\n default:\n throw new Error(`Unknown reference type: ${referenceType}`)\n }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(\n method: ABIMethod,\n args: (ABIValue | undefined)[],\n sender: Address,\n appId: bigint,\n accountReferences: Address[],\n appReferences: bigint[],\n assetReferences: bigint[],\n): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'string' || typeof argValue === 'bigint') {\n const foreignIndex = calculateMethodArgReferenceArrayIndex(\n argValue,\n referenceType,\n sender,\n appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n abiTypes.push(new ABIUintType(8))\n abiValues.push(foreignIndex)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 14 arguments\n // 14 instead of 15 in the ARC-4 because the first argument (method selector) is added separately\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // Encode first 14 arguments individually\n const first14AbiTypes = abiTypes.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n const first14AbiValues = abiValues.slice(0, ARGS_TUPLE_PACKING_THRESHOLD)\n encodedArgs.push(...encodeArgsIndividually(first14AbiTypes, first14AbiValues))\n\n // Pack remaining arguments into tuple at position 15\n const remainingAbiTypes = abiTypes.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n const remainingAbiValues = abiValues.slice(ARGS_TUPLE_PACKING_THRESHOLD)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Common method call building logic\n */\nfunction buildMethodCallCommon(\n params: {\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n },\n commonData: TransactionCommonData,\n): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences } = populateMethodArgsIntoReferenceArrays(\n commonData.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(\n params.method,\n params.args,\n commonData.sender,\n params.appId,\n accountReferences,\n appReferences,\n assetReferences,\n )\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const common = buildMethodCallCommon(\n {\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n },\n commonData,\n )\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: common.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: common.accountReferences,\n appReferences: common.appReferences,\n assetReferences: common.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3B,MAAI,QAAQ,OAEV;AAEF,MAAI,WAAW,IAAI,CAEjB;AAGF,MAAI,2BAA2B,IAAI,EAAE;AACnC,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK,IAAI;KACT,QAAQ,IAAI;KACb;IACD,MAAM;IACP,CAAC;AAEF;;AAEF,MAAI,uBAAuB,IAAI,EAAE;GAE/B,MAAM,6BAA6B,mDAAmD,KAAK,cAAc;AACzG,wBAAqB,KAAK,GAAG,2BAA2B;AACxD,wBAAqB,KAAK;IACxB,MAAM;KACJ,GAAG;KACH,QAAQ,IAAI,UAAU;KACtB,MAAM,yBAAyB,IAAI,KAAK;KACzC;IACD,MAAM;IACP,CA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,iBAAiB,OAAO;EACzB,EACD,WACD;CAGD,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIO,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAYC,uCAAsB;GACjB;GACE;GACnB,MAAM,OAAO;GACb,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,OAAO;IAC1B,eAAe,OAAO;IACtB,iBAAiB,OAAO;IACxB,eAAe,OAAO,eAAe,IAAIC,+BAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC;;AAGJ,MAAa,yBAAyB,OACpC,QACA,iBACA,0BACyB;CACzB,MAAM,aAAaL,0CAA2B,QAAQ,iBAAiB,sBAAsB;CAC7F,MAAM,oBAAoB,OAAO,mBAAmB,KAAK,MAAML,2BAAW,EAAE,CAAC;CAC7E,MAAM,SAAS,sBACb;EACE,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,MAAM,OAAO,QAAQ,EAAE;EACJ;EACnB,eAAe,OAAO;EACtB,iBAAiB,OAAO;EACzB,EACD,WACD;CAGD,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAIO,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAY,OAAO,cAAcC,uCAAsB;GACvD,MAAM,OAAO;GACb,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,OAAO;IAC1B,eAAe,OAAO;IACtB,iBAAiB,OAAO;IACxB,eAAe,OAAO,eAAe,IAAIC,+BAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
|
|
@@ -85,9 +85,9 @@ const isAbiValue = (x) => {
|
|
|
85
85
|
* Populate reference arrays from processed ABI method call arguments
|
|
86
86
|
*/
|
|
87
87
|
function populateMethodArgsIntoReferenceArrays(sender, appId, method, methodArgs, accountReferences, appReferences, assetReferences) {
|
|
88
|
-
const accounts = accountReferences ?? [];
|
|
89
|
-
const assets = assetReferences ?? [];
|
|
90
|
-
const apps = appReferences ?? [];
|
|
88
|
+
const accounts = [...accountReferences ?? []];
|
|
89
|
+
const assets = [...assetReferences ?? []];
|
|
90
|
+
const apps = [...appReferences ?? []];
|
|
91
91
|
methodArgs.forEach((arg, i) => {
|
|
92
92
|
const argType = method.args[i].type;
|
|
93
93
|
if (argTypeIsReference(argType)) switch (argType) {
|
|
@@ -245,9 +245,9 @@ const buildAppCreateMethodCall = async (params, appManager, suggestedParams, def
|
|
|
245
245
|
extraProgramPages,
|
|
246
246
|
args: common.args,
|
|
247
247
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
248
|
-
accountReferences:
|
|
249
|
-
appReferences:
|
|
250
|
-
assetReferences:
|
|
248
|
+
accountReferences: common.accountReferences,
|
|
249
|
+
appReferences: common.appReferences,
|
|
250
|
+
assetReferences: common.assetReferences,
|
|
251
251
|
boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
|
|
252
252
|
},
|
|
253
253
|
rejectVersion: params.rejectVersion
|
|
@@ -278,9 +278,9 @@ const buildAppUpdateMethodCall = async (params, appManager, suggestedParams, def
|
|
|
278
278
|
clearStateProgram,
|
|
279
279
|
args: common.args,
|
|
280
280
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
281
|
-
accountReferences:
|
|
282
|
-
appReferences:
|
|
283
|
-
assetReferences:
|
|
281
|
+
accountReferences: common.accountReferences,
|
|
282
|
+
appReferences: common.appReferences,
|
|
283
|
+
assetReferences: common.assetReferences,
|
|
284
284
|
boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
|
|
285
285
|
},
|
|
286
286
|
rejectVersion: params.rejectVersion
|
|
@@ -307,9 +307,9 @@ const buildAppCallMethodCall = async (params, suggestedParams, defaultValidityWi
|
|
|
307
307
|
onComplete: params.onComplete ?? OnApplicationComplete.NoOp,
|
|
308
308
|
args: common.args,
|
|
309
309
|
...hasAccessReferences ? { accessReferences: params.accessReferences } : {
|
|
310
|
-
accountReferences:
|
|
311
|
-
appReferences:
|
|
312
|
-
assetReferences:
|
|
310
|
+
accountReferences: common.accountReferences,
|
|
311
|
+
appReferences: common.appReferences,
|
|
312
|
+
assetReferences: common.assetReferences,
|
|
313
313
|
boxReferences: params.boxReferences?.map(AppManager.getBoxReference)
|
|
314
314
|
},
|
|
315
315
|
rejectVersion: params.rejectVersion
|