diff --git a/.gitignore b/.gitignore index 5263672b..d47c7524 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,13 @@ # Documentation here: https://yarnpkg.com/features/zero-installs !/.yarn/cache #/.pnp.* + +/build/ +/confio/ +/cosmos/ +/cosmos_proto/ +/cosmwasm/ +/gogoproto/ +/google/ +/ibc/ +/tendermint/ diff --git a/.gitmodules b/.gitmodules index f2965bbc..5a2988c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "cosmos-sdk"] - path = cosmos-sdk - url = https://github.com/cosmos/cosmos-sdk +[submodule "wasmd"] + path = wasmd-0.16 + url = https://github.com/cosmwasm/wasmd diff --git a/.pnp.js b/.pnp.js index 8ed257e2..dcd3010b 100755 --- a/.pnp.js +++ b/.pnp.js @@ -21,16 +21,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { { "name": "cosmjs-types", "reference": "workspace:." - }, - { - "name": "@cosmjs-types/cosmos", - "reference": "workspace:packages/cosmos" } ], "enableTopLevelFallback": true, "ignorePatternData": "(^(?:\\.yarn\\/sdks(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)|$))$)", "fallbackExclusionList": [ - ["@cosmjs-types/cosmos", ["workspace:packages/cosmos"]], ["cosmjs-types", ["workspace:."]] ], "fallbackPool": [ @@ -42,21 +37,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { [null, { "packageLocation": "./", "packageDependencies": [ - ["ts-proto", "npm:1.81.1"] - ], - "linkType": "SOFT", - }] - ]], - ["@cosmjs-types/cosmos", [ - ["workspace:packages/cosmos", { - "packageLocation": "./packages/cosmos/", - "packageDependencies": [ - ["@cosmjs-types/cosmos", "workspace:packages/cosmos"], ["@types/long", "npm:4.0.1"], - ["@types/node", "npm:15.6.1"], + ["@types/node", "npm:15.6.2"], ["long", "npm:4.0.0"], ["prettier", "npm:2.3.0"], ["protobufjs", "npm:6.10.2"], + ["ts-proto", "npm:1.81.1"], ["typescript", "patch:typescript@npm%3A4.0.7#builtin::version=4.0.7&hash=a45b0e"] ], "linkType": "SOFT", @@ -177,6 +163,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/node", "npm:15.6.1"] ], "linkType": "HARD", + }], + ["npm:15.6.2", { + "packageLocation": "./.yarn/cache/@types-node-npm-15.6.2-9d8f9d46a0-e65d6d4750.zip/node_modules/@types/node/", + "packageDependencies": [ + ["@types/node", "npm:15.6.2"] + ], + "linkType": "HARD", }] ]], ["@types/object-hash", [ @@ -202,7 +195,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./", "packageDependencies": [ ["cosmjs-types", "workspace:."], - ["ts-proto", "npm:1.81.1"] + ["@types/long", "npm:4.0.1"], + ["@types/node", "npm:15.6.2"], + ["long", "npm:4.0.0"], + ["prettier", "npm:2.3.0"], + ["protobufjs", "npm:6.10.2"], + ["ts-proto", "npm:1.81.1"], + ["typescript", "patch:typescript@npm%3A4.0.7#builtin::version=4.0.7&hash=a45b0e"] ], "linkType": "SOFT", }] diff --git a/.yarn/cache/@types-node-npm-15.6.2-9d8f9d46a0-e65d6d4750.zip b/.yarn/cache/@types-node-npm-15.6.2-9d8f9d46a0-e65d6d4750.zip new file mode 100644 index 00000000..7d2a9494 --- /dev/null +++ b/.yarn/cache/@types-node-npm-15.6.2-9d8f9d46a0-e65d6d4750.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9391971c1c2e1be27c5b92e8b7103cfc3d6c4748ddd80fc1b1c7322a60510a41 +size 134051 diff --git a/cosmos-sdk b/cosmos-sdk deleted file mode 160000 index f999b1ff..00000000 --- a/cosmos-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f999b1ff05a4db4a338a855713864497bedd4396 diff --git a/package.json b/package.json index 6a2a7bf0..cc64dd27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "cosmjs-types", "description": "JS and TS types relating to Protocol Buffers used by Cosmos-SDK and other related projects", - "private": true, "contributors": [ "Will Clark " ], @@ -13,10 +12,32 @@ "publishConfig": { "access": "public" }, - "workspaces": [ - "packages/*" + "files": [ + "confio/", + "cosmos/", + "cosmos_proto/", + "cosmwasm/", + "gogoproto/", + "google/", + "ibc/", + "tendermint/", + "*.md" ], + "scripts": { + "format": "prettier --write --loglevel warn \"./src/**/*.ts\"", + "define-proto": "./scripts/define-proto.sh && yarn format", + "prepare": "./scripts/prepare.sh", + "build": "rm -rf ./build && tsc && yarn prepare" + }, "devDependencies": { - "ts-proto": "^1.81.1" + "@types/long": "^4.0.1", + "@types/node": "^15.6.2", + "prettier": "^2.3.0", + "ts-proto": "^1.81.1", + "typescript": "~4.0" + }, + "dependencies": { + "long": "^4.0.0", + "protobufjs": "~6.10.2" } } diff --git a/packages/cosmos/.gitignore b/packages/cosmos/.gitignore deleted file mode 100644 index 567609b1..00000000 --- a/packages/cosmos/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/packages/cosmos/README.md b/packages/cosmos/README.md deleted file mode 100644 index 023785de..00000000 --- a/packages/cosmos/README.md +++ /dev/null @@ -1 +0,0 @@ -# @cosmjs-types/cosmos diff --git a/packages/cosmos/package.json b/packages/cosmos/package.json deleted file mode 100644 index d8dde72c..00000000 --- a/packages/cosmos/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@cosmjs-types/cosmos", - "version": "0.0.0", - "description": "Generated types for Cosmos protobuf definitions", - "contributors": [ - "Will Clark " - ], - "license": "Apache-2.0", - "files": [ - "build/", - "*.md" - ], - "repository": { - "type": "git", - "url": "https://github.com/confio/cosmjs-types/tree/main/packages/cosmos" - }, - "publishConfig": { - "access": "public" - }, - "scripts": { - "format": "prettier --write --loglevel warn \"./src/**/*.ts\"", - "define-proto": "./scripts/define-proto.sh && yarn format", - "build": "rm -rf ./build && tsc" - }, - "dependencies": { - "long": "^4.0.0", - "protobufjs": "~6.10.2" - }, - "devDependencies": { - "@types/long": "^4.0.1", - "@types/node": "^15.6.1", - "prettier": "^2.3.0", - "typescript": "~4.0" - } -} diff --git a/packages/cosmos/scripts/define-proto.sh b/packages/cosmos/scripts/define-proto.sh deleted file mode 100755 index 4196df04..00000000 --- a/packages/cosmos/scripts/define-proto.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -set -o errexit -o nounset -o pipefail -command -v shellcheck >/dev/null && shellcheck "$0" - -OUT_DIR="./src" -COSMOS_SDK_PROTO_DIR="../../cosmos-sdk/proto" -COSMOS_SDK_THIRD_PARTY_PROTO_DIR="../../cosmos-sdk/third_party/proto" - -PLUGIN_PATH="$(realpath ../../bin)/protoc-gen-ts_proto_yarn_2" - -mkdir -p "$OUT_DIR" - -protoc \ - --plugin="$PLUGIN_PATH" \ - --ts_proto_yarn_2_out="$OUT_DIR" \ - --proto_path="$COSMOS_SDK_PROTO_DIR" \ - --proto_path="$COSMOS_SDK_THIRD_PARTY_PROTO_DIR" \ - --ts_proto_yarn_2_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/auth/v1beta1/auth.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/auth/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/auth/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/bank/v1beta1/bank.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/bank/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/bank/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/bank/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/abci/v1beta1/abci.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/kv/v1beta1/kv.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/query/v1beta1/pagination.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/reflection/v1beta1/reflection.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/snapshots/v1beta1/snapshot.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/store/v1beta1/commit_info.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/store/v1beta1/snapshot.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/tendermint/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/base/v1beta1/coin.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/capability/v1beta1/capability.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/capability/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crisis/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crisis/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crypto/ed25519/keys.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crypto/multisig/keys.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crypto/multisig/v1beta1/multisig.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/crypto/secp256k1/keys.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/distribution/v1beta1/distribution.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/distribution/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/distribution/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/distribution/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/evidence/v1beta1/evidence.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/evidence/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/evidence/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/evidence/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/genutil/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/gov/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/gov/v1beta1/gov.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/gov/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/gov/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/mint/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/mint/v1beta1/mint.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/mint/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/params/v1beta1/params.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/params/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/slashing/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/slashing/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/slashing/v1beta1/slashing.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/slashing/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/staking/v1beta1/genesis.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/staking/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/staking/v1beta1/staking.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/staking/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/tx/signing/v1beta1/signing.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/tx/v1beta1/service.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/tx/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/upgrade/v1beta1/query.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/upgrade/v1beta1/upgrade.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/vesting/v1beta1/tx.proto" \ - "$COSMOS_SDK_PROTO_DIR/cosmos/vesting/v1beta1/vesting.proto" diff --git a/packages/cosmos/tsconfig.json b/packages/cosmos/tsconfig.json deleted file mode 100644 index 8a40e4f0..00000000 --- a/packages/cosmos/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "baseUrl": ".", - "outDir": "build", - "experimentalDecorators": true, - "rootDir": "src" - }, - "include": ["src/**/*"] -} diff --git a/scripts/define-proto.sh b/scripts/define-proto.sh new file mode 100755 index 00000000..538eeca7 --- /dev/null +++ b/scripts/define-proto.sh @@ -0,0 +1,106 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck >/dev/null && shellcheck "$0" + +OUT_DIR="./src" +WASMD_DIR="./wasmd-0.16/proto" +WASMD_THIRD_PARTY_DIR="./wasmd-0.16/third_party/proto" +CONFIO_DIR="$WASMD_THIRD_PARTY_DIR/confio/" +COSMOS_DIR="$WASMD_THIRD_PARTY_DIR/cosmos/" +IBC_DIR="$WASMD_THIRD_PARTY_DIR/ibc" + +PLUGIN_PATH="$(realpath ./bin)/protoc-gen-ts_proto_yarn_2" + +mkdir -p "$OUT_DIR" + +protoc \ + --plugin="$PLUGIN_PATH" \ + --ts_proto_yarn_2_out="$OUT_DIR" \ + --proto_path="$WASMD_DIR" \ + --proto_path="$WASMD_THIRD_PARTY_DIR" \ + --ts_proto_yarn_2_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \ + "$CONFIO_DIR/proofs.proto" \ + "$COSMOS_DIR/auth/v1beta1/auth.proto" \ + "$COSMOS_DIR/auth/v1beta1/genesis.proto" \ + "$COSMOS_DIR/auth/v1beta1/query.proto" \ + "$COSMOS_DIR/bank/v1beta1/bank.proto" \ + "$COSMOS_DIR/bank/v1beta1/genesis.proto" \ + "$COSMOS_DIR/bank/v1beta1/query.proto" \ + "$COSMOS_DIR/bank/v1beta1/tx.proto" \ + "$COSMOS_DIR/base/abci/v1beta1/abci.proto" \ + "$COSMOS_DIR/base/kv/v1beta1/kv.proto" \ + "$COSMOS_DIR/base/query/v1beta1/pagination.proto" \ + "$COSMOS_DIR/base/reflection/v1beta1/reflection.proto" \ + "$COSMOS_DIR/base/snapshots/v1beta1/snapshot.proto" \ + "$COSMOS_DIR/base/store/v1beta1/commit_info.proto" \ + "$COSMOS_DIR/base/store/v1beta1/snapshot.proto" \ + "$COSMOS_DIR/base/tendermint/v1beta1/query.proto" \ + "$COSMOS_DIR/base/v1beta1/coin.proto" \ + "$COSMOS_DIR/capability/v1beta1/capability.proto" \ + "$COSMOS_DIR/capability/v1beta1/genesis.proto" \ + "$COSMOS_DIR/crisis/v1beta1/genesis.proto" \ + "$COSMOS_DIR/crisis/v1beta1/tx.proto" \ + "$COSMOS_DIR/crypto/ed25519/keys.proto" \ + "$COSMOS_DIR/crypto/multisig/keys.proto" \ + "$COSMOS_DIR/crypto/multisig/v1beta1/multisig.proto" \ + "$COSMOS_DIR/crypto/secp256k1/keys.proto" \ + "$COSMOS_DIR/distribution/v1beta1/distribution.proto" \ + "$COSMOS_DIR/distribution/v1beta1/genesis.proto" \ + "$COSMOS_DIR/distribution/v1beta1/query.proto" \ + "$COSMOS_DIR/distribution/v1beta1/tx.proto" \ + "$COSMOS_DIR/evidence/v1beta1/evidence.proto" \ + "$COSMOS_DIR/evidence/v1beta1/genesis.proto" \ + "$COSMOS_DIR/evidence/v1beta1/query.proto" \ + "$COSMOS_DIR/evidence/v1beta1/tx.proto" \ + "$COSMOS_DIR/genutil/v1beta1/genesis.proto" \ + "$COSMOS_DIR/gov/v1beta1/genesis.proto" \ + "$COSMOS_DIR/gov/v1beta1/gov.proto" \ + "$COSMOS_DIR/gov/v1beta1/query.proto" \ + "$COSMOS_DIR/gov/v1beta1/tx.proto" \ + "$COSMOS_DIR/mint/v1beta1/genesis.proto" \ + "$COSMOS_DIR/mint/v1beta1/mint.proto" \ + "$COSMOS_DIR/mint/v1beta1/query.proto" \ + "$COSMOS_DIR/params/v1beta1/params.proto" \ + "$COSMOS_DIR/params/v1beta1/query.proto" \ + "$COSMOS_DIR/slashing/v1beta1/genesis.proto" \ + "$COSMOS_DIR/slashing/v1beta1/query.proto" \ + "$COSMOS_DIR/slashing/v1beta1/slashing.proto" \ + "$COSMOS_DIR/slashing/v1beta1/tx.proto" \ + "$COSMOS_DIR/staking/v1beta1/genesis.proto" \ + "$COSMOS_DIR/staking/v1beta1/query.proto" \ + "$COSMOS_DIR/staking/v1beta1/staking.proto" \ + "$COSMOS_DIR/staking/v1beta1/tx.proto" \ + "$COSMOS_DIR/tx/signing/v1beta1/signing.proto" \ + "$COSMOS_DIR/tx/v1beta1/service.proto" \ + "$COSMOS_DIR/tx/v1beta1/tx.proto" \ + "$COSMOS_DIR/upgrade/v1beta1/query.proto" \ + "$COSMOS_DIR/upgrade/v1beta1/upgrade.proto" \ + "$COSMOS_DIR/vesting/v1beta1/tx.proto" \ + "$COSMOS_DIR/vesting/v1beta1/vesting.proto" \ + "$IBC_DIR/applications/transfer/v1/genesis.proto" \ + "$IBC_DIR/applications/transfer/v1/query.proto" \ + "$IBC_DIR/applications/transfer/v1/transfer.proto" \ + "$IBC_DIR/applications/transfer/v1/tx.proto" \ + "$IBC_DIR/core/channel/v1/channel.proto" \ + "$IBC_DIR/core/channel/v1/genesis.proto" \ + "$IBC_DIR/core/channel/v1/query.proto" \ + "$IBC_DIR/core/channel/v1/tx.proto" \ + "$IBC_DIR/core/client/v1/client.proto" \ + "$IBC_DIR/core/client/v1/genesis.proto" \ + "$IBC_DIR/core/client/v1/query.proto" \ + "$IBC_DIR/core/client/v1/tx.proto" \ + "$IBC_DIR/lightclients/localhost/v1/localhost.proto" \ + "$IBC_DIR/lightclients/solomachine/v1/solomachine.proto" \ + "$IBC_DIR/lightclients/tendermint/v1/tendermint.proto" \ + "$IBC_DIR/core/commitment/v1/commitment.proto" \ + "$IBC_DIR/core/connection/v1/connection.proto" \ + "$IBC_DIR/core/connection/v1/genesis.proto" \ + "$IBC_DIR/core/connection/v1/query.proto" \ + "$IBC_DIR/core/connection/v1/tx.proto" \ + "$IBC_DIR/core/types/v1/genesis.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/genesis.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/ibc.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/proposal.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/query.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/tx.proto" \ + "$WASMD_DIR/cosmwasm/wasm/v1beta1/types.proto" diff --git a/scripts/prepare.sh b/scripts/prepare.sh new file mode 100755 index 00000000..a32308b6 --- /dev/null +++ b/scripts/prepare.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck >/dev/null && shellcheck "$0" + +DIRS="confio cosmos cosmos_proto cosmwasm gogoproto google ibc tendermint" + +for dir in $DIRS; do + rm -rf "$dir" + cp -R "./build/$dir" ./ +done diff --git a/src/confio/proofs.ts b/src/confio/proofs.ts new file mode 100644 index 00000000..efe7bcce --- /dev/null +++ b/src/confio/proofs.ts @@ -0,0 +1,1701 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "ics23"; + +export enum HashOp { + /** NO_HASH - NO_HASH is the default if no data passed. Note this is an illegal argument some places. */ + NO_HASH = 0, + SHA256 = 1, + SHA512 = 2, + KECCAK = 3, + RIPEMD160 = 4, + /** BITCOIN - ripemd160(sha256(x)) */ + BITCOIN = 5, + UNRECOGNIZED = -1, +} + +export function hashOpFromJSON(object: any): HashOp { + switch (object) { + case 0: + case "NO_HASH": + return HashOp.NO_HASH; + case 1: + case "SHA256": + return HashOp.SHA256; + case 2: + case "SHA512": + return HashOp.SHA512; + case 3: + case "KECCAK": + return HashOp.KECCAK; + case 4: + case "RIPEMD160": + return HashOp.RIPEMD160; + case 5: + case "BITCOIN": + return HashOp.BITCOIN; + case -1: + case "UNRECOGNIZED": + default: + return HashOp.UNRECOGNIZED; + } +} + +export function hashOpToJSON(object: HashOp): string { + switch (object) { + case HashOp.NO_HASH: + return "NO_HASH"; + case HashOp.SHA256: + return "SHA256"; + case HashOp.SHA512: + return "SHA512"; + case HashOp.KECCAK: + return "KECCAK"; + case HashOp.RIPEMD160: + return "RIPEMD160"; + case HashOp.BITCOIN: + return "BITCOIN"; + default: + return "UNKNOWN"; + } +} + +/** + * LengthOp defines how to process the key and value of the LeafOp + * to include length information. After encoding the length with the given + * algorithm, the length will be prepended to the key and value bytes. + * (Each one with it's own encoded length) + */ +export enum LengthOp { + /** NO_PREFIX - NO_PREFIX don't include any length info */ + NO_PREFIX = 0, + /** VAR_PROTO - VAR_PROTO uses protobuf (and go-amino) varint encoding of the length */ + VAR_PROTO = 1, + /** VAR_RLP - VAR_RLP uses rlp int encoding of the length */ + VAR_RLP = 2, + /** FIXED32_BIG - FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer */ + FIXED32_BIG = 3, + /** FIXED32_LITTLE - FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer */ + FIXED32_LITTLE = 4, + /** FIXED64_BIG - FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer */ + FIXED64_BIG = 5, + /** FIXED64_LITTLE - FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer */ + FIXED64_LITTLE = 6, + /** REQUIRE_32_BYTES - REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) */ + REQUIRE_32_BYTES = 7, + /** REQUIRE_64_BYTES - REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) */ + REQUIRE_64_BYTES = 8, + UNRECOGNIZED = -1, +} + +export function lengthOpFromJSON(object: any): LengthOp { + switch (object) { + case 0: + case "NO_PREFIX": + return LengthOp.NO_PREFIX; + case 1: + case "VAR_PROTO": + return LengthOp.VAR_PROTO; + case 2: + case "VAR_RLP": + return LengthOp.VAR_RLP; + case 3: + case "FIXED32_BIG": + return LengthOp.FIXED32_BIG; + case 4: + case "FIXED32_LITTLE": + return LengthOp.FIXED32_LITTLE; + case 5: + case "FIXED64_BIG": + return LengthOp.FIXED64_BIG; + case 6: + case "FIXED64_LITTLE": + return LengthOp.FIXED64_LITTLE; + case 7: + case "REQUIRE_32_BYTES": + return LengthOp.REQUIRE_32_BYTES; + case 8: + case "REQUIRE_64_BYTES": + return LengthOp.REQUIRE_64_BYTES; + case -1: + case "UNRECOGNIZED": + default: + return LengthOp.UNRECOGNIZED; + } +} + +export function lengthOpToJSON(object: LengthOp): string { + switch (object) { + case LengthOp.NO_PREFIX: + return "NO_PREFIX"; + case LengthOp.VAR_PROTO: + return "VAR_PROTO"; + case LengthOp.VAR_RLP: + return "VAR_RLP"; + case LengthOp.FIXED32_BIG: + return "FIXED32_BIG"; + case LengthOp.FIXED32_LITTLE: + return "FIXED32_LITTLE"; + case LengthOp.FIXED64_BIG: + return "FIXED64_BIG"; + case LengthOp.FIXED64_LITTLE: + return "FIXED64_LITTLE"; + case LengthOp.REQUIRE_32_BYTES: + return "REQUIRE_32_BYTES"; + case LengthOp.REQUIRE_64_BYTES: + return "REQUIRE_64_BYTES"; + default: + return "UNKNOWN"; + } +} + +/** + * ExistenceProof takes a key and a value and a set of steps to perform on it. + * The result of peforming all these steps will provide a "root hash", which can + * be compared to the value in a header. + * + * Since it is computationally infeasible to produce a hash collission for any of the used + * cryptographic hash functions, if someone can provide a series of operations to transform + * a given key and value into a root hash that matches some trusted root, these key and values + * must be in the referenced merkle tree. + * + * The only possible issue is maliablity in LeafOp, such as providing extra prefix data, + * which should be controlled by a spec. Eg. with lengthOp as NONE, + * prefix = FOO, key = BAR, value = CHOICE + * and + * prefix = F, key = OOBAR, value = CHOICE + * would produce the same value. + * + * With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field + * in the ProofSpec is valuable to prevent this mutability. And why all trees should + * length-prefix the data before hashing it. + */ +export interface ExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOp; + path: InnerOp[]; +} + +/** + * NonExistenceProof takes a proof of two neighbors, one left of the desired key, + * one right of the desired key. If both proofs are valid AND they are neighbors, + * then there is no valid proof for the given key. + */ +export interface NonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left?: ExistenceProof; + right?: ExistenceProof; +} + +/** CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages */ +export interface CommitmentProof { + exist?: ExistenceProof | undefined; + nonexist?: NonExistenceProof | undefined; + batch?: BatchProof | undefined; + compressed?: CompressedBatchProof | undefined; +} + +/** + * LeafOp represents the raw key-value data we wish to prove, and + * must be flexible to represent the internal transformation from + * the original key-value pairs into the basis hash, for many existing + * merkle trees. + * + * key and value are passed in. So that the signature of this operation is: + * leafOp(key, value) -> output + * + * To process this, first prehash the keys and values if needed (ANY means no hash in this case): + * hkey = prehashKey(key) + * hvalue = prehashValue(value) + * + * Then combine the bytes, and hash it + * output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) + */ +export interface LeafOp { + hash: HashOp; + prehashKey: HashOp; + prehashValue: HashOp; + length: LengthOp; + /** + * prefix is a fixed bytes that may optionally be included at the beginning to differentiate + * a leaf node from an inner node. + */ + prefix: Uint8Array; +} + +/** + * InnerOp represents a merkle-proof step that is not a leaf. + * It represents concatenating two children and hashing them to provide the next result. + * + * The result of the previous step is passed in, so the signature of this op is: + * innerOp(child) -> output + * + * The result of applying InnerOp should be: + * output = op.hash(op.prefix || child || op.suffix) + * + * where the || operator is concatenation of binary data, + * and child is the result of hashing all the tree below this step. + * + * Any special data, like prepending child with the length, or prepending the entire operation with + * some value to differentiate from leaf nodes, should be included in prefix and suffix. + * If either of prefix or suffix is empty, we just treat it as an empty string + */ +export interface InnerOp { + hash: HashOp; + prefix: Uint8Array; + suffix: Uint8Array; +} + +/** + * ProofSpec defines what the expected parameters are for a given proof type. + * This can be stored in the client and used to validate any incoming proofs. + * + * verify(ProofSpec, Proof) -> Proof | Error + * + * As demonstrated in tests, if we don't fix the algorithm used to calculate the + * LeafHash for a given tree, there are many possible key-value pairs that can + * generate a given hash (by interpretting the preimage differently). + * We need this for proper security, requires client knows a priori what + * tree format server uses. But not in code, rather a configuration object. + */ +export interface ProofSpec { + /** + * any field in the ExistenceProof must be the same as in this spec. + * except Prefix, which is just the first bytes of prefix (spec can be longer) + */ + leafSpec?: LeafOp; + innerSpec?: InnerSpec; + /** max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) */ + maxDepth: number; + /** min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) */ + minDepth: number; +} + +/** + * InnerSpec contains all store-specific structure info to determine if two proofs from a + * given store are neighbors. + * + * This enables: + * + * isLeftMost(spec: InnerSpec, op: InnerOp) + * isRightMost(spec: InnerSpec, op: InnerOp) + * isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) + */ +export interface InnerSpec { + /** + * Child order is the ordering of the children node, must count from 0 + * iavl tree is [0, 1] (left then right) + * merk is [0, 2, 1] (left, right, here) + */ + childOrder: number[]; + childSize: number; + minPrefixLength: number; + maxPrefixLength: number; + /** empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) */ + emptyChild: Uint8Array; + /** hash is the algorithm that must be used for each InnerOp */ + hash: HashOp; +} + +/** BatchProof is a group of multiple proof types than can be compressed */ +export interface BatchProof { + entries: BatchEntry[]; +} + +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface BatchEntry { + exist?: ExistenceProof | undefined; + nonexist?: NonExistenceProof | undefined; +} + +export interface CompressedBatchProof { + entries: CompressedBatchEntry[]; + lookupInners: InnerOp[]; +} + +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface CompressedBatchEntry { + exist?: CompressedExistenceProof | undefined; + nonexist?: CompressedNonExistenceProof | undefined; +} + +export interface CompressedExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOp; + /** these are indexes into the lookup_inners table in CompressedBatchProof */ + path: number[]; +} + +export interface CompressedNonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left?: CompressedExistenceProof; + right?: CompressedExistenceProof; +} + +const baseExistenceProof: object = {}; + +export const ExistenceProof = { + encode(message: ExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.path) { + InnerOp.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ExistenceProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + message.path.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExistenceProof { + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromJSON(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(InnerOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => (e ? InnerOp.toJSON(e) : undefined)); + } else { + obj.path = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ExistenceProof { + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(InnerOp.fromPartial(e)); + } + } + return message; + }, +}; + +const baseNonExistenceProof: object = {}; + +export const NonExistenceProof = { + encode(message: NonExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + ExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); + } + if (message.right !== undefined) { + ExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): NonExistenceProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseNonExistenceProof } as NonExistenceProof; + message.key = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = ExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.right = ExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): NonExistenceProof { + const message = { ...baseNonExistenceProof } as NonExistenceProof; + message.key = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromJSON(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromJSON(object.right); + } else { + message.right = undefined; + } + return message; + }, + + toJSON(message: NonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && (obj.left = message.left ? ExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && + (obj.right = message.right ? ExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): NonExistenceProof { + const message = { ...baseNonExistenceProof } as NonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromPartial(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromPartial(object.right); + } else { + message.right = undefined; + } + return message; + }, +}; + +const baseCommitmentProof: object = {}; + +export const CommitmentProof = { + encode(message: CommitmentProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + if (message.batch !== undefined) { + BatchProof.encode(message.batch, writer.uint32(26).fork()).ldelim(); + } + if (message.compressed !== undefined) { + CompressedBatchProof.encode(message.compressed, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CommitmentProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitmentProof } as CommitmentProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.batch = BatchProof.decode(reader, reader.uint32()); + break; + case 4: + message.compressed = CompressedBatchProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitmentProof { + const message = { ...baseCommitmentProof } as CommitmentProof; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromJSON(object.batch); + } else { + message.batch = undefined; + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromJSON(object.compressed); + } else { + message.compressed = undefined; + } + return message; + }, + + toJSON(message: CommitmentProof): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + message.batch !== undefined && (obj.batch = message.batch ? BatchProof.toJSON(message.batch) : undefined); + message.compressed !== undefined && + (obj.compressed = message.compressed ? CompressedBatchProof.toJSON(message.compressed) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CommitmentProof { + const message = { ...baseCommitmentProof } as CommitmentProof; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } else { + message.nonexist = undefined; + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromPartial(object.batch); + } else { + message.batch = undefined; + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromPartial(object.compressed); + } else { + message.compressed = undefined; + } + return message; + }, +}; + +const baseLeafOp: object = { hash: 0, prehashKey: 0, prehashValue: 0, length: 0 }; + +export const LeafOp = { + encode(message: LeafOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prehashKey !== 0) { + writer.uint32(16).int32(message.prehashKey); + } + if (message.prehashValue !== 0) { + writer.uint32(24).int32(message.prehashValue); + } + if (message.length !== 0) { + writer.uint32(32).int32(message.length); + } + if (message.prefix.length !== 0) { + writer.uint32(42).bytes(message.prefix); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): LeafOp { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLeafOp } as LeafOp; + message.prefix = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.int32() as any; + break; + case 2: + message.prehashKey = reader.int32() as any; + break; + case 3: + message.prehashValue = reader.int32() as any; + break; + case 4: + message.length = reader.int32() as any; + break; + case 5: + message.prefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LeafOp { + const message = { ...baseLeafOp } as LeafOp; + message.prefix = new Uint8Array(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + if (object.prehashKey !== undefined && object.prehashKey !== null) { + message.prehashKey = hashOpFromJSON(object.prehashKey); + } else { + message.prehashKey = 0; + } + if (object.prehashValue !== undefined && object.prehashValue !== null) { + message.prehashValue = hashOpFromJSON(object.prehashValue); + } else { + message.prehashValue = 0; + } + if (object.length !== undefined && object.length !== null) { + message.length = lengthOpFromJSON(object.length); + } else { + message.length = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + return message; + }, + + toJSON(message: LeafOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prehashKey !== undefined && (obj.prehashKey = hashOpToJSON(message.prehashKey)); + message.prehashValue !== undefined && (obj.prehashValue = hashOpToJSON(message.prehashValue)); + message.length !== undefined && (obj.length = lengthOpToJSON(message.length)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): LeafOp { + const message = { ...baseLeafOp } as LeafOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + if (object.prehashKey !== undefined && object.prehashKey !== null) { + message.prehashKey = object.prehashKey; + } else { + message.prehashKey = 0; + } + if (object.prehashValue !== undefined && object.prehashValue !== null) { + message.prehashValue = object.prehashValue; + } else { + message.prehashValue = 0; + } + if (object.length !== undefined && object.length !== null) { + message.length = object.length; + } else { + message.length = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = object.prefix; + } else { + message.prefix = new Uint8Array(); + } + return message; + }, +}; + +const baseInnerOp: object = { hash: 0 }; + +export const InnerOp = { + encode(message: InnerOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prefix.length !== 0) { + writer.uint32(18).bytes(message.prefix); + } + if (message.suffix.length !== 0) { + writer.uint32(26).bytes(message.suffix); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): InnerOp { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInnerOp } as InnerOp; + message.prefix = new Uint8Array(); + message.suffix = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.int32() as any; + break; + case 2: + message.prefix = reader.bytes(); + break; + case 3: + message.suffix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): InnerOp { + const message = { ...baseInnerOp } as InnerOp; + message.prefix = new Uint8Array(); + message.suffix = new Uint8Array(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = bytesFromBase64(object.suffix); + } + return message; + }, + + toJSON(message: InnerOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + message.suffix !== undefined && + (obj.suffix = base64FromBytes(message.suffix !== undefined ? message.suffix : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): InnerOp { + const message = { ...baseInnerOp } as InnerOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = object.prefix; + } else { + message.prefix = new Uint8Array(); + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = object.suffix; + } else { + message.suffix = new Uint8Array(); + } + return message; + }, +}; + +const baseProofSpec: object = { maxDepth: 0, minDepth: 0 }; + +export const ProofSpec = { + encode(message: ProofSpec, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leafSpec !== undefined) { + LeafOp.encode(message.leafSpec, writer.uint32(10).fork()).ldelim(); + } + if (message.innerSpec !== undefined) { + InnerSpec.encode(message.innerSpec, writer.uint32(18).fork()).ldelim(); + } + if (message.maxDepth !== 0) { + writer.uint32(24).int32(message.maxDepth); + } + if (message.minDepth !== 0) { + writer.uint32(32).int32(message.minDepth); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ProofSpec { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofSpec } as ProofSpec; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leafSpec = LeafOp.decode(reader, reader.uint32()); + break; + case 2: + message.innerSpec = InnerSpec.decode(reader, reader.uint32()); + break; + case 3: + message.maxDepth = reader.int32(); + break; + case 4: + message.minDepth = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofSpec { + const message = { ...baseProofSpec } as ProofSpec; + if (object.leafSpec !== undefined && object.leafSpec !== null) { + message.leafSpec = LeafOp.fromJSON(object.leafSpec); + } else { + message.leafSpec = undefined; + } + if (object.innerSpec !== undefined && object.innerSpec !== null) { + message.innerSpec = InnerSpec.fromJSON(object.innerSpec); + } else { + message.innerSpec = undefined; + } + if (object.maxDepth !== undefined && object.maxDepth !== null) { + message.maxDepth = Number(object.maxDepth); + } else { + message.maxDepth = 0; + } + if (object.minDepth !== undefined && object.minDepth !== null) { + message.minDepth = Number(object.minDepth); + } else { + message.minDepth = 0; + } + return message; + }, + + toJSON(message: ProofSpec): unknown { + const obj: any = {}; + message.leafSpec !== undefined && + (obj.leafSpec = message.leafSpec ? LeafOp.toJSON(message.leafSpec) : undefined); + message.innerSpec !== undefined && + (obj.innerSpec = message.innerSpec ? InnerSpec.toJSON(message.innerSpec) : undefined); + message.maxDepth !== undefined && (obj.maxDepth = message.maxDepth); + message.minDepth !== undefined && (obj.minDepth = message.minDepth); + return obj; + }, + + fromPartial(object: DeepPartial): ProofSpec { + const message = { ...baseProofSpec } as ProofSpec; + if (object.leafSpec !== undefined && object.leafSpec !== null) { + message.leafSpec = LeafOp.fromPartial(object.leafSpec); + } else { + message.leafSpec = undefined; + } + if (object.innerSpec !== undefined && object.innerSpec !== null) { + message.innerSpec = InnerSpec.fromPartial(object.innerSpec); + } else { + message.innerSpec = undefined; + } + if (object.maxDepth !== undefined && object.maxDepth !== null) { + message.maxDepth = object.maxDepth; + } else { + message.maxDepth = 0; + } + if (object.minDepth !== undefined && object.minDepth !== null) { + message.minDepth = object.minDepth; + } else { + message.minDepth = 0; + } + return message; + }, +}; + +const baseInnerSpec: object = { + childOrder: 0, + childSize: 0, + minPrefixLength: 0, + maxPrefixLength: 0, + hash: 0, +}; + +export const InnerSpec = { + encode(message: InnerSpec, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + writer.uint32(10).fork(); + for (const v of message.childOrder) { + writer.int32(v); + } + writer.ldelim(); + if (message.childSize !== 0) { + writer.uint32(16).int32(message.childSize); + } + if (message.minPrefixLength !== 0) { + writer.uint32(24).int32(message.minPrefixLength); + } + if (message.maxPrefixLength !== 0) { + writer.uint32(32).int32(message.maxPrefixLength); + } + if (message.emptyChild.length !== 0) { + writer.uint32(42).bytes(message.emptyChild); + } + if (message.hash !== 0) { + writer.uint32(48).int32(message.hash); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): InnerSpec { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + message.emptyChild = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.childOrder.push(reader.int32()); + } + } else { + message.childOrder.push(reader.int32()); + } + break; + case 2: + message.childSize = reader.int32(); + break; + case 3: + message.minPrefixLength = reader.int32(); + break; + case 4: + message.maxPrefixLength = reader.int32(); + break; + case 5: + message.emptyChild = reader.bytes(); + break; + case 6: + message.hash = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): InnerSpec { + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + message.emptyChild = new Uint8Array(); + if (object.childOrder !== undefined && object.childOrder !== null) { + for (const e of object.childOrder) { + message.childOrder.push(Number(e)); + } + } + if (object.childSize !== undefined && object.childSize !== null) { + message.childSize = Number(object.childSize); + } else { + message.childSize = 0; + } + if (object.minPrefixLength !== undefined && object.minPrefixLength !== null) { + message.minPrefixLength = Number(object.minPrefixLength); + } else { + message.minPrefixLength = 0; + } + if (object.maxPrefixLength !== undefined && object.maxPrefixLength !== null) { + message.maxPrefixLength = Number(object.maxPrefixLength); + } else { + message.maxPrefixLength = 0; + } + if (object.emptyChild !== undefined && object.emptyChild !== null) { + message.emptyChild = bytesFromBase64(object.emptyChild); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + return message; + }, + + toJSON(message: InnerSpec): unknown { + const obj: any = {}; + if (message.childOrder) { + obj.childOrder = message.childOrder.map((e) => e); + } else { + obj.childOrder = []; + } + message.childSize !== undefined && (obj.childSize = message.childSize); + message.minPrefixLength !== undefined && (obj.minPrefixLength = message.minPrefixLength); + message.maxPrefixLength !== undefined && (obj.maxPrefixLength = message.maxPrefixLength); + message.emptyChild !== undefined && + (obj.emptyChild = base64FromBytes( + message.emptyChild !== undefined ? message.emptyChild : new Uint8Array(), + )); + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + return obj; + }, + + fromPartial(object: DeepPartial): InnerSpec { + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + if (object.childOrder !== undefined && object.childOrder !== null) { + for (const e of object.childOrder) { + message.childOrder.push(e); + } + } + if (object.childSize !== undefined && object.childSize !== null) { + message.childSize = object.childSize; + } else { + message.childSize = 0; + } + if (object.minPrefixLength !== undefined && object.minPrefixLength !== null) { + message.minPrefixLength = object.minPrefixLength; + } else { + message.minPrefixLength = 0; + } + if (object.maxPrefixLength !== undefined && object.maxPrefixLength !== null) { + message.maxPrefixLength = object.maxPrefixLength; + } else { + message.maxPrefixLength = 0; + } + if (object.emptyChild !== undefined && object.emptyChild !== null) { + message.emptyChild = object.emptyChild; + } else { + message.emptyChild = new Uint8Array(); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + return message; + }, +}; + +const baseBatchProof: object = {}; + +export const BatchProof = { + encode(message: BatchProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.entries) { + BatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): BatchProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(BatchEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BatchProof { + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(BatchEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: BatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? BatchEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): BatchProof { + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(BatchEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseBatchEntry: object = {}; + +export const BatchEntry = { + encode(message: BatchEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): BatchEntry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBatchEntry } as BatchEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BatchEntry { + const message = { ...baseBatchEntry } as BatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, + + toJSON(message: BatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BatchEntry { + const message = { ...baseBatchEntry } as BatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, +}; + +const baseCompressedBatchProof: object = {}; + +export const CompressedBatchProof = { + encode(message: CompressedBatchProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.entries) { + CompressedBatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.lookupInners) { + InnerOp.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CompressedBatchProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(CompressedBatchEntry.decode(reader, reader.uint32())); + break; + case 2: + message.lookupInners.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedBatchProof { + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(CompressedBatchEntry.fromJSON(e)); + } + } + if (object.lookupInners !== undefined && object.lookupInners !== null) { + for (const e of object.lookupInners) { + message.lookupInners.push(InnerOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: CompressedBatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? CompressedBatchEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + if (message.lookupInners) { + obj.lookupInners = message.lookupInners.map((e) => (e ? InnerOp.toJSON(e) : undefined)); + } else { + obj.lookupInners = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): CompressedBatchProof { + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(CompressedBatchEntry.fromPartial(e)); + } + } + if (object.lookupInners !== undefined && object.lookupInners !== null) { + for (const e of object.lookupInners) { + message.lookupInners.push(InnerOp.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCompressedBatchEntry: object = {}; + +export const CompressedBatchEntry = { + encode(message: CompressedBatchEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.exist !== undefined) { + CompressedExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + CompressedNonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CompressedBatchEntry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = CompressedNonExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedBatchEntry { + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, + + toJSON(message: CompressedBatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? CompressedExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CompressedBatchEntry { + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromPartial(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, +}; + +const baseCompressedExistenceProof: object = { path: 0 }; + +export const CompressedExistenceProof = { + encode(message: CompressedExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + writer.uint32(34).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CompressedExistenceProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedExistenceProof } as CompressedExistenceProof; + message.path = []; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedExistenceProof { + const message = { ...baseCompressedExistenceProof } as CompressedExistenceProof; + message.path = []; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromJSON(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + return message; + }, + + toJSON(message: CompressedExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): CompressedExistenceProof { + const message = { ...baseCompressedExistenceProof } as CompressedExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + return message; + }, +}; + +const baseCompressedNonExistenceProof: object = {}; + +export const CompressedNonExistenceProof = { + encode(message: CompressedNonExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + CompressedExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); + } + if (message.right !== undefined) { + CompressedExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CompressedNonExistenceProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedNonExistenceProof } as CompressedNonExistenceProof; + message.key = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.right = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedNonExistenceProof { + const message = { ...baseCompressedNonExistenceProof } as CompressedNonExistenceProof; + message.key = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromJSON(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromJSON(object.right); + } else { + message.right = undefined; + } + return message; + }, + + toJSON(message: CompressedNonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && + (obj.left = message.left ? CompressedExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && + (obj.right = message.right ? CompressedExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CompressedNonExistenceProof { + const message = { ...baseCompressedNonExistenceProof } as CompressedNonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromPartial(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromPartial(object.right); + } else { + message.right = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/packages/cosmos/src/cosmos/auth/v1beta1/auth.ts b/src/cosmos/auth/v1beta1/auth.ts similarity index 100% rename from packages/cosmos/src/cosmos/auth/v1beta1/auth.ts rename to src/cosmos/auth/v1beta1/auth.ts diff --git a/packages/cosmos/src/cosmos/auth/v1beta1/genesis.ts b/src/cosmos/auth/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/auth/v1beta1/genesis.ts rename to src/cosmos/auth/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/auth/v1beta1/query.ts b/src/cosmos/auth/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/auth/v1beta1/query.ts rename to src/cosmos/auth/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/bank/v1beta1/bank.ts b/src/cosmos/bank/v1beta1/bank.ts similarity index 100% rename from packages/cosmos/src/cosmos/bank/v1beta1/bank.ts rename to src/cosmos/bank/v1beta1/bank.ts diff --git a/packages/cosmos/src/cosmos/bank/v1beta1/genesis.ts b/src/cosmos/bank/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/bank/v1beta1/genesis.ts rename to src/cosmos/bank/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/bank/v1beta1/query.ts b/src/cosmos/bank/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/bank/v1beta1/query.ts rename to src/cosmos/bank/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/bank/v1beta1/tx.ts b/src/cosmos/bank/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/bank/v1beta1/tx.ts rename to src/cosmos/bank/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/base/abci/v1beta1/abci.ts b/src/cosmos/base/abci/v1beta1/abci.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/abci/v1beta1/abci.ts rename to src/cosmos/base/abci/v1beta1/abci.ts diff --git a/packages/cosmos/src/cosmos/base/kv/v1beta1/kv.ts b/src/cosmos/base/kv/v1beta1/kv.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/kv/v1beta1/kv.ts rename to src/cosmos/base/kv/v1beta1/kv.ts diff --git a/packages/cosmos/src/cosmos/base/query/v1beta1/pagination.ts b/src/cosmos/base/query/v1beta1/pagination.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/query/v1beta1/pagination.ts rename to src/cosmos/base/query/v1beta1/pagination.ts diff --git a/packages/cosmos/src/cosmos/base/reflection/v1beta1/reflection.ts b/src/cosmos/base/reflection/v1beta1/reflection.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/reflection/v1beta1/reflection.ts rename to src/cosmos/base/reflection/v1beta1/reflection.ts diff --git a/packages/cosmos/src/cosmos/base/snapshots/v1beta1/snapshot.ts b/src/cosmos/base/snapshots/v1beta1/snapshot.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/snapshots/v1beta1/snapshot.ts rename to src/cosmos/base/snapshots/v1beta1/snapshot.ts diff --git a/packages/cosmos/src/cosmos/base/store/v1beta1/commit_info.ts b/src/cosmos/base/store/v1beta1/commit_info.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/store/v1beta1/commit_info.ts rename to src/cosmos/base/store/v1beta1/commit_info.ts diff --git a/packages/cosmos/src/cosmos/base/store/v1beta1/snapshot.ts b/src/cosmos/base/store/v1beta1/snapshot.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/store/v1beta1/snapshot.ts rename to src/cosmos/base/store/v1beta1/snapshot.ts diff --git a/packages/cosmos/src/cosmos/base/tendermint/v1beta1/query.ts b/src/cosmos/base/tendermint/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/tendermint/v1beta1/query.ts rename to src/cosmos/base/tendermint/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/base/v1beta1/coin.ts b/src/cosmos/base/v1beta1/coin.ts similarity index 100% rename from packages/cosmos/src/cosmos/base/v1beta1/coin.ts rename to src/cosmos/base/v1beta1/coin.ts diff --git a/packages/cosmos/src/cosmos/capability/v1beta1/capability.ts b/src/cosmos/capability/v1beta1/capability.ts similarity index 100% rename from packages/cosmos/src/cosmos/capability/v1beta1/capability.ts rename to src/cosmos/capability/v1beta1/capability.ts diff --git a/packages/cosmos/src/cosmos/capability/v1beta1/genesis.ts b/src/cosmos/capability/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/capability/v1beta1/genesis.ts rename to src/cosmos/capability/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/crisis/v1beta1/genesis.ts b/src/cosmos/crisis/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/crisis/v1beta1/genesis.ts rename to src/cosmos/crisis/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/crisis/v1beta1/tx.ts b/src/cosmos/crisis/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/crisis/v1beta1/tx.ts rename to src/cosmos/crisis/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/crypto/ed25519/keys.ts b/src/cosmos/crypto/ed25519/keys.ts similarity index 100% rename from packages/cosmos/src/cosmos/crypto/ed25519/keys.ts rename to src/cosmos/crypto/ed25519/keys.ts diff --git a/packages/cosmos/src/cosmos/crypto/multisig/keys.ts b/src/cosmos/crypto/multisig/keys.ts similarity index 100% rename from packages/cosmos/src/cosmos/crypto/multisig/keys.ts rename to src/cosmos/crypto/multisig/keys.ts diff --git a/packages/cosmos/src/cosmos/crypto/multisig/v1beta1/multisig.ts b/src/cosmos/crypto/multisig/v1beta1/multisig.ts similarity index 100% rename from packages/cosmos/src/cosmos/crypto/multisig/v1beta1/multisig.ts rename to src/cosmos/crypto/multisig/v1beta1/multisig.ts diff --git a/packages/cosmos/src/cosmos/crypto/secp256k1/keys.ts b/src/cosmos/crypto/secp256k1/keys.ts similarity index 100% rename from packages/cosmos/src/cosmos/crypto/secp256k1/keys.ts rename to src/cosmos/crypto/secp256k1/keys.ts diff --git a/packages/cosmos/src/cosmos/distribution/v1beta1/distribution.ts b/src/cosmos/distribution/v1beta1/distribution.ts similarity index 100% rename from packages/cosmos/src/cosmos/distribution/v1beta1/distribution.ts rename to src/cosmos/distribution/v1beta1/distribution.ts diff --git a/packages/cosmos/src/cosmos/distribution/v1beta1/genesis.ts b/src/cosmos/distribution/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/distribution/v1beta1/genesis.ts rename to src/cosmos/distribution/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/distribution/v1beta1/query.ts b/src/cosmos/distribution/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/distribution/v1beta1/query.ts rename to src/cosmos/distribution/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/distribution/v1beta1/tx.ts b/src/cosmos/distribution/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/distribution/v1beta1/tx.ts rename to src/cosmos/distribution/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/evidence/v1beta1/evidence.ts b/src/cosmos/evidence/v1beta1/evidence.ts similarity index 100% rename from packages/cosmos/src/cosmos/evidence/v1beta1/evidence.ts rename to src/cosmos/evidence/v1beta1/evidence.ts diff --git a/packages/cosmos/src/cosmos/evidence/v1beta1/genesis.ts b/src/cosmos/evidence/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/evidence/v1beta1/genesis.ts rename to src/cosmos/evidence/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/evidence/v1beta1/query.ts b/src/cosmos/evidence/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/evidence/v1beta1/query.ts rename to src/cosmos/evidence/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/evidence/v1beta1/tx.ts b/src/cosmos/evidence/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/evidence/v1beta1/tx.ts rename to src/cosmos/evidence/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/genutil/v1beta1/genesis.ts b/src/cosmos/genutil/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/genutil/v1beta1/genesis.ts rename to src/cosmos/genutil/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/gov/v1beta1/genesis.ts b/src/cosmos/gov/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/gov/v1beta1/genesis.ts rename to src/cosmos/gov/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/gov/v1beta1/gov.ts b/src/cosmos/gov/v1beta1/gov.ts similarity index 100% rename from packages/cosmos/src/cosmos/gov/v1beta1/gov.ts rename to src/cosmos/gov/v1beta1/gov.ts diff --git a/packages/cosmos/src/cosmos/gov/v1beta1/query.ts b/src/cosmos/gov/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/gov/v1beta1/query.ts rename to src/cosmos/gov/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/gov/v1beta1/tx.ts b/src/cosmos/gov/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/gov/v1beta1/tx.ts rename to src/cosmos/gov/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/mint/v1beta1/genesis.ts b/src/cosmos/mint/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/mint/v1beta1/genesis.ts rename to src/cosmos/mint/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/mint/v1beta1/mint.ts b/src/cosmos/mint/v1beta1/mint.ts similarity index 100% rename from packages/cosmos/src/cosmos/mint/v1beta1/mint.ts rename to src/cosmos/mint/v1beta1/mint.ts diff --git a/packages/cosmos/src/cosmos/mint/v1beta1/query.ts b/src/cosmos/mint/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/mint/v1beta1/query.ts rename to src/cosmos/mint/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/params/v1beta1/params.ts b/src/cosmos/params/v1beta1/params.ts similarity index 100% rename from packages/cosmos/src/cosmos/params/v1beta1/params.ts rename to src/cosmos/params/v1beta1/params.ts diff --git a/packages/cosmos/src/cosmos/params/v1beta1/query.ts b/src/cosmos/params/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/params/v1beta1/query.ts rename to src/cosmos/params/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/slashing/v1beta1/genesis.ts b/src/cosmos/slashing/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/slashing/v1beta1/genesis.ts rename to src/cosmos/slashing/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/slashing/v1beta1/query.ts b/src/cosmos/slashing/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/slashing/v1beta1/query.ts rename to src/cosmos/slashing/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/slashing/v1beta1/slashing.ts b/src/cosmos/slashing/v1beta1/slashing.ts similarity index 100% rename from packages/cosmos/src/cosmos/slashing/v1beta1/slashing.ts rename to src/cosmos/slashing/v1beta1/slashing.ts diff --git a/packages/cosmos/src/cosmos/slashing/v1beta1/tx.ts b/src/cosmos/slashing/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/slashing/v1beta1/tx.ts rename to src/cosmos/slashing/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/staking/v1beta1/genesis.ts b/src/cosmos/staking/v1beta1/genesis.ts similarity index 100% rename from packages/cosmos/src/cosmos/staking/v1beta1/genesis.ts rename to src/cosmos/staking/v1beta1/genesis.ts diff --git a/packages/cosmos/src/cosmos/staking/v1beta1/query.ts b/src/cosmos/staking/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/staking/v1beta1/query.ts rename to src/cosmos/staking/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/staking/v1beta1/staking.ts b/src/cosmos/staking/v1beta1/staking.ts similarity index 100% rename from packages/cosmos/src/cosmos/staking/v1beta1/staking.ts rename to src/cosmos/staking/v1beta1/staking.ts diff --git a/packages/cosmos/src/cosmos/staking/v1beta1/tx.ts b/src/cosmos/staking/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/staking/v1beta1/tx.ts rename to src/cosmos/staking/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/tx/signing/v1beta1/signing.ts b/src/cosmos/tx/signing/v1beta1/signing.ts similarity index 100% rename from packages/cosmos/src/cosmos/tx/signing/v1beta1/signing.ts rename to src/cosmos/tx/signing/v1beta1/signing.ts diff --git a/packages/cosmos/src/cosmos/tx/v1beta1/service.ts b/src/cosmos/tx/v1beta1/service.ts similarity index 100% rename from packages/cosmos/src/cosmos/tx/v1beta1/service.ts rename to src/cosmos/tx/v1beta1/service.ts diff --git a/packages/cosmos/src/cosmos/tx/v1beta1/tx.ts b/src/cosmos/tx/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/tx/v1beta1/tx.ts rename to src/cosmos/tx/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/upgrade/v1beta1/query.ts b/src/cosmos/upgrade/v1beta1/query.ts similarity index 100% rename from packages/cosmos/src/cosmos/upgrade/v1beta1/query.ts rename to src/cosmos/upgrade/v1beta1/query.ts diff --git a/packages/cosmos/src/cosmos/upgrade/v1beta1/upgrade.ts b/src/cosmos/upgrade/v1beta1/upgrade.ts similarity index 100% rename from packages/cosmos/src/cosmos/upgrade/v1beta1/upgrade.ts rename to src/cosmos/upgrade/v1beta1/upgrade.ts diff --git a/packages/cosmos/src/cosmos/vesting/v1beta1/tx.ts b/src/cosmos/vesting/v1beta1/tx.ts similarity index 100% rename from packages/cosmos/src/cosmos/vesting/v1beta1/tx.ts rename to src/cosmos/vesting/v1beta1/tx.ts diff --git a/packages/cosmos/src/cosmos/vesting/v1beta1/vesting.ts b/src/cosmos/vesting/v1beta1/vesting.ts similarity index 100% rename from packages/cosmos/src/cosmos/vesting/v1beta1/vesting.ts rename to src/cosmos/vesting/v1beta1/vesting.ts diff --git a/packages/cosmos/src/cosmos_proto/cosmos.ts b/src/cosmos_proto/cosmos.ts similarity index 100% rename from packages/cosmos/src/cosmos_proto/cosmos.ts rename to src/cosmos_proto/cosmos.ts diff --git a/src/cosmwasm/wasm/v1beta1/genesis.ts b/src/cosmwasm/wasm/v1beta1/genesis.ts new file mode 100644 index 00000000..d9da9874 --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/genesis.ts @@ -0,0 +1,622 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Params, CodeInfo, ContractInfo, Model } from "../../../cosmwasm/wasm/v1beta1/types"; +import { MsgStoreCode, MsgInstantiateContract, MsgExecuteContract } from "../../../cosmwasm/wasm/v1beta1/tx"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** GenesisState - genesis state of x/wasm */ +export interface GenesisState { + params?: Params; + codes: Code[]; + contracts: Contract[]; + sequences: Sequence[]; + genMsgs: GenesisState_GenMsgs[]; +} + +/** + * GenMsgs define the messages that can be executed during genesis phase in + * order. The intention is to have more human readable data that is auditable. + */ +export interface GenesisState_GenMsgs { + storeCode?: MsgStoreCode | undefined; + instantiateContract?: MsgInstantiateContract | undefined; + executeContract?: MsgExecuteContract | undefined; +} + +/** Code struct encompasses CodeInfo and CodeBytes */ +export interface Code { + codeId: Long; + codeInfo?: CodeInfo; + codeBytes: Uint8Array; + /** Pinned to wasmvm cache */ + pinned: boolean; +} + +/** Contract struct encompasses ContractAddress, ContractInfo, and ContractState */ +export interface Contract { + contractAddress: string; + contractInfo?: ContractInfo; + contractState: Model[]; +} + +/** Sequence key and value of an id generation counter */ +export interface Sequence { + idKey: Uint8Array; + value: Long; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.codes) { + Code.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.contracts) { + Contract.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.sequences) { + Sequence.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.genMsgs) { + GenesisState_GenMsgs.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.codes = []; + message.contracts = []; + message.sequences = []; + message.genMsgs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.codes.push(Code.decode(reader, reader.uint32())); + break; + case 3: + message.contracts.push(Contract.decode(reader, reader.uint32())); + break; + case 4: + message.sequences.push(Sequence.decode(reader, reader.uint32())); + break; + case 5: + message.genMsgs.push(GenesisState_GenMsgs.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.codes = []; + message.contracts = []; + message.sequences = []; + message.genMsgs = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.codes !== undefined && object.codes !== null) { + for (const e of object.codes) { + message.codes.push(Code.fromJSON(e)); + } + } + if (object.contracts !== undefined && object.contracts !== null) { + for (const e of object.contracts) { + message.contracts.push(Contract.fromJSON(e)); + } + } + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Sequence.fromJSON(e)); + } + } + if (object.genMsgs !== undefined && object.genMsgs !== null) { + for (const e of object.genMsgs) { + message.genMsgs.push(GenesisState_GenMsgs.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.codes) { + obj.codes = message.codes.map((e) => (e ? Code.toJSON(e) : undefined)); + } else { + obj.codes = []; + } + if (message.contracts) { + obj.contracts = message.contracts.map((e) => (e ? Contract.toJSON(e) : undefined)); + } else { + obj.contracts = []; + } + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e ? Sequence.toJSON(e) : undefined)); + } else { + obj.sequences = []; + } + if (message.genMsgs) { + obj.genMsgs = message.genMsgs.map((e) => (e ? GenesisState_GenMsgs.toJSON(e) : undefined)); + } else { + obj.genMsgs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.codes = []; + message.contracts = []; + message.sequences = []; + message.genMsgs = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.codes !== undefined && object.codes !== null) { + for (const e of object.codes) { + message.codes.push(Code.fromPartial(e)); + } + } + if (object.contracts !== undefined && object.contracts !== null) { + for (const e of object.contracts) { + message.contracts.push(Contract.fromPartial(e)); + } + } + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Sequence.fromPartial(e)); + } + } + if (object.genMsgs !== undefined && object.genMsgs !== null) { + for (const e of object.genMsgs) { + message.genMsgs.push(GenesisState_GenMsgs.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGenesisState_GenMsgs: object = {}; + +export const GenesisState_GenMsgs = { + encode(message: GenesisState_GenMsgs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.storeCode !== undefined) { + MsgStoreCode.encode(message.storeCode, writer.uint32(10).fork()).ldelim(); + } + if (message.instantiateContract !== undefined) { + MsgInstantiateContract.encode(message.instantiateContract, writer.uint32(18).fork()).ldelim(); + } + if (message.executeContract !== undefined) { + MsgExecuteContract.encode(message.executeContract, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState_GenMsgs { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState_GenMsgs } as GenesisState_GenMsgs; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.storeCode = MsgStoreCode.decode(reader, reader.uint32()); + break; + case 2: + message.instantiateContract = MsgInstantiateContract.decode(reader, reader.uint32()); + break; + case 3: + message.executeContract = MsgExecuteContract.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState_GenMsgs { + const message = { ...baseGenesisState_GenMsgs } as GenesisState_GenMsgs; + if (object.storeCode !== undefined && object.storeCode !== null) { + message.storeCode = MsgStoreCode.fromJSON(object.storeCode); + } else { + message.storeCode = undefined; + } + if (object.instantiateContract !== undefined && object.instantiateContract !== null) { + message.instantiateContract = MsgInstantiateContract.fromJSON(object.instantiateContract); + } else { + message.instantiateContract = undefined; + } + if (object.executeContract !== undefined && object.executeContract !== null) { + message.executeContract = MsgExecuteContract.fromJSON(object.executeContract); + } else { + message.executeContract = undefined; + } + return message; + }, + + toJSON(message: GenesisState_GenMsgs): unknown { + const obj: any = {}; + message.storeCode !== undefined && + (obj.storeCode = message.storeCode ? MsgStoreCode.toJSON(message.storeCode) : undefined); + message.instantiateContract !== undefined && + (obj.instantiateContract = message.instantiateContract + ? MsgInstantiateContract.toJSON(message.instantiateContract) + : undefined); + message.executeContract !== undefined && + (obj.executeContract = message.executeContract + ? MsgExecuteContract.toJSON(message.executeContract) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState_GenMsgs { + const message = { ...baseGenesisState_GenMsgs } as GenesisState_GenMsgs; + if (object.storeCode !== undefined && object.storeCode !== null) { + message.storeCode = MsgStoreCode.fromPartial(object.storeCode); + } else { + message.storeCode = undefined; + } + if (object.instantiateContract !== undefined && object.instantiateContract !== null) { + message.instantiateContract = MsgInstantiateContract.fromPartial(object.instantiateContract); + } else { + message.instantiateContract = undefined; + } + if (object.executeContract !== undefined && object.executeContract !== null) { + message.executeContract = MsgExecuteContract.fromPartial(object.executeContract); + } else { + message.executeContract = undefined; + } + return message; + }, +}; + +const baseCode: object = { codeId: Long.UZERO, pinned: false }; + +export const Code = { + encode(message: Code, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.codeInfo !== undefined) { + CodeInfo.encode(message.codeInfo, writer.uint32(18).fork()).ldelim(); + } + if (message.codeBytes.length !== 0) { + writer.uint32(26).bytes(message.codeBytes); + } + if (message.pinned === true) { + writer.uint32(32).bool(message.pinned); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Code { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCode } as Code; + message.codeBytes = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + case 2: + message.codeInfo = CodeInfo.decode(reader, reader.uint32()); + break; + case 3: + message.codeBytes = reader.bytes(); + break; + case 4: + message.pinned = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Code { + const message = { ...baseCode } as Code; + message.codeBytes = new Uint8Array(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfo.fromJSON(object.codeInfo); + } else { + message.codeInfo = undefined; + } + if (object.codeBytes !== undefined && object.codeBytes !== null) { + message.codeBytes = bytesFromBase64(object.codeBytes); + } + if (object.pinned !== undefined && object.pinned !== null) { + message.pinned = Boolean(object.pinned); + } else { + message.pinned = false; + } + return message; + }, + + toJSON(message: Code): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.codeInfo !== undefined && + (obj.codeInfo = message.codeInfo ? CodeInfo.toJSON(message.codeInfo) : undefined); + message.codeBytes !== undefined && + (obj.codeBytes = base64FromBytes( + message.codeBytes !== undefined ? message.codeBytes : new Uint8Array(), + )); + message.pinned !== undefined && (obj.pinned = message.pinned); + return obj; + }, + + fromPartial(object: DeepPartial): Code { + const message = { ...baseCode } as Code; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfo.fromPartial(object.codeInfo); + } else { + message.codeInfo = undefined; + } + if (object.codeBytes !== undefined && object.codeBytes !== null) { + message.codeBytes = object.codeBytes; + } else { + message.codeBytes = new Uint8Array(); + } + if (object.pinned !== undefined && object.pinned !== null) { + message.pinned = object.pinned; + } else { + message.pinned = false; + } + return message; + }, +}; + +const baseContract: object = { contractAddress: "" }; + +export const Contract = { + encode(message: Contract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.contractAddress !== "") { + writer.uint32(10).string(message.contractAddress); + } + if (message.contractInfo !== undefined) { + ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.contractState) { + Model.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Contract { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseContract } as Contract; + message.contractState = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.contractInfo = ContractInfo.decode(reader, reader.uint32()); + break; + case 3: + message.contractState.push(Model.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Contract { + const message = { ...baseContract } as Contract; + message.contractState = []; + if (object.contractAddress !== undefined && object.contractAddress !== null) { + message.contractAddress = String(object.contractAddress); + } else { + message.contractAddress = ""; + } + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromJSON(object.contractInfo); + } else { + message.contractInfo = undefined; + } + if (object.contractState !== undefined && object.contractState !== null) { + for (const e of object.contractState) { + message.contractState.push(Model.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Contract): unknown { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.contractInfo !== undefined && + (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + if (message.contractState) { + obj.contractState = message.contractState.map((e) => (e ? Model.toJSON(e) : undefined)); + } else { + obj.contractState = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Contract { + const message = { ...baseContract } as Contract; + message.contractState = []; + if (object.contractAddress !== undefined && object.contractAddress !== null) { + message.contractAddress = object.contractAddress; + } else { + message.contractAddress = ""; + } + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromPartial(object.contractInfo); + } else { + message.contractInfo = undefined; + } + if (object.contractState !== undefined && object.contractState !== null) { + for (const e of object.contractState) { + message.contractState.push(Model.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSequence: object = { value: Long.UZERO }; + +export const Sequence = { + encode(message: Sequence, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.idKey.length !== 0) { + writer.uint32(10).bytes(message.idKey); + } + if (!message.value.isZero()) { + writer.uint32(16).uint64(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Sequence { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSequence } as Sequence; + message.idKey = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.idKey = reader.bytes(); + break; + case 2: + message.value = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Sequence { + const message = { ...baseSequence } as Sequence; + message.idKey = new Uint8Array(); + if (object.idKey !== undefined && object.idKey !== null) { + message.idKey = bytesFromBase64(object.idKey); + } + if (object.value !== undefined && object.value !== null) { + message.value = Long.fromString(object.value); + } else { + message.value = Long.UZERO; + } + return message; + }, + + toJSON(message: Sequence): unknown { + const obj: any = {}; + message.idKey !== undefined && + (obj.idKey = base64FromBytes(message.idKey !== undefined ? message.idKey : new Uint8Array())); + message.value !== undefined && (obj.value = (message.value || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): Sequence { + const message = { ...baseSequence } as Sequence; + if (object.idKey !== undefined && object.idKey !== null) { + message.idKey = object.idKey; + } else { + message.idKey = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value as Long; + } else { + message.value = Long.UZERO; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/cosmwasm/wasm/v1beta1/ibc.ts b/src/cosmwasm/wasm/v1beta1/ibc.ts new file mode 100644 index 00000000..f80aac8d --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/ibc.ts @@ -0,0 +1,239 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** MsgIBCSend */ +export interface MsgIBCSend { + /** the channel by which the packet will be sent */ + channel: string; + /** + * Timeout height relative to the current block height. + * The timeout is disabled when set to 0. + */ + timeoutHeight: Long; + /** + * Timeout timestamp (in nanoseconds) relative to the current block timestamp. + * The timeout is disabled when set to 0. + */ + timeoutTimestamp: Long; + /** data is the payload to transfer */ + data: Uint8Array; +} + +/** MsgIBCCloseChannel port and channel need to be owned by the contract */ +export interface MsgIBCCloseChannel { + channel: string; +} + +const baseMsgIBCSend: object = { channel: "", timeoutHeight: Long.UZERO, timeoutTimestamp: Long.UZERO }; + +export const MsgIBCSend = { + encode(message: MsgIBCSend, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.channel !== "") { + writer.uint32(18).string(message.channel); + } + if (!message.timeoutHeight.isZero()) { + writer.uint32(32).uint64(message.timeoutHeight); + } + if (!message.timeoutTimestamp.isZero()) { + writer.uint32(40).uint64(message.timeoutTimestamp); + } + if (message.data.length !== 0) { + writer.uint32(50).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgIBCSend { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgIBCSend } as MsgIBCSend; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.channel = reader.string(); + break; + case 4: + message.timeoutHeight = reader.uint64() as Long; + break; + case 5: + message.timeoutTimestamp = reader.uint64() as Long; + break; + case 6: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgIBCSend { + const message = { ...baseMsgIBCSend } as MsgIBCSend; + message.data = new Uint8Array(); + if (object.channel !== undefined && object.channel !== null) { + message.channel = String(object.channel); + } else { + message.channel = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Long.fromString(object.timeoutHeight); + } else { + message.timeoutHeight = Long.UZERO; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = Long.fromString(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = Long.UZERO; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgIBCSend): unknown { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): MsgIBCSend { + const message = { ...baseMsgIBCSend } as MsgIBCSend; + if (object.channel !== undefined && object.channel !== null) { + message.channel = object.channel; + } else { + message.channel = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = object.timeoutHeight as Long; + } else { + message.timeoutHeight = Long.UZERO; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = object.timeoutTimestamp as Long; + } else { + message.timeoutTimestamp = Long.UZERO; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseMsgIBCCloseChannel: object = { channel: "" }; + +export const MsgIBCCloseChannel = { + encode(message: MsgIBCCloseChannel, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.channel !== "") { + writer.uint32(18).string(message.channel); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgIBCCloseChannel { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgIBCCloseChannel } as MsgIBCCloseChannel; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.channel = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgIBCCloseChannel { + const message = { ...baseMsgIBCCloseChannel } as MsgIBCCloseChannel; + if (object.channel !== undefined && object.channel !== null) { + message.channel = String(object.channel); + } else { + message.channel = ""; + } + return message; + }, + + toJSON(message: MsgIBCCloseChannel): unknown { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + return obj; + }, + + fromPartial(object: DeepPartial): MsgIBCCloseChannel { + const message = { ...baseMsgIBCCloseChannel } as MsgIBCCloseChannel; + if (object.channel !== undefined && object.channel !== null) { + message.channel = object.channel; + } else { + message.channel = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/cosmwasm/wasm/v1beta1/proposal.ts b/src/cosmwasm/wasm/v1beta1/proposal.ts new file mode 100644 index 00000000..f7a4d143 --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/proposal.ts @@ -0,0 +1,1071 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { AccessConfig } from "../../../cosmwasm/wasm/v1beta1/types"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** StoreCodeProposal gov proposal content type to submit WASM code to the system */ +export interface StoreCodeProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** WASMByteCode can be raw or gzip compressed */ + wasmByteCode: Uint8Array; + /** + * Source is a valid absolute HTTPS URI to the contract's source code, + * optional + */ + source: string; + /** Builder is a valid docker image name with tag, optional */ + builder: string; + /** InstantiatePermission to apply on contract creation, optional */ + instantiatePermission?: AccessConfig; +} + +/** + * InstantiateContractProposal gov proposal content type to instantiate a + * contract. + */ +export interface InstantiateContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** CodeID is the reference to the stored WASM code */ + codeId: Long; + /** Label is optional metadata to be stored with a constract instance. */ + label: string; + /** InitMsg json encoded message to be passed to the contract on instantiation */ + initMsg: Uint8Array; + /** Funds coins that are transferred to the contract on instantiation */ + funds: Coin[]; +} + +/** MigrateContractProposal gov proposal content type to migrate a contract. */ +export interface MigrateContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** Contract is the address of the smart contract */ + contract: string; + /** CodeID references the new WASM code */ + codeId: Long; + /** MigrateMsg json encoded message to be passed to the contract on migration */ + migrateMsg: Uint8Array; +} + +/** UpdateAdminProposal gov proposal content type to set an admin for a contract. */ +export interface UpdateAdminProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** NewAdmin address to be set */ + newAdmin: string; + /** Contract is the address of the smart contract */ + contract: string; +} + +/** + * ClearAdminProposal gov proposal content type to clear the admin of a + * contract. + */ +export interface ClearAdminProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** Contract is the address of the smart contract */ + contract: string; +} + +/** + * PinCodesProposal gov proposal content type to pin a set of code ids in the + * wasmvm cache. + */ +export interface PinCodesProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** CodeIDs references the new WASM codes */ + codeIds: Long[]; +} + +/** + * UnpinCodesProposal gov proposal content type to unpin a set of code ids in + * the wasmvm cache. + */ +export interface UnpinCodesProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** CodeIDs references the WASM codes */ + codeIds: Long[]; +} + +const baseStoreCodeProposal: object = { title: "", description: "", runAs: "", source: "", builder: "" }; + +export const StoreCodeProposal = { + encode(message: StoreCodeProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.runAs !== "") { + writer.uint32(26).string(message.runAs); + } + if (message.wasmByteCode.length !== 0) { + writer.uint32(34).bytes(message.wasmByteCode); + } + if (message.source !== "") { + writer.uint32(42).string(message.source); + } + if (message.builder !== "") { + writer.uint32(50).string(message.builder); + } + if (message.instantiatePermission !== undefined) { + AccessConfig.encode(message.instantiatePermission, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StoreCodeProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStoreCodeProposal } as StoreCodeProposal; + message.wasmByteCode = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.wasmByteCode = reader.bytes(); + break; + case 5: + message.source = reader.string(); + break; + case 6: + message.builder = reader.string(); + break; + case 7: + message.instantiatePermission = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StoreCodeProposal { + const message = { ...baseStoreCodeProposal } as StoreCodeProposal; + message.wasmByteCode = new Uint8Array(); + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = String(object.runAs); + } else { + message.runAs = ""; + } + if (object.wasmByteCode !== undefined && object.wasmByteCode !== null) { + message.wasmByteCode = bytesFromBase64(object.wasmByteCode); + } + if (object.source !== undefined && object.source !== null) { + message.source = String(object.source); + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = String(object.builder); + } else { + message.builder = ""; + } + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromJSON(object.instantiatePermission); + } else { + message.instantiatePermission = undefined; + } + return message; + }, + + toJSON(message: StoreCodeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.wasmByteCode !== undefined && + (obj.wasmByteCode = base64FromBytes( + message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array(), + )); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + message.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): StoreCodeProposal { + const message = { ...baseStoreCodeProposal } as StoreCodeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = object.runAs; + } else { + message.runAs = ""; + } + if (object.wasmByteCode !== undefined && object.wasmByteCode !== null) { + message.wasmByteCode = object.wasmByteCode; + } else { + message.wasmByteCode = new Uint8Array(); + } + if (object.source !== undefined && object.source !== null) { + message.source = object.source; + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = object.builder; + } else { + message.builder = ""; + } + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromPartial(object.instantiatePermission); + } else { + message.instantiatePermission = undefined; + } + return message; + }, +}; + +const baseInstantiateContractProposal: object = { + title: "", + description: "", + runAs: "", + admin: "", + codeId: Long.UZERO, + label: "", +}; + +export const InstantiateContractProposal = { + encode(message: InstantiateContractProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.runAs !== "") { + writer.uint32(26).string(message.runAs); + } + if (message.admin !== "") { + writer.uint32(34).string(message.admin); + } + if (!message.codeId.isZero()) { + writer.uint32(40).uint64(message.codeId); + } + if (message.label !== "") { + writer.uint32(50).string(message.label); + } + if (message.initMsg.length !== 0) { + writer.uint32(58).bytes(message.initMsg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): InstantiateContractProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInstantiateContractProposal } as InstantiateContractProposal; + message.funds = []; + message.initMsg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.admin = reader.string(); + break; + case 5: + message.codeId = reader.uint64() as Long; + break; + case 6: + message.label = reader.string(); + break; + case 7: + message.initMsg = reader.bytes(); + break; + case 8: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): InstantiateContractProposal { + const message = { ...baseInstantiateContractProposal } as InstantiateContractProposal; + message.funds = []; + message.initMsg = new Uint8Array(); + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = String(object.runAs); + } else { + message.runAs = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = String(object.admin); + } else { + message.admin = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.label !== undefined && object.label !== null) { + message.label = String(object.label); + } else { + message.label = ""; + } + if (object.initMsg !== undefined && object.initMsg !== null) { + message.initMsg = bytesFromBase64(object.initMsg); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: InstantiateContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.admin !== undefined && (obj.admin = message.admin); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.label !== undefined && (obj.label = message.label); + message.initMsg !== undefined && + (obj.initMsg = base64FromBytes(message.initMsg !== undefined ? message.initMsg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): InstantiateContractProposal { + const message = { ...baseInstantiateContractProposal } as InstantiateContractProposal; + message.funds = []; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = object.runAs; + } else { + message.runAs = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } else { + message.admin = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = ""; + } + if (object.initMsg !== undefined && object.initMsg !== null) { + message.initMsg = object.initMsg; + } else { + message.initMsg = new Uint8Array(); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMigrateContractProposal: object = { + title: "", + description: "", + runAs: "", + contract: "", + codeId: Long.UZERO, +}; + +export const MigrateContractProposal = { + encode(message: MigrateContractProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.runAs !== "") { + writer.uint32(26).string(message.runAs); + } + if (message.contract !== "") { + writer.uint32(34).string(message.contract); + } + if (!message.codeId.isZero()) { + writer.uint32(40).uint64(message.codeId); + } + if (message.migrateMsg.length !== 0) { + writer.uint32(50).bytes(message.migrateMsg); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MigrateContractProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMigrateContractProposal } as MigrateContractProposal; + message.migrateMsg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.contract = reader.string(); + break; + case 5: + message.codeId = reader.uint64() as Long; + break; + case 6: + message.migrateMsg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MigrateContractProposal { + const message = { ...baseMigrateContractProposal } as MigrateContractProposal; + message.migrateMsg = new Uint8Array(); + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = String(object.runAs); + } else { + message.runAs = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.migrateMsg !== undefined && object.migrateMsg !== null) { + message.migrateMsg = bytesFromBase64(object.migrateMsg); + } + return message; + }, + + toJSON(message: MigrateContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.migrateMsg !== undefined && + (obj.migrateMsg = base64FromBytes( + message.migrateMsg !== undefined ? message.migrateMsg : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): MigrateContractProposal { + const message = { ...baseMigrateContractProposal } as MigrateContractProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.runAs !== undefined && object.runAs !== null) { + message.runAs = object.runAs; + } else { + message.runAs = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.migrateMsg !== undefined && object.migrateMsg !== null) { + message.migrateMsg = object.migrateMsg; + } else { + message.migrateMsg = new Uint8Array(); + } + return message; + }, +}; + +const baseUpdateAdminProposal: object = { title: "", description: "", newAdmin: "", contract: "" }; + +export const UpdateAdminProposal = { + encode(message: UpdateAdminProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.newAdmin !== "") { + writer.uint32(26).string(message.newAdmin); + } + if (message.contract !== "") { + writer.uint32(34).string(message.contract); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UpdateAdminProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUpdateAdminProposal } as UpdateAdminProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.newAdmin = reader.string(); + break; + case 4: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UpdateAdminProposal { + const message = { ...baseUpdateAdminProposal } as UpdateAdminProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = String(object.newAdmin); + } else { + message.newAdmin = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + return message; + }, + + toJSON(message: UpdateAdminProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + + fromPartial(object: DeepPartial): UpdateAdminProposal { + const message = { ...baseUpdateAdminProposal } as UpdateAdminProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = object.newAdmin; + } else { + message.newAdmin = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + return message; + }, +}; + +const baseClearAdminProposal: object = { title: "", description: "", contract: "" }; + +export const ClearAdminProposal = { + encode(message: ClearAdminProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.contract !== "") { + writer.uint32(26).string(message.contract); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClearAdminProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClearAdminProposal } as ClearAdminProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClearAdminProposal { + const message = { ...baseClearAdminProposal } as ClearAdminProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + return message; + }, + + toJSON(message: ClearAdminProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + + fromPartial(object: DeepPartial): ClearAdminProposal { + const message = { ...baseClearAdminProposal } as ClearAdminProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + return message; + }, +}; + +const basePinCodesProposal: object = { title: "", description: "", codeIds: Long.UZERO }; + +export const PinCodesProposal = { + encode(message: PinCodesProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + writer.uint32(26).fork(); + for (const v of message.codeIds) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PinCodesProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePinCodesProposal } as PinCodesProposal; + message.codeIds = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.codeIds.push(reader.uint64() as Long); + } + } else { + message.codeIds.push(reader.uint64() as Long); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PinCodesProposal { + const message = { ...basePinCodesProposal } as PinCodesProposal; + message.codeIds = []; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.codeIds !== undefined && object.codeIds !== null) { + for (const e of object.codeIds) { + message.codeIds.push(Long.fromString(e)); + } + } + return message; + }, + + toJSON(message: PinCodesProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.codeIds) { + obj.codeIds = message.codeIds.map((e) => (e || Long.UZERO).toString()); + } else { + obj.codeIds = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): PinCodesProposal { + const message = { ...basePinCodesProposal } as PinCodesProposal; + message.codeIds = []; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.codeIds !== undefined && object.codeIds !== null) { + for (const e of object.codeIds) { + message.codeIds.push(e); + } + } + return message; + }, +}; + +const baseUnpinCodesProposal: object = { title: "", description: "", codeIds: Long.UZERO }; + +export const UnpinCodesProposal = { + encode(message: UnpinCodesProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + writer.uint32(26).fork(); + for (const v of message.codeIds) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UnpinCodesProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUnpinCodesProposal } as UnpinCodesProposal; + message.codeIds = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.codeIds.push(reader.uint64() as Long); + } + } else { + message.codeIds.push(reader.uint64() as Long); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UnpinCodesProposal { + const message = { ...baseUnpinCodesProposal } as UnpinCodesProposal; + message.codeIds = []; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.codeIds !== undefined && object.codeIds !== null) { + for (const e of object.codeIds) { + message.codeIds.push(Long.fromString(e)); + } + } + return message; + }, + + toJSON(message: UnpinCodesProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.codeIds) { + obj.codeIds = message.codeIds.map((e) => (e || Long.UZERO).toString()); + } else { + obj.codeIds = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): UnpinCodesProposal { + const message = { ...baseUnpinCodesProposal } as UnpinCodesProposal; + message.codeIds = []; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.codeIds !== undefined && object.codeIds !== null) { + for (const e of object.codeIds) { + message.codeIds.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/cosmwasm/wasm/v1beta1/query.ts b/src/cosmwasm/wasm/v1beta1/query.ts new file mode 100644 index 00000000..cedef7c4 --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/query.ts @@ -0,0 +1,1535 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { ContractInfo, ContractCodeHistoryEntry, Model } from "../../../cosmwasm/wasm/v1beta1/types"; +import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** + * QueryContractInfoRequest is the request type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoRequest { + /** address is the address of the contract to query */ + address: string; +} + +/** + * QueryContractInfoResponse is the response type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoResponse { + /** address is the address of the contract */ + address: string; + contractInfo?: ContractInfo; +} + +/** + * QueryContractHistoryRequest is the request type for the Query/ContractHistory + * RPC method + */ +export interface QueryContractHistoryRequest { + /** address is the address of the contract to query */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} + +/** + * QueryContractHistoryResponse is the response type for the + * Query/ContractHistory RPC method + */ +export interface QueryContractHistoryResponse { + entries: ContractCodeHistoryEntry[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} + +/** + * QueryContractsByCodeRequest is the request type for the Query/ContractsByCode + * RPC method + */ +export interface QueryContractsByCodeRequest { + /** grpc-gateway_out does not support Go style CodID */ + codeId: Long; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} + +/** + * QueryContractsByCodeResponse is the response type for the + * Query/ContractsByCode RPC method + */ +export interface QueryContractsByCodeResponse { + /** contracts are a set of contract addresses */ + contracts: string[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} + +/** + * QueryAllContractStateRequest is the request type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateRequest { + /** address is the address of the contract */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} + +/** + * QueryAllContractStateResponse is the response type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateResponse { + models: Model[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} + +/** + * QueryRawContractStateRequest is the request type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateRequest { + /** address is the address of the contract */ + address: string; + queryData: Uint8Array; +} + +/** + * QueryRawContractStateResponse is the response type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateResponse { + /** Data contains the raw store data */ + data: Uint8Array; +} + +/** + * QuerySmartContractStateRequest is the request type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateRequest { + /** address is the address of the contract */ + address: string; + /** QueryData contains the query data passed to the contract */ + queryData: Uint8Array; +} + +/** + * QuerySmartContractStateResponse is the response type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateResponse { + /** Data contains the json data returned from the smart contract */ + data: Uint8Array; +} + +/** QueryCodeRequest is the request type for the Query/Code RPC method */ +export interface QueryCodeRequest { + /** grpc-gateway_out does not support Go style CodID */ + codeId: Long; +} + +/** CodeInfoResponse contains code meta data from CodeInfo */ +export interface CodeInfoResponse { + /** id for legacy support */ + codeId: Long; + creator: string; + dataHash: Uint8Array; + source: string; + builder: string; +} + +/** QueryCodeResponse is the response type for the Query/Code RPC method */ +export interface QueryCodeResponse { + codeInfo?: CodeInfoResponse; + data: Uint8Array; +} + +/** QueryCodesRequest is the request type for the Query/Codes RPC method */ +export interface QueryCodesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} + +/** QueryCodesResponse is the response type for the Query/Codes RPC method */ +export interface QueryCodesResponse { + codeInfos: CodeInfoResponse[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} + +const baseQueryContractInfoRequest: object = { address: "" }; + +export const QueryContractInfoRequest = { + encode(message: QueryContractInfoRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractInfoRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractInfoRequest } as QueryContractInfoRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractInfoRequest { + const message = { ...baseQueryContractInfoRequest } as QueryContractInfoRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: QueryContractInfoRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractInfoRequest { + const message = { ...baseQueryContractInfoRequest } as QueryContractInfoRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseQueryContractInfoResponse: object = { address: "" }; + +export const QueryContractInfoResponse = { + encode(message: QueryContractInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.contractInfo !== undefined) { + ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractInfoResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractInfoResponse } as QueryContractInfoResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.contractInfo = ContractInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractInfoResponse { + const message = { ...baseQueryContractInfoResponse } as QueryContractInfoResponse; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromJSON(object.contractInfo); + } else { + message.contractInfo = undefined; + } + return message; + }, + + toJSON(message: QueryContractInfoResponse): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.contractInfo !== undefined && + (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractInfoResponse { + const message = { ...baseQueryContractInfoResponse } as QueryContractInfoResponse; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromPartial(object.contractInfo); + } else { + message.contractInfo = undefined; + } + return message; + }, +}; + +const baseQueryContractHistoryRequest: object = { address: "" }; + +export const QueryContractHistoryRequest = { + encode(message: QueryContractHistoryRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractHistoryRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractHistoryRequest } as QueryContractHistoryRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractHistoryRequest { + const message = { ...baseQueryContractHistoryRequest } as QueryContractHistoryRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryContractHistoryRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractHistoryRequest { + const message = { ...baseQueryContractHistoryRequest } as QueryContractHistoryRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryContractHistoryResponse: object = {}; + +export const QueryContractHistoryResponse = { + encode(message: QueryContractHistoryResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.entries) { + ContractCodeHistoryEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractHistoryResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractHistoryResponse } as QueryContractHistoryResponse; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(ContractCodeHistoryEntry.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractHistoryResponse { + const message = { ...baseQueryContractHistoryResponse } as QueryContractHistoryResponse; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(ContractCodeHistoryEntry.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryContractHistoryResponse): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? ContractCodeHistoryEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractHistoryResponse { + const message = { ...baseQueryContractHistoryResponse } as QueryContractHistoryResponse; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(ContractCodeHistoryEntry.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryContractsByCodeRequest: object = { codeId: Long.UZERO }; + +export const QueryContractsByCodeRequest = { + encode(message: QueryContractsByCodeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractsByCodeRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractsByCodeRequest } as QueryContractsByCodeRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractsByCodeRequest { + const message = { ...baseQueryContractsByCodeRequest } as QueryContractsByCodeRequest; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryContractsByCodeRequest): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractsByCodeRequest { + const message = { ...baseQueryContractsByCodeRequest } as QueryContractsByCodeRequest; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryContractsByCodeResponse: object = { contracts: "" }; + +export const QueryContractsByCodeResponse = { + encode(message: QueryContractsByCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.contracts) { + writer.uint32(10).string(v!); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryContractsByCodeResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse; + message.contracts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contracts.push(reader.string()); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryContractsByCodeResponse { + const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse; + message.contracts = []; + if (object.contracts !== undefined && object.contracts !== null) { + for (const e of object.contracts) { + message.contracts.push(String(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryContractsByCodeResponse): unknown { + const obj: any = {}; + if (message.contracts) { + obj.contracts = message.contracts.map((e) => e); + } else { + obj.contracts = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryContractsByCodeResponse { + const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse; + message.contracts = []; + if (object.contracts !== undefined && object.contracts !== null) { + for (const e of object.contracts) { + message.contracts.push(e); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllContractStateRequest: object = { address: "" }; + +export const QueryAllContractStateRequest = { + encode(message: QueryAllContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllContractStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllContractStateRequest } as QueryAllContractStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllContractStateRequest { + const message = { ...baseQueryAllContractStateRequest } as QueryAllContractStateRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryAllContractStateRequest { + const message = { ...baseQueryAllContractStateRequest } as QueryAllContractStateRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllContractStateResponse: object = {}; + +export const QueryAllContractStateResponse = { + encode(message: QueryAllContractStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.models) { + Model.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryAllContractStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllContractStateResponse } as QueryAllContractStateResponse; + message.models = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.models.push(Model.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllContractStateResponse { + const message = { ...baseQueryAllContractStateResponse } as QueryAllContractStateResponse; + message.models = []; + if (object.models !== undefined && object.models !== null) { + for (const e of object.models) { + message.models.push(Model.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllContractStateResponse): unknown { + const obj: any = {}; + if (message.models) { + obj.models = message.models.map((e) => (e ? Model.toJSON(e) : undefined)); + } else { + obj.models = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryAllContractStateResponse { + const message = { ...baseQueryAllContractStateResponse } as QueryAllContractStateResponse; + message.models = []; + if (object.models !== undefined && object.models !== null) { + for (const e of object.models) { + message.models.push(Model.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryRawContractStateRequest: object = { address: "" }; + +export const QueryRawContractStateRequest = { + encode(message: QueryRawContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryRawContractStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryRawContractStateRequest } as QueryRawContractStateRequest; + message.queryData = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.queryData = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryRawContractStateRequest { + const message = { ...baseQueryRawContractStateRequest } as QueryRawContractStateRequest; + message.queryData = new Uint8Array(); + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.queryData !== undefined && object.queryData !== null) { + message.queryData = bytesFromBase64(object.queryData); + } + return message; + }, + + toJSON(message: QueryRawContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && + (obj.queryData = base64FromBytes( + message.queryData !== undefined ? message.queryData : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): QueryRawContractStateRequest { + const message = { ...baseQueryRawContractStateRequest } as QueryRawContractStateRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.queryData !== undefined && object.queryData !== null) { + message.queryData = object.queryData; + } else { + message.queryData = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryRawContractStateResponse: object = {}; + +export const QueryRawContractStateResponse = { + encode(message: QueryRawContractStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryRawContractStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryRawContractStateResponse } as QueryRawContractStateResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryRawContractStateResponse { + const message = { ...baseQueryRawContractStateResponse } as QueryRawContractStateResponse; + message.data = new Uint8Array(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: QueryRawContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): QueryRawContractStateResponse { + const message = { ...baseQueryRawContractStateResponse } as QueryRawContractStateResponse; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseQuerySmartContractStateRequest: object = { address: "" }; + +export const QuerySmartContractStateRequest = { + encode(message: QuerySmartContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QuerySmartContractStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQuerySmartContractStateRequest } as QuerySmartContractStateRequest; + message.queryData = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.queryData = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySmartContractStateRequest { + const message = { ...baseQuerySmartContractStateRequest } as QuerySmartContractStateRequest; + message.queryData = new Uint8Array(); + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.queryData !== undefined && object.queryData !== null) { + message.queryData = bytesFromBase64(object.queryData); + } + return message; + }, + + toJSON(message: QuerySmartContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && + (obj.queryData = base64FromBytes( + message.queryData !== undefined ? message.queryData : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): QuerySmartContractStateRequest { + const message = { ...baseQuerySmartContractStateRequest } as QuerySmartContractStateRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.queryData !== undefined && object.queryData !== null) { + message.queryData = object.queryData; + } else { + message.queryData = new Uint8Array(); + } + return message; + }, +}; + +const baseQuerySmartContractStateResponse: object = {}; + +export const QuerySmartContractStateResponse = { + encode(message: QuerySmartContractStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QuerySmartContractStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQuerySmartContractStateResponse } as QuerySmartContractStateResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySmartContractStateResponse { + const message = { ...baseQuerySmartContractStateResponse } as QuerySmartContractStateResponse; + message.data = new Uint8Array(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: QuerySmartContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): QuerySmartContractStateResponse { + const message = { ...baseQuerySmartContractStateResponse } as QuerySmartContractStateResponse; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryCodeRequest: object = { codeId: Long.UZERO }; + +export const QueryCodeRequest = { + encode(message: QueryCodeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCodeRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryCodeRequest } as QueryCodeRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCodeRequest { + const message = { ...baseQueryCodeRequest } as QueryCodeRequest; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryCodeRequest): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): QueryCodeRequest { + const message = { ...baseQueryCodeRequest } as QueryCodeRequest; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + return message; + }, +}; + +const baseCodeInfoResponse: object = { codeId: Long.UZERO, creator: "", source: "", builder: "" }; + +export const CodeInfoResponse = { + encode(message: CodeInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.dataHash.length !== 0) { + writer.uint32(26).bytes(message.dataHash); + } + if (message.source !== "") { + writer.uint32(34).string(message.source); + } + if (message.builder !== "") { + writer.uint32(42).string(message.builder); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CodeInfoResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCodeInfoResponse } as CodeInfoResponse; + message.dataHash = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + case 2: + message.creator = reader.string(); + break; + case 3: + message.dataHash = reader.bytes(); + break; + case 4: + message.source = reader.string(); + break; + case 5: + message.builder = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CodeInfoResponse { + const message = { ...baseCodeInfoResponse } as CodeInfoResponse; + message.dataHash = new Uint8Array(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = bytesFromBase64(object.dataHash); + } + if (object.source !== undefined && object.source !== null) { + message.source = String(object.source); + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = String(object.builder); + } else { + message.builder = ""; + } + return message; + }, + + toJSON(message: CodeInfoResponse): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + return obj; + }, + + fromPartial(object: DeepPartial): CodeInfoResponse { + const message = { ...baseCodeInfoResponse } as CodeInfoResponse; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = object.dataHash; + } else { + message.dataHash = new Uint8Array(); + } + if (object.source !== undefined && object.source !== null) { + message.source = object.source; + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = object.builder; + } else { + message.builder = ""; + } + return message; + }, +}; + +const baseQueryCodeResponse: object = {}; + +export const QueryCodeResponse = { + encode(message: QueryCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.codeInfo !== undefined) { + CodeInfoResponse.encode(message.codeInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCodeResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryCodeResponse } as QueryCodeResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeInfo = CodeInfoResponse.decode(reader, reader.uint32()); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCodeResponse { + const message = { ...baseQueryCodeResponse } as QueryCodeResponse; + message.data = new Uint8Array(); + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfoResponse.fromJSON(object.codeInfo); + } else { + message.codeInfo = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: QueryCodeResponse): unknown { + const obj: any = {}; + message.codeInfo !== undefined && + (obj.codeInfo = message.codeInfo ? CodeInfoResponse.toJSON(message.codeInfo) : undefined); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): QueryCodeResponse { + const message = { ...baseQueryCodeResponse } as QueryCodeResponse; + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfoResponse.fromPartial(object.codeInfo); + } else { + message.codeInfo = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryCodesRequest: object = {}; + +export const QueryCodesRequest = { + encode(message: QueryCodesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCodesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryCodesRequest } as QueryCodesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCodesRequest { + const message = { ...baseQueryCodesRequest } as QueryCodesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryCodesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryCodesRequest { + const message = { ...baseQueryCodesRequest } as QueryCodesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryCodesResponse: object = {}; + +export const QueryCodesResponse = { + encode(message: QueryCodesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.codeInfos) { + CodeInfoResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryCodesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryCodesResponse } as QueryCodesResponse; + message.codeInfos = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeInfos.push(CodeInfoResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCodesResponse { + const message = { ...baseQueryCodesResponse } as QueryCodesResponse; + message.codeInfos = []; + if (object.codeInfos !== undefined && object.codeInfos !== null) { + for (const e of object.codeInfos) { + message.codeInfos.push(CodeInfoResponse.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryCodesResponse): unknown { + const obj: any = {}; + if (message.codeInfos) { + obj.codeInfos = message.codeInfos.map((e) => (e ? CodeInfoResponse.toJSON(e) : undefined)); + } else { + obj.codeInfos = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryCodesResponse { + const message = { ...baseQueryCodesResponse } as QueryCodesResponse; + message.codeInfos = []; + if (object.codeInfos !== undefined && object.codeInfos !== null) { + for (const e of object.codeInfos) { + message.codeInfos.push(CodeInfoResponse.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** ContractInfo gets the contract meta data */ + ContractInfo(request: QueryContractInfoRequest): Promise; + /** ContractHistory gets the contract code history */ + ContractHistory(request: QueryContractHistoryRequest): Promise; + /** ContractsByCode lists all smart contracts for a code id */ + ContractsByCode(request: QueryContractsByCodeRequest): Promise; + /** AllContractState gets all raw store data for a single contract */ + AllContractState(request: QueryAllContractStateRequest): Promise; + /** RawContractState gets single key from the raw store data of a contract */ + RawContractState(request: QueryRawContractStateRequest): Promise; + /** SmartContractState get smart query result from the contract */ + SmartContractState(request: QuerySmartContractStateRequest): Promise; + /** Code gets the binary code and metadata for a singe wasm code */ + Code(request: QueryCodeRequest): Promise; + /** Codes gets the metadata for all stored wasm codes */ + Codes(request: QueryCodesRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.ContractInfo = this.ContractInfo.bind(this); + this.ContractHistory = this.ContractHistory.bind(this); + this.ContractsByCode = this.ContractsByCode.bind(this); + this.AllContractState = this.AllContractState.bind(this); + this.RawContractState = this.RawContractState.bind(this); + this.SmartContractState = this.SmartContractState.bind(this); + this.Code = this.Code.bind(this); + this.Codes = this.Codes.bind(this); + } + ContractInfo(request: QueryContractInfoRequest): Promise { + const data = QueryContractInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "ContractInfo", data); + return promise.then((data) => QueryContractInfoResponse.decode(new _m0.Reader(data))); + } + + ContractHistory(request: QueryContractHistoryRequest): Promise { + const data = QueryContractHistoryRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "ContractHistory", data); + return promise.then((data) => QueryContractHistoryResponse.decode(new _m0.Reader(data))); + } + + ContractsByCode(request: QueryContractsByCodeRequest): Promise { + const data = QueryContractsByCodeRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "ContractsByCode", data); + return promise.then((data) => QueryContractsByCodeResponse.decode(new _m0.Reader(data))); + } + + AllContractState(request: QueryAllContractStateRequest): Promise { + const data = QueryAllContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "AllContractState", data); + return promise.then((data) => QueryAllContractStateResponse.decode(new _m0.Reader(data))); + } + + RawContractState(request: QueryRawContractStateRequest): Promise { + const data = QueryRawContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "RawContractState", data); + return promise.then((data) => QueryRawContractStateResponse.decode(new _m0.Reader(data))); + } + + SmartContractState(request: QuerySmartContractStateRequest): Promise { + const data = QuerySmartContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "SmartContractState", data); + return promise.then((data) => QuerySmartContractStateResponse.decode(new _m0.Reader(data))); + } + + Code(request: QueryCodeRequest): Promise { + const data = QueryCodeRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "Code", data); + return promise.then((data) => QueryCodeResponse.decode(new _m0.Reader(data))); + } + + Codes(request: QueryCodesRequest): Promise { + const data = QueryCodesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Query", "Codes", data); + return promise.then((data) => QueryCodesResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/cosmwasm/wasm/v1beta1/tx.ts b/src/cosmwasm/wasm/v1beta1/tx.ts new file mode 100644 index 00000000..cd002f65 --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/tx.ts @@ -0,0 +1,1215 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { AccessConfig } from "../../../cosmwasm/wasm/v1beta1/types"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** MsgStoreCode submit Wasm code to the system */ +export interface MsgStoreCode { + /** Sender is the that actor that signed the messages */ + sender: string; + /** WASMByteCode can be raw or gzip compressed */ + wasmByteCode: Uint8Array; + /** + * Source is a valid absolute HTTPS URI to the contract's source code, + * optional + */ + source: string; + /** Builder is a valid docker image name with tag, optional */ + builder: string; + /** + * InstantiatePermission access control to apply on contract creation, + * optional + */ + instantiatePermission?: AccessConfig; +} + +/** MsgStoreCodeResponse returns store result data. */ +export interface MsgStoreCodeResponse { + /** CodeID is the reference to the stored WASM code */ + codeId: Long; +} + +/** + * MsgInstantiateContract create a new smart contract instance for the given + * code id. + */ +export interface MsgInstantiateContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** CodeID is the reference to the stored WASM code */ + codeId: Long; + /** Label is optional metadata to be stored with a contract instance. */ + label: string; + /** InitMsg json encoded message to be passed to the contract on instantiation */ + initMsg: Uint8Array; + /** Funds coins that are transferred to the contract on instantiation */ + funds: Coin[]; +} + +/** MsgInstantiateContractResponse return instantiation result data */ +export interface MsgInstantiateContractResponse { + /** Address is the bech32 address of the new contract instance. */ + address: string; + /** Data contains base64-encoded bytes to returned from the contract */ + data: Uint8Array; +} + +/** MsgExecuteContract submits the given message data to a smart contract */ +export interface MsgExecuteContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; + /** Msg json encoded message to be passed to the contract */ + msg: Uint8Array; + /** Funds coins that are transferred to the contract on execution */ + funds: Coin[]; +} + +/** MsgExecuteContractResponse returns execution result data. */ +export interface MsgExecuteContractResponse { + /** Data contains base64-encoded bytes to returned from the contract */ + data: Uint8Array; +} + +/** MsgMigrateContract runs a code upgrade/ downgrade for a smart contract */ +export interface MsgMigrateContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; + /** CodeID references the new WASM code */ + codeId: Long; + /** MigrateMsg json encoded message to be passed to the contract on migration */ + migrateMsg: Uint8Array; +} + +/** MsgMigrateContractResponse returns contract migration result data. */ +export interface MsgMigrateContractResponse { + /** + * Data contains same raw bytes returned as data from the wasm contract. + * (May be empty) + */ + data: Uint8Array; +} + +/** MsgUpdateAdmin sets a new admin for a smart contract */ +export interface MsgUpdateAdmin { + /** Sender is the that actor that signed the messages */ + sender: string; + /** NewAdmin address to be set */ + newAdmin: string; + /** Contract is the address of the smart contract */ + contract: string; +} + +/** MsgUpdateAdminResponse returns empty data */ +export interface MsgUpdateAdminResponse {} + +/** MsgClearAdmin removes any admin stored for a smart contract */ +export interface MsgClearAdmin { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; +} + +/** MsgClearAdminResponse returns empty data */ +export interface MsgClearAdminResponse {} + +const baseMsgStoreCode: object = { sender: "", source: "", builder: "" }; + +export const MsgStoreCode = { + encode(message: MsgStoreCode, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.wasmByteCode.length !== 0) { + writer.uint32(18).bytes(message.wasmByteCode); + } + if (message.source !== "") { + writer.uint32(26).string(message.source); + } + if (message.builder !== "") { + writer.uint32(34).string(message.builder); + } + if (message.instantiatePermission !== undefined) { + AccessConfig.encode(message.instantiatePermission, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgStoreCode { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgStoreCode } as MsgStoreCode; + message.wasmByteCode = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.wasmByteCode = reader.bytes(); + break; + case 3: + message.source = reader.string(); + break; + case 4: + message.builder = reader.string(); + break; + case 5: + message.instantiatePermission = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgStoreCode { + const message = { ...baseMsgStoreCode } as MsgStoreCode; + message.wasmByteCode = new Uint8Array(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.wasmByteCode !== undefined && object.wasmByteCode !== null) { + message.wasmByteCode = bytesFromBase64(object.wasmByteCode); + } + if (object.source !== undefined && object.source !== null) { + message.source = String(object.source); + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = String(object.builder); + } else { + message.builder = ""; + } + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromJSON(object.instantiatePermission); + } else { + message.instantiatePermission = undefined; + } + return message; + }, + + toJSON(message: MsgStoreCode): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.wasmByteCode !== undefined && + (obj.wasmByteCode = base64FromBytes( + message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array(), + )); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + message.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgStoreCode { + const message = { ...baseMsgStoreCode } as MsgStoreCode; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.wasmByteCode !== undefined && object.wasmByteCode !== null) { + message.wasmByteCode = object.wasmByteCode; + } else { + message.wasmByteCode = new Uint8Array(); + } + if (object.source !== undefined && object.source !== null) { + message.source = object.source; + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = object.builder; + } else { + message.builder = ""; + } + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromPartial(object.instantiatePermission); + } else { + message.instantiatePermission = undefined; + } + return message; + }, +}; + +const baseMsgStoreCodeResponse: object = { codeId: Long.UZERO }; + +export const MsgStoreCodeResponse = { + encode(message: MsgStoreCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgStoreCodeResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgStoreCodeResponse } as MsgStoreCodeResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgStoreCodeResponse { + const message = { ...baseMsgStoreCodeResponse } as MsgStoreCodeResponse; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + return message; + }, + + toJSON(message: MsgStoreCodeResponse): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): MsgStoreCodeResponse { + const message = { ...baseMsgStoreCodeResponse } as MsgStoreCodeResponse; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + return message; + }, +}; + +const baseMsgInstantiateContract: object = { sender: "", admin: "", codeId: Long.UZERO, label: "" }; + +export const MsgInstantiateContract = { + encode(message: MsgInstantiateContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.admin !== "") { + writer.uint32(18).string(message.admin); + } + if (!message.codeId.isZero()) { + writer.uint32(24).uint64(message.codeId); + } + if (message.label !== "") { + writer.uint32(34).string(message.label); + } + if (message.initMsg.length !== 0) { + writer.uint32(42).bytes(message.initMsg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgInstantiateContract { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgInstantiateContract } as MsgInstantiateContract; + message.funds = []; + message.initMsg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.admin = reader.string(); + break; + case 3: + message.codeId = reader.uint64() as Long; + break; + case 4: + message.label = reader.string(); + break; + case 5: + message.initMsg = reader.bytes(); + break; + case 6: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgInstantiateContract { + const message = { ...baseMsgInstantiateContract } as MsgInstantiateContract; + message.funds = []; + message.initMsg = new Uint8Array(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = String(object.admin); + } else { + message.admin = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.label !== undefined && object.label !== null) { + message.label = String(object.label); + } else { + message.label = ""; + } + if (object.initMsg !== undefined && object.initMsg !== null) { + message.initMsg = bytesFromBase64(object.initMsg); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgInstantiateContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.admin !== undefined && (obj.admin = message.admin); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.label !== undefined && (obj.label = message.label); + message.initMsg !== undefined && + (obj.initMsg = base64FromBytes(message.initMsg !== undefined ? message.initMsg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgInstantiateContract { + const message = { ...baseMsgInstantiateContract } as MsgInstantiateContract; + message.funds = []; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } else { + message.admin = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = ""; + } + if (object.initMsg !== undefined && object.initMsg !== null) { + message.initMsg = object.initMsg; + } else { + message.initMsg = new Uint8Array(); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgInstantiateContractResponse: object = { address: "" }; + +export const MsgInstantiateContractResponse = { + encode(message: MsgInstantiateContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgInstantiateContractResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgInstantiateContractResponse } as MsgInstantiateContractResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgInstantiateContractResponse { + const message = { ...baseMsgInstantiateContractResponse } as MsgInstantiateContractResponse; + message.data = new Uint8Array(); + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgInstantiateContractResponse): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): MsgInstantiateContractResponse { + const message = { ...baseMsgInstantiateContractResponse } as MsgInstantiateContractResponse; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseMsgExecuteContract: object = { sender: "", contract: "" }; + +export const MsgExecuteContract = { + encode(message: MsgExecuteContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(18).string(message.contract); + } + if (message.msg.length !== 0) { + writer.uint32(26).bytes(message.msg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgExecuteContract { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExecuteContract } as MsgExecuteContract; + message.funds = []; + message.msg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.contract = reader.string(); + break; + case 3: + message.msg = reader.bytes(); + break; + case 5: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExecuteContract { + const message = { ...baseMsgExecuteContract } as MsgExecuteContract; + message.funds = []; + message.msg = new Uint8Array(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = bytesFromBase64(object.msg); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgExecuteContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgExecuteContract { + const message = { ...baseMsgExecuteContract } as MsgExecuteContract; + message.funds = []; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = object.msg; + } else { + message.msg = new Uint8Array(); + } + if (object.funds !== undefined && object.funds !== null) { + for (const e of object.funds) { + message.funds.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgExecuteContractResponse: object = {}; + +export const MsgExecuteContractResponse = { + encode(message: MsgExecuteContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgExecuteContractResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExecuteContractResponse } as MsgExecuteContractResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExecuteContractResponse { + const message = { ...baseMsgExecuteContractResponse } as MsgExecuteContractResponse; + message.data = new Uint8Array(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgExecuteContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): MsgExecuteContractResponse { + const message = { ...baseMsgExecuteContractResponse } as MsgExecuteContractResponse; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseMsgMigrateContract: object = { sender: "", contract: "", codeId: Long.UZERO }; + +export const MsgMigrateContract = { + encode(message: MsgMigrateContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(18).string(message.contract); + } + if (!message.codeId.isZero()) { + writer.uint32(24).uint64(message.codeId); + } + if (message.migrateMsg.length !== 0) { + writer.uint32(34).bytes(message.migrateMsg); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgMigrateContract { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMigrateContract } as MsgMigrateContract; + message.migrateMsg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.contract = reader.string(); + break; + case 3: + message.codeId = reader.uint64() as Long; + break; + case 4: + message.migrateMsg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgMigrateContract { + const message = { ...baseMsgMigrateContract } as MsgMigrateContract; + message.migrateMsg = new Uint8Array(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.migrateMsg !== undefined && object.migrateMsg !== null) { + message.migrateMsg = bytesFromBase64(object.migrateMsg); + } + return message; + }, + + toJSON(message: MsgMigrateContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.migrateMsg !== undefined && + (obj.migrateMsg = base64FromBytes( + message.migrateMsg !== undefined ? message.migrateMsg : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): MsgMigrateContract { + const message = { ...baseMsgMigrateContract } as MsgMigrateContract; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.migrateMsg !== undefined && object.migrateMsg !== null) { + message.migrateMsg = object.migrateMsg; + } else { + message.migrateMsg = new Uint8Array(); + } + return message; + }, +}; + +const baseMsgMigrateContractResponse: object = {}; + +export const MsgMigrateContractResponse = { + encode(message: MsgMigrateContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgMigrateContractResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMigrateContractResponse } as MsgMigrateContractResponse; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgMigrateContractResponse { + const message = { ...baseMsgMigrateContractResponse } as MsgMigrateContractResponse; + message.data = new Uint8Array(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgMigrateContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): MsgMigrateContractResponse { + const message = { ...baseMsgMigrateContractResponse } as MsgMigrateContractResponse; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseMsgUpdateAdmin: object = { sender: "", newAdmin: "", contract: "" }; + +export const MsgUpdateAdmin = { + encode(message: MsgUpdateAdmin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.newAdmin !== "") { + writer.uint32(18).string(message.newAdmin); + } + if (message.contract !== "") { + writer.uint32(26).string(message.contract); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateAdmin { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateAdmin } as MsgUpdateAdmin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.newAdmin = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpdateAdmin { + const message = { ...baseMsgUpdateAdmin } as MsgUpdateAdmin; + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = String(object.newAdmin); + } else { + message.newAdmin = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + return message; + }, + + toJSON(message: MsgUpdateAdmin): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUpdateAdmin { + const message = { ...baseMsgUpdateAdmin } as MsgUpdateAdmin; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = object.newAdmin; + } else { + message.newAdmin = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + return message; + }, +}; + +const baseMsgUpdateAdminResponse: object = {}; + +export const MsgUpdateAdminResponse = { + encode(_: MsgUpdateAdminResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateAdminResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateAdminResponse } as MsgUpdateAdminResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpdateAdminResponse { + const message = { ...baseMsgUpdateAdminResponse } as MsgUpdateAdminResponse; + return message; + }, + + toJSON(_: MsgUpdateAdminResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgUpdateAdminResponse { + const message = { ...baseMsgUpdateAdminResponse } as MsgUpdateAdminResponse; + return message; + }, +}; + +const baseMsgClearAdmin: object = { sender: "", contract: "" }; + +export const MsgClearAdmin = { + encode(message: MsgClearAdmin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(26).string(message.contract); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgClearAdmin { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgClearAdmin } as MsgClearAdmin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgClearAdmin { + const message = { ...baseMsgClearAdmin } as MsgClearAdmin; + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = String(object.contract); + } else { + message.contract = ""; + } + return message; + }, + + toJSON(message: MsgClearAdmin): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + + fromPartial(object: DeepPartial): MsgClearAdmin { + const message = { ...baseMsgClearAdmin } as MsgClearAdmin; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } else { + message.contract = ""; + } + return message; + }, +}; + +const baseMsgClearAdminResponse: object = {}; + +export const MsgClearAdminResponse = { + encode(_: MsgClearAdminResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgClearAdminResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgClearAdminResponse } as MsgClearAdminResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgClearAdminResponse { + const message = { ...baseMsgClearAdminResponse } as MsgClearAdminResponse; + return message; + }, + + toJSON(_: MsgClearAdminResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgClearAdminResponse { + const message = { ...baseMsgClearAdminResponse } as MsgClearAdminResponse; + return message; + }, +}; + +/** Msg defines the wasm Msg service. */ +export interface Msg { + /** StoreCode to submit Wasm code to the system */ + StoreCode(request: MsgStoreCode): Promise; + /** Instantiate creates a new smart contract instance for the given code id. */ + InstantiateContract(request: MsgInstantiateContract): Promise; + /** Execute submits the given message data to a smart contract */ + ExecuteContract(request: MsgExecuteContract): Promise; + /** Migrate runs a code upgrade/ downgrade for a smart contract */ + MigrateContract(request: MsgMigrateContract): Promise; + /** UpdateAdmin sets a new admin for a smart contract */ + UpdateAdmin(request: MsgUpdateAdmin): Promise; + /** ClearAdmin removes any admin stored for a smart contract */ + ClearAdmin(request: MsgClearAdmin): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.StoreCode = this.StoreCode.bind(this); + this.InstantiateContract = this.InstantiateContract.bind(this); + this.ExecuteContract = this.ExecuteContract.bind(this); + this.MigrateContract = this.MigrateContract.bind(this); + this.UpdateAdmin = this.UpdateAdmin.bind(this); + this.ClearAdmin = this.ClearAdmin.bind(this); + } + StoreCode(request: MsgStoreCode): Promise { + const data = MsgStoreCode.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "StoreCode", data); + return promise.then((data) => MsgStoreCodeResponse.decode(new _m0.Reader(data))); + } + + InstantiateContract(request: MsgInstantiateContract): Promise { + const data = MsgInstantiateContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "InstantiateContract", data); + return promise.then((data) => MsgInstantiateContractResponse.decode(new _m0.Reader(data))); + } + + ExecuteContract(request: MsgExecuteContract): Promise { + const data = MsgExecuteContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "ExecuteContract", data); + return promise.then((data) => MsgExecuteContractResponse.decode(new _m0.Reader(data))); + } + + MigrateContract(request: MsgMigrateContract): Promise { + const data = MsgMigrateContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "MigrateContract", data); + return promise.then((data) => MsgMigrateContractResponse.decode(new _m0.Reader(data))); + } + + UpdateAdmin(request: MsgUpdateAdmin): Promise { + const data = MsgUpdateAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "UpdateAdmin", data); + return promise.then((data) => MsgUpdateAdminResponse.decode(new _m0.Reader(data))); + } + + ClearAdmin(request: MsgClearAdmin): Promise { + const data = MsgClearAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1beta1.Msg", "ClearAdmin", data); + return promise.then((data) => MsgClearAdminResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/cosmwasm/wasm/v1beta1/types.ts b/src/cosmwasm/wasm/v1beta1/types.ts new file mode 100644 index 00000000..e4fc1cc5 --- /dev/null +++ b/src/cosmwasm/wasm/v1beta1/types.ts @@ -0,0 +1,1004 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmwasm.wasm.v1beta1"; + +/** AccessType permission types */ +export enum AccessType { + /** ACCESS_TYPE_UNSPECIFIED - AccessTypeUnspecified placeholder for empty value */ + ACCESS_TYPE_UNSPECIFIED = 0, + /** ACCESS_TYPE_NOBODY - AccessTypeNobody forbidden */ + ACCESS_TYPE_NOBODY = 1, + /** ACCESS_TYPE_ONLY_ADDRESS - AccessTypeOnlyAddress restricted to an address */ + ACCESS_TYPE_ONLY_ADDRESS = 2, + /** ACCESS_TYPE_EVERYBODY - AccessTypeEverybody unrestricted */ + ACCESS_TYPE_EVERYBODY = 3, + UNRECOGNIZED = -1, +} + +export function accessTypeFromJSON(object: any): AccessType { + switch (object) { + case 0: + case "ACCESS_TYPE_UNSPECIFIED": + return AccessType.ACCESS_TYPE_UNSPECIFIED; + case 1: + case "ACCESS_TYPE_NOBODY": + return AccessType.ACCESS_TYPE_NOBODY; + case 2: + case "ACCESS_TYPE_ONLY_ADDRESS": + return AccessType.ACCESS_TYPE_ONLY_ADDRESS; + case 3: + case "ACCESS_TYPE_EVERYBODY": + return AccessType.ACCESS_TYPE_EVERYBODY; + case -1: + case "UNRECOGNIZED": + default: + return AccessType.UNRECOGNIZED; + } +} + +export function accessTypeToJSON(object: AccessType): string { + switch (object) { + case AccessType.ACCESS_TYPE_UNSPECIFIED: + return "ACCESS_TYPE_UNSPECIFIED"; + case AccessType.ACCESS_TYPE_NOBODY: + return "ACCESS_TYPE_NOBODY"; + case AccessType.ACCESS_TYPE_ONLY_ADDRESS: + return "ACCESS_TYPE_ONLY_ADDRESS"; + case AccessType.ACCESS_TYPE_EVERYBODY: + return "ACCESS_TYPE_EVERYBODY"; + default: + return "UNKNOWN"; + } +} + +/** ContractCodeHistoryOperationType actions that caused a code change */ +export enum ContractCodeHistoryOperationType { + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED - ContractCodeHistoryOperationTypeUnspecified placeholder for empty value */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT - ContractCodeHistoryOperationTypeInit on chain contract instantiation */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE - ContractCodeHistoryOperationTypeMigrate code migration */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS - ContractCodeHistoryOperationTypeGenesis based on genesis data */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3, + UNRECOGNIZED = -1, +} + +export function contractCodeHistoryOperationTypeFromJSON(object: any): ContractCodeHistoryOperationType { + switch (object) { + case 0: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED; + case 1: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT; + case 2: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE; + case 3: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS; + case -1: + case "UNRECOGNIZED": + default: + return ContractCodeHistoryOperationType.UNRECOGNIZED; + } +} + +export function contractCodeHistoryOperationTypeToJSON(object: ContractCodeHistoryOperationType): string { + switch (object) { + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS"; + default: + return "UNKNOWN"; + } +} + +/** AccessTypeParam */ +export interface AccessTypeParam { + value: AccessType; +} + +/** AccessConfig access control type. */ +export interface AccessConfig { + permission: AccessType; + address: string; +} + +/** Params defines the set of wasm parameters. */ +export interface Params { + codeUploadAccess?: AccessConfig; + instantiateDefaultPermission: AccessType; + maxWasmCodeSize: Long; +} + +/** CodeInfo is data for the uploaded contract WASM code */ +export interface CodeInfo { + /** CodeHash is the unique identifier created by wasmvm */ + codeHash: Uint8Array; + /** Creator address who initially stored the code */ + creator: string; + /** + * Source is a valid absolute HTTPS URI to the contract's source code, + * optional + */ + source: string; + /** Builder is a valid docker image name with tag, optional */ + builder: string; + /** InstantiateConfig access control to apply on contract creation, optional */ + instantiateConfig?: AccessConfig; +} + +/** ContractInfo stores a WASM contract instance */ +export interface ContractInfo { + /** CodeID is the reference to the stored Wasm code */ + codeId: Long; + /** Creator address who initially instantiated the contract */ + creator: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** Label is optional metadata to be stored with a contract instance. */ + label: string; + /** + * Created Tx position when the contract was instantiated. + * This data should kept internal and not be exposed via query results. Just + * use for sorting + */ + created?: AbsoluteTxPosition; + ibcPortId: string; + /** + * Extension is an extension point to store custom metadata within the + * persistence model. + */ + extension?: Any; +} + +/** ContractCodeHistoryEntry metadata to a contract. */ +export interface ContractCodeHistoryEntry { + operation: ContractCodeHistoryOperationType; + /** CodeID is the reference to the stored WASM code */ + codeId: Long; + /** Updated Tx position when the operation was executed. */ + updated?: AbsoluteTxPosition; + msg: Uint8Array; +} + +/** + * AbsoluteTxPosition is a unique transaction position that allows for global + * ordering of transactions. + */ +export interface AbsoluteTxPosition { + /** BlockHeight is the block the contract was created at */ + blockHeight: Long; + /** + * TxIndex is a monotonic counter within the block (actual transaction index, + * or gas consumed) + */ + txIndex: Long; +} + +/** Model is a struct that holds a KV pair */ +export interface Model { + /** hex-encode key to read it better (this is often ascii) */ + key: Uint8Array; + /** base64-encode raw value */ + value: Uint8Array; +} + +const baseAccessTypeParam: object = { value: 0 }; + +export const AccessTypeParam = { + encode(message: AccessTypeParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.value !== 0) { + writer.uint32(8).int32(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): AccessTypeParam { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAccessTypeParam } as AccessTypeParam; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AccessTypeParam { + const message = { ...baseAccessTypeParam } as AccessTypeParam; + if (object.value !== undefined && object.value !== null) { + message.value = accessTypeFromJSON(object.value); + } else { + message.value = 0; + } + return message; + }, + + toJSON(message: AccessTypeParam): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); + return obj; + }, + + fromPartial(object: DeepPartial): AccessTypeParam { + const message = { ...baseAccessTypeParam } as AccessTypeParam; + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = 0; + } + return message; + }, +}; + +const baseAccessConfig: object = { permission: 0, address: "" }; + +export const AccessConfig = { + encode(message: AccessConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.permission !== 0) { + writer.uint32(8).int32(message.permission); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): AccessConfig { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAccessConfig } as AccessConfig; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.permission = reader.int32() as any; + break; + case 2: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AccessConfig { + const message = { ...baseAccessConfig } as AccessConfig; + if (object.permission !== undefined && object.permission !== null) { + message.permission = accessTypeFromJSON(object.permission); + } else { + message.permission = 0; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: AccessConfig): unknown { + const obj: any = {}; + message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission)); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial(object: DeepPartial): AccessConfig { + const message = { ...baseAccessConfig } as AccessConfig; + if (object.permission !== undefined && object.permission !== null) { + message.permission = object.permission; + } else { + message.permission = 0; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseParams: object = { instantiateDefaultPermission: 0, maxWasmCodeSize: Long.UZERO }; + +export const Params = { + encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.codeUploadAccess !== undefined) { + AccessConfig.encode(message.codeUploadAccess, writer.uint32(10).fork()).ldelim(); + } + if (message.instantiateDefaultPermission !== 0) { + writer.uint32(16).int32(message.instantiateDefaultPermission); + } + if (!message.maxWasmCodeSize.isZero()) { + writer.uint32(24).uint64(message.maxWasmCodeSize); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Params { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeUploadAccess = AccessConfig.decode(reader, reader.uint32()); + break; + case 2: + message.instantiateDefaultPermission = reader.int32() as any; + break; + case 3: + message.maxWasmCodeSize = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) { + message.codeUploadAccess = AccessConfig.fromJSON(object.codeUploadAccess); + } else { + message.codeUploadAccess = undefined; + } + if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) { + message.instantiateDefaultPermission = accessTypeFromJSON(object.instantiateDefaultPermission); + } else { + message.instantiateDefaultPermission = 0; + } + if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) { + message.maxWasmCodeSize = Long.fromString(object.maxWasmCodeSize); + } else { + message.maxWasmCodeSize = Long.UZERO; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.codeUploadAccess !== undefined && + (obj.codeUploadAccess = message.codeUploadAccess + ? AccessConfig.toJSON(message.codeUploadAccess) + : undefined); + message.instantiateDefaultPermission !== undefined && + (obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission)); + message.maxWasmCodeSize !== undefined && + (obj.maxWasmCodeSize = (message.maxWasmCodeSize || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) { + message.codeUploadAccess = AccessConfig.fromPartial(object.codeUploadAccess); + } else { + message.codeUploadAccess = undefined; + } + if (object.instantiateDefaultPermission !== undefined && object.instantiateDefaultPermission !== null) { + message.instantiateDefaultPermission = object.instantiateDefaultPermission; + } else { + message.instantiateDefaultPermission = 0; + } + if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) { + message.maxWasmCodeSize = object.maxWasmCodeSize as Long; + } else { + message.maxWasmCodeSize = Long.UZERO; + } + return message; + }, +}; + +const baseCodeInfo: object = { creator: "", source: "", builder: "" }; + +export const CodeInfo = { + encode(message: CodeInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.codeHash.length !== 0) { + writer.uint32(10).bytes(message.codeHash); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.source !== "") { + writer.uint32(26).string(message.source); + } + if (message.builder !== "") { + writer.uint32(34).string(message.builder); + } + if (message.instantiateConfig !== undefined) { + AccessConfig.encode(message.instantiateConfig, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CodeInfo { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCodeInfo } as CodeInfo; + message.codeHash = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeHash = reader.bytes(); + break; + case 2: + message.creator = reader.string(); + break; + case 3: + message.source = reader.string(); + break; + case 4: + message.builder = reader.string(); + break; + case 5: + message.instantiateConfig = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CodeInfo { + const message = { ...baseCodeInfo } as CodeInfo; + message.codeHash = new Uint8Array(); + if (object.codeHash !== undefined && object.codeHash !== null) { + message.codeHash = bytesFromBase64(object.codeHash); + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.source !== undefined && object.source !== null) { + message.source = String(object.source); + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = String(object.builder); + } else { + message.builder = ""; + } + if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) { + message.instantiateConfig = AccessConfig.fromJSON(object.instantiateConfig); + } else { + message.instantiateConfig = undefined; + } + return message; + }, + + toJSON(message: CodeInfo): unknown { + const obj: any = {}; + message.codeHash !== undefined && + (obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array())); + message.creator !== undefined && (obj.creator = message.creator); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + message.instantiateConfig !== undefined && + (obj.instantiateConfig = message.instantiateConfig + ? AccessConfig.toJSON(message.instantiateConfig) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CodeInfo { + const message = { ...baseCodeInfo } as CodeInfo; + if (object.codeHash !== undefined && object.codeHash !== null) { + message.codeHash = object.codeHash; + } else { + message.codeHash = new Uint8Array(); + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.source !== undefined && object.source !== null) { + message.source = object.source; + } else { + message.source = ""; + } + if (object.builder !== undefined && object.builder !== null) { + message.builder = object.builder; + } else { + message.builder = ""; + } + if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) { + message.instantiateConfig = AccessConfig.fromPartial(object.instantiateConfig); + } else { + message.instantiateConfig = undefined; + } + return message; + }, +}; + +const baseContractInfo: object = { codeId: Long.UZERO, creator: "", admin: "", label: "", ibcPortId: "" }; + +export const ContractInfo = { + encode(message: ContractInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.admin !== "") { + writer.uint32(26).string(message.admin); + } + if (message.label !== "") { + writer.uint32(34).string(message.label); + } + if (message.created !== undefined) { + AbsoluteTxPosition.encode(message.created, writer.uint32(42).fork()).ldelim(); + } + if (message.ibcPortId !== "") { + writer.uint32(50).string(message.ibcPortId); + } + if (message.extension !== undefined) { + Any.encode(message.extension, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ContractInfo { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseContractInfo } as ContractInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64() as Long; + break; + case 2: + message.creator = reader.string(); + break; + case 3: + message.admin = reader.string(); + break; + case 4: + message.label = reader.string(); + break; + case 5: + message.created = AbsoluteTxPosition.decode(reader, reader.uint32()); + break; + case 6: + message.ibcPortId = reader.string(); + break; + case 7: + message.extension = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ContractInfo { + const message = { ...baseContractInfo } as ContractInfo; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = String(object.admin); + } else { + message.admin = ""; + } + if (object.label !== undefined && object.label !== null) { + message.label = String(object.label); + } else { + message.label = ""; + } + if (object.created !== undefined && object.created !== null) { + message.created = AbsoluteTxPosition.fromJSON(object.created); + } else { + message.created = undefined; + } + if (object.ibcPortId !== undefined && object.ibcPortId !== null) { + message.ibcPortId = String(object.ibcPortId); + } else { + message.ibcPortId = ""; + } + if (object.extension !== undefined && object.extension !== null) { + message.extension = Any.fromJSON(object.extension); + } else { + message.extension = undefined; + } + return message; + }, + + toJSON(message: ContractInfo): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.admin !== undefined && (obj.admin = message.admin); + message.label !== undefined && (obj.label = message.label); + message.created !== undefined && + (obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined); + message.ibcPortId !== undefined && (obj.ibcPortId = message.ibcPortId); + message.extension !== undefined && + (obj.extension = message.extension ? Any.toJSON(message.extension) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ContractInfo { + const message = { ...baseContractInfo } as ContractInfo; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } else { + message.admin = ""; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = ""; + } + if (object.created !== undefined && object.created !== null) { + message.created = AbsoluteTxPosition.fromPartial(object.created); + } else { + message.created = undefined; + } + if (object.ibcPortId !== undefined && object.ibcPortId !== null) { + message.ibcPortId = object.ibcPortId; + } else { + message.ibcPortId = ""; + } + if (object.extension !== undefined && object.extension !== null) { + message.extension = Any.fromPartial(object.extension); + } else { + message.extension = undefined; + } + return message; + }, +}; + +const baseContractCodeHistoryEntry: object = { operation: 0, codeId: Long.UZERO }; + +export const ContractCodeHistoryEntry = { + encode(message: ContractCodeHistoryEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.operation !== 0) { + writer.uint32(8).int32(message.operation); + } + if (!message.codeId.isZero()) { + writer.uint32(16).uint64(message.codeId); + } + if (message.updated !== undefined) { + AbsoluteTxPosition.encode(message.updated, writer.uint32(26).fork()).ldelim(); + } + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ContractCodeHistoryEntry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry; + message.msg = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operation = reader.int32() as any; + break; + case 2: + message.codeId = reader.uint64() as Long; + break; + case 3: + message.updated = AbsoluteTxPosition.decode(reader, reader.uint32()); + break; + case 4: + message.msg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ContractCodeHistoryEntry { + const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry; + message.msg = new Uint8Array(); + if (object.operation !== undefined && object.operation !== null) { + message.operation = contractCodeHistoryOperationTypeFromJSON(object.operation); + } else { + message.operation = 0; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = Long.fromString(object.codeId); + } else { + message.codeId = Long.UZERO; + } + if (object.updated !== undefined && object.updated !== null) { + message.updated = AbsoluteTxPosition.fromJSON(object.updated); + } else { + message.updated = undefined; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = bytesFromBase64(object.msg); + } + return message; + }, + + toJSON(message: ContractCodeHistoryEntry): unknown { + const obj: any = {}; + message.operation !== undefined && + (obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation)); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.updated !== undefined && + (obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): ContractCodeHistoryEntry { + const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry; + if (object.operation !== undefined && object.operation !== null) { + message.operation = object.operation; + } else { + message.operation = 0; + } + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = object.codeId as Long; + } else { + message.codeId = Long.UZERO; + } + if (object.updated !== undefined && object.updated !== null) { + message.updated = AbsoluteTxPosition.fromPartial(object.updated); + } else { + message.updated = undefined; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = object.msg; + } else { + message.msg = new Uint8Array(); + } + return message; + }, +}; + +const baseAbsoluteTxPosition: object = { blockHeight: Long.UZERO, txIndex: Long.UZERO }; + +export const AbsoluteTxPosition = { + encode(message: AbsoluteTxPosition, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.blockHeight.isZero()) { + writer.uint32(8).uint64(message.blockHeight); + } + if (!message.txIndex.isZero()) { + writer.uint32(16).uint64(message.txIndex); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): AbsoluteTxPosition { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = reader.uint64() as Long; + break; + case 2: + message.txIndex = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AbsoluteTxPosition { + const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = Long.fromString(object.blockHeight); + } else { + message.blockHeight = Long.UZERO; + } + if (object.txIndex !== undefined && object.txIndex !== null) { + message.txIndex = Long.fromString(object.txIndex); + } else { + message.txIndex = Long.UZERO; + } + return message; + }, + + toJSON(message: AbsoluteTxPosition): unknown { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.UZERO).toString()); + message.txIndex !== undefined && (obj.txIndex = (message.txIndex || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): AbsoluteTxPosition { + const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = object.blockHeight as Long; + } else { + message.blockHeight = Long.UZERO; + } + if (object.txIndex !== undefined && object.txIndex !== null) { + message.txIndex = object.txIndex as Long; + } else { + message.txIndex = Long.UZERO; + } + return message; + }, +}; + +const baseModel: object = {}; + +export const Model = { + encode(message: Model, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Model { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModel } as Model; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Model { + const message = { ...baseModel } as Model; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Model): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): Model { + const message = { ...baseModel } as Model; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/packages/cosmos/src/gogoproto/gogo.ts b/src/gogoproto/gogo.ts similarity index 100% rename from packages/cosmos/src/gogoproto/gogo.ts rename to src/gogoproto/gogo.ts diff --git a/packages/cosmos/src/google/api/annotations.ts b/src/google/api/annotations.ts similarity index 100% rename from packages/cosmos/src/google/api/annotations.ts rename to src/google/api/annotations.ts diff --git a/packages/cosmos/src/google/api/http.ts b/src/google/api/http.ts similarity index 100% rename from packages/cosmos/src/google/api/http.ts rename to src/google/api/http.ts diff --git a/packages/cosmos/src/google/protobuf/any.ts b/src/google/protobuf/any.ts similarity index 100% rename from packages/cosmos/src/google/protobuf/any.ts rename to src/google/protobuf/any.ts diff --git a/packages/cosmos/src/google/protobuf/descriptor.ts b/src/google/protobuf/descriptor.ts similarity index 100% rename from packages/cosmos/src/google/protobuf/descriptor.ts rename to src/google/protobuf/descriptor.ts diff --git a/packages/cosmos/src/google/protobuf/duration.ts b/src/google/protobuf/duration.ts similarity index 100% rename from packages/cosmos/src/google/protobuf/duration.ts rename to src/google/protobuf/duration.ts diff --git a/packages/cosmos/src/google/protobuf/timestamp.ts b/src/google/protobuf/timestamp.ts similarity index 100% rename from packages/cosmos/src/google/protobuf/timestamp.ts rename to src/google/protobuf/timestamp.ts diff --git a/src/ibc/applications/transfer/v1/genesis.ts b/src/ibc/applications/transfer/v1/genesis.ts new file mode 100644 index 00000000..cf5da04e --- /dev/null +++ b/src/ibc/applications/transfer/v1/genesis.ts @@ -0,0 +1,125 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Params, DenomTrace } from "../../../../ibc/applications/transfer/v1/transfer"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** GenesisState defines the ibc-transfer genesis state */ +export interface GenesisState { + portId: string; + denomTraces: DenomTrace[]; + params?: Params; +} + +const baseGenesisState: object = { portId: "" }; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + for (const v of message.denomTraces) { + DenomTrace.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.denomTraces.push(DenomTrace.decode(reader, reader.uint32())); + break; + case 3: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromJSON(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => (e ? DenomTrace.toJSON(e) : undefined)); + } else { + obj.denomTraces = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromPartial(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/applications/transfer/v1/query.ts b/src/ibc/applications/transfer/v1/query.ts new file mode 100644 index 00000000..36e86f7f --- /dev/null +++ b/src/ibc/applications/transfer/v1/query.ts @@ -0,0 +1,451 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { DenomTrace, Params } from "../../../../ibc/applications/transfer/v1/transfer"; +import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC + * method + */ +export interface QueryDenomTraceRequest { + /** hash (in hex format) of the denomination trace information. */ + hash: string; +} + +/** + * QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC + * method. + */ +export interface QueryDenomTraceResponse { + /** denom_trace returns the requested denomination trace information. */ + denomTrace?: DenomTrace; +} + +/** + * QueryConnectionsRequest is the request type for the Query/DenomTraces RPC + * method + */ +export interface QueryDenomTracesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} + +/** + * QueryConnectionsResponse is the response type for the Query/DenomTraces RPC + * method. + */ +export interface QueryDenomTracesResponse { + /** denom_traces returns all denominations trace information. */ + denomTraces: DenomTrace[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Params; +} + +const baseQueryDenomTraceRequest: object = { hash: "" }; + +export const QueryDenomTraceRequest = { + encode(message: QueryDenomTraceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.hash !== "") { + writer.uint32(10).string(message.hash); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDenomTraceRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTraceRequest { + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = String(object.hash); + } else { + message.hash = ""; + } + return message; + }, + + toJSON(message: QueryDenomTraceRequest): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDenomTraceRequest { + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = ""; + } + return message; + }, +}; + +const baseQueryDenomTraceResponse: object = {}; + +export const QueryDenomTraceResponse = { + encode(message: QueryDenomTraceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.denomTrace !== undefined) { + DenomTrace.encode(message.denomTrace, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDenomTraceResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomTraceResponse } as QueryDenomTraceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomTrace = DenomTrace.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTraceResponse { + const message = { ...baseQueryDenomTraceResponse } as QueryDenomTraceResponse; + if (object.denomTrace !== undefined && object.denomTrace !== null) { + message.denomTrace = DenomTrace.fromJSON(object.denomTrace); + } else { + message.denomTrace = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTraceResponse): unknown { + const obj: any = {}; + message.denomTrace !== undefined && + (obj.denomTrace = message.denomTrace ? DenomTrace.toJSON(message.denomTrace) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDenomTraceResponse { + const message = { ...baseQueryDenomTraceResponse } as QueryDenomTraceResponse; + if (object.denomTrace !== undefined && object.denomTrace !== null) { + message.denomTrace = DenomTrace.fromPartial(object.denomTrace); + } else { + message.denomTrace = undefined; + } + return message; + }, +}; + +const baseQueryDenomTracesRequest: object = {}; + +export const QueryDenomTracesRequest = { + encode(message: QueryDenomTracesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDenomTracesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomTracesRequest } as QueryDenomTracesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTracesRequest { + const message = { ...baseQueryDenomTracesRequest } as QueryDenomTracesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTracesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDenomTracesRequest { + const message = { ...baseQueryDenomTracesRequest } as QueryDenomTracesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDenomTracesResponse: object = {}; + +export const QueryDenomTracesResponse = { + encode(message: QueryDenomTracesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.denomTraces) { + DenomTrace.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryDenomTracesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomTracesResponse } as QueryDenomTracesResponse; + message.denomTraces = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomTraces.push(DenomTrace.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTracesResponse { + const message = { ...baseQueryDenomTracesResponse } as QueryDenomTracesResponse; + message.denomTraces = []; + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTracesResponse): unknown { + const obj: any = {}; + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => (e ? DenomTrace.toJSON(e) : undefined)); + } else { + obj.denomTraces = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDenomTracesResponse { + const message = { ...baseQueryDenomTracesResponse } as QueryDenomTracesResponse; + message.denomTraces = []; + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** DenomTrace queries a denomination trace information. */ + DenomTrace(request: QueryDenomTraceRequest): Promise; + /** DenomTraces queries all denomination traces. */ + DenomTraces(request: QueryDenomTracesRequest): Promise; + /** Params queries all parameters of the ibc-transfer module. */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.DenomTrace = this.DenomTrace.bind(this); + this.DenomTraces = this.DenomTraces.bind(this); + this.Params = this.Params.bind(this); + } + DenomTrace(request: QueryDenomTraceRequest): Promise { + const data = QueryDenomTraceRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.applications.transfer.v1.Query", "DenomTrace", data); + return promise.then((data) => QueryDenomTraceResponse.decode(new _m0.Reader(data))); + } + + DenomTraces(request: QueryDenomTracesRequest): Promise { + const data = QueryDenomTracesRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.applications.transfer.v1.Query", "DenomTraces", data); + return promise.then((data) => QueryDenomTracesResponse.decode(new _m0.Reader(data))); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.applications.transfer.v1.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/applications/transfer/v1/transfer.ts b/src/ibc/applications/transfer/v1/transfer.ts new file mode 100644 index 00000000..e96c3beb --- /dev/null +++ b/src/ibc/applications/transfer/v1/transfer.ts @@ -0,0 +1,320 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * FungibleTokenPacketData defines a struct for the packet payload + * See FungibleTokenPacketData spec: + * https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + */ +export interface FungibleTokenPacketData { + /** the token denomination to be transferred */ + denom: string; + /** the token amount to be transferred */ + amount: Long; + /** the sender address */ + sender: string; + /** the recipient address on the destination chain */ + receiver: string; +} + +/** + * DenomTrace contains the base denomination for ICS20 fungible tokens and the + * source tracing information path. + */ +export interface DenomTrace { + /** + * path defines the chain of port/channel identifiers used for tracing the + * source of the fungible token. + */ + path: string; + /** base denomination of the relayed fungible token. */ + baseDenom: string; +} + +/** + * Params defines the set of IBC transfer parameters. + * NOTE: To prevent a single token from being transferred, set the + * TransfersEnabled parameter to true and then set the bank module's SendEnabled + * parameter for the denomination to false. + */ +export interface Params { + /** + * send_enabled enables or disables all cross-chain token transfers from this + * chain. + */ + sendEnabled: boolean; + /** + * receive_enabled enables or disables all cross-chain token transfers to this + * chain. + */ + receiveEnabled: boolean; +} + +const baseFungibleTokenPacketData: object = { denom: "", amount: Long.UZERO, sender: "", receiver: "" }; + +export const FungibleTokenPacketData = { + encode(message: FungibleTokenPacketData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (!message.amount.isZero()) { + writer.uint32(16).uint64(message.amount); + } + if (message.sender !== "") { + writer.uint32(26).string(message.sender); + } + if (message.receiver !== "") { + writer.uint32(34).string(message.receiver); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): FungibleTokenPacketData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFungibleTokenPacketData } as FungibleTokenPacketData; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.uint64() as Long; + break; + case 3: + message.sender = reader.string(); + break; + case 4: + message.receiver = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FungibleTokenPacketData { + const message = { ...baseFungibleTokenPacketData } as FungibleTokenPacketData; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Long.fromString(object.amount); + } else { + message.amount = Long.UZERO; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = String(object.receiver); + } else { + message.receiver = ""; + } + return message; + }, + + toJSON(message: FungibleTokenPacketData): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = (message.amount || Long.UZERO).toString()); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + return obj; + }, + + fromPartial(object: DeepPartial): FungibleTokenPacketData { + const message = { ...baseFungibleTokenPacketData } as FungibleTokenPacketData; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount as Long; + } else { + message.amount = Long.UZERO; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } else { + message.receiver = ""; + } + return message; + }, +}; + +const baseDenomTrace: object = { path: "", baseDenom: "" }; + +export const DenomTrace = { + encode(message: DenomTrace, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path !== "") { + writer.uint32(10).string(message.path); + } + if (message.baseDenom !== "") { + writer.uint32(18).string(message.baseDenom); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DenomTrace { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDenomTrace } as DenomTrace; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + case 2: + message.baseDenom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DenomTrace { + const message = { ...baseDenomTrace } as DenomTrace; + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + if (object.baseDenom !== undefined && object.baseDenom !== null) { + message.baseDenom = String(object.baseDenom); + } else { + message.baseDenom = ""; + } + return message; + }, + + toJSON(message: DenomTrace): unknown { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.baseDenom !== undefined && (obj.baseDenom = message.baseDenom); + return obj; + }, + + fromPartial(object: DeepPartial): DenomTrace { + const message = { ...baseDenomTrace } as DenomTrace; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + if (object.baseDenom !== undefined && object.baseDenom !== null) { + message.baseDenom = object.baseDenom; + } else { + message.baseDenom = ""; + } + return message; + }, +}; + +const baseParams: object = { sendEnabled: false, receiveEnabled: false }; + +export const Params = { + encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sendEnabled === true) { + writer.uint32(8).bool(message.sendEnabled); + } + if (message.receiveEnabled === true) { + writer.uint32(16).bool(message.receiveEnabled); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Params { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sendEnabled = reader.bool(); + break; + case 2: + message.receiveEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + message.sendEnabled = Boolean(object.sendEnabled); + } else { + message.sendEnabled = false; + } + if (object.receiveEnabled !== undefined && object.receiveEnabled !== null) { + message.receiveEnabled = Boolean(object.receiveEnabled); + } else { + message.receiveEnabled = false; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.sendEnabled !== undefined && (obj.sendEnabled = message.sendEnabled); + message.receiveEnabled !== undefined && (obj.receiveEnabled = message.receiveEnabled); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + message.sendEnabled = object.sendEnabled; + } else { + message.sendEnabled = false; + } + if (object.receiveEnabled !== undefined && object.receiveEnabled !== null) { + message.receiveEnabled = object.receiveEnabled; + } else { + message.receiveEnabled = false; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/applications/transfer/v1/tx.ts b/src/ibc/applications/transfer/v1/tx.ts new file mode 100644 index 00000000..3ec28878 --- /dev/null +++ b/src/ibc/applications/transfer/v1/tx.ts @@ -0,0 +1,280 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Coin } from "../../../../cosmos/base/v1beta1/coin"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between + * ICS20 enabled chains. See ICS Spec here: + * https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + */ +export interface MsgTransfer { + /** the port on which the packet will be sent */ + sourcePort: string; + /** the channel by which the packet will be sent */ + sourceChannel: string; + /** the tokens to be transferred */ + token?: Coin; + /** the sender address */ + sender: string; + /** the recipient address on the destination chain */ + receiver: string; + /** + * Timeout height relative to the current block height. + * The timeout is disabled when set to 0. + */ + timeoutHeight?: Height; + /** + * Timeout timestamp (in nanoseconds) relative to the current block timestamp. + * The timeout is disabled when set to 0. + */ + timeoutTimestamp: Long; +} + +/** MsgTransferResponse defines the Msg/Transfer response type. */ +export interface MsgTransferResponse {} + +const baseMsgTransfer: object = { + sourcePort: "", + sourceChannel: "", + sender: "", + receiver: "", + timeoutTimestamp: Long.UZERO, +}; + +export const MsgTransfer = { + encode(message: MsgTransfer, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sourcePort !== "") { + writer.uint32(10).string(message.sourcePort); + } + if (message.sourceChannel !== "") { + writer.uint32(18).string(message.sourceChannel); + } + if (message.token !== undefined) { + Coin.encode(message.token, writer.uint32(26).fork()).ldelim(); + } + if (message.sender !== "") { + writer.uint32(34).string(message.sender); + } + if (message.receiver !== "") { + writer.uint32(42).string(message.receiver); + } + if (message.timeoutHeight !== undefined) { + Height.encode(message.timeoutHeight, writer.uint32(50).fork()).ldelim(); + } + if (!message.timeoutTimestamp.isZero()) { + writer.uint32(56).uint64(message.timeoutTimestamp); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTransfer { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTransfer } as MsgTransfer; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sourcePort = reader.string(); + break; + case 2: + message.sourceChannel = reader.string(); + break; + case 3: + message.token = Coin.decode(reader, reader.uint32()); + break; + case 4: + message.sender = reader.string(); + break; + case 5: + message.receiver = reader.string(); + break; + case 6: + message.timeoutHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.timeoutTimestamp = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTransfer { + const message = { ...baseMsgTransfer } as MsgTransfer; + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = String(object.sourcePort); + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = String(object.sourceChannel); + } else { + message.sourceChannel = ""; + } + if (object.token !== undefined && object.token !== null) { + message.token = Coin.fromJSON(object.token); + } else { + message.token = undefined; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = String(object.receiver); + } else { + message.receiver = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromJSON(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = Long.fromString(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = Long.UZERO; + } + return message; + }, + + toJSON(message: MsgTransfer): unknown { + const obj: any = {}; + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && (obj.sourceChannel = message.sourceChannel); + message.token !== undefined && (obj.token = message.token ? Coin.toJSON(message.token) : undefined); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight ? Height.toJSON(message.timeoutHeight) : undefined); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTransfer { + const message = { ...baseMsgTransfer } as MsgTransfer; + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = object.sourcePort; + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = object.sourceChannel; + } else { + message.sourceChannel = ""; + } + if (object.token !== undefined && object.token !== null) { + message.token = Coin.fromPartial(object.token); + } else { + message.token = undefined; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } else { + message.receiver = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromPartial(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = object.timeoutTimestamp as Long; + } else { + message.timeoutTimestamp = Long.UZERO; + } + return message; + }, +}; + +const baseMsgTransferResponse: object = {}; + +export const MsgTransferResponse = { + encode(_: MsgTransferResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTransferResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgTransferResponse { + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + return message; + }, + + toJSON(_: MsgTransferResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgTransferResponse { + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + return message; + }, +}; + +/** Msg defines the ibc/transfer Msg service. */ +export interface Msg { + /** Transfer defines a rpc handler method for MsgTransfer. */ + Transfer(request: MsgTransfer): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.Transfer = this.Transfer.bind(this); + } + Transfer(request: MsgTransfer): Promise { + const data = MsgTransfer.encode(request).finish(); + const promise = this.rpc.request("ibc.applications.transfer.v1.Msg", "Transfer", data); + return promise.then((data) => MsgTransferResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/channel/v1/channel.ts b/src/ibc/core/channel/v1/channel.ts new file mode 100644 index 00000000..9420ca25 --- /dev/null +++ b/src/ibc/core/channel/v1/channel.ts @@ -0,0 +1,1008 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** + * State defines if a channel is in one of the following states: + * CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. + */ +export enum State { + /** STATE_UNINITIALIZED_UNSPECIFIED - Default State */ + STATE_UNINITIALIZED_UNSPECIFIED = 0, + /** STATE_INIT - A channel has just started the opening handshake. */ + STATE_INIT = 1, + /** STATE_TRYOPEN - A channel has acknowledged the handshake step on the counterparty chain. */ + STATE_TRYOPEN = 2, + /** + * STATE_OPEN - A channel has completed the handshake. Open channels are + * ready to send and receive packets. + */ + STATE_OPEN = 3, + /** + * STATE_CLOSED - A channel has been closed and can no longer be used to send or receive + * packets. + */ + STATE_CLOSED = 4, + UNRECOGNIZED = -1, +} + +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNINITIALIZED_UNSPECIFIED": + return State.STATE_UNINITIALIZED_UNSPECIFIED; + case 1: + case "STATE_INIT": + return State.STATE_INIT; + case 2: + case "STATE_TRYOPEN": + return State.STATE_TRYOPEN; + case 3: + case "STATE_OPEN": + return State.STATE_OPEN; + case 4: + case "STATE_CLOSED": + return State.STATE_CLOSED; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} + +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNINITIALIZED_UNSPECIFIED: + return "STATE_UNINITIALIZED_UNSPECIFIED"; + case State.STATE_INIT: + return "STATE_INIT"; + case State.STATE_TRYOPEN: + return "STATE_TRYOPEN"; + case State.STATE_OPEN: + return "STATE_OPEN"; + case State.STATE_CLOSED: + return "STATE_CLOSED"; + default: + return "UNKNOWN"; + } +} + +/** Order defines if a channel is ORDERED or UNORDERED */ +export enum Order { + /** ORDER_NONE_UNSPECIFIED - zero-value for channel ordering */ + ORDER_NONE_UNSPECIFIED = 0, + /** + * ORDER_UNORDERED - packets can be delivered in any order, which may differ from the order in + * which they were sent. + */ + ORDER_UNORDERED = 1, + /** ORDER_ORDERED - packets are delivered exactly in the order which they were sent */ + ORDER_ORDERED = 2, + UNRECOGNIZED = -1, +} + +export function orderFromJSON(object: any): Order { + switch (object) { + case 0: + case "ORDER_NONE_UNSPECIFIED": + return Order.ORDER_NONE_UNSPECIFIED; + case 1: + case "ORDER_UNORDERED": + return Order.ORDER_UNORDERED; + case 2: + case "ORDER_ORDERED": + return Order.ORDER_ORDERED; + case -1: + case "UNRECOGNIZED": + default: + return Order.UNRECOGNIZED; + } +} + +export function orderToJSON(object: Order): string { + switch (object) { + case Order.ORDER_NONE_UNSPECIFIED: + return "ORDER_NONE_UNSPECIFIED"; + case Order.ORDER_UNORDERED: + return "ORDER_UNORDERED"; + case Order.ORDER_ORDERED: + return "ORDER_ORDERED"; + default: + return "UNKNOWN"; + } +} + +/** + * Channel defines pipeline for exactly-once packet delivery between specific + * modules on separate blockchains, which has at least one end capable of + * sending packets and one end capable of receiving packets. + */ +export interface Channel { + /** current state of the channel end */ + state: State; + /** whether the channel is ordered or unordered */ + ordering: Order; + /** counterparty channel end */ + counterparty?: Counterparty; + /** + * list of connection identifiers, in order, along which packets sent on + * this channel will travel + */ + connectionHops: string[]; + /** opaque channel version, which is agreed upon during the handshake */ + version: string; +} + +/** + * IdentifiedChannel defines a channel with additional port and channel + * identifier fields. + */ +export interface IdentifiedChannel { + /** current state of the channel end */ + state: State; + /** whether the channel is ordered or unordered */ + ordering: Order; + /** counterparty channel end */ + counterparty?: Counterparty; + /** + * list of connection identifiers, in order, along which packets sent on + * this channel will travel + */ + connectionHops: string[]; + /** opaque channel version, which is agreed upon during the handshake */ + version: string; + /** port identifier */ + portId: string; + /** channel identifier */ + channelId: string; +} + +/** Counterparty defines a channel end counterparty */ +export interface Counterparty { + /** port on the counterparty chain which owns the other end of the channel. */ + portId: string; + /** channel end on the counterparty chain */ + channelId: string; +} + +/** Packet defines a type that carries data across different chains through IBC */ +export interface Packet { + /** + * number corresponds to the order of sends and receives, where a Packet + * with an earlier sequence number must be sent and received before a Packet + * with a later sequence number. + */ + sequence: Long; + /** identifies the port on the sending chain. */ + sourcePort: string; + /** identifies the channel end on the sending chain. */ + sourceChannel: string; + /** identifies the port on the receiving chain. */ + destinationPort: string; + /** identifies the channel end on the receiving chain. */ + destinationChannel: string; + /** actual opaque bytes transferred directly to the application module */ + data: Uint8Array; + /** block height after which the packet times out */ + timeoutHeight?: Height; + /** block timestamp (in nanoseconds) after which the packet times out */ + timeoutTimestamp: Long; +} + +/** + * PacketState defines the generic type necessary to retrieve and store + * packet commitments, acknowledgements, and receipts. + * Caller is responsible for knowing the context necessary to interpret this + * state as a commitment, acknowledgement, or a receipt. + */ +export interface PacketState { + /** channel port identifier. */ + portId: string; + /** channel unique identifier. */ + channelId: string; + /** packet sequence. */ + sequence: Long; + /** embedded data that represents packet state. */ + data: Uint8Array; +} + +/** + * Acknowledgement is the recommended acknowledgement format to be used by + * app-specific protocols. + * NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental + * conflicts with other protobuf message formats used for acknowledgements. + * The first byte of any message with this format will be the non-ASCII values + * `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: + * https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope + */ +export interface Acknowledgement { + result: Uint8Array | undefined; + error: string | undefined; +} + +const baseChannel: object = { state: 0, ordering: 0, connectionHops: "", version: "" }; + +export const Channel = { + encode(message: Channel, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.connectionHops) { + writer.uint32(34).string(v!); + } + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Channel { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32() as any; + break; + case 2: + message.ordering = reader.int32() as any; + break; + case 3: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 4: + message.connectionHops.push(reader.string()); + break; + case 5: + message.version = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Channel { + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = orderFromJSON(object.ordering); + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(String(e)); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + return message; + }, + + toJSON(message: Channel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): Channel { + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = object.ordering; + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(e); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + return message; + }, +}; + +const baseIdentifiedChannel: object = { + state: 0, + ordering: 0, + connectionHops: "", + version: "", + portId: "", + channelId: "", +}; + +export const IdentifiedChannel = { + encode(message: IdentifiedChannel, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.connectionHops) { + writer.uint32(34).string(v!); + } + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + if (message.portId !== "") { + writer.uint32(50).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(58).string(message.channelId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IdentifiedChannel { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32() as any; + break; + case 2: + message.ordering = reader.int32() as any; + break; + case 3: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 4: + message.connectionHops.push(reader.string()); + break; + case 5: + message.version = reader.string(); + break; + case 6: + message.portId = reader.string(); + break; + case 7: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedChannel { + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = orderFromJSON(object.ordering); + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(String(e)); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: IdentifiedChannel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedChannel { + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = object.ordering; + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(e); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseCounterparty: object = { portId: "", channelId: "" }; + +export const Counterparty = { + encode(message: Counterparty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Counterparty { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCounterparty } as Counterparty; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const basePacket: object = { + sequence: Long.UZERO, + sourcePort: "", + sourceChannel: "", + destinationPort: "", + destinationChannel: "", + timeoutTimestamp: Long.UZERO, +}; + +export const Packet = { + encode(message: Packet, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.sequence.isZero()) { + writer.uint32(8).uint64(message.sequence); + } + if (message.sourcePort !== "") { + writer.uint32(18).string(message.sourcePort); + } + if (message.sourceChannel !== "") { + writer.uint32(26).string(message.sourceChannel); + } + if (message.destinationPort !== "") { + writer.uint32(34).string(message.destinationPort); + } + if (message.destinationChannel !== "") { + writer.uint32(42).string(message.destinationChannel); + } + if (message.data.length !== 0) { + writer.uint32(50).bytes(message.data); + } + if (message.timeoutHeight !== undefined) { + Height.encode(message.timeoutHeight, writer.uint32(58).fork()).ldelim(); + } + if (!message.timeoutTimestamp.isZero()) { + writer.uint32(64).uint64(message.timeoutTimestamp); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Packet { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacket } as Packet; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = reader.uint64() as Long; + break; + case 2: + message.sourcePort = reader.string(); + break; + case 3: + message.sourceChannel = reader.string(); + break; + case 4: + message.destinationPort = reader.string(); + break; + case 5: + message.destinationChannel = reader.string(); + break; + case 6: + message.data = reader.bytes(); + break; + case 7: + message.timeoutHeight = Height.decode(reader, reader.uint32()); + break; + case 8: + message.timeoutTimestamp = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Packet { + const message = { ...basePacket } as Packet; + message.data = new Uint8Array(); + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = String(object.sourcePort); + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = String(object.sourceChannel); + } else { + message.sourceChannel = ""; + } + if (object.destinationPort !== undefined && object.destinationPort !== null) { + message.destinationPort = String(object.destinationPort); + } else { + message.destinationPort = ""; + } + if (object.destinationChannel !== undefined && object.destinationChannel !== null) { + message.destinationChannel = String(object.destinationChannel); + } else { + message.destinationChannel = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromJSON(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = Long.fromString(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = Long.UZERO; + } + return message; + }, + + toJSON(message: Packet): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && (obj.sourceChannel = message.sourceChannel); + message.destinationPort !== undefined && (obj.destinationPort = message.destinationPort); + message.destinationChannel !== undefined && (obj.destinationChannel = message.destinationChannel); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight ? Height.toJSON(message.timeoutHeight) : undefined); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): Packet { + const message = { ...basePacket } as Packet; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = object.sourcePort; + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = object.sourceChannel; + } else { + message.sourceChannel = ""; + } + if (object.destinationPort !== undefined && object.destinationPort !== null) { + message.destinationPort = object.destinationPort; + } else { + message.destinationPort = ""; + } + if (object.destinationChannel !== undefined && object.destinationChannel !== null) { + message.destinationChannel = object.destinationChannel; + } else { + message.destinationChannel = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromPartial(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = object.timeoutTimestamp as Long; + } else { + message.timeoutTimestamp = Long.UZERO; + } + return message; + }, +}; + +const basePacketState: object = { portId: "", channelId: "", sequence: Long.UZERO }; + +export const PacketState = { + encode(message: PacketState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + if (message.data.length !== 0) { + writer.uint32(34).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PacketState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketState } as PacketState; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = reader.uint64() as Long; + break; + case 4: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketState { + const message = { ...basePacketState } as PacketState; + message.data = new Uint8Array(); + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: PacketState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): PacketState { + const message = { ...basePacketState } as PacketState; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseAcknowledgement: object = {}; + +export const Acknowledgement = { + encode(message: Acknowledgement, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.result !== undefined) { + writer.uint32(170).bytes(message.result); + } + if (message.error !== undefined) { + writer.uint32(178).string(message.error); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Acknowledgement { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAcknowledgement } as Acknowledgement; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 21: + message.result = reader.bytes(); + break; + case 22: + message.error = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Acknowledgement { + const message = { ...baseAcknowledgement } as Acknowledgement; + if (object.result !== undefined && object.result !== null) { + message.result = bytesFromBase64(object.result); + } + if (object.error !== undefined && object.error !== null) { + message.error = String(object.error); + } else { + message.error = undefined; + } + return message; + }, + + toJSON(message: Acknowledgement): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = message.result !== undefined ? base64FromBytes(message.result) : undefined); + message.error !== undefined && (obj.error = message.error); + return obj; + }, + + fromPartial(object: DeepPartial): Acknowledgement { + const message = { ...baseAcknowledgement } as Acknowledgement; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = undefined; + } + if (object.error !== undefined && object.error !== null) { + message.error = object.error; + } else { + message.error = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/channel/v1/genesis.ts b/src/ibc/core/channel/v1/genesis.ts new file mode 100644 index 00000000..939f30d8 --- /dev/null +++ b/src/ibc/core/channel/v1/genesis.ts @@ -0,0 +1,358 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { IdentifiedChannel, PacketState } from "../../../../ibc/core/channel/v1/channel"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** GenesisState defines the ibc channel submodule's genesis state. */ +export interface GenesisState { + channels: IdentifiedChannel[]; + acknowledgements: PacketState[]; + commitments: PacketState[]; + receipts: PacketState[]; + sendSequences: PacketSequence[]; + recvSequences: PacketSequence[]; + ackSequences: PacketSequence[]; + /** the sequence for the next generated channel identifier */ + nextChannelSequence: Long; +} + +/** + * PacketSequence defines the genesis type necessary to retrieve and store + * next send and receive sequences. + */ +export interface PacketSequence { + portId: string; + channelId: string; + sequence: Long; +} + +const baseGenesisState: object = { nextChannelSequence: Long.UZERO }; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.acknowledgements) { + PacketState.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.commitments) { + PacketState.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.receipts) { + PacketState.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.sendSequences) { + PacketSequence.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.recvSequences) { + PacketSequence.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.ackSequences) { + PacketSequence.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (!message.nextChannelSequence.isZero()) { + writer.uint32(64).uint64(message.nextChannelSequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push(IdentifiedChannel.decode(reader, reader.uint32())); + break; + case 2: + message.acknowledgements.push(PacketState.decode(reader, reader.uint32())); + break; + case 3: + message.commitments.push(PacketState.decode(reader, reader.uint32())); + break; + case 4: + message.receipts.push(PacketState.decode(reader, reader.uint32())); + break; + case 5: + message.sendSequences.push(PacketSequence.decode(reader, reader.uint32())); + break; + case 6: + message.recvSequences.push(PacketSequence.decode(reader, reader.uint32())); + break; + case 7: + message.ackSequences.push(PacketSequence.decode(reader, reader.uint32())); + break; + case 8: + message.nextChannelSequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if (object.acknowledgements !== undefined && object.acknowledgements !== null) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromJSON(e)); + } + } + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromJSON(e)); + } + } + if (object.receipts !== undefined && object.receipts !== null) { + for (const e of object.receipts) { + message.receipts.push(PacketState.fromJSON(e)); + } + } + if (object.sendSequences !== undefined && object.sendSequences !== null) { + for (const e of object.sendSequences) { + message.sendSequences.push(PacketSequence.fromJSON(e)); + } + } + if (object.recvSequences !== undefined && object.recvSequences !== null) { + for (const e of object.recvSequences) { + message.recvSequences.push(PacketSequence.fromJSON(e)); + } + } + if (object.ackSequences !== undefined && object.ackSequences !== null) { + for (const e of object.ackSequences) { + message.ackSequences.push(PacketSequence.fromJSON(e)); + } + } + if (object.nextChannelSequence !== undefined && object.nextChannelSequence !== null) { + message.nextChannelSequence = Long.fromString(object.nextChannelSequence); + } else { + message.nextChannelSequence = Long.UZERO; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.acknowledgements = []; + } + if (message.commitments) { + obj.commitments = message.commitments.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.commitments = []; + } + if (message.receipts) { + obj.receipts = message.receipts.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.receipts = []; + } + if (message.sendSequences) { + obj.sendSequences = message.sendSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.sendSequences = []; + } + if (message.recvSequences) { + obj.recvSequences = message.recvSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.recvSequences = []; + } + if (message.ackSequences) { + obj.ackSequences = message.ackSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.ackSequences = []; + } + message.nextChannelSequence !== undefined && + (obj.nextChannelSequence = (message.nextChannelSequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if (object.acknowledgements !== undefined && object.acknowledgements !== null) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromPartial(e)); + } + } + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromPartial(e)); + } + } + if (object.receipts !== undefined && object.receipts !== null) { + for (const e of object.receipts) { + message.receipts.push(PacketState.fromPartial(e)); + } + } + if (object.sendSequences !== undefined && object.sendSequences !== null) { + for (const e of object.sendSequences) { + message.sendSequences.push(PacketSequence.fromPartial(e)); + } + } + if (object.recvSequences !== undefined && object.recvSequences !== null) { + for (const e of object.recvSequences) { + message.recvSequences.push(PacketSequence.fromPartial(e)); + } + } + if (object.ackSequences !== undefined && object.ackSequences !== null) { + for (const e of object.ackSequences) { + message.ackSequences.push(PacketSequence.fromPartial(e)); + } + } + if (object.nextChannelSequence !== undefined && object.nextChannelSequence !== null) { + message.nextChannelSequence = object.nextChannelSequence as Long; + } else { + message.nextChannelSequence = Long.UZERO; + } + return message; + }, +}; + +const basePacketSequence: object = { portId: "", channelId: "", sequence: Long.UZERO }; + +export const PacketSequence = { + encode(message: PacketSequence, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PacketSequence { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketSequence } as PacketSequence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketSequence { + const message = { ...basePacketSequence } as PacketSequence; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + return message; + }, + + toJSON(message: PacketSequence): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): PacketSequence { + const message = { ...basePacketSequence } as PacketSequence; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/channel/v1/query.ts b/src/ibc/core/channel/v1/query.ts new file mode 100644 index 00000000..6c278f9b --- /dev/null +++ b/src/ibc/core/channel/v1/query.ts @@ -0,0 +1,2890 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Channel, IdentifiedChannel, PacketState } from "../../../../ibc/core/channel/v1/channel"; +import { Height, IdentifiedClientState } from "../../../../ibc/core/client/v1/client"; +import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** QueryChannelRequest is the request type for the Query/Channel RPC method */ +export interface QueryChannelRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QueryChannelResponse is the response type for the Query/Channel RPC method. + * Besides the Channel end, it includes a proof and the height from which the + * proof was retrieved. + */ +export interface QueryChannelResponse { + /** channel associated with the request identifiers */ + channel?: Channel; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** QueryChannelsRequest is the request type for the Query/Channels RPC method */ +export interface QueryChannelsRequest { + /** pagination request */ + pagination?: PageRequest; +} + +/** QueryChannelsResponse is the response type for the Query/Channels RPC method. */ +export interface QueryChannelsResponse { + /** list of stored channels of the chain. */ + channels: IdentifiedChannel[]; + /** pagination response */ + pagination?: PageResponse; + /** query block height */ + height?: Height; +} + +/** + * QueryConnectionChannelsRequest is the request type for the + * Query/QueryConnectionChannels RPC method + */ +export interface QueryConnectionChannelsRequest { + /** connection unique identifier */ + connection: string; + /** pagination request */ + pagination?: PageRequest; +} + +/** + * QueryConnectionChannelsResponse is the Response type for the + * Query/QueryConnectionChannels RPC method + */ +export interface QueryConnectionChannelsResponse { + /** list of channels associated with a connection. */ + channels: IdentifiedChannel[]; + /** pagination response */ + pagination?: PageResponse; + /** query block height */ + height?: Height; +} + +/** + * QueryChannelClientStateRequest is the request type for the Query/ClientState + * RPC method + */ +export interface QueryChannelClientStateRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QueryChannelClientStateResponse is the Response type for the + * Query/QueryChannelClientState RPC method + */ +export interface QueryChannelClientStateResponse { + /** client state associated with the channel */ + identifiedClientState?: IdentifiedClientState; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryChannelConsensusStateRequest is the request type for the + * Query/ConsensusState RPC method + */ +export interface QueryChannelConsensusStateRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** revision number of the consensus state */ + revisionNumber: Long; + /** revision height of the consensus state */ + revisionHeight: Long; +} + +/** + * QueryChannelClientStateResponse is the Response type for the + * Query/QueryChannelClientState RPC method + */ +export interface QueryChannelConsensusStateResponse { + /** consensus state associated with the channel */ + consensusState?: Any; + /** client ID associated with the consensus state */ + clientId: string; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryPacketCommitmentRequest is the request type for the + * Query/PacketCommitment RPC method + */ +export interface QueryPacketCommitmentRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: Long; +} + +/** + * QueryPacketCommitmentResponse defines the client query response for a packet + * which also includes a proof and the height from which the proof was + * retrieved + */ +export interface QueryPacketCommitmentResponse { + /** packet associated with the request fields */ + commitment: Uint8Array; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryPacketCommitmentsRequest is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketCommitmentsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** pagination request */ + pagination?: PageRequest; +} + +/** + * QueryPacketCommitmentsResponse is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketCommitmentsResponse { + commitments: PacketState[]; + /** pagination response */ + pagination?: PageResponse; + /** query block height */ + height?: Height; +} + +/** + * QueryPacketReceiptRequest is the request type for the + * Query/PacketReceipt RPC method + */ +export interface QueryPacketReceiptRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: Long; +} + +/** + * QueryPacketReceiptResponse defines the client query response for a packet receipt + * which also includes a proof, and the height from which the proof was + * retrieved + */ +export interface QueryPacketReceiptResponse { + /** success flag for if receipt exists */ + received: boolean; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryPacketAcknowledgementRequest is the request type for the + * Query/PacketAcknowledgement RPC method + */ +export interface QueryPacketAcknowledgementRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: Long; +} + +/** + * QueryPacketAcknowledgementResponse defines the client query response for a + * packet which also includes a proof and the height from which the + * proof was retrieved + */ +export interface QueryPacketAcknowledgementResponse { + /** packet associated with the request fields */ + acknowledgement: Uint8Array; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryPacketAcknowledgementsRequest is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketAcknowledgementsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** pagination request */ + pagination?: PageRequest; +} + +/** + * QueryPacketAcknowledgemetsResponse is the request type for the + * Query/QueryPacketAcknowledgements RPC method + */ +export interface QueryPacketAcknowledgementsResponse { + acknowledgements: PacketState[]; + /** pagination response */ + pagination?: PageResponse; + /** query block height */ + height?: Height; +} + +/** + * QueryUnreceivedPacketsRequest is the request type for the + * Query/UnreceivedPackets RPC method + */ +export interface QueryUnreceivedPacketsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** list of packet sequences */ + packetCommitmentSequences: Long[]; +} + +/** + * QueryUnreceivedPacketsResponse is the response type for the + * Query/UnreceivedPacketCommitments RPC method + */ +export interface QueryUnreceivedPacketsResponse { + /** list of unreceived packet sequences */ + sequences: Long[]; + /** query block height */ + height?: Height; +} + +/** + * QueryUnreceivedAcks is the request type for the + * Query/UnreceivedAcks RPC method + */ +export interface QueryUnreceivedAcksRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** list of acknowledgement sequences */ + packetAckSequences: Long[]; +} + +/** + * QueryUnreceivedAcksResponse is the response type for the + * Query/UnreceivedAcks RPC method + */ +export interface QueryUnreceivedAcksResponse { + /** list of unreceived acknowledgement sequences */ + sequences: Long[]; + /** query block height */ + height?: Height; +} + +/** + * QueryNextSequenceReceiveRequest is the request type for the + * Query/QueryNextSequenceReceiveRequest RPC method + */ +export interface QueryNextSequenceReceiveRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QuerySequenceResponse is the request type for the + * Query/QueryNextSequenceReceiveResponse RPC method + */ +export interface QueryNextSequenceReceiveResponse { + /** next sequence receive number */ + nextSequenceReceive: Long; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +const baseQueryChannelRequest: object = { portId: "", channelId: "" }; + +export const QueryChannelRequest = { + encode(message: QueryChannelRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelRequest { + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryChannelRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelRequest { + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryChannelResponse: object = {}; + +export const QueryChannelResponse = { + encode(message: QueryChannelResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelResponse { + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + message.proof = new Uint8Array(); + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelResponse): unknown { + const obj: any = {}; + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelResponse { + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryChannelsRequest: object = {}; + +export const QueryChannelsRequest = { + encode(message: QueryChannelsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelsRequest { + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryChannelsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelsRequest { + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryChannelsResponse: object = {}; + +export const QueryChannelsResponse = { + encode(message: QueryChannelsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push(IdentifiedChannel.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelsResponse { + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelsResponse { + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryConnectionChannelsRequest: object = { connection: "" }; + +export const QueryConnectionChannelsRequest = { + encode(message: QueryConnectionChannelsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connection !== "") { + writer.uint32(10).string(message.connection); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionChannelsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionChannelsRequest } as QueryConnectionChannelsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connection = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionChannelsRequest { + const message = { ...baseQueryConnectionChannelsRequest } as QueryConnectionChannelsRequest; + if (object.connection !== undefined && object.connection !== null) { + message.connection = String(object.connection); + } else { + message.connection = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionChannelsRequest): unknown { + const obj: any = {}; + message.connection !== undefined && (obj.connection = message.connection); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionChannelsRequest { + const message = { ...baseQueryConnectionChannelsRequest } as QueryConnectionChannelsRequest; + if (object.connection !== undefined && object.connection !== null) { + message.connection = object.connection; + } else { + message.connection = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConnectionChannelsResponse: object = {}; + +export const QueryConnectionChannelsResponse = { + encode(message: QueryConnectionChannelsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionChannelsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionChannelsResponse } as QueryConnectionChannelsResponse; + message.channels = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push(IdentifiedChannel.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionChannelsResponse { + const message = { ...baseQueryConnectionChannelsResponse } as QueryConnectionChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionChannelsResponse { + const message = { ...baseQueryConnectionChannelsResponse } as QueryConnectionChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryChannelClientStateRequest: object = { portId: "", channelId: "" }; + +export const QueryChannelClientStateRequest = { + encode(message: QueryChannelClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelClientStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelClientStateRequest } as QueryChannelClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelClientStateRequest { + const message = { ...baseQueryChannelClientStateRequest } as QueryChannelClientStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryChannelClientStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelClientStateRequest { + const message = { ...baseQueryChannelClientStateRequest } as QueryChannelClientStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryChannelClientStateResponse: object = {}; + +export const QueryChannelClientStateResponse = { + encode(message: QueryChannelClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.identifiedClientState !== undefined) { + IdentifiedClientState.encode(message.identifiedClientState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelClientStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelClientStateResponse } as QueryChannelClientStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifiedClientState = IdentifiedClientState.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelClientStateResponse { + const message = { ...baseQueryChannelClientStateResponse } as QueryChannelClientStateResponse; + message.proof = new Uint8Array(); + if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { + message.identifiedClientState = IdentifiedClientState.fromJSON(object.identifiedClientState); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelClientStateResponse { + const message = { ...baseQueryChannelClientStateResponse } as QueryChannelClientStateResponse; + if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { + message.identifiedClientState = IdentifiedClientState.fromPartial(object.identifiedClientState); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryChannelConsensusStateRequest: object = { + portId: "", + channelId: "", + revisionNumber: Long.UZERO, + revisionHeight: Long.UZERO, +}; + +export const QueryChannelConsensusStateRequest = { + encode(message: QueryChannelConsensusStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.revisionNumber.isZero()) { + writer.uint32(24).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(32).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelConsensusStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelConsensusStateRequest } as QueryChannelConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.revisionNumber = reader.uint64() as Long; + break; + case 4: + message.revisionHeight = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelConsensusStateRequest { + const message = { ...baseQueryChannelConsensusStateRequest } as QueryChannelConsensusStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Long.fromString(object.revisionNumber); + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Long.fromString(object.revisionHeight); + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryChannelConsensusStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelConsensusStateRequest { + const message = { ...baseQueryChannelConsensusStateRequest } as QueryChannelConsensusStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber as Long; + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight as Long; + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, +}; + +const baseQueryChannelConsensusStateResponse: object = { clientId: "" }; + +export const QueryChannelConsensusStateResponse = { + encode(message: QueryChannelConsensusStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryChannelConsensusStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelConsensusStateResponse } as QueryChannelConsensusStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelConsensusStateResponse { + const message = { ...baseQueryChannelConsensusStateResponse } as QueryChannelConsensusStateResponse; + message.proof = new Uint8Array(); + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelConsensusStateResponse { + const message = { ...baseQueryChannelConsensusStateResponse } as QueryChannelConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; + +export const QueryPacketCommitmentRequest = { + encode(message: QueryPacketCommitmentRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketCommitmentRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketCommitmentRequest } as QueryPacketCommitmentRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentRequest { + const message = { ...baseQueryPacketCommitmentRequest } as QueryPacketCommitmentRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketCommitmentRequest { + const message = { ...baseQueryPacketCommitmentRequest } as QueryPacketCommitmentRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + return message; + }, +}; + +const baseQueryPacketCommitmentResponse: object = {}; + +export const QueryPacketCommitmentResponse = { + encode(message: QueryPacketCommitmentResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.commitment.length !== 0) { + writer.uint32(10).bytes(message.commitment); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketCommitmentResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketCommitmentResponse } as QueryPacketCommitmentResponse; + message.commitment = new Uint8Array(); + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commitment = reader.bytes(); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentResponse { + const message = { ...baseQueryPacketCommitmentResponse } as QueryPacketCommitmentResponse; + message.commitment = new Uint8Array(); + message.proof = new Uint8Array(); + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = bytesFromBase64(object.commitment); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentResponse): unknown { + const obj: any = {}; + message.commitment !== undefined && + (obj.commitment = base64FromBytes( + message.commitment !== undefined ? message.commitment : new Uint8Array(), + )); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketCommitmentResponse { + const message = { ...baseQueryPacketCommitmentResponse } as QueryPacketCommitmentResponse; + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = object.commitment; + } else { + message.commitment = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentsRequest: object = { portId: "", channelId: "" }; + +export const QueryPacketCommitmentsRequest = { + encode(message: QueryPacketCommitmentsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketCommitmentsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketCommitmentsRequest } as QueryPacketCommitmentsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentsRequest { + const message = { ...baseQueryPacketCommitmentsRequest } as QueryPacketCommitmentsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketCommitmentsRequest { + const message = { ...baseQueryPacketCommitmentsRequest } as QueryPacketCommitmentsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentsResponse: object = {}; + +export const QueryPacketCommitmentsResponse = { + encode(message: QueryPacketCommitmentsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.commitments) { + PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketCommitmentsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketCommitmentsResponse } as QueryPacketCommitmentsResponse; + message.commitments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commitments.push(PacketState.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentsResponse { + const message = { ...baseQueryPacketCommitmentsResponse } as QueryPacketCommitmentsResponse; + message.commitments = []; + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentsResponse): unknown { + const obj: any = {}; + if (message.commitments) { + obj.commitments = message.commitments.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.commitments = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketCommitmentsResponse { + const message = { ...baseQueryPacketCommitmentsResponse } as QueryPacketCommitmentsResponse; + message.commitments = []; + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryPacketReceiptRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; + +export const QueryPacketReceiptRequest = { + encode(message: QueryPacketReceiptRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketReceiptRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketReceiptRequest } as QueryPacketReceiptRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketReceiptRequest { + const message = { ...baseQueryPacketReceiptRequest } as QueryPacketReceiptRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryPacketReceiptRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketReceiptRequest { + const message = { ...baseQueryPacketReceiptRequest } as QueryPacketReceiptRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + return message; + }, +}; + +const baseQueryPacketReceiptResponse: object = { received: false }; + +export const QueryPacketReceiptResponse = { + encode(message: QueryPacketReceiptResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.received === true) { + writer.uint32(16).bool(message.received); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketReceiptResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketReceiptResponse } as QueryPacketReceiptResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.received = reader.bool(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketReceiptResponse { + const message = { ...baseQueryPacketReceiptResponse } as QueryPacketReceiptResponse; + message.proof = new Uint8Array(); + if (object.received !== undefined && object.received !== null) { + message.received = Boolean(object.received); + } else { + message.received = false; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketReceiptResponse): unknown { + const obj: any = {}; + message.received !== undefined && (obj.received = message.received); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketReceiptResponse { + const message = { ...baseQueryPacketReceiptResponse } as QueryPacketReceiptResponse; + if (object.received !== undefined && object.received !== null) { + message.received = object.received; + } else { + message.received = false; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; + +export const QueryPacketAcknowledgementRequest = { + encode(message: QueryPacketAcknowledgementRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketAcknowledgementRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketAcknowledgementRequest } as QueryPacketAcknowledgementRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementRequest { + const message = { ...baseQueryPacketAcknowledgementRequest } as QueryPacketAcknowledgementRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketAcknowledgementRequest { + const message = { ...baseQueryPacketAcknowledgementRequest } as QueryPacketAcknowledgementRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementResponse: object = {}; + +export const QueryPacketAcknowledgementResponse = { + encode(message: QueryPacketAcknowledgementResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.acknowledgement.length !== 0) { + writer.uint32(10).bytes(message.acknowledgement); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketAcknowledgementResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketAcknowledgementResponse } as QueryPacketAcknowledgementResponse; + message.acknowledgement = new Uint8Array(); + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acknowledgement = reader.bytes(); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementResponse { + const message = { ...baseQueryPacketAcknowledgementResponse } as QueryPacketAcknowledgementResponse; + message.acknowledgement = new Uint8Array(); + message.proof = new Uint8Array(); + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = bytesFromBase64(object.acknowledgement); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementResponse): unknown { + const obj: any = {}; + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketAcknowledgementResponse { + const message = { ...baseQueryPacketAcknowledgementResponse } as QueryPacketAcknowledgementResponse; + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = object.acknowledgement; + } else { + message.acknowledgement = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementsRequest: object = { portId: "", channelId: "" }; + +export const QueryPacketAcknowledgementsRequest = { + encode(message: QueryPacketAcknowledgementsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketAcknowledgementsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketAcknowledgementsRequest } as QueryPacketAcknowledgementsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementsRequest { + const message = { ...baseQueryPacketAcknowledgementsRequest } as QueryPacketAcknowledgementsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketAcknowledgementsRequest { + const message = { ...baseQueryPacketAcknowledgementsRequest } as QueryPacketAcknowledgementsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementsResponse: object = {}; + +export const QueryPacketAcknowledgementsResponse = { + encode(message: QueryPacketAcknowledgementsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.acknowledgements) { + PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryPacketAcknowledgementsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPacketAcknowledgementsResponse } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acknowledgements.push(PacketState.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementsResponse { + const message = { ...baseQueryPacketAcknowledgementsResponse } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + if (object.acknowledgements !== undefined && object.acknowledgements !== null) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementsResponse): unknown { + const obj: any = {}; + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.acknowledgements = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPacketAcknowledgementsResponse { + const message = { ...baseQueryPacketAcknowledgementsResponse } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + if (object.acknowledgements !== undefined && object.acknowledgements !== null) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryUnreceivedPacketsRequest: object = { + portId: "", + channelId: "", + packetCommitmentSequences: Long.UZERO, +}; + +export const QueryUnreceivedPacketsRequest = { + encode(message: QueryUnreceivedPacketsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + writer.uint32(26).fork(); + for (const v of message.packetCommitmentSequences) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryUnreceivedPacketsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryUnreceivedPacketsRequest } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.packetCommitmentSequences.push(reader.uint64() as Long); + } + } else { + message.packetCommitmentSequences.push(reader.uint64() as Long); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedPacketsRequest { + const message = { ...baseQueryUnreceivedPacketsRequest } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.packetCommitmentSequences !== undefined && object.packetCommitmentSequences !== null) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(Long.fromString(e)); + } + } + return message; + }, + + toJSON(message: QueryUnreceivedPacketsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetCommitmentSequences) { + obj.packetCommitmentSequences = message.packetCommitmentSequences.map((e) => + (e || Long.UZERO).toString(), + ); + } else { + obj.packetCommitmentSequences = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): QueryUnreceivedPacketsRequest { + const message = { ...baseQueryUnreceivedPacketsRequest } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.packetCommitmentSequences !== undefined && object.packetCommitmentSequences !== null) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(e); + } + } + return message; + }, +}; + +const baseQueryUnreceivedPacketsResponse: object = { sequences: Long.UZERO }; + +export const QueryUnreceivedPacketsResponse = { + encode(message: QueryUnreceivedPacketsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + writer.uint32(10).fork(); + for (const v of message.sequences) { + writer.uint64(v); + } + writer.ldelim(); + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryUnreceivedPacketsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryUnreceivedPacketsResponse } as QueryUnreceivedPacketsResponse; + message.sequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.sequences.push(reader.uint64() as Long); + } + } else { + message.sequences.push(reader.uint64() as Long); + } + break; + case 2: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedPacketsResponse { + const message = { ...baseQueryUnreceivedPacketsResponse } as QueryUnreceivedPacketsResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Long.fromString(e)); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryUnreceivedPacketsResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.sequences = []; + } + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryUnreceivedPacketsResponse { + const message = { ...baseQueryUnreceivedPacketsResponse } as QueryUnreceivedPacketsResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(e); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryUnreceivedAcksRequest: object = { portId: "", channelId: "", packetAckSequences: Long.UZERO }; + +export const QueryUnreceivedAcksRequest = { + encode(message: QueryUnreceivedAcksRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + writer.uint32(26).fork(); + for (const v of message.packetAckSequences) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryUnreceivedAcksRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryUnreceivedAcksRequest } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.packetAckSequences.push(reader.uint64() as Long); + } + } else { + message.packetAckSequences.push(reader.uint64() as Long); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedAcksRequest { + const message = { ...baseQueryUnreceivedAcksRequest } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.packetAckSequences !== undefined && object.packetAckSequences !== null) { + for (const e of object.packetAckSequences) { + message.packetAckSequences.push(Long.fromString(e)); + } + } + return message; + }, + + toJSON(message: QueryUnreceivedAcksRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetAckSequences) { + obj.packetAckSequences = message.packetAckSequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.packetAckSequences = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): QueryUnreceivedAcksRequest { + const message = { ...baseQueryUnreceivedAcksRequest } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.packetAckSequences !== undefined && object.packetAckSequences !== null) { + for (const e of object.packetAckSequences) { + message.packetAckSequences.push(e); + } + } + return message; + }, +}; + +const baseQueryUnreceivedAcksResponse: object = { sequences: Long.UZERO }; + +export const QueryUnreceivedAcksResponse = { + encode(message: QueryUnreceivedAcksResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + writer.uint32(10).fork(); + for (const v of message.sequences) { + writer.uint64(v); + } + writer.ldelim(); + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryUnreceivedAcksResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryUnreceivedAcksResponse } as QueryUnreceivedAcksResponse; + message.sequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.sequences.push(reader.uint64() as Long); + } + } else { + message.sequences.push(reader.uint64() as Long); + } + break; + case 2: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedAcksResponse { + const message = { ...baseQueryUnreceivedAcksResponse } as QueryUnreceivedAcksResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Long.fromString(e)); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryUnreceivedAcksResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.sequences = []; + } + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryUnreceivedAcksResponse { + const message = { ...baseQueryUnreceivedAcksResponse } as QueryUnreceivedAcksResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(e); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryNextSequenceReceiveRequest: object = { portId: "", channelId: "" }; + +export const QueryNextSequenceReceiveRequest = { + encode(message: QueryNextSequenceReceiveRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryNextSequenceReceiveRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryNextSequenceReceiveRequest } as QueryNextSequenceReceiveRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryNextSequenceReceiveRequest { + const message = { ...baseQueryNextSequenceReceiveRequest } as QueryNextSequenceReceiveRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryNextSequenceReceiveRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryNextSequenceReceiveRequest { + const message = { ...baseQueryNextSequenceReceiveRequest } as QueryNextSequenceReceiveRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryNextSequenceReceiveResponse: object = { nextSequenceReceive: Long.UZERO }; + +export const QueryNextSequenceReceiveResponse = { + encode(message: QueryNextSequenceReceiveResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.nextSequenceReceive.isZero()) { + writer.uint32(8).uint64(message.nextSequenceReceive); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryNextSequenceReceiveResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryNextSequenceReceiveResponse } as QueryNextSequenceReceiveResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextSequenceReceive = reader.uint64() as Long; + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryNextSequenceReceiveResponse { + const message = { ...baseQueryNextSequenceReceiveResponse } as QueryNextSequenceReceiveResponse; + message.proof = new Uint8Array(); + if (object.nextSequenceReceive !== undefined && object.nextSequenceReceive !== null) { + message.nextSequenceReceive = Long.fromString(object.nextSequenceReceive); + } else { + message.nextSequenceReceive = Long.UZERO; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryNextSequenceReceiveResponse): unknown { + const obj: any = {}; + message.nextSequenceReceive !== undefined && + (obj.nextSequenceReceive = (message.nextSequenceReceive || Long.UZERO).toString()); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryNextSequenceReceiveResponse { + const message = { ...baseQueryNextSequenceReceiveResponse } as QueryNextSequenceReceiveResponse; + if (object.nextSequenceReceive !== undefined && object.nextSequenceReceive !== null) { + message.nextSequenceReceive = object.nextSequenceReceive as Long; + } else { + message.nextSequenceReceive = Long.UZERO; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Channel queries an IBC Channel. */ + Channel(request: QueryChannelRequest): Promise; + /** Channels queries all the IBC channels of a chain. */ + Channels(request: QueryChannelsRequest): Promise; + /** + * ConnectionChannels queries all the channels associated with a connection + * end. + */ + ConnectionChannels(request: QueryConnectionChannelsRequest): Promise; + /** + * ChannelClientState queries for the client state for the channel associated + * with the provided channel identifiers. + */ + ChannelClientState(request: QueryChannelClientStateRequest): Promise; + /** + * ChannelConsensusState queries for the consensus state for the channel + * associated with the provided channel identifiers. + */ + ChannelConsensusState( + request: QueryChannelConsensusStateRequest, + ): Promise; + /** PacketCommitment queries a stored packet commitment hash. */ + PacketCommitment(request: QueryPacketCommitmentRequest): Promise; + /** + * PacketCommitments returns all the packet commitments hashes associated + * with a channel. + */ + PacketCommitments(request: QueryPacketCommitmentsRequest): Promise; + /** PacketReceipt queries if a given packet sequence has been received on the queried chain */ + PacketReceipt(request: QueryPacketReceiptRequest): Promise; + /** PacketAcknowledgement queries a stored packet acknowledgement hash. */ + PacketAcknowledgement( + request: QueryPacketAcknowledgementRequest, + ): Promise; + /** + * PacketAcknowledgements returns all the packet acknowledgements associated + * with a channel. + */ + PacketAcknowledgements( + request: QueryPacketAcknowledgementsRequest, + ): Promise; + /** + * UnreceivedPackets returns all the unreceived IBC packets associated with a + * channel and sequences. + */ + UnreceivedPackets(request: QueryUnreceivedPacketsRequest): Promise; + /** + * UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a + * channel and sequences. + */ + UnreceivedAcks(request: QueryUnreceivedAcksRequest): Promise; + /** NextSequenceReceive returns the next receive sequence for a given channel. */ + NextSequenceReceive(request: QueryNextSequenceReceiveRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.Channel = this.Channel.bind(this); + this.Channels = this.Channels.bind(this); + this.ConnectionChannels = this.ConnectionChannels.bind(this); + this.ChannelClientState = this.ChannelClientState.bind(this); + this.ChannelConsensusState = this.ChannelConsensusState.bind(this); + this.PacketCommitment = this.PacketCommitment.bind(this); + this.PacketCommitments = this.PacketCommitments.bind(this); + this.PacketReceipt = this.PacketReceipt.bind(this); + this.PacketAcknowledgement = this.PacketAcknowledgement.bind(this); + this.PacketAcknowledgements = this.PacketAcknowledgements.bind(this); + this.UnreceivedPackets = this.UnreceivedPackets.bind(this); + this.UnreceivedAcks = this.UnreceivedAcks.bind(this); + this.NextSequenceReceive = this.NextSequenceReceive.bind(this); + } + Channel(request: QueryChannelRequest): Promise { + const data = QueryChannelRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "Channel", data); + return promise.then((data) => QueryChannelResponse.decode(new _m0.Reader(data))); + } + + Channels(request: QueryChannelsRequest): Promise { + const data = QueryChannelsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "Channels", data); + return promise.then((data) => QueryChannelsResponse.decode(new _m0.Reader(data))); + } + + ConnectionChannels(request: QueryConnectionChannelsRequest): Promise { + const data = QueryConnectionChannelsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "ConnectionChannels", data); + return promise.then((data) => QueryConnectionChannelsResponse.decode(new _m0.Reader(data))); + } + + ChannelClientState(request: QueryChannelClientStateRequest): Promise { + const data = QueryChannelClientStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "ChannelClientState", data); + return promise.then((data) => QueryChannelClientStateResponse.decode(new _m0.Reader(data))); + } + + ChannelConsensusState( + request: QueryChannelConsensusStateRequest, + ): Promise { + const data = QueryChannelConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "ChannelConsensusState", data); + return promise.then((data) => QueryChannelConsensusStateResponse.decode(new _m0.Reader(data))); + } + + PacketCommitment(request: QueryPacketCommitmentRequest): Promise { + const data = QueryPacketCommitmentRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "PacketCommitment", data); + return promise.then((data) => QueryPacketCommitmentResponse.decode(new _m0.Reader(data))); + } + + PacketCommitments(request: QueryPacketCommitmentsRequest): Promise { + const data = QueryPacketCommitmentsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "PacketCommitments", data); + return promise.then((data) => QueryPacketCommitmentsResponse.decode(new _m0.Reader(data))); + } + + PacketReceipt(request: QueryPacketReceiptRequest): Promise { + const data = QueryPacketReceiptRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "PacketReceipt", data); + return promise.then((data) => QueryPacketReceiptResponse.decode(new _m0.Reader(data))); + } + + PacketAcknowledgement( + request: QueryPacketAcknowledgementRequest, + ): Promise { + const data = QueryPacketAcknowledgementRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "PacketAcknowledgement", data); + return promise.then((data) => QueryPacketAcknowledgementResponse.decode(new _m0.Reader(data))); + } + + PacketAcknowledgements( + request: QueryPacketAcknowledgementsRequest, + ): Promise { + const data = QueryPacketAcknowledgementsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "PacketAcknowledgements", data); + return promise.then((data) => QueryPacketAcknowledgementsResponse.decode(new _m0.Reader(data))); + } + + UnreceivedPackets(request: QueryUnreceivedPacketsRequest): Promise { + const data = QueryUnreceivedPacketsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "UnreceivedPackets", data); + return promise.then((data) => QueryUnreceivedPacketsResponse.decode(new _m0.Reader(data))); + } + + UnreceivedAcks(request: QueryUnreceivedAcksRequest): Promise { + const data = QueryUnreceivedAcksRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "UnreceivedAcks", data); + return promise.then((data) => QueryUnreceivedAcksResponse.decode(new _m0.Reader(data))); + } + + NextSequenceReceive(request: QueryNextSequenceReceiveRequest): Promise { + const data = QueryNextSequenceReceiveRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Query", "NextSequenceReceive", data); + return promise.then((data) => QueryNextSequenceReceiveResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/channel/v1/tx.ts b/src/ibc/core/channel/v1/tx.ts new file mode 100644 index 00000000..cdf82b9f --- /dev/null +++ b/src/ibc/core/channel/v1/tx.ts @@ -0,0 +1,1960 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Channel, Packet } from "../../../../ibc/core/channel/v1/channel"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** + * MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It + * is called by a relayer on Chain A. + */ +export interface MsgChannelOpenInit { + portId: string; + channel?: Channel; + signer: string; +} + +/** MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. */ +export interface MsgChannelOpenInitResponse {} + +/** + * MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel + * on Chain B. + */ +export interface MsgChannelOpenTry { + portId: string; + /** + * in the case of crossing hello's, when both chains call OpenInit, we need the channel identifier + * of the previous channel in state INIT + */ + previousChannelId: string; + channel?: Channel; + counterpartyVersion: string; + proofInit: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. */ +export interface MsgChannelOpenTryResponse {} + +/** + * MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge + * the change of channel state to TRYOPEN on Chain B. + */ +export interface MsgChannelOpenAck { + portId: string; + channelId: string; + counterpartyChannelId: string; + counterpartyVersion: string; + proofTry: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. */ +export interface MsgChannelOpenAckResponse {} + +/** + * MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to + * acknowledge the change of channel state to OPEN on Chain A. + */ +export interface MsgChannelOpenConfirm { + portId: string; + channelId: string; + proofAck: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response type. */ +export interface MsgChannelOpenConfirmResponse {} + +/** + * MsgChannelCloseInit defines a msg sent by a Relayer to Chain A + * to close a channel with Chain B. + */ +export interface MsgChannelCloseInit { + portId: string; + channelId: string; + signer: string; +} + +/** MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. */ +export interface MsgChannelCloseInitResponse {} + +/** + * MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B + * to acknowledge the change of channel state to CLOSED on Chain A. + */ +export interface MsgChannelCloseConfirm { + portId: string; + channelId: string; + proofInit: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response type. */ +export interface MsgChannelCloseConfirmResponse {} + +/** MsgRecvPacket receives incoming IBC packet */ +export interface MsgRecvPacket { + packet?: Packet; + proofCommitment: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgRecvPacketResponse defines the Msg/RecvPacket response type. */ +export interface MsgRecvPacketResponse {} + +/** MsgTimeout receives timed-out packet */ +export interface MsgTimeout { + packet?: Packet; + proofUnreceived: Uint8Array; + proofHeight?: Height; + nextSequenceRecv: Long; + signer: string; +} + +/** MsgTimeoutResponse defines the Msg/Timeout response type. */ +export interface MsgTimeoutResponse {} + +/** MsgTimeoutOnClose timed-out packet upon counterparty channel closure. */ +export interface MsgTimeoutOnClose { + packet?: Packet; + proofUnreceived: Uint8Array; + proofClose: Uint8Array; + proofHeight?: Height; + nextSequenceRecv: Long; + signer: string; +} + +/** MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. */ +export interface MsgTimeoutOnCloseResponse {} + +/** MsgAcknowledgement receives incoming IBC acknowledgement */ +export interface MsgAcknowledgement { + packet?: Packet; + acknowledgement: Uint8Array; + proofAcked: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. */ +export interface MsgAcknowledgementResponse {} + +const baseMsgChannelOpenInit: object = { portId: "", signer: "" }; + +export const MsgChannelOpenInit = { + encode(message: MsgChannelOpenInit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenInit { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenInit { + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenInit { + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenInitResponse: object = {}; + +export const MsgChannelOpenInitResponse = { + encode(_: MsgChannelOpenInitResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenInitResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenInitResponse } as MsgChannelOpenInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenInitResponse { + const message = { ...baseMsgChannelOpenInitResponse } as MsgChannelOpenInitResponse; + return message; + }, + + toJSON(_: MsgChannelOpenInitResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelOpenInitResponse { + const message = { ...baseMsgChannelOpenInitResponse } as MsgChannelOpenInitResponse; + return message; + }, +}; + +const baseMsgChannelOpenTry: object = { + portId: "", + previousChannelId: "", + counterpartyVersion: "", + signer: "", +}; + +export const MsgChannelOpenTry = { + encode(message: MsgChannelOpenTry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.previousChannelId !== "") { + writer.uint32(18).string(message.previousChannelId); + } + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(26).fork()).ldelim(); + } + if (message.counterpartyVersion !== "") { + writer.uint32(34).string(message.counterpartyVersion); + } + if (message.proofInit.length !== 0) { + writer.uint32(42).bytes(message.proofInit); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(58).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenTry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + message.proofInit = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.previousChannelId = reader.string(); + break; + case 3: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 4: + message.counterpartyVersion = reader.string(); + break; + case 5: + message.proofInit = reader.bytes(); + break; + case 6: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenTry { + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + message.proofInit = new Uint8Array(); + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.previousChannelId !== undefined && object.previousChannelId !== null) { + message.previousChannelId = String(object.previousChannelId); + } else { + message.previousChannelId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if (object.counterpartyVersion !== undefined && object.counterpartyVersion !== null) { + message.counterpartyVersion = String(object.counterpartyVersion); + } else { + message.counterpartyVersion = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenTry): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.previousChannelId !== undefined && (obj.previousChannelId = message.previousChannelId); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + message.counterpartyVersion !== undefined && (obj.counterpartyVersion = message.counterpartyVersion); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenTry { + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.previousChannelId !== undefined && object.previousChannelId !== null) { + message.previousChannelId = object.previousChannelId; + } else { + message.previousChannelId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if (object.counterpartyVersion !== undefined && object.counterpartyVersion !== null) { + message.counterpartyVersion = object.counterpartyVersion; + } else { + message.counterpartyVersion = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenTryResponse: object = {}; + +export const MsgChannelOpenTryResponse = { + encode(_: MsgChannelOpenTryResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenTryResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenTryResponse } as MsgChannelOpenTryResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenTryResponse { + const message = { ...baseMsgChannelOpenTryResponse } as MsgChannelOpenTryResponse; + return message; + }, + + toJSON(_: MsgChannelOpenTryResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelOpenTryResponse { + const message = { ...baseMsgChannelOpenTryResponse } as MsgChannelOpenTryResponse; + return message; + }, +}; + +const baseMsgChannelOpenAck: object = { + portId: "", + channelId: "", + counterpartyChannelId: "", + counterpartyVersion: "", + signer: "", +}; + +export const MsgChannelOpenAck = { + encode(message: MsgChannelOpenAck, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.counterpartyChannelId !== "") { + writer.uint32(26).string(message.counterpartyChannelId); + } + if (message.counterpartyVersion !== "") { + writer.uint32(34).string(message.counterpartyVersion); + } + if (message.proofTry.length !== 0) { + writer.uint32(42).bytes(message.proofTry); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(58).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenAck { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + message.proofTry = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.counterpartyChannelId = reader.string(); + break; + case 4: + message.counterpartyVersion = reader.string(); + break; + case 5: + message.proofTry = reader.bytes(); + break; + case 6: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenAck { + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + message.proofTry = new Uint8Array(); + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.counterpartyChannelId !== undefined && object.counterpartyChannelId !== null) { + message.counterpartyChannelId = String(object.counterpartyChannelId); + } else { + message.counterpartyChannelId = ""; + } + if (object.counterpartyVersion !== undefined && object.counterpartyVersion !== null) { + message.counterpartyVersion = String(object.counterpartyVersion); + } else { + message.counterpartyVersion = ""; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = bytesFromBase64(object.proofTry); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenAck): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.counterpartyChannelId !== undefined && + (obj.counterpartyChannelId = message.counterpartyChannelId); + message.counterpartyVersion !== undefined && (obj.counterpartyVersion = message.counterpartyVersion); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes(message.proofTry !== undefined ? message.proofTry : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenAck { + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.counterpartyChannelId !== undefined && object.counterpartyChannelId !== null) { + message.counterpartyChannelId = object.counterpartyChannelId; + } else { + message.counterpartyChannelId = ""; + } + if (object.counterpartyVersion !== undefined && object.counterpartyVersion !== null) { + message.counterpartyVersion = object.counterpartyVersion; + } else { + message.counterpartyVersion = ""; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = object.proofTry; + } else { + message.proofTry = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenAckResponse: object = {}; + +export const MsgChannelOpenAckResponse = { + encode(_: MsgChannelOpenAckResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenAckResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenAckResponse } as MsgChannelOpenAckResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenAckResponse { + const message = { ...baseMsgChannelOpenAckResponse } as MsgChannelOpenAckResponse; + return message; + }, + + toJSON(_: MsgChannelOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelOpenAckResponse { + const message = { ...baseMsgChannelOpenAckResponse } as MsgChannelOpenAckResponse; + return message; + }, +}; + +const baseMsgChannelOpenConfirm: object = { portId: "", channelId: "", signer: "" }; + +export const MsgChannelOpenConfirm = { + encode(message: MsgChannelOpenConfirm, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.proofAck.length !== 0) { + writer.uint32(26).bytes(message.proofAck); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenConfirm { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + message.proofAck = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.proofAck = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenConfirm { + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + message.proofAck = new Uint8Array(); + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = bytesFromBase64(object.proofAck); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes(message.proofAck !== undefined ? message.proofAck : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenConfirm { + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = object.proofAck; + } else { + message.proofAck = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenConfirmResponse: object = {}; + +export const MsgChannelOpenConfirmResponse = { + encode(_: MsgChannelOpenConfirmResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelOpenConfirmResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenConfirmResponse } as MsgChannelOpenConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenConfirmResponse { + const message = { ...baseMsgChannelOpenConfirmResponse } as MsgChannelOpenConfirmResponse; + return message; + }, + + toJSON(_: MsgChannelOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelOpenConfirmResponse { + const message = { ...baseMsgChannelOpenConfirmResponse } as MsgChannelOpenConfirmResponse; + return message; + }, +}; + +const baseMsgChannelCloseInit: object = { portId: "", channelId: "", signer: "" }; + +export const MsgChannelCloseInit = { + encode(message: MsgChannelCloseInit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelCloseInit { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelCloseInit { + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelCloseInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelCloseInit { + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelCloseInitResponse: object = {}; + +export const MsgChannelCloseInitResponse = { + encode(_: MsgChannelCloseInitResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelCloseInitResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseInitResponse } as MsgChannelCloseInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelCloseInitResponse { + const message = { ...baseMsgChannelCloseInitResponse } as MsgChannelCloseInitResponse; + return message; + }, + + toJSON(_: MsgChannelCloseInitResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelCloseInitResponse { + const message = { ...baseMsgChannelCloseInitResponse } as MsgChannelCloseInitResponse; + return message; + }, +}; + +const baseMsgChannelCloseConfirm: object = { portId: "", channelId: "", signer: "" }; + +export const MsgChannelCloseConfirm = { + encode(message: MsgChannelCloseConfirm, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.proofInit.length !== 0) { + writer.uint32(26).bytes(message.proofInit); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelCloseConfirm { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + message.proofInit = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.proofInit = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelCloseConfirm { + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + message.proofInit = new Uint8Array(); + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelCloseConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelCloseConfirm { + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelCloseConfirmResponse: object = {}; + +export const MsgChannelCloseConfirmResponse = { + encode(_: MsgChannelCloseConfirmResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgChannelCloseConfirmResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseConfirmResponse } as MsgChannelCloseConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelCloseConfirmResponse { + const message = { ...baseMsgChannelCloseConfirmResponse } as MsgChannelCloseConfirmResponse; + return message; + }, + + toJSON(_: MsgChannelCloseConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChannelCloseConfirmResponse { + const message = { ...baseMsgChannelCloseConfirmResponse } as MsgChannelCloseConfirmResponse; + return message; + }, +}; + +const baseMsgRecvPacket: object = { signer: "" }; + +export const MsgRecvPacket = { + encode(message: MsgRecvPacket, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofCommitment.length !== 0) { + writer.uint32(18).bytes(message.proofCommitment); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRecvPacket { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + message.proofCommitment = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofCommitment = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRecvPacket { + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + message.proofCommitment = new Uint8Array(); + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if (object.proofCommitment !== undefined && object.proofCommitment !== null) { + message.proofCommitment = bytesFromBase64(object.proofCommitment); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgRecvPacket): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofCommitment !== undefined && + (obj.proofCommitment = base64FromBytes( + message.proofCommitment !== undefined ? message.proofCommitment : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgRecvPacket { + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if (object.proofCommitment !== undefined && object.proofCommitment !== null) { + message.proofCommitment = object.proofCommitment; + } else { + message.proofCommitment = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgRecvPacketResponse: object = {}; + +export const MsgRecvPacketResponse = { + encode(_: MsgRecvPacketResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRecvPacketResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgRecvPacketResponse { + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + return message; + }, + + toJSON(_: MsgRecvPacketResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgRecvPacketResponse { + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + return message; + }, +}; + +const baseMsgTimeout: object = { nextSequenceRecv: Long.UZERO, signer: "" }; + +export const MsgTimeout = { + encode(message: MsgTimeout, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofUnreceived.length !== 0) { + writer.uint32(18).bytes(message.proofUnreceived); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (!message.nextSequenceRecv.isZero()) { + writer.uint32(32).uint64(message.nextSequenceRecv); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTimeout { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeout } as MsgTimeout; + message.proofUnreceived = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofUnreceived = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.nextSequenceRecv = reader.uint64() as Long; + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeout { + const message = { ...baseMsgTimeout } as MsgTimeout; + message.proofUnreceived = new Uint8Array(); + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if (object.proofUnreceived !== undefined && object.proofUnreceived !== null) { + message.proofUnreceived = bytesFromBase64(object.proofUnreceived); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.nextSequenceRecv !== undefined && object.nextSequenceRecv !== null) { + message.nextSequenceRecv = Long.fromString(object.nextSequenceRecv); + } else { + message.nextSequenceRecv = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgTimeout): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined ? message.proofUnreceived : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = (message.nextSequenceRecv || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTimeout { + const message = { ...baseMsgTimeout } as MsgTimeout; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if (object.proofUnreceived !== undefined && object.proofUnreceived !== null) { + message.proofUnreceived = object.proofUnreceived; + } else { + message.proofUnreceived = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.nextSequenceRecv !== undefined && object.nextSequenceRecv !== null) { + message.nextSequenceRecv = object.nextSequenceRecv as Long; + } else { + message.nextSequenceRecv = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgTimeoutResponse: object = {}; + +export const MsgTimeoutResponse = { + encode(_: MsgTimeoutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTimeoutResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgTimeoutResponse { + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + return message; + }, + + toJSON(_: MsgTimeoutResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgTimeoutResponse { + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + return message; + }, +}; + +const baseMsgTimeoutOnClose: object = { nextSequenceRecv: Long.UZERO, signer: "" }; + +export const MsgTimeoutOnClose = { + encode(message: MsgTimeoutOnClose, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofUnreceived.length !== 0) { + writer.uint32(18).bytes(message.proofUnreceived); + } + if (message.proofClose.length !== 0) { + writer.uint32(26).bytes(message.proofClose); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (!message.nextSequenceRecv.isZero()) { + writer.uint32(40).uint64(message.nextSequenceRecv); + } + if (message.signer !== "") { + writer.uint32(50).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTimeoutOnClose { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + message.proofUnreceived = new Uint8Array(); + message.proofClose = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofUnreceived = reader.bytes(); + break; + case 3: + message.proofClose = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.nextSequenceRecv = reader.uint64() as Long; + break; + case 6: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeoutOnClose { + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + message.proofUnreceived = new Uint8Array(); + message.proofClose = new Uint8Array(); + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if (object.proofUnreceived !== undefined && object.proofUnreceived !== null) { + message.proofUnreceived = bytesFromBase64(object.proofUnreceived); + } + if (object.proofClose !== undefined && object.proofClose !== null) { + message.proofClose = bytesFromBase64(object.proofClose); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.nextSequenceRecv !== undefined && object.nextSequenceRecv !== null) { + message.nextSequenceRecv = Long.fromString(object.nextSequenceRecv); + } else { + message.nextSequenceRecv = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgTimeoutOnClose): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined ? message.proofUnreceived : new Uint8Array(), + )); + message.proofClose !== undefined && + (obj.proofClose = base64FromBytes( + message.proofClose !== undefined ? message.proofClose : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = (message.nextSequenceRecv || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTimeoutOnClose { + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if (object.proofUnreceived !== undefined && object.proofUnreceived !== null) { + message.proofUnreceived = object.proofUnreceived; + } else { + message.proofUnreceived = new Uint8Array(); + } + if (object.proofClose !== undefined && object.proofClose !== null) { + message.proofClose = object.proofClose; + } else { + message.proofClose = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.nextSequenceRecv !== undefined && object.nextSequenceRecv !== null) { + message.nextSequenceRecv = object.nextSequenceRecv as Long; + } else { + message.nextSequenceRecv = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgTimeoutOnCloseResponse: object = {}; + +export const MsgTimeoutOnCloseResponse = { + encode(_: MsgTimeoutOnCloseResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgTimeoutOnCloseResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeoutOnCloseResponse } as MsgTimeoutOnCloseResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgTimeoutOnCloseResponse { + const message = { ...baseMsgTimeoutOnCloseResponse } as MsgTimeoutOnCloseResponse; + return message; + }, + + toJSON(_: MsgTimeoutOnCloseResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgTimeoutOnCloseResponse { + const message = { ...baseMsgTimeoutOnCloseResponse } as MsgTimeoutOnCloseResponse; + return message; + }, +}; + +const baseMsgAcknowledgement: object = { signer: "" }; + +export const MsgAcknowledgement = { + encode(message: MsgAcknowledgement, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.acknowledgement.length !== 0) { + writer.uint32(18).bytes(message.acknowledgement); + } + if (message.proofAcked.length !== 0) { + writer.uint32(26).bytes(message.proofAcked); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAcknowledgement { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + message.acknowledgement = new Uint8Array(); + message.proofAcked = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.acknowledgement = reader.bytes(); + break; + case 3: + message.proofAcked = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgAcknowledgement { + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + message.acknowledgement = new Uint8Array(); + message.proofAcked = new Uint8Array(); + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = bytesFromBase64(object.acknowledgement); + } + if (object.proofAcked !== undefined && object.proofAcked !== null) { + message.proofAcked = bytesFromBase64(object.proofAcked); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgAcknowledgement): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + message.proofAcked !== undefined && + (obj.proofAcked = base64FromBytes( + message.proofAcked !== undefined ? message.proofAcked : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgAcknowledgement { + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = object.acknowledgement; + } else { + message.acknowledgement = new Uint8Array(); + } + if (object.proofAcked !== undefined && object.proofAcked !== null) { + message.proofAcked = object.proofAcked; + } else { + message.proofAcked = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgAcknowledgementResponse: object = {}; + +export const MsgAcknowledgementResponse = { + encode(_: MsgAcknowledgementResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAcknowledgementResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgAcknowledgementResponse } as MsgAcknowledgementResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgAcknowledgementResponse { + const message = { ...baseMsgAcknowledgementResponse } as MsgAcknowledgementResponse; + return message; + }, + + toJSON(_: MsgAcknowledgementResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgAcknowledgementResponse { + const message = { ...baseMsgAcknowledgementResponse } as MsgAcknowledgementResponse; + return message; + }, +}; + +/** Msg defines the ibc/channel Msg service. */ +export interface Msg { + /** ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. */ + ChannelOpenInit(request: MsgChannelOpenInit): Promise; + /** ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. */ + ChannelOpenTry(request: MsgChannelOpenTry): Promise; + /** ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. */ + ChannelOpenAck(request: MsgChannelOpenAck): Promise; + /** ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. */ + ChannelOpenConfirm(request: MsgChannelOpenConfirm): Promise; + /** ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. */ + ChannelCloseInit(request: MsgChannelCloseInit): Promise; + /** ChannelCloseConfirm defines a rpc handler method for MsgChannelCloseConfirm. */ + ChannelCloseConfirm(request: MsgChannelCloseConfirm): Promise; + /** RecvPacket defines a rpc handler method for MsgRecvPacket. */ + RecvPacket(request: MsgRecvPacket): Promise; + /** Timeout defines a rpc handler method for MsgTimeout. */ + Timeout(request: MsgTimeout): Promise; + /** TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. */ + TimeoutOnClose(request: MsgTimeoutOnClose): Promise; + /** Acknowledgement defines a rpc handler method for MsgAcknowledgement. */ + Acknowledgement(request: MsgAcknowledgement): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.ChannelOpenInit = this.ChannelOpenInit.bind(this); + this.ChannelOpenTry = this.ChannelOpenTry.bind(this); + this.ChannelOpenAck = this.ChannelOpenAck.bind(this); + this.ChannelOpenConfirm = this.ChannelOpenConfirm.bind(this); + this.ChannelCloseInit = this.ChannelCloseInit.bind(this); + this.ChannelCloseConfirm = this.ChannelCloseConfirm.bind(this); + this.RecvPacket = this.RecvPacket.bind(this); + this.Timeout = this.Timeout.bind(this); + this.TimeoutOnClose = this.TimeoutOnClose.bind(this); + this.Acknowledgement = this.Acknowledgement.bind(this); + } + ChannelOpenInit(request: MsgChannelOpenInit): Promise { + const data = MsgChannelOpenInit.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelOpenInit", data); + return promise.then((data) => MsgChannelOpenInitResponse.decode(new _m0.Reader(data))); + } + + ChannelOpenTry(request: MsgChannelOpenTry): Promise { + const data = MsgChannelOpenTry.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelOpenTry", data); + return promise.then((data) => MsgChannelOpenTryResponse.decode(new _m0.Reader(data))); + } + + ChannelOpenAck(request: MsgChannelOpenAck): Promise { + const data = MsgChannelOpenAck.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelOpenAck", data); + return promise.then((data) => MsgChannelOpenAckResponse.decode(new _m0.Reader(data))); + } + + ChannelOpenConfirm(request: MsgChannelOpenConfirm): Promise { + const data = MsgChannelOpenConfirm.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelOpenConfirm", data); + return promise.then((data) => MsgChannelOpenConfirmResponse.decode(new _m0.Reader(data))); + } + + ChannelCloseInit(request: MsgChannelCloseInit): Promise { + const data = MsgChannelCloseInit.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelCloseInit", data); + return promise.then((data) => MsgChannelCloseInitResponse.decode(new _m0.Reader(data))); + } + + ChannelCloseConfirm(request: MsgChannelCloseConfirm): Promise { + const data = MsgChannelCloseConfirm.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "ChannelCloseConfirm", data); + return promise.then((data) => MsgChannelCloseConfirmResponse.decode(new _m0.Reader(data))); + } + + RecvPacket(request: MsgRecvPacket): Promise { + const data = MsgRecvPacket.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "RecvPacket", data); + return promise.then((data) => MsgRecvPacketResponse.decode(new _m0.Reader(data))); + } + + Timeout(request: MsgTimeout): Promise { + const data = MsgTimeout.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "Timeout", data); + return promise.then((data) => MsgTimeoutResponse.decode(new _m0.Reader(data))); + } + + TimeoutOnClose(request: MsgTimeoutOnClose): Promise { + const data = MsgTimeoutOnClose.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "TimeoutOnClose", data); + return promise.then((data) => MsgTimeoutOnCloseResponse.decode(new _m0.Reader(data))); + } + + Acknowledgement(request: MsgAcknowledgement): Promise { + const data = MsgAcknowledgement.encode(request).finish(); + const promise = this.rpc.request("ibc.core.channel.v1.Msg", "Acknowledgement", data); + return promise.then((data) => MsgAcknowledgementResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/client/v1/client.ts b/src/ibc/core/client/v1/client.ts new file mode 100644 index 00000000..ebc2f4a0 --- /dev/null +++ b/src/ibc/core/client/v1/client.ts @@ -0,0 +1,561 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ +export interface IdentifiedClientState { + /** client identifier */ + clientId: string; + /** client state */ + clientState?: Any; +} + +/** ConsensusStateWithHeight defines a consensus state with an additional height field. */ +export interface ConsensusStateWithHeight { + /** consensus state height */ + height?: Height; + /** consensus state */ + consensusState?: Any; +} + +/** + * ClientConsensusStates defines all the stored consensus states for a given + * client. + */ +export interface ClientConsensusStates { + /** client identifier */ + clientId: string; + /** consensus states and their heights associated with the client */ + consensusStates: ConsensusStateWithHeight[]; +} + +/** + * ClientUpdateProposal is a governance proposal. If it passes, the client is + * updated with the provided header. The update may fail if the header is not + * valid given certain conditions specified by the client implementation. + */ +export interface ClientUpdateProposal { + /** the title of the update proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the client identifier for the client to be updated if the proposal passes */ + clientId: string; + /** the header used to update the client if the proposal passes */ + header?: Any; +} + +/** + * Height is a monotonically increasing data type + * that can be compared against another Height for the purposes of updating and + * freezing clients + * + * Normally the RevisionHeight is incremented at each height while keeping RevisionNumber + * the same. However some consensus algorithms may choose to reset the + * height in certain conditions e.g. hard forks, state-machine breaking changes + * In these cases, the RevisionNumber is incremented so that height continues to + * be monitonically increasing even as the RevisionHeight gets reset + */ +export interface Height { + /** the revision that the client is currently on */ + revisionNumber: Long; + /** the height within the given revision */ + revisionHeight: Long; +} + +/** Params defines the set of IBC light client parameters. */ +export interface Params { + /** allowed_clients defines the list of allowed client state types. */ + allowedClients: string[]; +} + +const baseIdentifiedClientState: object = { clientId: "" }; + +export const IdentifiedClientState = { + encode(message: IdentifiedClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IdentifiedClientState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateWithHeight: object = {}; + +export const ConsensusStateWithHeight = { + encode(message: ConsensusStateWithHeight, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConsensusStateWithHeight { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusStateWithHeight } as ConsensusStateWithHeight; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = Height.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateWithHeight { + const message = { ...baseConsensusStateWithHeight } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusStateWithHeight { + const message = { ...baseConsensusStateWithHeight } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseClientConsensusStates: object = { clientId: "" }; + +export const ClientConsensusStates = { + encode(message: ClientConsensusStates, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientConsensusStates { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.consensusStates.push(ConsensusStateWithHeight.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.consensusStates !== undefined && object.consensusStates !== null) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined, + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.consensusStates !== undefined && object.consensusStates !== null) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + return message; + }, +}; + +const baseClientUpdateProposal: object = { title: "", description: "", clientId: "" }; + +export const ClientUpdateProposal = { + encode(message: ClientUpdateProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.clientId !== "") { + writer.uint32(26).string(message.clientId); + } + if (message.header !== undefined) { + Any.encode(message.header, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientUpdateProposal { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.clientId = reader.string(); + break; + case 4: + message.header = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromJSON(object.header); + } else { + message.header = undefined; + } + return message; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromPartial(object.header); + } else { + message.header = undefined; + } + return message; + }, +}; + +const baseHeight: object = { revisionNumber: Long.UZERO, revisionHeight: Long.UZERO }; + +export const Height = { + encode(message: Height, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.revisionNumber.isZero()) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(16).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Height { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeight } as Height; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.revisionNumber = reader.uint64() as Long; + break; + case 2: + message.revisionHeight = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Long.fromString(object.revisionNumber); + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Long.fromString(object.revisionHeight); + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, + + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber as Long; + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight as Long; + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, +}; + +const baseParams: object = { allowedClients: "" }; + +export const Params = { + encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.allowedClients) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Params { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowedClients = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowedClients.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(e); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/client/v1/genesis.ts b/src/ibc/core/client/v1/genesis.ts new file mode 100644 index 00000000..73bc804b --- /dev/null +++ b/src/ibc/core/client/v1/genesis.ts @@ -0,0 +1,404 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Params, IdentifiedClientState, ClientConsensusStates } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** GenesisState defines the ibc client submodule's genesis state. */ +export interface GenesisState { + /** client states with their corresponding identifiers */ + clients: IdentifiedClientState[]; + /** consensus states from each client */ + clientsConsensus: ClientConsensusStates[]; + /** metadata from each client */ + clientsMetadata: IdentifiedGenesisMetadata[]; + params?: Params; + /** create localhost on initialization */ + createLocalhost: boolean; + /** the sequence for the next generated client identifier */ + nextClientSequence: Long; +} + +/** + * GenesisMetadata defines the genesis type for metadata that clients may return + * with ExportMetadata + */ +export interface GenesisMetadata { + /** store key of metadata without clientID-prefix */ + key: Uint8Array; + /** metadata value */ + value: Uint8Array; +} + +/** IdentifiedGenesisMetadata has the client metadata with the corresponding client id. */ +export interface IdentifiedGenesisMetadata { + clientId: string; + clientMetadata: GenesisMetadata[]; +} + +const baseGenesisState: object = { createLocalhost: false, nextClientSequence: Long.UZERO }; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.clients) { + IdentifiedClientState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.clientsConsensus) { + ClientConsensusStates.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.clientsMetadata) { + IdentifiedGenesisMetadata.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(34).fork()).ldelim(); + } + if (message.createLocalhost === true) { + writer.uint32(40).bool(message.createLocalhost); + } + if (!message.nextClientSequence.isZero()) { + writer.uint32(48).uint64(message.nextClientSequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clients.push(IdentifiedClientState.decode(reader, reader.uint32())); + break; + case 2: + message.clientsConsensus.push(ClientConsensusStates.decode(reader, reader.uint32())); + break; + case 3: + message.clientsMetadata.push(IdentifiedGenesisMetadata.decode(reader, reader.uint32())); + break; + case 4: + message.params = Params.decode(reader, reader.uint32()); + break; + case 5: + message.createLocalhost = reader.bool(); + break; + case 6: + message.nextClientSequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + if (object.clients !== undefined && object.clients !== null) { + for (const e of object.clients) { + message.clients.push(IdentifiedClientState.fromJSON(e)); + } + } + if (object.clientsConsensus !== undefined && object.clientsConsensus !== null) { + for (const e of object.clientsConsensus) { + message.clientsConsensus.push(ClientConsensusStates.fromJSON(e)); + } + } + if (object.clientsMetadata !== undefined && object.clientsMetadata !== null) { + for (const e of object.clientsMetadata) { + message.clientsMetadata.push(IdentifiedGenesisMetadata.fromJSON(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.createLocalhost !== undefined && object.createLocalhost !== null) { + message.createLocalhost = Boolean(object.createLocalhost); + } else { + message.createLocalhost = false; + } + if (object.nextClientSequence !== undefined && object.nextClientSequence !== null) { + message.nextClientSequence = Long.fromString(object.nextClientSequence); + } else { + message.nextClientSequence = Long.UZERO; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.clients) { + obj.clients = message.clients.map((e) => (e ? IdentifiedClientState.toJSON(e) : undefined)); + } else { + obj.clients = []; + } + if (message.clientsConsensus) { + obj.clientsConsensus = message.clientsConsensus.map((e) => + e ? ClientConsensusStates.toJSON(e) : undefined, + ); + } else { + obj.clientsConsensus = []; + } + if (message.clientsMetadata) { + obj.clientsMetadata = message.clientsMetadata.map((e) => + e ? IdentifiedGenesisMetadata.toJSON(e) : undefined, + ); + } else { + obj.clientsMetadata = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.createLocalhost !== undefined && (obj.createLocalhost = message.createLocalhost); + message.nextClientSequence !== undefined && + (obj.nextClientSequence = (message.nextClientSequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + if (object.clients !== undefined && object.clients !== null) { + for (const e of object.clients) { + message.clients.push(IdentifiedClientState.fromPartial(e)); + } + } + if (object.clientsConsensus !== undefined && object.clientsConsensus !== null) { + for (const e of object.clientsConsensus) { + message.clientsConsensus.push(ClientConsensusStates.fromPartial(e)); + } + } + if (object.clientsMetadata !== undefined && object.clientsMetadata !== null) { + for (const e of object.clientsMetadata) { + message.clientsMetadata.push(IdentifiedGenesisMetadata.fromPartial(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.createLocalhost !== undefined && object.createLocalhost !== null) { + message.createLocalhost = object.createLocalhost; + } else { + message.createLocalhost = false; + } + if (object.nextClientSequence !== undefined && object.nextClientSequence !== null) { + message.nextClientSequence = object.nextClientSequence as Long; + } else { + message.nextClientSequence = Long.UZERO; + } + return message; + }, +}; + +const baseGenesisMetadata: object = {}; + +export const GenesisMetadata = { + encode(message: GenesisMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisMetadata { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisMetadata } as GenesisMetadata; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisMetadata { + const message = { ...baseGenesisMetadata } as GenesisMetadata; + message.key = new Uint8Array(); + message.value = new Uint8Array(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: GenesisMetadata): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisMetadata { + const message = { ...baseGenesisMetadata } as GenesisMetadata; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +const baseIdentifiedGenesisMetadata: object = { clientId: "" }; + +export const IdentifiedGenesisMetadata = { + encode(message: IdentifiedGenesisMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.clientMetadata) { + GenesisMetadata.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IdentifiedGenesisMetadata { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedGenesisMetadata } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientMetadata.push(GenesisMetadata.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedGenesisMetadata { + const message = { ...baseIdentifiedGenesisMetadata } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientMetadata !== undefined && object.clientMetadata !== null) { + for (const e of object.clientMetadata) { + message.clientMetadata.push(GenesisMetadata.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: IdentifiedGenesisMetadata): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.clientMetadata) { + obj.clientMetadata = message.clientMetadata.map((e) => (e ? GenesisMetadata.toJSON(e) : undefined)); + } else { + obj.clientMetadata = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedGenesisMetadata { + const message = { ...baseIdentifiedGenesisMetadata } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientMetadata !== undefined && object.clientMetadata !== null) { + for (const e of object.clientMetadata) { + message.clientMetadata.push(GenesisMetadata.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/client/v1/query.ts b/src/ibc/core/client/v1/query.ts new file mode 100644 index 00000000..ab93e176 --- /dev/null +++ b/src/ibc/core/client/v1/query.ts @@ -0,0 +1,967 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { + Height, + Params, + IdentifiedClientState, + ConsensusStateWithHeight, +} from "../../../../ibc/core/client/v1/client"; +import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * QueryClientStateRequest is the request type for the Query/ClientState RPC + * method + */ +export interface QueryClientStateRequest { + /** client state unique identifier */ + clientId: string; +} + +/** + * QueryClientStateResponse is the response type for the Query/ClientState RPC + * method. Besides the client state, it includes a proof and the height from + * which the proof was retrieved. + */ +export interface QueryClientStateResponse { + /** client state associated with the request identifier */ + clientState?: Any; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryClientStatesRequest is the request type for the Query/ClientStates RPC + * method + */ +export interface QueryClientStatesRequest { + /** pagination request */ + pagination?: PageRequest; +} + +/** + * QueryClientStatesResponse is the response type for the Query/ClientStates RPC + * method. + */ +export interface QueryClientStatesResponse { + /** list of stored ClientStates of the chain. */ + clientStates: IdentifiedClientState[]; + /** pagination response */ + pagination?: PageResponse; +} + +/** + * QueryConsensusStateRequest is the request type for the Query/ConsensusState + * RPC method. Besides the consensus state, it includes a proof and the height + * from which the proof was retrieved. + */ +export interface QueryConsensusStateRequest { + /** client identifier */ + clientId: string; + /** consensus state revision number */ + revisionNumber: Long; + /** consensus state revision height */ + revisionHeight: Long; + /** + * latest_height overrrides the height field and queries the latest stored + * ConsensusState + */ + latestHeight: boolean; +} + +/** + * QueryConsensusStateResponse is the response type for the Query/ConsensusState + * RPC method + */ +export interface QueryConsensusStateResponse { + /** consensus state associated with the client identifier at the given height */ + consensusState?: Any; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryConsensusStatesRequest is the request type for the Query/ConsensusStates + * RPC method. + */ +export interface QueryConsensusStatesRequest { + /** client identifier */ + clientId: string; + /** pagination request */ + pagination?: PageRequest; +} + +/** + * QueryConsensusStatesResponse is the response type for the + * Query/ConsensusStates RPC method + */ +export interface QueryConsensusStatesResponse { + /** consensus states associated with the identifier */ + consensusStates: ConsensusStateWithHeight[]; + /** pagination response */ + pagination?: PageResponse; +} + +/** QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. */ +export interface QueryClientParamsRequest {} + +/** QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. */ +export interface QueryClientParamsResponse { + /** params defines the parameters of the module. */ + params?: Params; +} + +const baseQueryClientStateRequest: object = { clientId: "" }; + +export const QueryClientStateRequest = { + encode(message: QueryClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStateRequest { + const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + return message; + }, + + toJSON(message: QueryClientStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientStateRequest { + const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + return message; + }, +}; + +const baseQueryClientStateResponse: object = {}; + +export const QueryClientStateResponse = { + encode(message: QueryClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStateResponse { + const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse; + message.proof = new Uint8Array(); + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryClientStateResponse): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientStateResponse { + const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryClientStatesRequest: object = {}; + +export const QueryClientStatesRequest = { + encode(message: QueryClientStatesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStatesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatesRequest { + const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryClientStatesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientStatesRequest { + const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryClientStatesResponse: object = {}; + +export const QueryClientStatesResponse = { + encode(message: QueryClientStatesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.clientStates) { + IdentifiedClientState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStatesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse; + message.clientStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientStates.push(IdentifiedClientState.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatesResponse { + const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse; + message.clientStates = []; + if (object.clientStates !== undefined && object.clientStates !== null) { + for (const e of object.clientStates) { + message.clientStates.push(IdentifiedClientState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryClientStatesResponse): unknown { + const obj: any = {}; + if (message.clientStates) { + obj.clientStates = message.clientStates.map((e) => (e ? IdentifiedClientState.toJSON(e) : undefined)); + } else { + obj.clientStates = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientStatesResponse { + const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse; + message.clientStates = []; + if (object.clientStates !== undefined && object.clientStates !== null) { + for (const e of object.clientStates) { + message.clientStates.push(IdentifiedClientState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStateRequest: object = { + clientId: "", + revisionNumber: Long.UZERO, + revisionHeight: Long.UZERO, + latestHeight: false, +}; + +export const QueryConsensusStateRequest = { + encode(message: QueryConsensusStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (!message.revisionNumber.isZero()) { + writer.uint32(16).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(24).uint64(message.revisionHeight); + } + if (message.latestHeight === true) { + writer.uint32(32).bool(message.latestHeight); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.revisionNumber = reader.uint64() as Long; + break; + case 3: + message.revisionHeight = reader.uint64() as Long; + break; + case 4: + message.latestHeight = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateRequest { + const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Long.fromString(object.revisionNumber); + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Long.fromString(object.revisionHeight); + } else { + message.revisionHeight = Long.UZERO; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = Boolean(object.latestHeight); + } else { + message.latestHeight = false; + } + return message; + }, + + toJSON(message: QueryConsensusStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + message.latestHeight !== undefined && (obj.latestHeight = message.latestHeight); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConsensusStateRequest { + const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber as Long; + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight as Long; + } else { + message.revisionHeight = Long.UZERO; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = object.latestHeight; + } else { + message.latestHeight = false; + } + return message; + }, +}; + +const baseQueryConsensusStateResponse: object = {}; + +export const QueryConsensusStateResponse = { + encode(message: QueryConsensusStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateResponse { + const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse; + message.proof = new Uint8Array(); + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConsensusStateResponse { + const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStatesRequest: object = { clientId: "" }; + +export const QueryConsensusStatesRequest = { + encode(message: QueryConsensusStatesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStatesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStatesRequest { + const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStatesRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConsensusStatesRequest { + const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStatesResponse: object = {}; + +export const QueryConsensusStatesResponse = { + encode(message: QueryConsensusStatesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStatesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusStates.push(ConsensusStateWithHeight.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStatesResponse { + const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse; + message.consensusStates = []; + if (object.consensusStates !== undefined && object.consensusStates !== null) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStatesResponse): unknown { + const obj: any = {}; + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined, + ); + } else { + obj.consensusStates = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConsensusStatesResponse { + const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse; + message.consensusStates = []; + if (object.consensusStates !== undefined && object.consensusStates !== null) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryClientParamsRequest: object = {}; + +export const QueryClientParamsRequest = { + encode(_: QueryClientParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientParamsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryClientParamsRequest { + const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest; + return message; + }, + + toJSON(_: QueryClientParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryClientParamsRequest { + const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest; + return message; + }, +}; + +const baseQueryClientParamsResponse: object = {}; + +export const QueryClientParamsResponse = { + encode(message: QueryClientParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientParamsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientParamsResponse { + const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryClientParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientParamsResponse { + const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** ClientState queries an IBC light client. */ + ClientState(request: QueryClientStateRequest): Promise; + /** ClientStates queries all the IBC light clients of a chain. */ + ClientStates(request: QueryClientStatesRequest): Promise; + /** + * ConsensusState queries a consensus state associated with a client state at + * a given height. + */ + ConsensusState(request: QueryConsensusStateRequest): Promise; + /** + * ConsensusStates queries all the consensus state associated with a given + * client. + */ + ConsensusStates(request: QueryConsensusStatesRequest): Promise; + /** ClientParams queries all parameters of the ibc client. */ + ClientParams(request: QueryClientParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.ClientState = this.ClientState.bind(this); + this.ClientStates = this.ClientStates.bind(this); + this.ConsensusState = this.ConsensusState.bind(this); + this.ConsensusStates = this.ConsensusStates.bind(this); + this.ClientParams = this.ClientParams.bind(this); + } + ClientState(request: QueryClientStateRequest): Promise { + const data = QueryClientStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientState", data); + return promise.then((data) => QueryClientStateResponse.decode(new _m0.Reader(data))); + } + + ClientStates(request: QueryClientStatesRequest): Promise { + const data = QueryClientStatesRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientStates", data); + return promise.then((data) => QueryClientStatesResponse.decode(new _m0.Reader(data))); + } + + ConsensusState(request: QueryConsensusStateRequest): Promise { + const data = QueryConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusState", data); + return promise.then((data) => QueryConsensusStateResponse.decode(new _m0.Reader(data))); + } + + ConsensusStates(request: QueryConsensusStatesRequest): Promise { + const data = QueryConsensusStatesRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusStates", data); + return promise.then((data) => QueryConsensusStatesResponse.decode(new _m0.Reader(data))); + } + + ClientParams(request: QueryClientParamsRequest): Promise { + const data = QueryClientParamsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientParams", data); + return promise.then((data) => QueryClientParamsResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/client/v1/tx.ts b/src/ibc/core/client/v1/tx.ts new file mode 100644 index 00000000..fe711e7f --- /dev/null +++ b/src/ibc/core/client/v1/tx.ts @@ -0,0 +1,742 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** MsgCreateClient defines a message to create an IBC client */ +export interface MsgCreateClient { + /** light client state */ + clientState?: Any; + /** + * consensus state associated with the client that corresponds to a given + * height. + */ + consensusState?: Any; + /** signer address */ + signer: string; +} + +/** MsgCreateClientResponse defines the Msg/CreateClient response type. */ +export interface MsgCreateClientResponse {} + +/** + * MsgUpdateClient defines an sdk.Msg to update a IBC client state using + * the given header. + */ +export interface MsgUpdateClient { + /** client unique identifier */ + clientId: string; + /** header to update the light client */ + header?: Any; + /** signer address */ + signer: string; +} + +/** MsgUpdateClientResponse defines the Msg/UpdateClient response type. */ +export interface MsgUpdateClientResponse {} + +/** MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state */ +export interface MsgUpgradeClient { + /** client unique identifier */ + clientId: string; + /** upgraded client state */ + clientState?: Any; + /** upgraded consensus state, only contains enough information to serve as a basis of trust in update logic */ + consensusState?: Any; + /** proof that old chain committed to new client */ + proofUpgradeClient: Uint8Array; + /** proof that old chain committed to new consensus state */ + proofUpgradeConsensusState: Uint8Array; + /** signer address */ + signer: string; +} + +/** MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. */ +export interface MsgUpgradeClientResponse {} + +/** + * MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for + * light client misbehaviour. + */ +export interface MsgSubmitMisbehaviour { + /** client unique identifier */ + clientId: string; + /** misbehaviour used for freezing the light client */ + misbehaviour?: Any; + /** signer address */ + signer: string; +} + +/** MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. */ +export interface MsgSubmitMisbehaviourResponse {} + +const baseMsgCreateClient: object = { signer: "" }; + +export const MsgCreateClient = { + encode(message: MsgCreateClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreateClient { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateClient } as MsgCreateClient; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateClient { + const message = { ...baseMsgCreateClient } as MsgCreateClient; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgCreateClient): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateClient { + const message = { ...baseMsgCreateClient } as MsgCreateClient; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgCreateClientResponse: object = {}; + +export const MsgCreateClientResponse = { + encode(_: MsgCreateClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreateClientResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateClientResponse { + const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse; + return message; + }, + + toJSON(_: MsgCreateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgCreateClientResponse { + const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse; + return message; + }, +}; + +const baseMsgUpdateClient: object = { clientId: "", signer: "" }; + +export const MsgUpdateClient = { + encode(message: MsgUpdateClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.header !== undefined) { + Any.encode(message.header, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateClient { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.header = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpdateClient { + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgUpdateClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUpdateClient { + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgUpdateClientResponse: object = {}; + +export const MsgUpdateClientResponse = { + encode(_: MsgUpdateClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateClientResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpdateClientResponse { + const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse; + return message; + }, + + toJSON(_: MsgUpdateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgUpdateClientResponse { + const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse; + return message; + }, +}; + +const baseMsgUpgradeClient: object = { clientId: "", signer: "" }; + +export const MsgUpgradeClient = { + encode(message: MsgUpgradeClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(26).fork()).ldelim(); + } + if (message.proofUpgradeClient.length !== 0) { + writer.uint32(34).bytes(message.proofUpgradeClient); + } + if (message.proofUpgradeConsensusState.length !== 0) { + writer.uint32(42).bytes(message.proofUpgradeConsensusState); + } + if (message.signer !== "") { + writer.uint32(50).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeClient { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + message.proofUpgradeClient = new Uint8Array(); + message.proofUpgradeConsensusState = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 3: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 4: + message.proofUpgradeClient = reader.bytes(); + break; + case 5: + message.proofUpgradeConsensusState = reader.bytes(); + break; + case 6: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpgradeClient { + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + message.proofUpgradeClient = new Uint8Array(); + message.proofUpgradeConsensusState = new Uint8Array(); + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proofUpgradeClient !== undefined && object.proofUpgradeClient !== null) { + message.proofUpgradeClient = bytesFromBase64(object.proofUpgradeClient); + } + if (object.proofUpgradeConsensusState !== undefined && object.proofUpgradeConsensusState !== null) { + message.proofUpgradeConsensusState = bytesFromBase64(object.proofUpgradeConsensusState); + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgUpgradeClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.proofUpgradeClient !== undefined && + (obj.proofUpgradeClient = base64FromBytes( + message.proofUpgradeClient !== undefined ? message.proofUpgradeClient : new Uint8Array(), + )); + message.proofUpgradeConsensusState !== undefined && + (obj.proofUpgradeConsensusState = base64FromBytes( + message.proofUpgradeConsensusState !== undefined + ? message.proofUpgradeConsensusState + : new Uint8Array(), + )); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUpgradeClient { + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proofUpgradeClient !== undefined && object.proofUpgradeClient !== null) { + message.proofUpgradeClient = object.proofUpgradeClient; + } else { + message.proofUpgradeClient = new Uint8Array(); + } + if (object.proofUpgradeConsensusState !== undefined && object.proofUpgradeConsensusState !== null) { + message.proofUpgradeConsensusState = object.proofUpgradeConsensusState; + } else { + message.proofUpgradeConsensusState = new Uint8Array(); + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgUpgradeClientResponse: object = {}; + +export const MsgUpgradeClientResponse = { + encode(_: MsgUpgradeClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeClientResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpgradeClientResponse { + const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse; + return message; + }, + + toJSON(_: MsgUpgradeClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgUpgradeClientResponse { + const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse; + return message; + }, +}; + +const baseMsgSubmitMisbehaviour: object = { clientId: "", signer: "" }; + +export const MsgSubmitMisbehaviour = { + encode(message: MsgSubmitMisbehaviour, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.misbehaviour !== undefined) { + Any.encode(message.misbehaviour, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSubmitMisbehaviour { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.misbehaviour = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitMisbehaviour { + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.misbehaviour !== undefined && object.misbehaviour !== null) { + message.misbehaviour = Any.fromJSON(object.misbehaviour); + } else { + message.misbehaviour = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgSubmitMisbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.misbehaviour !== undefined && + (obj.misbehaviour = message.misbehaviour ? Any.toJSON(message.misbehaviour) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSubmitMisbehaviour { + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.misbehaviour !== undefined && object.misbehaviour !== null) { + message.misbehaviour = Any.fromPartial(object.misbehaviour); + } else { + message.misbehaviour = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgSubmitMisbehaviourResponse: object = {}; + +export const MsgSubmitMisbehaviourResponse = { + encode(_: MsgSubmitMisbehaviourResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSubmitMisbehaviourResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSubmitMisbehaviourResponse { + const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse; + return message; + }, + + toJSON(_: MsgSubmitMisbehaviourResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgSubmitMisbehaviourResponse { + const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse; + return message; + }, +}; + +/** Msg defines the ibc/client Msg service. */ +export interface Msg { + /** CreateClient defines a rpc handler method for MsgCreateClient. */ + CreateClient(request: MsgCreateClient): Promise; + /** UpdateClient defines a rpc handler method for MsgUpdateClient. */ + UpdateClient(request: MsgUpdateClient): Promise; + /** UpgradeClient defines a rpc handler method for MsgUpgradeClient. */ + UpgradeClient(request: MsgUpgradeClient): Promise; + /** SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. */ + SubmitMisbehaviour(request: MsgSubmitMisbehaviour): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.CreateClient = this.CreateClient.bind(this); + this.UpdateClient = this.UpdateClient.bind(this); + this.UpgradeClient = this.UpgradeClient.bind(this); + this.SubmitMisbehaviour = this.SubmitMisbehaviour.bind(this); + } + CreateClient(request: MsgCreateClient): Promise { + const data = MsgCreateClient.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Msg", "CreateClient", data); + return promise.then((data) => MsgCreateClientResponse.decode(new _m0.Reader(data))); + } + + UpdateClient(request: MsgUpdateClient): Promise { + const data = MsgUpdateClient.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Msg", "UpdateClient", data); + return promise.then((data) => MsgUpdateClientResponse.decode(new _m0.Reader(data))); + } + + UpgradeClient(request: MsgUpgradeClient): Promise { + const data = MsgUpgradeClient.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Msg", "UpgradeClient", data); + return promise.then((data) => MsgUpgradeClientResponse.decode(new _m0.Reader(data))); + } + + SubmitMisbehaviour(request: MsgSubmitMisbehaviour): Promise { + const data = MsgSubmitMisbehaviour.encode(request).finish(); + const promise = this.rpc.request("ibc.core.client.v1.Msg", "SubmitMisbehaviour", data); + return promise.then((data) => MsgSubmitMisbehaviourResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/commitment/v1/commitment.ts b/src/ibc/core/commitment/v1/commitment.ts new file mode 100644 index 00000000..7aece7b1 --- /dev/null +++ b/src/ibc/core/commitment/v1/commitment.ts @@ -0,0 +1,328 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { CommitmentProof } from "../../../../confio/proofs"; + +export const protobufPackage = "ibc.core.commitment.v1"; + +/** + * MerkleRoot defines a merkle root hash. + * In the Cosmos SDK, the AppHash of a block header becomes the root. + */ +export interface MerkleRoot { + hash: Uint8Array; +} + +/** + * MerklePrefix is merkle path prefixed to the key. + * The constructed key from the Path and the key will be append(Path.KeyPath, + * append(Path.KeyPrefix, key...)) + */ +export interface MerklePrefix { + keyPrefix: Uint8Array; +} + +/** + * MerklePath is the path used to verify commitment proofs, which can be an + * arbitrary structured object (defined by a commitment type). + * MerklePath is represented from root-to-leaf + */ +export interface MerklePath { + keyPath: string[]; +} + +/** + * MerkleProof is a wrapper type over a chain of CommitmentProofs. + * It demonstrates membership or non-membership for an element or set of + * elements, verifiable in conjunction with a known commitment root. Proofs + * should be succinct. + * MerkleProofs are ordered from leaf-to-root + */ +export interface MerkleProof { + proofs: CommitmentProof[]; +} + +const baseMerkleRoot: object = {}; + +export const MerkleRoot = { + encode(message: MerkleRoot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MerkleRoot { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerkleRoot } as MerkleRoot; + message.hash = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerkleRoot { + const message = { ...baseMerkleRoot } as MerkleRoot; + message.hash = new Uint8Array(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: MerkleRoot): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): MerkleRoot { + const message = { ...baseMerkleRoot } as MerkleRoot; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const baseMerklePrefix: object = {}; + +export const MerklePrefix = { + encode(message: MerklePrefix, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.keyPrefix.length !== 0) { + writer.uint32(10).bytes(message.keyPrefix); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MerklePrefix { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerklePrefix } as MerklePrefix; + message.keyPrefix = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keyPrefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerklePrefix { + const message = { ...baseMerklePrefix } as MerklePrefix; + message.keyPrefix = new Uint8Array(); + if (object.keyPrefix !== undefined && object.keyPrefix !== null) { + message.keyPrefix = bytesFromBase64(object.keyPrefix); + } + return message; + }, + + toJSON(message: MerklePrefix): unknown { + const obj: any = {}; + message.keyPrefix !== undefined && + (obj.keyPrefix = base64FromBytes( + message.keyPrefix !== undefined ? message.keyPrefix : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): MerklePrefix { + const message = { ...baseMerklePrefix } as MerklePrefix; + if (object.keyPrefix !== undefined && object.keyPrefix !== null) { + message.keyPrefix = object.keyPrefix; + } else { + message.keyPrefix = new Uint8Array(); + } + return message; + }, +}; + +const baseMerklePath: object = { keyPath: "" }; + +export const MerklePath = { + encode(message: MerklePath, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.keyPath) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MerklePath { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keyPath.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerklePath { + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + if (object.keyPath !== undefined && object.keyPath !== null) { + for (const e of object.keyPath) { + message.keyPath.push(String(e)); + } + } + return message; + }, + + toJSON(message: MerklePath): unknown { + const obj: any = {}; + if (message.keyPath) { + obj.keyPath = message.keyPath.map((e) => e); + } else { + obj.keyPath = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MerklePath { + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + if (object.keyPath !== undefined && object.keyPath !== null) { + for (const e of object.keyPath) { + message.keyPath.push(e); + } + } + return message; + }, +}; + +const baseMerkleProof: object = {}; + +export const MerkleProof = { + encode(message: MerkleProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.proofs) { + CommitmentProof.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MerkleProof { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proofs.push(CommitmentProof.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerkleProof { + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + if (object.proofs !== undefined && object.proofs !== null) { + for (const e of object.proofs) { + message.proofs.push(CommitmentProof.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MerkleProof): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => (e ? CommitmentProof.toJSON(e) : undefined)); + } else { + obj.proofs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MerkleProof { + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + if (object.proofs !== undefined && object.proofs !== null) { + for (const e of object.proofs) { + message.proofs.push(CommitmentProof.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/connection/v1/connection.ts b/src/ibc/core/connection/v1/connection.ts new file mode 100644 index 00000000..476f6cd0 --- /dev/null +++ b/src/ibc/core/connection/v1/connection.ts @@ -0,0 +1,754 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { MerklePrefix } from "../../../../ibc/core/commitment/v1/commitment"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * State defines if a connection is in one of the following states: + * INIT, TRYOPEN, OPEN or UNINITIALIZED. + */ +export enum State { + /** STATE_UNINITIALIZED_UNSPECIFIED - Default State */ + STATE_UNINITIALIZED_UNSPECIFIED = 0, + /** STATE_INIT - A connection end has just started the opening handshake. */ + STATE_INIT = 1, + /** + * STATE_TRYOPEN - A connection end has acknowledged the handshake step on the counterparty + * chain. + */ + STATE_TRYOPEN = 2, + /** STATE_OPEN - A connection end has completed the handshake. */ + STATE_OPEN = 3, + UNRECOGNIZED = -1, +} + +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNINITIALIZED_UNSPECIFIED": + return State.STATE_UNINITIALIZED_UNSPECIFIED; + case 1: + case "STATE_INIT": + return State.STATE_INIT; + case 2: + case "STATE_TRYOPEN": + return State.STATE_TRYOPEN; + case 3: + case "STATE_OPEN": + return State.STATE_OPEN; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} + +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNINITIALIZED_UNSPECIFIED: + return "STATE_UNINITIALIZED_UNSPECIFIED"; + case State.STATE_INIT: + return "STATE_INIT"; + case State.STATE_TRYOPEN: + return "STATE_TRYOPEN"; + case State.STATE_OPEN: + return "STATE_OPEN"; + default: + return "UNKNOWN"; + } +} + +/** + * ConnectionEnd defines a stateful object on a chain connected to another + * separate one. + * NOTE: there must only be 2 defined ConnectionEnds to establish + * a connection between two chains. + */ +export interface ConnectionEnd { + /** client associated with this connection. */ + clientId: string; + /** + * IBC version which can be utilised to determine encodings or protocols for + * channels or packets utilising this connection. + */ + versions: Version[]; + /** current state of the connection end. */ + state: State; + /** counterparty chain associated with this connection. */ + counterparty?: Counterparty; + /** + * delay period that must pass before a consensus state can be used for packet-verification + * NOTE: delay period logic is only implemented by some clients. + */ + delayPeriod: Long; +} + +/** + * IdentifiedConnection defines a connection with additional connection + * identifier field. + */ +export interface IdentifiedConnection { + /** connection identifier. */ + id: string; + /** client associated with this connection. */ + clientId: string; + /** + * IBC version which can be utilised to determine encodings or protocols for + * channels or packets utilising this connection + */ + versions: Version[]; + /** current state of the connection end. */ + state: State; + /** counterparty chain associated with this connection. */ + counterparty?: Counterparty; + /** delay period associated with this connection. */ + delayPeriod: Long; +} + +/** Counterparty defines the counterparty chain associated with a connection end. */ +export interface Counterparty { + /** + * identifies the client on the counterparty chain associated with a given + * connection. + */ + clientId: string; + /** + * identifies the connection end on the counterparty chain associated with a + * given connection. + */ + connectionId: string; + /** commitment merkle prefix of the counterparty chain. */ + prefix?: MerklePrefix; +} + +/** ClientPaths define all the connection paths for a client state. */ +export interface ClientPaths { + /** list of connection paths */ + paths: string[]; +} + +/** ConnectionPaths define all the connection paths for a given client state. */ +export interface ConnectionPaths { + /** client state unique identifier */ + clientId: string; + /** list of connection paths */ + paths: string[]; +} + +/** + * Version defines the versioning scheme used to negotiate the IBC verison in + * the connection handshake. + */ +export interface Version { + /** unique version identifier */ + identifier: string; + /** list of features compatible with the specified identifier */ + features: string[]; +} + +const baseConnectionEnd: object = { clientId: "", state: 0, delayPeriod: Long.UZERO }; + +export const ConnectionEnd = { + encode(message: ConnectionEnd, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.versions) { + Version.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(34).fork()).ldelim(); + } + if (!message.delayPeriod.isZero()) { + writer.uint32(40).uint64(message.delayPeriod); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConnectionEnd { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.versions.push(Version.decode(reader, reader.uint32())); + break; + case 3: + message.state = reader.int32() as any; + break; + case 4: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 5: + message.delayPeriod = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConnectionEnd { + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromJSON(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Long.fromString(object.delayPeriod); + } else { + message.delayPeriod = Long.UZERO; + } + return message; + }, + + toJSON(message: ConnectionEnd): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): ConnectionEnd { + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromPartial(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod as Long; + } else { + message.delayPeriod = Long.UZERO; + } + return message; + }, +}; + +const baseIdentifiedConnection: object = { id: "", clientId: "", state: 0, delayPeriod: Long.UZERO }; + +export const IdentifiedConnection = { + encode(message: IdentifiedConnection, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + for (const v of message.versions) { + Version.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(42).fork()).ldelim(); + } + if (!message.delayPeriod.isZero()) { + writer.uint32(48).uint64(message.delayPeriod); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IdentifiedConnection { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.versions.push(Version.decode(reader, reader.uint32())); + break; + case 4: + message.state = reader.int32() as any; + break; + case 5: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 6: + message.delayPeriod = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedConnection { + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromJSON(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Long.fromString(object.delayPeriod); + } else { + message.delayPeriod = Long.UZERO; + } + return message; + }, + + toJSON(message: IdentifiedConnection): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedConnection { + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromPartial(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod as Long; + } else { + message.delayPeriod = Long.UZERO; + } + return message; + }, +}; + +const baseCounterparty: object = { clientId: "", connectionId: "" }; + +export const Counterparty = { + encode(message: Counterparty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.connectionId !== "") { + writer.uint32(18).string(message.connectionId); + } + if (message.prefix !== undefined) { + MerklePrefix.encode(message.prefix, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Counterparty { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCounterparty } as Counterparty; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.connectionId = reader.string(); + break; + case 3: + message.prefix = MerklePrefix.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = MerklePrefix.fromJSON(object.prefix); + } else { + message.prefix = undefined; + } + return message; + }, + + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.prefix !== undefined && + (obj.prefix = message.prefix ? MerklePrefix.toJSON(message.prefix) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = MerklePrefix.fromPartial(object.prefix); + } else { + message.prefix = undefined; + } + return message; + }, +}; + +const baseClientPaths: object = { paths: "" }; + +export const ClientPaths = { + encode(message: ClientPaths, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.paths) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientPaths { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientPaths { + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(String(e)); + } + } + return message; + }, + + toJSON(message: ClientPaths): unknown { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ClientPaths { + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(e); + } + } + return message; + }, +}; + +const baseConnectionPaths: object = { clientId: "", paths: "" }; + +export const ConnectionPaths = { + encode(message: ConnectionPaths, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.paths) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConnectionPaths { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConnectionPaths { + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(String(e)); + } + } + return message; + }, + + toJSON(message: ConnectionPaths): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ConnectionPaths { + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(e); + } + } + return message; + }, +}; + +const baseVersion: object = { identifier: "", features: "" }; + +export const Version = { + encode(message: Version, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + for (const v of message.features) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Version { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVersion } as Version; + message.features = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.features.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Version { + const message = { ...baseVersion } as Version; + message.features = []; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + if (object.features !== undefined && object.features !== null) { + for (const e of object.features) { + message.features.push(String(e)); + } + } + return message; + }, + + toJSON(message: Version): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + if (message.features) { + obj.features = message.features.map((e) => e); + } else { + obj.features = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Version { + const message = { ...baseVersion } as Version; + message.features = []; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + if (object.features !== undefined && object.features !== null) { + for (const e of object.features) { + message.features.push(e); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/connection/v1/genesis.ts b/src/ibc/core/connection/v1/genesis.ts new file mode 100644 index 00000000..65d97979 --- /dev/null +++ b/src/ibc/core/connection/v1/genesis.ts @@ -0,0 +1,136 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { IdentifiedConnection, ConnectionPaths } from "../../../../ibc/core/connection/v1/connection"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** GenesisState defines the ibc connection submodule's genesis state. */ +export interface GenesisState { + connections: IdentifiedConnection[]; + clientConnectionPaths: ConnectionPaths[]; + /** the sequence for the next generated connection identifier */ + nextConnectionSequence: Long; +} + +const baseGenesisState: object = { nextConnectionSequence: Long.UZERO }; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.connections) { + IdentifiedConnection.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.clientConnectionPaths) { + ConnectionPaths.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (!message.nextConnectionSequence.isZero()) { + writer.uint32(24).uint64(message.nextConnectionSequence); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connections.push(IdentifiedConnection.decode(reader, reader.uint32())); + break; + case 2: + message.clientConnectionPaths.push(ConnectionPaths.decode(reader, reader.uint32())); + break; + case 3: + message.nextConnectionSequence = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromJSON(e)); + } + } + if (object.clientConnectionPaths !== undefined && object.clientConnectionPaths !== null) { + for (const e of object.clientConnectionPaths) { + message.clientConnectionPaths.push(ConnectionPaths.fromJSON(e)); + } + } + if (object.nextConnectionSequence !== undefined && object.nextConnectionSequence !== null) { + message.nextConnectionSequence = Long.fromString(object.nextConnectionSequence); + } else { + message.nextConnectionSequence = Long.UZERO; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.connections) { + obj.connections = message.connections.map((e) => (e ? IdentifiedConnection.toJSON(e) : undefined)); + } else { + obj.connections = []; + } + if (message.clientConnectionPaths) { + obj.clientConnectionPaths = message.clientConnectionPaths.map((e) => + e ? ConnectionPaths.toJSON(e) : undefined, + ); + } else { + obj.clientConnectionPaths = []; + } + message.nextConnectionSequence !== undefined && + (obj.nextConnectionSequence = (message.nextConnectionSequence || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromPartial(e)); + } + } + if (object.clientConnectionPaths !== undefined && object.clientConnectionPaths !== null) { + for (const e of object.clientConnectionPaths) { + message.clientConnectionPaths.push(ConnectionPaths.fromPartial(e)); + } + } + if (object.nextConnectionSequence !== undefined && object.nextConnectionSequence !== null) { + message.nextConnectionSequence = object.nextConnectionSequence as Long; + } else { + message.nextConnectionSequence = Long.UZERO; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/connection/v1/query.ts b/src/ibc/core/connection/v1/query.ts new file mode 100644 index 00000000..fe509945 --- /dev/null +++ b/src/ibc/core/connection/v1/query.ts @@ -0,0 +1,1062 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { ConnectionEnd, IdentifiedConnection } from "../../../../ibc/core/connection/v1/connection"; +import { Height, IdentifiedClientState } from "../../../../ibc/core/client/v1/client"; +import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * QueryConnectionRequest is the request type for the Query/Connection RPC + * method + */ +export interface QueryConnectionRequest { + /** connection unique identifier */ + connectionId: string; +} + +/** + * QueryConnectionResponse is the response type for the Query/Connection RPC + * method. Besides the connection end, it includes a proof and the height from + * which the proof was retrieved. + */ +export interface QueryConnectionResponse { + /** connection associated with the request identifier */ + connection?: ConnectionEnd; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryConnectionsRequest is the request type for the Query/Connections RPC + * method + */ +export interface QueryConnectionsRequest { + pagination?: PageRequest; +} + +/** + * QueryConnectionsResponse is the response type for the Query/Connections RPC + * method. + */ +export interface QueryConnectionsResponse { + /** list of stored connections of the chain. */ + connections: IdentifiedConnection[]; + /** pagination response */ + pagination?: PageResponse; + /** query block height */ + height?: Height; +} + +/** + * QueryClientConnectionsRequest is the request type for the + * Query/ClientConnections RPC method + */ +export interface QueryClientConnectionsRequest { + /** client identifier associated with a connection */ + clientId: string; +} + +/** + * QueryClientConnectionsResponse is the response type for the + * Query/ClientConnections RPC method + */ +export interface QueryClientConnectionsResponse { + /** slice of all the connection paths associated with a client. */ + connectionPaths: string[]; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was generated */ + proofHeight?: Height; +} + +/** + * QueryConnectionClientStateRequest is the request type for the + * Query/ConnectionClientState RPC method + */ +export interface QueryConnectionClientStateRequest { + /** connection identifier */ + connectionId: string; +} + +/** + * QueryConnectionClientStateResponse is the response type for the + * Query/ConnectionClientState RPC method + */ +export interface QueryConnectionClientStateResponse { + /** client state associated with the channel */ + identifiedClientState?: IdentifiedClientState; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +/** + * QueryConnectionConsensusStateRequest is the request type for the + * Query/ConnectionConsensusState RPC method + */ +export interface QueryConnectionConsensusStateRequest { + /** connection identifier */ + connectionId: string; + revisionNumber: Long; + revisionHeight: Long; +} + +/** + * QueryConnectionConsensusStateResponse is the response type for the + * Query/ConnectionConsensusState RPC method + */ +export interface QueryConnectionConsensusStateResponse { + /** consensus state associated with the channel */ + consensusState?: Any; + /** client ID associated with the consensus state */ + clientId: string; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight?: Height; +} + +const baseQueryConnectionRequest: object = { connectionId: "" }; + +export const QueryConnectionRequest = { + encode(message: QueryConnectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionRequest { + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + return message; + }, + + toJSON(message: QueryConnectionRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionRequest { + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + return message; + }, +}; + +const baseQueryConnectionResponse: object = {}; + +export const QueryConnectionResponse = { + encode(message: QueryConnectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connection !== undefined) { + ConnectionEnd.encode(message.connection, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionResponse } as QueryConnectionResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connection = ConnectionEnd.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionResponse { + const message = { ...baseQueryConnectionResponse } as QueryConnectionResponse; + message.proof = new Uint8Array(); + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromJSON(object.connection); + } else { + message.connection = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionResponse): unknown { + const obj: any = {}; + message.connection !== undefined && + (obj.connection = message.connection ? ConnectionEnd.toJSON(message.connection) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionResponse { + const message = { ...baseQueryConnectionResponse } as QueryConnectionResponse; + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromPartial(object.connection); + } else { + message.connection = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionsRequest: object = {}; + +export const QueryConnectionsRequest = { + encode(message: QueryConnectionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionsRequest } as QueryConnectionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionsRequest { + const message = { ...baseQueryConnectionsRequest } as QueryConnectionsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionsRequest { + const message = { ...baseQueryConnectionsRequest } as QueryConnectionsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConnectionsResponse: object = {}; + +export const QueryConnectionsResponse = { + encode(message: QueryConnectionsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.connections) { + IdentifiedConnection.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionsResponse } as QueryConnectionsResponse; + message.connections = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connections.push(IdentifiedConnection.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionsResponse { + const message = { ...baseQueryConnectionsResponse } as QueryConnectionsResponse; + message.connections = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionsResponse): unknown { + const obj: any = {}; + if (message.connections) { + obj.connections = message.connections.map((e) => (e ? IdentifiedConnection.toJSON(e) : undefined)); + } else { + obj.connections = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionsResponse { + const message = { ...baseQueryConnectionsResponse } as QueryConnectionsResponse; + message.connections = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryClientConnectionsRequest: object = { clientId: "" }; + +export const QueryClientConnectionsRequest = { + encode(message: QueryClientConnectionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientConnectionsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientConnectionsRequest } as QueryClientConnectionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientConnectionsRequest { + const message = { ...baseQueryClientConnectionsRequest } as QueryClientConnectionsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + return message; + }, + + toJSON(message: QueryClientConnectionsRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientConnectionsRequest { + const message = { ...baseQueryClientConnectionsRequest } as QueryClientConnectionsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + return message; + }, +}; + +const baseQueryClientConnectionsResponse: object = { connectionPaths: "" }; + +export const QueryClientConnectionsResponse = { + encode(message: QueryClientConnectionsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.connectionPaths) { + writer.uint32(10).string(v!); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientConnectionsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryClientConnectionsResponse } as QueryClientConnectionsResponse; + message.connectionPaths = []; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionPaths.push(reader.string()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientConnectionsResponse { + const message = { ...baseQueryClientConnectionsResponse } as QueryClientConnectionsResponse; + message.connectionPaths = []; + message.proof = new Uint8Array(); + if (object.connectionPaths !== undefined && object.connectionPaths !== null) { + for (const e of object.connectionPaths) { + message.connectionPaths.push(String(e)); + } + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryClientConnectionsResponse): unknown { + const obj: any = {}; + if (message.connectionPaths) { + obj.connectionPaths = message.connectionPaths.map((e) => e); + } else { + obj.connectionPaths = []; + } + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryClientConnectionsResponse { + const message = { ...baseQueryClientConnectionsResponse } as QueryClientConnectionsResponse; + message.connectionPaths = []; + if (object.connectionPaths !== undefined && object.connectionPaths !== null) { + for (const e of object.connectionPaths) { + message.connectionPaths.push(e); + } + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionClientStateRequest: object = { connectionId: "" }; + +export const QueryConnectionClientStateRequest = { + encode(message: QueryConnectionClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionClientStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionClientStateRequest } as QueryConnectionClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionClientStateRequest { + const message = { ...baseQueryConnectionClientStateRequest } as QueryConnectionClientStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + return message; + }, + + toJSON(message: QueryConnectionClientStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionClientStateRequest { + const message = { ...baseQueryConnectionClientStateRequest } as QueryConnectionClientStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + return message; + }, +}; + +const baseQueryConnectionClientStateResponse: object = {}; + +export const QueryConnectionClientStateResponse = { + encode(message: QueryConnectionClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.identifiedClientState !== undefined) { + IdentifiedClientState.encode(message.identifiedClientState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionClientStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionClientStateResponse } as QueryConnectionClientStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifiedClientState = IdentifiedClientState.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionClientStateResponse { + const message = { ...baseQueryConnectionClientStateResponse } as QueryConnectionClientStateResponse; + message.proof = new Uint8Array(); + if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { + message.identifiedClientState = IdentifiedClientState.fromJSON(object.identifiedClientState); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryConnectionClientStateResponse { + const message = { ...baseQueryConnectionClientStateResponse } as QueryConnectionClientStateResponse; + if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { + message.identifiedClientState = IdentifiedClientState.fromPartial(object.identifiedClientState); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionConsensusStateRequest: object = { + connectionId: "", + revisionNumber: Long.UZERO, + revisionHeight: Long.UZERO, +}; + +export const QueryConnectionConsensusStateRequest = { + encode( + message: QueryConnectionConsensusStateRequest, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (!message.revisionNumber.isZero()) { + writer.uint32(16).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(24).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionConsensusStateRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionConsensusStateRequest } as QueryConnectionConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.revisionNumber = reader.uint64() as Long; + break; + case 3: + message.revisionHeight = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionConsensusStateRequest { + const message = { ...baseQueryConnectionConsensusStateRequest } as QueryConnectionConsensusStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Long.fromString(object.revisionNumber); + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Long.fromString(object.revisionHeight); + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, + + toJSON(message: QueryConnectionConsensusStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + + fromPartial( + object: DeepPartial, + ): QueryConnectionConsensusStateRequest { + const message = { ...baseQueryConnectionConsensusStateRequest } as QueryConnectionConsensusStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber as Long; + } else { + message.revisionNumber = Long.UZERO; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight as Long; + } else { + message.revisionHeight = Long.UZERO; + } + return message; + }, +}; + +const baseQueryConnectionConsensusStateResponse: object = { clientId: "" }; + +export const QueryConnectionConsensusStateResponse = { + encode( + message: QueryConnectionConsensusStateResponse, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryConnectionConsensusStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionConsensusStateResponse } as QueryConnectionConsensusStateResponse; + message.proof = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionConsensusStateResponse { + const message = { ...baseQueryConnectionConsensusStateResponse } as QueryConnectionConsensusStateResponse; + message.proof = new Uint8Array(); + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial, + ): QueryConnectionConsensusStateResponse { + const message = { ...baseQueryConnectionConsensusStateResponse } as QueryConnectionConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Connection queries an IBC connection end. */ + Connection(request: QueryConnectionRequest): Promise; + /** Connections queries all the IBC connections of a chain. */ + Connections(request: QueryConnectionsRequest): Promise; + /** + * ClientConnections queries the connection paths associated with a client + * state. + */ + ClientConnections(request: QueryClientConnectionsRequest): Promise; + /** + * ConnectionClientState queries the client state associated with the + * connection. + */ + ConnectionClientState( + request: QueryConnectionClientStateRequest, + ): Promise; + /** + * ConnectionConsensusState queries the consensus state associated with the + * connection. + */ + ConnectionConsensusState( + request: QueryConnectionConsensusStateRequest, + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.Connection = this.Connection.bind(this); + this.Connections = this.Connections.bind(this); + this.ClientConnections = this.ClientConnections.bind(this); + this.ConnectionClientState = this.ConnectionClientState.bind(this); + this.ConnectionConsensusState = this.ConnectionConsensusState.bind(this); + } + Connection(request: QueryConnectionRequest): Promise { + const data = QueryConnectionRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Query", "Connection", data); + return promise.then((data) => QueryConnectionResponse.decode(new _m0.Reader(data))); + } + + Connections(request: QueryConnectionsRequest): Promise { + const data = QueryConnectionsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Query", "Connections", data); + return promise.then((data) => QueryConnectionsResponse.decode(new _m0.Reader(data))); + } + + ClientConnections(request: QueryClientConnectionsRequest): Promise { + const data = QueryClientConnectionsRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Query", "ClientConnections", data); + return promise.then((data) => QueryClientConnectionsResponse.decode(new _m0.Reader(data))); + } + + ConnectionClientState( + request: QueryConnectionClientStateRequest, + ): Promise { + const data = QueryConnectionClientStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Query", "ConnectionClientState", data); + return promise.then((data) => QueryConnectionClientStateResponse.decode(new _m0.Reader(data))); + } + + ConnectionConsensusState( + request: QueryConnectionConsensusStateRequest, + ): Promise { + const data = QueryConnectionConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Query", "ConnectionConsensusState", data); + return promise.then((data) => QueryConnectionConsensusStateResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/connection/v1/tx.ts b/src/ibc/core/connection/v1/tx.ts new file mode 100644 index 00000000..2df9fdd1 --- /dev/null +++ b/src/ibc/core/connection/v1/tx.ts @@ -0,0 +1,1065 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Counterparty, Version } from "../../../../ibc/core/connection/v1/connection"; +import { Any } from "../../../../google/protobuf/any"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * MsgConnectionOpenInit defines the msg sent by an account on Chain A to + * initialize a connection with Chain B. + */ +export interface MsgConnectionOpenInit { + clientId: string; + counterparty?: Counterparty; + version?: Version; + delayPeriod: Long; + signer: string; +} + +/** MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. */ +export interface MsgConnectionOpenInitResponse {} + +/** + * MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a + * connection on Chain B. + */ +export interface MsgConnectionOpenTry { + clientId: string; + /** + * in the case of crossing hello's, when both chains call OpenInit, we need the connection identifier + * of the previous connection in state INIT + */ + previousConnectionId: string; + clientState?: Any; + counterparty?: Counterparty; + delayPeriod: Long; + counterpartyVersions: Version[]; + proofHeight?: Height; + /** + * proof of the initialization the connection on Chain A: `UNITIALIZED -> + * INIT` + */ + proofInit: Uint8Array; + /** proof of client state included in message */ + proofClient: Uint8Array; + /** proof of client consensus state */ + proofConsensus: Uint8Array; + consensusHeight?: Height; + signer: string; +} + +/** MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. */ +export interface MsgConnectionOpenTryResponse {} + +/** + * MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to + * acknowledge the change of connection state to TRYOPEN on Chain B. + */ +export interface MsgConnectionOpenAck { + connectionId: string; + counterpartyConnectionId: string; + version?: Version; + clientState?: Any; + proofHeight?: Height; + /** + * proof of the initialization the connection on Chain B: `UNITIALIZED -> + * TRYOPEN` + */ + proofTry: Uint8Array; + /** proof of client state included in message */ + proofClient: Uint8Array; + /** proof of client consensus state */ + proofConsensus: Uint8Array; + consensusHeight?: Height; + signer: string; +} + +/** MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. */ +export interface MsgConnectionOpenAckResponse {} + +/** + * MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to + * acknowledge the change of connection state to OPEN on Chain A. + */ +export interface MsgConnectionOpenConfirm { + connectionId: string; + /** proof for the change of the connection state on Chain A: `INIT -> OPEN` */ + proofAck: Uint8Array; + proofHeight?: Height; + signer: string; +} + +/** MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm response type. */ +export interface MsgConnectionOpenConfirmResponse {} + +const baseMsgConnectionOpenInit: object = { clientId: "", delayPeriod: Long.UZERO, signer: "" }; + +export const MsgConnectionOpenInit = { + encode(message: MsgConnectionOpenInit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(18).fork()).ldelim(); + } + if (message.version !== undefined) { + Version.encode(message.version, writer.uint32(26).fork()).ldelim(); + } + if (!message.delayPeriod.isZero()) { + writer.uint32(32).uint64(message.delayPeriod); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenInit { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 3: + message.version = Version.decode(reader, reader.uint32()); + break; + case 4: + message.delayPeriod = reader.uint64() as Long; + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenInit { + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Long.fromString(object.delayPeriod); + } else { + message.delayPeriod = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenInit): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.version !== undefined && + (obj.version = message.version ? Version.toJSON(message.version) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenInit { + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod as Long; + } else { + message.delayPeriod = Long.UZERO; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenInitResponse: object = {}; + +export const MsgConnectionOpenInitResponse = { + encode(_: MsgConnectionOpenInitResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenInitResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenInitResponse } as MsgConnectionOpenInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenInitResponse { + const message = { ...baseMsgConnectionOpenInitResponse } as MsgConnectionOpenInitResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenInitResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgConnectionOpenInitResponse { + const message = { ...baseMsgConnectionOpenInitResponse } as MsgConnectionOpenInitResponse; + return message; + }, +}; + +const baseMsgConnectionOpenTry: object = { + clientId: "", + previousConnectionId: "", + delayPeriod: Long.UZERO, + signer: "", +}; + +export const MsgConnectionOpenTry = { + encode(message: MsgConnectionOpenTry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.previousConnectionId !== "") { + writer.uint32(18).string(message.previousConnectionId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(26).fork()).ldelim(); + } + if (message.counterparty !== undefined) { + Counterparty.encode(message.counterparty, writer.uint32(34).fork()).ldelim(); + } + if (!message.delayPeriod.isZero()) { + writer.uint32(40).uint64(message.delayPeriod); + } + for (const v of message.counterpartyVersions) { + Version.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(58).fork()).ldelim(); + } + if (message.proofInit.length !== 0) { + writer.uint32(66).bytes(message.proofInit); + } + if (message.proofClient.length !== 0) { + writer.uint32(74).bytes(message.proofClient); + } + if (message.proofConsensus.length !== 0) { + writer.uint32(82).bytes(message.proofConsensus); + } + if (message.consensusHeight !== undefined) { + Height.encode(message.consensusHeight, writer.uint32(90).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(98).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenTry { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + message.proofInit = new Uint8Array(); + message.proofClient = new Uint8Array(); + message.proofConsensus = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.previousConnectionId = reader.string(); + break; + case 3: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 4: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 5: + message.delayPeriod = reader.uint64() as Long; + break; + case 6: + message.counterpartyVersions.push(Version.decode(reader, reader.uint32())); + break; + case 7: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 8: + message.proofInit = reader.bytes(); + break; + case 9: + message.proofClient = reader.bytes(); + break; + case 10: + message.proofConsensus = reader.bytes(); + break; + case 11: + message.consensusHeight = Height.decode(reader, reader.uint32()); + break; + case 12: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenTry { + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + message.proofInit = new Uint8Array(); + message.proofClient = new Uint8Array(); + message.proofConsensus = new Uint8Array(); + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.previousConnectionId !== undefined && object.previousConnectionId !== null) { + message.previousConnectionId = String(object.previousConnectionId); + } else { + message.previousConnectionId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Long.fromString(object.delayPeriod); + } else { + message.delayPeriod = Long.UZERO; + } + if (object.counterpartyVersions !== undefined && object.counterpartyVersions !== null) { + for (const e of object.counterpartyVersions) { + message.counterpartyVersions.push(Version.fromJSON(e)); + } + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = bytesFromBase64(object.proofClient); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = bytesFromBase64(object.proofConsensus); + } + if (object.consensusHeight !== undefined && object.consensusHeight !== null) { + message.consensusHeight = Height.fromJSON(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenTry): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.previousConnectionId !== undefined && (obj.previousConnectionId = message.previousConnectionId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + if (message.counterpartyVersions) { + obj.counterpartyVersions = message.counterpartyVersions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.counterpartyVersions = []; + } + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined ? message.proofClient : new Uint8Array(), + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined ? message.proofConsensus : new Uint8Array(), + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight ? Height.toJSON(message.consensusHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenTry { + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.previousConnectionId !== undefined && object.previousConnectionId !== null) { + message.previousConnectionId = object.previousConnectionId; + } else { + message.previousConnectionId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod as Long; + } else { + message.delayPeriod = Long.UZERO; + } + if (object.counterpartyVersions !== undefined && object.counterpartyVersions !== null) { + for (const e of object.counterpartyVersions) { + message.counterpartyVersions.push(Version.fromPartial(e)); + } + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = object.proofClient; + } else { + message.proofClient = new Uint8Array(); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = object.proofConsensus; + } else { + message.proofConsensus = new Uint8Array(); + } + if (object.consensusHeight !== undefined && object.consensusHeight !== null) { + message.consensusHeight = Height.fromPartial(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenTryResponse: object = {}; + +export const MsgConnectionOpenTryResponse = { + encode(_: MsgConnectionOpenTryResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenTryResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenTryResponse } as MsgConnectionOpenTryResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenTryResponse { + const message = { ...baseMsgConnectionOpenTryResponse } as MsgConnectionOpenTryResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenTryResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgConnectionOpenTryResponse { + const message = { ...baseMsgConnectionOpenTryResponse } as MsgConnectionOpenTryResponse; + return message; + }, +}; + +const baseMsgConnectionOpenAck: object = { connectionId: "", counterpartyConnectionId: "", signer: "" }; + +export const MsgConnectionOpenAck = { + encode(message: MsgConnectionOpenAck, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (message.counterpartyConnectionId !== "") { + writer.uint32(18).string(message.counterpartyConnectionId); + } + if (message.version !== undefined) { + Version.encode(message.version, writer.uint32(26).fork()).ldelim(); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(34).fork()).ldelim(); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(42).fork()).ldelim(); + } + if (message.proofTry.length !== 0) { + writer.uint32(50).bytes(message.proofTry); + } + if (message.proofClient.length !== 0) { + writer.uint32(58).bytes(message.proofClient); + } + if (message.proofConsensus.length !== 0) { + writer.uint32(66).bytes(message.proofConsensus); + } + if (message.consensusHeight !== undefined) { + Height.encode(message.consensusHeight, writer.uint32(74).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(82).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenAck { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + message.proofTry = new Uint8Array(); + message.proofClient = new Uint8Array(); + message.proofConsensus = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.counterpartyConnectionId = reader.string(); + break; + case 3: + message.version = Version.decode(reader, reader.uint32()); + break; + case 4: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 5: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 6: + message.proofTry = reader.bytes(); + break; + case 7: + message.proofClient = reader.bytes(); + break; + case 8: + message.proofConsensus = reader.bytes(); + break; + case 9: + message.consensusHeight = Height.decode(reader, reader.uint32()); + break; + case 10: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenAck { + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + message.proofTry = new Uint8Array(); + message.proofClient = new Uint8Array(); + message.proofConsensus = new Uint8Array(); + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.counterpartyConnectionId !== undefined && object.counterpartyConnectionId !== null) { + message.counterpartyConnectionId = String(object.counterpartyConnectionId); + } else { + message.counterpartyConnectionId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = bytesFromBase64(object.proofTry); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = bytesFromBase64(object.proofClient); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = bytesFromBase64(object.proofConsensus); + } + if (object.consensusHeight !== undefined && object.consensusHeight !== null) { + message.consensusHeight = Height.fromJSON(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenAck): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.counterpartyConnectionId !== undefined && + (obj.counterpartyConnectionId = message.counterpartyConnectionId); + message.version !== undefined && + (obj.version = message.version ? Version.toJSON(message.version) : undefined); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes(message.proofTry !== undefined ? message.proofTry : new Uint8Array())); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined ? message.proofClient : new Uint8Array(), + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined ? message.proofConsensus : new Uint8Array(), + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight ? Height.toJSON(message.consensusHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenAck { + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.counterpartyConnectionId !== undefined && object.counterpartyConnectionId !== null) { + message.counterpartyConnectionId = object.counterpartyConnectionId; + } else { + message.counterpartyConnectionId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = object.proofTry; + } else { + message.proofTry = new Uint8Array(); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = object.proofClient; + } else { + message.proofClient = new Uint8Array(); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = object.proofConsensus; + } else { + message.proofConsensus = new Uint8Array(); + } + if (object.consensusHeight !== undefined && object.consensusHeight !== null) { + message.consensusHeight = Height.fromPartial(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenAckResponse: object = {}; + +export const MsgConnectionOpenAckResponse = { + encode(_: MsgConnectionOpenAckResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenAckResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenAckResponse } as MsgConnectionOpenAckResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenAckResponse { + const message = { ...baseMsgConnectionOpenAckResponse } as MsgConnectionOpenAckResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgConnectionOpenAckResponse { + const message = { ...baseMsgConnectionOpenAckResponse } as MsgConnectionOpenAckResponse; + return message; + }, +}; + +const baseMsgConnectionOpenConfirm: object = { connectionId: "", signer: "" }; + +export const MsgConnectionOpenConfirm = { + encode(message: MsgConnectionOpenConfirm, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (message.proofAck.length !== 0) { + writer.uint32(18).bytes(message.proofAck); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenConfirm { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenConfirm } as MsgConnectionOpenConfirm; + message.proofAck = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.proofAck = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenConfirm { + const message = { ...baseMsgConnectionOpenConfirm } as MsgConnectionOpenConfirm; + message.proofAck = new Uint8Array(); + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = bytesFromBase64(object.proofAck); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenConfirm): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes(message.proofAck !== undefined ? message.proofAck : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenConfirm { + const message = { ...baseMsgConnectionOpenConfirm } as MsgConnectionOpenConfirm; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = object.proofAck; + } else { + message.proofAck = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenConfirmResponse: object = {}; + +export const MsgConnectionOpenConfirmResponse = { + encode(_: MsgConnectionOpenConfirmResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgConnectionOpenConfirmResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenConfirmResponse } as MsgConnectionOpenConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenConfirmResponse { + const message = { ...baseMsgConnectionOpenConfirmResponse } as MsgConnectionOpenConfirmResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgConnectionOpenConfirmResponse { + const message = { ...baseMsgConnectionOpenConfirmResponse } as MsgConnectionOpenConfirmResponse; + return message; + }, +}; + +/** Msg defines the ibc/connection Msg service. */ +export interface Msg { + /** ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. */ + ConnectionOpenInit(request: MsgConnectionOpenInit): Promise; + /** ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. */ + ConnectionOpenTry(request: MsgConnectionOpenTry): Promise; + /** ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. */ + ConnectionOpenAck(request: MsgConnectionOpenAck): Promise; + /** ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. */ + ConnectionOpenConfirm(request: MsgConnectionOpenConfirm): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.ConnectionOpenInit = this.ConnectionOpenInit.bind(this); + this.ConnectionOpenTry = this.ConnectionOpenTry.bind(this); + this.ConnectionOpenAck = this.ConnectionOpenAck.bind(this); + this.ConnectionOpenConfirm = this.ConnectionOpenConfirm.bind(this); + } + ConnectionOpenInit(request: MsgConnectionOpenInit): Promise { + const data = MsgConnectionOpenInit.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Msg", "ConnectionOpenInit", data); + return promise.then((data) => MsgConnectionOpenInitResponse.decode(new _m0.Reader(data))); + } + + ConnectionOpenTry(request: MsgConnectionOpenTry): Promise { + const data = MsgConnectionOpenTry.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Msg", "ConnectionOpenTry", data); + return promise.then((data) => MsgConnectionOpenTryResponse.decode(new _m0.Reader(data))); + } + + ConnectionOpenAck(request: MsgConnectionOpenAck): Promise { + const data = MsgConnectionOpenAck.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Msg", "ConnectionOpenAck", data); + return promise.then((data) => MsgConnectionOpenAckResponse.decode(new _m0.Reader(data))); + } + + ConnectionOpenConfirm(request: MsgConnectionOpenConfirm): Promise { + const data = MsgConnectionOpenConfirm.encode(request).finish(); + const promise = this.rpc.request("ibc.core.connection.v1.Msg", "ConnectionOpenConfirm", data); + return promise.then((data) => MsgConnectionOpenConfirmResponse.decode(new _m0.Reader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/core/types/v1/genesis.ts b/src/ibc/core/types/v1/genesis.ts new file mode 100644 index 00000000..b315dde8 --- /dev/null +++ b/src/ibc/core/types/v1/genesis.ts @@ -0,0 +1,130 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { GenesisState as GenesisState1 } from "../../../../ibc/core/client/v1/genesis"; +import { GenesisState as GenesisState2 } from "../../../../ibc/core/connection/v1/genesis"; +import { GenesisState as GenesisState3 } from "../../../../ibc/core/channel/v1/genesis"; + +export const protobufPackage = "ibc.core.types.v1"; + +/** GenesisState defines the ibc module's genesis state. */ +export interface GenesisState { + /** ICS002 - Clients genesis state */ + clientGenesis?: GenesisState1; + /** ICS003 - Connections genesis state */ + connectionGenesis?: GenesisState2; + /** ICS004 - Channel genesis state */ + channelGenesis?: GenesisState3; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientGenesis !== undefined) { + GenesisState1.encode(message.clientGenesis, writer.uint32(10).fork()).ldelim(); + } + if (message.connectionGenesis !== undefined) { + GenesisState2.encode(message.connectionGenesis, writer.uint32(18).fork()).ldelim(); + } + if (message.channelGenesis !== undefined) { + GenesisState3.encode(message.channelGenesis, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientGenesis = GenesisState1.decode(reader, reader.uint32()); + break; + case 2: + message.connectionGenesis = GenesisState2.decode(reader, reader.uint32()); + break; + case 3: + message.channelGenesis = GenesisState3.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.clientGenesis !== undefined && object.clientGenesis !== null) { + message.clientGenesis = GenesisState1.fromJSON(object.clientGenesis); + } else { + message.clientGenesis = undefined; + } + if (object.connectionGenesis !== undefined && object.connectionGenesis !== null) { + message.connectionGenesis = GenesisState2.fromJSON(object.connectionGenesis); + } else { + message.connectionGenesis = undefined; + } + if (object.channelGenesis !== undefined && object.channelGenesis !== null) { + message.channelGenesis = GenesisState3.fromJSON(object.channelGenesis); + } else { + message.channelGenesis = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.clientGenesis !== undefined && + (obj.clientGenesis = message.clientGenesis ? GenesisState1.toJSON(message.clientGenesis) : undefined); + message.connectionGenesis !== undefined && + (obj.connectionGenesis = message.connectionGenesis + ? GenesisState2.toJSON(message.connectionGenesis) + : undefined); + message.channelGenesis !== undefined && + (obj.channelGenesis = message.channelGenesis + ? GenesisState3.toJSON(message.channelGenesis) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.clientGenesis !== undefined && object.clientGenesis !== null) { + message.clientGenesis = GenesisState1.fromPartial(object.clientGenesis); + } else { + message.clientGenesis = undefined; + } + if (object.connectionGenesis !== undefined && object.connectionGenesis !== null) { + message.connectionGenesis = GenesisState2.fromPartial(object.connectionGenesis); + } else { + message.connectionGenesis = undefined; + } + if (object.channelGenesis !== undefined && object.channelGenesis !== null) { + message.channelGenesis = GenesisState3.fromPartial(object.channelGenesis); + } else { + message.channelGenesis = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/lightclients/localhost/v1/localhost.ts b/src/ibc/lightclients/localhost/v1/localhost.ts new file mode 100644 index 00000000..e3466829 --- /dev/null +++ b/src/ibc/lightclients/localhost/v1/localhost.ts @@ -0,0 +1,105 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.lightclients.localhost.v1"; + +/** + * ClientState defines a loopback (localhost) client. It requires (read-only) + * access to keys outside the client prefix. + */ +export interface ClientState { + /** self chain ID */ + chainId: string; + /** self latest block height */ + height?: Height; +} + +const baseClientState: object = { chainId: "" }; + +export const ClientState = { + encode(message: ClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientState } as ClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientState { + const message = { ...baseClientState } as ClientState; + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ClientState { + const message = { ...baseClientState } as ClientState; + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/lightclients/solomachine/v1/solomachine.ts b/src/ibc/lightclients/solomachine/v1/solomachine.ts new file mode 100644 index 00000000..a7b4092b --- /dev/null +++ b/src/ibc/lightclients/solomachine/v1/solomachine.ts @@ -0,0 +1,1708 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { ConnectionEnd } from "../../../../ibc/core/connection/v1/connection"; +import { Channel } from "../../../../ibc/core/channel/v1/channel"; + +export const protobufPackage = "ibc.lightclients.solomachine.v1"; + +/** + * DataType defines the type of solo machine proof being created. This is done to preserve uniqueness of different + * data sign byte encodings. + */ +export enum DataType { + /** DATA_TYPE_UNINITIALIZED_UNSPECIFIED - Default State */ + DATA_TYPE_UNINITIALIZED_UNSPECIFIED = 0, + /** DATA_TYPE_CLIENT_STATE - Data type for client state verification */ + DATA_TYPE_CLIENT_STATE = 1, + /** DATA_TYPE_CONSENSUS_STATE - Data type for consensus state verification */ + DATA_TYPE_CONSENSUS_STATE = 2, + /** DATA_TYPE_CONNECTION_STATE - Data type for connection state verification */ + DATA_TYPE_CONNECTION_STATE = 3, + /** DATA_TYPE_CHANNEL_STATE - Data type for channel state verification */ + DATA_TYPE_CHANNEL_STATE = 4, + /** DATA_TYPE_PACKET_COMMITMENT - Data type for packet commitment verification */ + DATA_TYPE_PACKET_COMMITMENT = 5, + /** DATA_TYPE_PACKET_ACKNOWLEDGEMENT - Data type for packet acknowledgement verification */ + DATA_TYPE_PACKET_ACKNOWLEDGEMENT = 6, + /** DATA_TYPE_PACKET_RECEIPT_ABSENCE - Data type for packet receipt absence verification */ + DATA_TYPE_PACKET_RECEIPT_ABSENCE = 7, + /** DATA_TYPE_NEXT_SEQUENCE_RECV - Data type for next sequence recv verification */ + DATA_TYPE_NEXT_SEQUENCE_RECV = 8, + /** DATA_TYPE_HEADER - Data type for header verification */ + DATA_TYPE_HEADER = 9, + UNRECOGNIZED = -1, +} + +export function dataTypeFromJSON(object: any): DataType { + switch (object) { + case 0: + case "DATA_TYPE_UNINITIALIZED_UNSPECIFIED": + return DataType.DATA_TYPE_UNINITIALIZED_UNSPECIFIED; + case 1: + case "DATA_TYPE_CLIENT_STATE": + return DataType.DATA_TYPE_CLIENT_STATE; + case 2: + case "DATA_TYPE_CONSENSUS_STATE": + return DataType.DATA_TYPE_CONSENSUS_STATE; + case 3: + case "DATA_TYPE_CONNECTION_STATE": + return DataType.DATA_TYPE_CONNECTION_STATE; + case 4: + case "DATA_TYPE_CHANNEL_STATE": + return DataType.DATA_TYPE_CHANNEL_STATE; + case 5: + case "DATA_TYPE_PACKET_COMMITMENT": + return DataType.DATA_TYPE_PACKET_COMMITMENT; + case 6: + case "DATA_TYPE_PACKET_ACKNOWLEDGEMENT": + return DataType.DATA_TYPE_PACKET_ACKNOWLEDGEMENT; + case 7: + case "DATA_TYPE_PACKET_RECEIPT_ABSENCE": + return DataType.DATA_TYPE_PACKET_RECEIPT_ABSENCE; + case 8: + case "DATA_TYPE_NEXT_SEQUENCE_RECV": + return DataType.DATA_TYPE_NEXT_SEQUENCE_RECV; + case 9: + case "DATA_TYPE_HEADER": + return DataType.DATA_TYPE_HEADER; + case -1: + case "UNRECOGNIZED": + default: + return DataType.UNRECOGNIZED; + } +} + +export function dataTypeToJSON(object: DataType): string { + switch (object) { + case DataType.DATA_TYPE_UNINITIALIZED_UNSPECIFIED: + return "DATA_TYPE_UNINITIALIZED_UNSPECIFIED"; + case DataType.DATA_TYPE_CLIENT_STATE: + return "DATA_TYPE_CLIENT_STATE"; + case DataType.DATA_TYPE_CONSENSUS_STATE: + return "DATA_TYPE_CONSENSUS_STATE"; + case DataType.DATA_TYPE_CONNECTION_STATE: + return "DATA_TYPE_CONNECTION_STATE"; + case DataType.DATA_TYPE_CHANNEL_STATE: + return "DATA_TYPE_CHANNEL_STATE"; + case DataType.DATA_TYPE_PACKET_COMMITMENT: + return "DATA_TYPE_PACKET_COMMITMENT"; + case DataType.DATA_TYPE_PACKET_ACKNOWLEDGEMENT: + return "DATA_TYPE_PACKET_ACKNOWLEDGEMENT"; + case DataType.DATA_TYPE_PACKET_RECEIPT_ABSENCE: + return "DATA_TYPE_PACKET_RECEIPT_ABSENCE"; + case DataType.DATA_TYPE_NEXT_SEQUENCE_RECV: + return "DATA_TYPE_NEXT_SEQUENCE_RECV"; + case DataType.DATA_TYPE_HEADER: + return "DATA_TYPE_HEADER"; + default: + return "UNKNOWN"; + } +} + +/** + * ClientState defines a solo machine client that tracks the current consensus + * state and if the client is frozen. + */ +export interface ClientState { + /** latest sequence of the client state */ + sequence: Long; + /** frozen sequence of the solo machine */ + frozenSequence: Long; + consensusState?: ConsensusState; + /** + * when set to true, will allow governance to update a solo machine client. + * The client will be unfrozen if it is frozen. + */ + allowUpdateAfterProposal: boolean; +} + +/** + * ConsensusState defines a solo machine consensus state. The sequence of a consensus state + * is contained in the "height" key used in storing the consensus state. + */ +export interface ConsensusState { + /** public key of the solo machine */ + publicKey?: Any; + /** + * diversifier allows the same public key to be re-used across different solo machine clients + * (potentially on different chains) without being considered misbehaviour. + */ + diversifier: string; + timestamp: Long; +} + +/** Header defines a solo machine consensus header */ +export interface Header { + /** sequence to update solo machine public key at */ + sequence: Long; + timestamp: Long; + signature: Uint8Array; + newPublicKey?: Any; + newDiversifier: string; +} + +/** + * Misbehaviour defines misbehaviour for a solo machine which consists + * of a sequence and two signatures over different messages at that sequence. + */ +export interface Misbehaviour { + clientId: string; + sequence: Long; + signatureOne?: SignatureAndData; + signatureTwo?: SignatureAndData; +} + +/** + * SignatureAndData contains a signature and the data signed over to create that + * signature. + */ +export interface SignatureAndData { + signature: Uint8Array; + dataType: DataType; + data: Uint8Array; + timestamp: Long; +} + +/** + * TimestampedSignatureData contains the signature data and the timestamp of the + * signature. + */ +export interface TimestampedSignatureData { + signatureData: Uint8Array; + timestamp: Long; +} + +/** SignBytes defines the signed bytes used for signature verification. */ +export interface SignBytes { + sequence: Long; + timestamp: Long; + diversifier: string; + /** type of the data used */ + dataType: DataType; + /** marshaled data */ + data: Uint8Array; +} + +/** HeaderData returns the SignBytes data for update verification. */ +export interface HeaderData { + /** header public key */ + newPubKey?: Any; + /** header diversifier */ + newDiversifier: string; +} + +/** ClientStateData returns the SignBytes data for client state verification. */ +export interface ClientStateData { + path: Uint8Array; + clientState?: Any; +} + +/** + * ConsensusStateData returns the SignBytes data for consensus state + * verification. + */ +export interface ConsensusStateData { + path: Uint8Array; + consensusState?: Any; +} + +/** + * ConnectionStateData returns the SignBytes data for connection state + * verification. + */ +export interface ConnectionStateData { + path: Uint8Array; + connection?: ConnectionEnd; +} + +/** + * ChannelStateData returns the SignBytes data for channel state + * verification. + */ +export interface ChannelStateData { + path: Uint8Array; + channel?: Channel; +} + +/** + * PacketCommitmentData returns the SignBytes data for packet commitment + * verification. + */ +export interface PacketCommitmentData { + path: Uint8Array; + commitment: Uint8Array; +} + +/** + * PacketAcknowledgementData returns the SignBytes data for acknowledgement + * verification. + */ +export interface PacketAcknowledgementData { + path: Uint8Array; + acknowledgement: Uint8Array; +} + +/** + * PacketReceiptAbsenceData returns the SignBytes data for + * packet receipt absence verification. + */ +export interface PacketReceiptAbsenceData { + path: Uint8Array; +} + +/** + * NextSequenceRecvData returns the SignBytes data for verification of the next + * sequence to be received. + */ +export interface NextSequenceRecvData { + path: Uint8Array; + nextSeqRecv: Long; +} + +const baseClientState: object = { + sequence: Long.UZERO, + frozenSequence: Long.UZERO, + allowUpdateAfterProposal: false, +}; + +export const ClientState = { + encode(message: ClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.sequence.isZero()) { + writer.uint32(8).uint64(message.sequence); + } + if (!message.frozenSequence.isZero()) { + writer.uint32(16).uint64(message.frozenSequence); + } + if (message.consensusState !== undefined) { + ConsensusState.encode(message.consensusState, writer.uint32(26).fork()).ldelim(); + } + if (message.allowUpdateAfterProposal === true) { + writer.uint32(32).bool(message.allowUpdateAfterProposal); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientState } as ClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = reader.uint64() as Long; + break; + case 2: + message.frozenSequence = reader.uint64() as Long; + break; + case 3: + message.consensusState = ConsensusState.decode(reader, reader.uint32()); + break; + case 4: + message.allowUpdateAfterProposal = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientState { + const message = { ...baseClientState } as ClientState; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.frozenSequence !== undefined && object.frozenSequence !== null) { + message.frozenSequence = Long.fromString(object.frozenSequence); + } else { + message.frozenSequence = Long.UZERO; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = ConsensusState.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.allowUpdateAfterProposal !== undefined && object.allowUpdateAfterProposal !== null) { + message.allowUpdateAfterProposal = Boolean(object.allowUpdateAfterProposal); + } else { + message.allowUpdateAfterProposal = false; + } + return message; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.frozenSequence !== undefined && + (obj.frozenSequence = (message.frozenSequence || Long.UZERO).toString()); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? ConsensusState.toJSON(message.consensusState) + : undefined); + message.allowUpdateAfterProposal !== undefined && + (obj.allowUpdateAfterProposal = message.allowUpdateAfterProposal); + return obj; + }, + + fromPartial(object: DeepPartial): ClientState { + const message = { ...baseClientState } as ClientState; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.frozenSequence !== undefined && object.frozenSequence !== null) { + message.frozenSequence = object.frozenSequence as Long; + } else { + message.frozenSequence = Long.UZERO; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = ConsensusState.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.allowUpdateAfterProposal !== undefined && object.allowUpdateAfterProposal !== null) { + message.allowUpdateAfterProposal = object.allowUpdateAfterProposal; + } else { + message.allowUpdateAfterProposal = false; + } + return message; + }, +}; + +const baseConsensusState: object = { diversifier: "", timestamp: Long.UZERO }; + +export const ConsensusState = { + encode(message: ConsensusState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); + } + if (message.diversifier !== "") { + writer.uint32(18).string(message.diversifier); + } + if (!message.timestamp.isZero()) { + writer.uint32(24).uint64(message.timestamp); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConsensusState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusState } as ConsensusState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.diversifier = reader.string(); + break; + case 3: + message.timestamp = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusState { + const message = { ...baseConsensusState } as ConsensusState; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromJSON(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.diversifier !== undefined && object.diversifier !== null) { + message.diversifier = String(object.diversifier); + } else { + message.diversifier = ""; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Long.fromString(object.timestamp); + } else { + message.timestamp = Long.UZERO; + } + return message; + }, + + toJSON(message: ConsensusState): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.diversifier !== undefined && (obj.diversifier = message.diversifier); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusState { + const message = { ...baseConsensusState } as ConsensusState; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.diversifier !== undefined && object.diversifier !== null) { + message.diversifier = object.diversifier; + } else { + message.diversifier = ""; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp as Long; + } else { + message.timestamp = Long.UZERO; + } + return message; + }, +}; + +const baseHeader: object = { sequence: Long.UZERO, timestamp: Long.UZERO, newDiversifier: "" }; + +export const Header = { + encode(message: Header, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.sequence.isZero()) { + writer.uint32(8).uint64(message.sequence); + } + if (!message.timestamp.isZero()) { + writer.uint32(16).uint64(message.timestamp); + } + if (message.signature.length !== 0) { + writer.uint32(26).bytes(message.signature); + } + if (message.newPublicKey !== undefined) { + Any.encode(message.newPublicKey, writer.uint32(34).fork()).ldelim(); + } + if (message.newDiversifier !== "") { + writer.uint32(42).string(message.newDiversifier); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Header { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + message.signature = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = reader.uint64() as Long; + break; + case 2: + message.timestamp = reader.uint64() as Long; + break; + case 3: + message.signature = reader.bytes(); + break; + case 4: + message.newPublicKey = Any.decode(reader, reader.uint32()); + break; + case 5: + message.newDiversifier = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + message.signature = new Uint8Array(); + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Long.fromString(object.timestamp); + } else { + message.timestamp = Long.UZERO; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + if (object.newPublicKey !== undefined && object.newPublicKey !== null) { + message.newPublicKey = Any.fromJSON(object.newPublicKey); + } else { + message.newPublicKey = undefined; + } + if (object.newDiversifier !== undefined && object.newDiversifier !== null) { + message.newDiversifier = String(object.newDiversifier); + } else { + message.newDiversifier = ""; + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + message.newPublicKey !== undefined && + (obj.newPublicKey = message.newPublicKey ? Any.toJSON(message.newPublicKey) : undefined); + message.newDiversifier !== undefined && (obj.newDiversifier = message.newDiversifier); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp as Long; + } else { + message.timestamp = Long.UZERO; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + if (object.newPublicKey !== undefined && object.newPublicKey !== null) { + message.newPublicKey = Any.fromPartial(object.newPublicKey); + } else { + message.newPublicKey = undefined; + } + if (object.newDiversifier !== undefined && object.newDiversifier !== null) { + message.newDiversifier = object.newDiversifier; + } else { + message.newDiversifier = ""; + } + return message; + }, +}; + +const baseMisbehaviour: object = { clientId: "", sequence: Long.UZERO }; + +export const Misbehaviour = { + encode(message: Misbehaviour, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (!message.sequence.isZero()) { + writer.uint32(16).uint64(message.sequence); + } + if (message.signatureOne !== undefined) { + SignatureAndData.encode(message.signatureOne, writer.uint32(26).fork()).ldelim(); + } + if (message.signatureTwo !== undefined) { + SignatureAndData.encode(message.signatureTwo, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Misbehaviour { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMisbehaviour } as Misbehaviour; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.sequence = reader.uint64() as Long; + break; + case 3: + message.signatureOne = SignatureAndData.decode(reader, reader.uint32()); + break; + case 4: + message.signatureTwo = SignatureAndData.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Misbehaviour { + const message = { ...baseMisbehaviour } as Misbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.signatureOne !== undefined && object.signatureOne !== null) { + message.signatureOne = SignatureAndData.fromJSON(object.signatureOne); + } else { + message.signatureOne = undefined; + } + if (object.signatureTwo !== undefined && object.signatureTwo !== null) { + message.signatureTwo = SignatureAndData.fromJSON(object.signatureTwo); + } else { + message.signatureTwo = undefined; + } + return message; + }, + + toJSON(message: Misbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.signatureOne !== undefined && + (obj.signatureOne = message.signatureOne ? SignatureAndData.toJSON(message.signatureOne) : undefined); + message.signatureTwo !== undefined && + (obj.signatureTwo = message.signatureTwo ? SignatureAndData.toJSON(message.signatureTwo) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Misbehaviour { + const message = { ...baseMisbehaviour } as Misbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.signatureOne !== undefined && object.signatureOne !== null) { + message.signatureOne = SignatureAndData.fromPartial(object.signatureOne); + } else { + message.signatureOne = undefined; + } + if (object.signatureTwo !== undefined && object.signatureTwo !== null) { + message.signatureTwo = SignatureAndData.fromPartial(object.signatureTwo); + } else { + message.signatureTwo = undefined; + } + return message; + }, +}; + +const baseSignatureAndData: object = { dataType: 0, timestamp: Long.UZERO }; + +export const SignatureAndData = { + encode(message: SignatureAndData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.signature.length !== 0) { + writer.uint32(10).bytes(message.signature); + } + if (message.dataType !== 0) { + writer.uint32(16).int32(message.dataType); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + if (!message.timestamp.isZero()) { + writer.uint32(32).uint64(message.timestamp); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SignatureAndData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignatureAndData } as SignatureAndData; + message.signature = new Uint8Array(); + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signature = reader.bytes(); + break; + case 2: + message.dataType = reader.int32() as any; + break; + case 3: + message.data = reader.bytes(); + break; + case 4: + message.timestamp = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureAndData { + const message = { ...baseSignatureAndData } as SignatureAndData; + message.signature = new Uint8Array(); + message.data = new Uint8Array(); + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + if (object.dataType !== undefined && object.dataType !== null) { + message.dataType = dataTypeFromJSON(object.dataType); + } else { + message.dataType = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Long.fromString(object.timestamp); + } else { + message.timestamp = Long.UZERO; + } + return message; + }, + + toJSON(message: SignatureAndData): unknown { + const obj: any = {}; + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + message.dataType !== undefined && (obj.dataType = dataTypeToJSON(message.dataType)); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): SignatureAndData { + const message = { ...baseSignatureAndData } as SignatureAndData; + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + if (object.dataType !== undefined && object.dataType !== null) { + message.dataType = object.dataType; + } else { + message.dataType = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp as Long; + } else { + message.timestamp = Long.UZERO; + } + return message; + }, +}; + +const baseTimestampedSignatureData: object = { timestamp: Long.UZERO }; + +export const TimestampedSignatureData = { + encode(message: TimestampedSignatureData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.signatureData.length !== 0) { + writer.uint32(10).bytes(message.signatureData); + } + if (!message.timestamp.isZero()) { + writer.uint32(16).uint64(message.timestamp); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): TimestampedSignatureData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestampedSignatureData } as TimestampedSignatureData; + message.signatureData = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signatureData = reader.bytes(); + break; + case 2: + message.timestamp = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TimestampedSignatureData { + const message = { ...baseTimestampedSignatureData } as TimestampedSignatureData; + message.signatureData = new Uint8Array(); + if (object.signatureData !== undefined && object.signatureData !== null) { + message.signatureData = bytesFromBase64(object.signatureData); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Long.fromString(object.timestamp); + } else { + message.timestamp = Long.UZERO; + } + return message; + }, + + toJSON(message: TimestampedSignatureData): unknown { + const obj: any = {}; + message.signatureData !== undefined && + (obj.signatureData = base64FromBytes( + message.signatureData !== undefined ? message.signatureData : new Uint8Array(), + )); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): TimestampedSignatureData { + const message = { ...baseTimestampedSignatureData } as TimestampedSignatureData; + if (object.signatureData !== undefined && object.signatureData !== null) { + message.signatureData = object.signatureData; + } else { + message.signatureData = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp as Long; + } else { + message.timestamp = Long.UZERO; + } + return message; + }, +}; + +const baseSignBytes: object = { sequence: Long.UZERO, timestamp: Long.UZERO, diversifier: "", dataType: 0 }; + +export const SignBytes = { + encode(message: SignBytes, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.sequence.isZero()) { + writer.uint32(8).uint64(message.sequence); + } + if (!message.timestamp.isZero()) { + writer.uint32(16).uint64(message.timestamp); + } + if (message.diversifier !== "") { + writer.uint32(26).string(message.diversifier); + } + if (message.dataType !== 0) { + writer.uint32(32).int32(message.dataType); + } + if (message.data.length !== 0) { + writer.uint32(42).bytes(message.data); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SignBytes { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignBytes } as SignBytes; + message.data = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = reader.uint64() as Long; + break; + case 2: + message.timestamp = reader.uint64() as Long; + break; + case 3: + message.diversifier = reader.string(); + break; + case 4: + message.dataType = reader.int32() as any; + break; + case 5: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignBytes { + const message = { ...baseSignBytes } as SignBytes; + message.data = new Uint8Array(); + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Long.fromString(object.sequence); + } else { + message.sequence = Long.UZERO; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Long.fromString(object.timestamp); + } else { + message.timestamp = Long.UZERO; + } + if (object.diversifier !== undefined && object.diversifier !== null) { + message.diversifier = String(object.diversifier); + } else { + message.diversifier = ""; + } + if (object.dataType !== undefined && object.dataType !== null) { + message.dataType = dataTypeFromJSON(object.dataType); + } else { + message.dataType = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: SignBytes): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + message.diversifier !== undefined && (obj.diversifier = message.diversifier); + message.dataType !== undefined && (obj.dataType = dataTypeToJSON(message.dataType)); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): SignBytes { + const message = { ...baseSignBytes } as SignBytes; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence as Long; + } else { + message.sequence = Long.UZERO; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp as Long; + } else { + message.timestamp = Long.UZERO; + } + if (object.diversifier !== undefined && object.diversifier !== null) { + message.diversifier = object.diversifier; + } else { + message.diversifier = ""; + } + if (object.dataType !== undefined && object.dataType !== null) { + message.dataType = object.dataType; + } else { + message.dataType = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseHeaderData: object = { newDiversifier: "" }; + +export const HeaderData = { + encode(message: HeaderData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.newPubKey !== undefined) { + Any.encode(message.newPubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.newDiversifier !== "") { + writer.uint32(18).string(message.newDiversifier); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): HeaderData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeaderData } as HeaderData; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.newPubKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.newDiversifier = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HeaderData { + const message = { ...baseHeaderData } as HeaderData; + if (object.newPubKey !== undefined && object.newPubKey !== null) { + message.newPubKey = Any.fromJSON(object.newPubKey); + } else { + message.newPubKey = undefined; + } + if (object.newDiversifier !== undefined && object.newDiversifier !== null) { + message.newDiversifier = String(object.newDiversifier); + } else { + message.newDiversifier = ""; + } + return message; + }, + + toJSON(message: HeaderData): unknown { + const obj: any = {}; + message.newPubKey !== undefined && + (obj.newPubKey = message.newPubKey ? Any.toJSON(message.newPubKey) : undefined); + message.newDiversifier !== undefined && (obj.newDiversifier = message.newDiversifier); + return obj; + }, + + fromPartial(object: DeepPartial): HeaderData { + const message = { ...baseHeaderData } as HeaderData; + if (object.newPubKey !== undefined && object.newPubKey !== null) { + message.newPubKey = Any.fromPartial(object.newPubKey); + } else { + message.newPubKey = undefined; + } + if (object.newDiversifier !== undefined && object.newDiversifier !== null) { + message.newDiversifier = object.newDiversifier; + } else { + message.newDiversifier = ""; + } + return message; + }, +}; + +const baseClientStateData: object = {}; + +export const ClientStateData = { + encode(message: ClientStateData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientStateData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientStateData } as ClientStateData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientStateData { + const message = { ...baseClientStateData } as ClientStateData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: ClientStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ClientStateData { + const message = { ...baseClientStateData } as ClientStateData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateData: object = {}; + +export const ConsensusStateData = { + encode(message: ConsensusStateData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConsensusStateData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusStateData } as ConsensusStateData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateData { + const message = { ...baseConsensusStateData } as ConsensusStateData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusStateData { + const message = { ...baseConsensusStateData } as ConsensusStateData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseConnectionStateData: object = {}; + +export const ConnectionStateData = { + encode(message: ConnectionStateData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.connection !== undefined) { + ConnectionEnd.encode(message.connection, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConnectionStateData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConnectionStateData } as ConnectionStateData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.connection = ConnectionEnd.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConnectionStateData { + const message = { ...baseConnectionStateData } as ConnectionStateData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromJSON(object.connection); + } else { + message.connection = undefined; + } + return message; + }, + + toJSON(message: ConnectionStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.connection !== undefined && + (obj.connection = message.connection ? ConnectionEnd.toJSON(message.connection) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConnectionStateData { + const message = { ...baseConnectionStateData } as ConnectionStateData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromPartial(object.connection); + } else { + message.connection = undefined; + } + return message; + }, +}; + +const baseChannelStateData: object = {}; + +export const ChannelStateData = { + encode(message: ChannelStateData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ChannelStateData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseChannelStateData } as ChannelStateData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.channel = Channel.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ChannelStateData { + const message = { ...baseChannelStateData } as ChannelStateData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + return message; + }, + + toJSON(message: ChannelStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ChannelStateData { + const message = { ...baseChannelStateData } as ChannelStateData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + return message; + }, +}; + +const basePacketCommitmentData: object = {}; + +export const PacketCommitmentData = { + encode(message: PacketCommitmentData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.commitment.length !== 0) { + writer.uint32(18).bytes(message.commitment); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PacketCommitmentData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketCommitmentData } as PacketCommitmentData; + message.path = new Uint8Array(); + message.commitment = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.commitment = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketCommitmentData { + const message = { ...basePacketCommitmentData } as PacketCommitmentData; + message.path = new Uint8Array(); + message.commitment = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = bytesFromBase64(object.commitment); + } + return message; + }, + + toJSON(message: PacketCommitmentData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.commitment !== undefined && + (obj.commitment = base64FromBytes( + message.commitment !== undefined ? message.commitment : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): PacketCommitmentData { + const message = { ...basePacketCommitmentData } as PacketCommitmentData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = object.commitment; + } else { + message.commitment = new Uint8Array(); + } + return message; + }, +}; + +const basePacketAcknowledgementData: object = {}; + +export const PacketAcknowledgementData = { + encode(message: PacketAcknowledgementData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (message.acknowledgement.length !== 0) { + writer.uint32(18).bytes(message.acknowledgement); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PacketAcknowledgementData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketAcknowledgementData } as PacketAcknowledgementData; + message.path = new Uint8Array(); + message.acknowledgement = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.acknowledgement = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketAcknowledgementData { + const message = { ...basePacketAcknowledgementData } as PacketAcknowledgementData; + message.path = new Uint8Array(); + message.acknowledgement = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = bytesFromBase64(object.acknowledgement); + } + return message; + }, + + toJSON(message: PacketAcknowledgementData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): PacketAcknowledgementData { + const message = { ...basePacketAcknowledgementData } as PacketAcknowledgementData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.acknowledgement !== undefined && object.acknowledgement !== null) { + message.acknowledgement = object.acknowledgement; + } else { + message.acknowledgement = new Uint8Array(); + } + return message; + }, +}; + +const basePacketReceiptAbsenceData: object = {}; + +export const PacketReceiptAbsenceData = { + encode(message: PacketReceiptAbsenceData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PacketReceiptAbsenceData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketReceiptAbsenceData } as PacketReceiptAbsenceData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketReceiptAbsenceData { + const message = { ...basePacketReceiptAbsenceData } as PacketReceiptAbsenceData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + return message; + }, + + toJSON(message: PacketReceiptAbsenceData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + return obj; + }, + + fromPartial(object: DeepPartial): PacketReceiptAbsenceData { + const message = { ...basePacketReceiptAbsenceData } as PacketReceiptAbsenceData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + return message; + }, +}; + +const baseNextSequenceRecvData: object = { nextSeqRecv: Long.UZERO }; + +export const NextSequenceRecvData = { + encode(message: NextSequenceRecvData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.path.length !== 0) { + writer.uint32(10).bytes(message.path); + } + if (!message.nextSeqRecv.isZero()) { + writer.uint32(16).uint64(message.nextSeqRecv); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): NextSequenceRecvData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseNextSequenceRecvData } as NextSequenceRecvData; + message.path = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.bytes(); + break; + case 2: + message.nextSeqRecv = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): NextSequenceRecvData { + const message = { ...baseNextSequenceRecvData } as NextSequenceRecvData; + message.path = new Uint8Array(); + if (object.path !== undefined && object.path !== null) { + message.path = bytesFromBase64(object.path); + } + if (object.nextSeqRecv !== undefined && object.nextSeqRecv !== null) { + message.nextSeqRecv = Long.fromString(object.nextSeqRecv); + } else { + message.nextSeqRecv = Long.UZERO; + } + return message; + }, + + toJSON(message: NextSequenceRecvData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.nextSeqRecv !== undefined && (obj.nextSeqRecv = (message.nextSeqRecv || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): NextSequenceRecvData { + const message = { ...baseNextSequenceRecvData } as NextSequenceRecvData; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = new Uint8Array(); + } + if (object.nextSeqRecv !== undefined && object.nextSeqRecv !== null) { + message.nextSeqRecv = object.nextSeqRecv as Long; + } else { + message.nextSeqRecv = Long.UZERO; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/src/ibc/lightclients/tendermint/v1/tendermint.ts b/src/ibc/lightclients/tendermint/v1/tendermint.ts new file mode 100644 index 00000000..583a8fad --- /dev/null +++ b/src/ibc/lightclients/tendermint/v1/tendermint.ts @@ -0,0 +1,795 @@ +/* eslint-disable */ +import Long from "long"; +import _m0 from "protobufjs/minimal"; +import { Duration } from "../../../../google/protobuf/duration"; +import { Height } from "../../../../ibc/core/client/v1/client"; +import { MerkleRoot } from "../../../../ibc/core/commitment/v1/commitment"; +import { SignedHeader } from "../../../../tendermint/types/types"; +import { ValidatorSet } from "../../../../tendermint/types/validator"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { ProofSpec } from "../../../../confio/proofs"; + +export const protobufPackage = "ibc.lightclients.tendermint.v1"; + +/** + * ClientState from Tendermint tracks the current validator set, latest height, + * and a possible frozen height. + */ +export interface ClientState { + chainId: string; + trustLevel?: Fraction; + /** + * duration of the period since the LastestTimestamp during which the + * submitted headers are valid for upgrade + */ + trustingPeriod?: Duration; + /** duration of the staking unbonding period */ + unbondingPeriod?: Duration; + /** defines how much new (untrusted) header's Time can drift into the future. */ + maxClockDrift?: Duration; + /** Block height when the client was frozen due to a misbehaviour */ + frozenHeight?: Height; + /** Latest height the client was updated to */ + latestHeight?: Height; + /** Proof specifications used in verifying counterparty state */ + proofSpecs: ProofSpec[]; + /** + * Path at which next upgraded client will be committed. + * Each element corresponds to the key for a single CommitmentProof in the chained proof. + * NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` + * ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` + * For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` + */ + upgradePath: string[]; + /** + * This flag, when set to true, will allow governance to recover a client + * which has expired + */ + allowUpdateAfterExpiry: boolean; + /** + * This flag, when set to true, will allow governance to unfreeze a client + * whose chain has experienced a misbehaviour event + */ + allowUpdateAfterMisbehaviour: boolean; +} + +/** ConsensusState defines the consensus state from Tendermint. */ +export interface ConsensusState { + /** + * timestamp that corresponds to the block height in which the ConsensusState + * was stored. + */ + timestamp?: Date; + /** commitment root (i.e app hash) */ + root?: MerkleRoot; + nextValidatorsHash: Uint8Array; +} + +/** + * Misbehaviour is a wrapper over two conflicting Headers + * that implements Misbehaviour interface expected by ICS-02 + */ +export interface Misbehaviour { + clientId: string; + header1?: Header; + header2?: Header; +} + +/** + * Header defines the Tendermint client consensus Header. + * It encapsulates all the information necessary to update from a trusted + * Tendermint ConsensusState. The inclusion of TrustedHeight and + * TrustedValidators allows this update to process correctly, so long as the + * ConsensusState for the TrustedHeight exists, this removes race conditions + * among relayers The SignedHeader and ValidatorSet are the new untrusted update + * fields for the client. The TrustedHeight is the height of a stored + * ConsensusState on the client that will be used to verify the new untrusted + * header. The Trusted ConsensusState must be within the unbonding period of + * current time in order to correctly verify, and the TrustedValidators must + * hash to TrustedConsensusState.NextValidatorsHash since that is the last + * trusted validator set at the TrustedHeight. + */ +export interface Header { + signedHeader?: SignedHeader; + validatorSet?: ValidatorSet; + trustedHeight?: Height; + trustedValidators?: ValidatorSet; +} + +/** Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. */ +export interface Fraction { + numerator: Long; + denominator: Long; +} + +const baseClientState: object = { + chainId: "", + upgradePath: "", + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, +}; + +export const ClientState = { + encode(message: ClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.trustLevel !== undefined) { + Fraction.encode(message.trustLevel, writer.uint32(18).fork()).ldelim(); + } + if (message.trustingPeriod !== undefined) { + Duration.encode(message.trustingPeriod, writer.uint32(26).fork()).ldelim(); + } + if (message.unbondingPeriod !== undefined) { + Duration.encode(message.unbondingPeriod, writer.uint32(34).fork()).ldelim(); + } + if (message.maxClockDrift !== undefined) { + Duration.encode(message.maxClockDrift, writer.uint32(42).fork()).ldelim(); + } + if (message.frozenHeight !== undefined) { + Height.encode(message.frozenHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.latestHeight !== undefined) { + Height.encode(message.latestHeight, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.proofSpecs) { + ProofSpec.encode(v!, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.upgradePath) { + writer.uint32(74).string(v!); + } + if (message.allowUpdateAfterExpiry === true) { + writer.uint32(80).bool(message.allowUpdateAfterExpiry); + } + if (message.allowUpdateAfterMisbehaviour === true) { + writer.uint32(88).bool(message.allowUpdateAfterMisbehaviour); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ClientState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientState } as ClientState; + message.proofSpecs = []; + message.upgradePath = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.trustLevel = Fraction.decode(reader, reader.uint32()); + break; + case 3: + message.trustingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.unbondingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 5: + message.maxClockDrift = Duration.decode(reader, reader.uint32()); + break; + case 6: + message.frozenHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.latestHeight = Height.decode(reader, reader.uint32()); + break; + case 8: + message.proofSpecs.push(ProofSpec.decode(reader, reader.uint32())); + break; + case 9: + message.upgradePath.push(reader.string()); + break; + case 10: + message.allowUpdateAfterExpiry = reader.bool(); + break; + case 11: + message.allowUpdateAfterMisbehaviour = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientState { + const message = { ...baseClientState } as ClientState; + message.proofSpecs = []; + message.upgradePath = []; + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.trustLevel !== undefined && object.trustLevel !== null) { + message.trustLevel = Fraction.fromJSON(object.trustLevel); + } else { + message.trustLevel = undefined; + } + if (object.trustingPeriod !== undefined && object.trustingPeriod !== null) { + message.trustingPeriod = Duration.fromJSON(object.trustingPeriod); + } else { + message.trustingPeriod = undefined; + } + if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) { + message.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod); + } else { + message.unbondingPeriod = undefined; + } + if (object.maxClockDrift !== undefined && object.maxClockDrift !== null) { + message.maxClockDrift = Duration.fromJSON(object.maxClockDrift); + } else { + message.maxClockDrift = undefined; + } + if (object.frozenHeight !== undefined && object.frozenHeight !== null) { + message.frozenHeight = Height.fromJSON(object.frozenHeight); + } else { + message.frozenHeight = undefined; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = Height.fromJSON(object.latestHeight); + } else { + message.latestHeight = undefined; + } + if (object.proofSpecs !== undefined && object.proofSpecs !== null) { + for (const e of object.proofSpecs) { + message.proofSpecs.push(ProofSpec.fromJSON(e)); + } + } + if (object.upgradePath !== undefined && object.upgradePath !== null) { + for (const e of object.upgradePath) { + message.upgradePath.push(String(e)); + } + } + if (object.allowUpdateAfterExpiry !== undefined && object.allowUpdateAfterExpiry !== null) { + message.allowUpdateAfterExpiry = Boolean(object.allowUpdateAfterExpiry); + } else { + message.allowUpdateAfterExpiry = false; + } + if (object.allowUpdateAfterMisbehaviour !== undefined && object.allowUpdateAfterMisbehaviour !== null) { + message.allowUpdateAfterMisbehaviour = Boolean(object.allowUpdateAfterMisbehaviour); + } else { + message.allowUpdateAfterMisbehaviour = false; + } + return message; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.trustLevel !== undefined && + (obj.trustLevel = message.trustLevel ? Fraction.toJSON(message.trustLevel) : undefined); + message.trustingPeriod !== undefined && + (obj.trustingPeriod = message.trustingPeriod ? Duration.toJSON(message.trustingPeriod) : undefined); + message.unbondingPeriod !== undefined && + (obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined); + message.maxClockDrift !== undefined && + (obj.maxClockDrift = message.maxClockDrift ? Duration.toJSON(message.maxClockDrift) : undefined); + message.frozenHeight !== undefined && + (obj.frozenHeight = message.frozenHeight ? Height.toJSON(message.frozenHeight) : undefined); + message.latestHeight !== undefined && + (obj.latestHeight = message.latestHeight ? Height.toJSON(message.latestHeight) : undefined); + if (message.proofSpecs) { + obj.proofSpecs = message.proofSpecs.map((e) => (e ? ProofSpec.toJSON(e) : undefined)); + } else { + obj.proofSpecs = []; + } + if (message.upgradePath) { + obj.upgradePath = message.upgradePath.map((e) => e); + } else { + obj.upgradePath = []; + } + message.allowUpdateAfterExpiry !== undefined && + (obj.allowUpdateAfterExpiry = message.allowUpdateAfterExpiry); + message.allowUpdateAfterMisbehaviour !== undefined && + (obj.allowUpdateAfterMisbehaviour = message.allowUpdateAfterMisbehaviour); + return obj; + }, + + fromPartial(object: DeepPartial): ClientState { + const message = { ...baseClientState } as ClientState; + message.proofSpecs = []; + message.upgradePath = []; + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.trustLevel !== undefined && object.trustLevel !== null) { + message.trustLevel = Fraction.fromPartial(object.trustLevel); + } else { + message.trustLevel = undefined; + } + if (object.trustingPeriod !== undefined && object.trustingPeriod !== null) { + message.trustingPeriod = Duration.fromPartial(object.trustingPeriod); + } else { + message.trustingPeriod = undefined; + } + if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) { + message.unbondingPeriod = Duration.fromPartial(object.unbondingPeriod); + } else { + message.unbondingPeriod = undefined; + } + if (object.maxClockDrift !== undefined && object.maxClockDrift !== null) { + message.maxClockDrift = Duration.fromPartial(object.maxClockDrift); + } else { + message.maxClockDrift = undefined; + } + if (object.frozenHeight !== undefined && object.frozenHeight !== null) { + message.frozenHeight = Height.fromPartial(object.frozenHeight); + } else { + message.frozenHeight = undefined; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = Height.fromPartial(object.latestHeight); + } else { + message.latestHeight = undefined; + } + if (object.proofSpecs !== undefined && object.proofSpecs !== null) { + for (const e of object.proofSpecs) { + message.proofSpecs.push(ProofSpec.fromPartial(e)); + } + } + if (object.upgradePath !== undefined && object.upgradePath !== null) { + for (const e of object.upgradePath) { + message.upgradePath.push(e); + } + } + if (object.allowUpdateAfterExpiry !== undefined && object.allowUpdateAfterExpiry !== null) { + message.allowUpdateAfterExpiry = object.allowUpdateAfterExpiry; + } else { + message.allowUpdateAfterExpiry = false; + } + if (object.allowUpdateAfterMisbehaviour !== undefined && object.allowUpdateAfterMisbehaviour !== null) { + message.allowUpdateAfterMisbehaviour = object.allowUpdateAfterMisbehaviour; + } else { + message.allowUpdateAfterMisbehaviour = false; + } + return message; + }, +}; + +const baseConsensusState: object = {}; + +export const ConsensusState = { + encode(message: ConsensusState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.timestamp !== undefined) { + Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim(); + } + if (message.root !== undefined) { + MerkleRoot.encode(message.root, writer.uint32(18).fork()).ldelim(); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(26).bytes(message.nextValidatorsHash); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ConsensusState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusState } as ConsensusState; + message.nextValidatorsHash = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 2: + message.root = MerkleRoot.decode(reader, reader.uint32()); + break; + case 3: + message.nextValidatorsHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusState { + const message = { ...baseConsensusState } as ConsensusState; + message.nextValidatorsHash = new Uint8Array(); + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.root !== undefined && object.root !== null) { + message.root = MerkleRoot.fromJSON(object.root); + } else { + message.root = undefined; + } + if (object.nextValidatorsHash !== undefined && object.nextValidatorsHash !== null) { + message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash); + } + return message; + }, + + toJSON(message: ConsensusState): unknown { + const obj: any = {}; + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + message.root !== undefined && (obj.root = message.root ? MerkleRoot.toJSON(message.root) : undefined); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined ? message.nextValidatorsHash : new Uint8Array(), + )); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusState { + const message = { ...baseConsensusState } as ConsensusState; + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.root !== undefined && object.root !== null) { + message.root = MerkleRoot.fromPartial(object.root); + } else { + message.root = undefined; + } + if (object.nextValidatorsHash !== undefined && object.nextValidatorsHash !== null) { + message.nextValidatorsHash = object.nextValidatorsHash; + } else { + message.nextValidatorsHash = new Uint8Array(); + } + return message; + }, +}; + +const baseMisbehaviour: object = { clientId: "" }; + +export const Misbehaviour = { + encode(message: Misbehaviour, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.header1 !== undefined) { + Header.encode(message.header1, writer.uint32(18).fork()).ldelim(); + } + if (message.header2 !== undefined) { + Header.encode(message.header2, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Misbehaviour { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMisbehaviour } as Misbehaviour; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.header1 = Header.decode(reader, reader.uint32()); + break; + case 3: + message.header2 = Header.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Misbehaviour { + const message = { ...baseMisbehaviour } as Misbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.header1 !== undefined && object.header1 !== null) { + message.header1 = Header.fromJSON(object.header1); + } else { + message.header1 = undefined; + } + if (object.header2 !== undefined && object.header2 !== null) { + message.header2 = Header.fromJSON(object.header2); + } else { + message.header2 = undefined; + } + return message; + }, + + toJSON(message: Misbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header1 !== undefined && + (obj.header1 = message.header1 ? Header.toJSON(message.header1) : undefined); + message.header2 !== undefined && + (obj.header2 = message.header2 ? Header.toJSON(message.header2) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Misbehaviour { + const message = { ...baseMisbehaviour } as Misbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.header1 !== undefined && object.header1 !== null) { + message.header1 = Header.fromPartial(object.header1); + } else { + message.header1 = undefined; + } + if (object.header2 !== undefined && object.header2 !== null) { + message.header2 = Header.fromPartial(object.header2); + } else { + message.header2 = undefined; + } + return message; + }, +}; + +const baseHeader: object = {}; + +export const Header = { + encode(message: Header, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.signedHeader !== undefined) { + SignedHeader.encode(message.signedHeader, writer.uint32(10).fork()).ldelim(); + } + if (message.validatorSet !== undefined) { + ValidatorSet.encode(message.validatorSet, writer.uint32(18).fork()).ldelim(); + } + if (message.trustedHeight !== undefined) { + Height.encode(message.trustedHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.trustedValidators !== undefined) { + ValidatorSet.encode(message.trustedValidators, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Header { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedHeader = SignedHeader.decode(reader, reader.uint32()); + break; + case 2: + message.validatorSet = ValidatorSet.decode(reader, reader.uint32()); + break; + case 3: + message.trustedHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.trustedValidators = ValidatorSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromJSON(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromJSON(object.validatorSet); + } else { + message.validatorSet = undefined; + } + if (object.trustedHeight !== undefined && object.trustedHeight !== null) { + message.trustedHeight = Height.fromJSON(object.trustedHeight); + } else { + message.trustedHeight = undefined; + } + if (object.trustedValidators !== undefined && object.trustedValidators !== null) { + message.trustedValidators = ValidatorSet.fromJSON(object.trustedValidators); + } else { + message.trustedValidators = undefined; + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader ? SignedHeader.toJSON(message.signedHeader) : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet ? ValidatorSet.toJSON(message.validatorSet) : undefined); + message.trustedHeight !== undefined && + (obj.trustedHeight = message.trustedHeight ? Height.toJSON(message.trustedHeight) : undefined); + message.trustedValidators !== undefined && + (obj.trustedValidators = message.trustedValidators + ? ValidatorSet.toJSON(message.trustedValidators) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromPartial(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromPartial(object.validatorSet); + } else { + message.validatorSet = undefined; + } + if (object.trustedHeight !== undefined && object.trustedHeight !== null) { + message.trustedHeight = Height.fromPartial(object.trustedHeight); + } else { + message.trustedHeight = undefined; + } + if (object.trustedValidators !== undefined && object.trustedValidators !== null) { + message.trustedValidators = ValidatorSet.fromPartial(object.trustedValidators); + } else { + message.trustedValidators = undefined; + } + return message; + }, +}; + +const baseFraction: object = { numerator: Long.UZERO, denominator: Long.UZERO }; + +export const Fraction = { + encode(message: Fraction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.numerator.isZero()) { + writer.uint32(8).uint64(message.numerator); + } + if (!message.denominator.isZero()) { + writer.uint32(16).uint64(message.denominator); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Fraction { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFraction } as Fraction; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.numerator = reader.uint64() as Long; + break; + case 2: + message.denominator = reader.uint64() as Long; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Fraction { + const message = { ...baseFraction } as Fraction; + if (object.numerator !== undefined && object.numerator !== null) { + message.numerator = Long.fromString(object.numerator); + } else { + message.numerator = Long.UZERO; + } + if (object.denominator !== undefined && object.denominator !== null) { + message.denominator = Long.fromString(object.denominator); + } else { + message.denominator = Long.UZERO; + } + return message; + }, + + toJSON(message: Fraction): unknown { + const obj: any = {}; + message.numerator !== undefined && (obj.numerator = (message.numerator || Long.UZERO).toString()); + message.denominator !== undefined && (obj.denominator = (message.denominator || Long.UZERO).toString()); + return obj; + }, + + fromPartial(object: DeepPartial): Fraction { + const message = { ...baseFraction } as Fraction; + if (object.numerator !== undefined && object.numerator !== null) { + message.numerator = object.numerator as Long; + } else { + message.numerator = Long.UZERO; + } + if (object.denominator !== undefined && object.denominator !== null) { + message.denominator = object.denominator as Long; + } else { + message.denominator = Long.UZERO; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = numberToLong(date.getTime() / 1_000); + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds.toNumber() * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function numberToLong(number: number) { + return Long.fromNumber(number); +} + +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/packages/cosmos/src/tendermint/abci/types.ts b/src/tendermint/abci/types.ts similarity index 100% rename from packages/cosmos/src/tendermint/abci/types.ts rename to src/tendermint/abci/types.ts diff --git a/packages/cosmos/src/tendermint/crypto/keys.ts b/src/tendermint/crypto/keys.ts similarity index 100% rename from packages/cosmos/src/tendermint/crypto/keys.ts rename to src/tendermint/crypto/keys.ts diff --git a/packages/cosmos/src/tendermint/crypto/proof.ts b/src/tendermint/crypto/proof.ts similarity index 100% rename from packages/cosmos/src/tendermint/crypto/proof.ts rename to src/tendermint/crypto/proof.ts diff --git a/packages/cosmos/src/tendermint/p2p/types.ts b/src/tendermint/p2p/types.ts similarity index 100% rename from packages/cosmos/src/tendermint/p2p/types.ts rename to src/tendermint/p2p/types.ts diff --git a/packages/cosmos/src/tendermint/types/block.ts b/src/tendermint/types/block.ts similarity index 100% rename from packages/cosmos/src/tendermint/types/block.ts rename to src/tendermint/types/block.ts diff --git a/packages/cosmos/src/tendermint/types/evidence.ts b/src/tendermint/types/evidence.ts similarity index 100% rename from packages/cosmos/src/tendermint/types/evidence.ts rename to src/tendermint/types/evidence.ts diff --git a/packages/cosmos/src/tendermint/types/params.ts b/src/tendermint/types/params.ts similarity index 100% rename from packages/cosmos/src/tendermint/types/params.ts rename to src/tendermint/types/params.ts diff --git a/packages/cosmos/src/tendermint/types/types.ts b/src/tendermint/types/types.ts similarity index 100% rename from packages/cosmos/src/tendermint/types/types.ts rename to src/tendermint/types/types.ts diff --git a/packages/cosmos/src/tendermint/types/validator.ts b/src/tendermint/types/validator.ts similarity index 100% rename from packages/cosmos/src/tendermint/types/validator.ts rename to src/tendermint/types/validator.ts diff --git a/packages/cosmos/src/tendermint/version/types.ts b/src/tendermint/version/types.ts similarity index 100% rename from packages/cosmos/src/tendermint/version/types.ts rename to src/tendermint/version/types.ts diff --git a/tsconfig.json b/tsconfig.json index b74563e3..6125e94e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,11 +13,14 @@ "noImplicitReturns": true, "noUnusedLocals": false, "noUnusedParameters": false, + "outDir": "build", "pretty": true, "removeComments": false, "resolveJsonModule": true, + "rootDir": "src", "sourceMap": true, "strict": true, "target": "es2017" - } + }, + "include": ["src/**/*"] } diff --git a/wasmd-0.16 b/wasmd-0.16 new file mode 160000 index 00000000..5eb3ae79 --- /dev/null +++ b/wasmd-0.16 @@ -0,0 +1 @@ +Subproject commit 5eb3ae79ca31548bcf1eba730e4bd0e7fa51010b diff --git a/yarn.lock b/yarn.lock index 46cee608..2d90de03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,19 +5,6 @@ __metadata: version: 4 cacheKey: 7 -"@cosmjs-types/cosmos@workspace:packages/cosmos": - version: 0.0.0-use.local - resolution: "@cosmjs-types/cosmos@workspace:packages/cosmos" - dependencies: - "@types/long": ^4.0.1 - "@types/node": ^15.6.1 - long: ^4.0.0 - prettier: ^2.3.0 - protobufjs: ~6.10.2 - typescript: ~4.0 - languageName: unknown - linkType: soft - "@protobufjs/aspromise@npm:^1.1.1, @protobufjs/aspromise@npm:^1.1.2": version: 1.1.2 resolution: "@protobufjs/aspromise@npm:1.1.2" @@ -98,7 +85,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:>=13.7.0, @types/node@npm:^15.6.1": +"@types/node@npm:>=13.7.0": version: 15.6.1 resolution: "@types/node@npm:15.6.1" checksum: 07b3855bc0a1ba2215455a3ef4ed5e88711321b3cdc0ba1ea0286f6facbdf61530970b9fa7eec79eb1d46231f986c21ef3b7c1f1e0c365cf1b887d76b0addb86 @@ -112,6 +99,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^15.6.2": + version: 15.6.2 + resolution: "@types/node@npm:15.6.2" + checksum: e65d6d4750c8bff0d7ecaba1b552118f17b163f3dae8007f6112c54bd591b7087b506c20bb03ce802dc895ef1c2565a750c5246bddab6ffa7d308c2d5f301571 + languageName: node + linkType: hard + "@types/object-hash@npm:^1.3.0": version: 1.3.4 resolution: "@types/object-hash@npm:1.3.4" @@ -130,7 +124,13 @@ __metadata: version: 0.0.0-use.local resolution: "cosmjs-types@workspace:." dependencies: + "@types/long": ^4.0.1 + "@types/node": ^15.6.2 + long: ^4.0.0 + prettier: ^2.3.0 + protobufjs: ~6.10.2 ts-proto: ^1.81.1 + typescript: ~4.0 languageName: unknown linkType: soft