@taquito/wallet-connect 24.3.0-beta.2 → 24.3.0-beta.3
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/dist/lib/{taquito-wallet-connect/src/taquito-wallet-connect.js → taquito-wallet-connect.js} +1 -4
- package/dist/lib/{taquito-http-utils/src/version.js → version.js} +2 -2
- package/package.json +5 -7
- package/dist/lib/taquito/src/batch/constants.js +0 -16
- package/dist/lib/taquito/src/batch/rpc-batch-provider.js +0 -327
- package/dist/lib/taquito/src/constants.js +0 -135
- package/dist/lib/taquito/src/context.js +0 -178
- package/dist/lib/taquito/src/contract/big-map.js +0 -57
- package/dist/lib/taquito/src/contract/compose.js +0 -6
- package/dist/lib/taquito/src/contract/constants.js +0 -4
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-factory.js +0 -18
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-interface.js +0 -2
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-object-param.js +0 -72
- package/dist/lib/taquito/src/contract/contract-methods/contract-on-chain-view.js +0 -111
- package/dist/lib/taquito/src/contract/contract.js +0 -158
- package/dist/lib/taquito/src/contract/errors.js +0 -140
- package/dist/lib/taquito/src/contract/index.js +0 -30
- package/dist/lib/taquito/src/contract/interface.js +0 -2
- package/dist/lib/taquito/src/contract/manager-lambda.js +0 -71
- package/dist/lib/taquito/src/contract/prepare.js +0 -231
- package/dist/lib/taquito/src/contract/rpc-contract-provider.js +0 -675
- package/dist/lib/taquito/src/contract/sapling-state-abstraction.js +0 -24
- package/dist/lib/taquito/src/contract/semantic.js +0 -43
- package/dist/lib/taquito/src/contract/view_lambda.js +0 -27
- package/dist/lib/taquito/src/errors.js +0 -42
- package/dist/lib/taquito/src/estimate/errors.js +0 -16
- package/dist/lib/taquito/src/estimate/estimate-provider-interface.js +0 -2
- package/dist/lib/taquito/src/estimate/estimate.js +0 -176
- package/dist/lib/taquito/src/estimate/index.js +0 -20
- package/dist/lib/taquito/src/estimate/rpc-estimate-provider.js +0 -640
- package/dist/lib/taquito/src/extension/extension.js +0 -2
- package/dist/lib/taquito/src/forger/composite-forger.js +0 -32
- package/dist/lib/taquito/src/forger/errors.js +0 -30
- package/dist/lib/taquito/src/forger/rpc-forger.js +0 -12
- package/dist/lib/taquito/src/forger/taquito-local-forger.js +0 -21
- package/dist/lib/taquito/src/global-constants/default-global-constants-provider.js +0 -35
- package/dist/lib/taquito/src/global-constants/errors.js +0 -30
- package/dist/lib/taquito/src/global-constants/interface-global-constants-provider.js +0 -2
- package/dist/lib/taquito/src/global-constants/noop-global-constants-provider.js +0 -10
- package/dist/lib/taquito/src/import-key.js +0 -40
- package/dist/lib/taquito/src/injector/helper.js +0 -18
- package/dist/lib/taquito/src/injector/interface.js +0 -2
- package/dist/lib/taquito/src/injector/rpc-injector.js +0 -27
- package/dist/lib/taquito/src/operations/ballot-operation.js +0 -32
- package/dist/lib/taquito/src/operations/batch-operation.js +0 -69
- package/dist/lib/taquito/src/operations/delegate-operation.js +0 -54
- package/dist/lib/taquito/src/operations/drain-delegate-operation.js +0 -31
- package/dist/lib/taquito/src/operations/errors.js +0 -133
- package/dist/lib/taquito/src/operations/failing-noop-operation.js +0 -2
- package/dist/lib/taquito/src/operations/increase-paid-storage-operation.js +0 -49
- package/dist/lib/taquito/src/operations/index.js +0 -54
- package/dist/lib/taquito/src/operations/operations.js +0 -193
- package/dist/lib/taquito/src/operations/origination-operation.js +0 -78
- package/dist/lib/taquito/src/operations/proposals-operation.js +0 -29
- package/dist/lib/taquito/src/operations/register-global-constant-operation.js +0 -52
- package/dist/lib/taquito/src/operations/reveal-operation.js +0 -74
- package/dist/lib/taquito/src/operations/smart-rollup-add-messages-operation.js +0 -44
- package/dist/lib/taquito/src/operations/smart-rollup-execute-outbox-message-operation.js +0 -53
- package/dist/lib/taquito/src/operations/smart-rollup-originate-operation.js +0 -50
- package/dist/lib/taquito/src/operations/transaction-operation.js +0 -73
- package/dist/lib/taquito/src/operations/transfer-ticket-operation.js +0 -47
- package/dist/lib/taquito/src/operations/types.js +0 -88
- package/dist/lib/taquito/src/operations/update-companion-key-operation.js +0 -55
- package/dist/lib/taquito/src/operations/update-consensus-key-operation.js +0 -55
- package/dist/lib/taquito/src/packer/interface.js +0 -2
- package/dist/lib/taquito/src/packer/michel-codec-packer.js +0 -11
- package/dist/lib/taquito/src/packer/rpc-packer.js +0 -12
- package/dist/lib/taquito/src/parser/interface.js +0 -2
- package/dist/lib/taquito/src/parser/michel-codec-parser.js +0 -110
- package/dist/lib/taquito/src/parser/noop-parser.js +0 -9
- package/dist/lib/taquito/src/prepare/index.js +0 -18
- package/dist/lib/taquito/src/prepare/interface.js +0 -2
- package/dist/lib/taquito/src/prepare/prepare-provider.js +0 -1049
- package/dist/lib/taquito/src/provider.js +0 -363
- package/dist/lib/taquito/src/read-provider/interface.js +0 -2
- package/dist/lib/taquito/src/read-provider/rpc-read-adapter.js +0 -183
- package/dist/lib/taquito/src/signer/errors.js +0 -17
- package/dist/lib/taquito/src/signer/noop.js +0 -23
- package/dist/lib/taquito/src/subscribe/create-observable-from-subscription.js +0 -20
- package/dist/lib/taquito/src/subscribe/errors.js +0 -30
- package/dist/lib/taquito/src/subscribe/filters.js +0 -96
- package/dist/lib/taquito/src/subscribe/interface.js +0 -2
- package/dist/lib/taquito/src/subscribe/observable-subscription.js +0 -79
- package/dist/lib/taquito/src/subscribe/polling-subcribe-provider.js +0 -118
- package/dist/lib/taquito/src/taquito.js +0 -404
- package/dist/lib/taquito/src/tz/interface.js +0 -2
- package/dist/lib/taquito/src/tz/rpc-tz-provider.js +0 -46
- package/dist/lib/taquito/src/version.js +0 -8
- package/dist/lib/taquito/src/wallet/batch-operation.js +0 -71
- package/dist/lib/taquito/src/wallet/delegation-operation.js +0 -42
- package/dist/lib/taquito/src/wallet/errors.js +0 -40
- package/dist/lib/taquito/src/wallet/increase-paid-storage-operation.js +0 -42
- package/dist/lib/taquito/src/wallet/index.js +0 -25
- package/dist/lib/taquito/src/wallet/interface.js +0 -2
- package/dist/lib/taquito/src/wallet/legacy.js +0 -51
- package/dist/lib/taquito/src/wallet/operation-factory.js +0 -88
- package/dist/lib/taquito/src/wallet/operation.js +0 -221
- package/dist/lib/taquito/src/wallet/origination-operation.js +0 -53
- package/dist/lib/taquito/src/wallet/receipt.js +0 -46
- package/dist/lib/taquito/src/wallet/register-global-constant-operation.js +0 -45
- package/dist/lib/taquito/src/wallet/transaction-operation.js +0 -38
- package/dist/lib/taquito/src/wallet/transfer-ticket-operation.js +0 -38
- package/dist/lib/taquito/src/wallet/wallet.js +0 -445
- package/dist/lib/taquito-core/src/errors.js +0 -351
- package/dist/lib/taquito-core/src/signer-interfaces.js +0 -2
- package/dist/lib/taquito-core/src/taquito-core.js +0 -22
- package/dist/lib/taquito-http-utils/src/errors.js +0 -103
- package/dist/lib/taquito-http-utils/src/status_code.js +0 -322
- package/dist/lib/taquito-http-utils/src/taquito-http-utils.js +0 -308
- package/dist/lib/taquito-http-utils/src/transport-errors.js +0 -141
- package/dist/lib/taquito-local-forging/src/codec.js +0 -543
- package/dist/lib/taquito-local-forging/src/constants.js +0 -291
- package/dist/lib/taquito-local-forging/src/decoder.js +0 -64
- package/dist/lib/taquito-local-forging/src/encoder.js +0 -63
- package/dist/lib/taquito-local-forging/src/errors.js +0 -179
- package/dist/lib/taquito-local-forging/src/interface.js +0 -2
- package/dist/lib/taquito-local-forging/src/michelson/codec.js +0 -283
- package/dist/lib/taquito-local-forging/src/protocols.js +0 -60
- package/dist/lib/taquito-local-forging/src/schema/operation.js +0 -259
- package/dist/lib/taquito-local-forging/src/taquito-local-forging.js +0 -117
- package/dist/lib/taquito-local-forging/src/uint8array-consumer.js +0 -35
- package/dist/lib/taquito-local-forging/src/utils.js +0 -18
- package/dist/lib/taquito-local-forging/src/validator.js +0 -57
- package/dist/lib/taquito-local-forging/src/version.js +0 -8
- package/dist/lib/taquito-michel-codec/src/base58.js +0 -255
- package/dist/lib/taquito-michel-codec/src/binary.js +0 -1271
- package/dist/lib/taquito-michel-codec/src/errors.js +0 -90
- package/dist/lib/taquito-michel-codec/src/formatters.js +0 -58
- package/dist/lib/taquito-michel-codec/src/global-constants.js +0 -12
- package/dist/lib/taquito-michel-codec/src/macros.js +0 -551
- package/dist/lib/taquito-michel-codec/src/micheline-emitter.js +0 -128
- package/dist/lib/taquito-michel-codec/src/micheline-parser.js +0 -402
- package/dist/lib/taquito-michel-codec/src/micheline.js +0 -5
- package/dist/lib/taquito-michel-codec/src/michelson-contract.js +0 -93
- package/dist/lib/taquito-michel-codec/src/michelson-typecheck.js +0 -1756
- package/dist/lib/taquito-michel-codec/src/michelson-types.js +0 -83
- package/dist/lib/taquito-michel-codec/src/michelson-validator.js +0 -833
- package/dist/lib/taquito-michel-codec/src/scan.js +0 -128
- package/dist/lib/taquito-michel-codec/src/taquito-michel-codec.js +0 -38
- package/dist/lib/taquito-michel-codec/src/utils.js +0 -323
- package/dist/lib/taquito-michel-codec/src/version.js +0 -8
- package/dist/lib/taquito-michelson-encoder/src/constants.js +0 -11
- package/dist/lib/taquito-michelson-encoder/src/errors.js +0 -38
- package/dist/lib/taquito-michelson-encoder/src/michelson-map.js +0 -201
- package/dist/lib/taquito-michelson-encoder/src/schema/errors.js +0 -127
- package/dist/lib/taquito-michelson-encoder/src/schema/event-schema.js +0 -52
- package/dist/lib/taquito-michelson-encoder/src/schema/parameter.js +0 -113
- package/dist/lib/taquito-michelson-encoder/src/schema/storage.js +0 -260
- package/dist/lib/taquito-michelson-encoder/src/schema/types.js +0 -2
- package/dist/lib/taquito-michelson-encoder/src/schema/view-schema.js +0 -90
- package/dist/lib/taquito-michelson-encoder/src/taquito-michelson-encoder.js +0 -36
- package/dist/lib/taquito-michelson-encoder/src/tokens/bigmap.js +0 -130
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-fr.js +0 -86
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-g1.js +0 -76
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-g2.js +0 -76
- package/dist/lib/taquito-michelson-encoder/src/tokens/chain-id.js +0 -78
- package/dist/lib/taquito-michelson-encoder/src/tokens/chest-key.js +0 -74
- package/dist/lib/taquito-michelson-encoder/src/tokens/chest.js +0 -74
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/address.js +0 -116
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/bool.js +0 -59
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/bytes.js +0 -90
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/int.js +0 -90
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/key_hash.js +0 -90
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/mutez.js +0 -90
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/nat.js +0 -93
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/string.js +0 -48
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/timestamp.js +0 -66
- package/dist/lib/taquito-michelson-encoder/src/tokens/constant.js +0 -80
- package/dist/lib/taquito-michelson-encoder/src/tokens/contract.js +0 -86
- package/dist/lib/taquito-michelson-encoder/src/tokens/createToken.js +0 -35
- package/dist/lib/taquito-michelson-encoder/src/tokens/key.js +0 -97
- package/dist/lib/taquito-michelson-encoder/src/tokens/lambda.js +0 -55
- package/dist/lib/taquito-michelson-encoder/src/tokens/list.js +0 -85
- package/dist/lib/taquito-michelson-encoder/src/tokens/map.js +0 -112
- package/dist/lib/taquito-michelson-encoder/src/tokens/never.js +0 -61
- package/dist/lib/taquito-michelson-encoder/src/tokens/operation.js +0 -39
- package/dist/lib/taquito-michelson-encoder/src/tokens/option.js +0 -88
- package/dist/lib/taquito-michelson-encoder/src/tokens/or.js +0 -282
- package/dist/lib/taquito-michelson-encoder/src/tokens/pair.js +0 -233
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-state.js +0 -84
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-transaction-deprecated.js +0 -74
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-transaction.js +0 -74
- package/dist/lib/taquito-michelson-encoder/src/tokens/set.js +0 -82
- package/dist/lib/taquito-michelson-encoder/src/tokens/signature.js +0 -82
- package/dist/lib/taquito-michelson-encoder/src/tokens/ticket-deprecated.js +0 -92
- package/dist/lib/taquito-michelson-encoder/src/tokens/ticket.js +0 -92
- package/dist/lib/taquito-michelson-encoder/src/tokens/token.js +0 -100
- package/dist/lib/taquito-michelson-encoder/src/tokens/tokens.js +0 -75
- package/dist/lib/taquito-michelson-encoder/src/tokens/unit.js +0 -52
- package/dist/lib/taquito-michelson-encoder/src/version.js +0 -8
- package/dist/lib/taquito-rpc/src/opkind.js +0 -49
- package/dist/lib/taquito-rpc/src/rpc-client-interface.js +0 -60
- package/dist/lib/taquito-rpc/src/rpc-client-modules/rpc-cache.js +0 -1118
- package/dist/lib/taquito-rpc/src/taquito-rpc.js +0 -990
- package/dist/lib/taquito-rpc/src/types.js +0 -114
- package/dist/lib/taquito-rpc/src/utils/utils.js +0 -65
- package/dist/lib/taquito-rpc/src/version.js +0 -8
- package/dist/lib/taquito-signer/src/bls-key.js +0 -104
- package/dist/lib/taquito-signer/src/derivation-tools/ecdsa.js +0 -156
- package/dist/lib/taquito-signer/src/derivation-tools/ed25519.js +0 -82
- package/dist/lib/taquito-signer/src/derivation-tools/index.js +0 -79
- package/dist/lib/taquito-signer/src/derivation-tools/types.js +0 -4
- package/dist/lib/taquito-signer/src/derivation-tools/utils.js +0 -16
- package/dist/lib/taquito-signer/src/ec-key.js +0 -196
- package/dist/lib/taquito-signer/src/ed-key.js +0 -130
- package/dist/lib/taquito-signer/src/errors.js +0 -77
- package/dist/lib/taquito-signer/src/helpers.js +0 -44
- package/dist/lib/taquito-signer/src/in-memory-signer.js +0 -240
- package/dist/lib/taquito-signer/src/key-interface.js +0 -6
- package/dist/lib/taquito-signer/src/taquito-signer.js +0 -28
- package/dist/lib/taquito-signer/src/version.js +0 -8
- package/dist/lib/taquito-utils/src/constants.js +0 -203
- package/dist/lib/taquito-utils/src/encoding.js +0 -606
- package/dist/lib/taquito-utils/src/errors.js +0 -45
- package/dist/lib/taquito-utils/src/format.js +0 -29
- package/dist/lib/taquito-utils/src/taquito-utils.js +0 -42
- package/dist/lib/taquito-utils/src/validators.js +0 -236
- package/dist/lib/taquito-utils/src/verify-signature.js +0 -136
- package/dist/lib/taquito-utils/src/version.js +0 -8
- package/dist/lib/taquito-wallet-connect/src/version.js +0 -8
- package/dist/types/taquito/src/batch/constants.d.ts +0 -3
- package/dist/types/taquito/src/batch/rpc-batch-provider.d.ts +0 -139
- package/dist/types/taquito/src/constants.d.ts +0 -81
- package/dist/types/taquito/src/context.d.ts +0 -100
- package/dist/types/taquito/src/contract/big-map.d.ts +0 -35
- package/dist/types/taquito/src/contract/compose.d.ts +0 -5
- package/dist/types/taquito/src/contract/constants.d.ts +0 -1
- package/dist/types/taquito/src/contract/contract-methods/contract-method-factory.d.ts +0 -14
- package/dist/types/taquito/src/contract/contract-methods/contract-method-interface.d.ts +0 -28
- package/dist/types/taquito/src/contract/contract-methods/contract-method-object-param.d.ts +0 -39
- package/dist/types/taquito/src/contract/contract-methods/contract-on-chain-view.d.ts +0 -43
- package/dist/types/taquito/src/contract/contract.d.ts +0 -75
- package/dist/types/taquito/src/contract/errors.d.ts +0 -83
- package/dist/types/taquito/src/contract/index.d.ts +0 -11
- package/dist/types/taquito/src/contract/interface.d.ts +0 -254
- package/dist/types/taquito/src/contract/manager-lambda.d.ts +0 -73
- package/dist/types/taquito/src/contract/prepare.d.ts +0 -18
- package/dist/types/taquito/src/contract/rpc-contract-provider.d.ts +0 -270
- package/dist/types/taquito/src/contract/sapling-state-abstraction.d.ts +0 -17
- package/dist/types/taquito/src/contract/semantic.d.ts +0 -7
- package/dist/types/taquito/src/contract/view_lambda.d.ts +0 -34
- package/dist/types/taquito/src/errors.d.ts +0 -26
- package/dist/types/taquito/src/estimate/errors.d.ts +0 -8
- package/dist/types/taquito/src/estimate/estimate-provider-interface.d.ts +0 -153
- package/dist/types/taquito/src/estimate/estimate.d.ts +0 -111
- package/dist/types/taquito/src/estimate/index.d.ts +0 -4
- package/dist/types/taquito/src/estimate/rpc-estimate-provider.d.ts +0 -174
- package/dist/types/taquito/src/extension/extension.d.ts +0 -4
- package/dist/types/taquito/src/forger/composite-forger.d.ts +0 -6
- package/dist/types/taquito/src/forger/errors.d.ts +0 -16
- package/dist/types/taquito/src/forger/rpc-forger.d.ts +0 -7
- package/dist/types/taquito/src/forger/taquito-local-forger.d.ts +0 -8
- package/dist/types/taquito/src/global-constants/default-global-constants-provider.d.ts +0 -18
- package/dist/types/taquito/src/global-constants/errors.d.ts +0 -16
- package/dist/types/taquito/src/global-constants/interface-global-constants-provider.d.ts +0 -11
- package/dist/types/taquito/src/global-constants/noop-global-constants-provider.d.ts +0 -5
- package/dist/types/taquito/src/import-key.d.ts +0 -13
- package/dist/types/taquito/src/injector/helper.d.ts +0 -2
- package/dist/types/taquito/src/injector/interface.d.ts +0 -5
- package/dist/types/taquito/src/injector/rpc-injector.d.ts +0 -7
- package/dist/types/taquito/src/operations/ballot-operation.d.ts +0 -18
- package/dist/types/taquito/src/operations/batch-operation.d.ts +0 -19
- package/dist/types/taquito/src/operations/delegate-operation.d.ts +0 -24
- package/dist/types/taquito/src/operations/drain-delegate-operation.d.ts +0 -17
- package/dist/types/taquito/src/operations/errors.d.ts +0 -50
- package/dist/types/taquito/src/operations/failing-noop-operation.d.ts +0 -17
- package/dist/types/taquito/src/operations/increase-paid-storage-operation.d.ts +0 -23
- package/dist/types/taquito/src/operations/index.d.ts +0 -18
- package/dist/types/taquito/src/operations/operations.d.ts +0 -35
- package/dist/types/taquito/src/operations/origination-operation.d.ts +0 -35
- package/dist/types/taquito/src/operations/proposals-operation.d.ts +0 -17
- package/dist/types/taquito/src/operations/register-global-constant-operation.d.ts +0 -25
- package/dist/types/taquito/src/operations/reveal-operation.d.ts +0 -25
- package/dist/types/taquito/src/operations/smart-rollup-add-messages-operation.d.ts +0 -20
- package/dist/types/taquito/src/operations/smart-rollup-execute-outbox-message-operation.d.ts +0 -24
- package/dist/types/taquito/src/operations/smart-rollup-originate-operation.d.ts +0 -23
- package/dist/types/taquito/src/operations/transaction-operation.d.ts +0 -28
- package/dist/types/taquito/src/operations/transfer-ticket-operation.d.ts +0 -22
- package/dist/types/taquito/src/operations/types.d.ts +0 -823
- package/dist/types/taquito/src/operations/update-companion-key-operation.d.ts +0 -23
- package/dist/types/taquito/src/operations/update-consensus-key-operation.d.ts +0 -23
- package/dist/types/taquito/src/packer/interface.d.ts +0 -4
- package/dist/types/taquito/src/packer/michel-codec-packer.d.ts +0 -5
- package/dist/types/taquito/src/packer/rpc-packer.d.ts +0 -8
- package/dist/types/taquito/src/parser/interface.d.ts +0 -4
- package/dist/types/taquito/src/parser/michel-codec-parser.d.ts +0 -16
- package/dist/types/taquito/src/parser/noop-parser.d.ts +0 -5
- package/dist/types/taquito/src/prepare/index.d.ts +0 -2
- package/dist/types/taquito/src/prepare/interface.d.ts +0 -152
- package/dist/types/taquito/src/prepare/prepare-provider.d.ts +0 -187
- package/dist/types/taquito/src/provider.d.ts +0 -50
- package/dist/types/taquito/src/read-provider/interface.d.ts +0 -132
- package/dist/types/taquito/src/read-provider/rpc-read-adapter.d.ts +0 -130
- package/dist/types/taquito/src/signer/errors.d.ts +0 -8
- package/dist/types/taquito/src/signer/noop.d.ts +0 -11
- package/dist/types/taquito/src/subscribe/create-observable-from-subscription.d.ts +0 -4
- package/dist/types/taquito/src/subscribe/errors.d.ts +0 -18
- package/dist/types/taquito/src/subscribe/filters.d.ts +0 -6
- package/dist/types/taquito/src/subscribe/interface.d.ts +0 -48
- package/dist/types/taquito/src/subscribe/observable-subscription.d.ts +0 -21
- package/dist/types/taquito/src/subscribe/polling-subcribe-provider.d.ts +0 -23
- package/dist/types/taquito/src/taquito.d.ts +0 -248
- package/dist/types/taquito/src/tz/interface.d.ts +0 -20
- package/dist/types/taquito/src/tz/rpc-tz-provider.d.ts +0 -13
- package/dist/types/taquito/src/version.d.ts +0 -4
- package/dist/types/taquito/src/wallet/batch-operation.d.ts +0 -13
- package/dist/types/taquito/src/wallet/delegation-operation.d.ts +0 -12
- package/dist/types/taquito/src/wallet/errors.d.ts +0 -24
- package/dist/types/taquito/src/wallet/increase-paid-storage-operation.d.ts +0 -12
- package/dist/types/taquito/src/wallet/index.d.ts +0 -9
- package/dist/types/taquito/src/wallet/interface.d.ts +0 -66
- package/dist/types/taquito/src/wallet/legacy.d.ts +0 -21
- package/dist/types/taquito/src/wallet/operation-factory.d.ts +0 -32
- package/dist/types/taquito/src/wallet/operation.d.ts +0 -55
- package/dist/types/taquito/src/wallet/origination-operation.d.ts +0 -14
- package/dist/types/taquito/src/wallet/receipt.d.ts +0 -16
- package/dist/types/taquito/src/wallet/register-global-constant-operation.d.ts +0 -13
- package/dist/types/taquito/src/wallet/transaction-operation.d.ts +0 -12
- package/dist/types/taquito/src/wallet/transfer-ticket-operation.d.ts +0 -12
- package/dist/types/taquito/src/wallet/wallet.d.ts +0 -196
- package/dist/types/taquito-core/src/errors.d.ts +0 -213
- package/dist/types/taquito-core/src/signer-interfaces.d.ts +0 -38
- package/dist/types/taquito-core/src/taquito-core.d.ts +0 -6
- package/dist/types/taquito-http-utils/src/errors.d.ts +0 -63
- package/dist/types/taquito-http-utils/src/status_code.d.ts +0 -318
- package/dist/types/taquito-http-utils/src/taquito-http-utils.d.ts +0 -58
- package/dist/types/taquito-http-utils/src/transport-errors.d.ts +0 -28
- package/dist/types/taquito-local-forging/src/codec.d.ts +0 -79
- package/dist/types/taquito-local-forging/src/constants.d.ts +0 -75
- package/dist/types/taquito-local-forging/src/decoder.d.ts +0 -5
- package/dist/types/taquito-local-forging/src/encoder.d.ts +0 -4
- package/dist/types/taquito-local-forging/src/errors.d.ts +0 -109
- package/dist/types/taquito-local-forging/src/interface.d.ts +0 -9
- package/dist/types/taquito-local-forging/src/michelson/codec.d.ts +0 -49
- package/dist/types/taquito-local-forging/src/protocols.d.ts +0 -27
- package/dist/types/taquito-local-forging/src/schema/operation.d.ts +0 -198
- package/dist/types/taquito-local-forging/src/taquito-local-forging.d.ts +0 -27
- package/dist/types/taquito-local-forging/src/uint8array-consumer.d.ts +0 -10
- package/dist/types/taquito-local-forging/src/utils.d.ts +0 -3
- package/dist/types/taquito-local-forging/src/validator.d.ts +0 -13
- package/dist/types/taquito-local-forging/src/version.d.ts +0 -4
- package/dist/types/taquito-michel-codec/src/base58.d.ts +0 -13
- package/dist/types/taquito-michel-codec/src/binary.d.ts +0 -127
- package/dist/types/taquito-michel-codec/src/errors.d.ts +0 -57
- package/dist/types/taquito-michel-codec/src/formatters.d.ts +0 -6
- package/dist/types/taquito-michel-codec/src/global-constants.d.ts +0 -3
- package/dist/types/taquito-michel-codec/src/macros.d.ts +0 -13
- package/dist/types/taquito-michel-codec/src/micheline-emitter.d.ts +0 -17
- package/dist/types/taquito-michel-codec/src/micheline-parser.d.ts +0 -130
- package/dist/types/taquito-michel-codec/src/micheline.d.ts +0 -44
- package/dist/types/taquito-michel-codec/src/michelson-contract.d.ts +0 -24
- package/dist/types/taquito-michel-codec/src/michelson-typecheck.d.ts +0 -38
- package/dist/types/taquito-michel-codec/src/michelson-types.d.ts +0 -147
- package/dist/types/taquito-michel-codec/src/michelson-validator.d.ts +0 -66
- package/dist/types/taquito-michel-codec/src/scan.d.ts +0 -26
- package/dist/types/taquito-michel-codec/src/taquito-michel-codec.d.ts +0 -16
- package/dist/types/taquito-michel-codec/src/utils.d.ts +0 -76
- package/dist/types/taquito-michel-codec/src/version.d.ts +0 -4
- package/dist/types/taquito-michelson-encoder/src/constants.d.ts +0 -8
- package/dist/types/taquito-michelson-encoder/src/errors.d.ts +0 -17
- package/dist/types/taquito-michelson-encoder/src/michelson-map.d.ts +0 -82
- package/dist/types/taquito-michelson-encoder/src/schema/errors.d.ts +0 -83
- package/dist/types/taquito-michelson-encoder/src/schema/event-schema.d.ts +0 -12
- package/dist/types/taquito-michelson-encoder/src/schema/parameter.d.ts +0 -54
- package/dist/types/taquito-michelson-encoder/src/schema/storage.d.ts +0 -97
- package/dist/types/taquito-michelson-encoder/src/schema/types.d.ts +0 -105
- package/dist/types/taquito-michelson-encoder/src/schema/view-schema.d.ts +0 -53
- package/dist/types/taquito-michelson-encoder/src/taquito-michelson-encoder.d.ts +0 -16
- package/dist/types/taquito-michelson-encoder/src/tokens/bigmap.d.ts +0 -51
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-fr.d.ts +0 -51
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-g1.d.ts +0 -47
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-g2.d.ts +0 -47
- package/dist/types/taquito-michelson-encoder/src/tokens/chain-id.d.ts +0 -51
- package/dist/types/taquito-michelson-encoder/src/tokens/chest-key.d.ts +0 -47
- package/dist/types/taquito-michelson-encoder/src/tokens/chest.d.ts +0 -47
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/address.d.ts +0 -61
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/bool.d.ts +0 -32
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/bytes.d.ts +0 -52
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/int.d.ts +0 -56
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/key_hash.d.ts +0 -55
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/mutez.d.ts +0 -53
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/nat.d.ts +0 -55
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/string.d.ts +0 -31
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/timestamp.d.ts +0 -34
- package/dist/types/taquito-michelson-encoder/src/tokens/constant.d.ts +0 -51
- package/dist/types/taquito-michelson-encoder/src/tokens/contract.d.ts +0 -48
- package/dist/types/taquito-michelson-encoder/src/tokens/createToken.d.ts +0 -18
- package/dist/types/taquito-michelson-encoder/src/tokens/key.d.ts +0 -55
- package/dist/types/taquito-michelson-encoder/src/tokens/lambda.d.ts +0 -24
- package/dist/types/taquito-michelson-encoder/src/tokens/list.d.ts +0 -46
- package/dist/types/taquito-michelson-encoder/src/tokens/map.d.ts +0 -47
- package/dist/types/taquito-michelson-encoder/src/tokens/never.d.ts +0 -41
- package/dist/types/taquito-michelson-encoder/src/tokens/operation.d.ts +0 -24
- package/dist/types/taquito-michelson-encoder/src/tokens/option.d.ts +0 -37
- package/dist/types/taquito-michelson-encoder/src/tokens/or.d.ts +0 -53
- package/dist/types/taquito-michelson-encoder/src/tokens/pair.d.ts +0 -50
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-state.d.ts +0 -44
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-transaction-deprecated.d.ts +0 -40
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-transaction.d.ts +0 -40
- package/dist/types/taquito-michelson-encoder/src/tokens/set.d.ts +0 -43
- package/dist/types/taquito-michelson-encoder/src/tokens/signature.d.ts +0 -53
- package/dist/types/taquito-michelson-encoder/src/tokens/ticket-deprecated.d.ts +0 -38
- package/dist/types/taquito-michelson-encoder/src/tokens/ticket.d.ts +0 -38
- package/dist/types/taquito-michelson-encoder/src/tokens/token.d.ts +0 -68
- package/dist/types/taquito-michelson-encoder/src/tokens/tokens.d.ts +0 -36
- package/dist/types/taquito-michelson-encoder/src/tokens/unit.d.ts +0 -34
- package/dist/types/taquito-michelson-encoder/src/version.d.ts +0 -4
- package/dist/types/taquito-rpc/src/opkind.d.ts +0 -45
- package/dist/types/taquito-rpc/src/rpc-client-interface.d.ts +0 -126
- package/dist/types/taquito-rpc/src/rpc-client-modules/rpc-cache.d.ts +0 -473
- package/dist/types/taquito-rpc/src/taquito-rpc.d.ts +0 -483
- package/dist/types/taquito-rpc/src/types.d.ts +0 -2362
- package/dist/types/taquito-rpc/src/utils/utils.d.ts +0 -14
- package/dist/types/taquito-rpc/src/version.d.ts +0 -4
- package/dist/types/taquito-signer/src/bls-key.d.ts +0 -21
- package/dist/types/taquito-signer/src/derivation-tools/ecdsa.d.ts +0 -49
- package/dist/types/taquito-signer/src/derivation-tools/ed25519.d.ts +0 -33
- package/dist/types/taquito-signer/src/derivation-tools/index.d.ts +0 -12
- package/dist/types/taquito-signer/src/derivation-tools/types.d.ts +0 -10
- package/dist/types/taquito-signer/src/derivation-tools/utils.d.ts +0 -1
- package/dist/types/taquito-signer/src/ec-key.d.ts +0 -42
- package/dist/types/taquito-signer/src/ed-key.d.ts +0 -39
- package/dist/types/taquito-signer/src/errors.d.ts +0 -51
- package/dist/types/taquito-signer/src/helpers.d.ts +0 -10
- package/dist/types/taquito-signer/src/in-memory-signer.d.ts +0 -56
- package/dist/types/taquito-signer/src/key-interface.d.ts +0 -37
- package/dist/types/taquito-signer/src/taquito-signer.d.ts +0 -10
- package/dist/types/taquito-signer/src/version.d.ts +0 -4
- package/dist/types/taquito-utils/src/constants.d.ts +0 -78
- package/dist/types/taquito-utils/src/encoding.d.ts +0 -184
- package/dist/types/taquito-utils/src/errors.d.ts +0 -20
- package/dist/types/taquito-utils/src/format.d.ts +0 -4
- package/dist/types/taquito-utils/src/taquito-utils.d.ts +0 -11
- package/dist/types/taquito-utils/src/validators.d.ts +0 -167
- package/dist/types/taquito-utils/src/verify-signature.d.ts +0 -22
- package/dist/types/taquito-utils/src/version.d.ts +0 -4
- package/dist/types/taquito-wallet-connect/src/version.d.ts +0 -4
- /package/dist/lib/{taquito-wallet-connect/src/errors.js → errors.js} +0 -0
- /package/dist/lib/{taquito-wallet-connect/src/types.js → types.js} +0 -0
- /package/dist/types/{taquito-wallet-connect/src/errors.d.ts → errors.d.ts} +0 -0
- /package/dist/types/{taquito-wallet-connect/src/taquito-wallet-connect.d.ts → taquito-wallet-connect.d.ts} +0 -0
- /package/dist/types/{taquito-wallet-connect/src/types.d.ts → types.d.ts} +0 -0
- /package/dist/types/{taquito-http-utils/src/version.d.ts → version.d.ts} +0 -0
|
@@ -1,1271 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packData = packData;
|
|
4
|
-
exports.packDataBytes = packDataBytes;
|
|
5
|
-
exports.unpackData = unpackData;
|
|
6
|
-
exports.unpackDataBytes = unpackDataBytes;
|
|
7
|
-
exports.decodeAddressBytes = decodeAddressBytes;
|
|
8
|
-
exports.decodePublicKeyHashBytes = decodePublicKeyHashBytes;
|
|
9
|
-
exports.decodePublicKeyBytes = decodePublicKeyBytes;
|
|
10
|
-
const michelson_validator_1 = require("./michelson-validator");
|
|
11
|
-
const utils_1 = require("./utils");
|
|
12
|
-
// The order is important!
|
|
13
|
-
// The position represent the encoding value.
|
|
14
|
-
const primitives = [
|
|
15
|
-
'parameter',
|
|
16
|
-
'storage',
|
|
17
|
-
'code',
|
|
18
|
-
'False',
|
|
19
|
-
'Elt',
|
|
20
|
-
'Left',
|
|
21
|
-
'None',
|
|
22
|
-
'Pair',
|
|
23
|
-
'Right',
|
|
24
|
-
'Some',
|
|
25
|
-
'True',
|
|
26
|
-
'Unit',
|
|
27
|
-
'PACK',
|
|
28
|
-
'UNPACK',
|
|
29
|
-
'BLAKE2B',
|
|
30
|
-
'SHA256',
|
|
31
|
-
'SHA512',
|
|
32
|
-
'ABS',
|
|
33
|
-
'ADD',
|
|
34
|
-
'AMOUNT',
|
|
35
|
-
'AND',
|
|
36
|
-
'BALANCE',
|
|
37
|
-
'CAR',
|
|
38
|
-
'CDR',
|
|
39
|
-
'CHECK_SIGNATURE',
|
|
40
|
-
'COMPARE',
|
|
41
|
-
'CONCAT',
|
|
42
|
-
'CONS',
|
|
43
|
-
'CREATE_ACCOUNT',
|
|
44
|
-
'CREATE_CONTRACT',
|
|
45
|
-
'IMPLICIT_ACCOUNT',
|
|
46
|
-
'DIP',
|
|
47
|
-
'DROP',
|
|
48
|
-
'DUP',
|
|
49
|
-
'EDIV',
|
|
50
|
-
'EMPTY_MAP',
|
|
51
|
-
'EMPTY_SET',
|
|
52
|
-
'EQ',
|
|
53
|
-
'EXEC',
|
|
54
|
-
'FAILWITH',
|
|
55
|
-
'GE',
|
|
56
|
-
'GET',
|
|
57
|
-
'GT',
|
|
58
|
-
'HASH_KEY',
|
|
59
|
-
'IF',
|
|
60
|
-
'IF_CONS',
|
|
61
|
-
'IF_LEFT',
|
|
62
|
-
'IF_NONE',
|
|
63
|
-
'INT',
|
|
64
|
-
'LAMBDA',
|
|
65
|
-
'LE',
|
|
66
|
-
'LEFT',
|
|
67
|
-
'LOOP',
|
|
68
|
-
'LSL',
|
|
69
|
-
'LSR',
|
|
70
|
-
'LT',
|
|
71
|
-
'MAP',
|
|
72
|
-
'MEM',
|
|
73
|
-
'MUL',
|
|
74
|
-
'NEG',
|
|
75
|
-
'NEQ',
|
|
76
|
-
'NIL',
|
|
77
|
-
'NONE',
|
|
78
|
-
'NOT',
|
|
79
|
-
'NOW',
|
|
80
|
-
'OR',
|
|
81
|
-
'PAIR',
|
|
82
|
-
'PUSH',
|
|
83
|
-
'RIGHT',
|
|
84
|
-
'SIZE',
|
|
85
|
-
'SOME',
|
|
86
|
-
'SOURCE',
|
|
87
|
-
'SENDER',
|
|
88
|
-
'SELF',
|
|
89
|
-
'STEPS_TO_QUOTA',
|
|
90
|
-
'SUB',
|
|
91
|
-
'SWAP',
|
|
92
|
-
'TRANSFER_TOKENS',
|
|
93
|
-
'SET_DELEGATE',
|
|
94
|
-
'UNIT',
|
|
95
|
-
'UPDATE',
|
|
96
|
-
'XOR',
|
|
97
|
-
'ITER',
|
|
98
|
-
'LOOP_LEFT',
|
|
99
|
-
'ADDRESS',
|
|
100
|
-
'CONTRACT',
|
|
101
|
-
'ISNAT',
|
|
102
|
-
'CAST',
|
|
103
|
-
'RENAME',
|
|
104
|
-
'bool',
|
|
105
|
-
'contract',
|
|
106
|
-
'int',
|
|
107
|
-
'key',
|
|
108
|
-
'key_hash',
|
|
109
|
-
'lambda',
|
|
110
|
-
'list',
|
|
111
|
-
'map',
|
|
112
|
-
'big_map',
|
|
113
|
-
'nat',
|
|
114
|
-
'option',
|
|
115
|
-
'or',
|
|
116
|
-
'pair',
|
|
117
|
-
'set',
|
|
118
|
-
'signature',
|
|
119
|
-
'string',
|
|
120
|
-
'bytes',
|
|
121
|
-
'mutez',
|
|
122
|
-
'timestamp',
|
|
123
|
-
'unit',
|
|
124
|
-
'operation',
|
|
125
|
-
'address',
|
|
126
|
-
'SLICE',
|
|
127
|
-
'DIG',
|
|
128
|
-
'DUG',
|
|
129
|
-
'EMPTY_BIG_MAP',
|
|
130
|
-
'APPLY',
|
|
131
|
-
'chain_id',
|
|
132
|
-
'CHAIN_ID',
|
|
133
|
-
'LEVEL',
|
|
134
|
-
'SELF_ADDRESS',
|
|
135
|
-
'never',
|
|
136
|
-
'NEVER',
|
|
137
|
-
'UNPAIR',
|
|
138
|
-
'VOTING_POWER',
|
|
139
|
-
'TOTAL_VOTING_POWER',
|
|
140
|
-
'KECCAK',
|
|
141
|
-
'SHA3',
|
|
142
|
-
'PAIRING_CHECK',
|
|
143
|
-
'bls12_381_g1',
|
|
144
|
-
'bls12_381_g2',
|
|
145
|
-
'bls12_381_fr',
|
|
146
|
-
'sapling_state',
|
|
147
|
-
'sapling_transaction_deprecated',
|
|
148
|
-
'SAPLING_EMPTY_STATE',
|
|
149
|
-
'SAPLING_VERIFY_UPDATE',
|
|
150
|
-
'ticket',
|
|
151
|
-
'TICKET_DEPRECATED',
|
|
152
|
-
'READ_TICKET',
|
|
153
|
-
'SPLIT_TICKET',
|
|
154
|
-
'JOIN_TICKETS',
|
|
155
|
-
'GET_AND_UPDATE',
|
|
156
|
-
'chest',
|
|
157
|
-
'chest_key',
|
|
158
|
-
'OPEN_CHEST',
|
|
159
|
-
'VIEW',
|
|
160
|
-
'view',
|
|
161
|
-
'constant',
|
|
162
|
-
'SUB_MUTEZ',
|
|
163
|
-
'tx_rollup_l2_address',
|
|
164
|
-
'MIN_BLOCK_TIME',
|
|
165
|
-
'sapling_transaction',
|
|
166
|
-
'EMIT',
|
|
167
|
-
'Lambda_rec',
|
|
168
|
-
'LAMBDA_REC',
|
|
169
|
-
'TICKET',
|
|
170
|
-
'BYTES',
|
|
171
|
-
'NAT',
|
|
172
|
-
'Ticket',
|
|
173
|
-
'IS_IMPLICIT_ACCOUNT',
|
|
174
|
-
'INDEX_ADDRESS',
|
|
175
|
-
'GET_ADDRESS_INDEX',
|
|
176
|
-
];
|
|
177
|
-
const primTags = Object.assign({}, ...primitives.map((v, i) => ({ [v]: i })));
|
|
178
|
-
var Tag;
|
|
179
|
-
(function (Tag) {
|
|
180
|
-
Tag[Tag["Int"] = 0] = "Int";
|
|
181
|
-
Tag[Tag["String"] = 1] = "String";
|
|
182
|
-
Tag[Tag["Sequence"] = 2] = "Sequence";
|
|
183
|
-
Tag[Tag["Prim0"] = 3] = "Prim0";
|
|
184
|
-
Tag[Tag["Prim0Annot"] = 4] = "Prim0Annot";
|
|
185
|
-
Tag[Tag["Prim1"] = 5] = "Prim1";
|
|
186
|
-
Tag[Tag["Prim1Annot"] = 6] = "Prim1Annot";
|
|
187
|
-
Tag[Tag["Prim2"] = 7] = "Prim2";
|
|
188
|
-
Tag[Tag["Prim2Annot"] = 8] = "Prim2Annot";
|
|
189
|
-
Tag[Tag["Prim"] = 9] = "Prim";
|
|
190
|
-
Tag[Tag["Bytes"] = 10] = "Bytes";
|
|
191
|
-
})(Tag || (Tag = {}));
|
|
192
|
-
class Writer {
|
|
193
|
-
constructor() {
|
|
194
|
-
this.buffer = [];
|
|
195
|
-
}
|
|
196
|
-
get length() {
|
|
197
|
-
return this.buffer.length;
|
|
198
|
-
}
|
|
199
|
-
writeBytes(val) {
|
|
200
|
-
this.buffer.push(...val.map((v) => v & 0xff));
|
|
201
|
-
}
|
|
202
|
-
writeUint8(val) {
|
|
203
|
-
const v = val | 0;
|
|
204
|
-
this.buffer.push(v & 0xff);
|
|
205
|
-
}
|
|
206
|
-
writeUint16(val) {
|
|
207
|
-
const v = val | 0;
|
|
208
|
-
this.buffer.push((v >> 8) & 0xff);
|
|
209
|
-
this.buffer.push(v & 0xff);
|
|
210
|
-
}
|
|
211
|
-
writeUint32(val) {
|
|
212
|
-
const v = val | 0;
|
|
213
|
-
this.buffer.push((v >> 24) & 0xff);
|
|
214
|
-
this.buffer.push((v >> 16) & 0xff);
|
|
215
|
-
this.buffer.push((v >> 8) & 0xff);
|
|
216
|
-
this.buffer.push(v & 0xff);
|
|
217
|
-
}
|
|
218
|
-
writeInt8(val) {
|
|
219
|
-
this.writeUint8(val);
|
|
220
|
-
}
|
|
221
|
-
writeInt16(val) {
|
|
222
|
-
this.writeUint16(val);
|
|
223
|
-
}
|
|
224
|
-
writeInt32(val) {
|
|
225
|
-
this.writeUint32(val);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const boundsErr = new Error('bounds out of range');
|
|
229
|
-
class Reader {
|
|
230
|
-
constructor(buffer, idx = 0, cap = buffer.length) {
|
|
231
|
-
this.buffer = buffer;
|
|
232
|
-
this.idx = idx;
|
|
233
|
-
this.cap = cap;
|
|
234
|
-
}
|
|
235
|
-
/** Remaining length */
|
|
236
|
-
get length() {
|
|
237
|
-
return this.cap - this.idx;
|
|
238
|
-
}
|
|
239
|
-
readBytes(len) {
|
|
240
|
-
if (this.cap - this.idx < len) {
|
|
241
|
-
throw boundsErr;
|
|
242
|
-
}
|
|
243
|
-
const ret = this.buffer.slice(this.idx, this.idx + len);
|
|
244
|
-
this.idx += len;
|
|
245
|
-
return ret;
|
|
246
|
-
}
|
|
247
|
-
reader(len) {
|
|
248
|
-
if (this.cap - this.idx < len) {
|
|
249
|
-
throw boundsErr;
|
|
250
|
-
}
|
|
251
|
-
const ret = new Reader(this.buffer, this.idx, this.idx + len);
|
|
252
|
-
this.idx += len;
|
|
253
|
-
return ret;
|
|
254
|
-
}
|
|
255
|
-
copy() {
|
|
256
|
-
return new Reader(this.buffer, this.idx, this.cap);
|
|
257
|
-
}
|
|
258
|
-
readUint8() {
|
|
259
|
-
if (this.cap - this.idx < 1) {
|
|
260
|
-
throw boundsErr;
|
|
261
|
-
}
|
|
262
|
-
return this.buffer[this.idx++] >>> 0;
|
|
263
|
-
}
|
|
264
|
-
readUint16() {
|
|
265
|
-
if (this.cap - this.idx < 2) {
|
|
266
|
-
throw boundsErr;
|
|
267
|
-
}
|
|
268
|
-
const x0 = this.buffer[this.idx++];
|
|
269
|
-
const x1 = this.buffer[this.idx++];
|
|
270
|
-
return ((x0 << 8) | x1) >>> 0;
|
|
271
|
-
}
|
|
272
|
-
readUint32() {
|
|
273
|
-
if (this.cap - this.idx < 4) {
|
|
274
|
-
throw boundsErr;
|
|
275
|
-
}
|
|
276
|
-
const x0 = this.buffer[this.idx++];
|
|
277
|
-
const x1 = this.buffer[this.idx++];
|
|
278
|
-
const x2 = this.buffer[this.idx++];
|
|
279
|
-
const x3 = this.buffer[this.idx++];
|
|
280
|
-
return ((x0 << 24) | (x1 << 16) | (x2 << 8) | x3) >>> 0;
|
|
281
|
-
}
|
|
282
|
-
readInt8() {
|
|
283
|
-
if (this.cap - this.idx < 1) {
|
|
284
|
-
throw boundsErr;
|
|
285
|
-
}
|
|
286
|
-
const x = this.buffer[this.idx++];
|
|
287
|
-
return (x << 24) >> 24;
|
|
288
|
-
}
|
|
289
|
-
readInt16() {
|
|
290
|
-
if (this.cap - this.idx < 2) {
|
|
291
|
-
throw boundsErr;
|
|
292
|
-
}
|
|
293
|
-
const x0 = this.buffer[this.idx++];
|
|
294
|
-
const x1 = this.buffer[this.idx++];
|
|
295
|
-
return (((x0 << 8) | x1) << 16) >> 16;
|
|
296
|
-
}
|
|
297
|
-
readInt32() {
|
|
298
|
-
if (this.cap - this.idx < 4) {
|
|
299
|
-
throw boundsErr;
|
|
300
|
-
}
|
|
301
|
-
const x0 = this.buffer[this.idx++];
|
|
302
|
-
const x1 = this.buffer[this.idx++];
|
|
303
|
-
const x2 = this.buffer[this.idx++];
|
|
304
|
-
const x3 = this.buffer[this.idx++];
|
|
305
|
-
return (x0 << 24) | (x1 << 16) | (x2 << 8) | x3;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
var ContractID;
|
|
309
|
-
(function (ContractID) {
|
|
310
|
-
ContractID[ContractID["Implicit"] = 0] = "Implicit";
|
|
311
|
-
ContractID[ContractID["Originated"] = 1] = "Originated";
|
|
312
|
-
})(ContractID || (ContractID = {}));
|
|
313
|
-
var PublicKeyHashID;
|
|
314
|
-
(function (PublicKeyHashID) {
|
|
315
|
-
PublicKeyHashID[PublicKeyHashID["ED25519"] = 0] = "ED25519";
|
|
316
|
-
PublicKeyHashID[PublicKeyHashID["SECP256K1"] = 1] = "SECP256K1";
|
|
317
|
-
PublicKeyHashID[PublicKeyHashID["P256"] = 2] = "P256";
|
|
318
|
-
})(PublicKeyHashID || (PublicKeyHashID = {}));
|
|
319
|
-
function readPublicKeyHash(rd) {
|
|
320
|
-
let type;
|
|
321
|
-
const tag = rd.readUint8();
|
|
322
|
-
switch (tag) {
|
|
323
|
-
case PublicKeyHashID.ED25519:
|
|
324
|
-
type = 'ED25519PublicKeyHash';
|
|
325
|
-
break;
|
|
326
|
-
case PublicKeyHashID.SECP256K1:
|
|
327
|
-
type = 'SECP256K1PublicKeyHash';
|
|
328
|
-
break;
|
|
329
|
-
case PublicKeyHashID.P256:
|
|
330
|
-
type = 'P256PublicKeyHash';
|
|
331
|
-
break;
|
|
332
|
-
default:
|
|
333
|
-
throw new Error(`unknown public key hash tag: ${tag}`);
|
|
334
|
-
}
|
|
335
|
-
return { type, hash: rd.readBytes(20) };
|
|
336
|
-
}
|
|
337
|
-
function readAddress(rd) {
|
|
338
|
-
let address;
|
|
339
|
-
const tag = rd.readUint8();
|
|
340
|
-
switch (tag) {
|
|
341
|
-
case ContractID.Implicit:
|
|
342
|
-
address = readPublicKeyHash(rd);
|
|
343
|
-
break;
|
|
344
|
-
case ContractID.Originated:
|
|
345
|
-
address = {
|
|
346
|
-
type: 'ContractHash',
|
|
347
|
-
hash: rd.readBytes(20),
|
|
348
|
-
};
|
|
349
|
-
rd.readBytes(1);
|
|
350
|
-
break;
|
|
351
|
-
default:
|
|
352
|
-
throw new Error(`unknown address tag: ${tag}`);
|
|
353
|
-
}
|
|
354
|
-
if (rd.length !== 0) {
|
|
355
|
-
// entry point
|
|
356
|
-
const dec = new TextDecoder();
|
|
357
|
-
address.entryPoint = dec.decode(new Uint8Array(rd.readBytes(rd.length)));
|
|
358
|
-
}
|
|
359
|
-
return address;
|
|
360
|
-
}
|
|
361
|
-
function writePublicKeyHash(a, w) {
|
|
362
|
-
let tag;
|
|
363
|
-
switch (a.type) {
|
|
364
|
-
case 'ED25519PublicKeyHash':
|
|
365
|
-
tag = PublicKeyHashID.ED25519;
|
|
366
|
-
break;
|
|
367
|
-
case 'SECP256K1PublicKeyHash':
|
|
368
|
-
tag = PublicKeyHashID.SECP256K1;
|
|
369
|
-
break;
|
|
370
|
-
case 'P256PublicKeyHash':
|
|
371
|
-
tag = PublicKeyHashID.P256;
|
|
372
|
-
break;
|
|
373
|
-
default:
|
|
374
|
-
throw new Error(`unexpected address type: ${a.type}`);
|
|
375
|
-
}
|
|
376
|
-
w.writeUint8(tag);
|
|
377
|
-
w.writeBytes(Array.from(a.hash));
|
|
378
|
-
}
|
|
379
|
-
function writeAddress(a, w) {
|
|
380
|
-
if (a.type === 'ContractHash') {
|
|
381
|
-
w.writeUint8(ContractID.Originated);
|
|
382
|
-
w.writeBytes(Array.from(a.hash));
|
|
383
|
-
w.writeUint8(0);
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
w.writeUint8(ContractID.Implicit);
|
|
387
|
-
writePublicKeyHash(a, w);
|
|
388
|
-
}
|
|
389
|
-
if (a.entryPoint !== undefined && a.entryPoint !== '' && a.entryPoint !== 'default') {
|
|
390
|
-
const enc = new TextEncoder();
|
|
391
|
-
const bytes = enc.encode(a.entryPoint);
|
|
392
|
-
w.writeBytes(Array.from(bytes));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
var PublicKeyID;
|
|
396
|
-
(function (PublicKeyID) {
|
|
397
|
-
PublicKeyID[PublicKeyID["ED25519"] = 0] = "ED25519";
|
|
398
|
-
PublicKeyID[PublicKeyID["SECP256K1"] = 1] = "SECP256K1";
|
|
399
|
-
PublicKeyID[PublicKeyID["P256"] = 2] = "P256";
|
|
400
|
-
})(PublicKeyID || (PublicKeyID = {}));
|
|
401
|
-
function readPublicKey(rd) {
|
|
402
|
-
let ln;
|
|
403
|
-
let type;
|
|
404
|
-
const tag = rd.readUint8();
|
|
405
|
-
switch (tag) {
|
|
406
|
-
case PublicKeyID.ED25519:
|
|
407
|
-
type = 'ED25519PublicKey';
|
|
408
|
-
ln = 32;
|
|
409
|
-
break;
|
|
410
|
-
case PublicKeyID.SECP256K1:
|
|
411
|
-
type = 'SECP256K1PublicKey';
|
|
412
|
-
ln = 33;
|
|
413
|
-
break;
|
|
414
|
-
case PublicKeyID.P256:
|
|
415
|
-
type = 'P256PublicKey';
|
|
416
|
-
ln = 33;
|
|
417
|
-
break;
|
|
418
|
-
default:
|
|
419
|
-
throw new Error(`unknown public key tag: ${tag}`);
|
|
420
|
-
}
|
|
421
|
-
return { type, publicKey: rd.readBytes(ln) };
|
|
422
|
-
}
|
|
423
|
-
function writePublicKey(pk, w) {
|
|
424
|
-
let tag;
|
|
425
|
-
switch (pk.type) {
|
|
426
|
-
case 'ED25519PublicKey':
|
|
427
|
-
tag = PublicKeyID.ED25519;
|
|
428
|
-
break;
|
|
429
|
-
case 'SECP256K1PublicKey':
|
|
430
|
-
tag = PublicKeyID.SECP256K1;
|
|
431
|
-
break;
|
|
432
|
-
case 'P256PublicKey':
|
|
433
|
-
tag = PublicKeyID.P256;
|
|
434
|
-
break;
|
|
435
|
-
default:
|
|
436
|
-
throw new Error(`unexpected public key type: ${pk.type}`);
|
|
437
|
-
}
|
|
438
|
-
w.writeUint8(tag);
|
|
439
|
-
w.writeBytes(Array.from(pk.publicKey));
|
|
440
|
-
}
|
|
441
|
-
function writeExpr(expr, wr, tf) {
|
|
442
|
-
const [e, args] = tf(expr);
|
|
443
|
-
if (Array.isArray(e)) {
|
|
444
|
-
const w = new Writer();
|
|
445
|
-
for (const v of e) {
|
|
446
|
-
const a = args.next();
|
|
447
|
-
if (a.done) {
|
|
448
|
-
throw new Error('REPORT ME: iterator is done');
|
|
449
|
-
}
|
|
450
|
-
writeExpr(v, w, a.value);
|
|
451
|
-
}
|
|
452
|
-
wr.writeUint8(Tag.Sequence);
|
|
453
|
-
wr.writeUint32(w.length);
|
|
454
|
-
wr.writeBytes(w.buffer);
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
if ('string' in e) {
|
|
458
|
-
const enc = new TextEncoder();
|
|
459
|
-
const bytes = enc.encode(e.string);
|
|
460
|
-
wr.writeUint8(Tag.String);
|
|
461
|
-
wr.writeUint32(bytes.length);
|
|
462
|
-
wr.writeBytes(Array.from(bytes));
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if ('int' in e) {
|
|
466
|
-
wr.writeUint8(Tag.Int);
|
|
467
|
-
let val = BigInt(e.int);
|
|
468
|
-
const sign = val < 0;
|
|
469
|
-
if (sign) {
|
|
470
|
-
val = -val;
|
|
471
|
-
}
|
|
472
|
-
let i = 0;
|
|
473
|
-
do {
|
|
474
|
-
const bits = i === 0 ? BigInt(6) : BigInt(7);
|
|
475
|
-
let byte = val & ((BigInt(1) << bits) - BigInt(1));
|
|
476
|
-
val >>= bits;
|
|
477
|
-
if (val) {
|
|
478
|
-
byte |= BigInt(0x80);
|
|
479
|
-
}
|
|
480
|
-
if (i === 0 && sign) {
|
|
481
|
-
byte |= BigInt(0x40);
|
|
482
|
-
}
|
|
483
|
-
wr.writeUint8(Number(byte));
|
|
484
|
-
i++;
|
|
485
|
-
} while (val);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if ('bytes' in e) {
|
|
489
|
-
const bytes = (0, utils_1.parseHex)(e.bytes);
|
|
490
|
-
wr.writeUint8(Tag.Bytes);
|
|
491
|
-
wr.writeUint32(bytes.length);
|
|
492
|
-
wr.writeBytes(bytes);
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
const prim = primTags[e.prim];
|
|
496
|
-
if (prim === undefined) {
|
|
497
|
-
throw new TypeError(`Can't encode primary: ${e.prim}`);
|
|
498
|
-
}
|
|
499
|
-
const tag = (e.args?.length || 0) < 3
|
|
500
|
-
? Tag.Prim0 +
|
|
501
|
-
(e.args?.length || 0) * 2 +
|
|
502
|
-
(e.annots === undefined || e.annots.length === 0 ? 0 : 1)
|
|
503
|
-
: Tag.Prim;
|
|
504
|
-
wr.writeUint8(tag);
|
|
505
|
-
wr.writeUint8(prim);
|
|
506
|
-
if (e.args !== undefined) {
|
|
507
|
-
if (e.args.length < 3) {
|
|
508
|
-
for (const v of e.args) {
|
|
509
|
-
const a = args.next();
|
|
510
|
-
if (a.done) {
|
|
511
|
-
throw new Error('REPORT ME: iterator is done');
|
|
512
|
-
}
|
|
513
|
-
writeExpr(v, wr, a.value);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
const w = new Writer();
|
|
518
|
-
for (const v of e.args) {
|
|
519
|
-
const a = args.next();
|
|
520
|
-
if (a.done) {
|
|
521
|
-
throw new Error('REPORT ME: iterator is done');
|
|
522
|
-
}
|
|
523
|
-
writeExpr(v, w, a.value);
|
|
524
|
-
}
|
|
525
|
-
wr.writeUint32(w.length);
|
|
526
|
-
wr.writeBytes(w.buffer);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (e.annots !== undefined && e.annots.length !== 0) {
|
|
530
|
-
const enc = new TextEncoder();
|
|
531
|
-
const bytes = enc.encode(e.annots.join(' '));
|
|
532
|
-
wr.writeUint32(bytes.length);
|
|
533
|
-
wr.writeBytes(Array.from(bytes));
|
|
534
|
-
}
|
|
535
|
-
else if (e.args !== undefined && e.args.length >= 3) {
|
|
536
|
-
wr.writeUint32(0);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function readExpr(rd, tf) {
|
|
540
|
-
function* passThrough() {
|
|
541
|
-
while (true) {
|
|
542
|
-
yield readPassThrough;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
const [args, tr] = tf;
|
|
546
|
-
const tag = rd.readUint8();
|
|
547
|
-
switch (tag) {
|
|
548
|
-
case Tag.Int: {
|
|
549
|
-
const buf = [];
|
|
550
|
-
let byte;
|
|
551
|
-
do {
|
|
552
|
-
byte = rd.readInt8();
|
|
553
|
-
buf.push(byte);
|
|
554
|
-
} while ((byte & 0x80) !== 0);
|
|
555
|
-
let val = BigInt(0);
|
|
556
|
-
let sign = false;
|
|
557
|
-
for (let i = buf.length - 1; i >= 0; i--) {
|
|
558
|
-
const bits = i === 0 ? BigInt(6) : BigInt(7);
|
|
559
|
-
const byte = BigInt(buf[i]);
|
|
560
|
-
val <<= bits;
|
|
561
|
-
val |= byte & ((BigInt(1) << bits) - BigInt(1));
|
|
562
|
-
if (i === 0) {
|
|
563
|
-
sign = !!(byte & BigInt(0x40));
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
if (sign) {
|
|
567
|
-
val = -val;
|
|
568
|
-
}
|
|
569
|
-
return tr({ int: String(val) });
|
|
570
|
-
}
|
|
571
|
-
case Tag.String: {
|
|
572
|
-
const length = rd.readUint32();
|
|
573
|
-
const bytes = rd.readBytes(length);
|
|
574
|
-
const dec = new TextDecoder();
|
|
575
|
-
return tr({ string: dec.decode(new Uint8Array(bytes)) });
|
|
576
|
-
}
|
|
577
|
-
case Tag.Bytes: {
|
|
578
|
-
const length = rd.readUint32();
|
|
579
|
-
const bytes = rd.readBytes(length);
|
|
580
|
-
const hex = (0, utils_1.hexBytes)(Array.from(bytes));
|
|
581
|
-
return tr({ bytes: hex });
|
|
582
|
-
}
|
|
583
|
-
case Tag.Sequence: {
|
|
584
|
-
const length = rd.readUint32();
|
|
585
|
-
let res = [];
|
|
586
|
-
let savedrd = rd.copy();
|
|
587
|
-
// make two passes
|
|
588
|
-
let it = passThrough();
|
|
589
|
-
for (let n = 0; n < 2; n++) {
|
|
590
|
-
const r = savedrd.reader(length);
|
|
591
|
-
res = [];
|
|
592
|
-
while (r.length > 0) {
|
|
593
|
-
const a = it.next();
|
|
594
|
-
if (a.done) {
|
|
595
|
-
throw new Error('REPORT ME: iterator is done');
|
|
596
|
-
}
|
|
597
|
-
res.push(readExpr(r, a.value));
|
|
598
|
-
}
|
|
599
|
-
// make a second pass with injected side effects
|
|
600
|
-
it = args(res);
|
|
601
|
-
savedrd = rd;
|
|
602
|
-
}
|
|
603
|
-
return tr(res);
|
|
604
|
-
}
|
|
605
|
-
default: {
|
|
606
|
-
if (tag > 9) {
|
|
607
|
-
throw new Error(`Unknown tag: ${tag}`);
|
|
608
|
-
}
|
|
609
|
-
const p = rd.readUint8();
|
|
610
|
-
if (p >= primitives.length) {
|
|
611
|
-
throw new Error(`Unknown primitive tag: ${p}`);
|
|
612
|
-
}
|
|
613
|
-
const prim = primitives[p];
|
|
614
|
-
const argn = (tag - 3) >> 1;
|
|
615
|
-
let res = { prim };
|
|
616
|
-
// make two passes
|
|
617
|
-
let it = passThrough();
|
|
618
|
-
let savedrd = rd.copy();
|
|
619
|
-
for (let n = 0; n < 2; n++) {
|
|
620
|
-
res = { prim };
|
|
621
|
-
if (argn < 3) {
|
|
622
|
-
for (let i = 0; i < argn; i++) {
|
|
623
|
-
const a = it.next();
|
|
624
|
-
if (a.done) {
|
|
625
|
-
throw new Error('REPORT ME: iterator is done');
|
|
626
|
-
}
|
|
627
|
-
res.args = res.args || [];
|
|
628
|
-
res.args.push(readExpr(savedrd, a.value));
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
res.args = res.args || [];
|
|
633
|
-
const length = savedrd.readUint32();
|
|
634
|
-
const r = savedrd.reader(length);
|
|
635
|
-
while (r.length > 0) {
|
|
636
|
-
const a = it.next();
|
|
637
|
-
if (a.done) {
|
|
638
|
-
throw new Error('REPORT ME: iterator is done');
|
|
639
|
-
}
|
|
640
|
-
res.args.push(readExpr(r, a.value));
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
// make a second pass with injected side effects
|
|
644
|
-
it = args(res);
|
|
645
|
-
savedrd = rd;
|
|
646
|
-
}
|
|
647
|
-
if (((tag - 3) & 1) === 1 || argn === 3) {
|
|
648
|
-
// read annotations
|
|
649
|
-
const length = rd.readUint32();
|
|
650
|
-
if (length !== 0) {
|
|
651
|
-
const bytes = rd.readBytes(length);
|
|
652
|
-
const dec = new TextDecoder();
|
|
653
|
-
res.annots = dec.decode(new Uint8Array(bytes)).split(' ');
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return tr(res);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
const isOrData = (e) => 'prim' in e && (e.prim === 'Left' || e.prim === 'Right');
|
|
661
|
-
const isOptionData = (e) => 'prim' in e && (e.prim === 'Some' || e.prim === 'None');
|
|
662
|
-
const getWriteTransformFunc = (t) => {
|
|
663
|
-
if ((0, utils_1.isPairType)(t)) {
|
|
664
|
-
return (d) => {
|
|
665
|
-
if (!(0, utils_1.isPairData)(d)) {
|
|
666
|
-
throw new utils_1.MichelsonTypeError(t, `pair expected: ${JSON.stringify(d)}`, d);
|
|
667
|
-
}
|
|
668
|
-
(0, michelson_validator_1.assertDataListIfAny)(d);
|
|
669
|
-
// combs aren't used in pack format
|
|
670
|
-
const tc = (0, utils_1.unpackComb)('pair', t);
|
|
671
|
-
const dc = (0, utils_1.unpackComb)('Pair', d);
|
|
672
|
-
return [
|
|
673
|
-
dc,
|
|
674
|
-
(function* () {
|
|
675
|
-
for (const a of tc.args) {
|
|
676
|
-
yield getWriteTransformFunc(a);
|
|
677
|
-
}
|
|
678
|
-
})(),
|
|
679
|
-
];
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
switch (t.prim) {
|
|
683
|
-
case 'or':
|
|
684
|
-
return (d) => {
|
|
685
|
-
if (!isOrData(d)) {
|
|
686
|
-
throw new utils_1.MichelsonTypeError(t, `or expected: ${JSON.stringify(d)}`, d);
|
|
687
|
-
}
|
|
688
|
-
return [
|
|
689
|
-
d,
|
|
690
|
-
(function* () {
|
|
691
|
-
yield getWriteTransformFunc(t.args[d.prim === 'Left' ? 0 : 1]);
|
|
692
|
-
})(),
|
|
693
|
-
];
|
|
694
|
-
};
|
|
695
|
-
case 'option':
|
|
696
|
-
return (d) => {
|
|
697
|
-
if (!isOptionData(d)) {
|
|
698
|
-
throw new utils_1.MichelsonTypeError(t, `option expected: ${JSON.stringify(d)}`, d);
|
|
699
|
-
}
|
|
700
|
-
return [
|
|
701
|
-
d,
|
|
702
|
-
(function* () {
|
|
703
|
-
const dd = d;
|
|
704
|
-
// TODO: refactor and remove ts-ignore
|
|
705
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
706
|
-
// @ts-ignore
|
|
707
|
-
if (dd.prim === 'Some') {
|
|
708
|
-
yield getWriteTransformFunc(t.args[0]);
|
|
709
|
-
}
|
|
710
|
-
})(),
|
|
711
|
-
];
|
|
712
|
-
};
|
|
713
|
-
case 'list':
|
|
714
|
-
case 'set':
|
|
715
|
-
return (d) => {
|
|
716
|
-
if (!Array.isArray(d)) {
|
|
717
|
-
throw new utils_1.MichelsonTypeError(t, `${t.prim} expected: ${JSON.stringify(d)}`, d);
|
|
718
|
-
}
|
|
719
|
-
return [
|
|
720
|
-
d,
|
|
721
|
-
(function* () {
|
|
722
|
-
for (const _v of d) {
|
|
723
|
-
yield getWriteTransformFunc(t.args[0]);
|
|
724
|
-
}
|
|
725
|
-
})(),
|
|
726
|
-
];
|
|
727
|
-
};
|
|
728
|
-
case 'map':
|
|
729
|
-
return (d) => {
|
|
730
|
-
if (!Array.isArray(d)) {
|
|
731
|
-
throw new utils_1.MichelsonTypeError(t, `map expected: ${JSON.stringify(d)}`, d);
|
|
732
|
-
}
|
|
733
|
-
return [
|
|
734
|
-
d,
|
|
735
|
-
(function* () {
|
|
736
|
-
for (const _elt of d) {
|
|
737
|
-
yield (elt) => {
|
|
738
|
-
if (!('prim' in elt) || elt.prim !== 'Elt') {
|
|
739
|
-
throw new utils_1.MichelsonTypeError(t, `map element expected: ${JSON.stringify(elt)}`, elt);
|
|
740
|
-
}
|
|
741
|
-
return [
|
|
742
|
-
elt,
|
|
743
|
-
(function* () {
|
|
744
|
-
for (const a of t.args) {
|
|
745
|
-
yield getWriteTransformFunc(a);
|
|
746
|
-
}
|
|
747
|
-
})(),
|
|
748
|
-
];
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
})(),
|
|
752
|
-
];
|
|
753
|
-
};
|
|
754
|
-
case 'chain_id':
|
|
755
|
-
return (d) => {
|
|
756
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
757
|
-
throw new utils_1.MichelsonTypeError(t, `chain id expected: ${JSON.stringify(d)}`, d);
|
|
758
|
-
}
|
|
759
|
-
let bytes;
|
|
760
|
-
if ('string' in d) {
|
|
761
|
-
const id = (0, utils_1.checkDecodeTezosID)(d.string, 'ChainID');
|
|
762
|
-
if (id === null) {
|
|
763
|
-
throw new utils_1.MichelsonTypeError(t, `chain id base58 expected: ${d.string}`, d);
|
|
764
|
-
}
|
|
765
|
-
bytes = { bytes: (0, utils_1.hexBytes)(id[1]) };
|
|
766
|
-
}
|
|
767
|
-
else {
|
|
768
|
-
bytes = d;
|
|
769
|
-
}
|
|
770
|
-
return [bytes, [][Symbol.iterator]()];
|
|
771
|
-
};
|
|
772
|
-
case 'signature':
|
|
773
|
-
return (d) => {
|
|
774
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
775
|
-
throw new utils_1.MichelsonTypeError(t, `signature expected: ${JSON.stringify(d)}`, d);
|
|
776
|
-
}
|
|
777
|
-
let bytes;
|
|
778
|
-
if ('string' in d) {
|
|
779
|
-
const sig = (0, utils_1.checkDecodeTezosID)(d.string, 'ED25519Signature', 'SECP256K1Signature', 'P256Signature', 'GenericSignature');
|
|
780
|
-
if (sig === null) {
|
|
781
|
-
throw new utils_1.MichelsonTypeError(t, `signature base58 expected: ${d.string}`, d);
|
|
782
|
-
}
|
|
783
|
-
bytes = { bytes: (0, utils_1.hexBytes)(sig[1]) };
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
bytes = d;
|
|
787
|
-
}
|
|
788
|
-
return [bytes, [][Symbol.iterator]()];
|
|
789
|
-
};
|
|
790
|
-
case 'key_hash':
|
|
791
|
-
return (d) => {
|
|
792
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
793
|
-
throw new utils_1.MichelsonTypeError(t, `key hash expected: ${JSON.stringify(d)}`, d);
|
|
794
|
-
}
|
|
795
|
-
let bytes;
|
|
796
|
-
if ('string' in d) {
|
|
797
|
-
const pkh = (0, utils_1.checkDecodeTezosID)(d.string, 'ED25519PublicKeyHash', 'SECP256K1PublicKeyHash', 'P256PublicKeyHash');
|
|
798
|
-
if (pkh === null) {
|
|
799
|
-
throw new utils_1.MichelsonTypeError(t, `key hash base58 expected: ${d.string}`, d);
|
|
800
|
-
}
|
|
801
|
-
const w = new Writer();
|
|
802
|
-
writePublicKeyHash({ type: pkh[0], hash: pkh[1] }, w);
|
|
803
|
-
bytes = { bytes: (0, utils_1.hexBytes)(w.buffer) };
|
|
804
|
-
}
|
|
805
|
-
else {
|
|
806
|
-
bytes = d;
|
|
807
|
-
}
|
|
808
|
-
return [bytes, [][Symbol.iterator]()];
|
|
809
|
-
};
|
|
810
|
-
case 'key':
|
|
811
|
-
return (d) => {
|
|
812
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
813
|
-
throw new utils_1.MichelsonTypeError(t, `public key expected: ${JSON.stringify(d)}`, d);
|
|
814
|
-
}
|
|
815
|
-
let bytes;
|
|
816
|
-
if ('string' in d) {
|
|
817
|
-
const key = (0, utils_1.checkDecodeTezosID)(d.string, 'ED25519PublicKey', 'SECP256K1PublicKey', 'P256PublicKey');
|
|
818
|
-
if (key === null) {
|
|
819
|
-
throw new utils_1.MichelsonTypeError(t, `public key base58 expected: ${d.string}`, d);
|
|
820
|
-
}
|
|
821
|
-
const w = new Writer();
|
|
822
|
-
writePublicKey({ type: key[0], publicKey: key[1] }, w);
|
|
823
|
-
bytes = { bytes: (0, utils_1.hexBytes)(w.buffer) };
|
|
824
|
-
}
|
|
825
|
-
else {
|
|
826
|
-
bytes = d;
|
|
827
|
-
}
|
|
828
|
-
return [bytes, [][Symbol.iterator]()];
|
|
829
|
-
};
|
|
830
|
-
case 'address':
|
|
831
|
-
return (d) => {
|
|
832
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
833
|
-
throw new utils_1.MichelsonTypeError(t, `address expected: ${JSON.stringify(d)}`, d);
|
|
834
|
-
}
|
|
835
|
-
let bytes;
|
|
836
|
-
if ('string' in d) {
|
|
837
|
-
const s = d.string.split('%');
|
|
838
|
-
const address = (0, utils_1.checkDecodeTezosID)(s[0], 'ED25519PublicKeyHash', 'SECP256K1PublicKeyHash', 'P256PublicKeyHash', 'ContractHash');
|
|
839
|
-
if (address === null) {
|
|
840
|
-
throw new utils_1.MichelsonTypeError(t, `address base58 expected: ${d.string}`, d);
|
|
841
|
-
}
|
|
842
|
-
const w = new Writer();
|
|
843
|
-
writeAddress({ type: address[0], hash: address[1], entryPoint: s.length > 1 ? s[1] : undefined }, w);
|
|
844
|
-
bytes = { bytes: (0, utils_1.hexBytes)(w.buffer) };
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
bytes = d;
|
|
848
|
-
}
|
|
849
|
-
return [bytes, [][Symbol.iterator]()];
|
|
850
|
-
};
|
|
851
|
-
case 'timestamp':
|
|
852
|
-
return (d) => {
|
|
853
|
-
if (!('string' in d) && !('int' in d)) {
|
|
854
|
-
throw new utils_1.MichelsonTypeError(t, `timestamp expected: ${JSON.stringify(d)}`, d);
|
|
855
|
-
}
|
|
856
|
-
let int;
|
|
857
|
-
if ('string' in d) {
|
|
858
|
-
const p = (0, utils_1.parseDate)(d);
|
|
859
|
-
if (p === null) {
|
|
860
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse date: ${d.string}`, d);
|
|
861
|
-
}
|
|
862
|
-
int = { int: String(Math.floor(p.getTime() / 1000)) };
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
int = d;
|
|
866
|
-
}
|
|
867
|
-
return [int, [][Symbol.iterator]()];
|
|
868
|
-
};
|
|
869
|
-
default:
|
|
870
|
-
return writePassThrough;
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
const isPushInstruction = (e) => 'prim' in e && e.prim === 'PUSH';
|
|
874
|
-
const writePassThrough = (e) => {
|
|
875
|
-
if (isPushInstruction(e)) {
|
|
876
|
-
(0, michelson_validator_1.assertMichelsonInstruction)(e);
|
|
877
|
-
// capture inlined type definition
|
|
878
|
-
return [
|
|
879
|
-
e,
|
|
880
|
-
(function* () {
|
|
881
|
-
yield writePassThrough;
|
|
882
|
-
yield getWriteTransformFunc(e.args[0]);
|
|
883
|
-
})(),
|
|
884
|
-
];
|
|
885
|
-
}
|
|
886
|
-
return [
|
|
887
|
-
e,
|
|
888
|
-
(function* () {
|
|
889
|
-
while (true) {
|
|
890
|
-
yield writePassThrough;
|
|
891
|
-
}
|
|
892
|
-
})(),
|
|
893
|
-
];
|
|
894
|
-
};
|
|
895
|
-
/**
|
|
896
|
-
* Serializes any value of packable type to its optimized binary representation
|
|
897
|
-
* identical to the one used by PACK and UNPACK Michelson instructions.
|
|
898
|
-
* Without a type definition (not recommended) the data will be encoded as a binary form of a generic Michelson expression.
|
|
899
|
-
* Type definition allows some types like `timestamp` and `address` and other base58 representable types to be encoded to
|
|
900
|
-
* corresponding optimized binary forms borrowed from the Tezos protocol
|
|
901
|
-
*
|
|
902
|
-
* ```typescript
|
|
903
|
-
* const data: MichelsonData = {
|
|
904
|
-
* string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
|
|
905
|
-
* };
|
|
906
|
-
*
|
|
907
|
-
* const typ: MichelsonType = {
|
|
908
|
-
* prim: "address"
|
|
909
|
-
* };
|
|
910
|
-
*
|
|
911
|
-
* const packed = packData(data, typ);
|
|
912
|
-
*
|
|
913
|
-
* // 050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e
|
|
914
|
-
* ```
|
|
915
|
-
*
|
|
916
|
-
* Without a type definition the base58 encoded address will be treated as a string
|
|
917
|
-
* ```typescript
|
|
918
|
-
* const data: MichelsonData = {
|
|
919
|
-
* string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
|
|
920
|
-
* };
|
|
921
|
-
*
|
|
922
|
-
* const packed = packData(data);
|
|
923
|
-
*
|
|
924
|
-
* // 0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e
|
|
925
|
-
* ```
|
|
926
|
-
* @param d Data object
|
|
927
|
-
* @param t Optional type definition
|
|
928
|
-
* @returns Binary representation as numeric array
|
|
929
|
-
*/
|
|
930
|
-
function packData(d, t) {
|
|
931
|
-
const w = new Writer();
|
|
932
|
-
w.writeUint8(5);
|
|
933
|
-
writeExpr(d, w, t !== undefined ? getWriteTransformFunc(t) : writePassThrough);
|
|
934
|
-
return w.buffer;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Serializes any value of packable type to its optimized binary representation
|
|
938
|
-
* identical to the one used by PACK and UNPACK Michelson instructions.
|
|
939
|
-
* Same as {@link packData} but returns a `bytes` Michelson data literal instead of an array
|
|
940
|
-
*
|
|
941
|
-
* ```typescript
|
|
942
|
-
* const data: MichelsonData = {
|
|
943
|
-
* string: "2019-09-26T10:59:51Z"
|
|
944
|
-
* };
|
|
945
|
-
*
|
|
946
|
-
* const typ: MichelsonType = {
|
|
947
|
-
* prim: "timestamp"
|
|
948
|
-
* };
|
|
949
|
-
*
|
|
950
|
-
* const packed = packDataBytes(data, typ);
|
|
951
|
-
*
|
|
952
|
-
* // { bytes: "0500a7e8e4d80b" }
|
|
953
|
-
* ```
|
|
954
|
-
* @param d Data object
|
|
955
|
-
* @param t Optional type definition
|
|
956
|
-
* @returns Binary representation as a bytes literal
|
|
957
|
-
*/
|
|
958
|
-
function packDataBytes(d, t) {
|
|
959
|
-
return { bytes: (0, utils_1.hexBytes)(packData(d, t)) };
|
|
960
|
-
}
|
|
961
|
-
const getReadTransformFuncs = (t) => {
|
|
962
|
-
if ((0, utils_1.isPairType)(t)) {
|
|
963
|
-
return [
|
|
964
|
-
(d) => {
|
|
965
|
-
if (!(0, utils_1.isPairData)(d)) {
|
|
966
|
-
throw new utils_1.MichelsonTypeError(t, `pair expected: ${JSON.stringify(d)}`, d);
|
|
967
|
-
}
|
|
968
|
-
const tc = (0, utils_1.unpackComb)('pair', t);
|
|
969
|
-
return (function* () {
|
|
970
|
-
for (const a of tc.args) {
|
|
971
|
-
yield getReadTransformFuncs(a);
|
|
972
|
-
}
|
|
973
|
-
})();
|
|
974
|
-
},
|
|
975
|
-
(d) => d,
|
|
976
|
-
];
|
|
977
|
-
}
|
|
978
|
-
switch (t.prim) {
|
|
979
|
-
case 'or':
|
|
980
|
-
return [
|
|
981
|
-
(d) => {
|
|
982
|
-
if (!isOrData(d)) {
|
|
983
|
-
throw new utils_1.MichelsonTypeError(t, `or expected: ${JSON.stringify(d)}`, d);
|
|
984
|
-
}
|
|
985
|
-
return (function* () {
|
|
986
|
-
yield getReadTransformFuncs(t.args[d.prim === 'Left' ? 0 : 1]);
|
|
987
|
-
})();
|
|
988
|
-
},
|
|
989
|
-
(d) => d,
|
|
990
|
-
];
|
|
991
|
-
case 'option':
|
|
992
|
-
return [
|
|
993
|
-
(d) => {
|
|
994
|
-
if (!isOptionData(d)) {
|
|
995
|
-
throw new utils_1.MichelsonTypeError(t, `option expected: ${JSON.stringify(d)}`, d);
|
|
996
|
-
}
|
|
997
|
-
return (function* () {
|
|
998
|
-
// TODO: refactor and remove ts-ignore
|
|
999
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1000
|
-
// @ts-ignore
|
|
1001
|
-
if (d.prim === 'Some') {
|
|
1002
|
-
yield getReadTransformFuncs(t.args[0]);
|
|
1003
|
-
}
|
|
1004
|
-
})();
|
|
1005
|
-
},
|
|
1006
|
-
(d) => d,
|
|
1007
|
-
];
|
|
1008
|
-
case 'list':
|
|
1009
|
-
case 'set':
|
|
1010
|
-
return [
|
|
1011
|
-
(d) => {
|
|
1012
|
-
if (!Array.isArray(d)) {
|
|
1013
|
-
throw new utils_1.MichelsonTypeError(t, `${t.prim} expected: ${JSON.stringify(d)}`, d);
|
|
1014
|
-
}
|
|
1015
|
-
return (function* () {
|
|
1016
|
-
while (true) {
|
|
1017
|
-
yield getReadTransformFuncs(t.args[0]);
|
|
1018
|
-
}
|
|
1019
|
-
})();
|
|
1020
|
-
},
|
|
1021
|
-
(d) => d,
|
|
1022
|
-
];
|
|
1023
|
-
case 'map':
|
|
1024
|
-
return [
|
|
1025
|
-
(d) => {
|
|
1026
|
-
if (!Array.isArray(d)) {
|
|
1027
|
-
throw new utils_1.MichelsonTypeError(t, `map expected: ${JSON.stringify(d)}`, d);
|
|
1028
|
-
}
|
|
1029
|
-
return (function* () {
|
|
1030
|
-
while (true) {
|
|
1031
|
-
yield [
|
|
1032
|
-
(elt) => {
|
|
1033
|
-
if (!('prim' in elt) || elt.prim !== 'Elt') {
|
|
1034
|
-
throw new utils_1.MichelsonTypeError(t, `map element expected: ${JSON.stringify(elt)}`, elt);
|
|
1035
|
-
}
|
|
1036
|
-
return (function* () {
|
|
1037
|
-
for (const a of t.args) {
|
|
1038
|
-
yield getReadTransformFuncs(a);
|
|
1039
|
-
}
|
|
1040
|
-
})();
|
|
1041
|
-
},
|
|
1042
|
-
(elt) => elt,
|
|
1043
|
-
];
|
|
1044
|
-
}
|
|
1045
|
-
})();
|
|
1046
|
-
},
|
|
1047
|
-
(d) => d,
|
|
1048
|
-
];
|
|
1049
|
-
case 'chain_id':
|
|
1050
|
-
return [
|
|
1051
|
-
() => [][Symbol.iterator](),
|
|
1052
|
-
(d) => {
|
|
1053
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
1054
|
-
throw new utils_1.MichelsonTypeError(t, `chain id expected: ${JSON.stringify(d)}`, d);
|
|
1055
|
-
}
|
|
1056
|
-
if ('string' in d) {
|
|
1057
|
-
return d;
|
|
1058
|
-
}
|
|
1059
|
-
const bytes = (0, utils_1.parseBytes)(d.bytes);
|
|
1060
|
-
if (bytes === null) {
|
|
1061
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse bytes: ${d.bytes}`, d);
|
|
1062
|
-
}
|
|
1063
|
-
return { string: (0, utils_1.encodeTezosID)('ChainID', bytes) };
|
|
1064
|
-
},
|
|
1065
|
-
];
|
|
1066
|
-
case 'signature':
|
|
1067
|
-
return [
|
|
1068
|
-
() => [][Symbol.iterator](),
|
|
1069
|
-
(d) => {
|
|
1070
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
1071
|
-
throw new utils_1.MichelsonTypeError(t, `signature expected: ${JSON.stringify(d)}`, d);
|
|
1072
|
-
}
|
|
1073
|
-
if ('string' in d) {
|
|
1074
|
-
return d;
|
|
1075
|
-
}
|
|
1076
|
-
const bytes = (0, utils_1.parseBytes)(d.bytes);
|
|
1077
|
-
if (bytes === null) {
|
|
1078
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse bytes: ${d.bytes}`, d);
|
|
1079
|
-
}
|
|
1080
|
-
return { string: (0, utils_1.encodeTezosID)('GenericSignature', bytes) };
|
|
1081
|
-
},
|
|
1082
|
-
];
|
|
1083
|
-
case 'key_hash':
|
|
1084
|
-
return [
|
|
1085
|
-
() => [][Symbol.iterator](),
|
|
1086
|
-
(d) => {
|
|
1087
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
1088
|
-
throw new utils_1.MichelsonTypeError(t, `key hash expected: ${JSON.stringify(d)}`, d);
|
|
1089
|
-
}
|
|
1090
|
-
if ('string' in d) {
|
|
1091
|
-
return d;
|
|
1092
|
-
}
|
|
1093
|
-
const bytes = (0, utils_1.parseBytes)(d.bytes);
|
|
1094
|
-
if (bytes === null) {
|
|
1095
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse bytes: ${d.bytes}`, d);
|
|
1096
|
-
}
|
|
1097
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1098
|
-
const addr = readPublicKeyHash(rd);
|
|
1099
|
-
return {
|
|
1100
|
-
string: (0, utils_1.encodeTezosID)(addr.type, addr.hash) + (addr.entryPoint ? '%' + addr.entryPoint : ''),
|
|
1101
|
-
};
|
|
1102
|
-
},
|
|
1103
|
-
];
|
|
1104
|
-
case 'key':
|
|
1105
|
-
return [
|
|
1106
|
-
() => [][Symbol.iterator](),
|
|
1107
|
-
(d) => {
|
|
1108
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
1109
|
-
throw new utils_1.MichelsonTypeError(t, `public key expected: ${JSON.stringify(d)}`, d);
|
|
1110
|
-
}
|
|
1111
|
-
if ('string' in d) {
|
|
1112
|
-
return d;
|
|
1113
|
-
}
|
|
1114
|
-
const bytes = (0, utils_1.parseBytes)(d.bytes);
|
|
1115
|
-
if (bytes === null) {
|
|
1116
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse bytes: ${d.bytes}`, d);
|
|
1117
|
-
}
|
|
1118
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1119
|
-
const pk = readPublicKey(rd);
|
|
1120
|
-
return { string: (0, utils_1.encodeTezosID)(pk.type, pk.publicKey) };
|
|
1121
|
-
},
|
|
1122
|
-
];
|
|
1123
|
-
case 'address':
|
|
1124
|
-
return [
|
|
1125
|
-
() => [][Symbol.iterator](),
|
|
1126
|
-
(d) => {
|
|
1127
|
-
if (!('bytes' in d) && !('string' in d)) {
|
|
1128
|
-
throw new utils_1.MichelsonTypeError(t, `address expected: ${JSON.stringify(d)}`, d);
|
|
1129
|
-
}
|
|
1130
|
-
if ('string' in d) {
|
|
1131
|
-
return d;
|
|
1132
|
-
}
|
|
1133
|
-
const bytes = (0, utils_1.parseBytes)(d.bytes);
|
|
1134
|
-
if (bytes === null) {
|
|
1135
|
-
throw new utils_1.MichelsonTypeError(t, `can't parse bytes: ${d.bytes}`, d);
|
|
1136
|
-
}
|
|
1137
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1138
|
-
const addr = readAddress(rd);
|
|
1139
|
-
return {
|
|
1140
|
-
string: (0, utils_1.encodeTezosID)(addr.type, addr.hash) + (addr.entryPoint ? '%' + addr.entryPoint : ''),
|
|
1141
|
-
};
|
|
1142
|
-
},
|
|
1143
|
-
];
|
|
1144
|
-
case 'timestamp':
|
|
1145
|
-
return [
|
|
1146
|
-
() => [][Symbol.iterator](),
|
|
1147
|
-
(d) => {
|
|
1148
|
-
if (!('int' in d) && !('string' in d)) {
|
|
1149
|
-
throw new utils_1.MichelsonTypeError(t, `address expected: ${JSON.stringify(d)}`, d);
|
|
1150
|
-
}
|
|
1151
|
-
if ('string' in d) {
|
|
1152
|
-
return d;
|
|
1153
|
-
}
|
|
1154
|
-
const date = new Date(parseInt(d.int, 10) * 1000);
|
|
1155
|
-
return { string: date.toISOString().slice(0, 19) + 'Z' };
|
|
1156
|
-
},
|
|
1157
|
-
];
|
|
1158
|
-
default:
|
|
1159
|
-
return readPassThrough;
|
|
1160
|
-
}
|
|
1161
|
-
};
|
|
1162
|
-
const readPassThrough = [
|
|
1163
|
-
(e) => {
|
|
1164
|
-
if (isPushInstruction(e)) {
|
|
1165
|
-
(0, michelson_validator_1.assertMichelsonInstruction)(e);
|
|
1166
|
-
// capture inlined type definition
|
|
1167
|
-
return (function* () {
|
|
1168
|
-
yield readPassThrough;
|
|
1169
|
-
yield getReadTransformFuncs(e.args[0]);
|
|
1170
|
-
})();
|
|
1171
|
-
}
|
|
1172
|
-
return (function* () {
|
|
1173
|
-
while (true) {
|
|
1174
|
-
yield readPassThrough;
|
|
1175
|
-
}
|
|
1176
|
-
})();
|
|
1177
|
-
},
|
|
1178
|
-
(e) => e,
|
|
1179
|
-
];
|
|
1180
|
-
/**
|
|
1181
|
-
* Deserialize a byte array into the corresponding Michelson value.
|
|
1182
|
-
* Without a type definition (not recommended) the binary data will be treated as a binary form of a generic Michelson expression and returned as is.
|
|
1183
|
-
* Type definition allows some types like `timestamp` and `address` and other types usually encoded in optimized binary forms to be transformed
|
|
1184
|
-
* back to their string representations like base58 and ISO timestamps.
|
|
1185
|
-
*
|
|
1186
|
-
* ```typescript
|
|
1187
|
-
* const src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];
|
|
1188
|
-
*
|
|
1189
|
-
* const typ: MichelsonType = {
|
|
1190
|
-
* prim: "timestamp"
|
|
1191
|
-
* };
|
|
1192
|
-
*
|
|
1193
|
-
* const data = unpackData(src, typ);
|
|
1194
|
-
*
|
|
1195
|
-
* // { string: "2019-09-26T10:59:51Z" }
|
|
1196
|
-
* ```
|
|
1197
|
-
*
|
|
1198
|
-
* Same binary data without a type definition
|
|
1199
|
-
* ```typescript
|
|
1200
|
-
* const src = [0x05, 0x00, 0xa7, 0xe8, 0xe4, 0xd8, 0x0b];
|
|
1201
|
-
*
|
|
1202
|
-
* const data = unpackData(src);
|
|
1203
|
-
*
|
|
1204
|
-
* // { int: "1569495591" }
|
|
1205
|
-
* ```
|
|
1206
|
-
* @param src Byte array
|
|
1207
|
-
* @param t Optional type definition
|
|
1208
|
-
* @returns Deserialized data
|
|
1209
|
-
*/
|
|
1210
|
-
function unpackData(src, t) {
|
|
1211
|
-
const r = new Reader(src);
|
|
1212
|
-
if (r.readUint8() !== 5) {
|
|
1213
|
-
throw new Error('incorrect packed data magic number');
|
|
1214
|
-
}
|
|
1215
|
-
const ex = readExpr(r, t !== undefined ? getReadTransformFuncs(t) : readPassThrough);
|
|
1216
|
-
if ((0, michelson_validator_1.assertMichelsonData)(ex)) {
|
|
1217
|
-
return ex;
|
|
1218
|
-
}
|
|
1219
|
-
throw new Error(); // never
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Deserialize a byte array into the corresponding Michelson value.
|
|
1223
|
-
* Same as {@link unpackData} but takes a `bytes` Michelson data literal instead of an array
|
|
1224
|
-
*
|
|
1225
|
-
* ```typescript
|
|
1226
|
-
* const src = { bytes: "0500a7e8e4d80b" };
|
|
1227
|
-
*
|
|
1228
|
-
* const typ: MichelsonType = {
|
|
1229
|
-
* prim: "timestamp"
|
|
1230
|
-
* };
|
|
1231
|
-
*
|
|
1232
|
-
* const data = unpackDataBytes(src, typ);
|
|
1233
|
-
*
|
|
1234
|
-
* // { string: "2019-09-26T10:59:51Z" }
|
|
1235
|
-
* ```
|
|
1236
|
-
* @param src Bytes object
|
|
1237
|
-
* @param t Optional type definition
|
|
1238
|
-
* @returns Deserialized data
|
|
1239
|
-
*/
|
|
1240
|
-
function unpackDataBytes(src, t) {
|
|
1241
|
-
const bytes = (0, utils_1.parseBytes)(src.bytes);
|
|
1242
|
-
if (bytes === null) {
|
|
1243
|
-
throw new Error(`can't parse bytes: "${src.bytes}"`);
|
|
1244
|
-
}
|
|
1245
|
-
return unpackData(bytes, t);
|
|
1246
|
-
}
|
|
1247
|
-
// helper functions also used by validator
|
|
1248
|
-
function decodeAddressBytes(b) {
|
|
1249
|
-
const bytes = (0, utils_1.parseBytes)(b.bytes);
|
|
1250
|
-
if (bytes === null) {
|
|
1251
|
-
throw new Error(`can't parse bytes: "${b.bytes}"`);
|
|
1252
|
-
}
|
|
1253
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1254
|
-
return readAddress(rd);
|
|
1255
|
-
}
|
|
1256
|
-
function decodePublicKeyHashBytes(b) {
|
|
1257
|
-
const bytes = (0, utils_1.parseBytes)(b.bytes);
|
|
1258
|
-
if (bytes === null) {
|
|
1259
|
-
throw new Error(`can't parse bytes: "${b.bytes}"`);
|
|
1260
|
-
}
|
|
1261
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1262
|
-
return readPublicKeyHash(rd);
|
|
1263
|
-
}
|
|
1264
|
-
function decodePublicKeyBytes(b) {
|
|
1265
|
-
const bytes = (0, utils_1.parseBytes)(b.bytes);
|
|
1266
|
-
if (bytes === null) {
|
|
1267
|
-
throw new Error(`can't parse bytes: "${b.bytes}"`);
|
|
1268
|
-
}
|
|
1269
|
-
const rd = new Reader(new Uint8Array(bytes));
|
|
1270
|
-
return readPublicKey(rd);
|
|
1271
|
-
}
|