@algorandfoundation/algokit-utils 10.0.0-alpha.3 → 10.0.0-alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/rolldown_runtime.js +10 -15
- package/abi/index.d.ts +2 -1
- package/abi/index.js +3 -0
- package/abi/index.mjs +2 -1
- package/account-manager.d.ts +448 -0
- package/account-manager.js +623 -0
- package/account-manager.js.map +1 -0
- package/account-manager.mjs +620 -0
- package/account-manager.mjs.map +1 -0
- package/account.d.ts +156 -0
- package/account.js +10 -0
- package/account.js.map +1 -0
- package/account.mjs +9 -0
- package/account.mjs.map +1 -0
- package/algod-client/index.d.ts +3 -7
- package/algod-client/index.js +2 -5
- package/algod-client/index.mjs +2 -2
- package/algorand-client-transaction-creator.d.ts +1103 -0
- package/algorand-client-transaction-creator.js +735 -0
- package/algorand-client-transaction-creator.js.map +1 -0
- package/algorand-client-transaction-creator.mjs +734 -0
- package/algorand-client-transaction-creator.mjs.map +1 -0
- package/algorand-client-transaction-sender.d.ts +1317 -0
- package/algorand-client-transaction-sender.js +933 -0
- package/algorand-client-transaction-sender.js.map +1 -0
- package/algorand-client-transaction-sender.mjs +932 -0
- package/algorand-client-transaction-sender.mjs.map +1 -0
- package/algorand-client.d.ts +246 -0
- package/algorand-client.js +325 -0
- package/algorand-client.js.map +1 -0
- package/algorand-client.mjs +325 -0
- package/algorand-client.mjs.map +1 -0
- package/amount.d.ts +46 -3
- package/amount.js +92 -13
- package/amount.js.map +1 -1
- package/amount.mjs +80 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +2130 -0
- package/app-client.js +909 -0
- package/app-client.js.map +1 -0
- package/app-client.mjs +908 -0
- package/app-client.mjs.map +1 -0
- package/app-deployer.d.ts +166 -0
- package/app-deployer.js +353 -0
- package/app-deployer.js.map +1 -0
- package/app-deployer.mjs +353 -0
- package/app-deployer.mjs.map +1 -0
- package/app-factory.d.ts +965 -0
- package/app-factory.js +448 -0
- package/app-factory.js.map +1 -0
- package/app-factory.mjs +448 -0
- package/app-factory.mjs.map +1 -0
- package/app-manager.d.ts +323 -0
- package/app-manager.js +468 -0
- package/app-manager.js.map +1 -0
- package/app-manager.mjs +468 -0
- package/app-manager.mjs.map +1 -0
- package/app-spec.d.ts +203 -0
- package/app-spec.js +137 -0
- package/app-spec.js.map +1 -0
- package/app-spec.mjs +137 -0
- package/app-spec.mjs.map +1 -0
- package/app.d.ts +257 -0
- package/app.js +49 -0
- package/app.js.map +1 -0
- package/app.mjs +42 -0
- package/app.mjs.map +1 -0
- package/asset-manager.d.ts +212 -0
- package/asset-manager.js +166 -0
- package/asset-manager.js.map +1 -0
- package/asset-manager.mjs +166 -0
- package/asset-manager.mjs.map +1 -0
- package/async-event-emitter.d.ts +16 -0
- package/async-event-emitter.js +38 -0
- package/async-event-emitter.js.map +1 -0
- package/async-event-emitter.mjs +37 -0
- package/async-event-emitter.mjs.map +1 -0
- package/client-manager.d.ts +475 -0
- package/client-manager.js +616 -0
- package/client-manager.js.map +1 -0
- package/client-manager.mjs +616 -0
- package/client-manager.mjs.map +1 -0
- package/composer.d.ts +947 -0
- package/composer.js +1584 -0
- package/composer.js.map +1 -0
- package/composer.mjs +1583 -0
- package/composer.mjs.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +2 -2
- package/config.js.map +1 -1
- package/config.mjs +1 -1
- package/config.mjs.map +1 -1
- package/debugging.d.ts +47 -0
- package/debugging.js +20 -0
- package/debugging.js.map +1 -0
- package/debugging.mjs +15 -0
- package/debugging.mjs.map +1 -0
- package/dispenser-client.d.ts +90 -0
- package/dispenser-client.js +127 -0
- package/dispenser-client.js.map +1 -0
- package/dispenser-client.mjs +127 -0
- package/dispenser-client.mjs.map +1 -0
- package/expand.d.ts +2 -0
- package/expand.js +0 -0
- package/expand.mjs +0 -0
- package/index.d.ts +6 -6
- package/index.js +4 -10
- package/index.mjs +5 -6
- package/indexer-client/index.d.ts +2 -2
- package/indexer-client/index.js +6 -6
- package/indexer-client/index.mjs +2 -2
- package/{indexer-lookup.d.ts → indexer-client/indexer-lookup.d.ts} +8 -11
- package/{indexer-lookup.mjs → indexer-client/indexer-lookup.js} +6 -10
- package/indexer-client/indexer-lookup.js.map +1 -0
- package/{indexer-lookup.js → indexer-client/indexer-lookup.mjs} +3 -18
- package/indexer-client/indexer-lookup.mjs.map +1 -0
- package/indexer.d.ts +40 -0
- package/indexer.js +38 -0
- package/indexer.js.map +1 -0
- package/indexer.mjs +35 -0
- package/indexer.mjs.map +1 -0
- package/instance-of.d.ts +8 -0
- package/kmd-account-manager.d.ts +74 -0
- package/kmd-account-manager.js +167 -0
- package/kmd-account-manager.js.map +1 -0
- package/kmd-account-manager.mjs +165 -0
- package/kmd-account-manager.mjs.map +1 -0
- package/kmd-client/index.d.ts +1 -2
- package/kmd-client/index.js +0 -5
- package/kmd-client/index.mjs +1 -2
- package/lifecycle-events.d.ts +14 -0
- package/lifecycle-events.js +11 -0
- package/lifecycle-events.js.map +1 -0
- package/lifecycle-events.mjs +10 -0
- package/lifecycle-events.mjs.map +1 -0
- package/logging.d.ts +13 -0
- package/logging.js +47 -0
- package/logging.js.map +1 -0
- package/logging.mjs +42 -0
- package/logging.mjs.map +1 -0
- package/logic-error.d.ts +39 -0
- package/logic-error.js +54 -0
- package/logic-error.js.map +1 -0
- package/logic-error.mjs +53 -0
- package/logic-error.mjs.map +1 -0
- package/network-client.d.ts +43 -0
- package/network-client.js +14 -0
- package/network-client.js.map +1 -0
- package/network-client.mjs +13 -0
- package/network-client.mjs.map +1 -0
- package/package.json +14 -5
- package/packages/abi/src/abi-method.d.ts +1 -1
- package/packages/abi/src/abi-method.js +1 -1
- package/packages/abi/src/abi-method.js.map +1 -1
- package/packages/abi/src/abi-method.mjs +1 -1
- package/packages/abi/src/abi-method.mjs.map +1 -1
- package/packages/abi/src/abi-type.d.ts +1 -3
- package/packages/abi/src/abi-type.js +7 -36
- package/packages/abi/src/abi-type.js.map +1 -1
- package/packages/abi/src/abi-type.mjs +7 -36
- 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/abi/src/utils.d.ts +22 -0
- package/packages/abi/src/utils.js +57 -0
- package/packages/abi/src/utils.js.map +1 -0
- package/packages/abi/src/utils.mjs +55 -0
- package/packages/abi/src/utils.mjs.map +1 -0
- package/packages/algo25/src/index.js +1 -1
- package/packages/algo25/src/index.mjs +1 -1
- package/packages/algod_client/src/apis/api-service.d.ts +44 -44
- package/packages/algod_client/src/apis/api-service.js +155 -155
- package/packages/algod_client/src/apis/api-service.js.map +1 -1
- package/packages/algod_client/src/apis/api-service.mjs +155 -155
- package/packages/algod_client/src/apis/api-service.mjs.map +1 -1
- package/packages/algod_client/src/core/api-error.js +3 -1
- package/packages/algod_client/src/core/api-error.js.map +1 -1
- package/packages/algod_client/src/core/api-error.mjs +3 -1
- package/packages/algod_client/src/core/api-error.mjs.map +1 -1
- package/packages/algod_client/src/core/model-runtime.js +6 -6
- package/packages/algod_client/src/core/model-runtime.js.map +1 -1
- package/packages/algod_client/src/core/model-runtime.mjs +8 -8
- package/packages/algod_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/algod_client/src/models/account-participation.js +4 -4
- package/packages/algod_client/src/models/account-participation.js.map +1 -1
- package/packages/algod_client/src/models/account-participation.mjs +4 -4
- package/packages/algod_client/src/models/account-participation.mjs.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/algod_client/src/models/application-state-schema.js +2 -2
- package/packages/algod_client/src/models/application-state-schema.js.map +1 -1
- package/packages/algod_client/src/models/application-state-schema.mjs +2 -2
- package/packages/algod_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/algod_client/src/models/asset-params.js +2 -1
- package/packages/algod_client/src/models/asset-params.js.map +1 -1
- package/packages/algod_client/src/models/asset-params.mjs +2 -1
- package/packages/algod_client/src/models/asset-params.mjs.map +1 -1
- package/packages/algod_client/src/models/block-response.js +1 -2
- package/packages/algod_client/src/models/block-response.js.map +1 -1
- package/packages/algod_client/src/models/block-response.mjs +2 -3
- package/packages/algod_client/src/models/block-response.mjs.map +1 -1
- package/packages/algod_client/src/models/block.d.ts +60 -40
- package/packages/algod_client/src/models/block.js +184 -108
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs +184 -108
- package/packages/algod_client/src/models/block.mjs.map +1 -1
- package/packages/algod_client/src/models/eval-delta-key-value.js +2 -2
- package/packages/algod_client/src/models/eval-delta-key-value.js.map +1 -1
- package/packages/algod_client/src/models/eval-delta-key-value.mjs +2 -2
- package/packages/algod_client/src/models/eval-delta-key-value.mjs.map +1 -1
- package/packages/algod_client/src/models/eval-delta.js +2 -2
- package/packages/algod_client/src/models/eval-delta.js.map +1 -1
- package/packages/algod_client/src/models/eval-delta.mjs +2 -2
- package/packages/algod_client/src/models/eval-delta.mjs.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.js.map +1 -1
- package/packages/algod_client/src/models/ledger-state-delta.mjs +2 -2
- package/packages/algod_client/src/models/ledger-state-delta.mjs.map +1 -1
- package/packages/algod_client/src/models/simulate-request.js +1 -1
- package/packages/algod_client/src/models/simulate-request.mjs +1 -1
- package/packages/algod_client/src/models/simulate-response.d.ts +2 -1
- package/packages/algod_client/src/models/simulate-response.js +6 -1
- package/packages/algod_client/src/models/simulate-response.js.map +1 -1
- package/packages/algod_client/src/models/simulate-response.mjs +6 -2
- package/packages/algod_client/src/models/simulate-response.mjs.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.d.ts +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js +4 -6
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.js.map +1 -1
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs +3 -5
- package/packages/algod_client/src/models/simulate-unnamed-resources-accessed.mjs.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.js +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.js.map +1 -1
- package/packages/algod_client/src/models/transaction-parameters-response.mjs +2 -2
- package/packages/algod_client/src/models/transaction-parameters-response.mjs.map +1 -1
- package/packages/common/src/address.d.ts +0 -1
- package/packages/common/src/address.js +4 -17
- package/packages/common/src/address.js.map +1 -1
- package/packages/common/src/address.mjs +5 -17
- 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-base64.js +26 -0
- package/packages/common/src/codecs/primitives/bytes-base64.js.map +1 -0
- package/packages/common/src/codecs/primitives/bytes-base64.mjs +25 -0
- package/packages/common/src/codecs/primitives/bytes-base64.mjs.map +1 -0
- package/packages/common/src/codecs/primitives/bytes.js +0 -1
- package/packages/common/src/codecs/primitives/bytes.js.map +1 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js +0 -1
- package/packages/common/src/codecs/primitives/fixed-bytes.js.map +1 -1
- package/packages/common/src/codecs/wire.js +0 -1
- package/packages/common/src/codecs/wire.js.map +1 -1
- package/packages/common/src/json.mjs +2 -2
- package/packages/common/src/json.mjs.map +1 -1
- package/packages/common/src/msgpack.js +0 -1
- package/packages/common/src/msgpack.js.map +1 -1
- package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
- package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
- package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
- package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
- package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
- package/packages/indexer_client/src/apis/api-service.d.ts +1 -1
- package/packages/indexer_client/src/apis/api-service.js +12 -12
- package/packages/indexer_client/src/apis/api-service.js.map +1 -1
- package/packages/indexer_client/src/apis/api-service.mjs +12 -12
- package/packages/indexer_client/src/apis/api-service.mjs.map +1 -1
- package/packages/indexer_client/src/core/api-error.js +3 -1
- package/packages/indexer_client/src/core/api-error.js.map +1 -1
- package/packages/indexer_client/src/core/api-error.mjs +3 -1
- package/packages/indexer_client/src/core/api-error.mjs.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.js +0 -15
- package/packages/indexer_client/src/core/model-runtime.js.map +1 -1
- package/packages/indexer_client/src/core/model-runtime.mjs +1 -13
- package/packages/indexer_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/indexer_client/src/models/account-participation.js +4 -4
- package/packages/indexer_client/src/models/account-participation.js.map +1 -1
- package/packages/indexer_client/src/models/account-participation.mjs +4 -4
- package/packages/indexer_client/src/models/account-participation.mjs.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js +2 -2
- package/packages/indexer_client/src/models/application-state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/application-state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/application-state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/asset-params.js +2 -1
- package/packages/indexer_client/src/models/asset-params.js.map +1 -1
- package/packages/indexer_client/src/models/asset-params.mjs +2 -1
- package/packages/indexer_client/src/models/asset-params.mjs.map +1 -1
- package/packages/indexer_client/src/models/block.d.ts +5 -5
- package/packages/indexer_client/src/models/block.js +13 -13
- package/packages/indexer_client/src/models/block.js.map +1 -1
- package/packages/indexer_client/src/models/block.mjs +13 -13
- package/packages/indexer_client/src/models/block.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.js +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.d.ts +1 -1
- package/packages/indexer_client/src/models/eval-delta.js +2 -2
- package/packages/indexer_client/src/models/eval-delta.js.map +1 -1
- package/packages/indexer_client/src/models/eval-delta.mjs +2 -2
- package/packages/indexer_client/src/models/eval-delta.mjs.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.js +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.js.map +1 -1
- package/packages/indexer_client/src/models/hb-proof-fields.mjs +6 -6
- package/packages/indexer_client/src/models/hb-proof-fields.mjs.map +1 -1
- package/packages/indexer_client/src/models/participation-updates.d.ts +2 -2
- package/packages/indexer_client/src/models/participation-updates.js +2 -2
- package/packages/indexer_client/src/models/participation-updates.js.map +1 -1
- package/packages/indexer_client/src/models/participation-updates.mjs +2 -2
- package/packages/indexer_client/src/models/participation-updates.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.js +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.js.map +1 -1
- package/packages/indexer_client/src/models/state-proof-verifier.mjs +2 -2
- package/packages/indexer_client/src/models/state-proof-verifier.mjs.map +1 -1
- package/packages/indexer_client/src/models/state-schema.d.ts +2 -2
- package/packages/indexer_client/src/models/state-schema.js +2 -2
- package/packages/indexer_client/src/models/state-schema.js.map +1 -1
- package/packages/indexer_client/src/models/state-schema.mjs +2 -2
- package/packages/indexer_client/src/models/state-schema.mjs.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.d.ts +1 -1
- package/packages/indexer_client/src/models/teal-key-value.js +2 -2
- package/packages/indexer_client/src/models/teal-key-value.js.map +1 -1
- package/packages/indexer_client/src/models/teal-key-value.mjs +2 -2
- package/packages/indexer_client/src/models/teal-key-value.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-heartbeat.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.js +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-keyreg.mjs +4 -4
- package/packages/indexer_client/src/models/transaction-keyreg.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs +2 -1
- package/packages/indexer_client/src/models/transaction-signature-logicsig.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs +3 -3
- package/packages/indexer_client/src/models/transaction-signature-multisig-subsignature.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction-state-proof.d.ts +1 -1
- package/packages/indexer_client/src/models/transaction-state-proof.js +2 -2
- package/packages/indexer_client/src/models/transaction-state-proof.js.map +1 -1
- package/packages/indexer_client/src/models/transaction-state-proof.mjs +2 -2
- package/packages/indexer_client/src/models/transaction-state-proof.mjs.map +1 -1
- package/packages/indexer_client/src/models/transaction.d.ts +2 -2
- package/packages/indexer_client/src/models/transaction.js +6 -5
- package/packages/indexer_client/src/models/transaction.js.map +1 -1
- package/packages/indexer_client/src/models/transaction.mjs +6 -5
- package/packages/indexer_client/src/models/transaction.mjs.map +1 -1
- package/packages/kmd_client/src/apis/api-service.d.ts +5 -5
- package/packages/kmd_client/src/apis/api-service.js +32 -32
- package/packages/kmd_client/src/apis/api-service.js.map +1 -1
- package/packages/kmd_client/src/apis/api-service.mjs +32 -32
- package/packages/kmd_client/src/apis/api-service.mjs.map +1 -1
- package/packages/kmd_client/src/core/api-error.js +3 -1
- package/packages/kmd_client/src/core/api-error.js.map +1 -1
- package/packages/kmd_client/src/core/api-error.mjs +3 -1
- package/packages/kmd_client/src/core/api-error.mjs.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.js +2 -12
- package/packages/kmd_client/src/core/model-runtime.js.map +1 -1
- package/packages/kmd_client/src/core/model-runtime.mjs +3 -11
- package/packages/kmd_client/src/core/model-runtime.mjs.map +1 -1
- package/packages/transact/src/logicsig.d.ts +35 -33
- package/packages/transact/src/logicsig.js +74 -76
- package/packages/transact/src/logicsig.js.map +1 -1
- package/packages/transact/src/logicsig.mjs +77 -78
- package/packages/transact/src/logicsig.mjs.map +1 -1
- package/packages/transact/src/multisig.d.ts +11 -116
- package/packages/transact/src/multisig.js +106 -136
- package/packages/transact/src/multisig.js.map +1 -1
- package/packages/transact/src/multisig.mjs +108 -118
- package/packages/transact/src/multisig.mjs.map +1 -1
- package/packages/transact/src/signer.js +9 -2
- package/packages/transact/src/signer.js.map +1 -1
- package/packages/transact/src/signer.mjs +10 -3
- package/packages/transact/src/signer.mjs.map +1 -1
- package/packages/transact/src/transactions/app-call.d.ts +10 -15
- package/packages/transact/src/transactions/app-call.js.map +1 -1
- package/packages/transact/src/transactions/app-call.mjs.map +1 -1
- package/packages/transact/src/transactions/asset-config.d.ts +1 -6
- package/packages/transact/src/transactions/asset-config.js.map +1 -1
- package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
- package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
- package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
- package/packages/transact/src/transactions/key-registration.d.ts +1 -8
- package/packages/transact/src/transactions/reference-types-meta.d.ts +26 -0
- package/packages/transact/src/transactions/reference-types-meta.js +71 -0
- package/packages/transact/src/transactions/reference-types-meta.js.map +1 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs +69 -0
- package/packages/transact/src/transactions/reference-types-meta.mjs.map +1 -0
- package/packages/transact/src/transactions/signed-transaction-meta.js +8 -9
- package/packages/transact/src/transactions/signed-transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction-meta.mjs +8 -8
- package/packages/transact/src/transactions/signed-transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.d.ts +10 -6
- package/packages/transact/src/transactions/signed-transaction.js +1 -1
- package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
- package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
- package/packages/transact/src/transactions/state-proof.d.ts +1 -1
- package/packages/transact/src/transactions/transaction-meta.js +29 -23
- package/packages/transact/src/transactions/transaction-meta.js.map +1 -1
- package/packages/transact/src/transactions/transaction-meta.mjs +29 -23
- package/packages/transact/src/transactions/transaction-meta.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction.d.ts +5 -2
- package/packages/transact/src/transactions/transaction.js +5 -4
- package/packages/transact/src/transactions/transaction.js.map +1 -1
- package/packages/transact/src/transactions/transaction.mjs +5 -4
- package/packages/transact/src/transactions/transaction.mjs.map +1 -1
- package/testing/account.d.ts +2 -2
- package/testing/account.js +2 -3
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +2 -3
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +5 -5
- package/testing/fixtures/algorand-fixture.js +2 -2
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +2 -2
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/test-logger.d.ts +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.js +1 -1
- package/testing/transaction-logger.mjs +1 -1
- package/testing/types.d.ts +156 -0
- package/transact/index.d.ts +11 -10
- package/transact/index.js +7 -31
- package/transact/index.mjs +7 -10
- package/transaction/index.d.ts +4 -0
- package/transaction/index.js +9 -0
- package/transaction/index.mjs +4 -0
- package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
- package/transaction/perform-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +2 -2
- 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/transaction/types.d.ts +133 -0
- package/transactions/app-call.d.ts +6 -5
- package/transactions/app-call.js +17 -17
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +17 -17
- 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/common.d.ts +1 -1
- package/transactions/common.js.map +1 -1
- package/transactions/common.mjs.map +1 -1
- package/transactions/key-registration.d.ts +1 -1
- package/transactions/key-registration.js.map +1 -1
- package/transactions/key-registration.mjs.map +1 -1
- package/transactions/method-call.d.ts +2 -2
- package/transactions/method-call.js +78 -85
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +78 -85
- package/transactions/method-call.mjs.map +1 -1
- package/transactions/payment.d.ts +1 -1
- package/transactions/payment.js.map +1 -1
- package/transactions/payment.mjs.map +1 -1
- package/types/account-manager.d.ts +11 -444
- package/types/account-manager.js +5 -606
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +5 -604
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +8 -150
- package/types/account.js +3 -4
- package/types/account.js.map +1 -1
- package/types/account.mjs +4 -4
- package/types/account.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +5 -1084
- package/types/algorand-client-transaction-creator.js +3 -721
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +4 -721
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +5 -1298
- package/types/algorand-client-transaction-sender.js +3 -920
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +3 -918
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +5 -241
- package/types/algorand-client.js +3 -319
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +3 -319
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +6 -45
- package/types/amount.js +3 -60
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +3 -60
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +75 -2120
- package/types/app-client.js +3 -904
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +3 -902
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +21 -161
- package/types/app-deployer.js +3 -347
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +3 -347
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +21 -957
- package/types/app-factory.js +3 -442
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +3 -442
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +15 -316
- package/types/app-manager.js +3 -456
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +3 -456
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +39 -198
- package/types/app-spec.js +3 -124
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +3 -124
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +62 -247
- package/types/app.js +15 -37
- package/types/app.js.map +1 -1
- package/types/app.mjs +16 -37
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +9 -207
- package/types/asset-manager.js +3 -160
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -160
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +7 -14
- package/types/async-event-emitter.js +3 -32
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +4 -32
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +27 -470
- package/types/client-manager.js +3 -610
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +3 -610
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +79 -935
- package/types/composer.js +3 -1569
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +3 -1567
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +7 -52
- package/types/config.js +3 -74
- package/types/config.js.map +1 -1
- package/types/config.mjs +3 -74
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +12 -33
- package/types/debugging.js +11 -10
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -10
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +11 -85
- package/types/dispenser-client.js +3 -121
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +3 -121
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +4 -5
- package/types/indexer.d.ts +16 -36
- package/types/indexer.js +7 -30
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +8 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +4 -4
- package/types/kmd-account-manager.d.ts +5 -68
- package/types/kmd-account-manager.js +3 -150
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +3 -148
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +7 -10
- package/types/lifecycle-events.js +3 -5
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +4 -5
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +14 -9
- package/types/logging.js +11 -37
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +12 -37
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +8 -35
- package/types/logic-error.js +3 -48
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +4 -48
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +10 -39
- package/types/network-client.js +3 -8
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +4 -8
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +13 -151
- package/types/transaction.d.ts +33 -128
- package/updatable-config.d.ts +57 -0
- package/updatable-config.js +80 -0
- package/updatable-config.js.map +1 -0
- package/updatable-config.mjs +80 -0
- package/updatable-config.mjs.map +1 -0
- package/util.js +1 -1
- package/util.js.map +1 -1
- package/util.mjs +1 -1
- package/util.mjs.map +1 -1
- package/_virtual/rolldown_runtime.mjs +0 -13
- package/indexer-lookup.js.map +0 -1
- package/indexer-lookup.mjs.map +0 -1
- package/packages/algod_client/src/core/model-runtime.d.ts +0 -10
- package/packages/algod_client/src/models/application-local-reference.d.ts +0 -20
- package/packages/algod_client/src/models/application-local-reference.js +0 -23
- package/packages/algod_client/src/models/application-local-reference.js.map +0 -1
- package/packages/algod_client/src/models/application-local-reference.mjs +0 -23
- package/packages/algod_client/src/models/application-local-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.d.ts +0 -20
- package/packages/algod_client/src/models/asset-holding-reference.js +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.js.map +0 -1
- package/packages/algod_client/src/models/asset-holding-reference.mjs +0 -23
- package/packages/algod_client/src/models/asset-holding-reference.mjs.map +0 -1
- package/packages/algod_client/src/models/box-reference.d.ts +0 -17
- package/packages/algod_client/src/models/box-reference.js +0 -23
- package/packages/algod_client/src/models/box-reference.js.map +0 -1
- package/packages/algod_client/src/models/box-reference.mjs +0 -23
- package/packages/algod_client/src/models/box-reference.mjs.map +0 -1
- package/packages/indexer_client/src/core/model-runtime.d.ts +0 -10
- package/packages/kmd_client/src/core/model-runtime.d.ts +0 -10
- package/packages/sdk/src/convert.d.ts +0 -17
- package/packages/sdk/src/convert.js +0 -28
- package/packages/sdk/src/convert.js.map +0 -1
- package/packages/sdk/src/convert.mjs +0 -25
- package/packages/sdk/src/convert.mjs.map +0 -1
- package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
- package/packages/sdk/src/encoding/binarydata.js +0 -65
- package/packages/sdk/src/encoding/binarydata.js.map +0 -1
- package/packages/sdk/src/encoding/binarydata.mjs +0 -60
- package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
- package/packages/sdk/src/encoding/encoding.d.ts +0 -237
- package/packages/sdk/src/encoding/encoding.js +0 -302
- package/packages/sdk/src/encoding/encoding.js.map +0 -1
- package/packages/sdk/src/encoding/encoding.mjs +0 -287
- package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/array.js +0 -35
- package/packages/sdk/src/encoding/schema/array.js.map +0 -1
- package/packages/sdk/src/encoding/schema/array.mjs +0 -35
- package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
- package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
- package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
- package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
- package/packages/sdk/src/encoding/schema/map.js +0 -110
- package/packages/sdk/src/encoding/schema/map.js.map +0 -1
- package/packages/sdk/src/encoding/schema/map.mjs +0 -107
- package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/optional.js +0 -46
- package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
- package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
- package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
- package/packages/sdk/src/encoding/schema/uint64.js +0 -30
- package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
- package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
- package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
- package/packages/sdk/src/encoding/uint64.d.ts +0 -34
- package/packages/sdk/src/encoding/uint64.js +0 -34
- package/packages/sdk/src/encoding/uint64.js.map +0 -1
- package/packages/sdk/src/encoding/uint64.mjs +0 -33
- package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
- package/packages/sdk/src/index.d.ts +0 -44
- package/packages/sdk/src/index.js +0 -62
- package/packages/sdk/src/index.js.map +0 -1
- package/packages/sdk/src/index.mjs +0 -58
- package/packages/sdk/src/index.mjs.map +0 -1
- package/packages/sdk/src/nacl/naclWrappers.js +0 -14
- package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
- package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
- package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
- package/packages/sdk/src/types/intDecoding.d.ts +0 -28
- package/packages/sdk/src/types/intDecoding.js +0 -32
- package/packages/sdk/src/types/intDecoding.js.map +0 -1
- package/packages/sdk/src/types/intDecoding.mjs +0 -31
- package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
- package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
- package/packages/sdk/src/types/transactions/encoded.js +0 -64
- package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
- package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
- package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
- package/packages/sdk/src/utils/utils.d.ts +0 -64
- package/packages/sdk/src/utils/utils.js +0 -140
- package/packages/sdk/src/utils/utils.js.map +0 -1
- package/packages/sdk/src/utils/utils.mjs +0 -128
- package/packages/sdk/src/utils/utils.mjs.map +0 -1
- package/packages/transact/src/transactions/common.d.ts +0 -37
- package/sdk/index.d.ts +0 -10
- package/sdk/index.js +0 -59
- package/sdk/index.mjs +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulate-unnamed-resources-accessed.js","names":["SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed>","addressArrayCodec","bigIntArrayCodec","ArrayCodec","ObjectModelCodec","BoxReferenceMeta","numberCodec","
|
|
1
|
+
{"version":3,"file":"simulate-unnamed-resources-accessed.js","names":["SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed>","addressArrayCodec","bigIntArrayCodec","ArrayCodec","ObjectModelCodec","BoxReferenceMeta","numberCodec","HoldingReferenceMeta","LocalsReferenceMeta"],"sources":["../../../../../packages/algod_client/src/models/simulate-unnamed-resources-accessed.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { numberCodec, ArrayCodec, bigIntArrayCodec, addressArrayCodec, ObjectModelCodec } from '@algorandfoundation/algokit-common'\nimport type { BoxReference, HoldingReference, LocalsReference } from '@algorandfoundation/algokit-transact'\nimport { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from '@algorandfoundation/algokit-transact'\n\n/**\n * These are resources that were accessed by this group that would normally have caused failure, but were allowed in simulation. Depending on where this object is in the response, the unnamed resources it contains may or may not qualify for group resource sharing. If this is a field in SimulateTransactionGroupResult, the resources do qualify, but if this is a field in SimulateTransactionResult, they do not qualify. In order to make this group valid for actual submission, resources that qualify for group sharing can be made available by any transaction of the group; otherwise, resources must be placed in the same transaction which accessed them.\n */\nexport type SimulateUnnamedResourcesAccessed = {\n /**\n * The unnamed accounts that were referenced. The order of this array is arbitrary.\n */\n accounts?: Address[]\n\n /**\n * The unnamed assets that were referenced. The order of this array is arbitrary.\n */\n assets?: bigint[]\n\n /**\n * The unnamed applications that were referenced. The order of this array is arbitrary.\n */\n apps?: bigint[]\n\n /**\n * The unnamed boxes that were referenced. The order of this array is arbitrary.\n */\n boxes?: BoxReference[]\n\n /**\n * The number of extra box references used to increase the IO budget. This is in addition to the references defined in the input transaction group and any referenced to unnamed boxes.\n */\n extraBoxRefs?: number\n\n /**\n * The unnamed asset holdings that were referenced. The order of this array is arbitrary.\n */\n assetHoldings?: HoldingReference[]\n\n /**\n * The unnamed application local states that were referenced. The order of this array is arbitrary.\n */\n appLocals?: LocalsReference[]\n}\n\nexport const SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed> = {\n name: 'SimulateUnnamedResourcesAccessed',\n kind: 'object',\n fields: [\n {\n name: 'accounts',\n wireKey: 'accounts',\n optional: true,\n codec: addressArrayCodec,\n },\n {\n name: 'assets',\n wireKey: 'assets',\n optional: true,\n codec: bigIntArrayCodec,\n },\n {\n name: 'apps',\n wireKey: 'apps',\n optional: true,\n codec: bigIntArrayCodec,\n },\n {\n name: 'boxes',\n wireKey: 'boxes',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(BoxReferenceMeta)),\n },\n {\n name: 'extraBoxRefs',\n wireKey: 'extra-box-refs',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'assetHoldings',\n wireKey: 'asset-holdings',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(HoldingReferenceMeta)),\n },\n {\n name: 'appLocals',\n wireKey: 'app-locals',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(LocalsReferenceMeta)),\n },\n ],\n}\n"],"mappings":";;;;;;AA6CA,MAAaA,uCAA8F;CACzG,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOA;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIC,yBAAW,IAAIC,sCAAiBC,8CAAiB,CAAC;GAC9D;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIH,yBAAW,IAAIC,sCAAiBG,kDAAqB,CAAC;GAClE;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAIJ,yBAAW,IAAIC,sCAAiBI,iDAAoB,CAAC;GACjE;EACF;CACF"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { numberCodec } from "../../../common/src/codecs/primitives/number.mjs";
|
|
2
2
|
import { ArrayCodec, addressArrayCodec, bigIntArrayCodec } from "../../../common/src/codecs/composite/array.mjs";
|
|
3
3
|
import { ObjectModelCodec } from "../../../common/src/codecs/models/object-model.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { ApplicationLocalReferenceMeta } from "./application-local-reference.mjs";
|
|
6
|
-
import { BoxReferenceMeta } from "./box-reference.mjs";
|
|
4
|
+
import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../../../transact/src/transactions/reference-types-meta.mjs";
|
|
7
5
|
|
|
8
6
|
//#region packages/algod_client/src/models/simulate-unnamed-resources-accessed.ts
|
|
9
7
|
const SimulateUnnamedResourcesAccessedMeta = {
|
|
@@ -44,13 +42,13 @@ const SimulateUnnamedResourcesAccessedMeta = {
|
|
|
44
42
|
name: "assetHoldings",
|
|
45
43
|
wireKey: "asset-holdings",
|
|
46
44
|
optional: true,
|
|
47
|
-
codec: new ArrayCodec(new ObjectModelCodec(
|
|
45
|
+
codec: new ArrayCodec(new ObjectModelCodec(HoldingReferenceMeta))
|
|
48
46
|
},
|
|
49
47
|
{
|
|
50
48
|
name: "appLocals",
|
|
51
49
|
wireKey: "app-locals",
|
|
52
50
|
optional: true,
|
|
53
|
-
codec: new ArrayCodec(new ObjectModelCodec(
|
|
51
|
+
codec: new ArrayCodec(new ObjectModelCodec(LocalsReferenceMeta))
|
|
54
52
|
}
|
|
55
53
|
]
|
|
56
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulate-unnamed-resources-accessed.mjs","names":["SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed>"],"sources":["../../../../../packages/algod_client/src/models/simulate-unnamed-resources-accessed.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { numberCodec, ArrayCodec, bigIntArrayCodec, addressArrayCodec, ObjectModelCodec } from '@algorandfoundation/algokit-common'\nimport type {
|
|
1
|
+
{"version":3,"file":"simulate-unnamed-resources-accessed.mjs","names":["SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed>"],"sources":["../../../../../packages/algod_client/src/models/simulate-unnamed-resources-accessed.ts"],"sourcesContent":["import type { Address, ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { numberCodec, ArrayCodec, bigIntArrayCodec, addressArrayCodec, ObjectModelCodec } from '@algorandfoundation/algokit-common'\nimport type { BoxReference, HoldingReference, LocalsReference } from '@algorandfoundation/algokit-transact'\nimport { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from '@algorandfoundation/algokit-transact'\n\n/**\n * These are resources that were accessed by this group that would normally have caused failure, but were allowed in simulation. Depending on where this object is in the response, the unnamed resources it contains may or may not qualify for group resource sharing. If this is a field in SimulateTransactionGroupResult, the resources do qualify, but if this is a field in SimulateTransactionResult, they do not qualify. In order to make this group valid for actual submission, resources that qualify for group sharing can be made available by any transaction of the group; otherwise, resources must be placed in the same transaction which accessed them.\n */\nexport type SimulateUnnamedResourcesAccessed = {\n /**\n * The unnamed accounts that were referenced. The order of this array is arbitrary.\n */\n accounts?: Address[]\n\n /**\n * The unnamed assets that were referenced. The order of this array is arbitrary.\n */\n assets?: bigint[]\n\n /**\n * The unnamed applications that were referenced. The order of this array is arbitrary.\n */\n apps?: bigint[]\n\n /**\n * The unnamed boxes that were referenced. The order of this array is arbitrary.\n */\n boxes?: BoxReference[]\n\n /**\n * The number of extra box references used to increase the IO budget. This is in addition to the references defined in the input transaction group and any referenced to unnamed boxes.\n */\n extraBoxRefs?: number\n\n /**\n * The unnamed asset holdings that were referenced. The order of this array is arbitrary.\n */\n assetHoldings?: HoldingReference[]\n\n /**\n * The unnamed application local states that were referenced. The order of this array is arbitrary.\n */\n appLocals?: LocalsReference[]\n}\n\nexport const SimulateUnnamedResourcesAccessedMeta: ObjectModelMetadata<SimulateUnnamedResourcesAccessed> = {\n name: 'SimulateUnnamedResourcesAccessed',\n kind: 'object',\n fields: [\n {\n name: 'accounts',\n wireKey: 'accounts',\n optional: true,\n codec: addressArrayCodec,\n },\n {\n name: 'assets',\n wireKey: 'assets',\n optional: true,\n codec: bigIntArrayCodec,\n },\n {\n name: 'apps',\n wireKey: 'apps',\n optional: true,\n codec: bigIntArrayCodec,\n },\n {\n name: 'boxes',\n wireKey: 'boxes',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(BoxReferenceMeta)),\n },\n {\n name: 'extraBoxRefs',\n wireKey: 'extra-box-refs',\n optional: true,\n codec: numberCodec,\n },\n {\n name: 'assetHoldings',\n wireKey: 'asset-holdings',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(HoldingReferenceMeta)),\n },\n {\n name: 'appLocals',\n wireKey: 'app-locals',\n optional: true,\n codec: new ArrayCodec(new ObjectModelCodec(LocalsReferenceMeta)),\n },\n ],\n}\n"],"mappings":";;;;;;AA6CA,MAAaA,uCAA8F;CACzG,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,iBAAiB,CAAC;GAC9D;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,qBAAqB,CAAC;GAClE;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO,IAAI,WAAW,IAAI,iBAAiB,oBAAoB,CAAC;GACjE;EACF;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_bigint = require('../../../common/src/codecs/primitives/bigint.js');
|
|
2
|
-
const
|
|
2
|
+
const require_fixed_bytes = require('../../../common/src/codecs/primitives/fixed-bytes.js');
|
|
3
3
|
const require_string = require('../../../common/src/codecs/primitives/string.js');
|
|
4
4
|
|
|
5
5
|
//#region packages/algod_client/src/models/transaction-parameters-response.ts
|
|
@@ -23,7 +23,7 @@ const TransactionParametersResponseMeta = {
|
|
|
23
23
|
name: "genesisHash",
|
|
24
24
|
wireKey: "genesis-hash",
|
|
25
25
|
optional: false,
|
|
26
|
-
codec:
|
|
26
|
+
codec: require_fixed_bytes.fixedBytes32Codec
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: "genesisId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-parameters-response.js","names":["TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse>","stringCodec","bigIntCodec","
|
|
1
|
+
{"version":3,"file":"transaction-parameters-response.js","names":["TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse>","stringCodec","bigIntCodec","fixedBytes32Codec"],"sources":["../../../../../packages/algod_client/src/models/transaction-parameters-response.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringCodec, bigIntCodec, fixedBytes32Codec } from '@algorandfoundation/algokit-common'\n\n/**\n * TransactionParams contains the parameters that help a client construct\n * a new transaction.\n */\nexport type TransactionParametersResponse = {\n /**\n * ConsensusVersion indicates the consensus protocol version\n * as of LastRound.\n */\n consensusVersion: string\n\n /**\n * Fee is the suggested transaction fee\n * Fee is in units of micro-Algos per byte.\n * Fee may fall to zero but transactions must still have a fee of\n * at least MinTxnFee for the current network protocol.\n */\n fee: bigint\n\n /**\n * GenesisHash is the hash of the genesis block.\n */\n genesisHash: Uint8Array\n\n /**\n * GenesisID is an ID listed in the genesis block.\n */\n genesisId: string\n\n /**\n * LastRound indicates the last round seen\n */\n lastRound: bigint\n\n /**\n * The minimum transaction fee (not per byte) required for the\n * txn to validate for the current network protocol.\n */\n minFee: bigint\n}\n\nexport const TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse> = {\n name: 'TransactionParametersResponse',\n kind: 'object',\n fields: [\n {\n name: 'consensusVersion',\n wireKey: 'consensus-version',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'fee',\n wireKey: 'fee',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'genesisHash',\n wireKey: 'genesis-hash',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'genesisId',\n wireKey: 'genesis-id',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'lastRound',\n wireKey: 'last-round',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'minFee',\n wireKey: 'min-fee',\n optional: false,\n codec: bigIntCodec,\n },\n ],\n}\n"],"mappings":";;;;;AA4CA,MAAaA,oCAAwF;CACnG,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOF;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOC;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAOA;GACR;EACF;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bigIntCodec } from "../../../common/src/codecs/primitives/bigint.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { fixedBytes32Codec } from "../../../common/src/codecs/primitives/fixed-bytes.mjs";
|
|
3
3
|
import { stringCodec } from "../../../common/src/codecs/primitives/string.mjs";
|
|
4
4
|
|
|
5
5
|
//#region packages/algod_client/src/models/transaction-parameters-response.ts
|
|
@@ -23,7 +23,7 @@ const TransactionParametersResponseMeta = {
|
|
|
23
23
|
name: "genesisHash",
|
|
24
24
|
wireKey: "genesis-hash",
|
|
25
25
|
optional: false,
|
|
26
|
-
codec:
|
|
26
|
+
codec: fixedBytes32Codec
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: "genesisId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-parameters-response.mjs","names":["TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse>"],"sources":["../../../../../packages/algod_client/src/models/transaction-parameters-response.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringCodec, bigIntCodec,
|
|
1
|
+
{"version":3,"file":"transaction-parameters-response.mjs","names":["TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse>"],"sources":["../../../../../packages/algod_client/src/models/transaction-parameters-response.ts"],"sourcesContent":["import type { ObjectModelMetadata } from '@algorandfoundation/algokit-common'\nimport { stringCodec, bigIntCodec, fixedBytes32Codec } from '@algorandfoundation/algokit-common'\n\n/**\n * TransactionParams contains the parameters that help a client construct\n * a new transaction.\n */\nexport type TransactionParametersResponse = {\n /**\n * ConsensusVersion indicates the consensus protocol version\n * as of LastRound.\n */\n consensusVersion: string\n\n /**\n * Fee is the suggested transaction fee\n * Fee is in units of micro-Algos per byte.\n * Fee may fall to zero but transactions must still have a fee of\n * at least MinTxnFee for the current network protocol.\n */\n fee: bigint\n\n /**\n * GenesisHash is the hash of the genesis block.\n */\n genesisHash: Uint8Array\n\n /**\n * GenesisID is an ID listed in the genesis block.\n */\n genesisId: string\n\n /**\n * LastRound indicates the last round seen\n */\n lastRound: bigint\n\n /**\n * The minimum transaction fee (not per byte) required for the\n * txn to validate for the current network protocol.\n */\n minFee: bigint\n}\n\nexport const TransactionParametersResponseMeta: ObjectModelMetadata<TransactionParametersResponse> = {\n name: 'TransactionParametersResponse',\n kind: 'object',\n fields: [\n {\n name: 'consensusVersion',\n wireKey: 'consensus-version',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'fee',\n wireKey: 'fee',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'genesisHash',\n wireKey: 'genesis-hash',\n optional: false,\n codec: fixedBytes32Codec,\n },\n {\n name: 'genesisId',\n wireKey: 'genesis-id',\n optional: false,\n codec: stringCodec,\n },\n {\n name: 'lastRound',\n wireKey: 'last-round',\n optional: false,\n codec: bigIntCodec,\n },\n {\n name: 'minFee',\n wireKey: 'min-fee',\n optional: false,\n codec: bigIntCodec,\n },\n ],\n}\n"],"mappings":";;;;;AA4CA,MAAaA,oCAAwF;CACnG,MAAM;CACN,MAAM;CACN,QAAQ;EACN;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACD;GACE,MAAM;GACN,SAAS;GACT,UAAU;GACV,OAAO;GACR;EACF;CACF"}
|
|
@@ -89,10 +89,11 @@ var Address = class Address {
|
|
|
89
89
|
static zeroAddress() {
|
|
90
90
|
return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH));
|
|
91
91
|
}
|
|
92
|
-
static [Symbol.hasInstance](obj) {
|
|
93
|
-
return Boolean(obj && typeof obj === "object" && ADDR_SYMBOL in obj && obj[ADDR_SYMBOL]);
|
|
94
|
-
}
|
|
95
92
|
};
|
|
93
|
+
Object.defineProperty(Address, Symbol.hasInstance, { value: function(obj) {
|
|
94
|
+
if (obj instanceof Object && Object.getPrototypeOf(obj) === Address.prototype) return true;
|
|
95
|
+
return Boolean(obj && typeof obj === "object" && ADDR_SYMBOL in obj && obj[ADDR_SYMBOL]);
|
|
96
|
+
} });
|
|
96
97
|
function getAddress(addr) {
|
|
97
98
|
if (typeof addr == "string") return Address.fromString(addr);
|
|
98
99
|
else if ("addr" in addr) return addr.addr;
|
|
@@ -102,19 +103,6 @@ function getOptionalAddress(addr) {
|
|
|
102
103
|
if (addr === void 0) return;
|
|
103
104
|
return getAddress(addr);
|
|
104
105
|
}
|
|
105
|
-
/**
|
|
106
|
-
* isValidAddress checks if a string is a valid Algorand address.
|
|
107
|
-
* @param address - an Algorand address with checksum.
|
|
108
|
-
* @returns true if valid, false otherwise
|
|
109
|
-
*/
|
|
110
|
-
function isValidAddress(address) {
|
|
111
|
-
try {
|
|
112
|
-
Address.fromString(address);
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
106
|
const APP_ID_PREFIX = new TextEncoder().encode("appID");
|
|
119
107
|
/**
|
|
120
108
|
* Get the escrow address of an application.
|
|
@@ -152,5 +140,4 @@ exports.encodeAddress = encodeAddress;
|
|
|
152
140
|
exports.getAddress = getAddress;
|
|
153
141
|
exports.getApplicationAddress = getApplicationAddress;
|
|
154
142
|
exports.getOptionalAddress = getOptionalAddress;
|
|
155
|
-
exports.isValidAddress = isValidAddress;
|
|
156
143
|
//# sourceMappingURL=address.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","names":["sha512","HASH_BYTES_LENGTH","CHECKSUM_BYTE_LENGTH","arrayEqual","base32","concatArrays"],"sources":["../../../../packages/common/src/address.ts"],"sourcesContent":["import base32 from 'hi-base32'\nimport sha512 from 'js-sha512'\nimport { arrayEqual, concatArrays } from './array'\nimport { CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH } from './constants'\n\nexport const ALGORAND_ADDRESS_BYTE_LENGTH = 36\nexport const ALGORAND_CHECKSUM_BYTE_LENGTH = 4\nexport const ALGORAND_ADDRESS_LENGTH = 58\nexport const ALGORAND_ZERO_ADDRESS_STRING = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'\n\nexport const MALFORMED_ADDRESS_ERROR_MSG = 'address seems to be malformed'\nexport const CHECKSUM_ADDRESS_ERROR_MSG = 'wrong checksum for address'\n\nexport function checksumFromPublicKey(publicKey: Uint8Array): Uint8Array {\n return Uint8Array.from(sha512.sha512_256.array(publicKey).slice(HASH_BYTES_LENGTH - CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH))\n}\n\nfunction genericHash(arr: sha512.Message) {\n return sha512.sha512_256.array(arr)\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nexport function encodeUint64(num: number | bigint) {\n const isInteger = typeof num === 'bigint' || Number.isInteger(num)\n\n if (!isInteger || num < 0 || num > BigInt('0xffffffffffffffff')) {\n throw new Error('Input is not a 64-bit unsigned integer')\n }\n\n const encoding = new Uint8Array(8)\n const view = new DataView(encoding.buffer)\n view.setBigUint64(0, BigInt(num))\n\n return encoding\n}\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nconst ADDR_SYMBOL = Symbol.for('algokit_common:Address')\n\n/**\n * Represents an Algorand address\n */\nexport class Address {\n /**\n * The binary form of the address. For standard accounts, this is the public key.\n */\n public readonly publicKey: Uint8Array;\n\n /** @internal */\n [ADDR_SYMBOL]: boolean\n\n /**\n * Create a new Address object from its binary form.\n * @param publicKey - The binary form of the address. Must be 32 bytes.\n */\n constructor(publicKey: Uint8Array) {\n this[ADDR_SYMBOL] = true\n if (publicKey.length !== ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(publicKey)}, length ${publicKey.length}`)\n this.publicKey = publicKey\n }\n\n /**\n * Check if the address is equal to another address.\n */\n equals(other: Address): boolean {\n return other instanceof Address && arrayEqual(this.publicKey, other.publicKey)\n }\n\n /**\n * Compute the 4 byte checksum of the address.\n */\n checksum(): Uint8Array {\n return checksumFromPublicKey(this.publicKey)\n }\n\n /**\n * Encode the address into a string form.\n */\n toString(): string {\n const addr = base32.encode(concatArrays(this.publicKey, this.checksum()))\n return addr.slice(0, ALGORAND_ADDRESS_LENGTH) // removing the extra '===='\n }\n\n /**\n * Decode an address from a string.\n * @param address - The address to decode. Must be 58 characters long.\n * @returns An Address object corresponding to the input string.\n */\n static fromString(address: string): Address {\n if (typeof address !== 'string') throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof address}, ${address}`)\n if (address.length !== ALGORAND_ADDRESS_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${address.length}: ${address}`)\n\n // try to decode\n const decoded = base32.decode.asBytes(address)\n // Sanity check\n if (decoded.length !== ALGORAND_ADDRESS_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${decoded.length}`)\n\n // Find publickey and checksum\n const pk = new Uint8Array(decoded.slice(0, ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n const cs = new Uint8Array(decoded.slice(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ADDRESS_BYTE_LENGTH))\n const checksum = checksumFromPublicKey(pk)\n // Check if the checksum and the address are equal\n if (!arrayEqual(checksum, cs)) throw new Error(`${CHECKSUM_ADDRESS_ERROR_MSG}: ${address} (${cs}, ${checksum})`)\n\n return new Address(pk)\n }\n\n /**\n * Get the zero address.\n */\n static zeroAddress(): Address {\n return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n }\n\n
|
|
1
|
+
{"version":3,"file":"address.js","names":["sha512","HASH_BYTES_LENGTH","CHECKSUM_BYTE_LENGTH","arrayEqual","base32","concatArrays"],"sources":["../../../../packages/common/src/address.ts"],"sourcesContent":["import base32 from 'hi-base32'\nimport sha512 from 'js-sha512'\nimport { arrayEqual, concatArrays } from './array'\nimport { CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH } from './constants'\n\nexport const ALGORAND_ADDRESS_BYTE_LENGTH = 36\nexport const ALGORAND_CHECKSUM_BYTE_LENGTH = 4\nexport const ALGORAND_ADDRESS_LENGTH = 58\nexport const ALGORAND_ZERO_ADDRESS_STRING = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'\n\nexport const MALFORMED_ADDRESS_ERROR_MSG = 'address seems to be malformed'\nexport const CHECKSUM_ADDRESS_ERROR_MSG = 'wrong checksum for address'\n\nexport function checksumFromPublicKey(publicKey: Uint8Array): Uint8Array {\n return Uint8Array.from(sha512.sha512_256.array(publicKey).slice(HASH_BYTES_LENGTH - CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH))\n}\n\nfunction genericHash(arr: sha512.Message) {\n return sha512.sha512_256.array(arr)\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nexport function encodeUint64(num: number | bigint) {\n const isInteger = typeof num === 'bigint' || Number.isInteger(num)\n\n if (!isInteger || num < 0 || num > BigInt('0xffffffffffffffff')) {\n throw new Error('Input is not a 64-bit unsigned integer')\n }\n\n const encoding = new Uint8Array(8)\n const view = new DataView(encoding.buffer)\n view.setBigUint64(0, BigInt(num))\n\n return encoding\n}\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nconst ADDR_SYMBOL = Symbol.for('algokit_common:Address')\n\n/**\n * Represents an Algorand address\n */\nexport class Address {\n /**\n * The binary form of the address. For standard accounts, this is the public key.\n */\n public readonly publicKey: Uint8Array;\n\n /** @internal */\n [ADDR_SYMBOL]: boolean\n\n /**\n * Create a new Address object from its binary form.\n * @param publicKey - The binary form of the address. Must be 32 bytes.\n */\n constructor(publicKey: Uint8Array) {\n this[ADDR_SYMBOL] = true\n if (publicKey.length !== ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(publicKey)}, length ${publicKey.length}`)\n this.publicKey = publicKey\n }\n\n /**\n * Check if the address is equal to another address.\n */\n equals(other: Address): boolean {\n return other instanceof Address && arrayEqual(this.publicKey, other.publicKey)\n }\n\n /**\n * Compute the 4 byte checksum of the address.\n */\n checksum(): Uint8Array {\n return checksumFromPublicKey(this.publicKey)\n }\n\n /**\n * Encode the address into a string form.\n */\n toString(): string {\n const addr = base32.encode(concatArrays(this.publicKey, this.checksum()))\n return addr.slice(0, ALGORAND_ADDRESS_LENGTH) // removing the extra '===='\n }\n\n /**\n * Decode an address from a string.\n * @param address - The address to decode. Must be 58 characters long.\n * @returns An Address object corresponding to the input string.\n */\n static fromString(address: string): Address {\n if (typeof address !== 'string') throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof address}, ${address}`)\n if (address.length !== ALGORAND_ADDRESS_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${address.length}: ${address}`)\n\n // try to decode\n const decoded = base32.decode.asBytes(address)\n // Sanity check\n if (decoded.length !== ALGORAND_ADDRESS_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${decoded.length}`)\n\n // Find publickey and checksum\n const pk = new Uint8Array(decoded.slice(0, ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n const cs = new Uint8Array(decoded.slice(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ADDRESS_BYTE_LENGTH))\n const checksum = checksumFromPublicKey(pk)\n // Check if the checksum and the address are equal\n if (!arrayEqual(checksum, cs)) throw new Error(`${CHECKSUM_ADDRESS_ERROR_MSG}: ${address} (${cs}, ${checksum})`)\n\n return new Address(pk)\n }\n\n /**\n * Get the zero address.\n */\n static zeroAddress(): Address {\n return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n }\n}\n\n// Define Symbol.hasInstance outside the class to avoid Metro/Hermes parser issues\n// with static computed property names like `static [Symbol.hasInstance]()`\n// Also must handle Babel's _classCallCheck which uses instanceof before ADDR_SYMBOL is set\nObject.defineProperty(Address, Symbol.hasInstance, {\n value: function (obj: unknown): boolean {\n // First check prototype chain (handles Babel's _classCallCheck and normal instances)\n if (obj instanceof Object && Object.getPrototypeOf(obj) === Address.prototype) {\n return true\n }\n // Then check for the brand symbol (handles cross-realm/serialized instances)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Boolean(obj && typeof obj === 'object' && ADDR_SYMBOL in obj && (obj as any)[ADDR_SYMBOL])\n },\n})\n\nexport interface Addressable {\n addr: Readonly<Address>\n}\n\nexport type ReadableAddress = Addressable | Address | string\n\nexport function getAddress(addr: ReadableAddress): Address {\n if (typeof addr == 'string') {\n return Address.fromString(addr)\n } else if ('addr' in addr) {\n return addr.addr\n } else {\n return addr\n }\n}\n\nexport function getOptionalAddress(addr: ReadableAddress | undefined): Address | undefined {\n if (addr === undefined) {\n return undefined\n }\n return getAddress(addr)\n}\n\n/**\n * isValidAddress checks if a string is a valid Algorand address.\n * @param address - an Algorand address with checksum.\n * @returns true if valid, false otherwise\n */\nexport function isValidAddress(address: string): boolean {\n // Try to decode\n try {\n Address.fromString(address)\n } catch {\n return false\n }\n return true\n}\n\nconst APP_ID_PREFIX = new TextEncoder().encode('appID')\n\n/**\n * Get the escrow address of an application.\n * @param appID - The ID of the application.\n * @returns The address corresponding to that application's escrow account.\n */\nexport function getApplicationAddress(appID: number | bigint): Address {\n const toBeSigned = concatArrays(APP_ID_PREFIX, encodeUint64(appID))\n const hash = genericHash(toBeSigned)\n return new Address(Uint8Array.from(hash))\n}\n\n/**\n * decodeAddress takes an Algorand address in string form and decodes it into a Uint8Array.\n * @param address - an Algorand address with checksum.\n * @returns the decoded form of the address's public key and checksum\n */\nexport function decodeAddress(address: string): Address {\n return Address.fromString(address)\n}\n\n/**\n * encodeAddress takes an Algorand address as a Uint8Array and encodes it into a string with checksum.\n * @param address - a raw Algorand address\n * @returns the address and checksum encoded as a string.\n */\nexport function encodeAddress(address: Uint8Array): string {\n return new Address(address).toString()\n}\n"],"mappings":";;;;;;;;;AAKA,MAAa,+BAA+B;AAC5C,MAAa,gCAAgC;AAC7C,MAAa,0BAA0B;AACvC,MAAa,+BAA+B;AAE5C,MAAa,8BAA8B;AAC3C,MAAa,6BAA6B;AAE1C,SAAgB,sBAAsB,WAAmC;AACvE,QAAO,WAAW,KAAKA,kBAAO,WAAW,MAAM,UAAU,CAAC,MAAMC,sCAAoBC,wCAAsBD,oCAAkB,CAAC;;AAG/H,SAAS,YAAY,KAAqB;AACxC,QAAOD,kBAAO,WAAW,MAAM,IAAI;;AAGrC,SAAS,WAAW,OAA2B;AAC7C,QAAO,OAAO,KAAK,MAAM,CAAC,SAAS,MAAM;;AAG3C,SAAgB,aAAa,KAAsB;AAGjD,KAAI,EAFc,OAAO,QAAQ,YAAY,OAAO,UAAU,IAAI,KAEhD,MAAM,KAAK,MAAM,OAAO,qBAAqB,CAC7D,OAAM,IAAI,MAAM,yCAAyC;CAG3D,MAAM,WAAW,IAAI,WAAW,EAAE;AAElC,CADa,IAAI,SAAS,SAAS,OAAO,CACrC,aAAa,GAAG,OAAO,IAAI,CAAC;AAEjC,QAAO;;;AAIT,MAAM,cAAc,OAAO,IAAI,yBAAyB;;;;AAKxD,IAAa,UAAb,MAAa,QAAQ;;;;CAInB,AAAgB;;CAGhB,CAAC;;;;;CAMD,YAAY,WAAuB;AACjC,OAAK,eAAe;AACpB,MAAI,UAAU,WAAW,+BAA+B,8BACtD,OAAM,IAAI,MAAM,GAAG,4BAA4B,MAAM,WAAW,UAAU,CAAC,WAAW,UAAU,SAAS;AAC3G,OAAK,YAAY;;;;;CAMnB,OAAO,OAAyB;AAC9B,SAAO,iBAAiB,WAAWG,yBAAW,KAAK,WAAW,MAAM,UAAU;;;;;CAMhF,WAAuB;AACrB,SAAO,sBAAsB,KAAK,UAAU;;;;;CAM9C,WAAmB;AAEjB,SADaC,kBAAO,OAAOC,2BAAa,KAAK,WAAW,KAAK,UAAU,CAAC,CAAC,CAC7D,MAAM,GAAG,wBAAwB;;;;;;;CAQ/C,OAAO,WAAW,SAA0B;AAC1C,MAAI,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,GAAG,4BAA4B,yBAAyB,OAAO,QAAQ,IAAI,UAAU;AACtI,MAAI,QAAQ,WAAW,wBACrB,OAAM,IAAI,MAAM,GAAG,4BAA4B,oBAAoB,wBAAwB,QAAQ,QAAQ,OAAO,IAAI,UAAU;EAGlI,MAAM,UAAUD,kBAAO,OAAO,QAAQ,QAAQ;AAE9C,MAAI,QAAQ,WAAW,6BACrB,OAAM,IAAI,MAAM,GAAG,4BAA4B,yBAAyB,6BAA6B,QAAQ,QAAQ,SAAS;EAGhI,MAAM,KAAK,IAAI,WAAW,QAAQ,MAAM,GAAG,+BAA+B,8BAA8B,CAAC;EACzG,MAAM,KAAK,IAAI,WAAW,QAAQ,MAAM,+BAA+B,+BAA+B,6BAA6B,CAAC;EACpI,MAAM,WAAW,sBAAsB,GAAG;AAE1C,MAAI,CAACD,yBAAW,UAAU,GAAG,CAAE,OAAM,IAAI,MAAM,GAAG,2BAA2B,IAAI,QAAQ,IAAI,GAAG,IAAI,SAAS,GAAG;AAEhH,SAAO,IAAI,QAAQ,GAAG;;;;;CAMxB,OAAO,cAAuB;AAC5B,SAAO,IAAI,QAAQ,IAAI,WAAW,+BAA+B,8BAA8B,CAAC;;;AAOpG,OAAO,eAAe,SAAS,OAAO,aAAa,EACjD,OAAO,SAAU,KAAuB;AAEtC,KAAI,eAAe,UAAU,OAAO,eAAe,IAAI,KAAK,QAAQ,UAClE,QAAO;AAIT,QAAO,QAAQ,OAAO,OAAO,QAAQ,YAAY,eAAe,OAAQ,IAAY,aAAa;GAEpG,CAAC;AAQF,SAAgB,WAAW,MAAgC;AACzD,KAAI,OAAO,QAAQ,SACjB,QAAO,QAAQ,WAAW,KAAK;UACtB,UAAU,KACnB,QAAO,KAAK;KAEZ,QAAO;;AAIX,SAAgB,mBAAmB,MAAwD;AACzF,KAAI,SAAS,OACX;AAEF,QAAO,WAAW,KAAK;;AAkBzB,MAAM,gBAAgB,IAAI,aAAa,CAAC,OAAO,QAAQ;;;;;;AAOvD,SAAgB,sBAAsB,OAAiC;CAErE,MAAM,OAAO,YADME,2BAAa,eAAe,aAAa,MAAM,CAAC,CAC/B;AACpC,QAAO,IAAI,QAAQ,WAAW,KAAK,KAAK,CAAC;;;;;;;AAQ3C,SAAgB,cAAc,SAA0B;AACtD,QAAO,QAAQ,WAAW,QAAQ;;;;;;;AAQpC,SAAgB,cAAc,SAA6B;AACzD,QAAO,IAAI,QAAQ,QAAQ,CAAC,UAAU"}
|
|
@@ -86,10 +86,11 @@ var Address = class Address {
|
|
|
86
86
|
static zeroAddress() {
|
|
87
87
|
return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH));
|
|
88
88
|
}
|
|
89
|
-
static [Symbol.hasInstance](obj) {
|
|
90
|
-
return Boolean(obj && typeof obj === "object" && ADDR_SYMBOL in obj && obj[ADDR_SYMBOL]);
|
|
91
|
-
}
|
|
92
89
|
};
|
|
90
|
+
Object.defineProperty(Address, Symbol.hasInstance, { value: function(obj) {
|
|
91
|
+
if (obj instanceof Object && Object.getPrototypeOf(obj) === Address.prototype) return true;
|
|
92
|
+
return Boolean(obj && typeof obj === "object" && ADDR_SYMBOL in obj && obj[ADDR_SYMBOL]);
|
|
93
|
+
} });
|
|
93
94
|
function getAddress(addr) {
|
|
94
95
|
if (typeof addr == "string") return Address.fromString(addr);
|
|
95
96
|
else if ("addr" in addr) return addr.addr;
|
|
@@ -99,19 +100,6 @@ function getOptionalAddress(addr) {
|
|
|
99
100
|
if (addr === void 0) return;
|
|
100
101
|
return getAddress(addr);
|
|
101
102
|
}
|
|
102
|
-
/**
|
|
103
|
-
* isValidAddress checks if a string is a valid Algorand address.
|
|
104
|
-
* @param address - an Algorand address with checksum.
|
|
105
|
-
* @returns true if valid, false otherwise
|
|
106
|
-
*/
|
|
107
|
-
function isValidAddress(address) {
|
|
108
|
-
try {
|
|
109
|
-
Address.fromString(address);
|
|
110
|
-
} catch {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
103
|
const APP_ID_PREFIX = new TextEncoder().encode("appID");
|
|
116
104
|
/**
|
|
117
105
|
* Get the escrow address of an application.
|
|
@@ -140,5 +128,5 @@ function encodeAddress(address) {
|
|
|
140
128
|
}
|
|
141
129
|
|
|
142
130
|
//#endregion
|
|
143
|
-
export { ALGORAND_ADDRESS_BYTE_LENGTH, ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ZERO_ADDRESS_STRING, Address, decodeAddress, encodeAddress, getAddress, getApplicationAddress, getOptionalAddress
|
|
131
|
+
export { ALGORAND_ADDRESS_BYTE_LENGTH, ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ZERO_ADDRESS_STRING, Address, decodeAddress, encodeAddress, getAddress, getApplicationAddress, getOptionalAddress };
|
|
144
132
|
//# sourceMappingURL=address.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.mjs","names":[],"sources":["../../../../packages/common/src/address.ts"],"sourcesContent":["import base32 from 'hi-base32'\nimport sha512 from 'js-sha512'\nimport { arrayEqual, concatArrays } from './array'\nimport { CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH } from './constants'\n\nexport const ALGORAND_ADDRESS_BYTE_LENGTH = 36\nexport const ALGORAND_CHECKSUM_BYTE_LENGTH = 4\nexport const ALGORAND_ADDRESS_LENGTH = 58\nexport const ALGORAND_ZERO_ADDRESS_STRING = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'\n\nexport const MALFORMED_ADDRESS_ERROR_MSG = 'address seems to be malformed'\nexport const CHECKSUM_ADDRESS_ERROR_MSG = 'wrong checksum for address'\n\nexport function checksumFromPublicKey(publicKey: Uint8Array): Uint8Array {\n return Uint8Array.from(sha512.sha512_256.array(publicKey).slice(HASH_BYTES_LENGTH - CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH))\n}\n\nfunction genericHash(arr: sha512.Message) {\n return sha512.sha512_256.array(arr)\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nexport function encodeUint64(num: number | bigint) {\n const isInteger = typeof num === 'bigint' || Number.isInteger(num)\n\n if (!isInteger || num < 0 || num > BigInt('0xffffffffffffffff')) {\n throw new Error('Input is not a 64-bit unsigned integer')\n }\n\n const encoding = new Uint8Array(8)\n const view = new DataView(encoding.buffer)\n view.setBigUint64(0, BigInt(num))\n\n return encoding\n}\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nconst ADDR_SYMBOL = Symbol.for('algokit_common:Address')\n\n/**\n * Represents an Algorand address\n */\nexport class Address {\n /**\n * The binary form of the address. For standard accounts, this is the public key.\n */\n public readonly publicKey: Uint8Array;\n\n /** @internal */\n [ADDR_SYMBOL]: boolean\n\n /**\n * Create a new Address object from its binary form.\n * @param publicKey - The binary form of the address. Must be 32 bytes.\n */\n constructor(publicKey: Uint8Array) {\n this[ADDR_SYMBOL] = true\n if (publicKey.length !== ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(publicKey)}, length ${publicKey.length}`)\n this.publicKey = publicKey\n }\n\n /**\n * Check if the address is equal to another address.\n */\n equals(other: Address): boolean {\n return other instanceof Address && arrayEqual(this.publicKey, other.publicKey)\n }\n\n /**\n * Compute the 4 byte checksum of the address.\n */\n checksum(): Uint8Array {\n return checksumFromPublicKey(this.publicKey)\n }\n\n /**\n * Encode the address into a string form.\n */\n toString(): string {\n const addr = base32.encode(concatArrays(this.publicKey, this.checksum()))\n return addr.slice(0, ALGORAND_ADDRESS_LENGTH) // removing the extra '===='\n }\n\n /**\n * Decode an address from a string.\n * @param address - The address to decode. Must be 58 characters long.\n * @returns An Address object corresponding to the input string.\n */\n static fromString(address: string): Address {\n if (typeof address !== 'string') throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof address}, ${address}`)\n if (address.length !== ALGORAND_ADDRESS_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${address.length}: ${address}`)\n\n // try to decode\n const decoded = base32.decode.asBytes(address)\n // Sanity check\n if (decoded.length !== ALGORAND_ADDRESS_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${decoded.length}`)\n\n // Find publickey and checksum\n const pk = new Uint8Array(decoded.slice(0, ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n const cs = new Uint8Array(decoded.slice(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ADDRESS_BYTE_LENGTH))\n const checksum = checksumFromPublicKey(pk)\n // Check if the checksum and the address are equal\n if (!arrayEqual(checksum, cs)) throw new Error(`${CHECKSUM_ADDRESS_ERROR_MSG}: ${address} (${cs}, ${checksum})`)\n\n return new Address(pk)\n }\n\n /**\n * Get the zero address.\n */\n static zeroAddress(): Address {\n return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n }\n\n
|
|
1
|
+
{"version":3,"file":"address.mjs","names":[],"sources":["../../../../packages/common/src/address.ts"],"sourcesContent":["import base32 from 'hi-base32'\nimport sha512 from 'js-sha512'\nimport { arrayEqual, concatArrays } from './array'\nimport { CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH } from './constants'\n\nexport const ALGORAND_ADDRESS_BYTE_LENGTH = 36\nexport const ALGORAND_CHECKSUM_BYTE_LENGTH = 4\nexport const ALGORAND_ADDRESS_LENGTH = 58\nexport const ALGORAND_ZERO_ADDRESS_STRING = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'\n\nexport const MALFORMED_ADDRESS_ERROR_MSG = 'address seems to be malformed'\nexport const CHECKSUM_ADDRESS_ERROR_MSG = 'wrong checksum for address'\n\nexport function checksumFromPublicKey(publicKey: Uint8Array): Uint8Array {\n return Uint8Array.from(sha512.sha512_256.array(publicKey).slice(HASH_BYTES_LENGTH - CHECKSUM_BYTE_LENGTH, HASH_BYTES_LENGTH))\n}\n\nfunction genericHash(arr: sha512.Message) {\n return sha512.sha512_256.array(arr)\n}\n\nfunction bytesToHex(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('hex')\n}\n\nexport function encodeUint64(num: number | bigint) {\n const isInteger = typeof num === 'bigint' || Number.isInteger(num)\n\n if (!isInteger || num < 0 || num > BigInt('0xffffffffffffffff')) {\n throw new Error('Input is not a 64-bit unsigned integer')\n }\n\n const encoding = new Uint8Array(8)\n const view = new DataView(encoding.buffer)\n view.setBigUint64(0, BigInt(num))\n\n return encoding\n}\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nconst ADDR_SYMBOL = Symbol.for('algokit_common:Address')\n\n/**\n * Represents an Algorand address\n */\nexport class Address {\n /**\n * The binary form of the address. For standard accounts, this is the public key.\n */\n public readonly publicKey: Uint8Array;\n\n /** @internal */\n [ADDR_SYMBOL]: boolean\n\n /**\n * Create a new Address object from its binary form.\n * @param publicKey - The binary form of the address. Must be 32 bytes.\n */\n constructor(publicKey: Uint8Array) {\n this[ADDR_SYMBOL] = true\n if (publicKey.length !== ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(publicKey)}, length ${publicKey.length}`)\n this.publicKey = publicKey\n }\n\n /**\n * Check if the address is equal to another address.\n */\n equals(other: Address): boolean {\n return other instanceof Address && arrayEqual(this.publicKey, other.publicKey)\n }\n\n /**\n * Compute the 4 byte checksum of the address.\n */\n checksum(): Uint8Array {\n return checksumFromPublicKey(this.publicKey)\n }\n\n /**\n * Encode the address into a string form.\n */\n toString(): string {\n const addr = base32.encode(concatArrays(this.publicKey, this.checksum()))\n return addr.slice(0, ALGORAND_ADDRESS_LENGTH) // removing the extra '===='\n }\n\n /**\n * Decode an address from a string.\n * @param address - The address to decode. Must be 58 characters long.\n * @returns An Address object corresponding to the input string.\n */\n static fromString(address: string): Address {\n if (typeof address !== 'string') throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof address}, ${address}`)\n if (address.length !== ALGORAND_ADDRESS_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${address.length}: ${address}`)\n\n // try to decode\n const decoded = base32.decode.asBytes(address)\n // Sanity check\n if (decoded.length !== ALGORAND_ADDRESS_BYTE_LENGTH)\n throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${decoded.length}`)\n\n // Find publickey and checksum\n const pk = new Uint8Array(decoded.slice(0, ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n const cs = new Uint8Array(decoded.slice(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, ALGORAND_ADDRESS_BYTE_LENGTH))\n const checksum = checksumFromPublicKey(pk)\n // Check if the checksum and the address are equal\n if (!arrayEqual(checksum, cs)) throw new Error(`${CHECKSUM_ADDRESS_ERROR_MSG}: ${address} (${cs}, ${checksum})`)\n\n return new Address(pk)\n }\n\n /**\n * Get the zero address.\n */\n static zeroAddress(): Address {\n return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH))\n }\n}\n\n// Define Symbol.hasInstance outside the class to avoid Metro/Hermes parser issues\n// with static computed property names like `static [Symbol.hasInstance]()`\n// Also must handle Babel's _classCallCheck which uses instanceof before ADDR_SYMBOL is set\nObject.defineProperty(Address, Symbol.hasInstance, {\n value: function (obj: unknown): boolean {\n // First check prototype chain (handles Babel's _classCallCheck and normal instances)\n if (obj instanceof Object && Object.getPrototypeOf(obj) === Address.prototype) {\n return true\n }\n // Then check for the brand symbol (handles cross-realm/serialized instances)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Boolean(obj && typeof obj === 'object' && ADDR_SYMBOL in obj && (obj as any)[ADDR_SYMBOL])\n },\n})\n\nexport interface Addressable {\n addr: Readonly<Address>\n}\n\nexport type ReadableAddress = Addressable | Address | string\n\nexport function getAddress(addr: ReadableAddress): Address {\n if (typeof addr == 'string') {\n return Address.fromString(addr)\n } else if ('addr' in addr) {\n return addr.addr\n } else {\n return addr\n }\n}\n\nexport function getOptionalAddress(addr: ReadableAddress | undefined): Address | undefined {\n if (addr === undefined) {\n return undefined\n }\n return getAddress(addr)\n}\n\n/**\n * isValidAddress checks if a string is a valid Algorand address.\n * @param address - an Algorand address with checksum.\n * @returns true if valid, false otherwise\n */\nexport function isValidAddress(address: string): boolean {\n // Try to decode\n try {\n Address.fromString(address)\n } catch {\n return false\n }\n return true\n}\n\nconst APP_ID_PREFIX = new TextEncoder().encode('appID')\n\n/**\n * Get the escrow address of an application.\n * @param appID - The ID of the application.\n * @returns The address corresponding to that application's escrow account.\n */\nexport function getApplicationAddress(appID: number | bigint): Address {\n const toBeSigned = concatArrays(APP_ID_PREFIX, encodeUint64(appID))\n const hash = genericHash(toBeSigned)\n return new Address(Uint8Array.from(hash))\n}\n\n/**\n * decodeAddress takes an Algorand address in string form and decodes it into a Uint8Array.\n * @param address - an Algorand address with checksum.\n * @returns the decoded form of the address's public key and checksum\n */\nexport function decodeAddress(address: string): Address {\n return Address.fromString(address)\n}\n\n/**\n * encodeAddress takes an Algorand address as a Uint8Array and encodes it into a string with checksum.\n * @param address - a raw Algorand address\n * @returns the address and checksum encoded as a string.\n */\nexport function encodeAddress(address: Uint8Array): string {\n return new Address(address).toString()\n}\n"],"mappings":";;;;;;AAKA,MAAa,+BAA+B;AAC5C,MAAa,gCAAgC;AAC7C,MAAa,0BAA0B;AACvC,MAAa,+BAA+B;AAE5C,MAAa,8BAA8B;AAC3C,MAAa,6BAA6B;AAE1C,SAAgB,sBAAsB,WAAmC;AACvE,QAAO,WAAW,KAAK,OAAO,WAAW,MAAM,UAAU,CAAC,MAAM,oBAAoB,sBAAsB,kBAAkB,CAAC;;AAG/H,SAAS,YAAY,KAAqB;AACxC,QAAO,OAAO,WAAW,MAAM,IAAI;;AAGrC,SAAS,WAAW,OAA2B;AAC7C,QAAO,OAAO,KAAK,MAAM,CAAC,SAAS,MAAM;;AAG3C,SAAgB,aAAa,KAAsB;AAGjD,KAAI,EAFc,OAAO,QAAQ,YAAY,OAAO,UAAU,IAAI,KAEhD,MAAM,KAAK,MAAM,OAAO,qBAAqB,CAC7D,OAAM,IAAI,MAAM,yCAAyC;CAG3D,MAAM,WAAW,IAAI,WAAW,EAAE;AAElC,CADa,IAAI,SAAS,SAAS,OAAO,CACrC,aAAa,GAAG,OAAO,IAAI,CAAC;AAEjC,QAAO;;;AAIT,MAAM,cAAc,OAAO,IAAI,yBAAyB;;;;AAKxD,IAAa,UAAb,MAAa,QAAQ;;;;CAInB,AAAgB;;CAGhB,CAAC;;;;;CAMD,YAAY,WAAuB;AACjC,OAAK,eAAe;AACpB,MAAI,UAAU,WAAW,+BAA+B,8BACtD,OAAM,IAAI,MAAM,GAAG,4BAA4B,MAAM,WAAW,UAAU,CAAC,WAAW,UAAU,SAAS;AAC3G,OAAK,YAAY;;;;;CAMnB,OAAO,OAAyB;AAC9B,SAAO,iBAAiB,WAAW,WAAW,KAAK,WAAW,MAAM,UAAU;;;;;CAMhF,WAAuB;AACrB,SAAO,sBAAsB,KAAK,UAAU;;;;;CAM9C,WAAmB;AAEjB,SADa,OAAO,OAAO,aAAa,KAAK,WAAW,KAAK,UAAU,CAAC,CAAC,CAC7D,MAAM,GAAG,wBAAwB;;;;;;;CAQ/C,OAAO,WAAW,SAA0B;AAC1C,MAAI,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,GAAG,4BAA4B,yBAAyB,OAAO,QAAQ,IAAI,UAAU;AACtI,MAAI,QAAQ,WAAW,wBACrB,OAAM,IAAI,MAAM,GAAG,4BAA4B,oBAAoB,wBAAwB,QAAQ,QAAQ,OAAO,IAAI,UAAU;EAGlI,MAAM,UAAU,OAAO,OAAO,QAAQ,QAAQ;AAE9C,MAAI,QAAQ,WAAW,6BACrB,OAAM,IAAI,MAAM,GAAG,4BAA4B,yBAAyB,6BAA6B,QAAQ,QAAQ,SAAS;EAGhI,MAAM,KAAK,IAAI,WAAW,QAAQ,MAAM,GAAG,+BAA+B,8BAA8B,CAAC;EACzG,MAAM,KAAK,IAAI,WAAW,QAAQ,MAAM,+BAA+B,+BAA+B,6BAA6B,CAAC;EACpI,MAAM,WAAW,sBAAsB,GAAG;AAE1C,MAAI,CAAC,WAAW,UAAU,GAAG,CAAE,OAAM,IAAI,MAAM,GAAG,2BAA2B,IAAI,QAAQ,IAAI,GAAG,IAAI,SAAS,GAAG;AAEhH,SAAO,IAAI,QAAQ,GAAG;;;;;CAMxB,OAAO,cAAuB;AAC5B,SAAO,IAAI,QAAQ,IAAI,WAAW,+BAA+B,8BAA8B,CAAC;;;AAOpG,OAAO,eAAe,SAAS,OAAO,aAAa,EACjD,OAAO,SAAU,KAAuB;AAEtC,KAAI,eAAe,UAAU,OAAO,eAAe,IAAI,KAAK,QAAQ,UAClE,QAAO;AAIT,QAAO,QAAQ,OAAO,OAAO,QAAQ,YAAY,eAAe,OAAQ,IAAY,aAAa;GAEpG,CAAC;AAQF,SAAgB,WAAW,MAAgC;AACzD,KAAI,OAAO,QAAQ,SACjB,QAAO,QAAQ,WAAW,KAAK;UACtB,UAAU,KACnB,QAAO,KAAK;KAEZ,QAAO;;AAIX,SAAgB,mBAAmB,MAAwD;AACzF,KAAI,SAAS,OACX;AAEF,QAAO,WAAW,KAAK;;AAkBzB,MAAM,gBAAgB,IAAI,aAAa,CAAC,OAAO,QAAQ;;;;;;AAOvD,SAAgB,sBAAsB,OAAiC;CAErE,MAAM,OAAO,YADM,aAAa,eAAe,aAAa,MAAM,CAAC,CAC/B;AACpC,QAAO,IAAI,QAAQ,WAAW,KAAK,KAAK,CAAC;;;;;;;AAQ3C,SAAgB,cAAc,SAA0B;AACtD,QAAO,QAAQ,WAAW,QAAQ;;;;;;;AAQpC,SAAgB,cAAc,SAA6B;AACzD,QAAO,IAAI,QAAQ,QAAQ,CAAC,UAAU"}
|
|
@@ -4,8 +4,9 @@ const require_codec = require('../codec.js');
|
|
|
4
4
|
/**
|
|
5
5
|
* Map codec - handles Maps with any key type (including Uint8Array, bigint, number)
|
|
6
6
|
* Depending on the encoding format, the map is encoded differently:
|
|
7
|
-
* - json:
|
|
8
|
-
*
|
|
7
|
+
* - json: Supports string and bigint keys. The map is represented as an object when encoding.
|
|
8
|
+
* Bigint keys are converted to/from strings (e.g., 1n becomes "1").
|
|
9
|
+
* An exception is thrown upon encountering an unsupported key type.
|
|
9
10
|
* - msgpack: Preserves key types and is represented as a Map when encoding.
|
|
10
11
|
*/
|
|
11
12
|
var MapCodec = class extends require_codec.Codec {
|
|
@@ -22,7 +23,7 @@ var MapCodec = class extends require_codec.Codec {
|
|
|
22
23
|
}
|
|
23
24
|
ensureKeyIsSupported(format) {
|
|
24
25
|
if (format === "msgpack") return true;
|
|
25
|
-
if (this.keyType !== "string") throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`);
|
|
26
|
+
if (this.keyType !== "string" && this.keyType !== "bigint") throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`);
|
|
26
27
|
}
|
|
27
28
|
toEncoded(value, format) {
|
|
28
29
|
this.ensureKeyIsSupported(format);
|
|
@@ -49,7 +50,9 @@ var MapCodec = class extends require_codec.Codec {
|
|
|
49
50
|
if (value instanceof Map) entries = Array.from(value.entries());
|
|
50
51
|
else entries = Object.entries(value);
|
|
51
52
|
for (const [encodedKey, encodedValue] of entries) {
|
|
52
|
-
|
|
53
|
+
let keyToDecode = encodedKey;
|
|
54
|
+
if (format === "json" && this.keyType === "bigint" && typeof encodedKey === "string") keyToDecode = BigInt(encodedKey);
|
|
55
|
+
const key = this.keyCodec.decode(keyToDecode, format);
|
|
53
56
|
const val = this.valueCodec.decode(encodedValue, format);
|
|
54
57
|
result.set(key, val);
|
|
55
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","names":["Codec","keyCodec: Codec<K, KEncoded>","valueCodec: Codec<V, VEncoded>","entries: Array<[KEncoded, VEncoded]>","obj: Record<string, VEncoded>"],"sources":["../../../../../../packages/common/src/codecs/composite/map.ts"],"sourcesContent":["import { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\n\n/**\n * Map codec - handles Maps with any key type (including Uint8Array, bigint, number)\n * Depending on the encoding format, the map is encoded differently:\n * - json:
|
|
1
|
+
{"version":3,"file":"map.js","names":["Codec","keyCodec: Codec<K, KEncoded>","valueCodec: Codec<V, VEncoded>","entries: Array<[KEncoded, VEncoded]>","obj: Record<string, VEncoded>"],"sources":["../../../../../../packages/common/src/codecs/composite/map.ts"],"sourcesContent":["import { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\n\n/**\n * Map codec - handles Maps with any key type (including Uint8Array, bigint, number)\n * Depending on the encoding format, the map is encoded differently:\n * - json: Supports string and bigint keys. The map is represented as an object when encoding.\n * Bigint keys are converted to/from strings (e.g., 1n becomes \"1\").\n * An exception is thrown upon encountering an unsupported key type.\n * - msgpack: Preserves key types and is represented as a Map when encoding.\n */\nexport class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>, Map<KEncoded, VEncoded> | Record<string, VEncoded>> {\n private keyType: string\n\n constructor(\n private readonly keyCodec: Codec<K, KEncoded>,\n private readonly valueCodec: Codec<V, VEncoded>,\n ) {\n super()\n const defaultKeyValue = this.keyCodec.defaultValue()\n this.keyType = defaultKeyValue instanceof Uint8Array ? 'Uint8Array' : typeof defaultKeyValue\n }\n\n public defaultValue(): Map<K, V> {\n return new Map()\n }\n\n private ensureKeyIsSupported(format: EncodingFormat) {\n if (format === 'msgpack') {\n return true\n }\n if (this.keyType !== 'string' && this.keyType !== 'bigint') {\n throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`)\n }\n }\n\n protected toEncoded(value: Map<K, V>, format: EncodingFormat): Map<KEncoded, VEncoded> | Record<string, VEncoded> {\n this.ensureKeyIsSupported(format)\n\n const entries: Array<[KEncoded, VEncoded]> = []\n\n for (const [k, v] of value.entries()) {\n const encodedKey = this.keyCodec.encode(k, format)\n const encodedValue = this.valueCodec.encode(v, format)\n entries.push([encodedKey, encodedValue])\n }\n if (format === 'json') {\n const obj: Record<string, VEncoded> = {}\n for (const [k, v] of entries) {\n const keyStr = typeof k === 'string' ? k : String(k)\n obj[keyStr] = v\n }\n return obj\n }\n\n return new Map(entries)\n }\n\n protected fromEncoded(value: Map<KEncoded, VEncoded> | Record<string, VEncoded>, format: EncodingFormat): Map<K, V> {\n this.ensureKeyIsSupported(format)\n\n const result = new Map<K, V>()\n\n let entries: Array<[KEncoded, VEncoded]>\n if (value instanceof Map) {\n entries = Array.from(value.entries())\n } else {\n entries = Object.entries(value) as Array<[KEncoded, VEncoded]>\n }\n\n for (const [encodedKey, encodedValue] of entries) {\n let keyToDecode = encodedKey as KEncoded\n if (format === 'json' && this.keyType === 'bigint' && typeof encodedKey === 'string') {\n keyToDecode = BigInt(encodedKey) as KEncoded\n }\n const key = this.keyCodec.decode(keyToDecode, format)\n const val = this.valueCodec.decode(encodedValue, format)\n result.set(key, val)\n }\n\n return result\n }\n\n public isDefaultValue(value: Map<K, V>): boolean {\n return value.size === 0\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,WAAb,cAAgEA,oBAAqE;CACnI,AAAQ;CAER,YACE,AAAiBC,UACjB,AAAiBC,YACjB;AACA,SAAO;EAHU;EACA;EAGjB,MAAM,kBAAkB,KAAK,SAAS,cAAc;AACpD,OAAK,UAAU,2BAA2B,aAAa,eAAe,OAAO;;CAG/E,AAAO,eAA0B;AAC/B,yBAAO,IAAI,KAAK;;CAGlB,AAAQ,qBAAqB,QAAwB;AACnD,MAAI,WAAW,UACb,QAAO;AAET,MAAI,KAAK,YAAY,YAAY,KAAK,YAAY,SAChD,OAAM,IAAI,MAAM,oBAAoB,KAAK,QAAQ,wBAAwB,OAAO,SAAS;;CAI7F,AAAU,UAAU,OAAkB,QAA4E;AAChH,OAAK,qBAAqB,OAAO;EAEjC,MAAMC,UAAuC,EAAE;AAE/C,OAAK,MAAM,CAAC,GAAG,MAAM,MAAM,SAAS,EAAE;GACpC,MAAM,aAAa,KAAK,SAAS,OAAO,GAAG,OAAO;GAClD,MAAM,eAAe,KAAK,WAAW,OAAO,GAAG,OAAO;AACtD,WAAQ,KAAK,CAAC,YAAY,aAAa,CAAC;;AAE1C,MAAI,WAAW,QAAQ;GACrB,MAAMC,MAAgC,EAAE;AACxC,QAAK,MAAM,CAAC,GAAG,MAAM,SAAS;IAC5B,MAAM,SAAS,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE;AACpD,QAAI,UAAU;;AAEhB,UAAO;;AAGT,SAAO,IAAI,IAAI,QAAQ;;CAGzB,AAAU,YAAY,OAA2D,QAAmC;AAClH,OAAK,qBAAqB,OAAO;EAEjC,MAAM,yBAAS,IAAI,KAAW;EAE9B,IAAID;AACJ,MAAI,iBAAiB,IACnB,WAAU,MAAM,KAAK,MAAM,SAAS,CAAC;MAErC,WAAU,OAAO,QAAQ,MAAM;AAGjC,OAAK,MAAM,CAAC,YAAY,iBAAiB,SAAS;GAChD,IAAI,cAAc;AAClB,OAAI,WAAW,UAAU,KAAK,YAAY,YAAY,OAAO,eAAe,SAC1E,eAAc,OAAO,WAAW;GAElC,MAAM,MAAM,KAAK,SAAS,OAAO,aAAa,OAAO;GACrD,MAAM,MAAM,KAAK,WAAW,OAAO,cAAc,OAAO;AACxD,UAAO,IAAI,KAAK,IAAI;;AAGtB,SAAO;;CAGT,AAAO,eAAe,OAA2B;AAC/C,SAAO,MAAM,SAAS"}
|
|
@@ -4,8 +4,9 @@ import { Codec } from "../codec.mjs";
|
|
|
4
4
|
/**
|
|
5
5
|
* Map codec - handles Maps with any key type (including Uint8Array, bigint, number)
|
|
6
6
|
* Depending on the encoding format, the map is encoded differently:
|
|
7
|
-
* - json:
|
|
8
|
-
*
|
|
7
|
+
* - json: Supports string and bigint keys. The map is represented as an object when encoding.
|
|
8
|
+
* Bigint keys are converted to/from strings (e.g., 1n becomes "1").
|
|
9
|
+
* An exception is thrown upon encountering an unsupported key type.
|
|
9
10
|
* - msgpack: Preserves key types and is represented as a Map when encoding.
|
|
10
11
|
*/
|
|
11
12
|
var MapCodec = class extends Codec {
|
|
@@ -22,7 +23,7 @@ var MapCodec = class extends Codec {
|
|
|
22
23
|
}
|
|
23
24
|
ensureKeyIsSupported(format) {
|
|
24
25
|
if (format === "msgpack") return true;
|
|
25
|
-
if (this.keyType !== "string") throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`);
|
|
26
|
+
if (this.keyType !== "string" && this.keyType !== "bigint") throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`);
|
|
26
27
|
}
|
|
27
28
|
toEncoded(value, format) {
|
|
28
29
|
this.ensureKeyIsSupported(format);
|
|
@@ -49,7 +50,9 @@ var MapCodec = class extends Codec {
|
|
|
49
50
|
if (value instanceof Map) entries = Array.from(value.entries());
|
|
50
51
|
else entries = Object.entries(value);
|
|
51
52
|
for (const [encodedKey, encodedValue] of entries) {
|
|
52
|
-
|
|
53
|
+
let keyToDecode = encodedKey;
|
|
54
|
+
if (format === "json" && this.keyType === "bigint" && typeof encodedKey === "string") keyToDecode = BigInt(encodedKey);
|
|
55
|
+
const key = this.keyCodec.decode(keyToDecode, format);
|
|
53
56
|
const val = this.valueCodec.decode(encodedValue, format);
|
|
54
57
|
result.set(key, val);
|
|
55
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.mjs","names":["keyCodec: Codec<K, KEncoded>","valueCodec: Codec<V, VEncoded>","entries: Array<[KEncoded, VEncoded]>","obj: Record<string, VEncoded>"],"sources":["../../../../../../packages/common/src/codecs/composite/map.ts"],"sourcesContent":["import { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\n\n/**\n * Map codec - handles Maps with any key type (including Uint8Array, bigint, number)\n * Depending on the encoding format, the map is encoded differently:\n * - json:
|
|
1
|
+
{"version":3,"file":"map.mjs","names":["keyCodec: Codec<K, KEncoded>","valueCodec: Codec<V, VEncoded>","entries: Array<[KEncoded, VEncoded]>","obj: Record<string, VEncoded>"],"sources":["../../../../../../packages/common/src/codecs/composite/map.ts"],"sourcesContent":["import { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\n\n/**\n * Map codec - handles Maps with any key type (including Uint8Array, bigint, number)\n * Depending on the encoding format, the map is encoded differently:\n * - json: Supports string and bigint keys. The map is represented as an object when encoding.\n * Bigint keys are converted to/from strings (e.g., 1n becomes \"1\").\n * An exception is thrown upon encountering an unsupported key type.\n * - msgpack: Preserves key types and is represented as a Map when encoding.\n */\nexport class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>, Map<KEncoded, VEncoded> | Record<string, VEncoded>> {\n private keyType: string\n\n constructor(\n private readonly keyCodec: Codec<K, KEncoded>,\n private readonly valueCodec: Codec<V, VEncoded>,\n ) {\n super()\n const defaultKeyValue = this.keyCodec.defaultValue()\n this.keyType = defaultKeyValue instanceof Uint8Array ? 'Uint8Array' : typeof defaultKeyValue\n }\n\n public defaultValue(): Map<K, V> {\n return new Map()\n }\n\n private ensureKeyIsSupported(format: EncodingFormat) {\n if (format === 'msgpack') {\n return true\n }\n if (this.keyType !== 'string' && this.keyType !== 'bigint') {\n throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`)\n }\n }\n\n protected toEncoded(value: Map<K, V>, format: EncodingFormat): Map<KEncoded, VEncoded> | Record<string, VEncoded> {\n this.ensureKeyIsSupported(format)\n\n const entries: Array<[KEncoded, VEncoded]> = []\n\n for (const [k, v] of value.entries()) {\n const encodedKey = this.keyCodec.encode(k, format)\n const encodedValue = this.valueCodec.encode(v, format)\n entries.push([encodedKey, encodedValue])\n }\n if (format === 'json') {\n const obj: Record<string, VEncoded> = {}\n for (const [k, v] of entries) {\n const keyStr = typeof k === 'string' ? k : String(k)\n obj[keyStr] = v\n }\n return obj\n }\n\n return new Map(entries)\n }\n\n protected fromEncoded(value: Map<KEncoded, VEncoded> | Record<string, VEncoded>, format: EncodingFormat): Map<K, V> {\n this.ensureKeyIsSupported(format)\n\n const result = new Map<K, V>()\n\n let entries: Array<[KEncoded, VEncoded]>\n if (value instanceof Map) {\n entries = Array.from(value.entries())\n } else {\n entries = Object.entries(value) as Array<[KEncoded, VEncoded]>\n }\n\n for (const [encodedKey, encodedValue] of entries) {\n let keyToDecode = encodedKey as KEncoded\n if (format === 'json' && this.keyType === 'bigint' && typeof encodedKey === 'string') {\n keyToDecode = BigInt(encodedKey) as KEncoded\n }\n const key = this.keyCodec.decode(keyToDecode, format)\n const val = this.valueCodec.decode(encodedValue, format)\n result.set(key, val)\n }\n\n return result\n }\n\n public isDefaultValue(value: Map<K, V>): boolean {\n return value.size === 0\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,WAAb,cAAgE,MAAqE;CACnI,AAAQ;CAER,YACE,AAAiBA,UACjB,AAAiBC,YACjB;AACA,SAAO;EAHU;EACA;EAGjB,MAAM,kBAAkB,KAAK,SAAS,cAAc;AACpD,OAAK,UAAU,2BAA2B,aAAa,eAAe,OAAO;;CAG/E,AAAO,eAA0B;AAC/B,yBAAO,IAAI,KAAK;;CAGlB,AAAQ,qBAAqB,QAAwB;AACnD,MAAI,WAAW,UACb,QAAO;AAET,MAAI,KAAK,YAAY,YAAY,KAAK,YAAY,SAChD,OAAM,IAAI,MAAM,oBAAoB,KAAK,QAAQ,wBAAwB,OAAO,SAAS;;CAI7F,AAAU,UAAU,OAAkB,QAA4E;AAChH,OAAK,qBAAqB,OAAO;EAEjC,MAAMC,UAAuC,EAAE;AAE/C,OAAK,MAAM,CAAC,GAAG,MAAM,MAAM,SAAS,EAAE;GACpC,MAAM,aAAa,KAAK,SAAS,OAAO,GAAG,OAAO;GAClD,MAAM,eAAe,KAAK,WAAW,OAAO,GAAG,OAAO;AACtD,WAAQ,KAAK,CAAC,YAAY,aAAa,CAAC;;AAE1C,MAAI,WAAW,QAAQ;GACrB,MAAMC,MAAgC,EAAE;AACxC,QAAK,MAAM,CAAC,GAAG,MAAM,SAAS;IAC5B,MAAM,SAAS,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE;AACpD,QAAI,UAAU;;AAEhB,UAAO;;AAGT,SAAO,IAAI,IAAI,QAAQ;;CAGzB,AAAU,YAAY,OAA2D,QAAmC;AAClH,OAAK,qBAAqB,OAAO;EAEjC,MAAM,yBAAS,IAAI,KAAW;EAE9B,IAAID;AACJ,MAAI,iBAAiB,IACnB,WAAU,MAAM,KAAK,MAAM,SAAS,CAAC;MAErC,WAAU,OAAO,QAAQ,MAAM;AAGjC,OAAK,MAAM,CAAC,YAAY,iBAAiB,SAAS;GAChD,IAAI,cAAc;AAClB,OAAI,WAAW,UAAU,KAAK,YAAY,YAAY,OAAO,eAAe,SAC1E,eAAc,OAAO,WAAW;GAElC,MAAM,MAAM,KAAK,SAAS,OAAO,aAAa,OAAO;GACrD,MAAM,MAAM,KAAK,WAAW,OAAO,cAAc,OAAO;AACxD,UAAO,IAAI,KAAK,IAAI;;AAGtB,SAAO;;CAGT,AAAO,eAAe,OAA2B;AAC/C,SAAO,MAAM,SAAS"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_codec = require('../codec.js');
|
|
3
3
|
let buffer = require("buffer");
|
|
4
|
-
buffer = require_rolldown_runtime.__toESM(buffer);
|
|
5
4
|
|
|
6
5
|
//#region packages/common/src/codecs/composite/record.ts
|
|
7
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","names":["Codec","valueCodec: Codec<V, VEncoded>","result: Record<string, VEncoded>","result: Record<string, V>","Buffer"],"sources":["../../../../../../packages/common/src/codecs/composite/record.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireObject } from '../wire'\n\n/**\n * Record codec - for string-keyed objects with homogeneous values\n */\nexport class RecordCodec<V, VEncoded = V> extends Codec<Record<string, V>, Record<string, VEncoded>, WireObject<VEncoded>> {\n constructor(private readonly valueCodec: Codec<V, VEncoded>) {\n super()\n }\n\n public defaultValue(): Record<string, V> {\n return {}\n }\n\n protected toEncoded(value: Record<string, V>, format: EncodingFormat): Record<string, VEncoded> {\n const result: Record<string, VEncoded> = {}\n\n for (const [key, val] of Object.entries(value)) {\n const encoded = this.valueCodec.encode(val, format)\n result[key] = encoded\n }\n\n return result\n }\n\n protected fromEncoded(value: WireObject<VEncoded>, format: EncodingFormat): Record<string, V> {\n const result: Record<string, V> = {}\n if (value instanceof Map) {\n for (const [_key, val] of value.entries()) {\n const keyType = typeof _key\n if (keyType === 'number' || keyType === 'bigint') {\n throw new Error(`RecordCodec received a non-string key of type ${keyType}`)\n }\n const key = _key instanceof Uint8Array ? Buffer.from(_key).toString('utf-8') : String(_key)\n result[key] = this.valueCodec.decode(val, format)\n }\n } else {\n for (const [key, val] of Object.entries(value)) {\n result[key] = this.valueCodec.decode(val, format)\n }\n }\n\n return result\n }\n\n public isDefaultValue(value: Record<string, V>): boolean {\n return Object.keys(value).length === 0\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.js","names":["Codec","valueCodec: Codec<V, VEncoded>","result: Record<string, VEncoded>","result: Record<string, V>","Buffer"],"sources":["../../../../../../packages/common/src/codecs/composite/record.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireObject } from '../wire'\n\n/**\n * Record codec - for string-keyed objects with homogeneous values\n */\nexport class RecordCodec<V, VEncoded = V> extends Codec<Record<string, V>, Record<string, VEncoded>, WireObject<VEncoded>> {\n constructor(private readonly valueCodec: Codec<V, VEncoded>) {\n super()\n }\n\n public defaultValue(): Record<string, V> {\n return {}\n }\n\n protected toEncoded(value: Record<string, V>, format: EncodingFormat): Record<string, VEncoded> {\n const result: Record<string, VEncoded> = {}\n\n for (const [key, val] of Object.entries(value)) {\n const encoded = this.valueCodec.encode(val, format)\n result[key] = encoded\n }\n\n return result\n }\n\n protected fromEncoded(value: WireObject<VEncoded>, format: EncodingFormat): Record<string, V> {\n const result: Record<string, V> = {}\n if (value instanceof Map) {\n for (const [_key, val] of value.entries()) {\n const keyType = typeof _key\n if (keyType === 'number' || keyType === 'bigint') {\n throw new Error(`RecordCodec received a non-string key of type ${keyType}`)\n }\n const key = _key instanceof Uint8Array ? Buffer.from(_key).toString('utf-8') : String(_key)\n result[key] = this.valueCodec.decode(val, format)\n }\n } else {\n for (const [key, val] of Object.entries(value)) {\n result[key] = this.valueCodec.decode(val, format)\n }\n }\n\n return result\n }\n\n public isDefaultValue(value: Record<string, V>): boolean {\n return Object.keys(value).length === 0\n }\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,cAAb,cAAkDA,oBAAyE;CACzH,YAAY,AAAiBC,YAAgC;AAC3D,SAAO;EADoB;;CAI7B,AAAO,eAAkC;AACvC,SAAO,EAAE;;CAGX,AAAU,UAAU,OAA0B,QAAkD;EAC9F,MAAMC,SAAmC,EAAE;AAE3C,OAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,MAAM,CAE5C,QAAO,OADS,KAAK,WAAW,OAAO,KAAK,OAAO;AAIrD,SAAO;;CAGT,AAAU,YAAY,OAA6B,QAA2C;EAC5F,MAAMC,SAA4B,EAAE;AACpC,MAAI,iBAAiB,IACnB,MAAK,MAAM,CAAC,MAAM,QAAQ,MAAM,SAAS,EAAE;GACzC,MAAM,UAAU,OAAO;AACvB,OAAI,YAAY,YAAY,YAAY,SACtC,OAAM,IAAI,MAAM,iDAAiD,UAAU;GAE7E,MAAM,MAAM,gBAAgB,aAAaC,cAAO,KAAK,KAAK,CAAC,SAAS,QAAQ,GAAG,OAAO,KAAK;AAC3F,UAAO,OAAO,KAAK,WAAW,OAAO,KAAK,OAAO;;MAGnD,MAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,MAAM,CAC5C,QAAO,OAAO,KAAK,WAAW,OAAO,KAAK,OAAO;AAIrD,SAAO;;CAGT,AAAO,eAAe,OAAmC;AACvD,SAAO,OAAO,KAAK,MAAM,CAAC,WAAW"}
|
|
@@ -3,7 +3,6 @@ const require_constants = require('../../constants.js');
|
|
|
3
3
|
const require_address = require('../../address.js');
|
|
4
4
|
const require_codec = require('../codec.js');
|
|
5
5
|
let buffer = require("buffer");
|
|
6
|
-
buffer = require_rolldown_runtime.__toESM(buffer);
|
|
7
6
|
|
|
8
7
|
//#region packages/common/src/codecs/primitives/address.ts
|
|
9
8
|
var AddressCodec = class extends require_codec.Codec {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","names":["Codec","Address","PUBLIC_KEY_BYTE_LENGTH","ADDRESS_LENGTH","Buffer"],"sources":["../../../../../../packages/common/src/codecs/primitives/address.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Address } from '../../address'\nimport { ADDRESS_LENGTH, PUBLIC_KEY_BYTE_LENGTH } from '../../constants'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\nclass AddressCodec extends Codec<Address, WireString> {\n public defaultValue(): Address {\n return Address.zeroAddress()\n }\n\n protected toEncoded(value: Address, format: EncodingFormat): WireString {\n if (format === 'json') {\n return value.toString()\n }\n return value.publicKey\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Address {\n if (typeof value === 'string') return Address.fromString(value)\n if (value instanceof Uint8Array) {\n if (value.length === PUBLIC_KEY_BYTE_LENGTH) {\n return new Address(value)\n } else if (value.length === ADDRESS_LENGTH) {\n return Address.fromString(Buffer.from(value).toString('utf-8'))\n }\n }\n throw new Error(`AddressCodec cannot decode address from ${typeof value}`)\n }\n\n public isDefaultValue(value: Address): boolean {\n return value.equals(this.defaultValue())\n }\n}\n\nexport const addressCodec = new AddressCodec()\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"address.js","names":["Codec","Address","PUBLIC_KEY_BYTE_LENGTH","ADDRESS_LENGTH","Buffer"],"sources":["../../../../../../packages/common/src/codecs/primitives/address.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Address } from '../../address'\nimport { ADDRESS_LENGTH, PUBLIC_KEY_BYTE_LENGTH } from '../../constants'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\nclass AddressCodec extends Codec<Address, WireString> {\n public defaultValue(): Address {\n return Address.zeroAddress()\n }\n\n protected toEncoded(value: Address, format: EncodingFormat): WireString {\n if (format === 'json') {\n return value.toString()\n }\n return value.publicKey\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Address {\n if (typeof value === 'string') return Address.fromString(value)\n if (value instanceof Uint8Array) {\n if (value.length === PUBLIC_KEY_BYTE_LENGTH) {\n return new Address(value)\n } else if (value.length === ADDRESS_LENGTH) {\n return Address.fromString(Buffer.from(value).toString('utf-8'))\n }\n }\n throw new Error(`AddressCodec cannot decode address from ${typeof value}`)\n }\n\n public isDefaultValue(value: Address): boolean {\n return value.equals(this.defaultValue())\n }\n}\n\nexport const addressCodec = new AddressCodec()\n"],"mappings":";;;;;;;AAOA,IAAM,eAAN,cAA2BA,oBAA2B;CACpD,AAAO,eAAwB;AAC7B,SAAOC,wBAAQ,aAAa;;CAG9B,AAAU,UAAU,OAAgB,QAAoC;AACtE,MAAI,WAAW,OACb,QAAO,MAAM,UAAU;AAEzB,SAAO,MAAM;;CAGf,AAAU,YAAY,OAAmB,SAAkC;AACzE,MAAI,OAAO,UAAU,SAAU,QAAOA,wBAAQ,WAAW,MAAM;AAC/D,MAAI,iBAAiB,YACnB;OAAI,MAAM,WAAWC,yCACnB,QAAO,IAAID,wBAAQ,MAAM;YAChB,MAAM,WAAWE,iCAC1B,QAAOF,wBAAQ,WAAWG,cAAO,KAAK,MAAM,CAAC,SAAS,QAAQ,CAAC;;AAGnE,QAAM,IAAI,MAAM,2CAA2C,OAAO,QAAQ;;CAG5E,AAAO,eAAe,OAAyB;AAC7C,SAAO,MAAM,OAAO,KAAK,cAAc,CAAC;;;AAI5C,MAAa,eAAe,IAAI,cAAc"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_codec = require('../codec.js');
|
|
3
|
+
let buffer = require("buffer");
|
|
4
|
+
|
|
5
|
+
//#region packages/common/src/codecs/primitives/bytes-base64.ts
|
|
6
|
+
var BytesBase64Codec = class extends require_codec.Codec {
|
|
7
|
+
defaultValue() {
|
|
8
|
+
return new Uint8Array();
|
|
9
|
+
}
|
|
10
|
+
toEncoded(value, _format) {
|
|
11
|
+
return buffer.Buffer.from(value).toString("base64");
|
|
12
|
+
}
|
|
13
|
+
fromEncoded(value, _format) {
|
|
14
|
+
if (value instanceof Uint8Array) return new Uint8Array(buffer.Buffer.from(buffer.Buffer.from(value).toString("utf-8"), "base64"));
|
|
15
|
+
if (typeof value === "string") return new Uint8Array(buffer.Buffer.from(value, "base64"));
|
|
16
|
+
throw new Error(`Cannot decode bytes from ${typeof value}`);
|
|
17
|
+
}
|
|
18
|
+
isDefaultValue(value) {
|
|
19
|
+
return value.byteLength === 0;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const bytesBase64Codec = new BytesBase64Codec();
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.bytesBase64Codec = bytesBase64Codec;
|
|
26
|
+
//# sourceMappingURL=bytes-base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes-base64.js","names":["Codec","Buffer"],"sources":["../../../../../../packages/common/src/codecs/primitives/bytes-base64.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\n// Some fields in the msgpack encoded models are base64 encoded strings representing bytes values.\n// This is a deviation from the general pattern of using raw byte arrays for bytes fields in the wire format.\n// This codec explicitly handles encoding/decoding of base64 string encoded bytes fields.\nclass BytesBase64Codec extends Codec<Uint8Array, WireString> {\n public defaultValue(): Uint8Array {\n return new Uint8Array()\n }\n\n protected toEncoded(value: Uint8Array, _format: EncodingFormat): WireString {\n return Buffer.from(value).toString('base64')\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Uint8Array {\n if (value instanceof Uint8Array) {\n return new Uint8Array(Buffer.from(Buffer.from(value).toString('utf-8'), 'base64'))\n }\n if (typeof value === 'string') {\n return new Uint8Array(Buffer.from(value, 'base64'))\n }\n throw new Error(`Cannot decode bytes from ${typeof value}`)\n }\n\n public isDefaultValue(value: Uint8Array): boolean {\n return value.byteLength === 0\n }\n}\n\nexport const bytesBase64Codec = new BytesBase64Codec()\n"],"mappings":";;;;;AAQA,IAAM,mBAAN,cAA+BA,oBAA8B;CAC3D,AAAO,eAA2B;AAChC,SAAO,IAAI,YAAY;;CAGzB,AAAU,UAAU,OAAmB,SAAqC;AAC1E,SAAOC,cAAO,KAAK,MAAM,CAAC,SAAS,SAAS;;CAG9C,AAAU,YAAY,OAAmB,SAAqC;AAC5E,MAAI,iBAAiB,WACnB,QAAO,IAAI,WAAWA,cAAO,KAAKA,cAAO,KAAK,MAAM,CAAC,SAAS,QAAQ,EAAE,SAAS,CAAC;AAEpF,MAAI,OAAO,UAAU,SACnB,QAAO,IAAI,WAAWA,cAAO,KAAK,OAAO,SAAS,CAAC;AAErD,QAAM,IAAI,MAAM,4BAA4B,OAAO,QAAQ;;CAG7D,AAAO,eAAe,OAA4B;AAChD,SAAO,MAAM,eAAe;;;AAIhC,MAAa,mBAAmB,IAAI,kBAAkB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Codec } from "../codec.mjs";
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
|
|
4
|
+
//#region packages/common/src/codecs/primitives/bytes-base64.ts
|
|
5
|
+
var BytesBase64Codec = class extends Codec {
|
|
6
|
+
defaultValue() {
|
|
7
|
+
return new Uint8Array();
|
|
8
|
+
}
|
|
9
|
+
toEncoded(value, _format) {
|
|
10
|
+
return Buffer.from(value).toString("base64");
|
|
11
|
+
}
|
|
12
|
+
fromEncoded(value, _format) {
|
|
13
|
+
if (value instanceof Uint8Array) return new Uint8Array(Buffer.from(Buffer.from(value).toString("utf-8"), "base64"));
|
|
14
|
+
if (typeof value === "string") return new Uint8Array(Buffer.from(value, "base64"));
|
|
15
|
+
throw new Error(`Cannot decode bytes from ${typeof value}`);
|
|
16
|
+
}
|
|
17
|
+
isDefaultValue(value) {
|
|
18
|
+
return value.byteLength === 0;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const bytesBase64Codec = new BytesBase64Codec();
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { bytesBase64Codec };
|
|
25
|
+
//# sourceMappingURL=bytes-base64.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes-base64.mjs","names":[],"sources":["../../../../../../packages/common/src/codecs/primitives/bytes-base64.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\n// Some fields in the msgpack encoded models are base64 encoded strings representing bytes values.\n// This is a deviation from the general pattern of using raw byte arrays for bytes fields in the wire format.\n// This codec explicitly handles encoding/decoding of base64 string encoded bytes fields.\nclass BytesBase64Codec extends Codec<Uint8Array, WireString> {\n public defaultValue(): Uint8Array {\n return new Uint8Array()\n }\n\n protected toEncoded(value: Uint8Array, _format: EncodingFormat): WireString {\n return Buffer.from(value).toString('base64')\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Uint8Array {\n if (value instanceof Uint8Array) {\n return new Uint8Array(Buffer.from(Buffer.from(value).toString('utf-8'), 'base64'))\n }\n if (typeof value === 'string') {\n return new Uint8Array(Buffer.from(value, 'base64'))\n }\n throw new Error(`Cannot decode bytes from ${typeof value}`)\n }\n\n public isDefaultValue(value: Uint8Array): boolean {\n return value.byteLength === 0\n }\n}\n\nexport const bytesBase64Codec = new BytesBase64Codec()\n"],"mappings":";;;;AAQA,IAAM,mBAAN,cAA+B,MAA8B;CAC3D,AAAO,eAA2B;AAChC,SAAO,IAAI,YAAY;;CAGzB,AAAU,UAAU,OAAmB,SAAqC;AAC1E,SAAO,OAAO,KAAK,MAAM,CAAC,SAAS,SAAS;;CAG9C,AAAU,YAAY,OAAmB,SAAqC;AAC5E,MAAI,iBAAiB,WACnB,QAAO,IAAI,WAAW,OAAO,KAAK,OAAO,KAAK,MAAM,CAAC,SAAS,QAAQ,EAAE,SAAS,CAAC;AAEpF,MAAI,OAAO,UAAU,SACnB,QAAO,IAAI,WAAW,OAAO,KAAK,OAAO,SAAS,CAAC;AAErD,QAAM,IAAI,MAAM,4BAA4B,OAAO,QAAQ;;CAG7D,AAAO,eAAe,OAA4B;AAChD,SAAO,MAAM,eAAe;;;AAIhC,MAAa,mBAAmB,IAAI,kBAAkB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_codec = require('../codec.js');
|
|
3
3
|
let buffer = require("buffer");
|
|
4
|
-
buffer = require_rolldown_runtime.__toESM(buffer);
|
|
5
4
|
|
|
6
5
|
//#region packages/common/src/codecs/primitives/bytes.ts
|
|
7
6
|
var BytesCodec = class extends require_codec.Codec {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","names":["Codec","Buffer"],"sources":["../../../../../../packages/common/src/codecs/primitives/bytes.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\nclass BytesCodec extends Codec<Uint8Array, WireString> {\n public defaultValue(): Uint8Array {\n return new Uint8Array()\n }\n\n protected toEncoded(value: Uint8Array, format: EncodingFormat): WireString {\n if (format === 'json') {\n return Buffer.from(value).toString('base64')\n }\n return value\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Uint8Array {\n if (value instanceof Uint8Array) return value\n if (typeof value === 'string') {\n return new Uint8Array(Buffer.from(value, 'base64'))\n }\n throw new Error(`Cannot decode bytes from ${typeof value}`)\n }\n\n public isDefaultValue(value: Uint8Array): boolean {\n return value.byteLength === 0\n }\n}\n\nexport const bytesCodec = new BytesCodec()\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bytes.js","names":["Codec","Buffer"],"sources":["../../../../../../packages/common/src/codecs/primitives/bytes.ts"],"sourcesContent":["import { Buffer } from 'buffer'\nimport { Codec } from '../codec'\nimport type { EncodingFormat } from '../types'\nimport { WireString } from '../wire'\n\nclass BytesCodec extends Codec<Uint8Array, WireString> {\n public defaultValue(): Uint8Array {\n return new Uint8Array()\n }\n\n protected toEncoded(value: Uint8Array, format: EncodingFormat): WireString {\n if (format === 'json') {\n return Buffer.from(value).toString('base64')\n }\n return value\n }\n\n protected fromEncoded(value: WireString, _format: EncodingFormat): Uint8Array {\n if (value instanceof Uint8Array) return value\n if (typeof value === 'string') {\n return new Uint8Array(Buffer.from(value, 'base64'))\n }\n throw new Error(`Cannot decode bytes from ${typeof value}`)\n }\n\n public isDefaultValue(value: Uint8Array): boolean {\n return value.byteLength === 0\n }\n}\n\nexport const bytesCodec = new BytesCodec()\n"],"mappings":";;;;;AAKA,IAAM,aAAN,cAAyBA,oBAA8B;CACrD,AAAO,eAA2B;AAChC,SAAO,IAAI,YAAY;;CAGzB,AAAU,UAAU,OAAmB,QAAoC;AACzE,MAAI,WAAW,OACb,QAAOC,cAAO,KAAK,MAAM,CAAC,SAAS,SAAS;AAE9C,SAAO;;CAGT,AAAU,YAAY,OAAmB,SAAqC;AAC5E,MAAI,iBAAiB,WAAY,QAAO;AACxC,MAAI,OAAO,UAAU,SACnB,QAAO,IAAI,WAAWA,cAAO,KAAK,OAAO,SAAS,CAAC;AAErD,QAAM,IAAI,MAAM,4BAA4B,OAAO,QAAQ;;CAG7D,AAAO,eAAe,OAA4B;AAChD,SAAO,MAAM,eAAe;;;AAIhC,MAAa,aAAa,IAAI,YAAY"}
|