@algorandfoundation/algokit-utils 10.0.0-alpha.1 → 10.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -5
- package/_virtual/rolldown_runtime.js +20 -11
- package/_virtual/rolldown_runtime.mjs +10 -5
- package/algo25/index.d.ts +2 -0
- package/algo25/index.js +9 -0
- package/algo25/index.mjs +3 -0
- package/algod-client/index.d.ts +2 -5
- package/package.json +1 -1
- package/packages/abi/src/abi-method.d.ts +1 -1
- package/packages/abi/src/abi-method.js.map +1 -1
- package/packages/abi/src/abi-method.mjs.map +1 -1
- package/packages/abi/src/abi-type.d.ts +1 -1
- package/packages/abi/src/abi-type.js +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/english.js.map +1 -1
- package/packages/algo25/src/english.mjs.map +1 -1
- package/packages/algo25/src/index.d.ts +40 -0
- package/packages/algo25/src/index.js +44 -0
- package/packages/algo25/src/index.js.map +1 -1
- package/packages/algo25/src/index.mjs +39 -1
- package/packages/algo25/src/index.mjs.map +1 -1
- package/packages/algod_client/src/apis/api-service.d.ts +44 -44
- package/packages/algod_client/src/apis/api-service.js +153 -153
- package/packages/algod_client/src/apis/api-service.js.map +1 -1
- package/packages/algod_client/src/apis/api-service.mjs +153 -153
- package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
- package/packages/algod_client/src/core/api-error.js +3 -1
- package/packages/algod_client/src/core/api-error.js.map +1 -1
- package/packages/algod_client/src/core/api-error.mjs +3 -1
- package/packages/algod_client/src/core/api-error.mjs.map +1 -1
- package/packages/algod_client/src/core/model-runtime.js +4 -4
- package/packages/algod_client/src/core/model-runtime.js.map +1 -1
- package/packages/algod_client/src/core/model-runtime.mjs +6 -6
- package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/algod_client/src/models/account-participation.js +4 -4
- package/packages/algod_client/src/models/account-participation.js.map +1 -1
- package/packages/algod_client/src/models/account-participation.mjs +4 -4
- package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/algod_client/src/models/application-state-schema.js +2 -2
- package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
- package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/algod_client/src/models/asset-params.js +2 -1
- package/packages/algod_client/src/models/asset-params.js.map +1 -1
- package/packages/algod_client/src/models/asset-params.mjs +2 -1
- package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
- package/packages/algod_client/src/models/block-response.js +1 -2
- package/packages/algod_client/src/models/block-response.js.map +1 -1
- package/packages/algod_client/src/models/block-response.mjs +2 -3
- package/packages/algod_client/src/models/block-response.mjs.map +1 -1
- package/packages/algod_client/src/models/block.d.ts +49 -29
- package/packages/algod_client/src/models/block.js +174 -98
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs +174 -98
- package/packages/algod_client/src/models/block.mjs.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
- package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
- package/packages/common/src/address.js +0 -14
- package/packages/common/src/address.js.map +1 -1
- package/packages/common/src/address.mjs +1 -14
- package/packages/common/src/address.mjs.map +1 -1
- package/packages/common/src/codecs/composite/map.js +7 -4
- package/packages/common/src/codecs/composite/map.js.map +1 -1
- package/packages/common/src/codecs/composite/map.mjs +7 -4
- package/packages/common/src/codecs/composite/map.mjs.map +1 -1
- package/packages/common/src/codecs/composite/record.js +0 -1
- package/packages/common/src/codecs/composite/record.js.map +1 -1
- package/packages/common/src/codecs/primitives/address.js +0 -1
- package/packages/common/src/codecs/primitives/address.js.map +1 -1
- package/packages/common/src/codecs/primitives/bytes.js +0 -1
- package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
- package/packages/common/src/codecs/wire.js +0 -1
- package/packages/common/src/codecs/wire.js.map +1 -1
- package/packages/common/src/msgpack.js +0 -1
- package/packages/common/src/msgpack.js.map +1 -1
- package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
- package/packages/indexer_client/src/apis/api-service.js +12 -12
- package/packages/indexer_client/src/apis/api-service.js.map +1 -1
- package/packages/indexer_client/src/apis/api-service.mjs +12 -12
- package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
- package/packages/indexer_client/src/core/api-error.js +3 -1
- package/packages/indexer_client/src/core/api-error.js.map +1 -1
- package/packages/indexer_client/src/core/api-error.mjs +3 -1
- package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.js +4 -4
- package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.mjs +6 -6
- package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/indexer_client/src/models/account-participation.js +4 -4
- package/packages/indexer_client/src/models/account-participation.js.map +1 -1
- package/packages/indexer_client/src/models/account-participation.mjs +4 -4
- package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/asset-params.js +2 -1
- package/packages/indexer_client/src/models/asset-params.js.map +1 -1
- package/packages/indexer_client/src/models/asset-params.mjs +2 -1
- package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
- package/packages/indexer_client/src/models/block.js +8 -8
- package/packages/indexer_client/src/models/block.js.map +1 -1
- package/packages/indexer_client/src/models/block.mjs +8 -8
- package/packages/indexer_client/src/models/block.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta.js +2 -2
- package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/state-schema.js +2 -2
- package/packages/indexer_client/src/models/state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/teal-key-value.js +2 -2
- package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction.d.ts +2 -2
- package/packages/indexer_client/src/models/transaction.js +6 -5
- package/packages/indexer_client/src/models/transaction.js.map +1 -1
- package/packages/indexer_client/src/models/transaction.mjs +6 -5
- package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
- package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
- package/packages/kmd_client/src/apis/api-service.js +32 -32
- package/packages/kmd_client/src/apis/api-service.js.map +1 -1
- package/packages/kmd_client/src/apis/api-service.mjs +32 -32
- package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
- package/packages/kmd_client/src/core/api-error.js +3 -1
- package/packages/kmd_client/src/core/api-error.js.map +1 -1
- package/packages/kmd_client/src/core/api-error.mjs +3 -1
- package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.js +4 -4
- package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.mjs +6 -6
- package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/sdk/src/encoding/encoding.js +12 -2
- package/packages/sdk/src/encoding/encoding.js.map +1 -1
- package/packages/sdk/src/encoding/encoding.mjs +12 -1
- package/packages/sdk/src/encoding/encoding.mjs.map +1 -1
- package/packages/sdk/src/encoding/schema/map.js +0 -2
- package/packages/sdk/src/encoding/schema/map.js.map +1 -1
- package/packages/transact/src/logicsig.d.ts +3 -15
- package/packages/transact/src/logicsig.js +16 -36
- package/packages/transact/src/logicsig.js.map +1 -1
- package/packages/transact/src/logicsig.mjs +18 -36
- package/packages/transact/src/logicsig.mjs.map +1 -1
- package/packages/transact/src/multisig.d.ts +7 -115
- package/packages/transact/src/multisig.js +86 -136
- package/packages/transact/src/multisig.js.map +1 -1
- package/packages/transact/src/multisig.mjs +87 -117
- package/packages/transact/src/multisig.mjs.map +1 -1
- package/packages/transact/src/transactions/app-call.d.ts +10 -10
- package/packages/transact/src/transactions/app-call.js.map +1 -1
- package/packages/transact/src/transactions/app-call.mjs.map +1 -1
- package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
- package/packages/transact/src/transactions/reference-types-meta.js +71 -0
- package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
- package/packages/transact/src/transactions/signed-transaction-meta.js +2 -3
- package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction-meta.mjs +3 -3
- package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.d.ts +2 -2
- package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction-meta.js +29 -23
- package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
- package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction.js +1 -0
- package/packages/transact/src/transactions/transaction.js.map +1 -1
- package/packages/transact/src/transactions/transaction.mjs +1 -0
- package/packages/transact/src/transactions/transaction.mjs.map +1 -1
- package/sdk/index.js +1 -1
- package/testing/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/transact/index.d.ts +5 -4
- package/transact/index.js +4 -22
- package/transact/index.mjs +4 -3
- package/transaction/transaction.js +2 -2
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +2 -2
- package/transaction/transaction.mjs.map +1 -1
- package/transactions/app-call.d.ts +4 -3
- package/transactions/app-call.js +15 -15
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +15 -15
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/asset-config.d.ts +1 -1
- package/transactions/asset-config.js +1 -1
- package/transactions/asset-config.js.map +1 -1
- package/transactions/asset-config.mjs +1 -1
- package/transactions/asset-config.mjs.map +1 -1
- package/transactions/method-call.js +69 -77
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +69 -77
- package/transactions/method-call.mjs.map +1 -1
- package/types/account-manager.d.ts +1 -1
- package/types/account-manager.js +3 -3
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +3 -3
- package/types/account-manager.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +97 -83
- package/types/algorand-client-transaction-creator.js +8 -0
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +8 -0
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +100 -86
- package/types/algorand-client-transaction-sender.js +8 -1
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +8 -0
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/app-client.d.ts +265 -260
- package/types/app-client.js +0 -1
- package/types/app-client.js.map +1 -1
- package/types/app-deployer.js +1 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +1 -1
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +91 -88
- package/types/app-manager.d.ts +3 -1
- package/types/app-manager.js +16 -10
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +16 -10
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.js +12 -5
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +12 -5
- package/types/app-spec.mjs.map +1 -1
- package/types/asset-manager.js +1 -1
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +1 -1
- package/types/asset-manager.mjs.map +1 -1
- package/types/composer.d.ts +9 -0
- package/types/composer.js +28 -13
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +28 -12
- package/types/composer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +1 -0
- package/types/kmd-account-manager.js +21 -10
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +22 -11
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/testing.d.ts +2 -2
- package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
- package/packages/algod_client/src/models/application-local-reference.js +0 -23
- package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
- package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
- package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
- package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/box-reference.d.ts +0 -17
- package/packages/algod_client/src/models/box-reference.js +0 -23
- package/packages/algod_client/src/models/box-reference.js.map +0 -1
- package/packages/algod_client/src/models/box-reference.mjs +0 -23
- package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
package/types/app-spec.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-spec.mjs","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (\n type: string,\n defaultArg: DefaultArgument | undefined,\n ): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n return {\n source: defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local',\n data: Buffer.from(\n typeof defaultArg.data === 'number' ? ABITypeClass.from('uint64').encode(defaultArg.data) : defaultArg.data,\n ).toString('base64'),\n type: type === 'string' ? 'AVMString' : type,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(a.type, !a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,SAAiC;CAC5D,MAAM,eAAe,OAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,WAAS,OAAO,QAAQA,OAAK,WAAW,EAAE,CAAC,CAAC;CACvG,MAAM,UAAU,OAAO,YACrB,aAAa,KAAK,CAAC,GAAG,YAAY;EAChC,MAAM,SAAS,OAAO,SAAS,KAAK,OAAO;GAAE,MAAM,EAAE;GAAI,MAAM,EAAE;GAAI,EAAE;AACvE,SAAO,CAAC,OAAO,MAAM,OAAO;GAC5B,CACH;CACD,MAAM,QAAQ,MAAuB,QAAQ,MAAM,4BAA4B,EAAE;CACjF,MAAM,WAAW,GAAoB,SAA4B;AAE/D,SAAO,KAAK,EAAE,EAAE,gBAAgB,SAAY,oBAAoB,KAAK,EAAE,EAAE,aAAc,KAAK,GAAG,EAAE;;CAEnG,MAAM,eAAe,SAA4B;AAC/C,SAAO,oBAAoB,QAAQ,kBAAkB,KAAK;;CAE5D,MAAM,uBAAuB,GAAe,SAA4B;EACtE,MAAMC,YAAwG,EAAE;AAChH,MAAI,EAAE,aAAa,CAAC,OAAO,KAAK,CAAC,SAAS,EAAE,UAAU,CAAE,WAAQ,KAAK,WAAW;AAChF,MA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AC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"app-spec.mjs","names":["hint","actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]","actions","defaultValueType: string | undefined","ABITypeClass"],"sources":["../../src/types/app-spec.ts"],"sourcesContent":["import {\n ABIMethod,\n ABIType as ABITypeClass,\n ARC28Event,\n Arc56Contract,\n Arc56Method,\n StorageKey,\n StructField,\n} from '@algorandfoundation/algokit-abi'\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[getABIMethodParamsSignature(m)] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (defaultArg: DefaultArgument | undefined): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n const mappedSource = defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local'\n\n // type is only set for literal source\n let defaultValueType: string | undefined = undefined\n if (mappedSource === 'literal') {\n if (typeof defaultArg.data === 'number') {\n defaultValueType = 'uint64'\n } else if (typeof defaultArg.data === 'string') {\n defaultValueType = 'AVMString'\n }\n }\n\n const argData =\n typeof defaultArg.data === 'number'\n ? ABITypeClass.from('uint64').encode(defaultArg.data)\n : typeof defaultArg.data === 'string'\n ? new TextEncoder().encode(defaultArg.data)\n : defaultArg.data\n\n return {\n source: mappedSource,\n data: Buffer.from(argData).toString('base64'),\n type: defaultValueType,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(!a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\nfunction getABIMethodParamsSignature(params: ABIMethodParams) {\n const args = params.args.map((a) => a.type).join(',')\n return `${params.name}(${args})${params.returns.type}`\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\ninterface ABIContractParams {\n name: string\n desc?: string\n networks?: ABIContractNetworks\n methods: ABIMethodParams[]\n events?: ARC28Event[]\n}\n\ninterface ABIContractNetworks {\n [network: string]: ABIContractNetworkInfo\n}\n\ninterface ABIContractNetworkInfo {\n appID: number\n}\n\ninterface ABIMethodParams {\n name: string\n desc?: string\n args: ABIMethodArgParams[]\n returns: ABIMethodReturnParams\n /** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */\n readonly?: boolean\n /** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */\n events?: ARC28Event[]\n}\n\ninterface ABIMethodArgParams {\n type: string\n name?: string\n desc?: string\n}\n\ninterface ABIMethodReturnParams {\n type: string\n desc?: string\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethod\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,aAAa,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AC7B;IACD,OAAO;KACL,MAAM,QAAQ,MAAM,MAAM;KAC1B,OAAO,QAAQ,MAAM,MAAM;KAC5B;IACF;GACD,MAAM;IACJ,QAAQ,OAAO,YACb,OAAO,QAAQ,QAAQ,OAAO,OAAO,SAAS,CAAC,KAAK,MAAM,CACxD,EAAE,IACF;KACE,KAAK,OAAO,KAAK,EAAE,GAAG,KAAK,QAAQ,CAAC,SAAS,SAAS;KACtD,SAAS;KACT,WAAW,EAAE,GAAG,SAAS,WAAW,cAAc;KAClD,MAAM,EAAE,GAAG;KACZ,CACF,CAAC,CACH;IACD,OAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,OAAO,MAAM,SAAS,CAAC,KAAK,MAAM,CACvD,EAAE,IACF;KACE,KAAK,OAAO,KAAK,EAAE,GAAG,KAAK,QAAQ,CAAC,SAAS,SAAS;KACtD,SAAS;KACT,WAAW,EAAE,GAAG,SAAS,WAAW,cAAc;KAClD,MAAM,EAAE,GAAG;KACZ,CACF,CAAC,CACH;IACD,KAAK,EAAE;IACR;GACD,MAAM;IACJ,QAAQ,EAAE;IACV,OAAO,EAAE;IACT,KAAK,EAAE;IACR;GACF;EACD,QAAQ,QAAQ;EAChB,aAAa;GACX,QAAQ,YAAY,SAAS;GAC7B,MAAM,YAAY,OAAO;GAC1B;EACD,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACpB;;AAGH,SAAS,4BAA4B,QAAyB;CAC5D,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI;AACrD,QAAO,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,OAAO,QAAQ"}
|
package/types/asset-manager.js
CHANGED
|
@@ -32,7 +32,7 @@ var AssetManager = class {
|
|
|
32
32
|
* @returns The asset information
|
|
33
33
|
*/
|
|
34
34
|
async getById(assetId) {
|
|
35
|
-
const asset = await this._algod.
|
|
35
|
+
const asset = await this._algod.assetById(assetId);
|
|
36
36
|
return {
|
|
37
37
|
assetId: BigInt(asset.id),
|
|
38
38
|
total: BigInt(asset.params.total),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-manager.js","names":["results: BulkAssetOptInOutResult[]","chunkArray","MAX_TRANSACTION_GROUP_SIZE","notOptedInAssetIds: bigint[]","nonZeroBalanceAssetIds: bigint[]"],"sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address, MAX_TRANSACTION_GROUP_SIZE } from '@algorandfoundation/algokit-common'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, TransactionComposer, TransactionComposerConfig } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: AlgodClient\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: AlgodClient, newGroup: (config?: TransactionComposerConfig) => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetById(assetId)\n\n return {\n assetId: BigInt(asset.id),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountassetinformation)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender.toString(), assetId)\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((ass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,OAAO,QAAQ,CAAC,EAAE;IAC/C,QAAQ;IACR,SAAS,OAAO,QAAQ;IACzB,CAAC;GAGJ,MAAM,SAAS,MAAM,SAAS,KAAK,QAAQ;AAE3C,yBAAO,UAAU,SAAS,YAAY,CAAC,KACrC,sBAAsB,QAAQ,iBAAiB,WAAW,KAAK,KAAK,CAAC,wBAAwB,OAAO,MAAM,KAAK,KAAK,qBAC7F,OAAO,QAAQ,YAAY,OAAO,gBAAgB,IAAI,eAAe,GAC7F;AAED,cAAW,SAAS,SAAS,UAAU;AACrC,YAAQ,KAAK;KAAE,SAAS,OAAO,QAAQ;KAAE,eAAe,OAAO,MAAM;KAAQ,CAAC;KAC9E;;AAGJ,SAAO"}
|
|
1
|
+
{"version":3,"file":"asset-manager.js","names":["results: BulkAssetOptInOutResult[]","chunkArray","MAX_TRANSACTION_GROUP_SIZE","notOptedInAssetIds: bigint[]","nonZeroBalanceAssetIds: bigint[]"],"sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address, MAX_TRANSACTION_GROUP_SIZE } from '@algorandfoundation/algokit-common'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, TransactionComposer, TransactionComposerConfig } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: AlgodClient\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: AlgodClient, newGroup: (config?: TransactionComposerConfig) => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.assetById(assetId)\n\n return {\n assetId: BigInt(asset.id),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountassetinformation)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender.toString(), assetId)\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"mappings":";;;;;;AA0IA,IAAa,eAAb,MAA0B;CACxB,AAAQ;CACR,AAAQ;;;;;;;;;;CAWR,YAAY,OAAoB,UAAuE;AACrG,OAAK,SAAS;AACd,OAAK,YAAY;;;;;;;;;;;;;CAcnB,MAAa,QAAQ,SAA4C;EAC/D,MAAM,QAAQ,MAAM,KAAK,OAAO,UAAU,QAAQ;AAElD,SAAO;GACL,SAAS,OAAO,MAAM,GAAG;GACzB,OAAO,OAAO,MAAM,OAAO,MAAM;GACjC,UAAU,OAAO,MAAM,OAAO,SAAS;GACvC,WAAW,MAAM,OAAO;GACxB,kBAAkB,MAAM,OAAO;GAC/B,UAAU,MAAM,OAAO;GACvB,iBAAiB,MAAM,OAAO;GAC9B,KAAK,MAAM,OAAO;GAClB,YAAY,MAAM,OAAO;GACzB,SAAS,MAAM,OAAO;GACtB,SAAS,MAAM,OAAO;GACtB,UAAU,MAAM,OAAO;GACvB,QAAQ,MAAM,OAAO;GACrB,SAAS,MAAM,OAAO;GACtB,eAAe,MAAM,OAAO;GAC5B,cAAc,MAAM,OAAO;GAC5B;;;;;;;;;;;;;;;;;CAkBH,MAAa,sBAAsB,QAA0B,SAAmD;EAC9G,MAAM,OAAO,MAAM,KAAK,OAAO,wBAAwB,OAAO,UAAU,EAAE,QAAQ;AAElF,SAAO;GACL,SAAS,OAAO,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S,EACnE,OAAM,IAAI,MACR,WAAW,UAAU,mBAAmB,SAAS,IAAI,4BAA4B,mBAAmB,SAAS,IAAI,MAAM,GAAG,GAAG,mBAAmB,KAAK,KAAK,KAAK,KAC7J,uBAAuB,SAAS,IAC5B,kCAAkC,uBAAuB,SAAS,IAAI,MAAM,GAAG,GAAG,uBAAuB,KAAK,KAAK,KACnH,GACL,kBACF;AAGH,QAAK,MAAM,WAAW,WACpB,UAAS,eAAe;IACtB,GAAG;IACH,UAAU,MAAM,KAAK,QAAQ,OAAO,QAAQ,CAAC,EAAE;IAC/C,QAAQ;IACR,SAAS,OAAO,QAAQ;IACzB,CAAC;GAGJ,MAAM,SAAS,MAAM,SAAS,KAAK,QAAQ;AAE3C,yBAAO,UAAU,SAAS,YAAY,CAAC,KACrC,sBAAsB,QAAQ,iBAAiB,WAAW,KAAK,KAAK,CAAC,wBAAwB,OAAO,MAAM,KAAK,KAAK,qBAC7F,OAAO,QAAQ,YAAY,OAAO,gBAAgB,IAAI,eAAe,GAC7F;AAED,cAAW,SAAS,SAAS,UAAU;AACrC,YAAQ,KAAK;KAAE,SAAS,OAAO,QAAQ;KAAE,eAAe,OAAO,MAAM;KAAQ,CAAC;KAC9E;;AAGJ,SAAO"}
|
package/types/asset-manager.mjs
CHANGED
|
@@ -32,7 +32,7 @@ var AssetManager = class {
|
|
|
32
32
|
* @returns The asset information
|
|
33
33
|
*/
|
|
34
34
|
async getById(assetId) {
|
|
35
|
-
const asset = await this._algod.
|
|
35
|
+
const asset = await this._algod.assetById(assetId);
|
|
36
36
|
return {
|
|
37
37
|
assetId: BigInt(asset.id),
|
|
38
38
|
total: BigInt(asset.params.total),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-manager.mjs","names":["results: BulkAssetOptInOutResult[]","notOptedInAssetIds: bigint[]","nonZeroBalanceAssetIds: bigint[]"],"sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address, MAX_TRANSACTION_GROUP_SIZE } from '@algorandfoundation/algokit-common'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, TransactionComposer, TransactionComposerConfig } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: AlgodClient\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: AlgodClient, newGroup: (config?: TransactionComposerConfig) => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetById(assetId)\n\n return {\n assetId: BigInt(asset.id),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountassetinformation)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender.toString(), assetId)\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"mappings":";;;;;;AA0IA,IAAa,eAAb,MAA0B;CACxB,AAAQ;CACR,AAAQ;;;;;;;;;;CAWR,YAAY,OAAoB,UAAuE;AACrG,OAAK,SAAS;AACd,OAAK,YAAY;;;;;;;;;;;;;CAcnB,MAAa,QAAQ,SAA4C;EAC/D,MAAM,QAAQ,MAAM,KAAK,OAAO,aAAa,QAAQ;AAErD,SAAO;GACL,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AU;AACrC,YAAQ,KAAK;KAAE,SAAS,OAAO,QAAQ;KAAE,eAAe,OAAO,MAAM;KAAQ,CAAC;KAC9E;;AAGJ,SAAO"}
|
|
1
|
+
{"version":3,"file":"asset-manager.mjs","names":["results: BulkAssetOptInOutResult[]","notOptedInAssetIds: bigint[]","nonZeroBalanceAssetIds: bigint[]"],"sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address, MAX_TRANSACTION_GROUP_SIZE } from '@algorandfoundation/algokit-common'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, TransactionComposer, TransactionComposerConfig } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: AlgodClient\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: AlgodClient, newGroup: (config?: TransactionComposerConfig) => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.assetById(assetId)\n\n return {\n assetId: BigInt(asset.id),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountassetinformation)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender.toString(), assetId)\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId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SAAS,OAAO,QAAQ;IACzB,CAAC;GAGJ,MAAM,SAAS,MAAM,SAAS,KAAK,QAAQ;AAE3C,UAAO,UAAU,SAAS,YAAY,CAAC,KACrC,sBAAsB,QAAQ,iBAAiB,WAAW,KAAK,KAAK,CAAC,wBAAwB,OAAO,MAAM,KAAK,KAAK,qBAC7F,OAAO,QAAQ,YAAY,OAAO,gBAAgB,IAAI,eAAe,GAC7F;AAED,cAAW,SAAS,SAAS,UAAU;AACrC,YAAQ,KAAK;KAAE,SAAS,OAAO,QAAQ;KAAE,eAAe,OAAO,MAAM;KAAQ,CAAC;KAC9E;;AAGJ,SAAO"}
|
package/types/composer.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ declare class TransactionComposer {
|
|
|
102
102
|
private signedTransactions?;
|
|
103
103
|
private rawBuildTransactions?;
|
|
104
104
|
private transformError;
|
|
105
|
+
private validateReferenceParams;
|
|
105
106
|
/**
|
|
106
107
|
* Create a `TransactionComposer`.
|
|
107
108
|
* @param params The configuration for this composer
|
|
@@ -432,6 +433,7 @@ declare class TransactionComposer {
|
|
|
432
433
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
433
434
|
* // already specified, but here for completeness
|
|
434
435
|
* maxFee: (3000).microAlgo(),
|
|
436
|
+
* rejectVersion: 1,
|
|
435
437
|
* // Signer only needed if you want to provide one,
|
|
436
438
|
* // generally you'd register it with AlgorandClient
|
|
437
439
|
* // against the sender and not need to pass it in
|
|
@@ -475,6 +477,7 @@ declare class TransactionComposer {
|
|
|
475
477
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
476
478
|
* // already specified, but here for completeness
|
|
477
479
|
* maxFee: (3000).microAlgo(),
|
|
480
|
+
* rejectVersion: 1,
|
|
478
481
|
*})
|
|
479
482
|
* ```
|
|
480
483
|
*/
|
|
@@ -510,6 +513,7 @@ declare class TransactionComposer {
|
|
|
510
513
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
511
514
|
* // already specified, but here for completeness
|
|
512
515
|
* maxFee: (3000).microAlgo(),
|
|
516
|
+
* rejectVersion: 1,
|
|
513
517
|
*})
|
|
514
518
|
* ```
|
|
515
519
|
*/
|
|
@@ -547,6 +551,7 @@ declare class TransactionComposer {
|
|
|
547
551
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
548
552
|
* // already specified, but here for completeness
|
|
549
553
|
* maxFee: (3000).microAlgo(),
|
|
554
|
+
* rejectVersion: 1,
|
|
550
555
|
*})
|
|
551
556
|
* ```
|
|
552
557
|
*/
|
|
@@ -603,6 +608,7 @@ declare class TransactionComposer {
|
|
|
603
608
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
604
609
|
* // already specified, but here for completeness
|
|
605
610
|
* maxFee: (3000).microAlgo(),
|
|
611
|
+
* rejectVersion: 1,
|
|
606
612
|
*})
|
|
607
613
|
* ```
|
|
608
614
|
*/
|
|
@@ -652,6 +658,7 @@ declare class TransactionComposer {
|
|
|
652
658
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
653
659
|
* // already specified, but here for completeness
|
|
654
660
|
* maxFee: (3000).microAlgo(),
|
|
661
|
+
* rejectVersion: 1,
|
|
655
662
|
*})
|
|
656
663
|
* ```
|
|
657
664
|
*/
|
|
@@ -699,6 +706,7 @@ declare class TransactionComposer {
|
|
|
699
706
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
700
707
|
* // already specified, but here for completeness
|
|
701
708
|
* maxFee: (3000).microAlgo(),
|
|
709
|
+
* rejectVersion: 1,
|
|
702
710
|
*})
|
|
703
711
|
* ```
|
|
704
712
|
*/
|
|
@@ -746,6 +754,7 @@ declare class TransactionComposer {
|
|
|
746
754
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
747
755
|
* // already specified, but here for completeness
|
|
748
756
|
* maxFee: (3000).microAlgo(),
|
|
757
|
+
* rejectVersion: 1,
|
|
749
758
|
*})
|
|
750
759
|
* ```
|
|
751
760
|
*/
|
package/types/composer.js
CHANGED
|
@@ -20,7 +20,6 @@ const require_payment = require('../transactions/payment.js');
|
|
|
20
20
|
const require_lifecycle_events = require('./lifecycle-events.js');
|
|
21
21
|
const require_network_client = require('./network-client.js');
|
|
22
22
|
let buffer = require("buffer");
|
|
23
|
-
buffer = require_rolldown_runtime.__toESM(buffer);
|
|
24
23
|
|
|
25
24
|
//#region src/types/composer.ts
|
|
26
25
|
var InvalidErrorTransformerValue = class extends Error {
|
|
@@ -64,6 +63,9 @@ var TransactionComposer = class TransactionComposer {
|
|
|
64
63
|
}
|
|
65
64
|
return transformedError;
|
|
66
65
|
}
|
|
66
|
+
validateReferenceParams(params) {
|
|
67
|
+
if (params.accessReferences && params.accessReferences.length > 0 && (params.appReferences && params.appReferences.length > 0 || params.assetReferences && params.assetReferences.length > 0 || params.boxReferences && params.boxReferences.length > 0)) throw new Error("Cannot specify both `accessReferences` and reference arrays (`appReferences`, `assetReferences`, `boxReferences`).");
|
|
68
|
+
}
|
|
67
69
|
/**
|
|
68
70
|
* Create a `TransactionComposer`.
|
|
69
71
|
* @param params The configuration for this composer
|
|
@@ -569,6 +571,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
569
571
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
570
572
|
* // already specified, but here for completeness
|
|
571
573
|
* maxFee: (3000).microAlgo(),
|
|
574
|
+
* rejectVersion: 1,
|
|
572
575
|
* // Signer only needed if you want to provide one,
|
|
573
576
|
* // generally you'd register it with AlgorandClient
|
|
574
577
|
* // against the sender and not need to pass it in
|
|
@@ -579,6 +582,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
579
582
|
* ```
|
|
580
583
|
*/
|
|
581
584
|
addAppCreate(params) {
|
|
585
|
+
this.validateReferenceParams(params);
|
|
582
586
|
this.push({
|
|
583
587
|
data: params,
|
|
584
588
|
type: "appCall"
|
|
@@ -618,10 +622,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
618
622
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
619
623
|
* // already specified, but here for completeness
|
|
620
624
|
* maxFee: (3000).microAlgo(),
|
|
625
|
+
* rejectVersion: 1,
|
|
621
626
|
*})
|
|
622
627
|
* ```
|
|
623
628
|
*/
|
|
624
629
|
addAppUpdate(params) {
|
|
630
|
+
this.validateReferenceParams(params);
|
|
625
631
|
this.push({
|
|
626
632
|
data: {
|
|
627
633
|
...params,
|
|
@@ -662,10 +668,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
662
668
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
663
669
|
* // already specified, but here for completeness
|
|
664
670
|
* maxFee: (3000).microAlgo(),
|
|
671
|
+
* rejectVersion: 1,
|
|
665
672
|
*})
|
|
666
673
|
* ```
|
|
667
674
|
*/
|
|
668
675
|
addAppDelete(params) {
|
|
676
|
+
this.validateReferenceParams(params);
|
|
669
677
|
this.push({
|
|
670
678
|
data: {
|
|
671
679
|
...params,
|
|
@@ -708,10 +716,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
708
716
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
709
717
|
* // already specified, but here for completeness
|
|
710
718
|
* maxFee: (3000).microAlgo(),
|
|
719
|
+
* rejectVersion: 1,
|
|
711
720
|
*})
|
|
712
721
|
* ```
|
|
713
722
|
*/
|
|
714
723
|
addAppCall(params) {
|
|
724
|
+
this.validateReferenceParams(params);
|
|
715
725
|
this.push({
|
|
716
726
|
data: params,
|
|
717
727
|
type: "appCall"
|
|
@@ -770,10 +780,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
770
780
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
771
781
|
* // already specified, but here for completeness
|
|
772
782
|
* maxFee: (3000).microAlgo(),
|
|
783
|
+
* rejectVersion: 1,
|
|
773
784
|
*})
|
|
774
785
|
* ```
|
|
775
786
|
*/
|
|
776
787
|
addAppCreateMethodCall(params) {
|
|
788
|
+
this.validateReferenceParams(params);
|
|
777
789
|
const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
|
|
778
790
|
this.push(...txnArgs, {
|
|
779
791
|
data: {
|
|
@@ -829,10 +841,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
829
841
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
830
842
|
* // already specified, but here for completeness
|
|
831
843
|
* maxFee: (3000).microAlgo(),
|
|
844
|
+
* rejectVersion: 1,
|
|
832
845
|
*})
|
|
833
846
|
* ```
|
|
834
847
|
*/
|
|
835
848
|
addAppUpdateMethodCall(params) {
|
|
849
|
+
this.validateReferenceParams(params);
|
|
836
850
|
const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
|
|
837
851
|
this.push(...txnArgs, {
|
|
838
852
|
data: {
|
|
@@ -887,10 +901,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
887
901
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
888
902
|
* // already specified, but here for completeness
|
|
889
903
|
* maxFee: (3000).microAlgo(),
|
|
904
|
+
* rejectVersion: 1,
|
|
890
905
|
*})
|
|
891
906
|
* ```
|
|
892
907
|
*/
|
|
893
908
|
addAppDeleteMethodCall(params) {
|
|
909
|
+
this.validateReferenceParams(params);
|
|
894
910
|
const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
|
|
895
911
|
this.push(...txnArgs, {
|
|
896
912
|
data: {
|
|
@@ -945,10 +961,12 @@ var TransactionComposer = class TransactionComposer {
|
|
|
945
961
|
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
946
962
|
* // already specified, but here for completeness
|
|
947
963
|
* maxFee: (3000).microAlgo(),
|
|
964
|
+
* rejectVersion: 1,
|
|
948
965
|
*})
|
|
949
966
|
* ```
|
|
950
967
|
*/
|
|
951
968
|
addAppCallMethodCall(params) {
|
|
969
|
+
this.validateReferenceParams(params);
|
|
952
970
|
const txnArgs = require_method_call.extractComposerTransactionsFromAppMethodCallParams(params);
|
|
953
971
|
this.push(...txnArgs, {
|
|
954
972
|
data: {
|
|
@@ -1067,7 +1085,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1067
1085
|
if (!this.transactionsWithSigners) {
|
|
1068
1086
|
const suggestedParams = await this.getSuggestedParams();
|
|
1069
1087
|
const builtTransactions = await this._buildTransactions(suggestedParams);
|
|
1070
|
-
this.rawBuildTransactions = builtTransactions.transactions;
|
|
1088
|
+
this.rawBuildTransactions = builtTransactions.transactions.map((txn) => new require_transaction.Transaction({ ...txn }));
|
|
1071
1089
|
const groupAnalysis = (this.composerConfig.coverAppCallInnerTransactionFees || this.composerConfig.populateAppCallResources) && builtTransactions.transactions.some((txn) => txn.type === require_transaction_type.TransactionType.AppCall) ? await this.analyzeGroupRequirements(builtTransactions.transactions, suggestedParams, this.composerConfig) : void 0;
|
|
1072
1090
|
this.populateTransactionAndGroupResources(builtTransactions.transactions, groupAnalysis);
|
|
1073
1091
|
this.transactionsWithSigners = builtTransactions.transactions.map((txn, index) => {
|
|
@@ -1127,7 +1145,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1127
1145
|
transaction = require_asset_transfer.buildAssetOptOut(ctxn.data, suggestedParams, defaultValidityWindow);
|
|
1128
1146
|
break;
|
|
1129
1147
|
case "appCall":
|
|
1130
|
-
if (
|
|
1148
|
+
if (ctxn.data.appId === void 0 || ctxn.data.appId === 0) transaction = await require_app_call$1.buildAppCreate(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
|
|
1131
1149
|
else if ("approvalProgram" in ctxn.data && "clearStateProgram" in ctxn.data) transaction = await require_app_call$1.buildAppUpdate(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
|
|
1132
1150
|
else transaction = require_app_call$1.buildAppCall(ctxn.data, suggestedParams, defaultValidityWindow);
|
|
1133
1151
|
break;
|
|
@@ -1135,7 +1153,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1135
1153
|
transaction = require_key_registration.buildKeyReg(ctxn.data, suggestedParams, defaultValidityWindow);
|
|
1136
1154
|
break;
|
|
1137
1155
|
case "methodCall":
|
|
1138
|
-
if (
|
|
1156
|
+
if (ctxn.data.appId === void 0 || ctxn.data.appId === 0) transaction = await require_method_call.buildAppCreateMethodCall(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
|
|
1139
1157
|
else if ("approvalProgram" in ctxn.data && "clearStateProgram" in ctxn.data) transaction = await require_method_call.buildAppUpdateMethodCall(ctxn.data, this.appManager, suggestedParams, defaultValidityWindow);
|
|
1140
1158
|
else transaction = await require_method_call.buildAppCallMethodCall(ctxn.data, suggestedParams, defaultValidityWindow);
|
|
1141
1159
|
break;
|
|
@@ -1303,13 +1321,13 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1303
1321
|
sortedResources.assets?.sort(compare);
|
|
1304
1322
|
sortedResources.apps?.sort(compare);
|
|
1305
1323
|
sortedResources.boxes?.sort((a, b) => {
|
|
1306
|
-
return compare(`${a.
|
|
1324
|
+
return compare(`${a.appId}-${a.name}`, `${b.appId}-${b.name}`);
|
|
1307
1325
|
});
|
|
1308
1326
|
sortedResources.appLocals?.sort((a, b) => {
|
|
1309
|
-
return compare(`${a.
|
|
1327
|
+
return compare(`${a.appId}-${a.address}`, `${b.appId}-${b.address}`);
|
|
1310
1328
|
});
|
|
1311
1329
|
sortedResources.assetHoldings?.sort((a, b) => {
|
|
1312
|
-
return compare(`${a.
|
|
1330
|
+
return compare(`${a.assetId}-${a.address}`, `${b.assetId}-${b.address}`);
|
|
1313
1331
|
});
|
|
1314
1332
|
}
|
|
1315
1333
|
return {
|
|
@@ -1436,7 +1454,7 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1436
1454
|
}
|
|
1437
1455
|
}
|
|
1438
1456
|
async simulate(options) {
|
|
1439
|
-
const { skipSignatures = false, resultOnFailure = false
|
|
1457
|
+
const { skipSignatures = false, resultOnFailure = false, ...rawOptions } = options ?? {};
|
|
1440
1458
|
if (skipSignatures) {
|
|
1441
1459
|
rawOptions.allowEmptySignatures = true;
|
|
1442
1460
|
rawOptions.fixSigners = true;
|
|
@@ -1533,11 +1551,8 @@ var TransactionComposer = class TransactionComposer {
|
|
|
1533
1551
|
const confirmation = confirmations[i];
|
|
1534
1552
|
const txn = this.txns[i];
|
|
1535
1553
|
if (txn?.type !== "methodCall") continue;
|
|
1536
|
-
const
|
|
1537
|
-
if (
|
|
1538
|
-
const abiReturn = require_app_manager.AppManager.getABIReturn(confirmation, method);
|
|
1539
|
-
if (abiReturn !== void 0) abiReturns.push(abiReturn);
|
|
1540
|
-
}
|
|
1554
|
+
const abiReturn = require_app_manager.AppManager.getABIReturn(confirmation, txn.data.method);
|
|
1555
|
+
if (abiReturn !== void 0) abiReturns.push(abiReturn);
|
|
1541
1556
|
}
|
|
1542
1557
|
return abiReturns;
|
|
1543
1558
|
}
|