@algorandfoundation/algokit-utils 10.0.0-alpha.2 → 10.0.0-alpha.21
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/_virtual/rolldown_runtime.js +10 -15
- 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 +3 -7
- package/algod-client/index.js +2 -5
- package/algod-client/index.mjs +2 -2
- package/index.d.ts +1 -2
- package/index.js +0 -7
- package/index.mjs +1 -2
- package/indexer-client/index.d.ts +2 -2
- package/indexer-client/index.js +6 -6
- package/indexer-client/index.mjs +2 -2
- package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
- package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
- package/indexer-client/indexer-lookup.js.map +1 -0
- package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
- package/indexer-client/indexer-lookup.mjs.map +1 -0
- package/kmd-client/index.d.ts +1 -2
- package/kmd-client/index.js +0 -5
- package/kmd-client/index.mjs +1 -2
- package/package.json +1 -6
- package/packages/abi/src/abi-method.d.ts +1 -1
- package/packages/abi/src/abi-method.js +1 -1
- package/packages/abi/src/abi-method.js.map +1 -1
- package/packages/abi/src/abi-method.mjs +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 +4 -2
- package/packages/abi/src/abi-type.js.map +1 -1
- package/packages/abi/src/abi-type.mjs +4 -2
- 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/index.d.ts +40 -0
- package/packages/algo25/src/index.js +45 -1
- package/packages/algo25/src/index.js.map +1 -1
- package/packages/algo25/src/index.mjs +40 -2
- 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 +155 -155
- package/packages/algod_client/src/apis/api-service.js.map +1 -1
- package/packages/algod_client/src/apis/api-service.mjs +155 -155
- 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 +6 -6
- package/packages/algod_client/src/core/model-runtime.js.map +1 -1
- package/packages/algod_client/src/core/model-runtime.mjs +8 -8
- 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 +60 -40
- package/packages/algod_client/src/models/block.js +184 -108
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs +184 -108
- 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-request.js +1 -1
- package/packages/algod_client/src/models/simulate-request.mjs +1 -1
- package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
- package/packages/algod_client/src/models/simulate-response.js +6 -1
- package/packages/algod_client/src/models/simulate-response.js.map +1 -1
- package/packages/algod_client/src/models/simulate-response.mjs +6 -2
- package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
- package/packages/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/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
- package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
- package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
- package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
- package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.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 +0 -15
- package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
- package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/indexer_client/src/models/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.d.ts +5 -5
- package/packages/indexer_client/src/models/block.js +13 -13
- package/packages/indexer_client/src/models/block.js.map +1 -1
- package/packages/indexer_client/src/models/block.mjs +13 -13
- 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/participation-updates.d.ts +2 -2
- package/packages/indexer_client/src/models/participation-updates.js +2 -2
- package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
- package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
- package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
- package/packages/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 +2 -12
- package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
- package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
- package/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 -15
- 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/asset-config.d.ts +1 -6
- package/packages/transact/src/transactions/asset-config.js.map +1 -1
- package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
- package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
- package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
- package/packages/transact/src/transactions/key-registration.d.ts +1 -8
- 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 +7 -3
- package/packages/transact/src/transactions/signed-transaction.js +1 -1
- package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
- 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.d.ts +5 -1
- package/packages/transact/src/transactions/transaction.js +1 -1
- package/packages/transact/src/transactions/transaction.js.map +1 -1
- package/packages/transact/src/transactions/transaction.mjs +1 -1
- package/packages/transact/src/transactions/transaction.mjs.map +1 -1
- package/testing/account.js +2 -5
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +2 -5
- package/testing/account.mjs.map +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/testing/transaction-logger.js +1 -1
- package/testing/transaction-logger.mjs +1 -1
- package/transact/index.d.ts +11 -10
- package/transact/index.js +7 -32
- package/transact/index.mjs +7 -10
- 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 +5 -4
- package/transactions/app-call.js +16 -16
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +16 -16
- 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/key-registration.d.ts +1 -1
- package/transactions/key-registration.js.map +1 -1
- package/transactions/key-registration.mjs.map +1 -1
- package/transactions/method-call.d.ts +1 -1
- package/transactions/method-call.js +70 -78
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +70 -78
- package/transactions/method-call.mjs.map +1 -1
- package/types/account-manager.d.ts +1 -1
- package/types/account-manager.js +5 -5
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +5 -5
- package/types/account-manager.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +74 -60
- 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 +79 -65
- 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/amount.js +23 -4
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +20 -2
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +174 -169
- package/types/app-client.js +2 -3
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +2 -2
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +1 -1
- package/types/app-deployer.js +3 -3
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +3 -3
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +70 -67
- package/types/app-factory.js +2 -2
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +2 -2
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +3 -1
- package/types/app-manager.js +17 -11
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +17 -11
- 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/app.d.ts +2 -2
- package/types/app.js.map +1 -1
- package/types/app.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/async-event-emitter.d.ts +3 -6
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +1 -1
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +9 -1
- package/types/composer.js +49 -37
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +40 -27
- package/types/composer.mjs.map +1 -1
- package/types/debugging.d.ts +13 -9
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs.map +1 -1
- package/types/expand.d.ts +2 -9
- package/types/kmd-account-manager.d.ts +1 -0
- package/types/kmd-account-manager.js +22 -11
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +23 -12
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +0 -1
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/testing.d.ts +2 -2
- package/types/transaction.d.ts +1 -1
- package/_virtual/rolldown_runtime.mjs +0 -13
- package/indexer-lookup.js.map +0 -1
- package/indexer-lookup.mjs.map +0 -1
- package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
- 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
- package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
- package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
- package/packages/sdk/src/convert.d.ts +0 -17
- package/packages/sdk/src/convert.js +0 -28
- package/packages/sdk/src/convert.js.map +0 -1
- package/packages/sdk/src/convert.mjs +0 -25
- package/packages/sdk/src/convert.mjs.map +0 -1
- package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
- package/packages/sdk/src/encoding/binarydata.js +0 -65
- package/packages/sdk/src/encoding/binarydata.js.map +0 -1
- package/packages/sdk/src/encoding/binarydata.mjs +0 -60
- package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
- package/packages/sdk/src/encoding/encoding.d.ts +0 -237
- package/packages/sdk/src/encoding/encoding.js +0 -302
- package/packages/sdk/src/encoding/encoding.js.map +0 -1
- package/packages/sdk/src/encoding/encoding.mjs +0 -287
- package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/array.js +0 -35
- package/packages/sdk/src/encoding/schema/array.js.map +0 -1
- package/packages/sdk/src/encoding/schema/array.mjs +0 -35
- package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
- package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
- package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
- package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
- package/packages/sdk/src/encoding/schema/map.js +0 -110
- package/packages/sdk/src/encoding/schema/map.js.map +0 -1
- package/packages/sdk/src/encoding/schema/map.mjs +0 -107
- package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/optional.js +0 -46
- package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
- package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
- package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/uint64.js +0 -30
- package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
- package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
- package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
- package/packages/sdk/src/encoding/uint64.d.ts +0 -34
- package/packages/sdk/src/encoding/uint64.js +0 -34
- package/packages/sdk/src/encoding/uint64.js.map +0 -1
- package/packages/sdk/src/encoding/uint64.mjs +0 -33
- package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
- package/packages/sdk/src/index.d.ts +0 -44
- package/packages/sdk/src/index.js +0 -62
- package/packages/sdk/src/index.js.map +0 -1
- package/packages/sdk/src/index.mjs +0 -58
- package/packages/sdk/src/index.mjs.map +0 -1
- package/packages/sdk/src/nacl/naclWrappers.js +0 -14
- package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
- package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
- package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
- package/packages/sdk/src/types/intDecoding.d.ts +0 -28
- package/packages/sdk/src/types/intDecoding.js +0 -32
- package/packages/sdk/src/types/intDecoding.js.map +0 -1
- package/packages/sdk/src/types/intDecoding.mjs +0 -31
- package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
- package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
- package/packages/sdk/src/types/transactions/encoded.js +0 -64
- package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
- package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
- package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
- package/packages/sdk/src/utils/utils.d.ts +0 -64
- package/packages/sdk/src/utils/utils.js +0 -140
- package/packages/sdk/src/utils/utils.js.map +0 -1
- package/packages/sdk/src/utils/utils.mjs +0 -128
- package/packages/sdk/src/utils/utils.mjs.map +0 -1
- package/packages/transact/src/transactions/common.d.ts +0 -37
- package/sdk/index.d.ts +0 -10
- package/sdk/index.js +0 -59
- package/sdk/index.mjs +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-factory.mjs","names":["result"],"sources":["../../src/types/app-factory.ts"],"sourcesContent":["import { Arc56Contract, argTypeIsTransaction, getABIDecodedValue, getABIMethod } from '@algorandfoundation/algokit-abi'\nimport { Address, ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, OnApplicationComplete, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport { type AlgorandClient } from './algorand-client'\nimport { AppCompilationResult, DELETABLE_TEMPLATE_NAME, TealTemplateParams, UPDATABLE_TEMPLATE_NAME } from './app'\nimport {\n AppClient,\n AppClientBareCallParams,\n AppClientCompilationParams,\n AppClientMethodCallParams,\n AppClientParams,\n AppSourceMaps,\n ResolveAppClientByCreatorAndName,\n} from './app-client'\nimport {\n AppDeployParams,\n DeployAppDeleteMethodCall,\n DeployAppDeleteParams,\n DeployAppUpdateMethodCall,\n DeployAppUpdateParams,\n} from './app-deployer'\nimport { AppSpec } from './app-spec'\nimport { AppCreateMethodCall, AppCreateParams, AppMethodCall, CommonAppCallParams } from './composer'\nimport { Expand } from './expand'\nimport { SendParams } from './transaction'\n\n/** Parameters to create an app client */\nexport interface AppFactoryParams {\n /** The ARC-56 or ARC-32 application spec as either:\n * * Parsed JSON ARC-56 `Contract`\n * * Parsed JSON ARC-32 `AppSpec`\n * * Raw JSON string (in either ARC-56 or ARC-32 format)\n */\n appSpec: Arc56Contract | AppSpec | string\n\n /** `AlgorandClient` instance */\n algorand: AlgorandClient\n\n /**\n * Optional override for the app name; used for on-chain metadata and lookups.\n * Defaults to the ARC-32/ARC-56 app spec name.\n */\n appName?: string\n\n /** Optional address to use for the account to use as the default sender for calls. */\n defaultSender?: ReadableAddress\n\n /** Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from `AlgorandClient`). */\n defaultSigner?: TransactionSigner\n\n /** The version of app that is / will be deployed; defaults to 1.0 */\n version?: string\n\n /**\n * Whether or not the contract should have deploy-time immutability control set, undefined = ignore.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n updatable?: boolean\n\n /**\n * Whether or not the contract should have deploy-time permanence control set, undefined = ignore.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n deletable?: boolean\n\n /**\n * Optional deploy-time TEAL template replacement parameters.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n deployTimeParams?: TealTemplateParams\n}\n\n/** onComplete parameter for a create app call */\nexport type CreateOnComplete = {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n}\n\n/** Specifies a schema used for creating an app */\nexport type CreateSchema = {\n /** The state schema for the app. This is immutable once the app is created. By default uses the ARC32/ARC-56 spec. */\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/** Params to specify a bare (raw) create call for an app */\nexport type AppFactoryCreateParams = Expand<AppClientBareCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema>\n\n/** Params to specify a create method call for an app */\nexport type AppFactoryCreateMethodCallParams = Expand<\n AppClientMethodCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema\n>\n\n/** Params to get an app client by ID from an app factory. */\nexport type AppFactoryAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>\n\n/** Params to get an app client by creator address and name from an app factory. */\nexport type AppFactoryResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>\n\n/** Parameters to define a deployment for an `AppFactory` */\nexport type AppFactoryDeployParams = Expand<\n Omit<AppDeployParams, 'createParams' | 'updateParams' | 'deleteParams' | 'metadata'> & {\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams?:\n | Expand<AppClientMethodCallParams & CreateOnComplete & CreateSchema>\n | Expand<AppClientBareCallParams & CreateOnComplete & CreateSchema>\n /** Update transaction parameters to use if a create needs to be issued as part of deployment */\n updateParams?: AppClientMethodCallParams | AppClientBareCallParams\n /** Delete transaction parameters to use if a create needs to be issued as part of deployment */\n deleteParams?: AppClientMethodCallParams | AppClientBareCallParams\n /**\n * Whether or not the contract should have deploy-time immutability control set.\n * `undefined` = use AppFactory constructor value if set or base it on the app spec.\n */\n updatable?: boolean\n /**\n * Whether or not the contract should have deploy-time permanence control set.\n * `undefined` = use AppFactory constructor value if set or base it on the app spec.\n */\n deletable?: boolean\n /** Override the app name for this deployment */\n appName?: string\n }\n>\n\n/**\n * ARC-56/ARC-32 app factory that, for a given app spec, allows you to create\n * and deploy one or more app instances and to create one or more app clients\n * to interact with those (or other) app instances.\n */\nexport class AppFactory {\n private _appSpec: Arc56Contract\n private _appName: string\n private _algorand: AlgorandClient\n private _version: string\n private _defaultSender?: Address\n private _defaultSigner?: TransactionSigner\n private _deployTimeParams?: TealTemplateParams\n private _updatable?: boolean\n private _deletable?: boolean\n\n private _approvalSourceMap: ProgramSourceMap | undefined\n private _clearSourceMap: ProgramSourceMap | undefined\n\n private _paramsMethods: ReturnType<AppFactory['getParamsMethods']>\n\n /**\n * Create a new app factory.\n * @param params The parameters to create the app factory\n * @returns The `AppFactory` instance\n * @example\n * ```typescript\n * const appFactory = new AppFactory({\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n constructor(params: AppFactoryParams) {\n this._appSpec = AppClient.normaliseAppSpec(params.appSpec)\n this._appName = params.appName ?? this._appSpec.name\n this._algorand = params.algorand\n this._version = params.version ?? '1.0'\n this._defaultSender = getOptionalAddress(params.defaultSender)\n this._defaultSigner = params.defaultSigner\n this._deployTimeParams = params.deployTimeParams\n this._updatable = params.updatable\n this._deletable = params.deletable\n this._paramsMethods = this.getParamsMethods()\n }\n\n /** The name of the app (from the ARC-32 / ARC-56 app spec or override). */\n public get appName() {\n return this._appName\n }\n\n /** The ARC-56 app spec being used */\n get appSpec() {\n return this._appSpec\n }\n\n /** Return the algorand client this factory is using. */\n get algorand() {\n return this._algorand\n }\n\n /** Get parameters to create transactions (create and deploy related calls) for the current app.\n *\n * A good mental model for this is that these parameters represent a deferred transaction creation.\n * @example Create a transaction in the future using Algorand Client\n * ```typescript\n * const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})\n * // ...\n * await algorand.send.AppCreateMethodCall(createAppParams)\n * ```\n * @example Define a nested transaction as an ABI argument\n * ```typescript\n * const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})\n * await appClient.send.call({method: 'my_method', args: [createAppParams]})\n * ```\n */\n get params() {\n return this._paramsMethods\n }\n\n /** Create transactions for the current app */\n readonly createTransaction = {\n /** Create bare (raw) transactions for the current app */\n bare: {\n /**\n * Create a create app call transaction using a bare (raw) create call.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the create call transaction\n * @returns The create call transaction\n */\n create: async (params?: AppFactoryCreateParams) => {\n return this._algorand.createTransaction.appCreate(await this.params.bare.create(params))\n },\n },\n\n /**\n * Create a create app call transaction using an ABI create call.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the create call transaction\n * @returns The create call transaction\n */\n create: async (params: AppFactoryCreateMethodCallParams) => {\n return this._algorand.createTransaction.appCreateMethodCall(await this.params.create(params))\n },\n }\n\n /** Send transactions to the current app */\n readonly send = {\n /** Send bare (raw) transactions for the current app */\n bare: {\n /**\n * Creates an instance of the app using a bare (raw) create call and returns the result\n * of the creation transaction and an app client to interact with that app instance.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the app\n * @returns The app client and the result of the creation transaction\n */\n create: async (params?: AppFactoryCreateParams & SendParams) => {\n const updatable = params?.updatable ?? this._updatable\n const deletable = params?.deletable ?? this._deletable\n const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams\n const compiled = await this.compile({ deployTimeParams, updatable, deletable })\n const result = await this.handleCallErrors(async () => ({\n ...(await this._algorand.send.appCreate(await this.params.bare.create({ ...params, updatable, deletable, deployTimeParams }))),\n return: undefined,\n }))\n return {\n appClient: this.getAppClientById({\n appId: result.appId,\n }),\n result: {\n ...result,\n ...(compiled as Partial<AppCompilationResult>),\n },\n }\n },\n },\n\n /**\n * Creates an instance of the app and returns the result of the creation\n * transaction and an app client to interact with that app instance.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the app\n * @returns The app client and the result of the creation transaction\n */\n create: async (params: AppFactoryCreateMethodCallParams & SendParams) => {\n const updatable = params?.updatable ?? this._updatable\n const deletable = params?.deletable ?? this._deletable\n const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams\n const compiled = await this.compile({ deployTimeParams, updatable, deletable })\n const result = await this.handleCallErrors(async () => {\n const result = await this._algorand.send.appCreateMethodCall(\n await this.params.create({ ...params, updatable, deletable, deployTimeParams }),\n )\n return {\n ...result,\n return: result.return?.returnValue,\n }\n })\n return {\n appClient: this.getAppClientById({\n appId: result.appId,\n }),\n result: {\n ...result,\n ...(compiled as Partial<AppCompilationResult>),\n },\n }\n },\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param params The arguments to control the app deployment\n * @returns The app client and the result of the deployment\n * @example\n * ```ts\n * const { appClient, result } = await factory.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n public async deploy(params: AppFactoryDeployParams) {\n const updatable = params.updatable ?? this._updatable ?? this.getDeployTimeControl('updatable')\n const deletable = params.deletable ?? this._deletable ?? this.getDeployTimeControl('deletable')\n const deployTimeParams = params.deployTimeParams ?? this._deployTimeParams\n\n // Compile using a appID 0 AppClient so we can register the error handler and use the programs\n // to identify the app within the error handler (because we can't use app ID 0)\n const tempAppClient = this.getAppClientById({ appId: 0n })\n const compiled = await tempAppClient.compile({ deployTimeParams, updatable, deletable })\n\n const deployResult = await this._algorand.appDeployer.deploy({\n ...params,\n createParams: await (params.createParams && 'method' in params.createParams\n ? this.params.create({ ...params.createParams, updatable, deletable, deployTimeParams })\n : this.params.bare.create({ ...params.createParams, updatable, deletable, deployTimeParams })),\n updateParams:\n params.updateParams && 'method' in params.updateParams\n ? this.params.deployUpdate(params.updateParams)\n : this.params.bare.deployUpdate(params.updateParams),\n deleteParams:\n params.deleteParams && 'method' in params.deleteParams\n ? this.params.deployDelete(params.deleteParams)\n : this.params.bare.deployDelete(params.deleteParams),\n metadata: {\n name: params.appName ?? this._appName,\n version: this._version,\n updatable,\n deletable,\n },\n })\n const appClient = this.getAppClientById({\n appId: deployResult.appId,\n appName: params.appName,\n })\n const result = {\n ...deployResult,\n ...(compiled as Partial<AppCompilationResult>),\n }\n return {\n appClient,\n result: {\n ...result,\n return:\n 'return' in result\n ? result.operationPerformed === 'update'\n ? params.updateParams && 'method' in params.updateParams\n ? result.return?.returnValue\n : undefined\n : params.createParams && 'method' in params.createParams\n ? result.return?.returnValue\n : undefined\n : undefined,\n deleteReturn:\n 'deleteReturn' in result && params.deleteParams && 'method' in params.deleteParams ? result.deleteReturn?.returnValue : undefined,\n },\n }\n }\n\n /**\n * Returns a new `AppClient` client for an app instance of the given ID.\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = factory.getAppClientById({ appId: 12345n })\n * ```\n */\n public getAppClientById(params: AppFactoryAppClientParams) {\n return new AppClient({\n ...params,\n algorand: this._algorand,\n appSpec: this._appSpec,\n appName: params.appName ?? this._appName,\n defaultSender: params.defaultSender ?? this._defaultSender,\n defaultSigner: params.defaultSigner ?? this._defaultSigner,\n approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,\n clearSourceMap: params.clearSourceMap ?? this._clearSourceMap,\n })\n }\n\n /**\n * Returns a new `AppClient` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = factory.getAppClientByCreatorAndName({ creatorAddress: 'CREATOR_ADDRESS', appName: 'my_app' })\n * ```\n */\n public getAppClientByCreatorAndName(params: AppFactoryResolveAppClientByCreatorAndNameParams) {\n return AppClient.fromCreatorAndName({\n ...params,\n algorand: this._algorand,\n appSpec: this._appSpec,\n appName: params.appName ?? this._appName,\n defaultSender: params.defaultSender ?? this._defaultSender,\n approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,\n clearSourceMap: params.clearSourceMap ?? this._clearSourceMap,\n })\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n exposeLogicError(e: Error, isClearStateProgram?: boolean): Error {\n return AppClient.exposeLogicError(e, this._appSpec, {\n isClearStateProgram,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n })\n }\n\n /**\n * Export the current source maps for the app.\n * @returns The source maps\n */\n exportSourceMaps(): AppSourceMaps {\n if (!this._approvalSourceMap || !this._clearSourceMap) {\n throw new Error(\n \"Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first\",\n )\n }\n\n return {\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n }\n }\n\n /**\n * Import source maps for the app.\n * @param sourceMaps The source maps to import\n */\n importSourceMaps(sourceMaps: AppSourceMaps) {\n this._approvalSourceMap = new ProgramSourceMap(sourceMaps.approvalSourceMap)\n this._clearSourceMap = new ProgramSourceMap(sourceMaps.clearSourceMap)\n }\n\n private getDeployTimeControl(control: 'updatable' | 'deletable'): boolean | undefined {\n const approval = this._appSpec.source?.approval ? Buffer.from(this._appSpec.source.approval, 'base64').toString('utf-8') : undefined\n // variable not present, so unknown control value\n if (!approval || !approval.includes(control === 'updatable' ? UPDATABLE_TEMPLATE_NAME : DELETABLE_TEMPLATE_NAME)) return undefined\n\n // A call is present and configured\n return (\n this._appSpec.bareActions.call.includes(control === 'updatable' ? 'UpdateApplication' : 'DeleteApplication') ||\n Object.values(this._appSpec.methods).some((c) =>\n c.actions.call.includes(control === 'updatable' ? 'UpdateApplication' : 'DeleteApplication'),\n )\n )\n }\n\n private getParamsMethods() {\n return {\n /** Return params for a create ABI call, including deploy-time TEAL template replacements and compilation if provided */\n create: async (params: AppFactoryCreateMethodCallParams) => {\n const compiled = await this.compile({ ...params, deployTimeParams: params.deployTimeParams ?? this._deployTimeParams })\n return this.getABIParams(\n {\n ...params,\n deployTimeParams: params.deployTimeParams ?? this._deployTimeParams,\n schema: params.schema ?? {\n globalByteSlices: this._appSpec.state.schema.global.bytes,\n globalInts: this._appSpec.state.schema.global.ints,\n localByteSlices: this._appSpec.state.schema.local.bytes,\n localInts: this._appSpec.state.schema.local.ints,\n },\n approvalProgram: compiled.approvalProgram,\n clearStateProgram: compiled.clearStateProgram,\n },\n params.onComplete ?? OnApplicationComplete.NoOp,\n ) satisfies AppCreateMethodCall\n },\n /** Return params for a deployment update ABI call */\n deployUpdate: (params: AppClientMethodCallParams) => {\n return this.getABIParams(params, OnApplicationComplete.UpdateApplication) satisfies DeployAppUpdateMethodCall\n },\n /** Return params for a deployment delete ABI call */\n deployDelete: (params: AppClientMethodCallParams) => {\n return this.getABIParams(params, OnApplicationComplete.DeleteApplication) satisfies DeployAppDeleteMethodCall\n },\n bare: {\n /** Return params for a create bare call, including deploy-time TEAL template replacements and compilation if provided */\n create: async (params?: AppFactoryCreateParams) => {\n return this.getBareParams(\n {\n ...params,\n deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams,\n schema: params?.schema ?? {\n globalByteSlices: this._appSpec.state.schema.global.bytes,\n globalInts: this._appSpec.state.schema.global.ints,\n localByteSlices: this._appSpec.state.schema.local.bytes,\n localInts: this._appSpec.state.schema.local.ints,\n },\n ...(await this.compile({ ...params, deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams })),\n },\n params?.onComplete ?? OnApplicationComplete.NoOp,\n ) satisfies AppCreateParams\n },\n /** Return params for a deployment update bare call */\n deployUpdate: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.UpdateApplication) satisfies DeployAppUpdateParams\n },\n /** Return params for a deployment delete bare call */\n deployDelete: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.DeleteApplication) satisfies DeployAppDeleteParams\n },\n },\n }\n }\n\n /** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */\n private async handleCallErrors<TResult>(call: () => Promise<TResult>) {\n try {\n return await call()\n } catch (e) {\n throw this.exposeLogicError(e as Error)\n }\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and stores\n * the source maps.\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param compilation Optional compilation parameters to use for the compilation\n * @returns The compilation result\n * @example\n * ```typescript\n * const result = await factory.compile()\n * ```\n */\n public async compile(compilation?: AppClientCompilationParams) {\n const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation)\n\n if (result.compiledApproval) {\n this._approvalSourceMap = result.compiledApproval.sourceMap\n }\n if (result.compiledClear) {\n this._clearSourceMap = result.compiledClear.sourceMap\n }\n\n return result\n }\n\n private getBareParams<\n TParams extends { sender?: ReadableAddress; signer?: TransactionSigner | AddressWithTransactionSigner } | undefined,\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n sender: this.getSender(params?.sender),\n signer: this.getSigner(params?.sender, params?.signer),\n onComplete,\n }\n }\n\n private getABIParams<\n TParams extends {\n method: string\n sender?: ReadableAddress\n signer?: TransactionSigner | AddressWithTransactionSigner\n args?: AppClientMethodCallParams['args']\n },\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n sender: this.getSender(params.sender),\n signer: this.getSigner(params.sender, params.signer),\n method: getABIMethod(params.method, this._appSpec),\n args: this.getCreateABIArgsWithDefaultValues(params.method, params.args),\n onComplete,\n }\n }\n\n private getCreateABIArgsWithDefaultValues(\n methodNameOrSignature: string,\n args: AppClientMethodCallParams['args'] | undefined,\n ): AppMethodCall<CommonAppCallParams>['args'] {\n const m = getABIMethod(methodNameOrSignature, this._appSpec)\n return args?.map((arg, i) => {\n const methodArg = m.args[i]\n if (arg !== undefined) {\n return arg\n }\n if (argTypeIsTransaction(methodArg.type)) {\n return arg\n }\n const defaultValue = methodArg.defaultValue\n if (defaultValue) {\n switch (defaultValue.source) {\n case 'literal': {\n const bytes = Buffer.from(defaultValue.data, 'base64')\n const value_type = defaultValue.type ?? methodArg.type\n return getABIDecodedValue(value_type, bytes)\n }\n default:\n throw new Error(`Can't provide default value for ${defaultValue.source} for a contract creation call`)\n }\n }\n throw new Error(`No value provided for required argument ${methodArg.name ?? `arg${i + 1}`} in call to method ${m.name}`)\n })\n }\n\n /** Returns the sender for a call, using the `defaultSender`\n * if none provided and throws an error if neither provided */\n private getSender(sender: ReadableAddress | undefined): Address {\n if (!sender && !this._defaultSender) {\n throw new Error(`No sender provided and no default sender present in app factory for call to app ${this._appName}`)\n }\n return getAddress(sender ?? this._defaultSender!)\n }\n\n /** Returns the signer for a call, using the provided signer or the `defaultSigner`\n * if no signer was provided and the sender resolves to the default sender, the call will use default signer\n * or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */\n private getSigner(\n sender: ReadableAddress | undefined,\n signer: TransactionSigner | AddressWithTransactionSigner | undefined,\n ): TransactionSigner | AddressWithTransactionSigner | undefined {\n return signer ?? (!sender || sender === this._defaultSender ? this._defaultSigner : undefined)\n }\n}\n"],"mapp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;CAKJ,AAAQ,UAAU,QAA8C;AAC9D,MAAI,CAAC,UAAU,CAAC,KAAK,eACnB,OAAM,IAAI,MAAM,mFAAmF,KAAK,WAAW;AAErH,SAAO,WAAW,UAAU,KAAK,eAAgB;;;;;CAMnD,AAAQ,UACN,QACA,QAC8D;AAC9D,SAAO,WAAW,CAAC,UAAU,WAAW,KAAK,iBAAiB,KAAK,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"app-factory.mjs","names":["result"],"sources":["../../src/types/app-factory.ts"],"sourcesContent":["import { Arc56Contract, argTypeIsTransaction, getABIDecodedValue, getABIMethod } from '@algorandfoundation/algokit-abi'\nimport { Address, Expand, ProgramSourceMap, ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, OnApplicationComplete, TransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { type AlgorandClient } from './algorand-client'\nimport { AppCompilationResult, DELETABLE_TEMPLATE_NAME, TealTemplateParams, UPDATABLE_TEMPLATE_NAME } from './app'\nimport {\n AppClient,\n AppClientBareCallParams,\n AppClientCompilationParams,\n AppClientMethodCallParams,\n AppClientParams,\n AppSourceMaps,\n ResolveAppClientByCreatorAndName,\n} from './app-client'\nimport {\n AppDeployParams,\n DeployAppDeleteMethodCall,\n DeployAppDeleteParams,\n DeployAppUpdateMethodCall,\n DeployAppUpdateParams,\n} from './app-deployer'\nimport { AppSpec } from './app-spec'\nimport { AppCreateMethodCall, AppCreateParams, AppMethodCall, CommonAppCallParams } from './composer'\nimport { SendParams } from './transaction'\n\n/** Parameters to create an app client */\nexport interface AppFactoryParams {\n /** The ARC-56 or ARC-32 application spec as either:\n * * Parsed JSON ARC-56 `Contract`\n * * Parsed JSON ARC-32 `AppSpec`\n * * Raw JSON string (in either ARC-56 or ARC-32 format)\n */\n appSpec: Arc56Contract | AppSpec | string\n\n /** `AlgorandClient` instance */\n algorand: AlgorandClient\n\n /**\n * Optional override for the app name; used for on-chain metadata and lookups.\n * Defaults to the ARC-32/ARC-56 app spec name.\n */\n appName?: string\n\n /** Optional address to use for the account to use as the default sender for calls. */\n defaultSender?: ReadableAddress\n\n /** Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from `AlgorandClient`). */\n defaultSigner?: TransactionSigner\n\n /** The version of app that is / will be deployed; defaults to 1.0 */\n version?: string\n\n /**\n * Whether or not the contract should have deploy-time immutability control set, undefined = ignore.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n updatable?: boolean\n\n /**\n * Whether or not the contract should have deploy-time permanence control set, undefined = ignore.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n deletable?: boolean\n\n /**\n * Optional deploy-time TEAL template replacement parameters.\n * If specified here will get used in calls to `deploy` and `create` calls unless overridden in those calls.\n *\n * Useful if you want to vend multiple contracts from the same factory without specifying this value\n * for each call.\n */\n deployTimeParams?: TealTemplateParams\n}\n\n/** onComplete parameter for a create app call */\nexport type CreateOnComplete = {\n onComplete?: Exclude<OnApplicationComplete, OnApplicationComplete.ClearState>\n}\n\n/** Specifies a schema used for creating an app */\nexport type CreateSchema = {\n /** The state schema for the app. This is immutable once the app is created. By default uses the ARC32/ARC-56 spec. */\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/** Params to specify a bare (raw) create call for an app */\nexport type AppFactoryCreateParams = Expand<AppClientBareCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema>\n\n/** Params to specify a create method call for an app */\nexport type AppFactoryCreateMethodCallParams = Expand<\n AppClientMethodCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema\n>\n\n/** Params to get an app client by ID from an app factory. */\nexport type AppFactoryAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>\n\n/** Params to get an app client by creator address and name from an app factory. */\nexport type AppFactoryResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>\n\n/** Parameters to define a deployment for an `AppFactory` */\nexport type AppFactoryDeployParams = Expand<\n Omit<AppDeployParams, 'createParams' | 'updateParams' | 'deleteParams' | 'metadata'> & {\n /** Create transaction parameters to use if a create needs to be issued as part of deployment */\n createParams?:\n | Expand<AppClientMethodCallParams & CreateOnComplete & CreateSchema>\n | Expand<AppClientBareCallParams & CreateOnComplete & CreateSchema>\n /** Update transaction parameters to use if a create needs to be issued as part of deployment */\n updateParams?: AppClientMethodCallParams | AppClientBareCallParams\n /** Delete transaction parameters to use if a create needs to be issued as part of deployment */\n deleteParams?: AppClientMethodCallParams | AppClientBareCallParams\n /**\n * Whether or not the contract should have deploy-time immutability control set.\n * `undefined` = use AppFactory constructor value if set or base it on the app spec.\n */\n updatable?: boolean\n /**\n * Whether or not the contract should have deploy-time permanence control set.\n * `undefined` = use AppFactory constructor value if set or base it on the app spec.\n */\n deletable?: boolean\n /** Override the app name for this deployment */\n appName?: string\n }\n>\n\n/**\n * ARC-56/ARC-32 app factory that, for a given app spec, allows you to create\n * and deploy one or more app instances and to create one or more app clients\n * to interact with those (or other) app instances.\n */\nexport class AppFactory {\n private _appSpec: Arc56Contract\n private _appName: string\n private _algorand: AlgorandClient\n private _version: string\n private _defaultSender?: Address\n private _defaultSigner?: TransactionSigner\n private _deployTimeParams?: TealTemplateParams\n private _updatable?: boolean\n private _deletable?: boolean\n\n private _approvalSourceMap: ProgramSourceMap | undefined\n private _clearSourceMap: ProgramSourceMap | undefined\n\n private _paramsMethods: ReturnType<AppFactory['getParamsMethods']>\n\n /**\n * Create a new app factory.\n * @param params The parameters to create the app factory\n * @returns The `AppFactory` instance\n * @example\n * ```typescript\n * const appFactory = new AppFactory({\n * appSpec: appSpec,\n * algorand: AlgorandClient.mainNet(),\n * })\n */\n constructor(params: AppFactoryParams) {\n this._appSpec = AppClient.normaliseAppSpec(params.appSpec)\n this._appName = params.appName ?? this._appSpec.name\n this._algorand = params.algorand\n this._version = params.version ?? '1.0'\n this._defaultSender = getOptionalAddress(params.defaultSender)\n this._defaultSigner = params.defaultSigner\n this._deployTimeParams = params.deployTimeParams\n this._updatable = params.updatable\n this._deletable = params.deletable\n this._paramsMethods = this.getParamsMethods()\n }\n\n /** The name of the app (from the ARC-32 / ARC-56 app spec or override). */\n public get appName() {\n return this._appName\n }\n\n /** The ARC-56 app spec being used */\n get appSpec() {\n return this._appSpec\n }\n\n /** Return the algorand client this factory is using. */\n get algorand() {\n return this._algorand\n }\n\n /** Get parameters to create transactions (create and deploy related calls) for the current app.\n *\n * A good mental model for this is that these parameters represent a deferred transaction creation.\n * @example Create a transaction in the future using Algorand Client\n * ```typescript\n * const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})\n * // ...\n * await algorand.send.AppCreateMethodCall(createAppParams)\n * ```\n * @example Define a nested transaction as an ABI argument\n * ```typescript\n * const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})\n * await appClient.send.call({method: 'my_method', args: [createAppParams]})\n * ```\n */\n get params() {\n return this._paramsMethods\n }\n\n /** Create transactions for the current app */\n readonly createTransaction = {\n /** Create bare (raw) transactions for the current app */\n bare: {\n /**\n * Create a create app call transaction using a bare (raw) create call.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the create call transaction\n * @returns The create call transaction\n */\n create: async (params?: AppFactoryCreateParams) => {\n return this._algorand.createTransaction.appCreate(await this.params.bare.create(params))\n },\n },\n\n /**\n * Create a create app call transaction using an ABI create call.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the create call transaction\n * @returns The create call transaction\n */\n create: async (params: AppFactoryCreateMethodCallParams) => {\n return this._algorand.createTransaction.appCreateMethodCall(await this.params.create(params))\n },\n }\n\n /** Send transactions to the current app */\n readonly send = {\n /** Send bare (raw) transactions for the current app */\n bare: {\n /**\n * Creates an instance of the app using a bare (raw) create call and returns the result\n * of the creation transaction and an app client to interact with that app instance.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the app\n * @returns The app client and the result of the creation transaction\n */\n create: async (params?: AppFactoryCreateParams & SendParams) => {\n const updatable = params?.updatable ?? this._updatable\n const deletable = params?.deletable ?? this._deletable\n const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams\n const compiled = await this.compile({ deployTimeParams, updatable, deletable })\n const result = await this.handleCallErrors(async () => ({\n ...(await this._algorand.send.appCreate(await this.params.bare.create({ ...params, updatable, deletable, deployTimeParams }))),\n return: undefined,\n }))\n return {\n appClient: this.getAppClientById({\n appId: result.appId,\n }),\n result: {\n ...result,\n ...(compiled as Partial<AppCompilationResult>),\n },\n }\n },\n },\n\n /**\n * Creates an instance of the app and returns the result of the creation\n * transaction and an app client to interact with that app instance.\n *\n * Performs deploy-time TEAL template placeholder substitutions (if specified).\n * @param params The parameters to create the app\n * @returns The app client and the result of the creation transaction\n */\n create: async (params: AppFactoryCreateMethodCallParams & SendParams) => {\n const updatable = params?.updatable ?? this._updatable\n const deletable = params?.deletable ?? this._deletable\n const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams\n const compiled = await this.compile({ deployTimeParams, updatable, deletable })\n const result = await this.handleCallErrors(async () => {\n const result = await this._algorand.send.appCreateMethodCall(\n await this.params.create({ ...params, updatable, deletable, deployTimeParams }),\n )\n return {\n ...result,\n return: result.return?.returnValue,\n }\n })\n return {\n appClient: this.getAppClientById({\n appId: result.appId,\n }),\n result: {\n ...result,\n ...(compiled as Partial<AppCompilationResult>),\n },\n }\n },\n }\n\n /**\n * Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).\n *\n * **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.\n *\n * **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.\n *\n * **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.\n * @param params The arguments to control the app deployment\n * @returns The app client and the result of the deployment\n * @example\n * ```ts\n * const { appClient, result } = await factory.deploy({\n * createParams: {\n * sender: 'SENDER_ADDRESS',\n * approvalProgram: 'APPROVAL PROGRAM',\n * clearStateProgram: 'CLEAR PROGRAM',\n * schema: {\n * globalByteSlices: 0,\n * globalInts: 0,\n * localByteSlices: 0,\n * localInts: 0\n * }\n * },\n * updateParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * deleteParams: {\n * sender: 'SENDER_ADDRESS'\n * },\n * onSchemaBreak: 'append',\n * onUpdate: 'append'\n * })\n * ```\n */\n public async deploy(params: AppFactoryDeployParams) {\n const updatable = params.updatable ?? this._updatable ?? this.getDeployTimeControl('updatable')\n const deletable = params.deletable ?? this._deletable ?? this.getDeployTimeControl('deletable')\n const deployTimeParams = params.deployTimeParams ?? this._deployTimeParams\n\n // Compile using a appID 0 AppClient so we can register the error handler and use the programs\n // to identify the app within the error handler (because we can't use app ID 0)\n const tempAppClient = this.getAppClientById({ appId: 0n })\n const compiled = await tempAppClient.compile({ deployTimeParams, updatable, deletable })\n\n const deployResult = await this._algorand.appDeployer.deploy({\n ...params,\n createParams: await (params.createParams && 'method' in params.createParams\n ? this.params.create({ ...params.createParams, updatable, deletable, deployTimeParams })\n : this.params.bare.create({ ...params.createParams, updatable, deletable, deployTimeParams })),\n updateParams:\n params.updateParams && 'method' in params.updateParams\n ? this.params.deployUpdate(params.updateParams)\n : this.params.bare.deployUpdate(params.updateParams),\n deleteParams:\n params.deleteParams && 'method' in params.deleteParams\n ? this.params.deployDelete(params.deleteParams)\n : this.params.bare.deployDelete(params.deleteParams),\n metadata: {\n name: params.appName ?? this._appName,\n version: this._version,\n updatable,\n deletable,\n },\n })\n const appClient = this.getAppClientById({\n appId: deployResult.appId,\n appName: params.appName,\n })\n const result = {\n ...deployResult,\n ...(compiled as Partial<AppCompilationResult>),\n }\n return {\n appClient,\n result: {\n ...result,\n return:\n 'return' in result\n ? result.operationPerformed === 'update'\n ? params.updateParams && 'method' in params.updateParams\n ? result.return?.returnValue\n : undefined\n : params.createParams && 'method' in params.createParams\n ? result.return?.returnValue\n : undefined\n : undefined,\n deleteReturn:\n 'deleteReturn' in result && params.deleteParams && 'method' in params.deleteParams ? result.deleteReturn?.returnValue : undefined,\n },\n }\n }\n\n /**\n * Returns a new `AppClient` client for an app instance of the given ID.\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = factory.getAppClientById({ appId: 12345n })\n * ```\n */\n public getAppClientById(params: AppFactoryAppClientParams) {\n return new AppClient({\n ...params,\n algorand: this._algorand,\n appSpec: this._appSpec,\n appName: params.appName ?? this._appName,\n defaultSender: params.defaultSender ?? this._defaultSender,\n defaultSigner: params.defaultSigner ?? this._defaultSigner,\n approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,\n clearSourceMap: params.clearSourceMap ?? this._clearSourceMap,\n })\n }\n\n /**\n * Returns a new `AppClient` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The `AppClient` instance\n * @example\n * ```typescript\n * const appClient = factory.getAppClientByCreatorAndName({ creatorAddress: 'CREATOR_ADDRESS', appName: 'my_app' })\n * ```\n */\n public getAppClientByCreatorAndName(params: AppFactoryResolveAppClientByCreatorAndNameParams) {\n return AppClient.fromCreatorAndName({\n ...params,\n algorand: this._algorand,\n appSpec: this._appSpec,\n appName: params.appName ?? this._appName,\n defaultSender: params.defaultSender ?? this._defaultSender,\n approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,\n clearSourceMap: params.clearSourceMap ?? this._clearSourceMap,\n })\n }\n\n /**\n * Takes an error that may include a logic error from a call to the current app and re-exposes the\n * error to include source code information via the source map and ARC-56 spec.\n * @param e The error to parse\n * @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)\n * @returns The new error, or if there was no logic error or source map then the wrapped error with source details\n */\n exposeLogicError(e: Error, isClearStateProgram?: boolean): Error {\n return AppClient.exposeLogicError(e, this._appSpec, {\n isClearStateProgram,\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n })\n }\n\n /**\n * Export the current source maps for the app.\n * @returns The source maps\n */\n exportSourceMaps(): AppSourceMaps {\n if (!this._approvalSourceMap || !this._clearSourceMap) {\n throw new Error(\n \"Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first\",\n )\n }\n\n return {\n approvalSourceMap: this._approvalSourceMap,\n clearSourceMap: this._clearSourceMap,\n }\n }\n\n /**\n * Import source maps for the app.\n * @param sourceMaps The source maps to import\n */\n importSourceMaps(sourceMaps: AppSourceMaps) {\n this._approvalSourceMap = new ProgramSourceMap(sourceMaps.approvalSourceMap)\n this._clearSourceMap = new ProgramSourceMap(sourceMaps.clearSourceMap)\n }\n\n private getDeployTimeControl(control: 'updatable' | 'deletable'): boolean | undefined {\n const approval = this._appSpec.source?.approval ? Buffer.from(this._appSpec.source.approval, 'base64').toString('utf-8') : undefined\n // variable not present, so unknown control value\n if (!approval || !approval.includes(control === 'updatable' ? UPDATABLE_TEMPLATE_NAME : DELETABLE_TEMPLATE_NAME)) return undefined\n\n // A call is present and configured\n return (\n this._appSpec.bareActions.call.includes(control === 'updatable' ? 'UpdateApplication' : 'DeleteApplication') ||\n Object.values(this._appSpec.methods).some((c) =>\n c.actions.call.includes(control === 'updatable' ? 'UpdateApplication' : 'DeleteApplication'),\n )\n )\n }\n\n private getParamsMethods() {\n return {\n /** Return params for a create ABI call, including deploy-time TEAL template replacements and compilation if provided */\n create: async (params: AppFactoryCreateMethodCallParams) => {\n const compiled = await this.compile({ ...params, deployTimeParams: params.deployTimeParams ?? this._deployTimeParams })\n return this.getABIParams(\n {\n ...params,\n deployTimeParams: params.deployTimeParams ?? this._deployTimeParams,\n schema: params.schema ?? {\n globalByteSlices: this._appSpec.state.schema.global.bytes,\n globalInts: this._appSpec.state.schema.global.ints,\n localByteSlices: this._appSpec.state.schema.local.bytes,\n localInts: this._appSpec.state.schema.local.ints,\n },\n approvalProgram: compiled.approvalProgram,\n clearStateProgram: compiled.clearStateProgram,\n },\n params.onComplete ?? OnApplicationComplete.NoOp,\n ) satisfies AppCreateMethodCall\n },\n /** Return params for a deployment update ABI call */\n deployUpdate: (params: AppClientMethodCallParams) => {\n return this.getABIParams(params, OnApplicationComplete.UpdateApplication) satisfies DeployAppUpdateMethodCall\n },\n /** Return params for a deployment delete ABI call */\n deployDelete: (params: AppClientMethodCallParams) => {\n return this.getABIParams(params, OnApplicationComplete.DeleteApplication) satisfies DeployAppDeleteMethodCall\n },\n bare: {\n /** Return params for a create bare call, including deploy-time TEAL template replacements and compilation if provided */\n create: async (params?: AppFactoryCreateParams) => {\n return this.getBareParams(\n {\n ...params,\n deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams,\n schema: params?.schema ?? {\n globalByteSlices: this._appSpec.state.schema.global.bytes,\n globalInts: this._appSpec.state.schema.global.ints,\n localByteSlices: this._appSpec.state.schema.local.bytes,\n localInts: this._appSpec.state.schema.local.ints,\n },\n ...(await this.compile({ ...params, deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams })),\n },\n params?.onComplete ?? OnApplicationComplete.NoOp,\n ) satisfies AppCreateParams\n },\n /** Return params for a deployment update bare call */\n deployUpdate: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.UpdateApplication) satisfies DeployAppUpdateParams\n },\n /** Return params for a deployment delete bare call */\n deployDelete: (params?: AppClientBareCallParams) => {\n return this.getBareParams(params, OnApplicationComplete.DeleteApplication) satisfies DeployAppDeleteParams\n },\n },\n }\n }\n\n /** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */\n private async handleCallErrors<TResult>(call: () => Promise<TResult>) {\n try {\n return await call()\n } catch (e) {\n throw this.exposeLogicError(e as Error)\n }\n }\n\n /**\n * Compiles the approval and clear state programs (if TEAL templates provided),\n * performing any provided deploy-time parameter replacement and stores\n * the source maps.\n *\n * If no TEAL templates provided it will use any byte code provided in the app spec.\n *\n * Will store any generated source maps for later use in debugging.\n * @param compilation Optional compilation parameters to use for the compilation\n * @returns The compilation result\n * @example\n * ```typescript\n * const result = await factory.compile()\n * ```\n */\n public async compile(compilation?: AppClientCompilationParams) {\n const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation)\n\n if (result.compiledApproval) {\n this._approvalSourceMap = result.compiledApproval.sourceMap\n }\n if (result.compiledClear) {\n this._clearSourceMap = result.compiledClear.sourceMap\n }\n\n return result\n }\n\n private getBareParams<\n TParams extends { sender?: ReadableAddress; signer?: TransactionSigner | AddressWithTransactionSigner } | undefined,\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n sender: this.getSender(params?.sender),\n signer: this.getSigner(params?.sender, params?.signer),\n onComplete,\n }\n }\n\n private getABIParams<\n TParams extends {\n method: string\n sender?: ReadableAddress\n signer?: TransactionSigner | AddressWithTransactionSigner\n args?: AppClientMethodCallParams['args']\n },\n TOnComplete extends OnApplicationComplete,\n >(params: TParams, onComplete: TOnComplete) {\n return {\n ...params,\n sender: this.getSender(params.sender),\n signer: this.getSigner(params.sender, params.signer),\n method: getABIMethod(params.method, this._appSpec),\n args: this.getCreateABIArgsWithDefaultValues(params.method, params.args),\n onComplete,\n }\n }\n\n private getCreateABIArgsWithDefaultValues(\n methodNameOrSignature: string,\n args: AppClientMethodCallParams['args'] | undefined,\n ): AppMethodCall<CommonAppCallParams>['args'] {\n const m = getABIMethod(methodNameOrSignature, this._appSpec)\n return args?.map((arg, i) => {\n const methodArg = m.args[i]\n if (arg !== undefined) {\n return arg\n }\n if (argTypeIsTransaction(methodArg.type)) {\n return arg\n }\n const defaultValue = methodArg.defaultValue\n if (defaultValue) {\n switch (defaultValue.source) {\n case 'literal': {\n const bytes = Buffer.from(defaultValue.data, 'base64')\n const value_type = defaultValue.type ?? methodArg.type\n return getABIDecodedValue(value_type, bytes)\n }\n default:\n throw new Error(`Can't provide default value for ${defaultValue.source} for a contract creation call`)\n }\n }\n throw new Error(`No value provided for required argument ${methodArg.name ?? `arg${i + 1}`} in call to method ${m.name}`)\n })\n }\n\n /** Returns the sender for a call, using the `defaultSender`\n * if none provided and throws an error if neither provided */\n private getSender(sender: ReadableAddress | undefined): Address {\n if (!sender && !this._defaultSender) {\n throw new Error(`No sender provided and no default sender present in app factory for call to app ${this._appName}`)\n }\n return getAddress(sender ?? this._defaultSender!)\n }\n\n /** Returns the signer for a call, using the provided signer or the `defaultSigner`\n * if no signer was provided and the sender resolves to the default sender, the call will use default signer\n * or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */\n private getSigner(\n sender: ReadableAddress | undefined,\n signer: TransactionSigner | AddressWithTransactionSigner | undefined,\n ): TransactionSigner | AddressWithTransactionSigner | undefined {\n return signer ?? (!sender || sender === this._defaultSender ? this._defaultSigner : undefined)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqJA,IAAa,aAAb,MAAwB;CACtB,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ;CACR,AAAQ;CAER,AAAQ;;;;;;;;;;;;CAaR,YAAY,QAA0B;AACpC,OAAK,WAAW,UAAU,iBAAiB,OAAO,QAAQ;AAC1D,OAAK,WAAW,OAAO,WAAW,KAAK,SAAS;AAChD,OA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
44
|
globalByteSlices: number;
|
|
45
45
|
/** Any extra pages that are needed for the smart contract. */
|
|
46
46
|
extraProgramPages?: number;
|
|
47
|
+
/** The number of updates to the application programs */
|
|
48
|
+
version?: number;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Something that identifies an app box name - either a:
|
|
@@ -267,7 +269,7 @@ declare class AppManager {
|
|
|
267
269
|
* const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));
|
|
268
270
|
* ```
|
|
269
271
|
*/
|
|
270
|
-
static getABIReturn(confirmation: PendingTransactionResponse, method: ABIMethod | undefined): ABIReturn | undefined;
|
|
272
|
+
static getABIReturn(confirmation: PendingTransactionResponse | undefined, method: ABIMethod | undefined): ABIReturn | undefined;
|
|
271
273
|
private static hasAbiReturnPrefix;
|
|
272
274
|
/**
|
|
273
275
|
* Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.
|
package/types/app-manager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_address = require('../packages/common/src/address.js');
|
|
2
|
-
const require_sourcemap = require('../packages/sdk/src/logic/sourcemap.js');
|
|
3
2
|
const require_app = require('./app.js');
|
|
3
|
+
const require_sourcemap = require('../packages/common/src/sourcemap.js');
|
|
4
4
|
|
|
5
5
|
//#region src/types/app-manager.ts
|
|
6
6
|
/** Allows management of application information. */
|
|
@@ -91,7 +91,7 @@ var AppManager = class AppManager {
|
|
|
91
91
|
* @returns The app information
|
|
92
92
|
*/
|
|
93
93
|
async getById(appId) {
|
|
94
|
-
const app = await this._algod.
|
|
94
|
+
const app = await this._algod.applicationById(appId);
|
|
95
95
|
const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({
|
|
96
96
|
key: kv.key,
|
|
97
97
|
value: kv.value
|
|
@@ -102,12 +102,13 @@ var AppManager = class AppManager {
|
|
|
102
102
|
approvalProgram: app.params.approvalProgram,
|
|
103
103
|
clearStateProgram: app.params.clearStateProgram,
|
|
104
104
|
creator: app.params.creator,
|
|
105
|
-
localInts:
|
|
106
|
-
localByteSlices:
|
|
107
|
-
globalInts:
|
|
108
|
-
globalByteSlices:
|
|
109
|
-
extraProgramPages:
|
|
110
|
-
globalState: AppManager.decodeAppState(convertedGlobalState)
|
|
105
|
+
localInts: app.params.localStateSchema?.numUints ?? 0,
|
|
106
|
+
localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,
|
|
107
|
+
globalInts: app.params.globalStateSchema?.numUints ?? 0,
|
|
108
|
+
globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,
|
|
109
|
+
extraProgramPages: app.params.extraProgramPages ?? 0,
|
|
110
|
+
globalState: AppManager.decodeAppState(convertedGlobalState),
|
|
111
|
+
version: app.params.version
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
@@ -154,7 +155,7 @@ var AppManager = class AppManager {
|
|
|
154
155
|
* ```
|
|
155
156
|
*/
|
|
156
157
|
async getBoxNames(appId) {
|
|
157
|
-
return (await this._algod.
|
|
158
|
+
return (await this._algod.applicationBoxes(appId)).boxes.map((b) => {
|
|
158
159
|
return {
|
|
159
160
|
nameRaw: b.name,
|
|
160
161
|
nameBase64: Buffer.from(b.name).toString("base64"),
|
|
@@ -175,7 +176,7 @@ var AppManager = class AppManager {
|
|
|
175
176
|
async getBoxValue(appId, boxName) {
|
|
176
177
|
const boxId = typeof boxName === "object" && "nameRaw" in boxName ? boxName.nameRaw : boxName;
|
|
177
178
|
const name = AppManager.getBoxReference(boxId).name;
|
|
178
|
-
return (await this._algod.
|
|
179
|
+
return (await this._algod.applicationBoxByName(Number(appId), name)).value;
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* Returns the value of the given box names for the given app.
|
|
@@ -297,7 +298,12 @@ var AppManager = class AppManager {
|
|
|
297
298
|
* ```
|
|
298
299
|
*/
|
|
299
300
|
static getABIReturn(confirmation, method) {
|
|
300
|
-
if (!method ||
|
|
301
|
+
if (!method || !confirmation) return;
|
|
302
|
+
if (method.returns.type === "void") return {
|
|
303
|
+
method,
|
|
304
|
+
rawReturnValue: void 0,
|
|
305
|
+
returnValue: void 0
|
|
306
|
+
};
|
|
301
307
|
try {
|
|
302
308
|
const logs = confirmation.logs || [];
|
|
303
309
|
if (logs.length === 0) throw new Error(`App call transaction did not log a return value`);
|
package/types/app-manager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-manager.js","names":["ProgramSourceMap","getApplicationAddress","getAddress","valueBase64: string","valueRaw: Buffer","ABI_RETURN_PREFIX","UPDATABLE_TEMPLATE_NAME","DELETABLE_TEMPLATE_NAME","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport { ProgramSourceMap } from '@algorandfoundation/sdk'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.getApplicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: Number(app.params.localStateSchema?.numUint ?? 0),\n localByteSlices: Number(app.params.localStateSchema?.numByteSlice ?? 0),\n globalInts: Number(app.params.globalStateSchema?.numUint ?? 0),\n globalByteSlices: Number(app.params.globalStateSchema?.numByteSlice ?? 0),\n extraProgramPages: Number(app.params.extraProgramPages ?? 0),\n globalState: AppManager.decodeAppState(convertedGlobalState),\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({\n key: kv.key,\n value: kv.value,\n }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.getApplicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return {\n nameRaw: b.name,\n nameBase64: Buffer.from(b.name).toString('base64'),\n name: Buffer.from(b.name).toString('utf-8'),\n }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.getApplicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = {\n keyRaw,\n keyBase64,\n value: BigInt(value),\n }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || method.returns.type === 'void') {\n return undefined\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return {\n method: method,\n rawReturnValue,\n decodeError: undefined,\n returnValue: method.returns.type.decode(rawReturnValue),\n }\n } catch (err) {\n return {\n method: method,\n rawReturnValue: undefined,\n decodeError: err as Error,\n returnValue: undefined,\n }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAkGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkBhB,MAAM,YAAY,UAAyC;AACzD,MAAI,KAAK,oBAAoB,UAC3B,QAAO,KAAK,oBAAoB;EAGlC,MAAM,WAAW,MAAM,KAAK,OAAO,YAAY,UAAU,EAAE,WAAW,MAAM,CAAC;EAC7E,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AAa,GAAG,MAChE,iBAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
|
|
1
|
+
{"version":3,"file":"app-manager.js","names":["ProgramSourceMap","getApplicationAddress","getAddress","valueBase64: string","valueRaw: Buffer","ABI_RETURN_PREFIX","UPDATABLE_TEMPLATE_NAME","DELETABLE_TEMPLATE_NAME","result: string[]"],"sources":["../../src/types/app-manager.ts"],"sourcesContent":["import { ABIMethod, ABIReturn, ABIType, ABIValue } from '@algorandfoundation/algokit-abi'\nimport { AlgodClient, EvalDelta, PendingTransactionResponse, TealValue } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ProgramSourceMap, ReadableAddress, getAddress, getApplicationAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, BoxReference as TransactionBoxReference } from '@algorandfoundation/algokit-transact'\nimport {\n ABI_RETURN_PREFIX,\n BoxName,\n DELETABLE_TEMPLATE_NAME,\n UPDATABLE_TEMPLATE_NAME,\n type AppState,\n type CompiledTeal,\n type TealTemplateParams,\n} from './app'\n\n/** Information about an app. */\nexport interface AppInformation {\n /** The ID of the app. */\n appId: bigint\n /** The escrow address that the app operates with. */\n appAddress: Address\n /**\n * Approval program.\n */\n approvalProgram: Uint8Array\n /**\n * Clear state program.\n */\n clearStateProgram: Uint8Array\n /**\n * The address that created this application. This is the address where the\n * parameters and global state for this application can be found.\n */\n creator: Address\n /**\n * Current global state values.\n */\n globalState: AppState\n /** The number of allocated ints in per-user local state. */\n localInts: number\n /** The number of allocated byte slices in per-user local state. */\n localByteSlices: number\n /** The number of allocated ints in global state. */\n globalInts: number\n /** The number of allocated byte slices in global state. */\n globalByteSlices: number\n /** Any extra pages that are needed for the smart contract. */\n extraProgramPages?: number\n /** The number of updates to the application programs */\n version?: number\n}\n\n/**\n * Something that identifies an app box name - either a:\n * * `Uint8Array` (the actual binary of the box name)\n * * `string` (that will be encoded to a `Uint8Array`)\n * * `AddressWithSigner` (that will be encoded into the\n * public key address of the corresponding account)\n */\nexport type BoxIdentifier = string | Uint8Array | AddressWithTransactionSigner\n\n/**\n * A grouping of the app ID and name identifier to reference an app box.\n */\nexport interface BoxReference {\n /**\n * A unique application id\n */\n appId: bigint\n /**\n * Identifier for a box name\n */\n name: BoxIdentifier\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValueRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The name of the box to return either as a string, binary array or `BoxName` */\n boxName: BoxIdentifier\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/**\n * Parameters to get and decode a box value as an ABI type.\n */\nexport interface BoxValuesRequestParams {\n /** The ID of the app return box names for */\n appId: bigint\n /** The names of the boxes to return either as a string, binary array or BoxName` */\n boxNames: BoxIdentifier[]\n /** The ABI type to decode the value using */\n type: ABIType\n}\n\n/** Allows management of application information. */\nexport class AppManager {\n private _algod: AlgodClient\n private _compilationResults: Record<string, CompiledTeal> = {}\n\n /**\n * Creates an `AppManager`\n * @param algod An algod instance\n */\n constructor(algod: AlgodClient) {\n this._algod = algod\n }\n\n /**\n * Compiles the given TEAL using algod and returns the result, including source map.\n *\n * The result of this compilation is also cached keyed by the TEAL\n * code so it can be retrieved via `getCompilationResult`.\n *\n * This function is re-entrant; it will only compile the same code once.\n *\n * @param tealCode The TEAL code\n * @returns The information about the compiled file\n * @example\n * ```typescript\n * const compiled = await appManager.compileTeal(tealProgram)\n * ```\n */\n async compileTeal(tealCode: string): Promise<CompiledTeal> {\n if (this._compilationResults[tealCode]) {\n return this._compilationResults[tealCode]\n }\n\n const compiled = await this._algod.tealCompile(tealCode, { sourcemap: true })\n const result = {\n teal: tealCode,\n compiled: compiled.result,\n compiledHash: compiled.hash,\n compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),\n sourceMap: new ProgramSourceMap(compiled.sourcemap as { version: number; sources: string[]; names: string[]; mappings: string }),\n }\n this._compilationResults[tealCode] = result\n\n return result\n }\n\n /**\n * Performs template substitution of a teal template and compiles it, returning the compiled result.\n *\n * Looks for `TMPL_{parameter}` for template replacements and replaces AlgoKit deploy-time control parameters\n * if deployment metadata is specified.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * @param tealTemplateCode The TEAL logic to compile\n * @param templateParams Any parameters to replace in the .teal file before compiling\n * @param deploymentMetadata The deployment metadata the app will be deployed with\n * @returns The information about the compiled code\n * @example\n * ```typescript\n * const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })\n * ```\n */\n async compileTealTemplate(\n tealTemplateCode: string,\n templateParams?: TealTemplateParams,\n deploymentMetadata?: { updatable?: boolean; deletable?: boolean },\n ): Promise<CompiledTeal> {\n let tealCode = AppManager.stripTealComments(tealTemplateCode)\n\n tealCode = AppManager.replaceTealTemplateParams(tealCode, templateParams)\n\n if (deploymentMetadata) {\n tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealCode, deploymentMetadata)\n }\n\n return await this.compileTeal(tealCode)\n }\n\n /**\n * Returns a previous compilation result.\n * @param tealCode The TEAL code\n * @returns The information about the previously compiled file\n * or `undefined` if that TEAL code wasn't previously compiled\n * @example\n * ```typescript\n * const compiled = appManager.getCompilationResult(tealProgram)\n * ```\n */\n getCompilationResult(tealCode: string): CompiledTeal | undefined {\n return this._compilationResults[tealCode]\n }\n\n /**\n * Returns the current app information for the app with the given ID.\n *\n * @example\n * ```typescript\n * const appInfo = await appManager.getById(12353n);\n * ```\n *\n * @param appId The ID of the app\n * @returns The app information\n */\n public async getById(appId: bigint): Promise<AppInformation> {\n const app = await this._algod.applicationById(appId)\n const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({ key: kv.key, value: kv.value }))\n\n return {\n appId: BigInt(app.id),\n appAddress: getApplicationAddress(app.id),\n approvalProgram: app.params.approvalProgram,\n clearStateProgram: app.params.clearStateProgram,\n creator: app.params.creator,\n localInts: app.params.localStateSchema?.numUints ?? 0,\n localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,\n globalInts: app.params.globalStateSchema?.numUints ?? 0,\n globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,\n extraProgramPages: app.params.extraProgramPages ?? 0,\n globalState: AppManager.decodeAppState(convertedGlobalState),\n version: app.params.version,\n }\n }\n\n /**\n * Returns the current global state values for the given app ID and account address\n *\n * @param appId The ID of the app to return global state for\n * @returns The current global state for the given app\n * @example\n * ```typescript\n * const globalState = await appManager.getGlobalState(12353n);\n * ```\n */\n public async getGlobalState(appId: bigint) {\n return (await this.getById(appId)).globalState\n }\n\n /**\n * Returns the current local state values for the given app ID and account address\n *\n * @param appId The ID of the app to return local state for\n * @param address The string address of the account to get local state for the given app\n * @returns The current local state for the given (app, account) combination\n * @example\n * ```typescript\n * const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');\n * ```\n */\n public async getLocalState(appId: bigint, address: ReadableAddress) {\n const appInfo = await this._algod.accountApplicationInformation(getAddress(address).toString(), Number(appId))\n\n if (!appInfo.appLocalState) {\n throw new Error(\"Couldn't find local state\")\n }\n\n // If keyValue is undefined or empty, return empty state\n if (!appInfo.appLocalState.keyValue || appInfo.appLocalState.keyValue.length === 0) {\n return {}\n }\n\n const convertedState = appInfo.appLocalState.keyValue.map((kv) => ({ key: kv.key, value: kv.value }))\n\n return AppManager.decodeAppState(convertedState)\n }\n\n /**\n * Returns the names of the current boxes for the given app.\n * @param appId The ID of the app return box names for\n * @returns The current box names\n * @example\n * ```typescript\n * const boxNames = await appManager.getBoxNames(12353n);\n * ```\n */\n public async getBoxNames(appId: bigint): Promise<BoxName[]> {\n const boxResult = await this._algod.applicationBoxes(appId)\n return boxResult.boxes.map((b: { name: Uint8Array }) => {\n return { nameRaw: b.name, nameBase64: Buffer.from(b.name).toString('base64'), name: Buffer.from(b.name).toString('utf-8') }\n })\n }\n\n /**\n * Returns the value of the given box name for the given app.\n * @param appId The ID of the app return box names for\n * @param boxName The name of the box to return either as a string, binary array or `BoxName`\n * @returns The current box value as a byte array\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValue(12353n, 'boxName');\n * ```\n */\n public async getBoxValue(appId: bigint, boxName: BoxIdentifier | BoxName): Promise<Uint8Array> {\n const boxId = typeof boxName === 'object' && 'nameRaw' in boxName ? boxName.nameRaw : boxName\n const name = AppManager.getBoxReference(boxId).name\n const boxResult = await this._algod.applicationBoxByName(Number(appId), name)\n return boxResult.value\n }\n\n /**\n * Returns the value of the given box names for the given app.\n * @param appId The ID of the app return box names for\n * @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`\n * @returns The current box values as a byte array in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);\n * ```\n */\n public async getBoxValues(appId: bigint, boxNames: (BoxIdentifier | BoxName)[]): Promise<Uint8Array[]> {\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValue(appId, boxName)))\n }\n\n /**\n * Returns the value of the given box name for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box value as an ABI value\n * @example\n * ```typescript\n * const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValueFromABIType(request: BoxValueRequestParams): Promise<ABIValue> {\n const { appId, boxName, type } = request\n const value = await this.getBoxValue(appId, boxName)\n return type.decode(value)\n }\n\n /**\n * Returns the value of the given box names for the given app decoded based on the given ABI type.\n * @param request The parameters for the box value request\n * @returns The current box values as an ABI value in the same order as the passed in box names\n * @example\n * ```typescript\n * const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });\n * ```\n */\n public async getBoxValuesFromABIType(request: BoxValuesRequestParams): Promise<ABIValue[]> {\n const { appId, boxNames, type } = request\n return await Promise.all(boxNames.map(async (boxName) => await this.getBoxValueFromABIType({ appId, boxName, type })))\n }\n\n /**\n * Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.\n * @param boxId The box to return a reference for\n * @returns The box reference ready to pass into a `algosdk.Transaction`\n * @example\n * ```typescript\n * const boxRef = AppManager.getBoxReference('boxName');\n * ```\n */\n public static getBoxReference(boxId: BoxIdentifier | BoxReference): TransactionBoxReference {\n const ref = typeof boxId === 'object' && 'appId' in boxId ? boxId : { appId: 0n, name: boxId }\n return {\n appId: ref.appId,\n name: typeof ref.name === 'string' ? new TextEncoder().encode(ref.name) : 'length' in ref.name ? ref.name : ref.name.addr.publicKey,\n } as TransactionBoxReference\n }\n\n /**\n * Converts an array of global/local state values from the algod api to a more friendly\n * generic object keyed by the UTF-8 value of the key.\n * @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`\n * @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values\n * @example\n * ```typescript\n * const stateValues = AppManager.decodeAppState(state);\n * ```\n */\n public static decodeAppState(state: { key: Uint8Array; value: TealValue | EvalDelta }[]): AppState {\n const stateValues = {} as AppState\n\n // Start with empty set\n for (const stateVal of state) {\n const keyBase64 = Buffer.from(stateVal.key).toString('base64')\n const keyRaw = stateVal.key\n const key = Buffer.from(stateVal.key).toString('utf-8')\n const tealValue = stateVal.value\n\n const dataTypeFlag = Number('action' in tealValue ? tealValue.action : tealValue.type)\n let valueBase64: string\n let valueRaw: Buffer\n switch (dataTypeFlag) {\n case 1:\n valueBase64 =\n typeof tealValue.bytes === 'string' ? tealValue.bytes : tealValue.bytes ? Buffer.from(tealValue.bytes).toString('base64') : ''\n valueRaw = Buffer.from(valueBase64, 'base64')\n stateValues[key] = {\n keyRaw,\n keyBase64,\n valueRaw: new Uint8Array(valueRaw),\n valueBase64: valueBase64,\n value: valueRaw.toString('utf-8'),\n }\n break\n case 2: {\n const value = tealValue.uint ?? 0\n stateValues[key] = { keyRaw, keyBase64, value: BigInt(value) }\n break\n }\n default:\n throw new Error(`Received unknown state data type of ${dataTypeFlag}`)\n }\n }\n\n return stateValues\n }\n\n /**\n * Returns any ABI return values for the given app call arguments and transaction confirmation.\n * @param confirmation The transaction confirmation from algod\n * @param method The ABI method\n * @returns The return value for the method call\n * @example\n * ```typescript\n * const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));\n * ```\n */\n public static getABIReturn(confirmation: PendingTransactionResponse | undefined, method: ABIMethod | undefined): ABIReturn | undefined {\n if (!method || !confirmation) {\n return undefined\n }\n\n if (method.returns.type === 'void') {\n return { method, rawReturnValue: undefined, returnValue: undefined }\n }\n\n try {\n const logs = confirmation.logs || []\n if (logs.length === 0) {\n throw new Error(`App call transaction did not log a return value`)\n }\n const lastLog = logs[logs.length - 1]\n if (!AppManager.hasAbiReturnPrefix(lastLog)) {\n throw new Error(`App call transaction did not log an ABI return value`)\n }\n\n const rawReturnValue = new Uint8Array(lastLog.slice(4))\n return { method: method, rawReturnValue, decodeError: undefined, returnValue: method.returns.type.decode(rawReturnValue) }\n } catch (err) {\n return { method: method, rawReturnValue: undefined, decodeError: err as Error, returnValue: undefined }\n }\n }\n\n private static hasAbiReturnPrefix(log: Uint8Array): boolean {\n if (log.length < ABI_RETURN_PREFIX.length) {\n return false\n }\n for (let i = 0; i < ABI_RETURN_PREFIX.length; i++) {\n if (log[i] !== ABI_RETURN_PREFIX[i]) {\n return false\n }\n }\n return true\n }\n\n /**\n * Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.\n *\n * * `TMPL_UPDATABLE` for updatability / immutability control\n * * `TMPL_DELETABLE` for deletability / permanence control\n *\n * Note: If these values are defined, but the corresponding `TMPL_*` value\n * isn't in the teal code it will throw an exception.\n *\n * @param tealTemplateCode The TEAL template code to substitute\n * @param params The deploy-time deployment control parameter value to replace\n * @returns The replaced TEAL code\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });\n * ```\n */\n static replaceTealTemplateDeployTimeControlParams(tealTemplateCode: string, params: { updatable?: boolean; deletable?: boolean }) {\n if (params.updatable !== undefined) {\n if (!tealTemplateCode.includes(UPDATABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time updatability control requested for app deployment, but ${UPDATABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, UPDATABLE_TEMPLATE_NAME, (params.updatable ? 1 : 0).toString())\n }\n\n if (params.deletable !== undefined) {\n if (!tealTemplateCode.includes(DELETABLE_TEMPLATE_NAME)) {\n throw new Error(\n `Deploy-time deletability control requested for app deployment, but ${DELETABLE_TEMPLATE_NAME} not present in TEAL code`,\n )\n }\n tealTemplateCode = replaceTemplateVariable(tealTemplateCode, DELETABLE_TEMPLATE_NAME, (params.deletable ? 1 : 0).toString())\n }\n\n return tealTemplateCode\n }\n\n /**\n * Performs template substitution of a teal file.\n *\n * Looks for `TMPL_{parameter}` for template replacements.\n *\n * @param tealTemplateCode The TEAL template code to make parameter replacements in\n * @param templateParams Any parameters to replace in the teal code\n * @returns The TEAL code with replacements\n * @example\n * ```typescript\n * const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });\n * ```\n */\n static replaceTealTemplateParams(tealTemplateCode: string, templateParams?: TealTemplateParams) {\n if (templateParams !== undefined) {\n for (const key in templateParams) {\n const value = templateParams[key]\n const token = `TMPL_${key.replace(/^TMPL_/, '')}`\n\n // If this is a number, first replace any byte representations of the number\n // These may appear in the TEAL in order to circumvent int compression and preserve PC values\n if (typeof value === 'number' || typeof value === 'bigint') {\n tealTemplateCode = tealTemplateCode.replace(new RegExp(`(?<=bytes )${token}`, 'g'), `0x${value.toString(16).padStart(16, '0')}`)\n\n // We could probably return here since mixing pushint and pushbytes is likely not going to happen, but might as well do both\n }\n\n tealTemplateCode = replaceTemplateVariable(\n tealTemplateCode,\n token,\n typeof value === 'string'\n ? `0x${Buffer.from(value, 'utf-8').toString('hex')}`\n : ArrayBuffer.isView(value)\n ? `0x${Buffer.from(value).toString('hex')}`\n : value.toString(),\n )\n }\n }\n\n return tealTemplateCode\n }\n\n /**\n * Remove comments from TEAL code (useful to reduce code size before compilation).\n *\n * @param tealCode The TEAL logic to strip\n * @returns The TEAL without comments\n * @example\n * ```typescript\n * const stripped = AppManager.stripTealComments(tealProgram);\n * ```\n */\n static stripTealComments(tealCode: string) {\n const stripCommentFromLine = (line: string) => {\n const commentIndex = findUnquotedString(line, '//')\n if (commentIndex === undefined) {\n return line\n }\n return line.slice(0, commentIndex).trimEnd()\n }\n\n return tealCode\n .split('\\n')\n .map((line) => stripCommentFromLine(line))\n .join('\\n')\n }\n}\n\n/**\n * Find the first string within a line of TEAL. Only matches outside of quotes and base64 are returned.\n * Returns undefined if not found\n */\nconst findUnquotedString = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n let index = startIndex\n let inQuotes = false\n let inBase64 = false\n\n while (index < endIndex) {\n const currentChar = line[index]\n if ((currentChar === ' ' || currentChar === '(') && !inQuotes && lastTokenBase64(line, index)) {\n // enter base64\n inBase64 = true\n } else if ((currentChar === ' ' || currentChar === ')') && !inQuotes && inBase64) {\n // exit base64\n inBase64 = false\n } else if (currentChar === '\\\\' && inQuotes) {\n // escaped char, skip next character\n index += 1\n } else if (currentChar === '\"') {\n // quote boundary\n inQuotes = !inQuotes\n } else if (!inQuotes && !inBase64 && line.startsWith(token, index)) {\n // can test for match\n return index\n }\n index += 1\n }\n return undefined\n}\n\nconst lastTokenBase64 = (line: string, index: number): boolean => {\n try {\n const tokens = line.slice(0, index).split(/\\s+/)\n const last = tokens[tokens.length - 1]\n return ['base64', 'b64'].includes(last)\n } catch {\n return false\n }\n}\n\nfunction replaceTemplateVariable(program: string, token: string, replacement: string): string {\n const result: string[] = []\n const tokenIndexOffset = replacement.length - token.length\n\n const programLines = program.split('\\n')\n\n for (const line of programLines) {\n const _commentIndex = findUnquotedString(line, '//')\n const commentIndex = _commentIndex === undefined ? line.length : _commentIndex\n let code = line.substring(0, commentIndex)\n const comment = line.substring(commentIndex)\n let trailingIndex = 0\n\n while (true) {\n const tokenIndex = findTemplateToken(code, token, trailingIndex)\n if (tokenIndex === undefined) {\n break\n }\n trailingIndex = tokenIndex + token.length\n const prefix = code.substring(0, tokenIndex)\n const suffix = code.substring(trailingIndex)\n code = `${prefix}${replacement}${suffix}`\n trailingIndex += tokenIndexOffset\n }\n result.push(code + comment)\n }\n\n return result.join('\\n')\n}\n\nconst findTemplateToken = (line: string, token: string, startIndex: number = 0, _endIndex?: number): number | undefined => {\n const endIndex = _endIndex === undefined ? line.length : _endIndex\n\n let index = startIndex\n while (index < endIndex) {\n const tokenIndex = findUnquotedString(line, token, index, endIndex)\n if (tokenIndex === undefined) {\n break\n }\n const trailingIndex = tokenIndex + token.length\n if (\n (tokenIndex === 0 || !isValidTokenCharacter(line[tokenIndex - 1])) &&\n (trailingIndex >= line.length || !isValidTokenCharacter(line[trailingIndex]))\n ) {\n return tokenIndex\n }\n index = trailingIndex\n }\n return undefined\n}\n\nfunction isValidTokenCharacter(char: string): boolean {\n return char.length === 1 && (/\\w/.test(char) || char === '_')\n}\n"],"mappings":";;;;;;AAmGA,IAAa,aAAb,MAAa,WAAW;CACtB,AAAQ;CACR,AAAQ,sBAAoD,EAAE;;;;;CAM9D,YAAY,OAAoB;AAC9B,OAAK,SAAS;;;;;;;;;;;;;;;;;CAkBhB,MAAM,YAAY,UAAyC;AACzD,MAAI,KAAK,oBAAoB,UAC3B,QAAO,KAAK,oBAAoB;EAGlC,MAAM,WAAW,MAAM,KAAK,OAAO,YAAY,UAAU,EAAE,WAAW,MAAM,CAAC;EAC7E,MAAM,SAAS;GACb,MAAM;GACN,UAAU,SAAS;GACnB,cAAc,SAAS;GACvB,uBAAuB,IAAI,WAA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BAAiB,KAAK,UAAU,CAAC,sBAAsB,KAAK,eAAe,EAE5E,QAAO;AAET,UAAQ;;;AAKZ,SAAS,sBAAsB,MAAuB;AACpD,QAAO,KAAK,WAAW,MAAM,KAAK,KAAK,KAAK,IAAI,SAAS"}
|
package/types/app-manager.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAddress, getApplicationAddress } from "../packages/common/src/address.mjs";
|
|
2
|
-
import { ProgramSourceMap } from "../packages/sdk/src/logic/sourcemap.mjs";
|
|
3
2
|
import { ABI_RETURN_PREFIX, DELETABLE_TEMPLATE_NAME, UPDATABLE_TEMPLATE_NAME } from "./app.mjs";
|
|
3
|
+
import { ProgramSourceMap } from "../packages/common/src/sourcemap.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/types/app-manager.ts
|
|
6
6
|
/** Allows management of application information. */
|
|
@@ -91,7 +91,7 @@ var AppManager = class AppManager {
|
|
|
91
91
|
* @returns The app information
|
|
92
92
|
*/
|
|
93
93
|
async getById(appId) {
|
|
94
|
-
const app = await this._algod.
|
|
94
|
+
const app = await this._algod.applicationById(appId);
|
|
95
95
|
const convertedGlobalState = (app.params.globalState ?? []).map((kv) => ({
|
|
96
96
|
key: kv.key,
|
|
97
97
|
value: kv.value
|
|
@@ -102,12 +102,13 @@ var AppManager = class AppManager {
|
|
|
102
102
|
approvalProgram: app.params.approvalProgram,
|
|
103
103
|
clearStateProgram: app.params.clearStateProgram,
|
|
104
104
|
creator: app.params.creator,
|
|
105
|
-
localInts:
|
|
106
|
-
localByteSlices:
|
|
107
|
-
globalInts:
|
|
108
|
-
globalByteSlices:
|
|
109
|
-
extraProgramPages:
|
|
110
|
-
globalState: AppManager.decodeAppState(convertedGlobalState)
|
|
105
|
+
localInts: app.params.localStateSchema?.numUints ?? 0,
|
|
106
|
+
localByteSlices: app.params.localStateSchema?.numByteSlices ?? 0,
|
|
107
|
+
globalInts: app.params.globalStateSchema?.numUints ?? 0,
|
|
108
|
+
globalByteSlices: app.params.globalStateSchema?.numByteSlices ?? 0,
|
|
109
|
+
extraProgramPages: app.params.extraProgramPages ?? 0,
|
|
110
|
+
globalState: AppManager.decodeAppState(convertedGlobalState),
|
|
111
|
+
version: app.params.version
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
@@ -154,7 +155,7 @@ var AppManager = class AppManager {
|
|
|
154
155
|
* ```
|
|
155
156
|
*/
|
|
156
157
|
async getBoxNames(appId) {
|
|
157
|
-
return (await this._algod.
|
|
158
|
+
return (await this._algod.applicationBoxes(appId)).boxes.map((b) => {
|
|
158
159
|
return {
|
|
159
160
|
nameRaw: b.name,
|
|
160
161
|
nameBase64: Buffer.from(b.name).toString("base64"),
|
|
@@ -175,7 +176,7 @@ var AppManager = class AppManager {
|
|
|
175
176
|
async getBoxValue(appId, boxName) {
|
|
176
177
|
const boxId = typeof boxName === "object" && "nameRaw" in boxName ? boxName.nameRaw : boxName;
|
|
177
178
|
const name = AppManager.getBoxReference(boxId).name;
|
|
178
|
-
return (await this._algod.
|
|
179
|
+
return (await this._algod.applicationBoxByName(Number(appId), name)).value;
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* Returns the value of the given box names for the given app.
|
|
@@ -297,7 +298,12 @@ var AppManager = class AppManager {
|
|
|
297
298
|
* ```
|
|
298
299
|
*/
|
|
299
300
|
static getABIReturn(confirmation, method) {
|
|
300
|
-
if (!method ||
|
|
301
|
+
if (!method || !confirmation) return;
|
|
302
|
+
if (method.returns.type === "void") return {
|
|
303
|
+
method,
|
|
304
|
+
rawReturnValue: void 0,
|
|
305
|
+
returnValue: void 0
|
|
306
|
+
};
|
|
301
307
|
try {
|
|
302
308
|
const logs = confirmation.logs || [];
|
|
303
309
|
if (logs.length === 0) throw new Error(`App call transaction did not log a return value`);
|