@taquito/wallet-connect 24.3.0-beta.0 → 24.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/lib/taquito/src/batch/constants.js +16 -0
- package/dist/lib/taquito/src/batch/rpc-batch-provider.js +327 -0
- package/dist/lib/taquito/src/constants.js +135 -0
- package/dist/lib/taquito/src/context.js +178 -0
- package/dist/lib/taquito/src/contract/big-map.js +57 -0
- package/dist/lib/taquito/src/contract/compose.js +6 -0
- package/dist/lib/taquito/src/contract/constants.js +4 -0
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-factory.js +18 -0
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-interface.js +2 -0
- package/dist/lib/taquito/src/contract/contract-methods/contract-method-object-param.js +72 -0
- package/dist/lib/taquito/src/contract/contract-methods/contract-on-chain-view.js +111 -0
- package/dist/lib/taquito/src/contract/contract.js +158 -0
- package/dist/lib/taquito/src/contract/errors.js +140 -0
- package/dist/lib/taquito/src/contract/index.js +30 -0
- package/dist/lib/taquito/src/contract/interface.js +2 -0
- package/dist/lib/taquito/src/contract/manager-lambda.js +71 -0
- package/dist/lib/taquito/src/contract/prepare.js +231 -0
- package/dist/lib/taquito/src/contract/rpc-contract-provider.js +675 -0
- package/dist/lib/taquito/src/contract/sapling-state-abstraction.js +24 -0
- package/dist/lib/taquito/src/contract/semantic.js +43 -0
- package/dist/lib/taquito/src/contract/view_lambda.js +27 -0
- package/dist/lib/taquito/src/errors.js +42 -0
- package/dist/lib/taquito/src/estimate/errors.js +16 -0
- package/dist/lib/taquito/src/estimate/estimate-provider-interface.js +2 -0
- package/dist/lib/taquito/src/estimate/estimate.js +176 -0
- package/dist/lib/taquito/src/estimate/index.js +20 -0
- package/dist/lib/taquito/src/estimate/rpc-estimate-provider.js +640 -0
- package/dist/lib/taquito/src/extension/extension.js +2 -0
- package/dist/lib/taquito/src/forger/composite-forger.js +32 -0
- package/dist/lib/taquito/src/forger/errors.js +30 -0
- package/dist/lib/taquito/src/forger/rpc-forger.js +12 -0
- package/dist/lib/taquito/src/forger/taquito-local-forger.js +21 -0
- package/dist/lib/taquito/src/global-constants/default-global-constants-provider.js +35 -0
- package/dist/lib/taquito/src/global-constants/errors.js +30 -0
- package/dist/lib/taquito/src/global-constants/interface-global-constants-provider.js +2 -0
- package/dist/lib/taquito/src/global-constants/noop-global-constants-provider.js +10 -0
- package/dist/lib/taquito/src/import-key.js +40 -0
- package/dist/lib/taquito/src/injector/helper.js +18 -0
- package/dist/lib/taquito/src/injector/interface.js +2 -0
- package/dist/lib/taquito/src/injector/rpc-injector.js +27 -0
- package/dist/lib/taquito/src/operations/ballot-operation.js +32 -0
- package/dist/lib/taquito/src/operations/batch-operation.js +69 -0
- package/dist/lib/taquito/src/operations/delegate-operation.js +54 -0
- package/dist/lib/taquito/src/operations/drain-delegate-operation.js +31 -0
- package/dist/lib/taquito/src/operations/errors.js +133 -0
- package/dist/lib/taquito/src/operations/failing-noop-operation.js +2 -0
- package/dist/lib/taquito/src/operations/increase-paid-storage-operation.js +49 -0
- package/dist/lib/taquito/src/operations/index.js +54 -0
- package/dist/lib/taquito/src/operations/operations.js +193 -0
- package/dist/lib/taquito/src/operations/origination-operation.js +78 -0
- package/dist/lib/taquito/src/operations/proposals-operation.js +29 -0
- package/dist/lib/taquito/src/operations/register-global-constant-operation.js +52 -0
- package/dist/lib/taquito/src/operations/reveal-operation.js +74 -0
- package/dist/lib/taquito/src/operations/smart-rollup-add-messages-operation.js +44 -0
- package/dist/lib/taquito/src/operations/smart-rollup-execute-outbox-message-operation.js +53 -0
- package/dist/lib/taquito/src/operations/smart-rollup-originate-operation.js +50 -0
- package/dist/lib/taquito/src/operations/transaction-operation.js +73 -0
- package/dist/lib/taquito/src/operations/transfer-ticket-operation.js +47 -0
- package/dist/lib/taquito/src/operations/types.js +88 -0
- package/dist/lib/taquito/src/operations/update-companion-key-operation.js +55 -0
- package/dist/lib/taquito/src/operations/update-consensus-key-operation.js +55 -0
- package/dist/lib/taquito/src/packer/interface.js +2 -0
- package/dist/lib/taquito/src/packer/michel-codec-packer.js +11 -0
- package/dist/lib/taquito/src/packer/rpc-packer.js +12 -0
- package/dist/lib/taquito/src/parser/interface.js +2 -0
- package/dist/lib/taquito/src/parser/michel-codec-parser.js +110 -0
- package/dist/lib/taquito/src/parser/noop-parser.js +9 -0
- package/dist/lib/taquito/src/prepare/index.js +18 -0
- package/dist/lib/taquito/src/prepare/interface.js +2 -0
- package/dist/lib/taquito/src/prepare/prepare-provider.js +1049 -0
- package/dist/lib/taquito/src/provider.js +363 -0
- package/dist/lib/taquito/src/read-provider/interface.js +2 -0
- package/dist/lib/taquito/src/read-provider/rpc-read-adapter.js +183 -0
- package/dist/lib/taquito/src/signer/errors.js +17 -0
- package/dist/lib/taquito/src/signer/noop.js +23 -0
- package/dist/lib/taquito/src/subscribe/create-observable-from-subscription.js +20 -0
- package/dist/lib/taquito/src/subscribe/errors.js +30 -0
- package/dist/lib/taquito/src/subscribe/filters.js +96 -0
- package/dist/lib/taquito/src/subscribe/interface.js +2 -0
- package/dist/lib/taquito/src/subscribe/observable-subscription.js +79 -0
- package/dist/lib/taquito/src/subscribe/polling-subcribe-provider.js +118 -0
- package/dist/lib/taquito/src/taquito.js +404 -0
- package/dist/lib/taquito/src/tz/interface.js +2 -0
- package/dist/lib/taquito/src/tz/rpc-tz-provider.js +46 -0
- package/dist/lib/taquito/src/version.js +8 -0
- package/dist/lib/taquito/src/wallet/batch-operation.js +71 -0
- package/dist/lib/taquito/src/wallet/delegation-operation.js +42 -0
- package/dist/lib/taquito/src/wallet/errors.js +40 -0
- package/dist/lib/taquito/src/wallet/increase-paid-storage-operation.js +42 -0
- package/dist/lib/taquito/src/wallet/index.js +25 -0
- package/dist/lib/taquito/src/wallet/interface.js +2 -0
- package/dist/lib/taquito/src/wallet/legacy.js +51 -0
- package/dist/lib/taquito/src/wallet/operation-factory.js +88 -0
- package/dist/lib/taquito/src/wallet/operation.js +221 -0
- package/dist/lib/taquito/src/wallet/origination-operation.js +53 -0
- package/dist/lib/taquito/src/wallet/receipt.js +46 -0
- package/dist/lib/taquito/src/wallet/register-global-constant-operation.js +45 -0
- package/dist/lib/taquito/src/wallet/transaction-operation.js +38 -0
- package/dist/lib/taquito/src/wallet/transfer-ticket-operation.js +38 -0
- package/dist/lib/taquito/src/wallet/wallet.js +445 -0
- package/dist/lib/taquito-core/src/errors.js +351 -0
- package/dist/lib/taquito-core/src/signer-interfaces.js +2 -0
- package/dist/lib/taquito-core/src/taquito-core.js +22 -0
- package/dist/lib/taquito-http-utils/src/errors.js +103 -0
- package/dist/lib/taquito-http-utils/src/status_code.js +322 -0
- package/dist/lib/taquito-http-utils/src/taquito-http-utils.js +308 -0
- package/dist/lib/taquito-http-utils/src/transport-errors.js +141 -0
- package/dist/lib/{version.js → taquito-http-utils/src/version.js} +2 -2
- package/dist/lib/taquito-local-forging/src/codec.js +543 -0
- package/dist/lib/taquito-local-forging/src/constants.js +291 -0
- package/dist/lib/taquito-local-forging/src/decoder.js +64 -0
- package/dist/lib/taquito-local-forging/src/encoder.js +63 -0
- package/dist/lib/taquito-local-forging/src/errors.js +179 -0
- package/dist/lib/taquito-local-forging/src/interface.js +2 -0
- package/dist/lib/taquito-local-forging/src/michelson/codec.js +283 -0
- package/dist/lib/taquito-local-forging/src/protocols.js +60 -0
- package/dist/lib/taquito-local-forging/src/schema/operation.js +259 -0
- package/dist/lib/taquito-local-forging/src/taquito-local-forging.js +117 -0
- package/dist/lib/taquito-local-forging/src/uint8array-consumer.js +35 -0
- package/dist/lib/taquito-local-forging/src/utils.js +18 -0
- package/dist/lib/taquito-local-forging/src/validator.js +57 -0
- package/dist/lib/taquito-local-forging/src/version.js +8 -0
- package/dist/lib/taquito-michel-codec/src/base58.js +255 -0
- package/dist/lib/taquito-michel-codec/src/binary.js +1271 -0
- package/dist/lib/taquito-michel-codec/src/errors.js +90 -0
- package/dist/lib/taquito-michel-codec/src/formatters.js +58 -0
- package/dist/lib/taquito-michel-codec/src/global-constants.js +12 -0
- package/dist/lib/taquito-michel-codec/src/macros.js +551 -0
- package/dist/lib/taquito-michel-codec/src/micheline-emitter.js +128 -0
- package/dist/lib/taquito-michel-codec/src/micheline-parser.js +402 -0
- package/dist/lib/taquito-michel-codec/src/micheline.js +5 -0
- package/dist/lib/taquito-michel-codec/src/michelson-contract.js +93 -0
- package/dist/lib/taquito-michel-codec/src/michelson-typecheck.js +1756 -0
- package/dist/lib/taquito-michel-codec/src/michelson-types.js +83 -0
- package/dist/lib/taquito-michel-codec/src/michelson-validator.js +833 -0
- package/dist/lib/taquito-michel-codec/src/scan.js +128 -0
- package/dist/lib/taquito-michel-codec/src/taquito-michel-codec.js +38 -0
- package/dist/lib/taquito-michel-codec/src/utils.js +323 -0
- package/dist/lib/taquito-michel-codec/src/version.js +8 -0
- package/dist/lib/taquito-michelson-encoder/src/constants.js +11 -0
- package/dist/lib/taquito-michelson-encoder/src/errors.js +38 -0
- package/dist/lib/taquito-michelson-encoder/src/michelson-map.js +201 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/errors.js +127 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/event-schema.js +52 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/parameter.js +113 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/storage.js +260 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/types.js +2 -0
- package/dist/lib/taquito-michelson-encoder/src/schema/view-schema.js +90 -0
- package/dist/lib/taquito-michelson-encoder/src/taquito-michelson-encoder.js +36 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/bigmap.js +130 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-fr.js +86 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-g1.js +76 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/bls12-381-g2.js +76 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/chain-id.js +78 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/chest-key.js +74 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/chest.js +74 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/address.js +116 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/bool.js +59 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/bytes.js +90 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/int.js +90 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/key_hash.js +90 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/mutez.js +90 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/nat.js +93 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/string.js +48 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/comparable/timestamp.js +66 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/constant.js +80 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/contract.js +86 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/createToken.js +35 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/key.js +97 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/lambda.js +55 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/list.js +85 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/map.js +112 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/never.js +61 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/operation.js +39 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/option.js +88 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/or.js +282 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/pair.js +233 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-state.js +84 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-transaction-deprecated.js +74 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/sapling-transaction.js +74 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/set.js +82 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/signature.js +82 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/ticket-deprecated.js +92 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/ticket.js +92 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/token.js +100 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/tokens.js +75 -0
- package/dist/lib/taquito-michelson-encoder/src/tokens/unit.js +52 -0
- package/dist/lib/taquito-michelson-encoder/src/version.js +8 -0
- package/dist/lib/taquito-rpc/src/opkind.js +49 -0
- package/dist/lib/taquito-rpc/src/rpc-client-interface.js +60 -0
- package/dist/lib/taquito-rpc/src/rpc-client-modules/rpc-cache.js +1118 -0
- package/dist/lib/taquito-rpc/src/taquito-rpc.js +990 -0
- package/dist/lib/taquito-rpc/src/types.js +114 -0
- package/dist/lib/taquito-rpc/src/utils/utils.js +65 -0
- package/dist/lib/taquito-rpc/src/version.js +8 -0
- package/dist/lib/taquito-signer/src/bls-key.js +104 -0
- package/dist/lib/taquito-signer/src/derivation-tools/ecdsa.js +156 -0
- package/dist/lib/taquito-signer/src/derivation-tools/ed25519.js +82 -0
- package/dist/lib/taquito-signer/src/derivation-tools/index.js +79 -0
- package/dist/lib/taquito-signer/src/derivation-tools/types.js +4 -0
- package/dist/lib/taquito-signer/src/derivation-tools/utils.js +16 -0
- package/dist/lib/taquito-signer/src/ec-key.js +196 -0
- package/dist/lib/taquito-signer/src/ed-key.js +130 -0
- package/dist/lib/taquito-signer/src/errors.js +77 -0
- package/dist/lib/taquito-signer/src/helpers.js +44 -0
- package/dist/lib/taquito-signer/src/in-memory-signer.js +240 -0
- package/dist/lib/taquito-signer/src/key-interface.js +6 -0
- package/dist/lib/taquito-signer/src/taquito-signer.js +28 -0
- package/dist/lib/taquito-signer/src/version.js +8 -0
- package/dist/lib/taquito-utils/src/constants.js +203 -0
- package/dist/lib/taquito-utils/src/encoding.js +606 -0
- package/dist/lib/taquito-utils/src/errors.js +45 -0
- package/dist/lib/taquito-utils/src/format.js +29 -0
- package/dist/lib/taquito-utils/src/taquito-utils.js +42 -0
- package/dist/lib/taquito-utils/src/validators.js +236 -0
- package/dist/lib/taquito-utils/src/verify-signature.js +136 -0
- package/dist/lib/taquito-utils/src/version.js +8 -0
- package/dist/lib/{taquito-wallet-connect.js → taquito-wallet-connect/src/taquito-wallet-connect.js} +50 -33
- package/dist/lib/taquito-wallet-connect/src/version.js +8 -0
- package/dist/taquito-wallet-connect.es6.js +46 -32
- package/dist/taquito-wallet-connect.es6.js.map +1 -1
- package/dist/taquito-wallet-connect.umd.js +46 -32
- package/dist/taquito-wallet-connect.umd.js.map +1 -1
- package/dist/types/taquito/src/batch/constants.d.ts +3 -0
- package/dist/types/taquito/src/batch/rpc-batch-provider.d.ts +139 -0
- package/dist/types/taquito/src/constants.d.ts +81 -0
- package/dist/types/taquito/src/context.d.ts +100 -0
- package/dist/types/taquito/src/contract/big-map.d.ts +35 -0
- package/dist/types/taquito/src/contract/compose.d.ts +5 -0
- package/dist/types/taquito/src/contract/constants.d.ts +1 -0
- package/dist/types/taquito/src/contract/contract-methods/contract-method-factory.d.ts +14 -0
- package/dist/types/taquito/src/contract/contract-methods/contract-method-interface.d.ts +28 -0
- package/dist/types/taquito/src/contract/contract-methods/contract-method-object-param.d.ts +39 -0
- package/dist/types/taquito/src/contract/contract-methods/contract-on-chain-view.d.ts +43 -0
- package/dist/types/taquito/src/contract/contract.d.ts +75 -0
- package/dist/types/taquito/src/contract/errors.d.ts +83 -0
- package/dist/types/taquito/src/contract/index.d.ts +11 -0
- package/dist/types/taquito/src/contract/interface.d.ts +254 -0
- package/dist/types/taquito/src/contract/manager-lambda.d.ts +73 -0
- package/dist/types/taquito/src/contract/prepare.d.ts +18 -0
- package/dist/types/taquito/src/contract/rpc-contract-provider.d.ts +270 -0
- package/dist/types/taquito/src/contract/sapling-state-abstraction.d.ts +17 -0
- package/dist/types/taquito/src/contract/semantic.d.ts +7 -0
- package/dist/types/taquito/src/contract/view_lambda.d.ts +34 -0
- package/dist/types/taquito/src/errors.d.ts +26 -0
- package/dist/types/taquito/src/estimate/errors.d.ts +8 -0
- package/dist/types/taquito/src/estimate/estimate-provider-interface.d.ts +153 -0
- package/dist/types/taquito/src/estimate/estimate.d.ts +111 -0
- package/dist/types/taquito/src/estimate/index.d.ts +4 -0
- package/dist/types/taquito/src/estimate/rpc-estimate-provider.d.ts +174 -0
- package/dist/types/taquito/src/extension/extension.d.ts +4 -0
- package/dist/types/taquito/src/forger/composite-forger.d.ts +6 -0
- package/dist/types/taquito/src/forger/errors.d.ts +16 -0
- package/dist/types/taquito/src/forger/rpc-forger.d.ts +7 -0
- package/dist/types/taquito/src/forger/taquito-local-forger.d.ts +8 -0
- package/dist/types/taquito/src/global-constants/default-global-constants-provider.d.ts +18 -0
- package/dist/types/taquito/src/global-constants/errors.d.ts +16 -0
- package/dist/types/taquito/src/global-constants/interface-global-constants-provider.d.ts +11 -0
- package/dist/types/taquito/src/global-constants/noop-global-constants-provider.d.ts +5 -0
- package/dist/types/taquito/src/import-key.d.ts +13 -0
- package/dist/types/taquito/src/injector/helper.d.ts +2 -0
- package/dist/types/taquito/src/injector/interface.d.ts +5 -0
- package/dist/types/taquito/src/injector/rpc-injector.d.ts +7 -0
- package/dist/types/taquito/src/operations/ballot-operation.d.ts +18 -0
- package/dist/types/taquito/src/operations/batch-operation.d.ts +19 -0
- package/dist/types/taquito/src/operations/delegate-operation.d.ts +24 -0
- package/dist/types/taquito/src/operations/drain-delegate-operation.d.ts +17 -0
- package/dist/types/taquito/src/operations/errors.d.ts +50 -0
- package/dist/types/taquito/src/operations/failing-noop-operation.d.ts +17 -0
- package/dist/types/taquito/src/operations/increase-paid-storage-operation.d.ts +23 -0
- package/dist/types/taquito/src/operations/index.d.ts +18 -0
- package/dist/types/taquito/src/operations/operations.d.ts +35 -0
- package/dist/types/taquito/src/operations/origination-operation.d.ts +35 -0
- package/dist/types/taquito/src/operations/proposals-operation.d.ts +17 -0
- package/dist/types/taquito/src/operations/register-global-constant-operation.d.ts +25 -0
- package/dist/types/taquito/src/operations/reveal-operation.d.ts +25 -0
- package/dist/types/taquito/src/operations/smart-rollup-add-messages-operation.d.ts +20 -0
- package/dist/types/taquito/src/operations/smart-rollup-execute-outbox-message-operation.d.ts +24 -0
- package/dist/types/taquito/src/operations/smart-rollup-originate-operation.d.ts +23 -0
- package/dist/types/taquito/src/operations/transaction-operation.d.ts +28 -0
- package/dist/types/taquito/src/operations/transfer-ticket-operation.d.ts +22 -0
- package/dist/types/taquito/src/operations/types.d.ts +823 -0
- package/dist/types/taquito/src/operations/update-companion-key-operation.d.ts +23 -0
- package/dist/types/taquito/src/operations/update-consensus-key-operation.d.ts +23 -0
- package/dist/types/taquito/src/packer/interface.d.ts +4 -0
- package/dist/types/taquito/src/packer/michel-codec-packer.d.ts +5 -0
- package/dist/types/taquito/src/packer/rpc-packer.d.ts +8 -0
- package/dist/types/taquito/src/parser/interface.d.ts +4 -0
- package/dist/types/taquito/src/parser/michel-codec-parser.d.ts +16 -0
- package/dist/types/taquito/src/parser/noop-parser.d.ts +5 -0
- package/dist/types/taquito/src/prepare/index.d.ts +2 -0
- package/dist/types/taquito/src/prepare/interface.d.ts +152 -0
- package/dist/types/taquito/src/prepare/prepare-provider.d.ts +187 -0
- package/dist/types/taquito/src/provider.d.ts +50 -0
- package/dist/types/taquito/src/read-provider/interface.d.ts +132 -0
- package/dist/types/taquito/src/read-provider/rpc-read-adapter.d.ts +130 -0
- package/dist/types/taquito/src/signer/errors.d.ts +8 -0
- package/dist/types/taquito/src/signer/noop.d.ts +11 -0
- package/dist/types/taquito/src/subscribe/create-observable-from-subscription.d.ts +4 -0
- package/dist/types/taquito/src/subscribe/errors.d.ts +18 -0
- package/dist/types/taquito/src/subscribe/filters.d.ts +6 -0
- package/dist/types/taquito/src/subscribe/interface.d.ts +48 -0
- package/dist/types/taquito/src/subscribe/observable-subscription.d.ts +21 -0
- package/dist/types/taquito/src/subscribe/polling-subcribe-provider.d.ts +23 -0
- package/dist/types/taquito/src/taquito.d.ts +248 -0
- package/dist/types/taquito/src/tz/interface.d.ts +20 -0
- package/dist/types/taquito/src/tz/rpc-tz-provider.d.ts +13 -0
- package/dist/types/taquito/src/version.d.ts +4 -0
- package/dist/types/taquito/src/wallet/batch-operation.d.ts +13 -0
- package/dist/types/taquito/src/wallet/delegation-operation.d.ts +12 -0
- package/dist/types/taquito/src/wallet/errors.d.ts +24 -0
- package/dist/types/taquito/src/wallet/increase-paid-storage-operation.d.ts +12 -0
- package/dist/types/taquito/src/wallet/index.d.ts +9 -0
- package/dist/types/taquito/src/wallet/interface.d.ts +66 -0
- package/dist/types/taquito/src/wallet/legacy.d.ts +21 -0
- package/dist/types/taquito/src/wallet/operation-factory.d.ts +32 -0
- package/dist/types/taquito/src/wallet/operation.d.ts +55 -0
- package/dist/types/taquito/src/wallet/origination-operation.d.ts +14 -0
- package/dist/types/taquito/src/wallet/receipt.d.ts +16 -0
- package/dist/types/taquito/src/wallet/register-global-constant-operation.d.ts +13 -0
- package/dist/types/taquito/src/wallet/transaction-operation.d.ts +12 -0
- package/dist/types/taquito/src/wallet/transfer-ticket-operation.d.ts +12 -0
- package/dist/types/taquito/src/wallet/wallet.d.ts +196 -0
- package/dist/types/taquito-core/src/errors.d.ts +213 -0
- package/dist/types/taquito-core/src/signer-interfaces.d.ts +38 -0
- package/dist/types/taquito-core/src/taquito-core.d.ts +6 -0
- package/dist/types/taquito-http-utils/src/errors.d.ts +63 -0
- package/dist/types/taquito-http-utils/src/status_code.d.ts +318 -0
- package/dist/types/taquito-http-utils/src/taquito-http-utils.d.ts +58 -0
- package/dist/types/taquito-http-utils/src/transport-errors.d.ts +28 -0
- package/dist/types/taquito-local-forging/src/codec.d.ts +79 -0
- package/dist/types/taquito-local-forging/src/constants.d.ts +75 -0
- package/dist/types/taquito-local-forging/src/decoder.d.ts +5 -0
- package/dist/types/taquito-local-forging/src/encoder.d.ts +4 -0
- package/dist/types/taquito-local-forging/src/errors.d.ts +109 -0
- package/dist/types/taquito-local-forging/src/interface.d.ts +9 -0
- package/dist/types/taquito-local-forging/src/michelson/codec.d.ts +49 -0
- package/dist/types/taquito-local-forging/src/protocols.d.ts +27 -0
- package/dist/types/taquito-local-forging/src/schema/operation.d.ts +198 -0
- package/dist/types/taquito-local-forging/src/taquito-local-forging.d.ts +27 -0
- package/dist/types/taquito-local-forging/src/uint8array-consumer.d.ts +10 -0
- package/dist/types/taquito-local-forging/src/utils.d.ts +3 -0
- package/dist/types/taquito-local-forging/src/validator.d.ts +13 -0
- package/dist/types/taquito-local-forging/src/version.d.ts +4 -0
- package/dist/types/taquito-michel-codec/src/base58.d.ts +13 -0
- package/dist/types/taquito-michel-codec/src/binary.d.ts +127 -0
- package/dist/types/taquito-michel-codec/src/errors.d.ts +57 -0
- package/dist/types/taquito-michel-codec/src/formatters.d.ts +6 -0
- package/dist/types/taquito-michel-codec/src/global-constants.d.ts +3 -0
- package/dist/types/taquito-michel-codec/src/macros.d.ts +13 -0
- package/dist/types/taquito-michel-codec/src/micheline-emitter.d.ts +17 -0
- package/dist/types/taquito-michel-codec/src/micheline-parser.d.ts +130 -0
- package/dist/types/taquito-michel-codec/src/micheline.d.ts +44 -0
- package/dist/types/taquito-michel-codec/src/michelson-contract.d.ts +24 -0
- package/dist/types/taquito-michel-codec/src/michelson-typecheck.d.ts +38 -0
- package/dist/types/taquito-michel-codec/src/michelson-types.d.ts +147 -0
- package/dist/types/taquito-michel-codec/src/michelson-validator.d.ts +66 -0
- package/dist/types/taquito-michel-codec/src/scan.d.ts +26 -0
- package/dist/types/taquito-michel-codec/src/taquito-michel-codec.d.ts +16 -0
- package/dist/types/taquito-michel-codec/src/utils.d.ts +76 -0
- package/dist/types/taquito-michel-codec/src/version.d.ts +4 -0
- package/dist/types/taquito-michelson-encoder/src/constants.d.ts +8 -0
- package/dist/types/taquito-michelson-encoder/src/errors.d.ts +17 -0
- package/dist/types/taquito-michelson-encoder/src/michelson-map.d.ts +82 -0
- package/dist/types/taquito-michelson-encoder/src/schema/errors.d.ts +83 -0
- package/dist/types/taquito-michelson-encoder/src/schema/event-schema.d.ts +12 -0
- package/dist/types/taquito-michelson-encoder/src/schema/parameter.d.ts +54 -0
- package/dist/types/taquito-michelson-encoder/src/schema/storage.d.ts +97 -0
- package/dist/types/taquito-michelson-encoder/src/schema/types.d.ts +105 -0
- package/dist/types/taquito-michelson-encoder/src/schema/view-schema.d.ts +53 -0
- package/dist/types/taquito-michelson-encoder/src/taquito-michelson-encoder.d.ts +16 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/bigmap.d.ts +51 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-fr.d.ts +51 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-g1.d.ts +47 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/bls12-381-g2.d.ts +47 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/chain-id.d.ts +51 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/chest-key.d.ts +47 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/chest.d.ts +47 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/address.d.ts +61 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/bool.d.ts +32 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/bytes.d.ts +52 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/int.d.ts +56 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/key_hash.d.ts +55 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/mutez.d.ts +53 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/nat.d.ts +55 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/string.d.ts +31 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/comparable/timestamp.d.ts +34 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/constant.d.ts +51 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/contract.d.ts +48 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/createToken.d.ts +18 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/key.d.ts +55 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/lambda.d.ts +24 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/list.d.ts +46 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/map.d.ts +47 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/never.d.ts +41 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/operation.d.ts +24 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/option.d.ts +37 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/or.d.ts +53 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/pair.d.ts +50 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-state.d.ts +44 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-transaction-deprecated.d.ts +40 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/sapling-transaction.d.ts +40 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/set.d.ts +43 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/signature.d.ts +53 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/ticket-deprecated.d.ts +38 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/ticket.d.ts +38 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/token.d.ts +68 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/tokens.d.ts +36 -0
- package/dist/types/taquito-michelson-encoder/src/tokens/unit.d.ts +34 -0
- package/dist/types/taquito-michelson-encoder/src/version.d.ts +4 -0
- package/dist/types/taquito-rpc/src/opkind.d.ts +45 -0
- package/dist/types/taquito-rpc/src/rpc-client-interface.d.ts +126 -0
- package/dist/types/taquito-rpc/src/rpc-client-modules/rpc-cache.d.ts +473 -0
- package/dist/types/taquito-rpc/src/taquito-rpc.d.ts +483 -0
- package/dist/types/taquito-rpc/src/types.d.ts +2362 -0
- package/dist/types/taquito-rpc/src/utils/utils.d.ts +14 -0
- package/dist/types/taquito-rpc/src/version.d.ts +4 -0
- package/dist/types/taquito-signer/src/bls-key.d.ts +21 -0
- package/dist/types/taquito-signer/src/derivation-tools/ecdsa.d.ts +49 -0
- package/dist/types/taquito-signer/src/derivation-tools/ed25519.d.ts +33 -0
- package/dist/types/taquito-signer/src/derivation-tools/index.d.ts +12 -0
- package/dist/types/taquito-signer/src/derivation-tools/types.d.ts +10 -0
- package/dist/types/taquito-signer/src/derivation-tools/utils.d.ts +1 -0
- package/dist/types/taquito-signer/src/ec-key.d.ts +42 -0
- package/dist/types/taquito-signer/src/ed-key.d.ts +39 -0
- package/dist/types/taquito-signer/src/errors.d.ts +51 -0
- package/dist/types/taquito-signer/src/helpers.d.ts +10 -0
- package/dist/types/taquito-signer/src/in-memory-signer.d.ts +56 -0
- package/dist/types/taquito-signer/src/key-interface.d.ts +37 -0
- package/dist/types/taquito-signer/src/taquito-signer.d.ts +10 -0
- package/dist/types/taquito-signer/src/version.d.ts +4 -0
- package/dist/types/taquito-utils/src/constants.d.ts +78 -0
- package/dist/types/taquito-utils/src/encoding.d.ts +184 -0
- package/dist/types/taquito-utils/src/errors.d.ts +20 -0
- package/dist/types/taquito-utils/src/format.d.ts +4 -0
- package/dist/types/taquito-utils/src/taquito-utils.d.ts +11 -0
- package/dist/types/taquito-utils/src/validators.d.ts +167 -0
- package/dist/types/taquito-utils/src/verify-signature.d.ts +22 -0
- package/dist/types/taquito-utils/src/version.d.ts +4 -0
- package/dist/types/{taquito-wallet-connect.d.ts → taquito-wallet-connect/src/taquito-wallet-connect.d.ts} +4 -2
- package/dist/types/taquito-wallet-connect/src/version.d.ts +4 -0
- package/package.json +9 -35
- /package/dist/lib/{errors.js → taquito-wallet-connect/src/errors.js} +0 -0
- /package/dist/lib/{types.js → taquito-wallet-connect/src/types.js} +0 -0
- /package/dist/types/{version.d.ts → taquito-http-utils/src/version.d.ts} +0 -0
- /package/dist/types/{errors.d.ts → taquito-wallet-connect/src/errors.d.ts} +0 -0
- /package/dist/types/{types.d.ts → taquito-wallet-connect/src/types.d.ts} +0 -0
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MichelsonValidationError = exports.instructionIDs = void 0;
|
|
4
|
+
exports.assertMichelsonInstruction = assertMichelsonInstruction;
|
|
5
|
+
exports.assertMichelsonComparableType = assertMichelsonComparableType;
|
|
6
|
+
exports.assertMichelsonPackableType = assertMichelsonPackableType;
|
|
7
|
+
exports.assertMichelsonPushableType = assertMichelsonPushableType;
|
|
8
|
+
exports.assertMichelsonStorableType = assertMichelsonStorableType;
|
|
9
|
+
exports.assertMichelsonPassableType = assertMichelsonPassableType;
|
|
10
|
+
exports.assertMichelsonBigMapStorableType = assertMichelsonBigMapStorableType;
|
|
11
|
+
exports.assertViewNameValid = assertViewNameValid;
|
|
12
|
+
exports.assertMichelsonType = assertMichelsonType;
|
|
13
|
+
exports.assertMichelsonData = assertMichelsonData;
|
|
14
|
+
exports.assertMichelsonContract = assertMichelsonContract;
|
|
15
|
+
exports.isMichelsonScript = isMichelsonScript;
|
|
16
|
+
exports.isMichelsonData = isMichelsonData;
|
|
17
|
+
exports.isMichelsonCode = isMichelsonCode;
|
|
18
|
+
exports.isMichelsonType = isMichelsonType;
|
|
19
|
+
exports.isInstruction = isInstruction;
|
|
20
|
+
exports.assertDataListIfAny = assertDataListIfAny;
|
|
21
|
+
const utils_1 = require("./utils");
|
|
22
|
+
// Michelson validator
|
|
23
|
+
const maxViewNameLength = 31;
|
|
24
|
+
const noArgInstructionIDs = {
|
|
25
|
+
ABS: true,
|
|
26
|
+
ADD: true,
|
|
27
|
+
ADDRESS: true,
|
|
28
|
+
AMOUNT: true,
|
|
29
|
+
AND: true,
|
|
30
|
+
APPLY: true,
|
|
31
|
+
BALANCE: true,
|
|
32
|
+
BLAKE2B: true,
|
|
33
|
+
CAR: true,
|
|
34
|
+
CDR: true,
|
|
35
|
+
CHAIN_ID: true,
|
|
36
|
+
CHECK_SIGNATURE: true,
|
|
37
|
+
COMPARE: true,
|
|
38
|
+
CONCAT: true,
|
|
39
|
+
CONS: true,
|
|
40
|
+
EDIV: true,
|
|
41
|
+
EQ: true,
|
|
42
|
+
EXEC: true,
|
|
43
|
+
FAILWITH: true,
|
|
44
|
+
GE: true,
|
|
45
|
+
GET_AND_UPDATE: true,
|
|
46
|
+
GT: true,
|
|
47
|
+
HASH_KEY: true,
|
|
48
|
+
IMPLICIT_ACCOUNT: true,
|
|
49
|
+
INT: true,
|
|
50
|
+
ISNAT: true,
|
|
51
|
+
JOIN_TICKETS: true,
|
|
52
|
+
KECCAK: true,
|
|
53
|
+
LE: true,
|
|
54
|
+
LEVEL: true,
|
|
55
|
+
LSL: true,
|
|
56
|
+
LSR: true,
|
|
57
|
+
LT: true,
|
|
58
|
+
MEM: true,
|
|
59
|
+
MUL: true,
|
|
60
|
+
NEG: true,
|
|
61
|
+
NEQ: true,
|
|
62
|
+
NEVER: true,
|
|
63
|
+
NOT: true,
|
|
64
|
+
NOW: true,
|
|
65
|
+
OR: true,
|
|
66
|
+
PACK: true,
|
|
67
|
+
PAIRING_CHECK: true,
|
|
68
|
+
READ_TICKET: true,
|
|
69
|
+
SAPLING_VERIFY_UPDATE: true,
|
|
70
|
+
SELF: true,
|
|
71
|
+
SELF_ADDRESS: true,
|
|
72
|
+
SENDER: true,
|
|
73
|
+
SET_DELEGATE: true,
|
|
74
|
+
SHA256: true,
|
|
75
|
+
SHA3: true,
|
|
76
|
+
SHA512: true,
|
|
77
|
+
SIZE: true,
|
|
78
|
+
SLICE: true,
|
|
79
|
+
SOME: true,
|
|
80
|
+
SOURCE: true,
|
|
81
|
+
SPLIT_TICKET: true,
|
|
82
|
+
SUB: true,
|
|
83
|
+
SWAP: true,
|
|
84
|
+
TICKET: true,
|
|
85
|
+
TICKET_DEPRECATED: true,
|
|
86
|
+
TOTAL_VOTING_POWER: true,
|
|
87
|
+
TRANSFER_TOKENS: true,
|
|
88
|
+
UNIT: true,
|
|
89
|
+
VOTING_POWER: true,
|
|
90
|
+
XOR: true,
|
|
91
|
+
RENAME: true,
|
|
92
|
+
OPEN_CHEST: true,
|
|
93
|
+
SUB_MUTEZ: true,
|
|
94
|
+
MIN_BLOCK_TIME: true,
|
|
95
|
+
BYTES: true,
|
|
96
|
+
NAT: true,
|
|
97
|
+
IS_IMPLICIT_ACCOUNT: true,
|
|
98
|
+
INDEX_ADDRESS: true,
|
|
99
|
+
GET_ADDRESS_INDEX: true,
|
|
100
|
+
};
|
|
101
|
+
exports.instructionIDs = Object.assign({}, noArgInstructionIDs, {
|
|
102
|
+
CONTRACT: true,
|
|
103
|
+
CREATE_CONTRACT: true,
|
|
104
|
+
DIG: true,
|
|
105
|
+
DIP: true,
|
|
106
|
+
DROP: true,
|
|
107
|
+
DUG: true,
|
|
108
|
+
DUP: true,
|
|
109
|
+
EMIT: true,
|
|
110
|
+
EMPTY_BIG_MAP: true,
|
|
111
|
+
EMPTY_MAP: true,
|
|
112
|
+
EMPTY_SET: true,
|
|
113
|
+
GET: true,
|
|
114
|
+
IF: true,
|
|
115
|
+
IF_CONS: true,
|
|
116
|
+
IF_LEFT: true,
|
|
117
|
+
IF_NONE: true,
|
|
118
|
+
ITER: true,
|
|
119
|
+
LAMBDA: true,
|
|
120
|
+
LAMBDA_REC: true,
|
|
121
|
+
LEFT: true,
|
|
122
|
+
LOOP: true,
|
|
123
|
+
LOOP_LEFT: true,
|
|
124
|
+
MAP: true,
|
|
125
|
+
NIL: true,
|
|
126
|
+
NONE: true,
|
|
127
|
+
PAIR: true,
|
|
128
|
+
PUSH: true,
|
|
129
|
+
RIGHT: true,
|
|
130
|
+
SAPLING_EMPTY_STATE: true,
|
|
131
|
+
UNPACK: true,
|
|
132
|
+
UNPAIR: true,
|
|
133
|
+
UPDATE: true,
|
|
134
|
+
CAST: true,
|
|
135
|
+
VIEW: true,
|
|
136
|
+
});
|
|
137
|
+
const simpleComparableTypeIDs = {
|
|
138
|
+
unit: true,
|
|
139
|
+
never: true,
|
|
140
|
+
bool: true,
|
|
141
|
+
int: true,
|
|
142
|
+
nat: true,
|
|
143
|
+
string: true,
|
|
144
|
+
chain_id: true,
|
|
145
|
+
bytes: true,
|
|
146
|
+
mutez: true,
|
|
147
|
+
key_hash: true,
|
|
148
|
+
key: true,
|
|
149
|
+
signature: true,
|
|
150
|
+
timestamp: true,
|
|
151
|
+
address: true,
|
|
152
|
+
tx_rollup_l2_address: true,
|
|
153
|
+
};
|
|
154
|
+
const typeIDs = Object.assign({}, simpleComparableTypeIDs, {
|
|
155
|
+
or: true,
|
|
156
|
+
pair: true,
|
|
157
|
+
set: true,
|
|
158
|
+
big_map: true,
|
|
159
|
+
contract: true,
|
|
160
|
+
lambda: true,
|
|
161
|
+
list: true,
|
|
162
|
+
map: true,
|
|
163
|
+
operation: true,
|
|
164
|
+
option: true,
|
|
165
|
+
bls12_381_g1: true,
|
|
166
|
+
bls12_381_g2: true,
|
|
167
|
+
bls12_381_fr: true,
|
|
168
|
+
sapling_transaction: true,
|
|
169
|
+
sapling_transaction_deprecated: true,
|
|
170
|
+
sapling_state: true,
|
|
171
|
+
ticket: true,
|
|
172
|
+
chest_key: true,
|
|
173
|
+
chest: true,
|
|
174
|
+
});
|
|
175
|
+
class MichelsonValidationError extends utils_1.MichelsonError {
|
|
176
|
+
/**
|
|
177
|
+
* @param val Value of a node caused the error
|
|
178
|
+
* @param message An error message
|
|
179
|
+
*/
|
|
180
|
+
constructor(val, message) {
|
|
181
|
+
super(val, message);
|
|
182
|
+
this.val = val;
|
|
183
|
+
this.message = message;
|
|
184
|
+
this.name = 'MichelsonValidationError';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.MichelsonValidationError = MichelsonValidationError;
|
|
188
|
+
function isPrim(ex) {
|
|
189
|
+
return 'prim' in ex;
|
|
190
|
+
}
|
|
191
|
+
function isPrimOrSeq(ex) {
|
|
192
|
+
return Array.isArray(ex) || 'prim' in ex;
|
|
193
|
+
}
|
|
194
|
+
function assertPrim(ex) {
|
|
195
|
+
if (isPrim(ex)) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
throw new MichelsonValidationError(ex, 'prim expression expected');
|
|
199
|
+
}
|
|
200
|
+
function assertSeq(ex) {
|
|
201
|
+
if (Array.isArray(ex)) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
throw new MichelsonValidationError(ex, 'sequence expression expected');
|
|
205
|
+
}
|
|
206
|
+
function assertPrimOrSeq(ex) {
|
|
207
|
+
if (isPrimOrSeq(ex)) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
throw new MichelsonValidationError(ex, 'prim or sequence expression expected');
|
|
211
|
+
}
|
|
212
|
+
function assertNatural(i) {
|
|
213
|
+
if (i.int[0] === '-') {
|
|
214
|
+
throw new MichelsonValidationError(i, 'natural number expected');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function assertIntLiteral(ex) {
|
|
218
|
+
if ('int' in ex) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
throw new MichelsonValidationError(ex, 'int literal expected');
|
|
222
|
+
}
|
|
223
|
+
function assertStringLiteral(ex) {
|
|
224
|
+
if ('string' in ex) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
throw new MichelsonValidationError(ex, 'string literal expected');
|
|
228
|
+
}
|
|
229
|
+
// usually an address
|
|
230
|
+
function assertStringOrBytes(ex) {
|
|
231
|
+
if ('string' in ex || 'bytes' in ex) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
throw new MichelsonValidationError(ex, 'string or bytes literal expected');
|
|
235
|
+
}
|
|
236
|
+
function assertArgs(ex, n) {
|
|
237
|
+
if ((n === 0 && ex.args === undefined) || ex.args?.length === n) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
throw new MichelsonValidationError(ex, `${n} arguments expected`);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Checks if the node is a valid Michelson code (sequence of instructions).
|
|
244
|
+
* This is a type guard function which either returns true of throws an exception.
|
|
245
|
+
* @param ex An AST node
|
|
246
|
+
*/
|
|
247
|
+
function assertMichelsonInstruction(ex) {
|
|
248
|
+
if (Array.isArray(ex)) {
|
|
249
|
+
for (const n of ex) {
|
|
250
|
+
if (!Array.isArray(n) && !isPrim(n)) {
|
|
251
|
+
throw new MichelsonValidationError(ex, 'sequence or prim expected');
|
|
252
|
+
}
|
|
253
|
+
assertMichelsonInstruction(n);
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
if (assertPrim(ex)) {
|
|
258
|
+
if (Object.prototype.hasOwnProperty.call(noArgInstructionIDs, ex.prim)) {
|
|
259
|
+
assertArgs(ex, 0);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
switch (ex.prim) {
|
|
263
|
+
case 'DROP':
|
|
264
|
+
case 'PAIR':
|
|
265
|
+
case 'UNPAIR':
|
|
266
|
+
case 'DUP':
|
|
267
|
+
case 'UPDATE':
|
|
268
|
+
case 'GET':
|
|
269
|
+
if (ex.args !== undefined && assertArgs(ex, 1)) {
|
|
270
|
+
/* istanbul ignore else */
|
|
271
|
+
if (assertIntLiteral(ex.args[0])) {
|
|
272
|
+
assertNatural(ex.args[0]);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
276
|
+
case 'DIG':
|
|
277
|
+
case 'DUG':
|
|
278
|
+
case 'SAPLING_EMPTY_STATE':
|
|
279
|
+
/* istanbul ignore else */
|
|
280
|
+
if (assertArgs(ex, 1)) {
|
|
281
|
+
/* istanbul ignore else */
|
|
282
|
+
if (assertIntLiteral(ex.args[0])) {
|
|
283
|
+
assertNatural(ex.args[0]);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case 'NONE':
|
|
288
|
+
case 'LEFT':
|
|
289
|
+
case 'RIGHT':
|
|
290
|
+
case 'NIL':
|
|
291
|
+
case 'CAST':
|
|
292
|
+
/* istanbul ignore else */
|
|
293
|
+
if (assertArgs(ex, 1)) {
|
|
294
|
+
assertMichelsonType(ex.args[0]);
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
case 'UNPACK':
|
|
298
|
+
/* istanbul ignore else */
|
|
299
|
+
if (assertArgs(ex, 1)) {
|
|
300
|
+
assertMichelsonPackableType(ex.args[0]);
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case 'CONTRACT':
|
|
304
|
+
/* istanbul ignore else */
|
|
305
|
+
if (assertArgs(ex, 1)) {
|
|
306
|
+
assertMichelsonPassableType(ex.args[0]);
|
|
307
|
+
}
|
|
308
|
+
break;
|
|
309
|
+
case 'IF_NONE':
|
|
310
|
+
case 'IF_LEFT':
|
|
311
|
+
case 'IF_CONS':
|
|
312
|
+
case 'IF':
|
|
313
|
+
/* istanbul ignore else */
|
|
314
|
+
if (assertArgs(ex, 2)) {
|
|
315
|
+
/* istanbul ignore else */
|
|
316
|
+
if (assertSeq(ex.args[0])) {
|
|
317
|
+
assertMichelsonInstruction(ex.args[0]);
|
|
318
|
+
}
|
|
319
|
+
/* istanbul ignore else */
|
|
320
|
+
if (assertSeq(ex.args[1])) {
|
|
321
|
+
assertMichelsonInstruction(ex.args[1]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
case 'MAP':
|
|
326
|
+
case 'ITER':
|
|
327
|
+
case 'LOOP':
|
|
328
|
+
case 'LOOP_LEFT':
|
|
329
|
+
/* istanbul ignore else */
|
|
330
|
+
if (assertArgs(ex, 1)) {
|
|
331
|
+
assertMichelsonInstruction(ex.args[0]);
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
case 'CREATE_CONTRACT':
|
|
335
|
+
/* istanbul ignore else */
|
|
336
|
+
if (assertArgs(ex, 1)) {
|
|
337
|
+
assertMichelsonContract(ex.args[0]);
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
case 'DIP':
|
|
341
|
+
if (ex.args?.length === 2) {
|
|
342
|
+
/* istanbul ignore else */
|
|
343
|
+
if (assertIntLiteral(ex.args[0])) {
|
|
344
|
+
assertNatural(ex.args[0]);
|
|
345
|
+
}
|
|
346
|
+
/* istanbul ignore else */
|
|
347
|
+
if (assertSeq(ex.args[1])) {
|
|
348
|
+
assertMichelsonInstruction(ex.args[1]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else if (ex.args?.length === 1) {
|
|
352
|
+
/* istanbul ignore else */
|
|
353
|
+
if (assertSeq(ex.args[0])) {
|
|
354
|
+
assertMichelsonInstruction(ex.args[0]);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
throw new MichelsonValidationError(ex, '1 or 2 arguments expected');
|
|
359
|
+
}
|
|
360
|
+
break;
|
|
361
|
+
case 'PUSH':
|
|
362
|
+
/* istanbul ignore else */
|
|
363
|
+
if (assertArgs(ex, 2)) {
|
|
364
|
+
assertMichelsonPushableType(ex.args[0]);
|
|
365
|
+
assertMichelsonData(ex.args[1]);
|
|
366
|
+
}
|
|
367
|
+
break;
|
|
368
|
+
case 'EMPTY_SET':
|
|
369
|
+
/* istanbul ignore else */
|
|
370
|
+
if (assertArgs(ex, 1)) {
|
|
371
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
374
|
+
case 'EMPTY_MAP':
|
|
375
|
+
/* istanbul ignore else */
|
|
376
|
+
if (assertArgs(ex, 2)) {
|
|
377
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
378
|
+
assertMichelsonType(ex.args[1]);
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
case 'EMPTY_BIG_MAP':
|
|
382
|
+
/* istanbul ignore else */
|
|
383
|
+
if (assertArgs(ex, 2)) {
|
|
384
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
385
|
+
assertMichelsonBigMapStorableType(ex.args[1]);
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
case 'LAMBDA_REC':
|
|
389
|
+
case 'LAMBDA':
|
|
390
|
+
/* istanbul ignore else */
|
|
391
|
+
if (assertArgs(ex, 3)) {
|
|
392
|
+
assertMichelsonType(ex.args[0]);
|
|
393
|
+
assertMichelsonType(ex.args[1]);
|
|
394
|
+
/* istanbul ignore else */
|
|
395
|
+
if (assertSeq(ex.args[2])) {
|
|
396
|
+
assertMichelsonInstruction(ex.args[2]);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
case 'VIEW':
|
|
401
|
+
/* istanbul ignore else */
|
|
402
|
+
if (assertArgs(ex, 2)) {
|
|
403
|
+
if (assertStringLiteral(ex.args[0])) {
|
|
404
|
+
assertViewNameValid(ex.args[0]);
|
|
405
|
+
}
|
|
406
|
+
if (assertMichelsonType(ex.args[1])) {
|
|
407
|
+
assertMichelsonPushableType(ex.args[1]);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
case 'EMIT':
|
|
412
|
+
if (ex.args && ex.args.length > 0) {
|
|
413
|
+
assertArgs(ex, 1);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
assertArgs(ex, 0);
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
default:
|
|
420
|
+
throw new MichelsonValidationError(ex, 'instruction expected');
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
function assertMichelsonComparableType(ex) {
|
|
426
|
+
/* istanbul ignore else */
|
|
427
|
+
if (assertPrimOrSeq(ex)) {
|
|
428
|
+
if (Array.isArray(ex) || ex.prim === 'pair' || ex.prim === 'or' || ex.prim === 'option') {
|
|
429
|
+
traverseType(ex, (ex) => assertMichelsonComparableType(ex));
|
|
430
|
+
}
|
|
431
|
+
else if (!Object.prototype.hasOwnProperty.call(simpleComparableTypeIDs, ex.prim)) {
|
|
432
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type is not comparable`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
function assertMichelsonPackableType(ex) {
|
|
438
|
+
/* istanbul ignore else */
|
|
439
|
+
if (assertPrimOrSeq(ex)) {
|
|
440
|
+
if (isPrim(ex)) {
|
|
441
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim) ||
|
|
442
|
+
ex.prim === 'big_map' ||
|
|
443
|
+
ex.prim === 'operation' ||
|
|
444
|
+
ex.prim === 'sapling_state' ||
|
|
445
|
+
ex.prim === 'ticket') {
|
|
446
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used inside PACK/UNPACK instructions`);
|
|
447
|
+
}
|
|
448
|
+
traverseType(ex, (ex) => assertMichelsonPackableType(ex));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
function assertMichelsonPushableType(ex) {
|
|
454
|
+
/* istanbul ignore else */
|
|
455
|
+
if (assertPrimOrSeq(ex)) {
|
|
456
|
+
if (isPrim(ex)) {
|
|
457
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim) ||
|
|
458
|
+
ex.prim === 'big_map' ||
|
|
459
|
+
ex.prim === 'operation' ||
|
|
460
|
+
ex.prim === 'sapling_state' ||
|
|
461
|
+
ex.prim === 'ticket' ||
|
|
462
|
+
ex.prim === 'contract') {
|
|
463
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be pushed`);
|
|
464
|
+
}
|
|
465
|
+
traverseType(ex, (ex) => assertMichelsonPushableType(ex));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
function assertMichelsonStorableType(ex) {
|
|
471
|
+
/* istanbul ignore else */
|
|
472
|
+
if (assertPrimOrSeq(ex)) {
|
|
473
|
+
if (isPrim(ex)) {
|
|
474
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim) ||
|
|
475
|
+
ex.prim === 'operation' ||
|
|
476
|
+
ex.prim === 'contract') {
|
|
477
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used as part of a storage`);
|
|
478
|
+
}
|
|
479
|
+
traverseType(ex, (ex) => assertMichelsonStorableType(ex));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
function assertMichelsonPassableType(ex) {
|
|
485
|
+
/* istanbul ignore else */
|
|
486
|
+
if (assertPrimOrSeq(ex)) {
|
|
487
|
+
if (isPrim(ex)) {
|
|
488
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim) || ex.prim === 'operation') {
|
|
489
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used as part of a parameter`);
|
|
490
|
+
}
|
|
491
|
+
traverseType(ex, (ex) => assertMichelsonPassableType(ex));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
function assertMichelsonBigMapStorableType(ex) {
|
|
497
|
+
/* istanbul ignore else */
|
|
498
|
+
if (assertPrimOrSeq(ex)) {
|
|
499
|
+
if (isPrim(ex)) {
|
|
500
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim) ||
|
|
501
|
+
ex.prim === 'big_map' ||
|
|
502
|
+
ex.prim === 'operation' ||
|
|
503
|
+
ex.prim === 'sapling_state') {
|
|
504
|
+
throw new MichelsonValidationError(ex, `${ex.prim}: type can't be used inside a big_map`);
|
|
505
|
+
}
|
|
506
|
+
traverseType(ex, (ex) => assertMichelsonBigMapStorableType(ex));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
const viewRe = new RegExp('^[a-zA-Z0-9_.%@]*$');
|
|
512
|
+
function assertViewNameValid(name) {
|
|
513
|
+
if (name.string.length > maxViewNameLength) {
|
|
514
|
+
throw new MichelsonValidationError(name, `view name too long: ${name.string}`);
|
|
515
|
+
}
|
|
516
|
+
if (!viewRe.test(name.string)) {
|
|
517
|
+
throw new MichelsonValidationError(name, `invalid character(s) in view name: ${name.string}`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Checks if the node is a valid Michelson type expression.
|
|
522
|
+
* This is a type guard function which either returns true of throws an exception.
|
|
523
|
+
* @param ex An AST node
|
|
524
|
+
*/
|
|
525
|
+
function assertMichelsonType(ex) {
|
|
526
|
+
/* istanbul ignore else */
|
|
527
|
+
if (assertPrimOrSeq(ex)) {
|
|
528
|
+
if (isPrim(ex)) {
|
|
529
|
+
if (!Object.prototype.hasOwnProperty.call(typeIDs, ex.prim)) {
|
|
530
|
+
throw new MichelsonValidationError(ex, 'type expected');
|
|
531
|
+
}
|
|
532
|
+
traverseType(ex, (ex) => assertMichelsonType(ex));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
function traverseType(ex, cb) {
|
|
538
|
+
if (Array.isArray(ex) || ex.prim === 'pair') {
|
|
539
|
+
const args = Array.isArray(ex) ? ex : ex.args;
|
|
540
|
+
if (args === undefined || args.length < 2) {
|
|
541
|
+
throw new MichelsonValidationError(ex, 'at least 2 arguments expected');
|
|
542
|
+
}
|
|
543
|
+
args.forEach((a) => {
|
|
544
|
+
if (assertPrimOrSeq(a)) {
|
|
545
|
+
cb(a);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
switch (ex.prim) {
|
|
551
|
+
case 'option':
|
|
552
|
+
case 'list':
|
|
553
|
+
/* istanbul ignore else */
|
|
554
|
+
if (assertArgs(ex, 1) && assertPrimOrSeq(ex.args[0])) {
|
|
555
|
+
cb(ex.args[0]);
|
|
556
|
+
}
|
|
557
|
+
break;
|
|
558
|
+
case 'contract':
|
|
559
|
+
/* istanbul ignore else */
|
|
560
|
+
if (assertArgs(ex, 1)) {
|
|
561
|
+
assertMichelsonPassableType(ex.args[0]);
|
|
562
|
+
}
|
|
563
|
+
break;
|
|
564
|
+
case 'or':
|
|
565
|
+
/* istanbul ignore else */
|
|
566
|
+
if (assertArgs(ex, 2) && assertPrimOrSeq(ex.args[0]) && assertPrimOrSeq(ex.args[1])) {
|
|
567
|
+
cb(ex.args[0]);
|
|
568
|
+
cb(ex.args[1]);
|
|
569
|
+
}
|
|
570
|
+
break;
|
|
571
|
+
case 'lambda':
|
|
572
|
+
/* istanbul ignore else */
|
|
573
|
+
if (assertArgs(ex, 2)) {
|
|
574
|
+
assertMichelsonType(ex.args[0]);
|
|
575
|
+
assertMichelsonType(ex.args[1]);
|
|
576
|
+
}
|
|
577
|
+
break;
|
|
578
|
+
case 'set':
|
|
579
|
+
/* istanbul ignore else */
|
|
580
|
+
if (assertArgs(ex, 1)) {
|
|
581
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
case 'map':
|
|
585
|
+
/* istanbul ignore else */
|
|
586
|
+
if (assertArgs(ex, 2) && assertPrimOrSeq(ex.args[0]) && assertPrimOrSeq(ex.args[1])) {
|
|
587
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
588
|
+
cb(ex.args[1]);
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
591
|
+
case 'big_map':
|
|
592
|
+
/* istanbul ignore else */
|
|
593
|
+
if (assertArgs(ex, 2) && assertPrimOrSeq(ex.args[0]) && assertPrimOrSeq(ex.args[1])) {
|
|
594
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
595
|
+
assertMichelsonBigMapStorableType(ex.args[1]);
|
|
596
|
+
cb(ex.args[1]);
|
|
597
|
+
}
|
|
598
|
+
break;
|
|
599
|
+
case 'ticket':
|
|
600
|
+
/* istanbul ignore else */
|
|
601
|
+
if (assertArgs(ex, 1) && assertPrimOrSeq(ex.args[0])) {
|
|
602
|
+
assertMichelsonComparableType(ex.args[0]);
|
|
603
|
+
}
|
|
604
|
+
break;
|
|
605
|
+
case 'sapling_state':
|
|
606
|
+
case 'sapling_transaction':
|
|
607
|
+
if (assertArgs(ex, 1)) {
|
|
608
|
+
assertIntLiteral(ex.args[0]);
|
|
609
|
+
}
|
|
610
|
+
break;
|
|
611
|
+
default:
|
|
612
|
+
assertArgs(ex, 0);
|
|
613
|
+
}
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Checks if the node is a valid Michelson data literal such as `(Pair {Elt "0" 0} 0)`.
|
|
618
|
+
* This is a type guard function which either returns true of throws an exception.
|
|
619
|
+
* @param ex An AST node
|
|
620
|
+
*/
|
|
621
|
+
function assertMichelsonData(ex) {
|
|
622
|
+
if ('int' in ex || 'string' in ex || 'bytes' in ex) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
if (Array.isArray(ex)) {
|
|
626
|
+
let mapElts = 0;
|
|
627
|
+
for (const n of ex) {
|
|
628
|
+
if (isPrim(n) && n.prim === 'Elt') {
|
|
629
|
+
/* istanbul ignore else */
|
|
630
|
+
if (assertArgs(n, 2)) {
|
|
631
|
+
assertMichelsonData(n.args[0]);
|
|
632
|
+
assertMichelsonData(n.args[1]);
|
|
633
|
+
}
|
|
634
|
+
mapElts++;
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
assertMichelsonData(n);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (mapElts !== 0 && mapElts !== ex.length) {
|
|
641
|
+
throw new MichelsonValidationError(ex, "data entries and map elements can't be intermixed");
|
|
642
|
+
}
|
|
643
|
+
return true;
|
|
644
|
+
}
|
|
645
|
+
if (isPrim(ex)) {
|
|
646
|
+
switch (ex.prim) {
|
|
647
|
+
case 'Unit':
|
|
648
|
+
case 'True':
|
|
649
|
+
case 'False':
|
|
650
|
+
case 'None':
|
|
651
|
+
assertArgs(ex, 0);
|
|
652
|
+
break;
|
|
653
|
+
case 'Pair':
|
|
654
|
+
/* istanbul ignore else */
|
|
655
|
+
if (ex.args === undefined || ex.args.length < 2) {
|
|
656
|
+
throw new MichelsonValidationError(ex, 'at least 2 arguments expected');
|
|
657
|
+
}
|
|
658
|
+
for (const a of ex.args) {
|
|
659
|
+
assertMichelsonData(a);
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
662
|
+
case 'Left':
|
|
663
|
+
case 'Right':
|
|
664
|
+
case 'Some':
|
|
665
|
+
/* istanbul ignore else */
|
|
666
|
+
if (assertArgs(ex, 1)) {
|
|
667
|
+
assertMichelsonData(ex.args[0]);
|
|
668
|
+
}
|
|
669
|
+
break;
|
|
670
|
+
case 'Lambda_rec':
|
|
671
|
+
if (ex.args) {
|
|
672
|
+
assertMichelsonInstruction(ex.args);
|
|
673
|
+
}
|
|
674
|
+
break;
|
|
675
|
+
case 'Ticket':
|
|
676
|
+
if (assertArgs(ex, 4)) {
|
|
677
|
+
assertStringOrBytes(ex.args[0]);
|
|
678
|
+
assertMichelsonType(ex.args[1]);
|
|
679
|
+
assertMichelsonData(ex.args[2]);
|
|
680
|
+
assertIntLiteral(ex.args[3]);
|
|
681
|
+
}
|
|
682
|
+
break;
|
|
683
|
+
default:
|
|
684
|
+
if (Object.prototype.hasOwnProperty.call(exports.instructionIDs, ex.prim)) {
|
|
685
|
+
assertMichelsonInstruction(ex);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
throw new MichelsonValidationError(ex, 'data entry or instruction expected');
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
throw new MichelsonValidationError(ex, 'data entry expected');
|
|
694
|
+
}
|
|
695
|
+
return true;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Checks if the node is a valid Michelson smart contract source containing all required and valid properties such as `parameter`, `storage` and `code`.
|
|
699
|
+
* This is a type guard function which either returns true of throws an exception.
|
|
700
|
+
* @param ex An AST node
|
|
701
|
+
*/
|
|
702
|
+
function assertMichelsonContract(ex) {
|
|
703
|
+
/* istanbul ignore else */
|
|
704
|
+
if (assertSeq(ex)) {
|
|
705
|
+
const toplevelSec = {};
|
|
706
|
+
const views = {};
|
|
707
|
+
for (const sec of ex) {
|
|
708
|
+
if (assertPrim(sec)) {
|
|
709
|
+
if (sec.prim !== 'view') {
|
|
710
|
+
if (sec.prim in toplevelSec) {
|
|
711
|
+
throw new MichelsonValidationError(ex, `duplicate contract section: ${sec.prim}`);
|
|
712
|
+
}
|
|
713
|
+
toplevelSec[sec.prim] = true;
|
|
714
|
+
}
|
|
715
|
+
/* istanbul ignore else */
|
|
716
|
+
switch (sec.prim) {
|
|
717
|
+
case 'code':
|
|
718
|
+
if (assertArgs(sec, 1)) {
|
|
719
|
+
/* istanbul ignore else */
|
|
720
|
+
if (assertSeq(sec.args[0])) {
|
|
721
|
+
assertMichelsonInstruction(sec.args[0]);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
break;
|
|
725
|
+
case 'parameter':
|
|
726
|
+
if (assertArgs(sec, 1)) {
|
|
727
|
+
assertMichelsonPassableType(sec.args[0]);
|
|
728
|
+
}
|
|
729
|
+
if (sec.annots) {
|
|
730
|
+
throw new MichelsonValidationError(sec, 'Annotation must be part of the parameter type');
|
|
731
|
+
}
|
|
732
|
+
break;
|
|
733
|
+
case 'storage':
|
|
734
|
+
if (assertArgs(sec, 1)) {
|
|
735
|
+
assertMichelsonStorableType(sec.args[0]);
|
|
736
|
+
}
|
|
737
|
+
break;
|
|
738
|
+
case 'view':
|
|
739
|
+
if (assertArgs(sec, 4)) {
|
|
740
|
+
if (assertStringLiteral(sec.args[0])) {
|
|
741
|
+
const name = sec.args[0];
|
|
742
|
+
if (name.string in views) {
|
|
743
|
+
throw new MichelsonValidationError(ex, `duplicate view name: ${name.string}`);
|
|
744
|
+
}
|
|
745
|
+
views[name.string] = true;
|
|
746
|
+
assertViewNameValid(name);
|
|
747
|
+
}
|
|
748
|
+
assertMichelsonPushableType(sec.args[1]);
|
|
749
|
+
assertMichelsonPushableType(sec.args[2]);
|
|
750
|
+
if (assertSeq(sec.args[3])) {
|
|
751
|
+
assertMichelsonInstruction(sec.args[3]);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
break;
|
|
755
|
+
default:
|
|
756
|
+
throw new MichelsonValidationError(ex, `unexpected contract section: ${sec.prim}`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Checks if the node is a valid Michelson smart contract source containing all required and valid properties such as `parameter`, `storage` and `code`.
|
|
765
|
+
* @param ex An AST node
|
|
766
|
+
*/
|
|
767
|
+
function isMichelsonScript(ex) {
|
|
768
|
+
try {
|
|
769
|
+
assertMichelsonContract(ex);
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
catch {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Checks if the node is a valid Michelson data literal such as `(Pair {Elt "0" 0} 0)`.
|
|
778
|
+
* @param ex An AST node
|
|
779
|
+
*/
|
|
780
|
+
function isMichelsonData(ex) {
|
|
781
|
+
try {
|
|
782
|
+
assertMichelsonData(ex);
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
catch {
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Checks if the node is a valid Michelson code (sequence of instructions).
|
|
791
|
+
* @param ex An AST node
|
|
792
|
+
*/
|
|
793
|
+
function isMichelsonCode(ex) {
|
|
794
|
+
try {
|
|
795
|
+
assertMichelsonInstruction(ex);
|
|
796
|
+
return true;
|
|
797
|
+
}
|
|
798
|
+
catch {
|
|
799
|
+
return false;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Checks if the node is a valid Michelson type expression.
|
|
804
|
+
* @param ex An AST node
|
|
805
|
+
*/
|
|
806
|
+
function isMichelsonType(ex) {
|
|
807
|
+
try {
|
|
808
|
+
assertMichelsonType(ex);
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
catch {
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
function isInstruction(p) {
|
|
816
|
+
return Object.prototype.hasOwnProperty.call(exports.instructionIDs, p.prim);
|
|
817
|
+
}
|
|
818
|
+
function assertDataListIfAny(d) {
|
|
819
|
+
if (!Array.isArray(d)) {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
for (const v of d) {
|
|
823
|
+
if ('prim' in v) {
|
|
824
|
+
if (isInstruction(v)) {
|
|
825
|
+
throw new utils_1.MichelsonError(d, `Instruction outside of a lambda: ${JSON.stringify(d)}`);
|
|
826
|
+
}
|
|
827
|
+
else if (v.prim === 'Elt') {
|
|
828
|
+
throw new utils_1.MichelsonError(d, `Elt item outside of a map literal: ${JSON.stringify(d)}`);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
return true;
|
|
833
|
+
}
|