From 8ca4875e81fc7cdfffab513bb410ca7cff09db78 Mon Sep 17 00:00:00 2001 From: swelf Date: Fri, 18 Oct 2024 04:15:36 +0300 Subject: [PATCH 1/2] added interchain security, ibcratelimit. updated dex --- .gitignore | 1 + .gitmodules | 3 + protos/interchain-security-src | 1 + protos/neutron-src | 2 +- scripts/clean.sh | 2 +- scripts/codegen.js | 1 + scripts/exports_protos.sh | 2 +- scripts/prepare-publishing.sh | 2 +- scripts/set-versions.sh | 3 + .../ccv/consumer/v1/consumer.ts | 184 ++ .../ccv/consumer/v1/genesis.ts | 603 ++++ .../ccv/consumer/v1/query.rpc.Query.ts | 84 + .../ccv/consumer/v1/query.ts | 624 +++++ .../ccv/consumer/v1/tx.rpc.msg.ts | 20 + src/interchain_security/ccv/consumer/v1/tx.ts | 108 + .../ccv/provider/v1/genesis.ts | 549 ++++ .../ccv/provider/v1/provider.ts | 2457 +++++++++++++++++ .../ccv/provider/v1/query.rpc.Query.ts | 396 +++ .../ccv/provider/v1/query.ts | 2166 +++++++++++++++ .../ccv/provider/v1/tx.rpc.msg.ts | 128 + src/interchain_security/ccv/provider/v1/tx.ts | 1749 ++++++++++++ .../ccv/v1/shared_consumer.ts | 459 +++ src/interchain_security/ccv/v1/wire.ts | 642 +++++ src/interchain_security/rpc.query.ts | 105 + src/interchain_security/rpc.tx.ts | 71 + src/neutron/dex/limit_order_tranche.ts | 14 + src/neutron/dex/pool_reserves.ts | 19 + src/neutron/dex/query.rpc.Query.ts | 106 +- src/neutron/dex/query.ts | 699 ++++- src/neutron/dex/tx.ts | 219 +- src/neutron/ibcratelimit/v1beta1/genesis.ts | 59 + src/neutron/ibcratelimit/v1beta1/params.ts | 55 + .../ibcratelimit/v1beta1/query.rpc.Query.ts | 34 + src/neutron/ibcratelimit/v1beta1/query.ts | 96 + .../ibcratelimit/v1beta1/tx.rpc.msg.ts | 20 + src/neutron/ibcratelimit/v1beta1/tx.ts | 121 + src/neutron/rpc.query.ts | 3 + src/neutron/rpc.tx.ts | 3 + 38 files changed, 11785 insertions(+), 25 deletions(-) create mode 160000 protos/interchain-security-src create mode 100644 src/interchain_security/ccv/consumer/v1/consumer.ts create mode 100644 src/interchain_security/ccv/consumer/v1/genesis.ts create mode 100644 src/interchain_security/ccv/consumer/v1/query.rpc.Query.ts create mode 100644 src/interchain_security/ccv/consumer/v1/query.ts create mode 100644 src/interchain_security/ccv/consumer/v1/tx.rpc.msg.ts create mode 100644 src/interchain_security/ccv/consumer/v1/tx.ts create mode 100644 src/interchain_security/ccv/provider/v1/genesis.ts create mode 100644 src/interchain_security/ccv/provider/v1/provider.ts create mode 100644 src/interchain_security/ccv/provider/v1/query.rpc.Query.ts create mode 100644 src/interchain_security/ccv/provider/v1/query.ts create mode 100644 src/interchain_security/ccv/provider/v1/tx.rpc.msg.ts create mode 100644 src/interchain_security/ccv/provider/v1/tx.ts create mode 100644 src/interchain_security/ccv/v1/shared_consumer.ts create mode 100644 src/interchain_security/ccv/v1/wire.ts create mode 100644 src/interchain_security/rpc.query.ts create mode 100644 src/interchain_security/rpc.tx.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/genesis.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/params.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/query.rpc.Query.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/query.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/tx.rpc.msg.ts create mode 100644 src/neutron/ibcratelimit/v1beta1/tx.ts diff --git a/.gitignore b/.gitignore index dc1a312..4ec5f74 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules/ /protos/neutron /protos/slinky /protos/wasmd +/protos/interchain-security /build/ /capability/ diff --git a/.gitmodules b/.gitmodules index 64cb390..37776be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "wasmd"] path = protos/wasmd-src url = git@github.com:neutron-org/wasmd.git +[submodule "interchain-security"] + path = protos/interchain-security-src + url = git@github.com:cosmos/interchain-security.git diff --git a/protos/interchain-security-src b/protos/interchain-security-src new file mode 160000 index 0000000..99d6fdf --- /dev/null +++ b/protos/interchain-security-src @@ -0,0 +1 @@ +Subproject commit 99d6fdf473fe87274d7ee33dedfa47df597e08be diff --git a/protos/neutron-src b/protos/neutron-src index a319222..813221c 160000 --- a/protos/neutron-src +++ b/protos/neutron-src @@ -1 +1 @@ -Subproject commit a319222034843a91c9d6500dc75f7b633debfa45 +Subproject commit 813221cc8d48237e17170558dbf41fb776809522 diff --git a/scripts/clean.sh b/scripts/clean.sh index 6461edf..6772589 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -36,6 +36,6 @@ done rm -rf ./build -for dir in admin-module block-sdk cosmos-sdk feemarket ibc-go neutron slinky wasmd ; do +for dir in admin-module block-sdk cosmos-sdk feemarket ibc-go neutron slinky wasmd; do rm -rf "protos/$dir" done diff --git a/scripts/codegen.js b/scripts/codegen.js index f3a9850..701fbc2 100755 --- a/scripts/codegen.js +++ b/scripts/codegen.js @@ -15,6 +15,7 @@ telescope({ "protos/neutron", "protos/slinky", "protos/wasmd", + "protos/interchain-security", ], outPath: outPath, options: { diff --git a/scripts/exports_protos.sh b/scripts/exports_protos.sh index 71f099e..c000792 100755 --- a/scripts/exports_protos.sh +++ b/scripts/exports_protos.sh @@ -11,7 +11,7 @@ for dir in admin-module cosmos-sdk ibc-go wasmd ; do buf export "protos/$dir-src/" --output "protos/$dir" done -for dir in block-sdk feemarket slinky ; do +for dir in block-sdk feemarket slinky interchain-security; do rm -rf "protos/$dir" mkdir -p "protos/$dir" echo "Autogenerated folder, see export_protos.sh" > "protos/$dir/README.md" diff --git a/scripts/prepare-publishing.sh b/scripts/prepare-publishing.sh index fbf42e4..f9a3abe 100755 --- a/scripts/prepare-publishing.sh +++ b/scripts/prepare-publishing.sh @@ -3,7 +3,7 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" -DIRS=(capability cosmos cosmos_proto cosmwasm feemarket gaia gogoproto google ibc neutron osmosis sdk slinky tendermint) +DIRS=(capability cosmos cosmos_proto cosmwasm feemarket gaia gogoproto google ibc neutron osmosis sdk slinky tendermint interchain-security) FILES=( binary.d.ts binary.js diff --git a/scripts/set-versions.sh b/scripts/set-versions.sh index fc33602..24e3ccc 100755 --- a/scripts/set-versions.sh +++ b/scripts/set-versions.sh @@ -11,6 +11,7 @@ readonly IBC_GO_DIR="ibc-go-src" readonly NEUTRON_DIR="neutron-src" readonly SLINKY_DIR="slinky-src" readonly WASMD_DIR="wasmd-src" +readonly ISC_DIR="interchain-security-src" readonly ADMIN_MODULE_REV="v2.0.2" readonly BLOCK_SDK_REV="v2.1.5" @@ -20,6 +21,7 @@ readonly IBC_GO_REV="v8.5.1" readonly NEUTRON_REV="main" readonly SLINKY_REV="v1.0.12" readonly WASMD_REV="v0.51.2-neutron" +readonly ISC_REV="v5.1.1" checkout_version () { git -C protos/$1 checkout $2 @@ -33,3 +35,4 @@ checkout_version $IBC_GO_DIR $IBC_GO_REV checkout_version $NEUTRON_DIR $NEUTRON_REV checkout_version $SLINKY_DIR $SLINKY_REV checkout_version $WASMD_DIR $WASMD_REV +checkout_version $ISC_DIR $ISC_REV diff --git a/src/interchain_security/ccv/consumer/v1/consumer.ts b/src/interchain_security/ccv/consumer/v1/consumer.ts new file mode 100644 index 0000000..f0fe701 --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/consumer.ts @@ -0,0 +1,184 @@ +/* eslint-disable */ +import { Any } from "../../../../google/protobuf/any"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { + isSet, + bytesFromBase64, + base64FromBytes, + DeepPartial, + Exact, + fromJsonTimestamp, + fromTimestamp, +} from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.consumer.v1"; +/** + * CrossChainValidator defines the type used to store validator information + * internal to the consumer CCV module. Note one cross chain validator entry is + * persisted for each consumer validator, where incoming VSC packets update this + * data, which is eventually forwarded to comet for consumer chain consensus. + * + * Note this type is only used internally to the consumer CCV module. + */ +export interface CrossChainValidator { + address: Uint8Array; + power: bigint; + /** pubkey is the consensus public key of the validator, as a Protobuf Any. */ + pubkey?: Any; + /** + * !!! DEPRECATED !!! opted_out is deprecated because after the introduction of Partial Set Security (PSS) + * we removed the soft opt-out feature. + */ + /** @deprecated */ + optedOut: boolean; +} +/** + * A record storing the state of a slash packet sent to the provider chain + * which may bounce back and forth until handled by the provider. + * + * Note this type is only used internally to the consumer CCV module. + */ +export interface SlashRecord { + waitingOnReply: boolean; + sendTime: Timestamp; +} +function createBaseCrossChainValidator(): CrossChainValidator { + return { + address: new Uint8Array(), + power: BigInt(0), + pubkey: undefined, + optedOut: false, + }; +} +export const CrossChainValidator = { + typeUrl: "/interchain_security.ccv.consumer.v1.CrossChainValidator", + encode(message: CrossChainValidator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.power !== BigInt(0)) { + writer.uint32(16).int64(message.power); + } + if (message.pubkey !== undefined) { + Any.encode(message.pubkey, writer.uint32(26).fork()).ldelim(); + } + if (message.optedOut === true) { + writer.uint32(32).bool(message.optedOut); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CrossChainValidator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCrossChainValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 2: + message.power = reader.int64(); + break; + case 3: + message.pubkey = Any.decode(reader, reader.uint32()); + break; + case 4: + message.optedOut = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CrossChainValidator { + const obj = createBaseCrossChainValidator(); + if (isSet(object.address)) obj.address = bytesFromBase64(object.address); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + if (isSet(object.pubkey)) obj.pubkey = Any.fromJSON(object.pubkey); + if (isSet(object.optedOut)) obj.optedOut = Boolean(object.optedOut); + return obj; + }, + toJSON(message: CrossChainValidator): JsonSafe { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.optedOut !== undefined && (obj.optedOut = message.optedOut); + return obj; + }, + fromPartial, I>>(object: I): CrossChainValidator { + const message = createBaseCrossChainValidator(); + message.address = object.address ?? new Uint8Array(); + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromPartial(object.pubkey); + } + message.optedOut = object.optedOut ?? false; + return message; + }, +}; +function createBaseSlashRecord(): SlashRecord { + return { + waitingOnReply: false, + sendTime: Timestamp.fromPartial({}), + }; +} +export const SlashRecord = { + typeUrl: "/interchain_security.ccv.consumer.v1.SlashRecord", + encode(message: SlashRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.waitingOnReply === true) { + writer.uint32(8).bool(message.waitingOnReply); + } + if (message.sendTime !== undefined) { + Timestamp.encode(message.sendTime, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SlashRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSlashRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.waitingOnReply = reader.bool(); + break; + case 2: + message.sendTime = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SlashRecord { + const obj = createBaseSlashRecord(); + if (isSet(object.waitingOnReply)) obj.waitingOnReply = Boolean(object.waitingOnReply); + if (isSet(object.sendTime)) obj.sendTime = fromJsonTimestamp(object.sendTime); + return obj; + }, + toJSON(message: SlashRecord): JsonSafe { + const obj: any = {}; + message.waitingOnReply !== undefined && (obj.waitingOnReply = message.waitingOnReply); + message.sendTime !== undefined && (obj.sendTime = fromTimestamp(message.sendTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): SlashRecord { + const message = createBaseSlashRecord(); + message.waitingOnReply = object.waitingOnReply ?? false; + if (object.sendTime !== undefined && object.sendTime !== null) { + message.sendTime = Timestamp.fromPartial(object.sendTime); + } + return message; + }, +}; diff --git a/src/interchain_security/ccv/consumer/v1/genesis.ts b/src/interchain_security/ccv/consumer/v1/genesis.ts new file mode 100644 index 0000000..01cb0ca --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/genesis.ts @@ -0,0 +1,603 @@ +/* eslint-disable */ +import { ConsumerParams, ProviderInfo } from "../../v1/shared_consumer"; +import { ClientState, ConsensusState } from "../../../../ibc/lightclients/tendermint/v1/tendermint"; +import { ValidatorUpdate } from "../../../../tendermint/abci/types"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { ConsumerPacketData } from "../../v1/wire"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { isSet, DeepPartial, Exact, fromJsonTimestamp, fromTimestamp } from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.consumer.v1"; +/** + * GenesisState defines the CCV consumer genesis state + * + * Note: this type is only used on consumer side and references shared types with + * provider + */ +export interface GenesisState { + /** ConsumerParams is a shared type with provider module */ + params: ConsumerParams; + /** Client ID of the provider. Empty for a new chain, filled in on restart. */ + providerClientId: string; + /** Channel ID of the provider. Empty for a new chain, filled in on restart. */ + providerChannelId: string; + /** true for new chain, false for chain restart. */ + newChain: boolean; + /** !!! DEPRECATED !!! ProviderClientState is deprecated. Use provider.client_state instead */ + /** @deprecated */ + providerClientState?: ClientState; + /** !!! DEPRECATED !!! ProviderConsensusState is deprecated. Use provider.consensus_state instead */ + /** @deprecated */ + providerConsensusState?: ConsensusState; + /** MaturingPackets nil on new chain, filled in on restart. */ + maturingPackets: MaturingVSCPacket[]; + /** !!! DEPRECATED !!!! InitialValset is deprecated. Use provider.initial_val_set instead */ + /** @deprecated */ + initialValSet: ValidatorUpdate[]; + /** HeightToValsetUpdateId nil on new chain, filled in on restart. */ + heightToValsetUpdateId: HeightToValsetUpdateID[]; + /** OutstandingDowntimes nil on new chain, filled in on restart. */ + outstandingDowntimeSlashing: OutstandingDowntime[]; + /** PendingConsumerPackets nil on new chain, filled in on restart. */ + pendingConsumerPackets: ConsumerPacketDataList; + /** LastTransmissionBlockHeight nil on new chain, filled in on restart. */ + lastTransmissionBlockHeight: LastTransmissionBlockHeight; + /** flag indicating whether the consumer CCV module starts in pre-CCV state */ + preCCV: boolean; + provider: ProviderInfo; +} +/** + * HeightValsetUpdateID represents a mapping internal to the consumer CCV module + * which links a block height to each recv valset update id. + */ +export interface HeightToValsetUpdateID { + height: bigint; + valsetUpdateId: bigint; +} +/** + * OutstandingDowntime defines the type used internally to the consumer CCV + * module and is used in order to not send multiple slashing requests for + * the same downtime infraction. + */ +export interface OutstandingDowntime { + validatorConsensusAddress: string; +} +/** + * LastTransmissionBlockHeight is the last time validator holding + * pools were transmitted to the provider chain. This type is used internally + * to the consumer CCV module. + */ +export interface LastTransmissionBlockHeight { + height: bigint; +} +/** + * MaturingVSCPacket represents a vsc packet that is maturing internal to the + * consumer CCV module, where the consumer has not yet relayed a VSCMatured + * packet back to the provider. + */ +export interface MaturingVSCPacket { + vscId: bigint; + maturityTime: Timestamp; +} +/** + * ConsumerPacketDataList is a list of consumer packet data packets. + * + * Note this type is used internally to the consumer CCV module + * for exporting / importing state in InitGenesis and ExportGenesis. + */ +export interface ConsumerPacketDataList { + list: ConsumerPacketData[]; +} +function createBaseGenesisState(): GenesisState { + return { + params: ConsumerParams.fromPartial({}), + providerClientId: "", + providerChannelId: "", + newChain: false, + providerClientState: undefined, + providerConsensusState: undefined, + maturingPackets: [], + initialValSet: [], + heightToValsetUpdateId: [], + outstandingDowntimeSlashing: [], + pendingConsumerPackets: ConsumerPacketDataList.fromPartial({}), + lastTransmissionBlockHeight: LastTransmissionBlockHeight.fromPartial({}), + preCCV: false, + provider: ProviderInfo.fromPartial({}), + }; +} +export const GenesisState = { + typeUrl: "/interchain_security.ccv.consumer.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + ConsumerParams.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.providerClientId !== "") { + writer.uint32(18).string(message.providerClientId); + } + if (message.providerChannelId !== "") { + writer.uint32(26).string(message.providerChannelId); + } + if (message.newChain === true) { + writer.uint32(32).bool(message.newChain); + } + if (message.providerClientState !== undefined) { + ClientState.encode(message.providerClientState, writer.uint32(42).fork()).ldelim(); + } + if (message.providerConsensusState !== undefined) { + ConsensusState.encode(message.providerConsensusState, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.maturingPackets) { + MaturingVSCPacket.encode(v!, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.initialValSet) { + ValidatorUpdate.encode(v!, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.heightToValsetUpdateId) { + HeightToValsetUpdateID.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.outstandingDowntimeSlashing) { + OutstandingDowntime.encode(v!, writer.uint32(82).fork()).ldelim(); + } + if (message.pendingConsumerPackets !== undefined) { + ConsumerPacketDataList.encode(message.pendingConsumerPackets, writer.uint32(90).fork()).ldelim(); + } + if (message.lastTransmissionBlockHeight !== undefined) { + LastTransmissionBlockHeight.encode( + message.lastTransmissionBlockHeight, + writer.uint32(98).fork(), + ).ldelim(); + } + if (message.preCCV === true) { + writer.uint32(104).bool(message.preCCV); + } + if (message.provider !== undefined) { + ProviderInfo.encode(message.provider, writer.uint32(114).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = ConsumerParams.decode(reader, reader.uint32()); + break; + case 2: + message.providerClientId = reader.string(); + break; + case 3: + message.providerChannelId = reader.string(); + break; + case 4: + message.newChain = reader.bool(); + break; + case 5: + message.providerClientState = ClientState.decode(reader, reader.uint32()); + break; + case 6: + message.providerConsensusState = ConsensusState.decode(reader, reader.uint32()); + break; + case 7: + message.maturingPackets.push(MaturingVSCPacket.decode(reader, reader.uint32())); + break; + case 8: + message.initialValSet.push(ValidatorUpdate.decode(reader, reader.uint32())); + break; + case 9: + message.heightToValsetUpdateId.push(HeightToValsetUpdateID.decode(reader, reader.uint32())); + break; + case 10: + message.outstandingDowntimeSlashing.push(OutstandingDowntime.decode(reader, reader.uint32())); + break; + case 11: + message.pendingConsumerPackets = ConsumerPacketDataList.decode(reader, reader.uint32()); + break; + case 12: + message.lastTransmissionBlockHeight = LastTransmissionBlockHeight.decode(reader, reader.uint32()); + break; + case 13: + message.preCCV = reader.bool(); + break; + case 14: + message.provider = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = ConsumerParams.fromJSON(object.params); + if (isSet(object.providerClientId)) obj.providerClientId = String(object.providerClientId); + if (isSet(object.providerChannelId)) obj.providerChannelId = String(object.providerChannelId); + if (isSet(object.newChain)) obj.newChain = Boolean(object.newChain); + if (isSet(object.providerClientState)) + obj.providerClientState = ClientState.fromJSON(object.providerClientState); + if (isSet(object.providerConsensusState)) + obj.providerConsensusState = ConsensusState.fromJSON(object.providerConsensusState); + if (Array.isArray(object?.maturingPackets)) + obj.maturingPackets = object.maturingPackets.map((e: any) => MaturingVSCPacket.fromJSON(e)); + if (Array.isArray(object?.initialValSet)) + obj.initialValSet = object.initialValSet.map((e: any) => ValidatorUpdate.fromJSON(e)); + if (Array.isArray(object?.heightToValsetUpdateId)) + obj.heightToValsetUpdateId = object.heightToValsetUpdateId.map((e: any) => + HeightToValsetUpdateID.fromJSON(e), + ); + if (Array.isArray(object?.outstandingDowntimeSlashing)) + obj.outstandingDowntimeSlashing = object.outstandingDowntimeSlashing.map((e: any) => + OutstandingDowntime.fromJSON(e), + ); + if (isSet(object.pendingConsumerPackets)) + obj.pendingConsumerPackets = ConsumerPacketDataList.fromJSON(object.pendingConsumerPackets); + if (isSet(object.lastTransmissionBlockHeight)) + obj.lastTransmissionBlockHeight = LastTransmissionBlockHeight.fromJSON( + object.lastTransmissionBlockHeight, + ); + if (isSet(object.preCCV)) obj.preCCV = Boolean(object.preCCV); + if (isSet(object.provider)) obj.provider = ProviderInfo.fromJSON(object.provider); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? ConsumerParams.toJSON(message.params) : undefined); + message.providerClientId !== undefined && (obj.providerClientId = message.providerClientId); + message.providerChannelId !== undefined && (obj.providerChannelId = message.providerChannelId); + message.newChain !== undefined && (obj.newChain = message.newChain); + message.providerClientState !== undefined && + (obj.providerClientState = message.providerClientState + ? ClientState.toJSON(message.providerClientState) + : undefined); + message.providerConsensusState !== undefined && + (obj.providerConsensusState = message.providerConsensusState + ? ConsensusState.toJSON(message.providerConsensusState) + : undefined); + if (message.maturingPackets) { + obj.maturingPackets = message.maturingPackets.map((e) => (e ? MaturingVSCPacket.toJSON(e) : undefined)); + } else { + obj.maturingPackets = []; + } + if (message.initialValSet) { + obj.initialValSet = message.initialValSet.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.initialValSet = []; + } + if (message.heightToValsetUpdateId) { + obj.heightToValsetUpdateId = message.heightToValsetUpdateId.map((e) => + e ? HeightToValsetUpdateID.toJSON(e) : undefined, + ); + } else { + obj.heightToValsetUpdateId = []; + } + if (message.outstandingDowntimeSlashing) { + obj.outstandingDowntimeSlashing = message.outstandingDowntimeSlashing.map((e) => + e ? OutstandingDowntime.toJSON(e) : undefined, + ); + } else { + obj.outstandingDowntimeSlashing = []; + } + message.pendingConsumerPackets !== undefined && + (obj.pendingConsumerPackets = message.pendingConsumerPackets + ? ConsumerPacketDataList.toJSON(message.pendingConsumerPackets) + : undefined); + message.lastTransmissionBlockHeight !== undefined && + (obj.lastTransmissionBlockHeight = message.lastTransmissionBlockHeight + ? LastTransmissionBlockHeight.toJSON(message.lastTransmissionBlockHeight) + : undefined); + message.preCCV !== undefined && (obj.preCCV = message.preCCV); + message.provider !== undefined && + (obj.provider = message.provider ? ProviderInfo.toJSON(message.provider) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = ConsumerParams.fromPartial(object.params); + } + message.providerClientId = object.providerClientId ?? ""; + message.providerChannelId = object.providerChannelId ?? ""; + message.newChain = object.newChain ?? false; + if (object.providerClientState !== undefined && object.providerClientState !== null) { + message.providerClientState = ClientState.fromPartial(object.providerClientState); + } + if (object.providerConsensusState !== undefined && object.providerConsensusState !== null) { + message.providerConsensusState = ConsensusState.fromPartial(object.providerConsensusState); + } + message.maturingPackets = object.maturingPackets?.map((e) => MaturingVSCPacket.fromPartial(e)) || []; + message.initialValSet = object.initialValSet?.map((e) => ValidatorUpdate.fromPartial(e)) || []; + message.heightToValsetUpdateId = + object.heightToValsetUpdateId?.map((e) => HeightToValsetUpdateID.fromPartial(e)) || []; + message.outstandingDowntimeSlashing = + object.outstandingDowntimeSlashing?.map((e) => OutstandingDowntime.fromPartial(e)) || []; + if (object.pendingConsumerPackets !== undefined && object.pendingConsumerPackets !== null) { + message.pendingConsumerPackets = ConsumerPacketDataList.fromPartial(object.pendingConsumerPackets); + } + if (object.lastTransmissionBlockHeight !== undefined && object.lastTransmissionBlockHeight !== null) { + message.lastTransmissionBlockHeight = LastTransmissionBlockHeight.fromPartial( + object.lastTransmissionBlockHeight, + ); + } + message.preCCV = object.preCCV ?? false; + if (object.provider !== undefined && object.provider !== null) { + message.provider = ProviderInfo.fromPartial(object.provider); + } + return message; + }, +}; +function createBaseHeightToValsetUpdateID(): HeightToValsetUpdateID { + return { + height: BigInt(0), + valsetUpdateId: BigInt(0), + }; +} +export const HeightToValsetUpdateID = { + typeUrl: "/interchain_security.ccv.consumer.v1.HeightToValsetUpdateID", + encode(message: HeightToValsetUpdateID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== BigInt(0)) { + writer.uint32(8).uint64(message.height); + } + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(16).uint64(message.valsetUpdateId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HeightToValsetUpdateID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHeightToValsetUpdateID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.uint64(); + break; + case 2: + message.valsetUpdateId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HeightToValsetUpdateID { + const obj = createBaseHeightToValsetUpdateID(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + return obj; + }, + toJSON(message: HeightToValsetUpdateID): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): HeightToValsetUpdateID { + const message = createBaseHeightToValsetUpdateID(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + return message; + }, +}; +function createBaseOutstandingDowntime(): OutstandingDowntime { + return { + validatorConsensusAddress: "", + }; +} +export const OutstandingDowntime = { + typeUrl: "/interchain_security.ccv.consumer.v1.OutstandingDowntime", + encode(message: OutstandingDowntime, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorConsensusAddress !== "") { + writer.uint32(10).string(message.validatorConsensusAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OutstandingDowntime { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutstandingDowntime(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorConsensusAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OutstandingDowntime { + const obj = createBaseOutstandingDowntime(); + if (isSet(object.validatorConsensusAddress)) + obj.validatorConsensusAddress = String(object.validatorConsensusAddress); + return obj; + }, + toJSON(message: OutstandingDowntime): JsonSafe { + const obj: any = {}; + message.validatorConsensusAddress !== undefined && + (obj.validatorConsensusAddress = message.validatorConsensusAddress); + return obj; + }, + fromPartial, I>>(object: I): OutstandingDowntime { + const message = createBaseOutstandingDowntime(); + message.validatorConsensusAddress = object.validatorConsensusAddress ?? ""; + return message; + }, +}; +function createBaseLastTransmissionBlockHeight(): LastTransmissionBlockHeight { + return { + height: BigInt(0), + }; +} +export const LastTransmissionBlockHeight = { + typeUrl: "/interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight", + encode(message: LastTransmissionBlockHeight, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== BigInt(0)) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LastTransmissionBlockHeight { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLastTransmissionBlockHeight(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LastTransmissionBlockHeight { + const obj = createBaseLastTransmissionBlockHeight(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: LastTransmissionBlockHeight): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>( + object: I, + ): LastTransmissionBlockHeight { + const message = createBaseLastTransmissionBlockHeight(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, +}; +function createBaseMaturingVSCPacket(): MaturingVSCPacket { + return { + vscId: BigInt(0), + maturityTime: Timestamp.fromPartial({}), + }; +} +export const MaturingVSCPacket = { + typeUrl: "/interchain_security.ccv.consumer.v1.MaturingVSCPacket", + encode(message: MaturingVSCPacket, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vscId !== BigInt(0)) { + writer.uint32(8).uint64(message.vscId); + } + if (message.maturityTime !== undefined) { + Timestamp.encode(message.maturityTime, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MaturingVSCPacket { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMaturingVSCPacket(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vscId = reader.uint64(); + break; + case 2: + message.maturityTime = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MaturingVSCPacket { + const obj = createBaseMaturingVSCPacket(); + if (isSet(object.vscId)) obj.vscId = BigInt(object.vscId.toString()); + if (isSet(object.maturityTime)) obj.maturityTime = fromJsonTimestamp(object.maturityTime); + return obj; + }, + toJSON(message: MaturingVSCPacket): JsonSafe { + const obj: any = {}; + message.vscId !== undefined && (obj.vscId = (message.vscId || BigInt(0)).toString()); + message.maturityTime !== undefined && + (obj.maturityTime = fromTimestamp(message.maturityTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): MaturingVSCPacket { + const message = createBaseMaturingVSCPacket(); + if (object.vscId !== undefined && object.vscId !== null) { + message.vscId = BigInt(object.vscId.toString()); + } + if (object.maturityTime !== undefined && object.maturityTime !== null) { + message.maturityTime = Timestamp.fromPartial(object.maturityTime); + } + return message; + }, +}; +function createBaseConsumerPacketDataList(): ConsumerPacketDataList { + return { + list: [], + }; +} +export const ConsumerPacketDataList = { + typeUrl: "/interchain_security.ccv.consumer.v1.ConsumerPacketDataList", + encode(message: ConsumerPacketDataList, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.list) { + ConsumerPacketData.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerPacketDataList { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerPacketDataList(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(ConsumerPacketData.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerPacketDataList { + const obj = createBaseConsumerPacketDataList(); + if (Array.isArray(object?.list)) obj.list = object.list.map((e: any) => ConsumerPacketData.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerPacketDataList): JsonSafe { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => (e ? ConsumerPacketData.toJSON(e) : undefined)); + } else { + obj.list = []; + } + return obj; + }, + fromPartial, I>>(object: I): ConsumerPacketDataList { + const message = createBaseConsumerPacketDataList(); + message.list = object.list?.map((e) => ConsumerPacketData.fromPartial(e)) || []; + return message; + }, +}; diff --git a/src/interchain_security/ccv/consumer/v1/query.rpc.Query.ts b/src/interchain_security/ccv/consumer/v1/query.rpc.Query.ts new file mode 100644 index 0000000..631e152 --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/query.rpc.Query.ts @@ -0,0 +1,84 @@ +/* eslint-disable */ +import { Rpc } from "../../../../helpers"; +import { BinaryReader } from "../../../../binary"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { + QueryNextFeeDistributionEstimateRequest, + QueryNextFeeDistributionEstimateResponse, + QueryParamsRequest, + QueryParamsResponse, + QueryProviderInfoRequest, + QueryProviderInfoResponse, + QueryThrottleStateRequest, + QueryThrottleStateResponse, +} from "./query"; +export interface Query { + /** + * ConsumerGenesis queries the genesis state needed to start a consumer chain + * whose proposal has been accepted + */ + queryNextFeeDistribution( + request?: QueryNextFeeDistributionEstimateRequest, + ): Promise; + /** QueryParams queries the ccv/consumer module parameters. */ + queryParams(request?: QueryParamsRequest): Promise; + queryProviderInfo(request?: QueryProviderInfoRequest): Promise; + /** QueryThrottleState returns on-chain state relevant to throttled consumer packets */ + queryThrottleState(request?: QueryThrottleStateRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.queryNextFeeDistribution = this.queryNextFeeDistribution.bind(this); + this.queryParams = this.queryParams.bind(this); + this.queryProviderInfo = this.queryProviderInfo.bind(this); + this.queryThrottleState = this.queryThrottleState.bind(this); + } + queryNextFeeDistribution( + request: QueryNextFeeDistributionEstimateRequest = {}, + ): Promise { + const data = QueryNextFeeDistributionEstimateRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.consumer.v1.Query", + "QueryNextFeeDistribution", + data, + ); + return promise.then((data) => QueryNextFeeDistributionEstimateResponse.decode(new BinaryReader(data))); + } + queryParams(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.consumer.v1.Query", "QueryParams", data); + return promise.then((data) => QueryParamsResponse.decode(new BinaryReader(data))); + } + queryProviderInfo(request: QueryProviderInfoRequest = {}): Promise { + const data = QueryProviderInfoRequest.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.consumer.v1.Query", "QueryProviderInfo", data); + return promise.then((data) => QueryProviderInfoResponse.decode(new BinaryReader(data))); + } + queryThrottleState(request: QueryThrottleStateRequest = {}): Promise { + const data = QueryThrottleStateRequest.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.consumer.v1.Query", "QueryThrottleState", data); + return promise.then((data) => QueryThrottleStateResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + queryNextFeeDistribution( + request?: QueryNextFeeDistributionEstimateRequest, + ): Promise { + return queryService.queryNextFeeDistribution(request); + }, + queryParams(request?: QueryParamsRequest): Promise { + return queryService.queryParams(request); + }, + queryProviderInfo(request?: QueryProviderInfoRequest): Promise { + return queryService.queryProviderInfo(request); + }, + queryThrottleState(request?: QueryThrottleStateRequest): Promise { + return queryService.queryThrottleState(request); + }, + }; +}; diff --git a/src/interchain_security/ccv/consumer/v1/query.ts b/src/interchain_security/ccv/consumer/v1/query.ts new file mode 100644 index 0000000..406f1e5 --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/query.ts @@ -0,0 +1,624 @@ +/* eslint-disable */ +import { ConsumerParams } from "../../v1/shared_consumer"; +import { SlashRecord } from "./consumer"; +import { ConsumerPacketData } from "../../v1/wire"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.consumer.v1"; +/** NextFeeDistributionEstimate holds information about next fee distribution */ +export interface NextFeeDistributionEstimate { + /** current block height at the time of querying */ + currentHeight: bigint; + /** block height at which last distribution took place */ + lastHeight: bigint; + /** block height at which next distribution will take place */ + nextHeight: bigint; + /** ratio between consumer and provider fee distribution */ + distributionFraction: string; + /** total accruead fees at the time of querying */ + total: string; + /** amount distributed to provider chain */ + toProvider: string; + /** amount distributed (kept) by consumer chain */ + toConsumer: string; +} +export interface QueryNextFeeDistributionEstimateRequest {} +export interface QueryNextFeeDistributionEstimateResponse { + data?: NextFeeDistributionEstimate; +} +export interface QueryParamsRequest {} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: ConsumerParams; +} +export interface QueryProviderInfoRequest {} +export interface QueryProviderInfoResponse { + consumer: ChainInfo; + provider: ChainInfo; +} +export interface QueryThrottleStateRequest {} +export interface QueryThrottleStateResponse { + slashRecord?: SlashRecord; + packetDataQueue: ConsumerPacketData[]; +} +export interface ChainInfo { + chainID: string; + clientID: string; + connectionID: string; + channelID: string; +} +function createBaseNextFeeDistributionEstimate(): NextFeeDistributionEstimate { + return { + currentHeight: BigInt(0), + lastHeight: BigInt(0), + nextHeight: BigInt(0), + distributionFraction: "", + total: "", + toProvider: "", + toConsumer: "", + }; +} +export const NextFeeDistributionEstimate = { + typeUrl: "/interchain_security.ccv.consumer.v1.NextFeeDistributionEstimate", + encode(message: NextFeeDistributionEstimate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.currentHeight !== BigInt(0)) { + writer.uint32(8).int64(message.currentHeight); + } + if (message.lastHeight !== BigInt(0)) { + writer.uint32(16).int64(message.lastHeight); + } + if (message.nextHeight !== BigInt(0)) { + writer.uint32(24).int64(message.nextHeight); + } + if (message.distributionFraction !== "") { + writer.uint32(34).string(message.distributionFraction); + } + if (message.total !== "") { + writer.uint32(42).string(message.total); + } + if (message.toProvider !== "") { + writer.uint32(50).string(message.toProvider); + } + if (message.toConsumer !== "") { + writer.uint32(58).string(message.toConsumer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): NextFeeDistributionEstimate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseNextFeeDistributionEstimate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.currentHeight = reader.int64(); + break; + case 2: + message.lastHeight = reader.int64(); + break; + case 3: + message.nextHeight = reader.int64(); + break; + case 4: + message.distributionFraction = reader.string(); + break; + case 5: + message.total = reader.string(); + break; + case 6: + message.toProvider = reader.string(); + break; + case 7: + message.toConsumer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): NextFeeDistributionEstimate { + const obj = createBaseNextFeeDistributionEstimate(); + if (isSet(object.currentHeight)) obj.currentHeight = BigInt(object.currentHeight.toString()); + if (isSet(object.lastHeight)) obj.lastHeight = BigInt(object.lastHeight.toString()); + if (isSet(object.nextHeight)) obj.nextHeight = BigInt(object.nextHeight.toString()); + if (isSet(object.distributionFraction)) obj.distributionFraction = String(object.distributionFraction); + if (isSet(object.total)) obj.total = String(object.total); + if (isSet(object.toProvider)) obj.toProvider = String(object.toProvider); + if (isSet(object.toConsumer)) obj.toConsumer = String(object.toConsumer); + return obj; + }, + toJSON(message: NextFeeDistributionEstimate): JsonSafe { + const obj: any = {}; + message.currentHeight !== undefined && + (obj.currentHeight = (message.currentHeight || BigInt(0)).toString()); + message.lastHeight !== undefined && (obj.lastHeight = (message.lastHeight || BigInt(0)).toString()); + message.nextHeight !== undefined && (obj.nextHeight = (message.nextHeight || BigInt(0)).toString()); + message.distributionFraction !== undefined && (obj.distributionFraction = message.distributionFraction); + message.total !== undefined && (obj.total = message.total); + message.toProvider !== undefined && (obj.toProvider = message.toProvider); + message.toConsumer !== undefined && (obj.toConsumer = message.toConsumer); + return obj; + }, + fromPartial, I>>( + object: I, + ): NextFeeDistributionEstimate { + const message = createBaseNextFeeDistributionEstimate(); + if (object.currentHeight !== undefined && object.currentHeight !== null) { + message.currentHeight = BigInt(object.currentHeight.toString()); + } + if (object.lastHeight !== undefined && object.lastHeight !== null) { + message.lastHeight = BigInt(object.lastHeight.toString()); + } + if (object.nextHeight !== undefined && object.nextHeight !== null) { + message.nextHeight = BigInt(object.nextHeight.toString()); + } + message.distributionFraction = object.distributionFraction ?? ""; + message.total = object.total ?? ""; + message.toProvider = object.toProvider ?? ""; + message.toConsumer = object.toConsumer ?? ""; + return message; + }, +}; +function createBaseQueryNextFeeDistributionEstimateRequest(): QueryNextFeeDistributionEstimateRequest { + return {}; +} +export const QueryNextFeeDistributionEstimateRequest = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryNextFeeDistributionEstimateRequest", + encode( + _: QueryNextFeeDistributionEstimateRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNextFeeDistributionEstimateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNextFeeDistributionEstimateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryNextFeeDistributionEstimateRequest { + const obj = createBaseQueryNextFeeDistributionEstimateRequest(); + return obj; + }, + toJSON(_: QueryNextFeeDistributionEstimateRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): QueryNextFeeDistributionEstimateRequest { + const message = createBaseQueryNextFeeDistributionEstimateRequest(); + return message; + }, +}; +function createBaseQueryNextFeeDistributionEstimateResponse(): QueryNextFeeDistributionEstimateResponse { + return { + data: undefined, + }; +} +export const QueryNextFeeDistributionEstimateResponse = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryNextFeeDistributionEstimateResponse", + encode( + message: QueryNextFeeDistributionEstimateResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.data !== undefined) { + NextFeeDistributionEstimate.encode(message.data, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNextFeeDistributionEstimateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNextFeeDistributionEstimateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = NextFeeDistributionEstimate.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryNextFeeDistributionEstimateResponse { + const obj = createBaseQueryNextFeeDistributionEstimateResponse(); + if (isSet(object.data)) obj.data = NextFeeDistributionEstimate.fromJSON(object.data); + return obj; + }, + toJSON( + message: QueryNextFeeDistributionEstimateResponse, + ): JsonSafe { + const obj: any = {}; + message.data !== undefined && + (obj.data = message.data ? NextFeeDistributionEstimate.toJSON(message.data) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryNextFeeDistributionEstimateResponse { + const message = createBaseQueryNextFeeDistributionEstimateResponse(); + if (object.data !== undefined && object.data !== null) { + message.data = NextFeeDistributionEstimate.fromPartial(object.data); + } + return message; + }, +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: ConsumerParams.fromPartial({}), + }; +} +export const QueryParamsResponse = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + ConsumerParams.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = ConsumerParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = ConsumerParams.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? ConsumerParams.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = ConsumerParams.fromPartial(object.params); + } + return message; + }, +}; +function createBaseQueryProviderInfoRequest(): QueryProviderInfoRequest { + return {}; +} +export const QueryProviderInfoRequest = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryProviderInfoRequest", + encode(_: QueryProviderInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryProviderInfoRequest { + const obj = createBaseQueryProviderInfoRequest(); + return obj; + }, + toJSON(_: QueryProviderInfoRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryProviderInfoRequest { + const message = createBaseQueryProviderInfoRequest(); + return message; + }, +}; +function createBaseQueryProviderInfoResponse(): QueryProviderInfoResponse { + return { + consumer: ChainInfo.fromPartial({}), + provider: ChainInfo.fromPartial({}), + }; +} +export const QueryProviderInfoResponse = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryProviderInfoResponse", + encode(message: QueryProviderInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.consumer !== undefined) { + ChainInfo.encode(message.consumer, writer.uint32(10).fork()).ldelim(); + } + if (message.provider !== undefined) { + ChainInfo.encode(message.provider, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consumer = ChainInfo.decode(reader, reader.uint32()); + break; + case 2: + message.provider = ChainInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderInfoResponse { + const obj = createBaseQueryProviderInfoResponse(); + if (isSet(object.consumer)) obj.consumer = ChainInfo.fromJSON(object.consumer); + if (isSet(object.provider)) obj.provider = ChainInfo.fromJSON(object.provider); + return obj; + }, + toJSON(message: QueryProviderInfoResponse): JsonSafe { + const obj: any = {}; + message.consumer !== undefined && + (obj.consumer = message.consumer ? ChainInfo.toJSON(message.consumer) : undefined); + message.provider !== undefined && + (obj.provider = message.provider ? ChainInfo.toJSON(message.provider) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryProviderInfoResponse { + const message = createBaseQueryProviderInfoResponse(); + if (object.consumer !== undefined && object.consumer !== null) { + message.consumer = ChainInfo.fromPartial(object.consumer); + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = ChainInfo.fromPartial(object.provider); + } + return message; + }, +}; +function createBaseQueryThrottleStateRequest(): QueryThrottleStateRequest { + return {}; +} +export const QueryThrottleStateRequest = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryThrottleStateRequest", + encode(_: QueryThrottleStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryThrottleStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryThrottleStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryThrottleStateRequest { + const obj = createBaseQueryThrottleStateRequest(); + return obj; + }, + toJSON(_: QueryThrottleStateRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryThrottleStateRequest { + const message = createBaseQueryThrottleStateRequest(); + return message; + }, +}; +function createBaseQueryThrottleStateResponse(): QueryThrottleStateResponse { + return { + slashRecord: undefined, + packetDataQueue: [], + }; +} +export const QueryThrottleStateResponse = { + typeUrl: "/interchain_security.ccv.consumer.v1.QueryThrottleStateResponse", + encode(message: QueryThrottleStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.slashRecord !== undefined) { + SlashRecord.encode(message.slashRecord, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.packetDataQueue) { + ConsumerPacketData.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryThrottleStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryThrottleStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.slashRecord = SlashRecord.decode(reader, reader.uint32()); + break; + case 2: + message.packetDataQueue.push(ConsumerPacketData.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryThrottleStateResponse { + const obj = createBaseQueryThrottleStateResponse(); + if (isSet(object.slashRecord)) obj.slashRecord = SlashRecord.fromJSON(object.slashRecord); + if (Array.isArray(object?.packetDataQueue)) + obj.packetDataQueue = object.packetDataQueue.map((e: any) => ConsumerPacketData.fromJSON(e)); + return obj; + }, + toJSON(message: QueryThrottleStateResponse): JsonSafe { + const obj: any = {}; + message.slashRecord !== undefined && + (obj.slashRecord = message.slashRecord ? SlashRecord.toJSON(message.slashRecord) : undefined); + if (message.packetDataQueue) { + obj.packetDataQueue = message.packetDataQueue.map((e) => + e ? ConsumerPacketData.toJSON(e) : undefined, + ); + } else { + obj.packetDataQueue = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryThrottleStateResponse { + const message = createBaseQueryThrottleStateResponse(); + if (object.slashRecord !== undefined && object.slashRecord !== null) { + message.slashRecord = SlashRecord.fromPartial(object.slashRecord); + } + message.packetDataQueue = object.packetDataQueue?.map((e) => ConsumerPacketData.fromPartial(e)) || []; + return message; + }, +}; +function createBaseChainInfo(): ChainInfo { + return { + chainID: "", + clientID: "", + connectionID: "", + channelID: "", + }; +} +export const ChainInfo = { + typeUrl: "/interchain_security.ccv.consumer.v1.ChainInfo", + encode(message: ChainInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainID !== "") { + writer.uint32(10).string(message.chainID); + } + if (message.clientID !== "") { + writer.uint32(18).string(message.clientID); + } + if (message.connectionID !== "") { + writer.uint32(26).string(message.connectionID); + } + if (message.channelID !== "") { + writer.uint32(34).string(message.channelID); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ChainInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChainInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainID = reader.string(); + break; + case 2: + message.clientID = reader.string(); + break; + case 3: + message.connectionID = reader.string(); + break; + case 4: + message.channelID = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ChainInfo { + const obj = createBaseChainInfo(); + if (isSet(object.chainID)) obj.chainID = String(object.chainID); + if (isSet(object.clientID)) obj.clientID = String(object.clientID); + if (isSet(object.connectionID)) obj.connectionID = String(object.connectionID); + if (isSet(object.channelID)) obj.channelID = String(object.channelID); + return obj; + }, + toJSON(message: ChainInfo): JsonSafe { + const obj: any = {}; + message.chainID !== undefined && (obj.chainID = message.chainID); + message.clientID !== undefined && (obj.clientID = message.clientID); + message.connectionID !== undefined && (obj.connectionID = message.connectionID); + message.channelID !== undefined && (obj.channelID = message.channelID); + return obj; + }, + fromPartial, I>>(object: I): ChainInfo { + const message = createBaseChainInfo(); + message.chainID = object.chainID ?? ""; + message.clientID = object.clientID ?? ""; + message.connectionID = object.connectionID ?? ""; + message.channelID = object.channelID ?? ""; + return message; + }, +}; diff --git a/src/interchain_security/ccv/consumer/v1/tx.rpc.msg.ts b/src/interchain_security/ccv/consumer/v1/tx.rpc.msg.ts new file mode 100644 index 0000000..dce09fb --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/tx.rpc.msg.ts @@ -0,0 +1,20 @@ +/* eslint-disable */ +import { Rpc } from "../../../../helpers"; +import { BinaryReader } from "../../../../binary"; +import { MsgUpdateParams, MsgUpdateParamsResponse } from "./tx"; +/** Msg defines the Msg service. */ +export interface Msg { + updateParams(request: MsgUpdateParams): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.updateParams = this.updateParams.bind(this); + } + updateParams(request: MsgUpdateParams): Promise { + const data = MsgUpdateParams.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.consumer.v1.Msg", "UpdateParams", data); + return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); + } +} diff --git a/src/interchain_security/ccv/consumer/v1/tx.ts b/src/interchain_security/ccv/consumer/v1/tx.ts new file mode 100644 index 0000000..c86ad27 --- /dev/null +++ b/src/interchain_security/ccv/consumer/v1/tx.ts @@ -0,0 +1,108 @@ +/* eslint-disable */ +import { ConsumerParams } from "../../v1/shared_consumer"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.consumer.v1"; +/** MsgUpdateParams is the Msg/UpdateParams request type */ +export interface MsgUpdateParams { + /** signer is the address of the governance account. */ + authority: string; + /** params defines the x/provider parameters to update. */ + params: ConsumerParams; +} +export interface MsgUpdateParamsResponse {} +function createBaseMsgUpdateParams(): MsgUpdateParams { + return { + authority: "", + params: ConsumerParams.fromPartial({}), + }; +} +export const MsgUpdateParams = { + typeUrl: "/interchain_security.ccv.consumer.v1.MsgUpdateParams", + encode(message: MsgUpdateParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authority !== "") { + writer.uint32(10).string(message.authority); + } + if (message.params !== undefined) { + ConsumerParams.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + case 2: + message.params = ConsumerParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateParams { + const obj = createBaseMsgUpdateParams(); + if (isSet(object.authority)) obj.authority = String(object.authority); + if (isSet(object.params)) obj.params = ConsumerParams.fromJSON(object.params); + return obj; + }, + toJSON(message: MsgUpdateParams): JsonSafe { + const obj: any = {}; + message.authority !== undefined && (obj.authority = message.authority); + message.params !== undefined && + (obj.params = message.params ? ConsumerParams.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateParams { + const message = createBaseMsgUpdateParams(); + message.authority = object.authority ?? ""; + if (object.params !== undefined && object.params !== null) { + message.params = ConsumerParams.fromPartial(object.params); + } + return message; + }, +}; +function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse { + return {}; +} +export const MsgUpdateParamsResponse = { + typeUrl: "/interchain_security.ccv.consumer.v1.MsgUpdateParamsResponse", + encode(_: MsgUpdateParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateParamsResponse { + const obj = createBaseMsgUpdateParamsResponse(); + return obj; + }, + toJSON(_: MsgUpdateParamsResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateParamsResponse { + const message = createBaseMsgUpdateParamsResponse(); + return message; + }, +}; diff --git a/src/interchain_security/ccv/provider/v1/genesis.ts b/src/interchain_security/ccv/provider/v1/genesis.ts new file mode 100644 index 0000000..a3c3860 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/genesis.ts @@ -0,0 +1,549 @@ +/* eslint-disable */ +import { + UnbondingOp, + MaturedUnbondingOps, + ConsumerAdditionProposal, + ConsumerRemovalProposal, + Params, + ValidatorConsumerPubKey, + ValidatorByConsumerAddr, + ConsumerAddrsToPrune, + InitTimeoutTimestamp, + ExportedVscSendTimestamp, + VscUnbondingOps, +} from "./provider"; +import { ConsumerGenesisState } from "../../v1/shared_consumer"; +import { ValidatorSetChangePacketData } from "../../v1/wire"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.provider.v1"; +/** GenesisState defines the CCV provider chain genesis state */ +export interface GenesisState { + /** strictly positive and set to 1 (DefaultValsetUpdateID) for a new chain */ + valsetUpdateId: bigint; + /** empty for a new chain */ + consumerStates: ConsumerState[]; + /** empty for a new chain */ + unbondingOps: UnbondingOp[]; + /** empty for a new chain */ + matureUnbondingOps?: MaturedUnbondingOps; + /** empty for a new chain */ + valsetUpdateIdToHeight: ValsetUpdateIdToHeight[]; + /** empty for a new chain */ + consumerAdditionProposals: ConsumerAdditionProposal[]; + /** empty for a new chain */ + consumerRemovalProposals: ConsumerRemovalProposal[]; + params: Params; + /** empty for a new chain */ + validatorConsumerPubkeys: ValidatorConsumerPubKey[]; + /** empty for a new chain */ + validatorsByConsumerAddr: ValidatorByConsumerAddr[]; + /** empty for a new chain */ + consumerAddrsToPrune: ConsumerAddrsToPrune[]; + initTimeoutTimestamps: InitTimeoutTimestamp[]; + exportedVscSendTimestamps: ExportedVscSendTimestamp[]; +} +/** + * The provider CCV module's knowledge of consumer state. + * + * Note this type is only used internally to the provider CCV module. + */ +export interface ConsumerState { + /** ChainID defines the chain ID for the consumer chain */ + chainId: string; + /** ChannelID defines the IBC channel ID for the consumer chain */ + channelId: string; + /** ClientID defines the IBC client ID for the consumer chain */ + clientId: string; + /** InitalHeight defines the initial block height for the consumer chain */ + initialHeight: bigint; + /** ConsumerGenesis defines the initial consumer chain genesis states */ + consumerGenesis: ConsumerGenesisState; + pendingValsetChanges: ValidatorSetChangePacketData[]; + slashDowntimeAck: string[]; + unbondingOpsIndex: VscUnbondingOps[]; +} +/** + * ValsetUpdateIdToHeight defines the genesis information for the mapping + * of each valset update id to a block height + */ +export interface ValsetUpdateIdToHeight { + valsetUpdateId: bigint; + height: bigint; +} +function createBaseGenesisState(): GenesisState { + return { + valsetUpdateId: BigInt(0), + consumerStates: [], + unbondingOps: [], + matureUnbondingOps: undefined, + valsetUpdateIdToHeight: [], + consumerAdditionProposals: [], + consumerRemovalProposals: [], + params: Params.fromPartial({}), + validatorConsumerPubkeys: [], + validatorsByConsumerAddr: [], + consumerAddrsToPrune: [], + initTimeoutTimestamps: [], + exportedVscSendTimestamps: [], + }; +} +export const GenesisState = { + typeUrl: "/interchain_security.ccv.provider.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(8).uint64(message.valsetUpdateId); + } + for (const v of message.consumerStates) { + ConsumerState.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.unbondingOps) { + UnbondingOp.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.matureUnbondingOps !== undefined) { + MaturedUnbondingOps.encode(message.matureUnbondingOps, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.valsetUpdateIdToHeight) { + ValsetUpdateIdToHeight.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.consumerAdditionProposals) { + ConsumerAdditionProposal.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.consumerRemovalProposals) { + ConsumerRemovalProposal.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.validatorConsumerPubkeys) { + ValidatorConsumerPubKey.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.validatorsByConsumerAddr) { + ValidatorByConsumerAddr.encode(v!, writer.uint32(82).fork()).ldelim(); + } + for (const v of message.consumerAddrsToPrune) { + ConsumerAddrsToPrune.encode(v!, writer.uint32(90).fork()).ldelim(); + } + for (const v of message.initTimeoutTimestamps) { + InitTimeoutTimestamp.encode(v!, writer.uint32(98).fork()).ldelim(); + } + for (const v of message.exportedVscSendTimestamps) { + ExportedVscSendTimestamp.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.valsetUpdateId = reader.uint64(); + break; + case 2: + message.consumerStates.push(ConsumerState.decode(reader, reader.uint32())); + break; + case 3: + message.unbondingOps.push(UnbondingOp.decode(reader, reader.uint32())); + break; + case 4: + message.matureUnbondingOps = MaturedUnbondingOps.decode(reader, reader.uint32()); + break; + case 5: + message.valsetUpdateIdToHeight.push(ValsetUpdateIdToHeight.decode(reader, reader.uint32())); + break; + case 6: + message.consumerAdditionProposals.push(ConsumerAdditionProposal.decode(reader, reader.uint32())); + break; + case 7: + message.consumerRemovalProposals.push(ConsumerRemovalProposal.decode(reader, reader.uint32())); + break; + case 8: + message.params = Params.decode(reader, reader.uint32()); + break; + case 9: + message.validatorConsumerPubkeys.push(ValidatorConsumerPubKey.decode(reader, reader.uint32())); + break; + case 10: + message.validatorsByConsumerAddr.push(ValidatorByConsumerAddr.decode(reader, reader.uint32())); + break; + case 11: + message.consumerAddrsToPrune.push(ConsumerAddrsToPrune.decode(reader, reader.uint32())); + break; + case 12: + message.initTimeoutTimestamps.push(InitTimeoutTimestamp.decode(reader, reader.uint32())); + break; + case 13: + message.exportedVscSendTimestamps.push(ExportedVscSendTimestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + if (Array.isArray(object?.consumerStates)) + obj.consumerStates = object.consumerStates.map((e: any) => ConsumerState.fromJSON(e)); + if (Array.isArray(object?.unbondingOps)) + obj.unbondingOps = object.unbondingOps.map((e: any) => UnbondingOp.fromJSON(e)); + if (isSet(object.matureUnbondingOps)) + obj.matureUnbondingOps = MaturedUnbondingOps.fromJSON(object.matureUnbondingOps); + if (Array.isArray(object?.valsetUpdateIdToHeight)) + obj.valsetUpdateIdToHeight = object.valsetUpdateIdToHeight.map((e: any) => + ValsetUpdateIdToHeight.fromJSON(e), + ); + if (Array.isArray(object?.consumerAdditionProposals)) + obj.consumerAdditionProposals = object.consumerAdditionProposals.map((e: any) => + ConsumerAdditionProposal.fromJSON(e), + ); + if (Array.isArray(object?.consumerRemovalProposals)) + obj.consumerRemovalProposals = object.consumerRemovalProposals.map((e: any) => + ConsumerRemovalProposal.fromJSON(e), + ); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.validatorConsumerPubkeys)) + obj.validatorConsumerPubkeys = object.validatorConsumerPubkeys.map((e: any) => + ValidatorConsumerPubKey.fromJSON(e), + ); + if (Array.isArray(object?.validatorsByConsumerAddr)) + obj.validatorsByConsumerAddr = object.validatorsByConsumerAddr.map((e: any) => + ValidatorByConsumerAddr.fromJSON(e), + ); + if (Array.isArray(object?.consumerAddrsToPrune)) + obj.consumerAddrsToPrune = object.consumerAddrsToPrune.map((e: any) => + ConsumerAddrsToPrune.fromJSON(e), + ); + if (Array.isArray(object?.initTimeoutTimestamps)) + obj.initTimeoutTimestamps = object.initTimeoutTimestamps.map((e: any) => + InitTimeoutTimestamp.fromJSON(e), + ); + if (Array.isArray(object?.exportedVscSendTimestamps)) + obj.exportedVscSendTimestamps = object.exportedVscSendTimestamps.map((e: any) => + ExportedVscSendTimestamp.fromJSON(e), + ); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + if (message.consumerStates) { + obj.consumerStates = message.consumerStates.map((e) => (e ? ConsumerState.toJSON(e) : undefined)); + } else { + obj.consumerStates = []; + } + if (message.unbondingOps) { + obj.unbondingOps = message.unbondingOps.map((e) => (e ? UnbondingOp.toJSON(e) : undefined)); + } else { + obj.unbondingOps = []; + } + message.matureUnbondingOps !== undefined && + (obj.matureUnbondingOps = message.matureUnbondingOps + ? MaturedUnbondingOps.toJSON(message.matureUnbondingOps) + : undefined); + if (message.valsetUpdateIdToHeight) { + obj.valsetUpdateIdToHeight = message.valsetUpdateIdToHeight.map((e) => + e ? ValsetUpdateIdToHeight.toJSON(e) : undefined, + ); + } else { + obj.valsetUpdateIdToHeight = []; + } + if (message.consumerAdditionProposals) { + obj.consumerAdditionProposals = message.consumerAdditionProposals.map((e) => + e ? ConsumerAdditionProposal.toJSON(e) : undefined, + ); + } else { + obj.consumerAdditionProposals = []; + } + if (message.consumerRemovalProposals) { + obj.consumerRemovalProposals = message.consumerRemovalProposals.map((e) => + e ? ConsumerRemovalProposal.toJSON(e) : undefined, + ); + } else { + obj.consumerRemovalProposals = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.validatorConsumerPubkeys) { + obj.validatorConsumerPubkeys = message.validatorConsumerPubkeys.map((e) => + e ? ValidatorConsumerPubKey.toJSON(e) : undefined, + ); + } else { + obj.validatorConsumerPubkeys = []; + } + if (message.validatorsByConsumerAddr) { + obj.validatorsByConsumerAddr = message.validatorsByConsumerAddr.map((e) => + e ? ValidatorByConsumerAddr.toJSON(e) : undefined, + ); + } else { + obj.validatorsByConsumerAddr = []; + } + if (message.consumerAddrsToPrune) { + obj.consumerAddrsToPrune = message.consumerAddrsToPrune.map((e) => + e ? ConsumerAddrsToPrune.toJSON(e) : undefined, + ); + } else { + obj.consumerAddrsToPrune = []; + } + if (message.initTimeoutTimestamps) { + obj.initTimeoutTimestamps = message.initTimeoutTimestamps.map((e) => + e ? InitTimeoutTimestamp.toJSON(e) : undefined, + ); + } else { + obj.initTimeoutTimestamps = []; + } + if (message.exportedVscSendTimestamps) { + obj.exportedVscSendTimestamps = message.exportedVscSendTimestamps.map((e) => + e ? ExportedVscSendTimestamp.toJSON(e) : undefined, + ); + } else { + obj.exportedVscSendTimestamps = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + message.consumerStates = object.consumerStates?.map((e) => ConsumerState.fromPartial(e)) || []; + message.unbondingOps = object.unbondingOps?.map((e) => UnbondingOp.fromPartial(e)) || []; + if (object.matureUnbondingOps !== undefined && object.matureUnbondingOps !== null) { + message.matureUnbondingOps = MaturedUnbondingOps.fromPartial(object.matureUnbondingOps); + } + message.valsetUpdateIdToHeight = + object.valsetUpdateIdToHeight?.map((e) => ValsetUpdateIdToHeight.fromPartial(e)) || []; + message.consumerAdditionProposals = + object.consumerAdditionProposals?.map((e) => ConsumerAdditionProposal.fromPartial(e)) || []; + message.consumerRemovalProposals = + object.consumerRemovalProposals?.map((e) => ConsumerRemovalProposal.fromPartial(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.validatorConsumerPubkeys = + object.validatorConsumerPubkeys?.map((e) => ValidatorConsumerPubKey.fromPartial(e)) || []; + message.validatorsByConsumerAddr = + object.validatorsByConsumerAddr?.map((e) => ValidatorByConsumerAddr.fromPartial(e)) || []; + message.consumerAddrsToPrune = + object.consumerAddrsToPrune?.map((e) => ConsumerAddrsToPrune.fromPartial(e)) || []; + message.initTimeoutTimestamps = + object.initTimeoutTimestamps?.map((e) => InitTimeoutTimestamp.fromPartial(e)) || []; + message.exportedVscSendTimestamps = + object.exportedVscSendTimestamps?.map((e) => ExportedVscSendTimestamp.fromPartial(e)) || []; + return message; + }, +}; +function createBaseConsumerState(): ConsumerState { + return { + chainId: "", + channelId: "", + clientId: "", + initialHeight: BigInt(0), + consumerGenesis: ConsumerGenesisState.fromPartial({}), + pendingValsetChanges: [], + slashDowntimeAck: [], + unbondingOpsIndex: [], + }; +} +export const ConsumerState = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerState", + encode(message: ConsumerState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.clientId !== "") { + writer.uint32(26).string(message.clientId); + } + if (message.initialHeight !== BigInt(0)) { + writer.uint32(32).uint64(message.initialHeight); + } + if (message.consumerGenesis !== undefined) { + ConsumerGenesisState.encode(message.consumerGenesis, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.pendingValsetChanges) { + ValidatorSetChangePacketData.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.slashDowntimeAck) { + writer.uint32(58).string(v!); + } + for (const v of message.unbondingOpsIndex) { + VscUnbondingOps.encode(v!, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.clientId = reader.string(); + break; + case 4: + message.initialHeight = reader.uint64(); + break; + case 5: + message.consumerGenesis = ConsumerGenesisState.decode(reader, reader.uint32()); + break; + case 6: + message.pendingValsetChanges.push(ValidatorSetChangePacketData.decode(reader, reader.uint32())); + break; + case 7: + message.slashDowntimeAck.push(reader.string()); + break; + case 8: + message.unbondingOpsIndex.push(VscUnbondingOps.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerState { + const obj = createBaseConsumerState(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.channelId)) obj.channelId = String(object.channelId); + if (isSet(object.clientId)) obj.clientId = String(object.clientId); + if (isSet(object.initialHeight)) obj.initialHeight = BigInt(object.initialHeight.toString()); + if (isSet(object.consumerGenesis)) + obj.consumerGenesis = ConsumerGenesisState.fromJSON(object.consumerGenesis); + if (Array.isArray(object?.pendingValsetChanges)) + obj.pendingValsetChanges = object.pendingValsetChanges.map((e: any) => + ValidatorSetChangePacketData.fromJSON(e), + ); + if (Array.isArray(object?.slashDowntimeAck)) + obj.slashDowntimeAck = object.slashDowntimeAck.map((e: any) => String(e)); + if (Array.isArray(object?.unbondingOpsIndex)) + obj.unbondingOpsIndex = object.unbondingOpsIndex.map((e: any) => VscUnbondingOps.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerState): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.initialHeight !== undefined && + (obj.initialHeight = (message.initialHeight || BigInt(0)).toString()); + message.consumerGenesis !== undefined && + (obj.consumerGenesis = message.consumerGenesis + ? ConsumerGenesisState.toJSON(message.consumerGenesis) + : undefined); + if (message.pendingValsetChanges) { + obj.pendingValsetChanges = message.pendingValsetChanges.map((e) => + e ? ValidatorSetChangePacketData.toJSON(e) : undefined, + ); + } else { + obj.pendingValsetChanges = []; + } + if (message.slashDowntimeAck) { + obj.slashDowntimeAck = message.slashDowntimeAck.map((e) => e); + } else { + obj.slashDowntimeAck = []; + } + if (message.unbondingOpsIndex) { + obj.unbondingOpsIndex = message.unbondingOpsIndex.map((e) => + e ? VscUnbondingOps.toJSON(e) : undefined, + ); + } else { + obj.unbondingOpsIndex = []; + } + return obj; + }, + fromPartial, I>>(object: I): ConsumerState { + const message = createBaseConsumerState(); + message.chainId = object.chainId ?? ""; + message.channelId = object.channelId ?? ""; + message.clientId = object.clientId ?? ""; + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = BigInt(object.initialHeight.toString()); + } + if (object.consumerGenesis !== undefined && object.consumerGenesis !== null) { + message.consumerGenesis = ConsumerGenesisState.fromPartial(object.consumerGenesis); + } + message.pendingValsetChanges = + object.pendingValsetChanges?.map((e) => ValidatorSetChangePacketData.fromPartial(e)) || []; + message.slashDowntimeAck = object.slashDowntimeAck?.map((e) => e) || []; + message.unbondingOpsIndex = object.unbondingOpsIndex?.map((e) => VscUnbondingOps.fromPartial(e)) || []; + return message; + }, +}; +function createBaseValsetUpdateIdToHeight(): ValsetUpdateIdToHeight { + return { + valsetUpdateId: BigInt(0), + height: BigInt(0), + }; +} +export const ValsetUpdateIdToHeight = { + typeUrl: "/interchain_security.ccv.provider.v1.ValsetUpdateIdToHeight", + encode(message: ValsetUpdateIdToHeight, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(8).uint64(message.valsetUpdateId); + } + if (message.height !== BigInt(0)) { + writer.uint32(16).uint64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValsetUpdateIdToHeight { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValsetUpdateIdToHeight(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.valsetUpdateId = reader.uint64(); + break; + case 2: + message.height = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValsetUpdateIdToHeight { + const obj = createBaseValsetUpdateIdToHeight(); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: ValsetUpdateIdToHeight): JsonSafe { + const obj: any = {}; + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): ValsetUpdateIdToHeight { + const message = createBaseValsetUpdateIdToHeight(); + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, +}; diff --git a/src/interchain_security/ccv/provider/v1/provider.ts b/src/interchain_security/ccv/provider/v1/provider.ts new file mode 100644 index 0000000..5686227 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/provider.ts @@ -0,0 +1,2457 @@ +/* eslint-disable */ +import { Height } from "../../../../ibc/core/client/v1/client"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { Duration } from "../../../../google/protobuf/duration"; +import { Equivocation } from "../../../../cosmos/evidence/v1beta1/evidence"; +import { ClientState } from "../../../../ibc/lightclients/tendermint/v1/tendermint"; +import { Coin, DecCoin } from "../../../../cosmos/base/v1beta1/coin"; +import { ValidatorSetChangePacketData } from "../../v1/wire"; +import { PublicKey } from "../../../../tendermint/crypto/keys"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { + isSet, + bytesFromBase64, + fromJsonTimestamp, + base64FromBytes, + fromTimestamp, + DeepPartial, + Exact, +} from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.provider.v1"; +/** + * ConsumerAdditionProposal is a governance proposal on the provider chain to + * spawn a new consumer chain. If it passes, then all validators on the provider + * chain are expected to validate the consumer chain at spawn time or get + * slashed. It is recommended that spawn time occurs after the proposal end + * time. + * Use MsgConsumerAddition to submit this proposal type. + */ +export interface ConsumerAdditionProposal { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** + * the proposed chain-id of the new consumer chain, must be different from all + * other consumer chain ids of the executing provider chain. + */ + chainId: string; + /** + * the proposed initial height of new consumer chain. + * For a completely new chain, this will be {0,1}. However, it may be + * different if this is a chain that is converting to a consumer chain. + */ + initialHeight: Height; + /** + * The hash of the consumer chain genesis state without the consumer CCV + * module genesis params. It is used for off-chain confirmation of + * genesis.json validity by validators and other parties. + */ + genesisHash: Uint8Array; + /** + * The hash of the consumer chain binary that should be run by validators on + * chain initialization. It is used for off-chain confirmation of binary + * validity by validators and other parties. + */ + binaryHash: Uint8Array; + /** + * spawn time is the time on the provider chain at which the consumer chain + * genesis is finalized and all validators will be responsible for starting + * their consumer chain validator node. + */ + spawnTime: Timestamp; + /** + * Unbonding period for the consumer, + * which should be smaller than that of the provider in general. + */ + unbondingPeriod: Duration; + /** Sent CCV related IBC packets will timeout after this duration */ + ccvTimeoutPeriod: Duration; + /** Sent transfer related IBC packets will timeout after this duration */ + transferTimeoutPeriod: Duration; + /** + * The fraction of tokens allocated to the consumer redistribution address + * during distribution events. The fraction is a string representing a + * decimal number. For example "0.75" would represent 75%. + */ + consumerRedistributionFraction: string; + /** + * BlocksPerDistributionTransmission is the number of blocks between + * ibc-token-transfers from the consumer chain to the provider chain. On + * sending transmission event, `consumer_redistribution_fraction` of the + * accumulated tokens are sent to the consumer redistribution address. + */ + blocksPerDistributionTransmission: bigint; + /** + * The number of historical info entries to persist in store. + * This param is a part of the cosmos sdk staking module. In the case of + * a ccv enabled consumer chain, the ccv module acts as the staking module. + */ + historicalEntries: bigint; + /** + * The ID of a token transfer channel used for the Reward Distribution + * sub-protocol. If DistributionTransmissionChannel == "", a new transfer + * channel is created on top of the same connection as the CCV channel. + * Note that transfer_channel_id is the ID of the channel end on the consumer + * chain. it is most relevant for chains performing a sovereign to consumer + * changeover in order to maintain the existing ibc transfer channel + */ + distributionTransmissionChannel: string; + /** + * Corresponds to the percentage of validators that have to validate the chain under the Top N case. + * For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + * have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + * A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + */ + topN: number; + /** + * Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + * `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + * consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + * 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + * to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + */ + validatorsPowerCap: number; + /** + * Corresponds to the maximum number of validators that can validate a consumer chain. + * Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + */ + validatorSetCap: number; + /** + * Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + * the consumer chain. + */ + allowlist: string[]; + /** Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. */ + denylist: string[]; +} +/** + * ConsumerRemovalProposal is a governance proposal on the provider chain to + * remove (and stop) a consumer chain. If it passes, all the consumer chain's + * state is removed from the provider chain. The outstanding unbonding operation + * funds are released. + * Use MsgConsumerRemoval to submit this proposal type. + */ +export interface ConsumerRemovalProposal { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the chain-id of the consumer chain to be stopped */ + chainId: string; + /** + * the time on the provider chain at which all validators are responsible to + * stop their consumer chain validator node + */ + stopTime: Timestamp; +} +/** + * ConsumerModificationProposal is a governance proposal on the provider chain to modify parameters of a running + * consumer chain. If it passes, the consumer chain's state is updated to take into account the newest params. + */ +export interface ConsumerModificationProposal { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the chain-id of the consumer chain to be modified */ + chainId: string; + /** + * Corresponds to the percentage of validators that have to validate the chain under the Top N case. + * For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + * have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + * A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + */ + topN: number; + /** + * Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + * `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + * consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + * 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + * to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + */ + validatorsPowerCap: number; + /** + * Corresponds to the maximum number of validators that can validate a consumer chain. + * Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + */ + validatorSetCap: number; + /** + * Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + * the consumer chain. + */ + allowlist: string[]; + /** Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. */ + denylist: string[]; +} +/** + * EquivocationProposal is a governance proposal on the provider chain to + * punish a validator for equivocation on a consumer chain. + * + * This type is only used internally to the consumer CCV module. + * WARNING: This message is deprecated now that equivocations can be submitted + * and verified automatically on the provider. (see SubmitConsumerDoubleVoting in proto/interchain-security/ccv/provider/v1/tx.proto). + */ +/** @deprecated */ +export interface EquivocationProposal { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the list of equivocations that will be processed */ + equivocations: Equivocation[]; +} +/** + * ChangeRewardDenomsProposal is a governance proposal on the provider chain to + * mutate the set of denoms accepted by the provider as rewards. + * Use MsgChangeRewardDenoms to submit this proposal type. + */ +export interface ChangeRewardDenomsProposal { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the list of consumer reward denoms to add */ + denomsToAdd: string[]; + /** the list of consumer reward denoms to remove */ + denomsToRemove: string[]; +} +/** + * A persisted queue entry indicating that a slash packet data instance needs to + * be handled. This type belongs in the "global" queue, to coordinate slash + * packet handling times between consumers. + */ +export interface GlobalSlashEntry { + /** + * Block time that slash packet was received by provider chain. + * This field is used for store key iteration ordering. + */ + recvTime: Timestamp; + /** The consumer that sent a slash packet. */ + consumerChainId: string; + /** + * The IBC sequence number of the recv packet. + * This field is used in the store key to ensure uniqueness. + */ + ibcSeqNum: bigint; + /** + * The provider's consensus address of the validator being slashed. + * This field is used to obtain validator power in HandleThrottleQueues. + * + * This field is not used in the store key, but is persisted in value bytes, + * see QueueGlobalSlashEntry. + */ + providerValConsAddr: Uint8Array; +} +/** Params defines the parameters for CCV Provider module */ +export interface Params { + templateClient?: ClientState; + /** + * TrustingPeriodFraction is used to compute the consumer and provider IBC + * client's TrustingPeriod from the chain defined UnbondingPeriod + */ + trustingPeriodFraction: string; + /** Sent IBC packets will timeout after this duration */ + ccvTimeoutPeriod: Duration; + /** + * The channel initialization (IBC channel opening handshake) will timeout + * after this duration + */ + initTimeoutPeriod: Duration; + /** + * The VSC packets sent by the provider will timeout after this duration. + * Note that unlike ccv_timeout_period which is an IBC param, + * the vsc_timeout_period is a provider-side param that enables the provider + * to timeout VSC packets even when a consumer chain is not live. + */ + vscTimeoutPeriod: Duration; + /** The period for which the slash meter is replenished */ + slashMeterReplenishPeriod: Duration; + /** + * The fraction of total voting power that is replenished to the slash meter + * every replenish period. This param also serves as a maximum fraction of + * total voting power that the slash meter can hold. + */ + slashMeterReplenishFraction: string; + /** The fee required to be paid to add a reward denom */ + consumerRewardDenomRegistrationFee: Coin; + /** The number of blocks that comprise an epoch. */ + blocksPerEpoch: bigint; + /** The number of epochs a validator has to validate a consumer chain in order to start receiving rewards from that chain. */ + numberOfEpochsToStartReceivingRewards: bigint; +} +/** + * SlashAcks contains cons addresses of consumer chain validators + * successfully slashed on the provider chain. + */ +export interface SlashAcks { + addresses: string[]; +} +/** + * ConsumerAdditionProposals holds pending governance proposals on the provider + * chain to spawn a new chain. + */ +export interface ConsumerAdditionProposals { + /** proposals waiting for spawn_time to pass */ + pending: ConsumerAdditionProposal[]; +} +/** + * ConsumerRemovalProposals holds pending governance proposals on the provider + * chain to remove (and stop) a consumer chain. + */ +export interface ConsumerRemovalProposals { + /** proposals waiting for stop_time to pass */ + pending: ConsumerRemovalProposal[]; +} +/** AddressList contains a list of consensus addresses */ +export interface AddressList { + addresses: Uint8Array[]; +} +/** ChannelToChain is used to map a CCV channel ID to the consumer chainID */ +export interface ChannelToChain { + channelId: string; + chainId: string; +} +/** + * VscUnbondingOps contains the IDs of unbonding operations that are waiting for + * at least one VSCMaturedPacket with vscID from a consumer chain + */ +export interface VscUnbondingOps { + vscId: bigint; + unbondingOpIds: bigint[]; +} +/** + * UnbondingOp contains the ids of consumer chains that need to unbond before + * the unbonding operation with the given ID can unbond + */ +export interface UnbondingOp { + id: bigint; + /** consumer chains that are still unbonding */ + unbondingConsumerChains: string[]; +} +export interface InitTimeoutTimestamp { + chainId: string; + timestamp: bigint; +} +export interface VscSendTimestamp { + vscId: bigint; + timestamp: Timestamp; +} +/** ValidatorSetChangePackets is a pb list of ccv.ValidatorSetChangePacketData. */ +export interface ValidatorSetChangePackets { + list: ValidatorSetChangePacketData[]; +} +/** + * MaturedUnbondingOps defines a list of ids corresponding to ids of matured + * unbonding operations. + */ +export interface MaturedUnbondingOps { + ids: bigint[]; +} +/** ExportedVscSendTimestamps is VscSendTimestamp with chainID info for exporting to genesis */ +export interface ExportedVscSendTimestamp { + chainId: string; + vscSendTimestamps: VscSendTimestamp[]; +} +export interface KeyAssignmentReplacement { + providerAddr: Uint8Array; + prevCKey?: PublicKey; + power: bigint; +} +/** + * Used to serialize the ValidatorConsumerPubKey index from key assignment + * ValidatorConsumerPubKey: (chainID, providerAddr consAddr) -> consumerKey + * tmprotocrypto.PublicKey + */ +export interface ValidatorConsumerPubKey { + chainId: string; + providerAddr: Uint8Array; + consumerKey?: PublicKey; +} +/** + * Used to serialize the ValidatorConsumerAddr index from key assignment + * ValidatorByConsumerAddr: (chainID, consumerAddr consAddr) -> providerAddr + * consAddr + */ +export interface ValidatorByConsumerAddr { + chainId: string; + consumerAddr: Uint8Array; + providerAddr: Uint8Array; +} +/** + * Used to serialize the ConsumerAddrsToPrune index from key assignment + * ConsumerAddrsToPrune: (chainID, vscID uint64) -> consumerAddrs AddressList + */ +export interface ConsumerAddrsToPrune { + chainId: string; + vscId: bigint; + consumerAddrs?: AddressList; +} +/** + * ConsumerValidator is used to facilitate epoch-based transitions. It contains relevant info for + * a validator that is expected to validate on a consumer chain during an epoch. + */ +export interface ConsumerValidator { + /** validator's consensus address on the provider chain */ + providerConsAddr: Uint8Array; + /** voting power the validator has during this epoch */ + power: bigint; + /** public key the validator uses on the consumer chain during this epoch */ + consumerPublicKey?: PublicKey; + /** + * height the validator had when it FIRST became a consumer validator + * If a validator becomes a consumer validator at height `H` and is continuously a consumer validator for all the upcoming + * epochs, then the height of the validator SHOULD remain `H`. This height only resets to a different height if a validator + * stops being a consumer validator during an epoch and later becomes again a consumer validator. + */ + joinHeight: bigint; +} +/** + * ConsumerRewardsAllocation stores the rewards allocated by a consumer chain + * to the consumer rewards pool. It is used to allocate the tokens to the consumer + * opted-in validators and the community pool during BeginBlock. + */ +export interface ConsumerRewardsAllocation { + rewards: DecCoin[]; +} +function createBaseConsumerAdditionProposal(): ConsumerAdditionProposal { + return { + title: "", + description: "", + chainId: "", + initialHeight: Height.fromPartial({}), + genesisHash: new Uint8Array(), + binaryHash: new Uint8Array(), + spawnTime: Timestamp.fromPartial({}), + unbondingPeriod: Duration.fromPartial({}), + ccvTimeoutPeriod: Duration.fromPartial({}), + transferTimeoutPeriod: Duration.fromPartial({}), + consumerRedistributionFraction: "", + blocksPerDistributionTransmission: BigInt(0), + historicalEntries: BigInt(0), + distributionTransmissionChannel: "", + topN: 0, + validatorsPowerCap: 0, + validatorSetCap: 0, + allowlist: [], + denylist: [], + }; +} +export const ConsumerAdditionProposal = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal", + encode(message: ConsumerAdditionProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (message.initialHeight !== undefined) { + Height.encode(message.initialHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.genesisHash.length !== 0) { + writer.uint32(42).bytes(message.genesisHash); + } + if (message.binaryHash.length !== 0) { + writer.uint32(50).bytes(message.binaryHash); + } + if (message.spawnTime !== undefined) { + Timestamp.encode(message.spawnTime, writer.uint32(58).fork()).ldelim(); + } + if (message.unbondingPeriod !== undefined) { + Duration.encode(message.unbondingPeriod, writer.uint32(66).fork()).ldelim(); + } + if (message.ccvTimeoutPeriod !== undefined) { + Duration.encode(message.ccvTimeoutPeriod, writer.uint32(74).fork()).ldelim(); + } + if (message.transferTimeoutPeriod !== undefined) { + Duration.encode(message.transferTimeoutPeriod, writer.uint32(82).fork()).ldelim(); + } + if (message.consumerRedistributionFraction !== "") { + writer.uint32(90).string(message.consumerRedistributionFraction); + } + if (message.blocksPerDistributionTransmission !== BigInt(0)) { + writer.uint32(96).int64(message.blocksPerDistributionTransmission); + } + if (message.historicalEntries !== BigInt(0)) { + writer.uint32(104).int64(message.historicalEntries); + } + if (message.distributionTransmissionChannel !== "") { + writer.uint32(114).string(message.distributionTransmissionChannel); + } + if (message.topN !== 0) { + writer.uint32(120).uint32(message.topN); + } + if (message.validatorsPowerCap !== 0) { + writer.uint32(128).uint32(message.validatorsPowerCap); + } + if (message.validatorSetCap !== 0) { + writer.uint32(136).uint32(message.validatorSetCap); + } + for (const v of message.allowlist) { + writer.uint32(146).string(v!); + } + for (const v of message.denylist) { + writer.uint32(154).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerAdditionProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerAdditionProposal(); + 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.chainId = reader.string(); + break; + case 4: + message.initialHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.genesisHash = reader.bytes(); + break; + case 6: + message.binaryHash = reader.bytes(); + break; + case 7: + message.spawnTime = Timestamp.decode(reader, reader.uint32()); + break; + case 8: + message.unbondingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 9: + message.ccvTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 10: + message.transferTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 11: + message.consumerRedistributionFraction = reader.string(); + break; + case 12: + message.blocksPerDistributionTransmission = reader.int64(); + break; + case 13: + message.historicalEntries = reader.int64(); + break; + case 14: + message.distributionTransmissionChannel = reader.string(); + break; + case 15: + message.topN = reader.uint32(); + break; + case 16: + message.validatorsPowerCap = reader.uint32(); + break; + case 17: + message.validatorSetCap = reader.uint32(); + break; + case 18: + message.allowlist.push(reader.string()); + break; + case 19: + message.denylist.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerAdditionProposal { + const obj = createBaseConsumerAdditionProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.initialHeight)) obj.initialHeight = Height.fromJSON(object.initialHeight); + if (isSet(object.genesisHash)) obj.genesisHash = bytesFromBase64(object.genesisHash); + if (isSet(object.binaryHash)) obj.binaryHash = bytesFromBase64(object.binaryHash); + if (isSet(object.spawnTime)) obj.spawnTime = fromJsonTimestamp(object.spawnTime); + if (isSet(object.unbondingPeriod)) obj.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod); + if (isSet(object.ccvTimeoutPeriod)) obj.ccvTimeoutPeriod = Duration.fromJSON(object.ccvTimeoutPeriod); + if (isSet(object.transferTimeoutPeriod)) + obj.transferTimeoutPeriod = Duration.fromJSON(object.transferTimeoutPeriod); + if (isSet(object.consumerRedistributionFraction)) + obj.consumerRedistributionFraction = String(object.consumerRedistributionFraction); + if (isSet(object.blocksPerDistributionTransmission)) + obj.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + if (isSet(object.historicalEntries)) obj.historicalEntries = BigInt(object.historicalEntries.toString()); + if (isSet(object.distributionTransmissionChannel)) + obj.distributionTransmissionChannel = String(object.distributionTransmissionChannel); + if (isSet(object.topN)) obj.topN = Number(object.topN); + if (isSet(object.validatorsPowerCap)) obj.validatorsPowerCap = Number(object.validatorsPowerCap); + if (isSet(object.validatorSetCap)) obj.validatorSetCap = Number(object.validatorSetCap); + if (Array.isArray(object?.allowlist)) obj.allowlist = object.allowlist.map((e: any) => String(e)); + if (Array.isArray(object?.denylist)) obj.denylist = object.denylist.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ConsumerAdditionProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.initialHeight !== undefined && + (obj.initialHeight = message.initialHeight ? Height.toJSON(message.initialHeight) : undefined); + message.genesisHash !== undefined && + (obj.genesisHash = base64FromBytes( + message.genesisHash !== undefined ? message.genesisHash : new Uint8Array(), + )); + message.binaryHash !== undefined && + (obj.binaryHash = base64FromBytes( + message.binaryHash !== undefined ? message.binaryHash : new Uint8Array(), + )); + message.spawnTime !== undefined && (obj.spawnTime = fromTimestamp(message.spawnTime).toISOString()); + message.unbondingPeriod !== undefined && + (obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined); + message.ccvTimeoutPeriod !== undefined && + (obj.ccvTimeoutPeriod = message.ccvTimeoutPeriod + ? Duration.toJSON(message.ccvTimeoutPeriod) + : undefined); + message.transferTimeoutPeriod !== undefined && + (obj.transferTimeoutPeriod = message.transferTimeoutPeriod + ? Duration.toJSON(message.transferTimeoutPeriod) + : undefined); + message.consumerRedistributionFraction !== undefined && + (obj.consumerRedistributionFraction = message.consumerRedistributionFraction); + message.blocksPerDistributionTransmission !== undefined && + (obj.blocksPerDistributionTransmission = ( + message.blocksPerDistributionTransmission || BigInt(0) + ).toString()); + message.historicalEntries !== undefined && + (obj.historicalEntries = (message.historicalEntries || BigInt(0)).toString()); + message.distributionTransmissionChannel !== undefined && + (obj.distributionTransmissionChannel = message.distributionTransmissionChannel); + message.topN !== undefined && (obj.topN = Math.round(message.topN)); + message.validatorsPowerCap !== undefined && + (obj.validatorsPowerCap = Math.round(message.validatorsPowerCap)); + message.validatorSetCap !== undefined && (obj.validatorSetCap = Math.round(message.validatorSetCap)); + if (message.allowlist) { + obj.allowlist = message.allowlist.map((e) => e); + } else { + obj.allowlist = []; + } + if (message.denylist) { + obj.denylist = message.denylist.map((e) => e); + } else { + obj.denylist = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ConsumerAdditionProposal { + const message = createBaseConsumerAdditionProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.chainId = object.chainId ?? ""; + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = Height.fromPartial(object.initialHeight); + } + message.genesisHash = object.genesisHash ?? new Uint8Array(); + message.binaryHash = object.binaryHash ?? new Uint8Array(); + if (object.spawnTime !== undefined && object.spawnTime !== null) { + message.spawnTime = Timestamp.fromPartial(object.spawnTime); + } + if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) { + message.unbondingPeriod = Duration.fromPartial(object.unbondingPeriod); + } + if (object.ccvTimeoutPeriod !== undefined && object.ccvTimeoutPeriod !== null) { + message.ccvTimeoutPeriod = Duration.fromPartial(object.ccvTimeoutPeriod); + } + if (object.transferTimeoutPeriod !== undefined && object.transferTimeoutPeriod !== null) { + message.transferTimeoutPeriod = Duration.fromPartial(object.transferTimeoutPeriod); + } + message.consumerRedistributionFraction = object.consumerRedistributionFraction ?? ""; + if ( + object.blocksPerDistributionTransmission !== undefined && + object.blocksPerDistributionTransmission !== null + ) { + message.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + } + if (object.historicalEntries !== undefined && object.historicalEntries !== null) { + message.historicalEntries = BigInt(object.historicalEntries.toString()); + } + message.distributionTransmissionChannel = object.distributionTransmissionChannel ?? ""; + message.topN = object.topN ?? 0; + message.validatorsPowerCap = object.validatorsPowerCap ?? 0; + message.validatorSetCap = object.validatorSetCap ?? 0; + message.allowlist = object.allowlist?.map((e) => e) || []; + message.denylist = object.denylist?.map((e) => e) || []; + return message; + }, +}; +function createBaseConsumerRemovalProposal(): ConsumerRemovalProposal { + return { + title: "", + description: "", + chainId: "", + stopTime: Timestamp.fromPartial({}), + }; +} +export const ConsumerRemovalProposal = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerRemovalProposal", + encode(message: ConsumerRemovalProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (message.stopTime !== undefined) { + Timestamp.encode(message.stopTime, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerRemovalProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerRemovalProposal(); + 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.chainId = reader.string(); + break; + case 4: + message.stopTime = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerRemovalProposal { + const obj = createBaseConsumerRemovalProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.stopTime)) obj.stopTime = fromJsonTimestamp(object.stopTime); + return obj; + }, + toJSON(message: ConsumerRemovalProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.stopTime !== undefined && (obj.stopTime = fromTimestamp(message.stopTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): ConsumerRemovalProposal { + const message = createBaseConsumerRemovalProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.chainId = object.chainId ?? ""; + if (object.stopTime !== undefined && object.stopTime !== null) { + message.stopTime = Timestamp.fromPartial(object.stopTime); + } + return message; + }, +}; +function createBaseConsumerModificationProposal(): ConsumerModificationProposal { + return { + title: "", + description: "", + chainId: "", + topN: 0, + validatorsPowerCap: 0, + validatorSetCap: 0, + allowlist: [], + denylist: [], + }; +} +export const ConsumerModificationProposal = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerModificationProposal", + encode(message: ConsumerModificationProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (message.topN !== 0) { + writer.uint32(32).uint32(message.topN); + } + if (message.validatorsPowerCap !== 0) { + writer.uint32(40).uint32(message.validatorsPowerCap); + } + if (message.validatorSetCap !== 0) { + writer.uint32(48).uint32(message.validatorSetCap); + } + for (const v of message.allowlist) { + writer.uint32(58).string(v!); + } + for (const v of message.denylist) { + writer.uint32(66).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerModificationProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerModificationProposal(); + 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.chainId = reader.string(); + break; + case 4: + message.topN = reader.uint32(); + break; + case 5: + message.validatorsPowerCap = reader.uint32(); + break; + case 6: + message.validatorSetCap = reader.uint32(); + break; + case 7: + message.allowlist.push(reader.string()); + break; + case 8: + message.denylist.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerModificationProposal { + const obj = createBaseConsumerModificationProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.topN)) obj.topN = Number(object.topN); + if (isSet(object.validatorsPowerCap)) obj.validatorsPowerCap = Number(object.validatorsPowerCap); + if (isSet(object.validatorSetCap)) obj.validatorSetCap = Number(object.validatorSetCap); + if (Array.isArray(object?.allowlist)) obj.allowlist = object.allowlist.map((e: any) => String(e)); + if (Array.isArray(object?.denylist)) obj.denylist = object.denylist.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ConsumerModificationProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.topN !== undefined && (obj.topN = Math.round(message.topN)); + message.validatorsPowerCap !== undefined && + (obj.validatorsPowerCap = Math.round(message.validatorsPowerCap)); + message.validatorSetCap !== undefined && (obj.validatorSetCap = Math.round(message.validatorSetCap)); + if (message.allowlist) { + obj.allowlist = message.allowlist.map((e) => e); + } else { + obj.allowlist = []; + } + if (message.denylist) { + obj.denylist = message.denylist.map((e) => e); + } else { + obj.denylist = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ConsumerModificationProposal { + const message = createBaseConsumerModificationProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.chainId = object.chainId ?? ""; + message.topN = object.topN ?? 0; + message.validatorsPowerCap = object.validatorsPowerCap ?? 0; + message.validatorSetCap = object.validatorSetCap ?? 0; + message.allowlist = object.allowlist?.map((e) => e) || []; + message.denylist = object.denylist?.map((e) => e) || []; + return message; + }, +}; +function createBaseEquivocationProposal(): EquivocationProposal { + return { + title: "", + description: "", + equivocations: [], + }; +} +export const EquivocationProposal = { + typeUrl: "/interchain_security.ccv.provider.v1.EquivocationProposal", + encode(message: EquivocationProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + for (const v of message.equivocations) { + Equivocation.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EquivocationProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEquivocationProposal(); + 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.equivocations.push(Equivocation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EquivocationProposal { + const obj = createBaseEquivocationProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.equivocations)) + obj.equivocations = object.equivocations.map((e: any) => Equivocation.fromJSON(e)); + return obj; + }, + toJSON(message: EquivocationProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.equivocations) { + obj.equivocations = message.equivocations.map((e) => (e ? Equivocation.toJSON(e) : undefined)); + } else { + obj.equivocations = []; + } + return obj; + }, + fromPartial, I>>(object: I): EquivocationProposal { + const message = createBaseEquivocationProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.equivocations = object.equivocations?.map((e) => Equivocation.fromPartial(e)) || []; + return message; + }, +}; +function createBaseChangeRewardDenomsProposal(): ChangeRewardDenomsProposal { + return { + title: "", + description: "", + denomsToAdd: [], + denomsToRemove: [], + }; +} +export const ChangeRewardDenomsProposal = { + typeUrl: "/interchain_security.ccv.provider.v1.ChangeRewardDenomsProposal", + encode(message: ChangeRewardDenomsProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + for (const v of message.denomsToAdd) { + writer.uint32(26).string(v!); + } + for (const v of message.denomsToRemove) { + writer.uint32(34).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ChangeRewardDenomsProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChangeRewardDenomsProposal(); + 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.denomsToAdd.push(reader.string()); + break; + case 4: + message.denomsToRemove.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ChangeRewardDenomsProposal { + const obj = createBaseChangeRewardDenomsProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.denomsToAdd)) obj.denomsToAdd = object.denomsToAdd.map((e: any) => String(e)); + if (Array.isArray(object?.denomsToRemove)) + obj.denomsToRemove = object.denomsToRemove.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ChangeRewardDenomsProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.denomsToAdd) { + obj.denomsToAdd = message.denomsToAdd.map((e) => e); + } else { + obj.denomsToAdd = []; + } + if (message.denomsToRemove) { + obj.denomsToRemove = message.denomsToRemove.map((e) => e); + } else { + obj.denomsToRemove = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ChangeRewardDenomsProposal { + const message = createBaseChangeRewardDenomsProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.denomsToAdd = object.denomsToAdd?.map((e) => e) || []; + message.denomsToRemove = object.denomsToRemove?.map((e) => e) || []; + return message; + }, +}; +function createBaseGlobalSlashEntry(): GlobalSlashEntry { + return { + recvTime: Timestamp.fromPartial({}), + consumerChainId: "", + ibcSeqNum: BigInt(0), + providerValConsAddr: new Uint8Array(), + }; +} +export const GlobalSlashEntry = { + typeUrl: "/interchain_security.ccv.provider.v1.GlobalSlashEntry", + encode(message: GlobalSlashEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.recvTime !== undefined) { + Timestamp.encode(message.recvTime, writer.uint32(10).fork()).ldelim(); + } + if (message.consumerChainId !== "") { + writer.uint32(18).string(message.consumerChainId); + } + if (message.ibcSeqNum !== BigInt(0)) { + writer.uint32(24).uint64(message.ibcSeqNum); + } + if (message.providerValConsAddr.length !== 0) { + writer.uint32(34).bytes(message.providerValConsAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GlobalSlashEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGlobalSlashEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.recvTime = Timestamp.decode(reader, reader.uint32()); + break; + case 2: + message.consumerChainId = reader.string(); + break; + case 3: + message.ibcSeqNum = reader.uint64(); + break; + case 4: + message.providerValConsAddr = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GlobalSlashEntry { + const obj = createBaseGlobalSlashEntry(); + if (isSet(object.recvTime)) obj.recvTime = fromJsonTimestamp(object.recvTime); + if (isSet(object.consumerChainId)) obj.consumerChainId = String(object.consumerChainId); + if (isSet(object.ibcSeqNum)) obj.ibcSeqNum = BigInt(object.ibcSeqNum.toString()); + if (isSet(object.providerValConsAddr)) + obj.providerValConsAddr = bytesFromBase64(object.providerValConsAddr); + return obj; + }, + toJSON(message: GlobalSlashEntry): JsonSafe { + const obj: any = {}; + message.recvTime !== undefined && (obj.recvTime = fromTimestamp(message.recvTime).toISOString()); + message.consumerChainId !== undefined && (obj.consumerChainId = message.consumerChainId); + message.ibcSeqNum !== undefined && (obj.ibcSeqNum = (message.ibcSeqNum || BigInt(0)).toString()); + message.providerValConsAddr !== undefined && + (obj.providerValConsAddr = base64FromBytes( + message.providerValConsAddr !== undefined ? message.providerValConsAddr : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): GlobalSlashEntry { + const message = createBaseGlobalSlashEntry(); + if (object.recvTime !== undefined && object.recvTime !== null) { + message.recvTime = Timestamp.fromPartial(object.recvTime); + } + message.consumerChainId = object.consumerChainId ?? ""; + if (object.ibcSeqNum !== undefined && object.ibcSeqNum !== null) { + message.ibcSeqNum = BigInt(object.ibcSeqNum.toString()); + } + message.providerValConsAddr = object.providerValConsAddr ?? new Uint8Array(); + return message; + }, +}; +function createBaseParams(): Params { + return { + templateClient: undefined, + trustingPeriodFraction: "", + ccvTimeoutPeriod: Duration.fromPartial({}), + initTimeoutPeriod: Duration.fromPartial({}), + vscTimeoutPeriod: Duration.fromPartial({}), + slashMeterReplenishPeriod: Duration.fromPartial({}), + slashMeterReplenishFraction: "", + consumerRewardDenomRegistrationFee: Coin.fromPartial({}), + blocksPerEpoch: BigInt(0), + numberOfEpochsToStartReceivingRewards: BigInt(0), + }; +} +export const Params = { + typeUrl: "/interchain_security.ccv.provider.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.templateClient !== undefined) { + ClientState.encode(message.templateClient, writer.uint32(10).fork()).ldelim(); + } + if (message.trustingPeriodFraction !== "") { + writer.uint32(18).string(message.trustingPeriodFraction); + } + if (message.ccvTimeoutPeriod !== undefined) { + Duration.encode(message.ccvTimeoutPeriod, writer.uint32(26).fork()).ldelim(); + } + if (message.initTimeoutPeriod !== undefined) { + Duration.encode(message.initTimeoutPeriod, writer.uint32(34).fork()).ldelim(); + } + if (message.vscTimeoutPeriod !== undefined) { + Duration.encode(message.vscTimeoutPeriod, writer.uint32(42).fork()).ldelim(); + } + if (message.slashMeterReplenishPeriod !== undefined) { + Duration.encode(message.slashMeterReplenishPeriod, writer.uint32(50).fork()).ldelim(); + } + if (message.slashMeterReplenishFraction !== "") { + writer.uint32(58).string(message.slashMeterReplenishFraction); + } + if (message.consumerRewardDenomRegistrationFee !== undefined) { + Coin.encode(message.consumerRewardDenomRegistrationFee, writer.uint32(74).fork()).ldelim(); + } + if (message.blocksPerEpoch !== BigInt(0)) { + writer.uint32(80).int64(message.blocksPerEpoch); + } + if (message.numberOfEpochsToStartReceivingRewards !== BigInt(0)) { + writer.uint32(88).int64(message.numberOfEpochsToStartReceivingRewards); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.templateClient = ClientState.decode(reader, reader.uint32()); + break; + case 2: + message.trustingPeriodFraction = reader.string(); + break; + case 3: + message.ccvTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.initTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 5: + message.vscTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 6: + message.slashMeterReplenishPeriod = Duration.decode(reader, reader.uint32()); + break; + case 7: + message.slashMeterReplenishFraction = reader.string(); + break; + case 9: + message.consumerRewardDenomRegistrationFee = Coin.decode(reader, reader.uint32()); + break; + case 10: + message.blocksPerEpoch = reader.int64(); + break; + case 11: + message.numberOfEpochsToStartReceivingRewards = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.templateClient)) obj.templateClient = ClientState.fromJSON(object.templateClient); + if (isSet(object.trustingPeriodFraction)) + obj.trustingPeriodFraction = String(object.trustingPeriodFraction); + if (isSet(object.ccvTimeoutPeriod)) obj.ccvTimeoutPeriod = Duration.fromJSON(object.ccvTimeoutPeriod); + if (isSet(object.initTimeoutPeriod)) obj.initTimeoutPeriod = Duration.fromJSON(object.initTimeoutPeriod); + if (isSet(object.vscTimeoutPeriod)) obj.vscTimeoutPeriod = Duration.fromJSON(object.vscTimeoutPeriod); + if (isSet(object.slashMeterReplenishPeriod)) + obj.slashMeterReplenishPeriod = Duration.fromJSON(object.slashMeterReplenishPeriod); + if (isSet(object.slashMeterReplenishFraction)) + obj.slashMeterReplenishFraction = String(object.slashMeterReplenishFraction); + if (isSet(object.consumerRewardDenomRegistrationFee)) + obj.consumerRewardDenomRegistrationFee = Coin.fromJSON(object.consumerRewardDenomRegistrationFee); + if (isSet(object.blocksPerEpoch)) obj.blocksPerEpoch = BigInt(object.blocksPerEpoch.toString()); + if (isSet(object.numberOfEpochsToStartReceivingRewards)) + obj.numberOfEpochsToStartReceivingRewards = BigInt( + object.numberOfEpochsToStartReceivingRewards.toString(), + ); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.templateClient !== undefined && + (obj.templateClient = message.templateClient ? ClientState.toJSON(message.templateClient) : undefined); + message.trustingPeriodFraction !== undefined && + (obj.trustingPeriodFraction = message.trustingPeriodFraction); + message.ccvTimeoutPeriod !== undefined && + (obj.ccvTimeoutPeriod = message.ccvTimeoutPeriod + ? Duration.toJSON(message.ccvTimeoutPeriod) + : undefined); + message.initTimeoutPeriod !== undefined && + (obj.initTimeoutPeriod = message.initTimeoutPeriod + ? Duration.toJSON(message.initTimeoutPeriod) + : undefined); + message.vscTimeoutPeriod !== undefined && + (obj.vscTimeoutPeriod = message.vscTimeoutPeriod + ? Duration.toJSON(message.vscTimeoutPeriod) + : undefined); + message.slashMeterReplenishPeriod !== undefined && + (obj.slashMeterReplenishPeriod = message.slashMeterReplenishPeriod + ? Duration.toJSON(message.slashMeterReplenishPeriod) + : undefined); + message.slashMeterReplenishFraction !== undefined && + (obj.slashMeterReplenishFraction = message.slashMeterReplenishFraction); + message.consumerRewardDenomRegistrationFee !== undefined && + (obj.consumerRewardDenomRegistrationFee = message.consumerRewardDenomRegistrationFee + ? Coin.toJSON(message.consumerRewardDenomRegistrationFee) + : undefined); + message.blocksPerEpoch !== undefined && + (obj.blocksPerEpoch = (message.blocksPerEpoch || BigInt(0)).toString()); + message.numberOfEpochsToStartReceivingRewards !== undefined && + (obj.numberOfEpochsToStartReceivingRewards = ( + message.numberOfEpochsToStartReceivingRewards || BigInt(0) + ).toString()); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + if (object.templateClient !== undefined && object.templateClient !== null) { + message.templateClient = ClientState.fromPartial(object.templateClient); + } + message.trustingPeriodFraction = object.trustingPeriodFraction ?? ""; + if (object.ccvTimeoutPeriod !== undefined && object.ccvTimeoutPeriod !== null) { + message.ccvTimeoutPeriod = Duration.fromPartial(object.ccvTimeoutPeriod); + } + if (object.initTimeoutPeriod !== undefined && object.initTimeoutPeriod !== null) { + message.initTimeoutPeriod = Duration.fromPartial(object.initTimeoutPeriod); + } + if (object.vscTimeoutPeriod !== undefined && object.vscTimeoutPeriod !== null) { + message.vscTimeoutPeriod = Duration.fromPartial(object.vscTimeoutPeriod); + } + if (object.slashMeterReplenishPeriod !== undefined && object.slashMeterReplenishPeriod !== null) { + message.slashMeterReplenishPeriod = Duration.fromPartial(object.slashMeterReplenishPeriod); + } + message.slashMeterReplenishFraction = object.slashMeterReplenishFraction ?? ""; + if ( + object.consumerRewardDenomRegistrationFee !== undefined && + object.consumerRewardDenomRegistrationFee !== null + ) { + message.consumerRewardDenomRegistrationFee = Coin.fromPartial( + object.consumerRewardDenomRegistrationFee, + ); + } + if (object.blocksPerEpoch !== undefined && object.blocksPerEpoch !== null) { + message.blocksPerEpoch = BigInt(object.blocksPerEpoch.toString()); + } + if ( + object.numberOfEpochsToStartReceivingRewards !== undefined && + object.numberOfEpochsToStartReceivingRewards !== null + ) { + message.numberOfEpochsToStartReceivingRewards = BigInt( + object.numberOfEpochsToStartReceivingRewards.toString(), + ); + } + return message; + }, +}; +function createBaseSlashAcks(): SlashAcks { + return { + addresses: [], + }; +} +export const SlashAcks = { + typeUrl: "/interchain_security.ccv.provider.v1.SlashAcks", + encode(message: SlashAcks, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.addresses) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SlashAcks { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSlashAcks(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addresses.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SlashAcks { + const obj = createBaseSlashAcks(); + if (Array.isArray(object?.addresses)) obj.addresses = object.addresses.map((e: any) => String(e)); + return obj; + }, + toJSON(message: SlashAcks): JsonSafe { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map((e) => e); + } else { + obj.addresses = []; + } + return obj; + }, + fromPartial, I>>(object: I): SlashAcks { + const message = createBaseSlashAcks(); + message.addresses = object.addresses?.map((e) => e) || []; + return message; + }, +}; +function createBaseConsumerAdditionProposals(): ConsumerAdditionProposals { + return { + pending: [], + }; +} +export const ConsumerAdditionProposals = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerAdditionProposals", + encode(message: ConsumerAdditionProposals, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.pending) { + ConsumerAdditionProposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerAdditionProposals { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerAdditionProposals(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pending.push(ConsumerAdditionProposal.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerAdditionProposals { + const obj = createBaseConsumerAdditionProposals(); + if (Array.isArray(object?.pending)) + obj.pending = object.pending.map((e: any) => ConsumerAdditionProposal.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerAdditionProposals): JsonSafe { + const obj: any = {}; + if (message.pending) { + obj.pending = message.pending.map((e) => (e ? ConsumerAdditionProposal.toJSON(e) : undefined)); + } else { + obj.pending = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ConsumerAdditionProposals { + const message = createBaseConsumerAdditionProposals(); + message.pending = object.pending?.map((e) => ConsumerAdditionProposal.fromPartial(e)) || []; + return message; + }, +}; +function createBaseConsumerRemovalProposals(): ConsumerRemovalProposals { + return { + pending: [], + }; +} +export const ConsumerRemovalProposals = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerRemovalProposals", + encode(message: ConsumerRemovalProposals, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.pending) { + ConsumerRemovalProposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerRemovalProposals { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerRemovalProposals(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pending.push(ConsumerRemovalProposal.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerRemovalProposals { + const obj = createBaseConsumerRemovalProposals(); + if (Array.isArray(object?.pending)) + obj.pending = object.pending.map((e: any) => ConsumerRemovalProposal.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerRemovalProposals): JsonSafe { + const obj: any = {}; + if (message.pending) { + obj.pending = message.pending.map((e) => (e ? ConsumerRemovalProposal.toJSON(e) : undefined)); + } else { + obj.pending = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ConsumerRemovalProposals { + const message = createBaseConsumerRemovalProposals(); + message.pending = object.pending?.map((e) => ConsumerRemovalProposal.fromPartial(e)) || []; + return message; + }, +}; +function createBaseAddressList(): AddressList { + return { + addresses: [], + }; +} +export const AddressList = { + typeUrl: "/interchain_security.ccv.provider.v1.AddressList", + encode(message: AddressList, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.addresses) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AddressList { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAddressList(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addresses.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AddressList { + const obj = createBaseAddressList(); + if (Array.isArray(object?.addresses)) + obj.addresses = object.addresses.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: AddressList): JsonSafe { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.addresses = []; + } + return obj; + }, + fromPartial, I>>(object: I): AddressList { + const message = createBaseAddressList(); + message.addresses = object.addresses?.map((e) => e) || []; + return message; + }, +}; +function createBaseChannelToChain(): ChannelToChain { + return { + channelId: "", + chainId: "", + }; +} +export const ChannelToChain = { + typeUrl: "/interchain_security.ccv.provider.v1.ChannelToChain", + encode(message: ChannelToChain, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.channelId !== "") { + writer.uint32(10).string(message.channelId); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ChannelToChain { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChannelToChain(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channelId = reader.string(); + break; + case 2: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ChannelToChain { + const obj = createBaseChannelToChain(); + if (isSet(object.channelId)) obj.channelId = String(object.channelId); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON(message: ChannelToChain): JsonSafe { + const obj: any = {}; + message.channelId !== undefined && (obj.channelId = message.channelId); + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>(object: I): ChannelToChain { + const message = createBaseChannelToChain(); + message.channelId = object.channelId ?? ""; + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseVscUnbondingOps(): VscUnbondingOps { + return { + vscId: BigInt(0), + unbondingOpIds: [], + }; +} +export const VscUnbondingOps = { + typeUrl: "/interchain_security.ccv.provider.v1.VscUnbondingOps", + encode(message: VscUnbondingOps, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vscId !== BigInt(0)) { + writer.uint32(8).uint64(message.vscId); + } + writer.uint32(18).fork(); + for (const v of message.unbondingOpIds) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VscUnbondingOps { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVscUnbondingOps(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vscId = reader.uint64(); + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.unbondingOpIds.push(reader.uint64()); + } + } else { + message.unbondingOpIds.push(reader.uint64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VscUnbondingOps { + const obj = createBaseVscUnbondingOps(); + if (isSet(object.vscId)) obj.vscId = BigInt(object.vscId.toString()); + if (Array.isArray(object?.unbondingOpIds)) + obj.unbondingOpIds = object.unbondingOpIds.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: VscUnbondingOps): JsonSafe { + const obj: any = {}; + message.vscId !== undefined && (obj.vscId = (message.vscId || BigInt(0)).toString()); + if (message.unbondingOpIds) { + obj.unbondingOpIds = message.unbondingOpIds.map((e) => (e || BigInt(0)).toString()); + } else { + obj.unbondingOpIds = []; + } + return obj; + }, + fromPartial, I>>(object: I): VscUnbondingOps { + const message = createBaseVscUnbondingOps(); + if (object.vscId !== undefined && object.vscId !== null) { + message.vscId = BigInt(object.vscId.toString()); + } + message.unbondingOpIds = object.unbondingOpIds?.map((e) => BigInt(e.toString())) || []; + return message; + }, +}; +function createBaseUnbondingOp(): UnbondingOp { + return { + id: BigInt(0), + unbondingConsumerChains: [], + }; +} +export const UnbondingOp = { + typeUrl: "/interchain_security.ccv.provider.v1.UnbondingOp", + encode(message: UnbondingOp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== BigInt(0)) { + writer.uint32(8).uint64(message.id); + } + for (const v of message.unbondingConsumerChains) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnbondingOp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnbondingOp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64(); + break; + case 2: + message.unbondingConsumerChains.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnbondingOp { + const obj = createBaseUnbondingOp(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (Array.isArray(object?.unbondingConsumerChains)) + obj.unbondingConsumerChains = object.unbondingConsumerChains.map((e: any) => String(e)); + return obj; + }, + toJSON(message: UnbondingOp): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + if (message.unbondingConsumerChains) { + obj.unbondingConsumerChains = message.unbondingConsumerChains.map((e) => e); + } else { + obj.unbondingConsumerChains = []; + } + return obj; + }, + fromPartial, I>>(object: I): UnbondingOp { + const message = createBaseUnbondingOp(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.unbondingConsumerChains = object.unbondingConsumerChains?.map((e) => e) || []; + return message; + }, +}; +function createBaseInitTimeoutTimestamp(): InitTimeoutTimestamp { + return { + chainId: "", + timestamp: BigInt(0), + }; +} +export const InitTimeoutTimestamp = { + typeUrl: "/interchain_security.ccv.provider.v1.InitTimeoutTimestamp", + encode(message: InitTimeoutTimestamp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.timestamp !== BigInt(0)) { + writer.uint32(16).uint64(message.timestamp); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InitTimeoutTimestamp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInitTimeoutTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.timestamp = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InitTimeoutTimestamp { + const obj = createBaseInitTimeoutTimestamp(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.timestamp)) obj.timestamp = BigInt(object.timestamp.toString()); + return obj; + }, + toJSON(message: InitTimeoutTimestamp): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): InitTimeoutTimestamp { + const message = createBaseInitTimeoutTimestamp(); + message.chainId = object.chainId ?? ""; + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = BigInt(object.timestamp.toString()); + } + return message; + }, +}; +function createBaseVscSendTimestamp(): VscSendTimestamp { + return { + vscId: BigInt(0), + timestamp: Timestamp.fromPartial({}), + }; +} +export const VscSendTimestamp = { + typeUrl: "/interchain_security.ccv.provider.v1.VscSendTimestamp", + encode(message: VscSendTimestamp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vscId !== BigInt(0)) { + writer.uint32(8).uint64(message.vscId); + } + if (message.timestamp !== undefined) { + Timestamp.encode(message.timestamp, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VscSendTimestamp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVscSendTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vscId = reader.uint64(); + break; + case 2: + message.timestamp = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VscSendTimestamp { + const obj = createBaseVscSendTimestamp(); + if (isSet(object.vscId)) obj.vscId = BigInt(object.vscId.toString()); + if (isSet(object.timestamp)) obj.timestamp = fromJsonTimestamp(object.timestamp); + return obj; + }, + toJSON(message: VscSendTimestamp): JsonSafe { + const obj: any = {}; + message.vscId !== undefined && (obj.vscId = (message.vscId || BigInt(0)).toString()); + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): VscSendTimestamp { + const message = createBaseVscSendTimestamp(); + if (object.vscId !== undefined && object.vscId !== null) { + message.vscId = BigInt(object.vscId.toString()); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = Timestamp.fromPartial(object.timestamp); + } + return message; + }, +}; +function createBaseValidatorSetChangePackets(): ValidatorSetChangePackets { + return { + list: [], + }; +} +export const ValidatorSetChangePackets = { + typeUrl: "/interchain_security.ccv.provider.v1.ValidatorSetChangePackets", + encode(message: ValidatorSetChangePackets, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.list) { + ValidatorSetChangePacketData.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSetChangePackets { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSetChangePackets(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(ValidatorSetChangePacketData.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSetChangePackets { + const obj = createBaseValidatorSetChangePackets(); + if (Array.isArray(object?.list)) + obj.list = object.list.map((e: any) => ValidatorSetChangePacketData.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorSetChangePackets): JsonSafe { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => (e ? ValidatorSetChangePacketData.toJSON(e) : undefined)); + } else { + obj.list = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ValidatorSetChangePackets { + const message = createBaseValidatorSetChangePackets(); + message.list = object.list?.map((e) => ValidatorSetChangePacketData.fromPartial(e)) || []; + return message; + }, +}; +function createBaseMaturedUnbondingOps(): MaturedUnbondingOps { + return { + ids: [], + }; +} +export const MaturedUnbondingOps = { + typeUrl: "/interchain_security.ccv.provider.v1.MaturedUnbondingOps", + encode(message: MaturedUnbondingOps, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.ids) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MaturedUnbondingOps { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMaturedUnbondingOps(); + 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.ids.push(reader.uint64()); + } + } else { + message.ids.push(reader.uint64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MaturedUnbondingOps { + const obj = createBaseMaturedUnbondingOps(); + if (Array.isArray(object?.ids)) obj.ids = object.ids.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: MaturedUnbondingOps): JsonSafe { + const obj: any = {}; + if (message.ids) { + obj.ids = message.ids.map((e) => (e || BigInt(0)).toString()); + } else { + obj.ids = []; + } + return obj; + }, + fromPartial, I>>(object: I): MaturedUnbondingOps { + const message = createBaseMaturedUnbondingOps(); + message.ids = object.ids?.map((e) => BigInt(e.toString())) || []; + return message; + }, +}; +function createBaseExportedVscSendTimestamp(): ExportedVscSendTimestamp { + return { + chainId: "", + vscSendTimestamps: [], + }; +} +export const ExportedVscSendTimestamp = { + typeUrl: "/interchain_security.ccv.provider.v1.ExportedVscSendTimestamp", + encode(message: ExportedVscSendTimestamp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + for (const v of message.vscSendTimestamps) { + VscSendTimestamp.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExportedVscSendTimestamp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExportedVscSendTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.vscSendTimestamps.push(VscSendTimestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExportedVscSendTimestamp { + const obj = createBaseExportedVscSendTimestamp(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (Array.isArray(object?.vscSendTimestamps)) + obj.vscSendTimestamps = object.vscSendTimestamps.map((e: any) => VscSendTimestamp.fromJSON(e)); + return obj; + }, + toJSON(message: ExportedVscSendTimestamp): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + if (message.vscSendTimestamps) { + obj.vscSendTimestamps = message.vscSendTimestamps.map((e) => + e ? VscSendTimestamp.toJSON(e) : undefined, + ); + } else { + obj.vscSendTimestamps = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ExportedVscSendTimestamp { + const message = createBaseExportedVscSendTimestamp(); + message.chainId = object.chainId ?? ""; + message.vscSendTimestamps = object.vscSendTimestamps?.map((e) => VscSendTimestamp.fromPartial(e)) || []; + return message; + }, +}; +function createBaseKeyAssignmentReplacement(): KeyAssignmentReplacement { + return { + providerAddr: new Uint8Array(), + prevCKey: undefined, + power: BigInt(0), + }; +} +export const KeyAssignmentReplacement = { + typeUrl: "/interchain_security.ccv.provider.v1.KeyAssignmentReplacement", + encode(message: KeyAssignmentReplacement, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.providerAddr.length !== 0) { + writer.uint32(10).bytes(message.providerAddr); + } + if (message.prevCKey !== undefined) { + PublicKey.encode(message.prevCKey, writer.uint32(18).fork()).ldelim(); + } + if (message.power !== BigInt(0)) { + writer.uint32(24).int64(message.power); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): KeyAssignmentReplacement { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseKeyAssignmentReplacement(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddr = reader.bytes(); + break; + case 2: + message.prevCKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.power = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): KeyAssignmentReplacement { + const obj = createBaseKeyAssignmentReplacement(); + if (isSet(object.providerAddr)) obj.providerAddr = bytesFromBase64(object.providerAddr); + if (isSet(object.prevCKey)) obj.prevCKey = PublicKey.fromJSON(object.prevCKey); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + return obj; + }, + toJSON(message: KeyAssignmentReplacement): JsonSafe { + const obj: any = {}; + message.providerAddr !== undefined && + (obj.providerAddr = base64FromBytes( + message.providerAddr !== undefined ? message.providerAddr : new Uint8Array(), + )); + message.prevCKey !== undefined && + (obj.prevCKey = message.prevCKey ? PublicKey.toJSON(message.prevCKey) : undefined); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>( + object: I, + ): KeyAssignmentReplacement { + const message = createBaseKeyAssignmentReplacement(); + message.providerAddr = object.providerAddr ?? new Uint8Array(); + if (object.prevCKey !== undefined && object.prevCKey !== null) { + message.prevCKey = PublicKey.fromPartial(object.prevCKey); + } + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + return message; + }, +}; +function createBaseValidatorConsumerPubKey(): ValidatorConsumerPubKey { + return { + chainId: "", + providerAddr: new Uint8Array(), + consumerKey: undefined, + }; +} +export const ValidatorConsumerPubKey = { + typeUrl: "/interchain_security.ccv.provider.v1.ValidatorConsumerPubKey", + encode(message: ValidatorConsumerPubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddr.length !== 0) { + writer.uint32(18).bytes(message.providerAddr); + } + if (message.consumerKey !== undefined) { + PublicKey.encode(message.consumerKey, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorConsumerPubKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorConsumerPubKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddr = reader.bytes(); + break; + case 3: + message.consumerKey = PublicKey.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorConsumerPubKey { + const obj = createBaseValidatorConsumerPubKey(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddr)) obj.providerAddr = bytesFromBase64(object.providerAddr); + if (isSet(object.consumerKey)) obj.consumerKey = PublicKey.fromJSON(object.consumerKey); + return obj; + }, + toJSON(message: ValidatorConsumerPubKey): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddr !== undefined && + (obj.providerAddr = base64FromBytes( + message.providerAddr !== undefined ? message.providerAddr : new Uint8Array(), + )); + message.consumerKey !== undefined && + (obj.consumerKey = message.consumerKey ? PublicKey.toJSON(message.consumerKey) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ValidatorConsumerPubKey { + const message = createBaseValidatorConsumerPubKey(); + message.chainId = object.chainId ?? ""; + message.providerAddr = object.providerAddr ?? new Uint8Array(); + if (object.consumerKey !== undefined && object.consumerKey !== null) { + message.consumerKey = PublicKey.fromPartial(object.consumerKey); + } + return message; + }, +}; +function createBaseValidatorByConsumerAddr(): ValidatorByConsumerAddr { + return { + chainId: "", + consumerAddr: new Uint8Array(), + providerAddr: new Uint8Array(), + }; +} +export const ValidatorByConsumerAddr = { + typeUrl: "/interchain_security.ccv.provider.v1.ValidatorByConsumerAddr", + encode(message: ValidatorByConsumerAddr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.consumerAddr.length !== 0) { + writer.uint32(18).bytes(message.consumerAddr); + } + if (message.providerAddr.length !== 0) { + writer.uint32(26).bytes(message.providerAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorByConsumerAddr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorByConsumerAddr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.consumerAddr = reader.bytes(); + break; + case 3: + message.providerAddr = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorByConsumerAddr { + const obj = createBaseValidatorByConsumerAddr(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.consumerAddr)) obj.consumerAddr = bytesFromBase64(object.consumerAddr); + if (isSet(object.providerAddr)) obj.providerAddr = bytesFromBase64(object.providerAddr); + return obj; + }, + toJSON(message: ValidatorByConsumerAddr): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.consumerAddr !== undefined && + (obj.consumerAddr = base64FromBytes( + message.consumerAddr !== undefined ? message.consumerAddr : new Uint8Array(), + )); + message.providerAddr !== undefined && + (obj.providerAddr = base64FromBytes( + message.providerAddr !== undefined ? message.providerAddr : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): ValidatorByConsumerAddr { + const message = createBaseValidatorByConsumerAddr(); + message.chainId = object.chainId ?? ""; + message.consumerAddr = object.consumerAddr ?? new Uint8Array(); + message.providerAddr = object.providerAddr ?? new Uint8Array(); + return message; + }, +}; +function createBaseConsumerAddrsToPrune(): ConsumerAddrsToPrune { + return { + chainId: "", + vscId: BigInt(0), + consumerAddrs: undefined, + }; +} +export const ConsumerAddrsToPrune = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerAddrsToPrune", + encode(message: ConsumerAddrsToPrune, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.vscId !== BigInt(0)) { + writer.uint32(16).uint64(message.vscId); + } + if (message.consumerAddrs !== undefined) { + AddressList.encode(message.consumerAddrs, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerAddrsToPrune { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerAddrsToPrune(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.vscId = reader.uint64(); + break; + case 3: + message.consumerAddrs = AddressList.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerAddrsToPrune { + const obj = createBaseConsumerAddrsToPrune(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.vscId)) obj.vscId = BigInt(object.vscId.toString()); + if (isSet(object.consumerAddrs)) obj.consumerAddrs = AddressList.fromJSON(object.consumerAddrs); + return obj; + }, + toJSON(message: ConsumerAddrsToPrune): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.vscId !== undefined && (obj.vscId = (message.vscId || BigInt(0)).toString()); + message.consumerAddrs !== undefined && + (obj.consumerAddrs = message.consumerAddrs ? AddressList.toJSON(message.consumerAddrs) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConsumerAddrsToPrune { + const message = createBaseConsumerAddrsToPrune(); + message.chainId = object.chainId ?? ""; + if (object.vscId !== undefined && object.vscId !== null) { + message.vscId = BigInt(object.vscId.toString()); + } + if (object.consumerAddrs !== undefined && object.consumerAddrs !== null) { + message.consumerAddrs = AddressList.fromPartial(object.consumerAddrs); + } + return message; + }, +}; +function createBaseConsumerValidator(): ConsumerValidator { + return { + providerConsAddr: new Uint8Array(), + power: BigInt(0), + consumerPublicKey: undefined, + joinHeight: BigInt(0), + }; +} +export const ConsumerValidator = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerValidator", + encode(message: ConsumerValidator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.providerConsAddr.length !== 0) { + writer.uint32(10).bytes(message.providerConsAddr); + } + if (message.power !== BigInt(0)) { + writer.uint32(16).int64(message.power); + } + if (message.consumerPublicKey !== undefined) { + PublicKey.encode(message.consumerPublicKey, writer.uint32(26).fork()).ldelim(); + } + if (message.joinHeight !== BigInt(0)) { + writer.uint32(32).int64(message.joinHeight); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerValidator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerConsAddr = reader.bytes(); + break; + case 2: + message.power = reader.int64(); + break; + case 3: + message.consumerPublicKey = PublicKey.decode(reader, reader.uint32()); + break; + case 4: + message.joinHeight = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerValidator { + const obj = createBaseConsumerValidator(); + if (isSet(object.providerConsAddr)) obj.providerConsAddr = bytesFromBase64(object.providerConsAddr); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + if (isSet(object.consumerPublicKey)) obj.consumerPublicKey = PublicKey.fromJSON(object.consumerPublicKey); + if (isSet(object.joinHeight)) obj.joinHeight = BigInt(object.joinHeight.toString()); + return obj; + }, + toJSON(message: ConsumerValidator): JsonSafe { + const obj: any = {}; + message.providerConsAddr !== undefined && + (obj.providerConsAddr = base64FromBytes( + message.providerConsAddr !== undefined ? message.providerConsAddr : new Uint8Array(), + )); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + message.consumerPublicKey !== undefined && + (obj.consumerPublicKey = message.consumerPublicKey + ? PublicKey.toJSON(message.consumerPublicKey) + : undefined); + message.joinHeight !== undefined && (obj.joinHeight = (message.joinHeight || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): ConsumerValidator { + const message = createBaseConsumerValidator(); + message.providerConsAddr = object.providerConsAddr ?? new Uint8Array(); + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + if (object.consumerPublicKey !== undefined && object.consumerPublicKey !== null) { + message.consumerPublicKey = PublicKey.fromPartial(object.consumerPublicKey); + } + if (object.joinHeight !== undefined && object.joinHeight !== null) { + message.joinHeight = BigInt(object.joinHeight.toString()); + } + return message; + }, +}; +function createBaseConsumerRewardsAllocation(): ConsumerRewardsAllocation { + return { + rewards: [], + }; +} +export const ConsumerRewardsAllocation = { + typeUrl: "/interchain_security.ccv.provider.v1.ConsumerRewardsAllocation", + encode(message: ConsumerRewardsAllocation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerRewardsAllocation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerRewardsAllocation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerRewardsAllocation { + const obj = createBaseConsumerRewardsAllocation(); + if (Array.isArray(object?.rewards)) obj.rewards = object.rewards.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerRewardsAllocation): JsonSafe { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.rewards = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ConsumerRewardsAllocation { + const message = createBaseConsumerRewardsAllocation(); + message.rewards = object.rewards?.map((e) => DecCoin.fromPartial(e)) || []; + return message; + }, +}; diff --git a/src/interchain_security/ccv/provider/v1/query.rpc.Query.ts b/src/interchain_security/ccv/provider/v1/query.rpc.Query.ts new file mode 100644 index 0000000..aa64402 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/query.rpc.Query.ts @@ -0,0 +1,396 @@ +/* eslint-disable */ +import { Rpc } from "../../../../helpers"; +import { BinaryReader } from "../../../../binary"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { + QueryConsumerGenesisRequest, + QueryConsumerGenesisResponse, + QueryConsumerChainsRequest, + QueryConsumerChainsResponse, + QueryConsumerChainStartProposalsRequest, + QueryConsumerChainStartProposalsResponse, + QueryConsumerChainStopProposalsRequest, + QueryConsumerChainStopProposalsResponse, + QueryValidatorConsumerAddrRequest, + QueryValidatorConsumerAddrResponse, + QueryValidatorProviderAddrRequest, + QueryValidatorProviderAddrResponse, + QueryThrottleStateRequest, + QueryThrottleStateResponse, + QueryRegisteredConsumerRewardDenomsRequest, + QueryRegisteredConsumerRewardDenomsResponse, + QueryProposedChainIDsRequest, + QueryProposedChainIDsResponse, + QueryAllPairsValConAddrByConsumerChainIDRequest, + QueryAllPairsValConAddrByConsumerChainIDResponse, + QueryParamsRequest, + QueryParamsResponse, + QueryConsumerChainOptedInValidatorsRequest, + QueryConsumerChainOptedInValidatorsResponse, + QueryConsumerChainsValidatorHasToValidateRequest, + QueryConsumerChainsValidatorHasToValidateResponse, + QueryValidatorConsumerCommissionRateRequest, + QueryValidatorConsumerCommissionRateResponse, + QueryOldestUnconfirmedVscRequest, + QueryOldestUnconfirmedVscResponse, + QueryConsumerValidatorsRequest, + QueryConsumerValidatorsResponse, +} from "./query"; +export interface Query { + /** + * ConsumerGenesis queries the genesis state needed to start a consumer chain + * whose proposal has been accepted + */ + queryConsumerGenesis(request: QueryConsumerGenesisRequest): Promise; + /** + * ConsumerChains queries active consumer chains supported by the provider + * chain + */ + queryConsumerChains(request?: QueryConsumerChainsRequest): Promise; + /** QueryConsumerChainStarts queries consumer chain start proposals. */ + queryConsumerChainStarts( + request?: QueryConsumerChainStartProposalsRequest, + ): Promise; + /** QueryConsumerChainStops queries consumer chain stop proposals. */ + queryConsumerChainStops( + request?: QueryConsumerChainStopProposalsRequest, + ): Promise; + /** + * QueryValidatorConsumerAddr queries the address + * assigned by a validator for a consumer chain. + */ + queryValidatorConsumerAddr( + request: QueryValidatorConsumerAddrRequest, + ): Promise; + /** + * QueryProviderAddr returns the provider chain validator + * given a consumer chain validator address + */ + queryValidatorProviderAddr( + request: QueryValidatorProviderAddrRequest, + ): Promise; + /** + * QueryThrottleState returns the main on-chain state relevant to currently + * throttled slash packets + */ + queryThrottleState(request?: QueryThrottleStateRequest): Promise; + /** + * QueryRegisteredConsumerRewardDenoms returns a list of consumer reward + * denoms that are registered + */ + queryRegisteredConsumerRewardDenoms( + request?: QueryRegisteredConsumerRewardDenomsRequest, + ): Promise; + /** + * QueryProposedConsumerChainIDs returns the chain IDs of the proposed consumer chain addition proposals + * that are still in the voting period + */ + queryProposedConsumerChainIDs( + request?: QueryProposedChainIDsRequest, + ): Promise; + /** + * QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address + * between provider and consumer chain + */ + queryAllPairsValConAddrByConsumerChainID( + request: QueryAllPairsValConAddrByConsumerChainIDRequest, + ): Promise; + /** QueryParams returns all current values of provider parameters */ + queryParams(request?: QueryParamsRequest): Promise; + /** + * QueryConsumerChainOptedInValidators returns a list of validators consensus addresses + * that opted-in to the given consumer chain + */ + queryConsumerChainOptedInValidators( + request: QueryConsumerChainOptedInValidatorsRequest, + ): Promise; + /** + * QueryConsumerChainsValidatorHasToValidate returns a list of consumer chains + * that a given validator must validate + */ + queryConsumerChainsValidatorHasToValidate( + request: QueryConsumerChainsValidatorHasToValidateRequest, + ): Promise; + /** + * QueryValidatorConsumerCommissionRate returns the commission rate a given + * validator charges on a given consumer chain + */ + queryValidatorConsumerCommissionRate( + request: QueryValidatorConsumerCommissionRateRequest, + ): Promise; + /** QueryOldestUnconfirmedVsc returns the send timestamp of the oldest unconfirmed VSCPacket for a given chainID */ + queryOldestUnconfirmedVsc( + request: QueryOldestUnconfirmedVscRequest, + ): Promise; + /** + * QueryConsumerValidators returns the latest set consumer-validator set for a given chainID + * Note that this does not necessarily mean that the consumer chain is using this validator set at this exact moment + * because a VSCPacket could be delayed to be delivered on the consumer chain. + */ + queryConsumerValidators(request: QueryConsumerValidatorsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.queryConsumerGenesis = this.queryConsumerGenesis.bind(this); + this.queryConsumerChains = this.queryConsumerChains.bind(this); + this.queryConsumerChainStarts = this.queryConsumerChainStarts.bind(this); + this.queryConsumerChainStops = this.queryConsumerChainStops.bind(this); + this.queryValidatorConsumerAddr = this.queryValidatorConsumerAddr.bind(this); + this.queryValidatorProviderAddr = this.queryValidatorProviderAddr.bind(this); + this.queryThrottleState = this.queryThrottleState.bind(this); + this.queryRegisteredConsumerRewardDenoms = this.queryRegisteredConsumerRewardDenoms.bind(this); + this.queryProposedConsumerChainIDs = this.queryProposedConsumerChainIDs.bind(this); + this.queryAllPairsValConAddrByConsumerChainID = this.queryAllPairsValConAddrByConsumerChainID.bind(this); + this.queryParams = this.queryParams.bind(this); + this.queryConsumerChainOptedInValidators = this.queryConsumerChainOptedInValidators.bind(this); + this.queryConsumerChainsValidatorHasToValidate = + this.queryConsumerChainsValidatorHasToValidate.bind(this); + this.queryValidatorConsumerCommissionRate = this.queryValidatorConsumerCommissionRate.bind(this); + this.queryOldestUnconfirmedVsc = this.queryOldestUnconfirmedVsc.bind(this); + this.queryConsumerValidators = this.queryConsumerValidators.bind(this); + } + queryConsumerGenesis(request: QueryConsumerGenesisRequest): Promise { + const data = QueryConsumerGenesisRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerGenesis", + data, + ); + return promise.then((data) => QueryConsumerGenesisResponse.decode(new BinaryReader(data))); + } + queryConsumerChains(request: QueryConsumerChainsRequest = {}): Promise { + const data = QueryConsumerChainsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerChains", + data, + ); + return promise.then((data) => QueryConsumerChainsResponse.decode(new BinaryReader(data))); + } + queryConsumerChainStarts( + request: QueryConsumerChainStartProposalsRequest = {}, + ): Promise { + const data = QueryConsumerChainStartProposalsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerChainStarts", + data, + ); + return promise.then((data) => QueryConsumerChainStartProposalsResponse.decode(new BinaryReader(data))); + } + queryConsumerChainStops( + request: QueryConsumerChainStopProposalsRequest = {}, + ): Promise { + const data = QueryConsumerChainStopProposalsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerChainStops", + data, + ); + return promise.then((data) => QueryConsumerChainStopProposalsResponse.decode(new BinaryReader(data))); + } + queryValidatorConsumerAddr( + request: QueryValidatorConsumerAddrRequest, + ): Promise { + const data = QueryValidatorConsumerAddrRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryValidatorConsumerAddr", + data, + ); + return promise.then((data) => QueryValidatorConsumerAddrResponse.decode(new BinaryReader(data))); + } + queryValidatorProviderAddr( + request: QueryValidatorProviderAddrRequest, + ): Promise { + const data = QueryValidatorProviderAddrRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryValidatorProviderAddr", + data, + ); + return promise.then((data) => QueryValidatorProviderAddrResponse.decode(new BinaryReader(data))); + } + queryThrottleState(request: QueryThrottleStateRequest = {}): Promise { + const data = QueryThrottleStateRequest.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Query", "QueryThrottleState", data); + return promise.then((data) => QueryThrottleStateResponse.decode(new BinaryReader(data))); + } + queryRegisteredConsumerRewardDenoms( + request: QueryRegisteredConsumerRewardDenomsRequest = {}, + ): Promise { + const data = QueryRegisteredConsumerRewardDenomsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryRegisteredConsumerRewardDenoms", + data, + ); + return promise.then((data) => QueryRegisteredConsumerRewardDenomsResponse.decode(new BinaryReader(data))); + } + queryProposedConsumerChainIDs( + request: QueryProposedChainIDsRequest = {}, + ): Promise { + const data = QueryProposedChainIDsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryProposedConsumerChainIDs", + data, + ); + return promise.then((data) => QueryProposedChainIDsResponse.decode(new BinaryReader(data))); + } + queryAllPairsValConAddrByConsumerChainID( + request: QueryAllPairsValConAddrByConsumerChainIDRequest, + ): Promise { + const data = QueryAllPairsValConAddrByConsumerChainIDRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryAllPairsValConAddrByConsumerChainID", + data, + ); + return promise.then((data) => + QueryAllPairsValConAddrByConsumerChainIDResponse.decode(new BinaryReader(data)), + ); + } + queryParams(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Query", "QueryParams", data); + return promise.then((data) => QueryParamsResponse.decode(new BinaryReader(data))); + } + queryConsumerChainOptedInValidators( + request: QueryConsumerChainOptedInValidatorsRequest, + ): Promise { + const data = QueryConsumerChainOptedInValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerChainOptedInValidators", + data, + ); + return promise.then((data) => QueryConsumerChainOptedInValidatorsResponse.decode(new BinaryReader(data))); + } + queryConsumerChainsValidatorHasToValidate( + request: QueryConsumerChainsValidatorHasToValidateRequest, + ): Promise { + const data = QueryConsumerChainsValidatorHasToValidateRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerChainsValidatorHasToValidate", + data, + ); + return promise.then((data) => + QueryConsumerChainsValidatorHasToValidateResponse.decode(new BinaryReader(data)), + ); + } + queryValidatorConsumerCommissionRate( + request: QueryValidatorConsumerCommissionRateRequest, + ): Promise { + const data = QueryValidatorConsumerCommissionRateRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryValidatorConsumerCommissionRate", + data, + ); + return promise.then((data) => + QueryValidatorConsumerCommissionRateResponse.decode(new BinaryReader(data)), + ); + } + queryOldestUnconfirmedVsc( + request: QueryOldestUnconfirmedVscRequest, + ): Promise { + const data = QueryOldestUnconfirmedVscRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryOldestUnconfirmedVsc", + data, + ); + return promise.then((data) => QueryOldestUnconfirmedVscResponse.decode(new BinaryReader(data))); + } + queryConsumerValidators(request: QueryConsumerValidatorsRequest): Promise { + const data = QueryConsumerValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Query", + "QueryConsumerValidators", + data, + ); + return promise.then((data) => QueryConsumerValidatorsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + queryConsumerGenesis(request: QueryConsumerGenesisRequest): Promise { + return queryService.queryConsumerGenesis(request); + }, + queryConsumerChains(request?: QueryConsumerChainsRequest): Promise { + return queryService.queryConsumerChains(request); + }, + queryConsumerChainStarts( + request?: QueryConsumerChainStartProposalsRequest, + ): Promise { + return queryService.queryConsumerChainStarts(request); + }, + queryConsumerChainStops( + request?: QueryConsumerChainStopProposalsRequest, + ): Promise { + return queryService.queryConsumerChainStops(request); + }, + queryValidatorConsumerAddr( + request: QueryValidatorConsumerAddrRequest, + ): Promise { + return queryService.queryValidatorConsumerAddr(request); + }, + queryValidatorProviderAddr( + request: QueryValidatorProviderAddrRequest, + ): Promise { + return queryService.queryValidatorProviderAddr(request); + }, + queryThrottleState(request?: QueryThrottleStateRequest): Promise { + return queryService.queryThrottleState(request); + }, + queryRegisteredConsumerRewardDenoms( + request?: QueryRegisteredConsumerRewardDenomsRequest, + ): Promise { + return queryService.queryRegisteredConsumerRewardDenoms(request); + }, + queryProposedConsumerChainIDs( + request?: QueryProposedChainIDsRequest, + ): Promise { + return queryService.queryProposedConsumerChainIDs(request); + }, + queryAllPairsValConAddrByConsumerChainID( + request: QueryAllPairsValConAddrByConsumerChainIDRequest, + ): Promise { + return queryService.queryAllPairsValConAddrByConsumerChainID(request); + }, + queryParams(request?: QueryParamsRequest): Promise { + return queryService.queryParams(request); + }, + queryConsumerChainOptedInValidators( + request: QueryConsumerChainOptedInValidatorsRequest, + ): Promise { + return queryService.queryConsumerChainOptedInValidators(request); + }, + queryConsumerChainsValidatorHasToValidate( + request: QueryConsumerChainsValidatorHasToValidateRequest, + ): Promise { + return queryService.queryConsumerChainsValidatorHasToValidate(request); + }, + queryValidatorConsumerCommissionRate( + request: QueryValidatorConsumerCommissionRateRequest, + ): Promise { + return queryService.queryValidatorConsumerCommissionRate(request); + }, + queryOldestUnconfirmedVsc( + request: QueryOldestUnconfirmedVscRequest, + ): Promise { + return queryService.queryOldestUnconfirmedVsc(request); + }, + queryConsumerValidators( + request: QueryConsumerValidatorsRequest, + ): Promise { + return queryService.queryConsumerValidators(request); + }, + }; +}; diff --git a/src/interchain_security/ccv/provider/v1/query.ts b/src/interchain_security/ccv/provider/v1/query.ts new file mode 100644 index 0000000..d38bed8 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/query.ts @@ -0,0 +1,2166 @@ +/* eslint-disable */ +import { ConsumerGenesisState } from "../../v1/shared_consumer"; +import { ConsumerAdditionProposals, ConsumerRemovalProposals, Params, VscSendTimestamp } from "./provider"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { PublicKey } from "../../../../tendermint/crypto/keys"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { isSet, DeepPartial, Exact, fromJsonTimestamp, fromTimestamp } from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "interchain_security.ccv.provider.v1"; +export interface QueryConsumerGenesisRequest { + chainId: string; +} +export interface QueryConsumerGenesisResponse { + genesisState: ConsumerGenesisState; +} +export interface QueryConsumerChainsRequest {} +export interface QueryConsumerChainsResponse { + chains: Chain[]; +} +export interface QueryConsumerChainStartProposalsRequest {} +export interface QueryConsumerChainStartProposalsResponse { + proposals?: ConsumerAdditionProposals; +} +export interface QueryConsumerChainStopProposalsRequest {} +export interface QueryConsumerChainStopProposalsResponse { + proposals?: ConsumerRemovalProposals; +} +export interface Chain { + chainId: string; + clientId: string; + /** If chain with `chainID` is a Top-N chain, i.e., enforces at least one validator to validate chain `chainID` */ + topN: number; + /** + * If the chain is a Top-N chain, this is the minimum power required to be in the top N. + * Otherwise, this is -1. + */ + minPowerInTopN: bigint; + /** Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. */ + validatorsPowerCap: number; + /** + * Corresponds to the maximum number of validators that can validate a consumer chain. + * Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + */ + validatorSetCap: number; + /** + * Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + * the consumer chain. + */ + allowlist: string[]; + /** Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. */ + denylist: string[]; +} +export interface QueryValidatorConsumerAddrRequest { + /** The id of the consumer chain */ + chainId: string; + /** The consensus address of the validator on the provider chain */ + providerAddress: string; +} +export interface QueryValidatorConsumerAddrResponse { + /** The address of the validator on the consumer chain */ + consumerAddress: string; +} +export interface QueryValidatorProviderAddrRequest { + /** The id of the provider chain */ + chainId: string; + /** The consensus address of the validator on the consumer chain */ + consumerAddress: string; +} +export interface QueryValidatorProviderAddrResponse { + /** The address of the validator on the provider chain */ + providerAddress: string; +} +export interface QueryThrottleStateRequest {} +export interface QueryThrottleStateResponse { + /** current slash_meter state */ + slashMeter: bigint; + /** + * allowance of voting power units (int) that the slash meter is given per + * replenish period this also serves as the max value for the meter. + */ + slashMeterAllowance: bigint; + /** + * next time the slash meter could potentially be replenished, iff it's not + * full + */ + nextReplenishCandidate: Timestamp; +} +export interface QueryRegisteredConsumerRewardDenomsRequest {} +export interface QueryRegisteredConsumerRewardDenomsResponse { + denoms: string[]; +} +export interface QueryProposedChainIDsRequest {} +export interface QueryProposedChainIDsResponse { + proposedChains: ProposedChain[]; +} +export interface ProposedChain { + chainID: string; + proposalID: bigint; +} +export interface QueryAllPairsValConAddrByConsumerChainIDRequest { + /** The id of the consumer chain */ + chainId: string; +} +export interface QueryAllPairsValConAddrByConsumerChainIDResponse { + pairValConAddr: PairValConAddrProviderAndConsumer[]; +} +export interface PairValConAddrProviderAndConsumer { + /** The consensus address of the validator on the provider chain */ + providerAddress: string; + /** The consensus address of the validator on the consumer chain */ + consumerAddress: string; + consumerKey?: PublicKey; +} +export interface QueryParamsRequest {} +export interface QueryParamsResponse { + params: Params; +} +export interface QueryConsumerChainOptedInValidatorsRequest { + chainId: string; +} +export interface QueryConsumerChainOptedInValidatorsResponse { + /** The consensus addresses of the validators on the provider chain */ + validatorsProviderAddresses: string[]; +} +export interface QueryConsumerValidatorsRequest { + chainId: string; +} +export interface QueryConsumerValidatorsValidator { + /** The consensus address of the validator on the provider chain */ + providerAddress: string; + /** The consumer public key of the validator used on the consumer chain */ + consumerKey?: PublicKey; + /** The power of the validator used on the consumer chain */ + power: bigint; +} +export interface QueryConsumerValidatorsResponse { + validators: QueryConsumerValidatorsValidator[]; +} +export interface QueryConsumerChainsValidatorHasToValidateRequest { + /** The consensus address of the validator on the provider chain */ + providerAddress: string; +} +export interface QueryConsumerChainsValidatorHasToValidateResponse { + consumerChainIds: string[]; +} +export interface QueryValidatorConsumerCommissionRateRequest { + chainId: string; + /** The consensus address of the validator on the provider chain */ + providerAddress: string; +} +export interface QueryValidatorConsumerCommissionRateResponse { + /** The rate to charge delegators on the consumer chain, as a fraction */ + rate: string; +} +export interface QueryOldestUnconfirmedVscRequest { + chainId: string; +} +export interface QueryOldestUnconfirmedVscResponse { + vscSendTimestamp: VscSendTimestamp; +} +function createBaseQueryConsumerGenesisRequest(): QueryConsumerGenesisRequest { + return { + chainId: "", + }; +} +export const QueryConsumerGenesisRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerGenesisRequest", + encode(message: QueryConsumerGenesisRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerGenesisRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerGenesisRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerGenesisRequest { + const obj = createBaseQueryConsumerGenesisRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON(message: QueryConsumerGenesisRequest): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerGenesisRequest { + const message = createBaseQueryConsumerGenesisRequest(); + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseQueryConsumerGenesisResponse(): QueryConsumerGenesisResponse { + return { + genesisState: ConsumerGenesisState.fromPartial({}), + }; +} +export const QueryConsumerGenesisResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerGenesisResponse", + encode(message: QueryConsumerGenesisResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.genesisState !== undefined) { + ConsumerGenesisState.encode(message.genesisState, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerGenesisResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerGenesisResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.genesisState = ConsumerGenesisState.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerGenesisResponse { + const obj = createBaseQueryConsumerGenesisResponse(); + if (isSet(object.genesisState)) obj.genesisState = ConsumerGenesisState.fromJSON(object.genesisState); + return obj; + }, + toJSON(message: QueryConsumerGenesisResponse): JsonSafe { + const obj: any = {}; + message.genesisState !== undefined && + (obj.genesisState = message.genesisState + ? ConsumerGenesisState.toJSON(message.genesisState) + : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerGenesisResponse { + const message = createBaseQueryConsumerGenesisResponse(); + if (object.genesisState !== undefined && object.genesisState !== null) { + message.genesisState = ConsumerGenesisState.fromPartial(object.genesisState); + } + return message; + }, +}; +function createBaseQueryConsumerChainsRequest(): QueryConsumerChainsRequest { + return {}; +} +export const QueryConsumerChainsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainsRequest", + encode(_: QueryConsumerChainsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryConsumerChainsRequest { + const obj = createBaseQueryConsumerChainsRequest(); + return obj; + }, + toJSON(_: QueryConsumerChainsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryConsumerChainsRequest { + const message = createBaseQueryConsumerChainsRequest(); + return message; + }, +}; +function createBaseQueryConsumerChainsResponse(): QueryConsumerChainsResponse { + return { + chains: [], + }; +} +export const QueryConsumerChainsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainsResponse", + encode(message: QueryConsumerChainsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.chains) { + Chain.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chains.push(Chain.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainsResponse { + const obj = createBaseQueryConsumerChainsResponse(); + if (Array.isArray(object?.chains)) obj.chains = object.chains.map((e: any) => Chain.fromJSON(e)); + return obj; + }, + toJSON(message: QueryConsumerChainsResponse): JsonSafe { + const obj: any = {}; + if (message.chains) { + obj.chains = message.chains.map((e) => (e ? Chain.toJSON(e) : undefined)); + } else { + obj.chains = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainsResponse { + const message = createBaseQueryConsumerChainsResponse(); + message.chains = object.chains?.map((e) => Chain.fromPartial(e)) || []; + return message; + }, +}; +function createBaseQueryConsumerChainStartProposalsRequest(): QueryConsumerChainStartProposalsRequest { + return {}; +} +export const QueryConsumerChainStartProposalsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainStartProposalsRequest", + encode( + _: QueryConsumerChainStartProposalsRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainStartProposalsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainStartProposalsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryConsumerChainStartProposalsRequest { + const obj = createBaseQueryConsumerChainStartProposalsRequest(); + return obj; + }, + toJSON(_: QueryConsumerChainStartProposalsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): QueryConsumerChainStartProposalsRequest { + const message = createBaseQueryConsumerChainStartProposalsRequest(); + return message; + }, +}; +function createBaseQueryConsumerChainStartProposalsResponse(): QueryConsumerChainStartProposalsResponse { + return { + proposals: undefined, + }; +} +export const QueryConsumerChainStartProposalsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainStartProposalsResponse", + encode( + message: QueryConsumerChainStartProposalsResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.proposals !== undefined) { + ConsumerAdditionProposals.encode(message.proposals, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainStartProposalsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainStartProposalsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals = ConsumerAdditionProposals.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainStartProposalsResponse { + const obj = createBaseQueryConsumerChainStartProposalsResponse(); + if (isSet(object.proposals)) obj.proposals = ConsumerAdditionProposals.fromJSON(object.proposals); + return obj; + }, + toJSON( + message: QueryConsumerChainStartProposalsResponse, + ): JsonSafe { + const obj: any = {}; + message.proposals !== undefined && + (obj.proposals = message.proposals ? ConsumerAdditionProposals.toJSON(message.proposals) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainStartProposalsResponse { + const message = createBaseQueryConsumerChainStartProposalsResponse(); + if (object.proposals !== undefined && object.proposals !== null) { + message.proposals = ConsumerAdditionProposals.fromPartial(object.proposals); + } + return message; + }, +}; +function createBaseQueryConsumerChainStopProposalsRequest(): QueryConsumerChainStopProposalsRequest { + return {}; +} +export const QueryConsumerChainStopProposalsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainStopProposalsRequest", + encode( + _: QueryConsumerChainStopProposalsRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainStopProposalsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainStopProposalsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryConsumerChainStopProposalsRequest { + const obj = createBaseQueryConsumerChainStopProposalsRequest(); + return obj; + }, + toJSON(_: QueryConsumerChainStopProposalsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): QueryConsumerChainStopProposalsRequest { + const message = createBaseQueryConsumerChainStopProposalsRequest(); + return message; + }, +}; +function createBaseQueryConsumerChainStopProposalsResponse(): QueryConsumerChainStopProposalsResponse { + return { + proposals: undefined, + }; +} +export const QueryConsumerChainStopProposalsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainStopProposalsResponse", + encode( + message: QueryConsumerChainStopProposalsResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.proposals !== undefined) { + ConsumerRemovalProposals.encode(message.proposals, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainStopProposalsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainStopProposalsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals = ConsumerRemovalProposals.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainStopProposalsResponse { + const obj = createBaseQueryConsumerChainStopProposalsResponse(); + if (isSet(object.proposals)) obj.proposals = ConsumerRemovalProposals.fromJSON(object.proposals); + return obj; + }, + toJSON( + message: QueryConsumerChainStopProposalsResponse, + ): JsonSafe { + const obj: any = {}; + message.proposals !== undefined && + (obj.proposals = message.proposals ? ConsumerRemovalProposals.toJSON(message.proposals) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainStopProposalsResponse { + const message = createBaseQueryConsumerChainStopProposalsResponse(); + if (object.proposals !== undefined && object.proposals !== null) { + message.proposals = ConsumerRemovalProposals.fromPartial(object.proposals); + } + return message; + }, +}; +function createBaseChain(): Chain { + return { + chainId: "", + clientId: "", + topN: 0, + minPowerInTopN: BigInt(0), + validatorsPowerCap: 0, + validatorSetCap: 0, + allowlist: [], + denylist: [], + }; +} +export const Chain = { + typeUrl: "/interchain_security.ccv.provider.v1.Chain", + encode(message: Chain, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.topN !== 0) { + writer.uint32(24).uint32(message.topN); + } + if (message.minPowerInTopN !== BigInt(0)) { + writer.uint32(32).int64(message.minPowerInTopN); + } + if (message.validatorsPowerCap !== 0) { + writer.uint32(40).uint32(message.validatorsPowerCap); + } + if (message.validatorSetCap !== 0) { + writer.uint32(48).uint32(message.validatorSetCap); + } + for (const v of message.allowlist) { + writer.uint32(58).string(v!); + } + for (const v of message.denylist) { + writer.uint32(66).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Chain { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChain(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.topN = reader.uint32(); + break; + case 4: + message.minPowerInTopN = reader.int64(); + break; + case 5: + message.validatorsPowerCap = reader.uint32(); + break; + case 6: + message.validatorSetCap = reader.uint32(); + break; + case 7: + message.allowlist.push(reader.string()); + break; + case 8: + message.denylist.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Chain { + const obj = createBaseChain(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.clientId)) obj.clientId = String(object.clientId); + if (isSet(object.topN)) obj.topN = Number(object.topN); + if (isSet(object.minPowerInTopN)) obj.minPowerInTopN = BigInt(object.minPowerInTopN.toString()); + if (isSet(object.validatorsPowerCap)) obj.validatorsPowerCap = Number(object.validatorsPowerCap); + if (isSet(object.validatorSetCap)) obj.validatorSetCap = Number(object.validatorSetCap); + if (Array.isArray(object?.allowlist)) obj.allowlist = object.allowlist.map((e: any) => String(e)); + if (Array.isArray(object?.denylist)) obj.denylist = object.denylist.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Chain): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.topN !== undefined && (obj.topN = Math.round(message.topN)); + message.minPowerInTopN !== undefined && + (obj.minPowerInTopN = (message.minPowerInTopN || BigInt(0)).toString()); + message.validatorsPowerCap !== undefined && + (obj.validatorsPowerCap = Math.round(message.validatorsPowerCap)); + message.validatorSetCap !== undefined && (obj.validatorSetCap = Math.round(message.validatorSetCap)); + if (message.allowlist) { + obj.allowlist = message.allowlist.map((e) => e); + } else { + obj.allowlist = []; + } + if (message.denylist) { + obj.denylist = message.denylist.map((e) => e); + } else { + obj.denylist = []; + } + return obj; + }, + fromPartial, I>>(object: I): Chain { + const message = createBaseChain(); + message.chainId = object.chainId ?? ""; + message.clientId = object.clientId ?? ""; + message.topN = object.topN ?? 0; + if (object.minPowerInTopN !== undefined && object.minPowerInTopN !== null) { + message.minPowerInTopN = BigInt(object.minPowerInTopN.toString()); + } + message.validatorsPowerCap = object.validatorsPowerCap ?? 0; + message.validatorSetCap = object.validatorSetCap ?? 0; + message.allowlist = object.allowlist?.map((e) => e) || []; + message.denylist = object.denylist?.map((e) => e) || []; + return message; + }, +}; +function createBaseQueryValidatorConsumerAddrRequest(): QueryValidatorConsumerAddrRequest { + return { + chainId: "", + providerAddress: "", + }; +} +export const QueryValidatorConsumerAddrRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorConsumerAddrRequest", + encode( + message: QueryValidatorConsumerAddrRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddress !== "") { + writer.uint32(18).string(message.providerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorConsumerAddrRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorConsumerAddrRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorConsumerAddrRequest { + const obj = createBaseQueryValidatorConsumerAddrRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + return obj; + }, + toJSON(message: QueryValidatorConsumerAddrRequest): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorConsumerAddrRequest { + const message = createBaseQueryValidatorConsumerAddrRequest(); + message.chainId = object.chainId ?? ""; + message.providerAddress = object.providerAddress ?? ""; + return message; + }, +}; +function createBaseQueryValidatorConsumerAddrResponse(): QueryValidatorConsumerAddrResponse { + return { + consumerAddress: "", + }; +} +export const QueryValidatorConsumerAddrResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorConsumerAddrResponse", + encode( + message: QueryValidatorConsumerAddrResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.consumerAddress !== "") { + writer.uint32(10).string(message.consumerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorConsumerAddrResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorConsumerAddrResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consumerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorConsumerAddrResponse { + const obj = createBaseQueryValidatorConsumerAddrResponse(); + if (isSet(object.consumerAddress)) obj.consumerAddress = String(object.consumerAddress); + return obj; + }, + toJSON(message: QueryValidatorConsumerAddrResponse): JsonSafe { + const obj: any = {}; + message.consumerAddress !== undefined && (obj.consumerAddress = message.consumerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorConsumerAddrResponse { + const message = createBaseQueryValidatorConsumerAddrResponse(); + message.consumerAddress = object.consumerAddress ?? ""; + return message; + }, +}; +function createBaseQueryValidatorProviderAddrRequest(): QueryValidatorProviderAddrRequest { + return { + chainId: "", + consumerAddress: "", + }; +} +export const QueryValidatorProviderAddrRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorProviderAddrRequest", + encode( + message: QueryValidatorProviderAddrRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.consumerAddress !== "") { + writer.uint32(18).string(message.consumerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorProviderAddrRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorProviderAddrRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.consumerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorProviderAddrRequest { + const obj = createBaseQueryValidatorProviderAddrRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.consumerAddress)) obj.consumerAddress = String(object.consumerAddress); + return obj; + }, + toJSON(message: QueryValidatorProviderAddrRequest): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.consumerAddress !== undefined && (obj.consumerAddress = message.consumerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorProviderAddrRequest { + const message = createBaseQueryValidatorProviderAddrRequest(); + message.chainId = object.chainId ?? ""; + message.consumerAddress = object.consumerAddress ?? ""; + return message; + }, +}; +function createBaseQueryValidatorProviderAddrResponse(): QueryValidatorProviderAddrResponse { + return { + providerAddress: "", + }; +} +export const QueryValidatorProviderAddrResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorProviderAddrResponse", + encode( + message: QueryValidatorProviderAddrResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.providerAddress !== "") { + writer.uint32(10).string(message.providerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorProviderAddrResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorProviderAddrResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorProviderAddrResponse { + const obj = createBaseQueryValidatorProviderAddrResponse(); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + return obj; + }, + toJSON(message: QueryValidatorProviderAddrResponse): JsonSafe { + const obj: any = {}; + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorProviderAddrResponse { + const message = createBaseQueryValidatorProviderAddrResponse(); + message.providerAddress = object.providerAddress ?? ""; + return message; + }, +}; +function createBaseQueryThrottleStateRequest(): QueryThrottleStateRequest { + return {}; +} +export const QueryThrottleStateRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryThrottleStateRequest", + encode(_: QueryThrottleStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryThrottleStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryThrottleStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryThrottleStateRequest { + const obj = createBaseQueryThrottleStateRequest(); + return obj; + }, + toJSON(_: QueryThrottleStateRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryThrottleStateRequest { + const message = createBaseQueryThrottleStateRequest(); + return message; + }, +}; +function createBaseQueryThrottleStateResponse(): QueryThrottleStateResponse { + return { + slashMeter: BigInt(0), + slashMeterAllowance: BigInt(0), + nextReplenishCandidate: Timestamp.fromPartial({}), + }; +} +export const QueryThrottleStateResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryThrottleStateResponse", + encode(message: QueryThrottleStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.slashMeter !== BigInt(0)) { + writer.uint32(8).int64(message.slashMeter); + } + if (message.slashMeterAllowance !== BigInt(0)) { + writer.uint32(16).int64(message.slashMeterAllowance); + } + if (message.nextReplenishCandidate !== undefined) { + Timestamp.encode(message.nextReplenishCandidate, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryThrottleStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryThrottleStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.slashMeter = reader.int64(); + break; + case 2: + message.slashMeterAllowance = reader.int64(); + break; + case 3: + message.nextReplenishCandidate = Timestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryThrottleStateResponse { + const obj = createBaseQueryThrottleStateResponse(); + if (isSet(object.slashMeter)) obj.slashMeter = BigInt(object.slashMeter.toString()); + if (isSet(object.slashMeterAllowance)) + obj.slashMeterAllowance = BigInt(object.slashMeterAllowance.toString()); + if (isSet(object.nextReplenishCandidate)) + obj.nextReplenishCandidate = fromJsonTimestamp(object.nextReplenishCandidate); + return obj; + }, + toJSON(message: QueryThrottleStateResponse): JsonSafe { + const obj: any = {}; + message.slashMeter !== undefined && (obj.slashMeter = (message.slashMeter || BigInt(0)).toString()); + message.slashMeterAllowance !== undefined && + (obj.slashMeterAllowance = (message.slashMeterAllowance || BigInt(0)).toString()); + message.nextReplenishCandidate !== undefined && + (obj.nextReplenishCandidate = fromTimestamp(message.nextReplenishCandidate).toISOString()); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryThrottleStateResponse { + const message = createBaseQueryThrottleStateResponse(); + if (object.slashMeter !== undefined && object.slashMeter !== null) { + message.slashMeter = BigInt(object.slashMeter.toString()); + } + if (object.slashMeterAllowance !== undefined && object.slashMeterAllowance !== null) { + message.slashMeterAllowance = BigInt(object.slashMeterAllowance.toString()); + } + if (object.nextReplenishCandidate !== undefined && object.nextReplenishCandidate !== null) { + message.nextReplenishCandidate = Timestamp.fromPartial(object.nextReplenishCandidate); + } + return message; + }, +}; +function createBaseQueryRegisteredConsumerRewardDenomsRequest(): QueryRegisteredConsumerRewardDenomsRequest { + return {}; +} +export const QueryRegisteredConsumerRewardDenomsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsRequest", + encode( + _: QueryRegisteredConsumerRewardDenomsRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRegisteredConsumerRewardDenomsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRegisteredConsumerRewardDenomsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryRegisteredConsumerRewardDenomsRequest { + const obj = createBaseQueryRegisteredConsumerRewardDenomsRequest(); + return obj; + }, + toJSON( + _: QueryRegisteredConsumerRewardDenomsRequest, + ): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): QueryRegisteredConsumerRewardDenomsRequest { + const message = createBaseQueryRegisteredConsumerRewardDenomsRequest(); + return message; + }, +}; +function createBaseQueryRegisteredConsumerRewardDenomsResponse(): QueryRegisteredConsumerRewardDenomsResponse { + return { + denoms: [], + }; +} +export const QueryRegisteredConsumerRewardDenomsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsResponse", + encode( + message: QueryRegisteredConsumerRewardDenomsResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + for (const v of message.denoms) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRegisteredConsumerRewardDenomsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRegisteredConsumerRewardDenomsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denoms.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryRegisteredConsumerRewardDenomsResponse { + const obj = createBaseQueryRegisteredConsumerRewardDenomsResponse(); + if (Array.isArray(object?.denoms)) obj.denoms = object.denoms.map((e: any) => String(e)); + return obj; + }, + toJSON( + message: QueryRegisteredConsumerRewardDenomsResponse, + ): JsonSafe { + const obj: any = {}; + if (message.denoms) { + obj.denoms = message.denoms.map((e) => e); + } else { + obj.denoms = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryRegisteredConsumerRewardDenomsResponse { + const message = createBaseQueryRegisteredConsumerRewardDenomsResponse(); + message.denoms = object.denoms?.map((e) => e) || []; + return message; + }, +}; +function createBaseQueryProposedChainIDsRequest(): QueryProposedChainIDsRequest { + return {}; +} +export const QueryProposedChainIDsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryProposedChainIDsRequest", + encode(_: QueryProposedChainIDsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposedChainIDsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposedChainIDsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryProposedChainIDsRequest { + const obj = createBaseQueryProposedChainIDsRequest(); + return obj; + }, + toJSON(_: QueryProposedChainIDsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): QueryProposedChainIDsRequest { + const message = createBaseQueryProposedChainIDsRequest(); + return message; + }, +}; +function createBaseQueryProposedChainIDsResponse(): QueryProposedChainIDsResponse { + return { + proposedChains: [], + }; +} +export const QueryProposedChainIDsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryProposedChainIDsResponse", + encode(message: QueryProposedChainIDsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.proposedChains) { + ProposedChain.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposedChainIDsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposedChainIDsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposedChains.push(ProposedChain.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposedChainIDsResponse { + const obj = createBaseQueryProposedChainIDsResponse(); + if (Array.isArray(object?.proposedChains)) + obj.proposedChains = object.proposedChains.map((e: any) => ProposedChain.fromJSON(e)); + return obj; + }, + toJSON(message: QueryProposedChainIDsResponse): JsonSafe { + const obj: any = {}; + if (message.proposedChains) { + obj.proposedChains = message.proposedChains.map((e) => (e ? ProposedChain.toJSON(e) : undefined)); + } else { + obj.proposedChains = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryProposedChainIDsResponse { + const message = createBaseQueryProposedChainIDsResponse(); + message.proposedChains = object.proposedChains?.map((e) => ProposedChain.fromPartial(e)) || []; + return message; + }, +}; +function createBaseProposedChain(): ProposedChain { + return { + chainID: "", + proposalID: BigInt(0), + }; +} +export const ProposedChain = { + typeUrl: "/interchain_security.ccv.provider.v1.ProposedChain", + encode(message: ProposedChain, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainID !== "") { + writer.uint32(10).string(message.chainID); + } + if (message.proposalID !== BigInt(0)) { + writer.uint32(16).uint64(message.proposalID); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProposedChain { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProposedChain(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainID = reader.string(); + break; + case 2: + message.proposalID = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProposedChain { + const obj = createBaseProposedChain(); + if (isSet(object.chainID)) obj.chainID = String(object.chainID); + if (isSet(object.proposalID)) obj.proposalID = BigInt(object.proposalID.toString()); + return obj; + }, + toJSON(message: ProposedChain): JsonSafe { + const obj: any = {}; + message.chainID !== undefined && (obj.chainID = message.chainID); + message.proposalID !== undefined && (obj.proposalID = (message.proposalID || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): ProposedChain { + const message = createBaseProposedChain(); + message.chainID = object.chainID ?? ""; + if (object.proposalID !== undefined && object.proposalID !== null) { + message.proposalID = BigInt(object.proposalID.toString()); + } + return message; + }, +}; +function createBaseQueryAllPairsValConAddrByConsumerChainIDRequest(): QueryAllPairsValConAddrByConsumerChainIDRequest { + return { + chainId: "", + }; +} +export const QueryAllPairsValConAddrByConsumerChainIDRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDRequest", + encode( + message: QueryAllPairsValConAddrByConsumerChainIDRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllPairsValConAddrByConsumerChainIDRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllPairsValConAddrByConsumerChainIDRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllPairsValConAddrByConsumerChainIDRequest { + const obj = createBaseQueryAllPairsValConAddrByConsumerChainIDRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON( + message: QueryAllPairsValConAddrByConsumerChainIDRequest, + ): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryAllPairsValConAddrByConsumerChainIDRequest { + const message = createBaseQueryAllPairsValConAddrByConsumerChainIDRequest(); + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseQueryAllPairsValConAddrByConsumerChainIDResponse(): QueryAllPairsValConAddrByConsumerChainIDResponse { + return { + pairValConAddr: [], + }; +} +export const QueryAllPairsValConAddrByConsumerChainIDResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDResponse", + encode( + message: QueryAllPairsValConAddrByConsumerChainIDResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + for (const v of message.pairValConAddr) { + PairValConAddrProviderAndConsumer.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): QueryAllPairsValConAddrByConsumerChainIDResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllPairsValConAddrByConsumerChainIDResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pairValConAddr.push(PairValConAddrProviderAndConsumer.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllPairsValConAddrByConsumerChainIDResponse { + const obj = createBaseQueryAllPairsValConAddrByConsumerChainIDResponse(); + if (Array.isArray(object?.pairValConAddr)) + obj.pairValConAddr = object.pairValConAddr.map((e: any) => + PairValConAddrProviderAndConsumer.fromJSON(e), + ); + return obj; + }, + toJSON( + message: QueryAllPairsValConAddrByConsumerChainIDResponse, + ): JsonSafe { + const obj: any = {}; + if (message.pairValConAddr) { + obj.pairValConAddr = message.pairValConAddr.map((e) => + e ? PairValConAddrProviderAndConsumer.toJSON(e) : undefined, + ); + } else { + obj.pairValConAddr = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryAllPairsValConAddrByConsumerChainIDResponse { + const message = createBaseQueryAllPairsValConAddrByConsumerChainIDResponse(); + message.pairValConAddr = + object.pairValConAddr?.map((e) => PairValConAddrProviderAndConsumer.fromPartial(e)) || []; + return message; + }, +}; +function createBasePairValConAddrProviderAndConsumer(): PairValConAddrProviderAndConsumer { + return { + providerAddress: "", + consumerAddress: "", + consumerKey: undefined, + }; +} +export const PairValConAddrProviderAndConsumer = { + typeUrl: "/interchain_security.ccv.provider.v1.PairValConAddrProviderAndConsumer", + encode( + message: PairValConAddrProviderAndConsumer, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.providerAddress !== "") { + writer.uint32(10).string(message.providerAddress); + } + if (message.consumerAddress !== "") { + writer.uint32(18).string(message.consumerAddress); + } + if (message.consumerKey !== undefined) { + PublicKey.encode(message.consumerKey, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PairValConAddrProviderAndConsumer { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePairValConAddrProviderAndConsumer(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddress = reader.string(); + break; + case 2: + message.consumerAddress = reader.string(); + break; + case 3: + message.consumerKey = PublicKey.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PairValConAddrProviderAndConsumer { + const obj = createBasePairValConAddrProviderAndConsumer(); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + if (isSet(object.consumerAddress)) obj.consumerAddress = String(object.consumerAddress); + if (isSet(object.consumerKey)) obj.consumerKey = PublicKey.fromJSON(object.consumerKey); + return obj; + }, + toJSON(message: PairValConAddrProviderAndConsumer): JsonSafe { + const obj: any = {}; + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + message.consumerAddress !== undefined && (obj.consumerAddress = message.consumerAddress); + message.consumerKey !== undefined && + (obj.consumerKey = message.consumerKey ? PublicKey.toJSON(message.consumerKey) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): PairValConAddrProviderAndConsumer { + const message = createBasePairValConAddrProviderAndConsumer(); + message.providerAddress = object.providerAddress ?? ""; + message.consumerAddress = object.consumerAddress ?? ""; + if (object.consumerKey !== undefined && object.consumerKey !== null) { + message.consumerKey = PublicKey.fromPartial(object.consumerKey); + } + return message; + }, +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}), + }; +} +export const QueryParamsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + 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 obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, +}; +function createBaseQueryConsumerChainOptedInValidatorsRequest(): QueryConsumerChainOptedInValidatorsRequest { + return { + chainId: "", + }; +} +export const QueryConsumerChainOptedInValidatorsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainOptedInValidatorsRequest", + encode( + message: QueryConsumerChainOptedInValidatorsRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainOptedInValidatorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainOptedInValidatorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainOptedInValidatorsRequest { + const obj = createBaseQueryConsumerChainOptedInValidatorsRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON( + message: QueryConsumerChainOptedInValidatorsRequest, + ): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainOptedInValidatorsRequest { + const message = createBaseQueryConsumerChainOptedInValidatorsRequest(); + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseQueryConsumerChainOptedInValidatorsResponse(): QueryConsumerChainOptedInValidatorsResponse { + return { + validatorsProviderAddresses: [], + }; +} +export const QueryConsumerChainOptedInValidatorsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainOptedInValidatorsResponse", + encode( + message: QueryConsumerChainOptedInValidatorsResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + for (const v of message.validatorsProviderAddresses) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerChainOptedInValidatorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainOptedInValidatorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorsProviderAddresses.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainOptedInValidatorsResponse { + const obj = createBaseQueryConsumerChainOptedInValidatorsResponse(); + if (Array.isArray(object?.validatorsProviderAddresses)) + obj.validatorsProviderAddresses = object.validatorsProviderAddresses.map((e: any) => String(e)); + return obj; + }, + toJSON( + message: QueryConsumerChainOptedInValidatorsResponse, + ): JsonSafe { + const obj: any = {}; + if (message.validatorsProviderAddresses) { + obj.validatorsProviderAddresses = message.validatorsProviderAddresses.map((e) => e); + } else { + obj.validatorsProviderAddresses = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainOptedInValidatorsResponse { + const message = createBaseQueryConsumerChainOptedInValidatorsResponse(); + message.validatorsProviderAddresses = object.validatorsProviderAddresses?.map((e) => e) || []; + return message; + }, +}; +function createBaseQueryConsumerValidatorsRequest(): QueryConsumerValidatorsRequest { + return { + chainId: "", + }; +} +export const QueryConsumerValidatorsRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerValidatorsRequest", + encode( + message: QueryConsumerValidatorsRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerValidatorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerValidatorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerValidatorsRequest { + const obj = createBaseQueryConsumerValidatorsRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON(message: QueryConsumerValidatorsRequest): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerValidatorsRequest { + const message = createBaseQueryConsumerValidatorsRequest(); + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseQueryConsumerValidatorsValidator(): QueryConsumerValidatorsValidator { + return { + providerAddress: "", + consumerKey: undefined, + power: BigInt(0), + }; +} +export const QueryConsumerValidatorsValidator = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerValidatorsValidator", + encode( + message: QueryConsumerValidatorsValidator, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.providerAddress !== "") { + writer.uint32(10).string(message.providerAddress); + } + if (message.consumerKey !== undefined) { + PublicKey.encode(message.consumerKey, writer.uint32(18).fork()).ldelim(); + } + if (message.power !== BigInt(0)) { + writer.uint32(24).int64(message.power); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerValidatorsValidator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerValidatorsValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddress = reader.string(); + break; + case 2: + message.consumerKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.power = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerValidatorsValidator { + const obj = createBaseQueryConsumerValidatorsValidator(); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + if (isSet(object.consumerKey)) obj.consumerKey = PublicKey.fromJSON(object.consumerKey); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + return obj; + }, + toJSON(message: QueryConsumerValidatorsValidator): JsonSafe { + const obj: any = {}; + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + message.consumerKey !== undefined && + (obj.consumerKey = message.consumerKey ? PublicKey.toJSON(message.consumerKey) : undefined); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerValidatorsValidator { + const message = createBaseQueryConsumerValidatorsValidator(); + message.providerAddress = object.providerAddress ?? ""; + if (object.consumerKey !== undefined && object.consumerKey !== null) { + message.consumerKey = PublicKey.fromPartial(object.consumerKey); + } + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + return message; + }, +}; +function createBaseQueryConsumerValidatorsResponse(): QueryConsumerValidatorsResponse { + return { + validators: [], + }; +} +export const QueryConsumerValidatorsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerValidatorsResponse", + encode( + message: QueryConsumerValidatorsResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + for (const v of message.validators) { + QueryConsumerValidatorsValidator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConsumerValidatorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerValidatorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(QueryConsumerValidatorsValidator.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerValidatorsResponse { + const obj = createBaseQueryConsumerValidatorsResponse(); + if (Array.isArray(object?.validators)) + obj.validators = object.validators.map((e: any) => QueryConsumerValidatorsValidator.fromJSON(e)); + return obj; + }, + toJSON(message: QueryConsumerValidatorsResponse): JsonSafe { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? QueryConsumerValidatorsValidator.toJSON(e) : undefined, + ); + } else { + obj.validators = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerValidatorsResponse { + const message = createBaseQueryConsumerValidatorsResponse(); + message.validators = object.validators?.map((e) => QueryConsumerValidatorsValidator.fromPartial(e)) || []; + return message; + }, +}; +function createBaseQueryConsumerChainsValidatorHasToValidateRequest(): QueryConsumerChainsValidatorHasToValidateRequest { + return { + providerAddress: "", + }; +} +export const QueryConsumerChainsValidatorHasToValidateRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainsValidatorHasToValidateRequest", + encode( + message: QueryConsumerChainsValidatorHasToValidateRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.providerAddress !== "") { + writer.uint32(10).string(message.providerAddress); + } + return writer; + }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): QueryConsumerChainsValidatorHasToValidateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainsValidatorHasToValidateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainsValidatorHasToValidateRequest { + const obj = createBaseQueryConsumerChainsValidatorHasToValidateRequest(); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + return obj; + }, + toJSON( + message: QueryConsumerChainsValidatorHasToValidateRequest, + ): JsonSafe { + const obj: any = {}; + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainsValidatorHasToValidateRequest { + const message = createBaseQueryConsumerChainsValidatorHasToValidateRequest(); + message.providerAddress = object.providerAddress ?? ""; + return message; + }, +}; +function createBaseQueryConsumerChainsValidatorHasToValidateResponse(): QueryConsumerChainsValidatorHasToValidateResponse { + return { + consumerChainIds: [], + }; +} +export const QueryConsumerChainsValidatorHasToValidateResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryConsumerChainsValidatorHasToValidateResponse", + encode( + message: QueryConsumerChainsValidatorHasToValidateResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + for (const v of message.consumerChainIds) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): QueryConsumerChainsValidatorHasToValidateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConsumerChainsValidatorHasToValidateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consumerChainIds.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConsumerChainsValidatorHasToValidateResponse { + const obj = createBaseQueryConsumerChainsValidatorHasToValidateResponse(); + if (Array.isArray(object?.consumerChainIds)) + obj.consumerChainIds = object.consumerChainIds.map((e: any) => String(e)); + return obj; + }, + toJSON( + message: QueryConsumerChainsValidatorHasToValidateResponse, + ): JsonSafe { + const obj: any = {}; + if (message.consumerChainIds) { + obj.consumerChainIds = message.consumerChainIds.map((e) => e); + } else { + obj.consumerChainIds = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryConsumerChainsValidatorHasToValidateResponse { + const message = createBaseQueryConsumerChainsValidatorHasToValidateResponse(); + message.consumerChainIds = object.consumerChainIds?.map((e) => e) || []; + return message; + }, +}; +function createBaseQueryValidatorConsumerCommissionRateRequest(): QueryValidatorConsumerCommissionRateRequest { + return { + chainId: "", + providerAddress: "", + }; +} +export const QueryValidatorConsumerCommissionRateRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorConsumerCommissionRateRequest", + encode( + message: QueryValidatorConsumerCommissionRateRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddress !== "") { + writer.uint32(18).string(message.providerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorConsumerCommissionRateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorConsumerCommissionRateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorConsumerCommissionRateRequest { + const obj = createBaseQueryValidatorConsumerCommissionRateRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddress)) obj.providerAddress = String(object.providerAddress); + return obj; + }, + toJSON( + message: QueryValidatorConsumerCommissionRateRequest, + ): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddress !== undefined && (obj.providerAddress = message.providerAddress); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorConsumerCommissionRateRequest { + const message = createBaseQueryValidatorConsumerCommissionRateRequest(); + message.chainId = object.chainId ?? ""; + message.providerAddress = object.providerAddress ?? ""; + return message; + }, +}; +function createBaseQueryValidatorConsumerCommissionRateResponse(): QueryValidatorConsumerCommissionRateResponse { + return { + rate: "", + }; +} +export const QueryValidatorConsumerCommissionRateResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryValidatorConsumerCommissionRateResponse", + encode( + message: QueryValidatorConsumerCommissionRateResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.rate !== "") { + writer.uint32(10).string(Decimal.fromUserInput(message.rate, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorConsumerCommissionRateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorConsumerCommissionRateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorConsumerCommissionRateResponse { + const obj = createBaseQueryValidatorConsumerCommissionRateResponse(); + if (isSet(object.rate)) obj.rate = String(object.rate); + return obj; + }, + toJSON( + message: QueryValidatorConsumerCommissionRateResponse, + ): JsonSafe { + const obj: any = {}; + message.rate !== undefined && (obj.rate = message.rate); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryValidatorConsumerCommissionRateResponse { + const message = createBaseQueryValidatorConsumerCommissionRateResponse(); + message.rate = object.rate ?? ""; + return message; + }, +}; +function createBaseQueryOldestUnconfirmedVscRequest(): QueryOldestUnconfirmedVscRequest { + return { + chainId: "", + }; +} +export const QueryOldestUnconfirmedVscRequest = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryOldestUnconfirmedVscRequest", + encode( + message: QueryOldestUnconfirmedVscRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOldestUnconfirmedVscRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOldestUnconfirmedVscRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOldestUnconfirmedVscRequest { + const obj = createBaseQueryOldestUnconfirmedVscRequest(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + return obj; + }, + toJSON(message: QueryOldestUnconfirmedVscRequest): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryOldestUnconfirmedVscRequest { + const message = createBaseQueryOldestUnconfirmedVscRequest(); + message.chainId = object.chainId ?? ""; + return message; + }, +}; +function createBaseQueryOldestUnconfirmedVscResponse(): QueryOldestUnconfirmedVscResponse { + return { + vscSendTimestamp: VscSendTimestamp.fromPartial({}), + }; +} +export const QueryOldestUnconfirmedVscResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.QueryOldestUnconfirmedVscResponse", + encode( + message: QueryOldestUnconfirmedVscResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.vscSendTimestamp !== undefined) { + VscSendTimestamp.encode(message.vscSendTimestamp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOldestUnconfirmedVscResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOldestUnconfirmedVscResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vscSendTimestamp = VscSendTimestamp.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOldestUnconfirmedVscResponse { + const obj = createBaseQueryOldestUnconfirmedVscResponse(); + if (isSet(object.vscSendTimestamp)) + obj.vscSendTimestamp = VscSendTimestamp.fromJSON(object.vscSendTimestamp); + return obj; + }, + toJSON(message: QueryOldestUnconfirmedVscResponse): JsonSafe { + const obj: any = {}; + message.vscSendTimestamp !== undefined && + (obj.vscSendTimestamp = message.vscSendTimestamp + ? VscSendTimestamp.toJSON(message.vscSendTimestamp) + : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QueryOldestUnconfirmedVscResponse { + const message = createBaseQueryOldestUnconfirmedVscResponse(); + if (object.vscSendTimestamp !== undefined && object.vscSendTimestamp !== null) { + message.vscSendTimestamp = VscSendTimestamp.fromPartial(object.vscSendTimestamp); + } + return message; + }, +}; diff --git a/src/interchain_security/ccv/provider/v1/tx.rpc.msg.ts b/src/interchain_security/ccv/provider/v1/tx.rpc.msg.ts new file mode 100644 index 0000000..c73d8a6 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/tx.rpc.msg.ts @@ -0,0 +1,128 @@ +/* eslint-disable */ +import { Rpc } from "../../../../helpers"; +import { BinaryReader } from "../../../../binary"; +import { + MsgAssignConsumerKey, + MsgAssignConsumerKeyResponse, + MsgSubmitConsumerMisbehaviour, + MsgSubmitConsumerMisbehaviourResponse, + MsgSubmitConsumerDoubleVoting, + MsgSubmitConsumerDoubleVotingResponse, + MsgConsumerAddition, + MsgConsumerAdditionResponse, + MsgConsumerRemoval, + MsgConsumerRemovalResponse, + MsgUpdateParams, + MsgUpdateParamsResponse, + MsgOptIn, + MsgOptInResponse, + MsgOptOut, + MsgOptOutResponse, + MsgSetConsumerCommissionRate, + MsgSetConsumerCommissionRateResponse, + MsgConsumerModification, + MsgConsumerModificationResponse, +} from "./tx"; +/** Msg defines the Msg service. */ +export interface Msg { + assignConsumerKey(request: MsgAssignConsumerKey): Promise; + submitConsumerMisbehaviour( + request: MsgSubmitConsumerMisbehaviour, + ): Promise; + submitConsumerDoubleVoting( + request: MsgSubmitConsumerDoubleVoting, + ): Promise; + consumerAddition(request: MsgConsumerAddition): Promise; + consumerRemoval(request: MsgConsumerRemoval): Promise; + updateParams(request: MsgUpdateParams): Promise; + optIn(request: MsgOptIn): Promise; + optOut(request: MsgOptOut): Promise; + setConsumerCommissionRate( + request: MsgSetConsumerCommissionRate, + ): Promise; + consumerModification(request: MsgConsumerModification): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.assignConsumerKey = this.assignConsumerKey.bind(this); + this.submitConsumerMisbehaviour = this.submitConsumerMisbehaviour.bind(this); + this.submitConsumerDoubleVoting = this.submitConsumerDoubleVoting.bind(this); + this.consumerAddition = this.consumerAddition.bind(this); + this.consumerRemoval = this.consumerRemoval.bind(this); + this.updateParams = this.updateParams.bind(this); + this.optIn = this.optIn.bind(this); + this.optOut = this.optOut.bind(this); + this.setConsumerCommissionRate = this.setConsumerCommissionRate.bind(this); + this.consumerModification = this.consumerModification.bind(this); + } + assignConsumerKey(request: MsgAssignConsumerKey): Promise { + const data = MsgAssignConsumerKey.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "AssignConsumerKey", data); + return promise.then((data) => MsgAssignConsumerKeyResponse.decode(new BinaryReader(data))); + } + submitConsumerMisbehaviour( + request: MsgSubmitConsumerMisbehaviour, + ): Promise { + const data = MsgSubmitConsumerMisbehaviour.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Msg", + "SubmitConsumerMisbehaviour", + data, + ); + return promise.then((data) => MsgSubmitConsumerMisbehaviourResponse.decode(new BinaryReader(data))); + } + submitConsumerDoubleVoting( + request: MsgSubmitConsumerDoubleVoting, + ): Promise { + const data = MsgSubmitConsumerDoubleVoting.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Msg", + "SubmitConsumerDoubleVoting", + data, + ); + return promise.then((data) => MsgSubmitConsumerDoubleVotingResponse.decode(new BinaryReader(data))); + } + consumerAddition(request: MsgConsumerAddition): Promise { + const data = MsgConsumerAddition.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "ConsumerAddition", data); + return promise.then((data) => MsgConsumerAdditionResponse.decode(new BinaryReader(data))); + } + consumerRemoval(request: MsgConsumerRemoval): Promise { + const data = MsgConsumerRemoval.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "ConsumerRemoval", data); + return promise.then((data) => MsgConsumerRemovalResponse.decode(new BinaryReader(data))); + } + updateParams(request: MsgUpdateParams): Promise { + const data = MsgUpdateParams.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "UpdateParams", data); + return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); + } + optIn(request: MsgOptIn): Promise { + const data = MsgOptIn.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "OptIn", data); + return promise.then((data) => MsgOptInResponse.decode(new BinaryReader(data))); + } + optOut(request: MsgOptOut): Promise { + const data = MsgOptOut.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "OptOut", data); + return promise.then((data) => MsgOptOutResponse.decode(new BinaryReader(data))); + } + setConsumerCommissionRate( + request: MsgSetConsumerCommissionRate, + ): Promise { + const data = MsgSetConsumerCommissionRate.encode(request).finish(); + const promise = this.rpc.request( + "interchain_security.ccv.provider.v1.Msg", + "SetConsumerCommissionRate", + data, + ); + return promise.then((data) => MsgSetConsumerCommissionRateResponse.decode(new BinaryReader(data))); + } + consumerModification(request: MsgConsumerModification): Promise { + const data = MsgConsumerModification.encode(request).finish(); + const promise = this.rpc.request("interchain_security.ccv.provider.v1.Msg", "ConsumerModification", data); + return promise.then((data) => MsgConsumerModificationResponse.decode(new BinaryReader(data))); + } +} diff --git a/src/interchain_security/ccv/provider/v1/tx.ts b/src/interchain_security/ccv/provider/v1/tx.ts new file mode 100644 index 0000000..298bab3 --- /dev/null +++ b/src/interchain_security/ccv/provider/v1/tx.ts @@ -0,0 +1,1749 @@ +/* eslint-disable */ +import { Misbehaviour, Header } from "../../../../ibc/lightclients/tendermint/v1/tendermint"; +import { DuplicateVoteEvidence } from "../../../../tendermint/types/evidence"; +import { Height, Params } from "../../../../ibc/core/client/v1/client"; +import { Timestamp } from "../../../../google/protobuf/timestamp"; +import { Duration } from "../../../../google/protobuf/duration"; +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { + isSet, + DeepPartial, + Exact, + bytesFromBase64, + fromJsonTimestamp, + base64FromBytes, + fromTimestamp, +} from "../../../../helpers"; +import { JsonSafe } from "../../../../json-safe"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "interchain_security.ccv.provider.v1"; +export interface MsgAssignConsumerKey { + /** The chain id of the consumer chain to assign a consensus public key to */ + chainId: string; + /** The validator address on the provider */ + providerAddr: string; + /** + * The consensus public key to use on the consumer. + * in json string format corresponding to proto-any, ex: + * `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` + */ + consumerKey: string; + /** Tx signer address */ + signer: string; +} +export interface MsgAssignConsumerKeyResponse {} +/** + * MsgSubmitConsumerMisbehaviour defines a message that reports a light client attack, + * also known as a misbehaviour, observed on a consumer chain + */ +export interface MsgSubmitConsumerMisbehaviour { + submitter: string; + /** + * The Misbehaviour of the consumer chain wrapping + * two conflicting IBC headers + */ + misbehaviour?: Misbehaviour; +} +export interface MsgSubmitConsumerMisbehaviourResponse {} +/** + * MsgSubmitConsumerDoubleVoting defines a message that reports + * a double signing infraction observed on a consumer chain + */ +export interface MsgSubmitConsumerDoubleVoting { + submitter: string; + /** + * The equivocation of the consumer chain wrapping + * an evidence of a validator that signed two conflicting votes + */ + duplicateVoteEvidence?: DuplicateVoteEvidence; + /** The light client header of the infraction block */ + infractionBlockHeader?: Header; +} +export interface MsgSubmitConsumerDoubleVotingResponse {} +/** MsgUpdateParams is the Msg/UpdateParams request type */ +export interface MsgUpdateParams { + /** signer is the address of the governance account. */ + authority: string; + /** params defines the x/provider parameters to update. */ + params: Params; +} +export interface MsgUpdateParamsResponse {} +/** + * MsgConsumerAddition defines the message used to spawn a new consumer chain using a v1 governance proposal. + * If it passes, then all validators on the provider chain are expected to validate + * the consumer chain at spawn time or get slashed. + * It is recommended that spawn time occurs after the proposal end time. + * + * Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon + */ +export interface MsgConsumerAddition { + /** + * the proposed chain-id of the new consumer chain, must be different from all + * other consumer chain ids of the executing provider chain. + */ + chainId: string; + /** + * the proposed initial height of new consumer chain. + * For a completely new chain, this will be {0,1}. However, it may be + * different if this is a chain that is converting to a consumer chain. + */ + initialHeight: Height; + /** + * The hash of the consumer chain genesis state without the consumer CCV + * module genesis params. It is used for off-chain confirmation of + * genesis.json validity by validators and other parties. + */ + genesisHash: Uint8Array; + /** + * The hash of the consumer chain binary that should be run by validators on + * chain initialization. It is used for off-chain confirmation of binary + * validity by validators and other parties. + */ + binaryHash: Uint8Array; + /** + * spawn time is the time on the provider chain at which the consumer chain + * genesis is finalized and all validators will be responsible for starting + * their consumer chain validator node. + */ + spawnTime: Timestamp; + /** + * Unbonding period for the consumer, + * which should be smaller than that of the provider in general. + */ + unbondingPeriod: Duration; + /** Sent CCV related IBC packets will timeout after this duration */ + ccvTimeoutPeriod: Duration; + /** Sent transfer related IBC packets will timeout after this duration */ + transferTimeoutPeriod: Duration; + /** + * The fraction of tokens allocated to the consumer redistribution address + * during distribution events. The fraction is a string representing a + * decimal number. For example "0.75" would represent 75%. + */ + consumerRedistributionFraction: string; + /** + * BlocksPerDistributionTransmission is the number of blocks between + * ibc-token-transfers from the consumer chain to the provider chain. On + * sending transmission event, `consumer_redistribution_fraction` of the + * accumulated tokens are sent to the consumer redistribution address. + */ + blocksPerDistributionTransmission: bigint; + /** + * The number of historical info entries to persist in store. + * This param is a part of the cosmos sdk staking module. In the case of + * a ccv enabled consumer chain, the ccv module acts as the staking module. + */ + historicalEntries: bigint; + /** + * The ID of a token transfer channel used for the Reward Distribution + * sub-protocol. If DistributionTransmissionChannel == "", a new transfer + * channel is created on top of the same connection as the CCV channel. + * Note that transfer_channel_id is the ID of the channel end on the consumer + * chain. it is most relevant for chains performing a sovereign to consumer + * changeover in order to maintan the existing ibc transfer channel + */ + distributionTransmissionChannel: string; + /** + * Corresponds to the percentage of validators that have to validate the chain under the Top N case. + * For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + * have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + * A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + */ + topN: number; + /** + * Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + * `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + * consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + * 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + * to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + */ + validatorsPowerCap: number; + /** + * Corresponds to the maximum number of validators that can validate a consumer chain. + * Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + */ + validatorSetCap: number; + /** + * Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + * the consumer chain. + */ + allowlist: string[]; + /** Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. */ + denylist: string[]; + /** signer address */ + authority: string; +} +/** MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages */ +export interface MsgConsumerAdditionResponse {} +/** + * MsgConsumerRemoval message contains a governance proposal on the provider chain to + * remove (and stop) a consumer chain. If it passes, all the consumer chain's + * state is removed from the provider chain. The outstanding unbonding operation + * funds are released. + * + * Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon + */ +export interface MsgConsumerRemoval { + /** the chain-id of the consumer chain to be stopped */ + chainId: string; + /** + * the time on the provider chain at which all validators are responsible to + * stop their consumer chain validator node + */ + stopTime: Timestamp; + /** signer address */ + authority: string; +} +/** MsgConsumerRemovalResponse defines response type for MsgConsumerRemoval messages */ +export interface MsgConsumerRemovalResponse {} +/** + * ChangeRewardDenomsProposal is a governance proposal on the provider chain to + * mutate the set of denoms accepted by the provider as rewards. + * + * Note: this replaces ChangeRewardDenomsProposal which is deprecated and will be removed soon + */ +export interface MsgChangeRewardDenoms { + /** the list of consumer reward denoms to add */ + denomsToAdd: string[]; + /** the list of consumer reward denoms to remove */ + denomsToRemove: string[]; + /** signer address */ + authority: string; +} +/** MsgChangeRewardDenomsResponse defines response type for MsgChangeRewardDenoms messages */ +export interface MsgChangeRewardDenomsResponse {} +export interface MsgOptIn { + /** the chain id of the consumer chain to opt in to */ + chainId: string; + /** the validator address on the provider */ + providerAddr: string; + /** + * (optional) The consensus public key to use on the consumer in json string format corresponding to proto-any, + * for example `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`. + * This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the + * consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. + */ + consumerKey: string; + /** signer address */ + signer: string; +} +export interface MsgOptInResponse {} +export interface MsgOptOut { + /** the chain id of the consumer chain to opt out from */ + chainId: string; + /** the validator address on the provider */ + providerAddr: string; + /** signer address */ + signer: string; +} +export interface MsgOptOutResponse {} +/** + * MsgSetConsumerCommissionRate allows validators to set + * a per-consumer chain commission rate + */ +export interface MsgSetConsumerCommissionRate { + /** The validator address on the provider */ + providerAddr: string; + /** The chain id of the consumer chain to set a commission rate */ + chainId: string; + /** + * The rate to charge delegators on the consumer chain, as a fraction + * TODO: migrate rate from sdk.Dec to math.LegacyDec + */ + rate: string; + /** signer address */ + signer: string; +} +export interface MsgSetConsumerCommissionRateResponse {} +/** + * MsgConsumerModification message contains a governance proposal on the provider chain to + * modify a running consumer chain. If it passes, the consumer chain's + * parameters are updated. + * + * Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon + */ +export interface MsgConsumerModification { + /** the title of the proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the chain-id of the consumer chain to be modified */ + chainId: string; + /** + * Corresponds to the percentage of validators that have to validate the chain under the Top N case. + * For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + * have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + * A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + */ + topN: number; + /** + * Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + * `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + * consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + * 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + * to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + */ + validatorsPowerCap: number; + /** + * Corresponds to the maximum number of validators that can validate a consumer chain. + * Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + */ + validatorSetCap: number; + /** + * Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + * the consumer chain. + */ + allowlist: string[]; + /** Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. */ + denylist: string[]; + /** signer address */ + authority: string; +} +export interface MsgConsumerModificationResponse {} +function createBaseMsgAssignConsumerKey(): MsgAssignConsumerKey { + return { + chainId: "", + providerAddr: "", + consumerKey: "", + signer: "", + }; +} +export const MsgAssignConsumerKey = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgAssignConsumerKey", + encode(message: MsgAssignConsumerKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddr !== "") { + writer.uint32(18).string(message.providerAddr); + } + if (message.consumerKey !== "") { + writer.uint32(26).string(message.consumerKey); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgAssignConsumerKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAssignConsumerKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddr = reader.string(); + break; + case 3: + message.consumerKey = reader.string(); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgAssignConsumerKey { + const obj = createBaseMsgAssignConsumerKey(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddr)) obj.providerAddr = String(object.providerAddr); + if (isSet(object.consumerKey)) obj.consumerKey = String(object.consumerKey); + if (isSet(object.signer)) obj.signer = String(object.signer); + return obj; + }, + toJSON(message: MsgAssignConsumerKey): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddr !== undefined && (obj.providerAddr = message.providerAddr); + message.consumerKey !== undefined && (obj.consumerKey = message.consumerKey); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgAssignConsumerKey { + const message = createBaseMsgAssignConsumerKey(); + message.chainId = object.chainId ?? ""; + message.providerAddr = object.providerAddr ?? ""; + message.consumerKey = object.consumerKey ?? ""; + message.signer = object.signer ?? ""; + return message; + }, +}; +function createBaseMsgAssignConsumerKeyResponse(): MsgAssignConsumerKeyResponse { + return {}; +} +export const MsgAssignConsumerKeyResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgAssignConsumerKeyResponse", + encode(_: MsgAssignConsumerKeyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgAssignConsumerKeyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAssignConsumerKeyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgAssignConsumerKeyResponse { + const obj = createBaseMsgAssignConsumerKeyResponse(); + return obj; + }, + toJSON(_: MsgAssignConsumerKeyResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgAssignConsumerKeyResponse { + const message = createBaseMsgAssignConsumerKeyResponse(); + return message; + }, +}; +function createBaseMsgSubmitConsumerMisbehaviour(): MsgSubmitConsumerMisbehaviour { + return { + submitter: "", + misbehaviour: undefined, + }; +} +export const MsgSubmitConsumerMisbehaviour = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviour", + encode(message: MsgSubmitConsumerMisbehaviour, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.submitter !== "") { + writer.uint32(10).string(message.submitter); + } + if (message.misbehaviour !== undefined) { + Misbehaviour.encode(message.misbehaviour, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitConsumerMisbehaviour { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitConsumerMisbehaviour(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.submitter = reader.string(); + break; + case 2: + message.misbehaviour = Misbehaviour.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitConsumerMisbehaviour { + const obj = createBaseMsgSubmitConsumerMisbehaviour(); + if (isSet(object.submitter)) obj.submitter = String(object.submitter); + if (isSet(object.misbehaviour)) obj.misbehaviour = Misbehaviour.fromJSON(object.misbehaviour); + return obj; + }, + toJSON(message: MsgSubmitConsumerMisbehaviour): JsonSafe { + const obj: any = {}; + message.submitter !== undefined && (obj.submitter = message.submitter); + message.misbehaviour !== undefined && + (obj.misbehaviour = message.misbehaviour ? Misbehaviour.toJSON(message.misbehaviour) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): MsgSubmitConsumerMisbehaviour { + const message = createBaseMsgSubmitConsumerMisbehaviour(); + message.submitter = object.submitter ?? ""; + if (object.misbehaviour !== undefined && object.misbehaviour !== null) { + message.misbehaviour = Misbehaviour.fromPartial(object.misbehaviour); + } + return message; + }, +}; +function createBaseMsgSubmitConsumerMisbehaviourResponse(): MsgSubmitConsumerMisbehaviourResponse { + return {}; +} +export const MsgSubmitConsumerMisbehaviourResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviourResponse", + encode( + _: MsgSubmitConsumerMisbehaviourResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitConsumerMisbehaviourResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitConsumerMisbehaviourResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSubmitConsumerMisbehaviourResponse { + const obj = createBaseMsgSubmitConsumerMisbehaviourResponse(); + return obj; + }, + toJSON(_: MsgSubmitConsumerMisbehaviourResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgSubmitConsumerMisbehaviourResponse { + const message = createBaseMsgSubmitConsumerMisbehaviourResponse(); + return message; + }, +}; +function createBaseMsgSubmitConsumerDoubleVoting(): MsgSubmitConsumerDoubleVoting { + return { + submitter: "", + duplicateVoteEvidence: undefined, + infractionBlockHeader: undefined, + }; +} +export const MsgSubmitConsumerDoubleVoting = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVoting", + encode(message: MsgSubmitConsumerDoubleVoting, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.submitter !== "") { + writer.uint32(10).string(message.submitter); + } + if (message.duplicateVoteEvidence !== undefined) { + DuplicateVoteEvidence.encode(message.duplicateVoteEvidence, writer.uint32(18).fork()).ldelim(); + } + if (message.infractionBlockHeader !== undefined) { + Header.encode(message.infractionBlockHeader, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitConsumerDoubleVoting { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitConsumerDoubleVoting(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.submitter = reader.string(); + break; + case 2: + message.duplicateVoteEvidence = DuplicateVoteEvidence.decode(reader, reader.uint32()); + break; + case 3: + message.infractionBlockHeader = Header.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitConsumerDoubleVoting { + const obj = createBaseMsgSubmitConsumerDoubleVoting(); + if (isSet(object.submitter)) obj.submitter = String(object.submitter); + if (isSet(object.duplicateVoteEvidence)) + obj.duplicateVoteEvidence = DuplicateVoteEvidence.fromJSON(object.duplicateVoteEvidence); + if (isSet(object.infractionBlockHeader)) + obj.infractionBlockHeader = Header.fromJSON(object.infractionBlockHeader); + return obj; + }, + toJSON(message: MsgSubmitConsumerDoubleVoting): JsonSafe { + const obj: any = {}; + message.submitter !== undefined && (obj.submitter = message.submitter); + message.duplicateVoteEvidence !== undefined && + (obj.duplicateVoteEvidence = message.duplicateVoteEvidence + ? DuplicateVoteEvidence.toJSON(message.duplicateVoteEvidence) + : undefined); + message.infractionBlockHeader !== undefined && + (obj.infractionBlockHeader = message.infractionBlockHeader + ? Header.toJSON(message.infractionBlockHeader) + : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): MsgSubmitConsumerDoubleVoting { + const message = createBaseMsgSubmitConsumerDoubleVoting(); + message.submitter = object.submitter ?? ""; + if (object.duplicateVoteEvidence !== undefined && object.duplicateVoteEvidence !== null) { + message.duplicateVoteEvidence = DuplicateVoteEvidence.fromPartial(object.duplicateVoteEvidence); + } + if (object.infractionBlockHeader !== undefined && object.infractionBlockHeader !== null) { + message.infractionBlockHeader = Header.fromPartial(object.infractionBlockHeader); + } + return message; + }, +}; +function createBaseMsgSubmitConsumerDoubleVotingResponse(): MsgSubmitConsumerDoubleVotingResponse { + return {}; +} +export const MsgSubmitConsumerDoubleVotingResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVotingResponse", + encode( + _: MsgSubmitConsumerDoubleVotingResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitConsumerDoubleVotingResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitConsumerDoubleVotingResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSubmitConsumerDoubleVotingResponse { + const obj = createBaseMsgSubmitConsumerDoubleVotingResponse(); + return obj; + }, + toJSON(_: MsgSubmitConsumerDoubleVotingResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgSubmitConsumerDoubleVotingResponse { + const message = createBaseMsgSubmitConsumerDoubleVotingResponse(); + return message; + }, +}; +function createBaseMsgUpdateParams(): MsgUpdateParams { + return { + authority: "", + params: Params.fromPartial({}), + }; +} +export const MsgUpdateParams = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgUpdateParams", + encode(message: MsgUpdateParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authority !== "") { + writer.uint32(10).string(message.authority); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateParams { + const obj = createBaseMsgUpdateParams(); + if (isSet(object.authority)) obj.authority = String(object.authority); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: MsgUpdateParams): JsonSafe { + const obj: any = {}; + message.authority !== undefined && (obj.authority = message.authority); + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateParams { + const message = createBaseMsgUpdateParams(); + message.authority = object.authority ?? ""; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, +}; +function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse { + return {}; +} +export const MsgUpdateParamsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgUpdateParamsResponse", + encode(_: MsgUpdateParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateParamsResponse { + const obj = createBaseMsgUpdateParamsResponse(); + return obj; + }, + toJSON(_: MsgUpdateParamsResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateParamsResponse { + const message = createBaseMsgUpdateParamsResponse(); + return message; + }, +}; +function createBaseMsgConsumerAddition(): MsgConsumerAddition { + return { + chainId: "", + initialHeight: Height.fromPartial({}), + genesisHash: new Uint8Array(), + binaryHash: new Uint8Array(), + spawnTime: Timestamp.fromPartial({}), + unbondingPeriod: Duration.fromPartial({}), + ccvTimeoutPeriod: Duration.fromPartial({}), + transferTimeoutPeriod: Duration.fromPartial({}), + consumerRedistributionFraction: "", + blocksPerDistributionTransmission: BigInt(0), + historicalEntries: BigInt(0), + distributionTransmissionChannel: "", + topN: 0, + validatorsPowerCap: 0, + validatorSetCap: 0, + allowlist: [], + denylist: [], + authority: "", + }; +} +export const MsgConsumerAddition = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerAddition", + encode(message: MsgConsumerAddition, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.initialHeight !== undefined) { + Height.encode(message.initialHeight, writer.uint32(18).fork()).ldelim(); + } + if (message.genesisHash.length !== 0) { + writer.uint32(26).bytes(message.genesisHash); + } + if (message.binaryHash.length !== 0) { + writer.uint32(34).bytes(message.binaryHash); + } + if (message.spawnTime !== undefined) { + Timestamp.encode(message.spawnTime, writer.uint32(42).fork()).ldelim(); + } + if (message.unbondingPeriod !== undefined) { + Duration.encode(message.unbondingPeriod, writer.uint32(50).fork()).ldelim(); + } + if (message.ccvTimeoutPeriod !== undefined) { + Duration.encode(message.ccvTimeoutPeriod, writer.uint32(58).fork()).ldelim(); + } + if (message.transferTimeoutPeriod !== undefined) { + Duration.encode(message.transferTimeoutPeriod, writer.uint32(66).fork()).ldelim(); + } + if (message.consumerRedistributionFraction !== "") { + writer.uint32(74).string(message.consumerRedistributionFraction); + } + if (message.blocksPerDistributionTransmission !== BigInt(0)) { + writer.uint32(80).int64(message.blocksPerDistributionTransmission); + } + if (message.historicalEntries !== BigInt(0)) { + writer.uint32(88).int64(message.historicalEntries); + } + if (message.distributionTransmissionChannel !== "") { + writer.uint32(98).string(message.distributionTransmissionChannel); + } + if (message.topN !== 0) { + writer.uint32(104).uint32(message.topN); + } + if (message.validatorsPowerCap !== 0) { + writer.uint32(112).uint32(message.validatorsPowerCap); + } + if (message.validatorSetCap !== 0) { + writer.uint32(120).uint32(message.validatorSetCap); + } + for (const v of message.allowlist) { + writer.uint32(130).string(v!); + } + for (const v of message.denylist) { + writer.uint32(138).string(v!); + } + if (message.authority !== "") { + writer.uint32(146).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerAddition { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerAddition(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.initialHeight = Height.decode(reader, reader.uint32()); + break; + case 3: + message.genesisHash = reader.bytes(); + break; + case 4: + message.binaryHash = reader.bytes(); + break; + case 5: + message.spawnTime = Timestamp.decode(reader, reader.uint32()); + break; + case 6: + message.unbondingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 7: + message.ccvTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 8: + message.transferTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 9: + message.consumerRedistributionFraction = reader.string(); + break; + case 10: + message.blocksPerDistributionTransmission = reader.int64(); + break; + case 11: + message.historicalEntries = reader.int64(); + break; + case 12: + message.distributionTransmissionChannel = reader.string(); + break; + case 13: + message.topN = reader.uint32(); + break; + case 14: + message.validatorsPowerCap = reader.uint32(); + break; + case 15: + message.validatorSetCap = reader.uint32(); + break; + case 16: + message.allowlist.push(reader.string()); + break; + case 17: + message.denylist.push(reader.string()); + break; + case 18: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgConsumerAddition { + const obj = createBaseMsgConsumerAddition(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.initialHeight)) obj.initialHeight = Height.fromJSON(object.initialHeight); + if (isSet(object.genesisHash)) obj.genesisHash = bytesFromBase64(object.genesisHash); + if (isSet(object.binaryHash)) obj.binaryHash = bytesFromBase64(object.binaryHash); + if (isSet(object.spawnTime)) obj.spawnTime = fromJsonTimestamp(object.spawnTime); + if (isSet(object.unbondingPeriod)) obj.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod); + if (isSet(object.ccvTimeoutPeriod)) obj.ccvTimeoutPeriod = Duration.fromJSON(object.ccvTimeoutPeriod); + if (isSet(object.transferTimeoutPeriod)) + obj.transferTimeoutPeriod = Duration.fromJSON(object.transferTimeoutPeriod); + if (isSet(object.consumerRedistributionFraction)) + obj.consumerRedistributionFraction = String(object.consumerRedistributionFraction); + if (isSet(object.blocksPerDistributionTransmission)) + obj.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + if (isSet(object.historicalEntries)) obj.historicalEntries = BigInt(object.historicalEntries.toString()); + if (isSet(object.distributionTransmissionChannel)) + obj.distributionTransmissionChannel = String(object.distributionTransmissionChannel); + if (isSet(object.topN)) obj.topN = Number(object.topN); + if (isSet(object.validatorsPowerCap)) obj.validatorsPowerCap = Number(object.validatorsPowerCap); + if (isSet(object.validatorSetCap)) obj.validatorSetCap = Number(object.validatorSetCap); + if (Array.isArray(object?.allowlist)) obj.allowlist = object.allowlist.map((e: any) => String(e)); + if (Array.isArray(object?.denylist)) obj.denylist = object.denylist.map((e: any) => String(e)); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgConsumerAddition): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.initialHeight !== undefined && + (obj.initialHeight = message.initialHeight ? Height.toJSON(message.initialHeight) : undefined); + message.genesisHash !== undefined && + (obj.genesisHash = base64FromBytes( + message.genesisHash !== undefined ? message.genesisHash : new Uint8Array(), + )); + message.binaryHash !== undefined && + (obj.binaryHash = base64FromBytes( + message.binaryHash !== undefined ? message.binaryHash : new Uint8Array(), + )); + message.spawnTime !== undefined && (obj.spawnTime = fromTimestamp(message.spawnTime).toISOString()); + message.unbondingPeriod !== undefined && + (obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined); + message.ccvTimeoutPeriod !== undefined && + (obj.ccvTimeoutPeriod = message.ccvTimeoutPeriod + ? Duration.toJSON(message.ccvTimeoutPeriod) + : undefined); + message.transferTimeoutPeriod !== undefined && + (obj.transferTimeoutPeriod = message.transferTimeoutPeriod + ? Duration.toJSON(message.transferTimeoutPeriod) + : undefined); + message.consumerRedistributionFraction !== undefined && + (obj.consumerRedistributionFraction = message.consumerRedistributionFraction); + message.blocksPerDistributionTransmission !== undefined && + (obj.blocksPerDistributionTransmission = ( + message.blocksPerDistributionTransmission || BigInt(0) + ).toString()); + message.historicalEntries !== undefined && + (obj.historicalEntries = (message.historicalEntries || BigInt(0)).toString()); + message.distributionTransmissionChannel !== undefined && + (obj.distributionTransmissionChannel = message.distributionTransmissionChannel); + message.topN !== undefined && (obj.topN = Math.round(message.topN)); + message.validatorsPowerCap !== undefined && + (obj.validatorsPowerCap = Math.round(message.validatorsPowerCap)); + message.validatorSetCap !== undefined && (obj.validatorSetCap = Math.round(message.validatorSetCap)); + if (message.allowlist) { + obj.allowlist = message.allowlist.map((e) => e); + } else { + obj.allowlist = []; + } + if (message.denylist) { + obj.denylist = message.denylist.map((e) => e); + } else { + obj.denylist = []; + } + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial, I>>(object: I): MsgConsumerAddition { + const message = createBaseMsgConsumerAddition(); + message.chainId = object.chainId ?? ""; + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = Height.fromPartial(object.initialHeight); + } + message.genesisHash = object.genesisHash ?? new Uint8Array(); + message.binaryHash = object.binaryHash ?? new Uint8Array(); + if (object.spawnTime !== undefined && object.spawnTime !== null) { + message.spawnTime = Timestamp.fromPartial(object.spawnTime); + } + if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) { + message.unbondingPeriod = Duration.fromPartial(object.unbondingPeriod); + } + if (object.ccvTimeoutPeriod !== undefined && object.ccvTimeoutPeriod !== null) { + message.ccvTimeoutPeriod = Duration.fromPartial(object.ccvTimeoutPeriod); + } + if (object.transferTimeoutPeriod !== undefined && object.transferTimeoutPeriod !== null) { + message.transferTimeoutPeriod = Duration.fromPartial(object.transferTimeoutPeriod); + } + message.consumerRedistributionFraction = object.consumerRedistributionFraction ?? ""; + if ( + object.blocksPerDistributionTransmission !== undefined && + object.blocksPerDistributionTransmission !== null + ) { + message.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + } + if (object.historicalEntries !== undefined && object.historicalEntries !== null) { + message.historicalEntries = BigInt(object.historicalEntries.toString()); + } + message.distributionTransmissionChannel = object.distributionTransmissionChannel ?? ""; + message.topN = object.topN ?? 0; + message.validatorsPowerCap = object.validatorsPowerCap ?? 0; + message.validatorSetCap = object.validatorSetCap ?? 0; + message.allowlist = object.allowlist?.map((e) => e) || []; + message.denylist = object.denylist?.map((e) => e) || []; + message.authority = object.authority ?? ""; + return message; + }, +}; +function createBaseMsgConsumerAdditionResponse(): MsgConsumerAdditionResponse { + return {}; +} +export const MsgConsumerAdditionResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerAdditionResponse", + encode(_: MsgConsumerAdditionResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerAdditionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerAdditionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgConsumerAdditionResponse { + const obj = createBaseMsgConsumerAdditionResponse(); + return obj; + }, + toJSON(_: MsgConsumerAdditionResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgConsumerAdditionResponse { + const message = createBaseMsgConsumerAdditionResponse(); + return message; + }, +}; +function createBaseMsgConsumerRemoval(): MsgConsumerRemoval { + return { + chainId: "", + stopTime: Timestamp.fromPartial({}), + authority: "", + }; +} +export const MsgConsumerRemoval = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerRemoval", + encode(message: MsgConsumerRemoval, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.stopTime !== undefined) { + Timestamp.encode(message.stopTime, writer.uint32(18).fork()).ldelim(); + } + if (message.authority !== "") { + writer.uint32(26).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerRemoval { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerRemoval(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.stopTime = Timestamp.decode(reader, reader.uint32()); + break; + case 3: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgConsumerRemoval { + const obj = createBaseMsgConsumerRemoval(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.stopTime)) obj.stopTime = fromJsonTimestamp(object.stopTime); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgConsumerRemoval): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.stopTime !== undefined && (obj.stopTime = fromTimestamp(message.stopTime).toISOString()); + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial, I>>(object: I): MsgConsumerRemoval { + const message = createBaseMsgConsumerRemoval(); + message.chainId = object.chainId ?? ""; + if (object.stopTime !== undefined && object.stopTime !== null) { + message.stopTime = Timestamp.fromPartial(object.stopTime); + } + message.authority = object.authority ?? ""; + return message; + }, +}; +function createBaseMsgConsumerRemovalResponse(): MsgConsumerRemovalResponse { + return {}; +} +export const MsgConsumerRemovalResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerRemovalResponse", + encode(_: MsgConsumerRemovalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerRemovalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerRemovalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgConsumerRemovalResponse { + const obj = createBaseMsgConsumerRemovalResponse(); + return obj; + }, + toJSON(_: MsgConsumerRemovalResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgConsumerRemovalResponse { + const message = createBaseMsgConsumerRemovalResponse(); + return message; + }, +}; +function createBaseMsgChangeRewardDenoms(): MsgChangeRewardDenoms { + return { + denomsToAdd: [], + denomsToRemove: [], + authority: "", + }; +} +export const MsgChangeRewardDenoms = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgChangeRewardDenoms", + encode(message: MsgChangeRewardDenoms, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.denomsToAdd) { + writer.uint32(10).string(v!); + } + for (const v of message.denomsToRemove) { + writer.uint32(18).string(v!); + } + if (message.authority !== "") { + writer.uint32(26).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgChangeRewardDenoms { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgChangeRewardDenoms(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomsToAdd.push(reader.string()); + break; + case 2: + message.denomsToRemove.push(reader.string()); + break; + case 3: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgChangeRewardDenoms { + const obj = createBaseMsgChangeRewardDenoms(); + if (Array.isArray(object?.denomsToAdd)) obj.denomsToAdd = object.denomsToAdd.map((e: any) => String(e)); + if (Array.isArray(object?.denomsToRemove)) + obj.denomsToRemove = object.denomsToRemove.map((e: any) => String(e)); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgChangeRewardDenoms): JsonSafe { + const obj: any = {}; + if (message.denomsToAdd) { + obj.denomsToAdd = message.denomsToAdd.map((e) => e); + } else { + obj.denomsToAdd = []; + } + if (message.denomsToRemove) { + obj.denomsToRemove = message.denomsToRemove.map((e) => e); + } else { + obj.denomsToRemove = []; + } + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial, I>>(object: I): MsgChangeRewardDenoms { + const message = createBaseMsgChangeRewardDenoms(); + message.denomsToAdd = object.denomsToAdd?.map((e) => e) || []; + message.denomsToRemove = object.denomsToRemove?.map((e) => e) || []; + message.authority = object.authority ?? ""; + return message; + }, +}; +function createBaseMsgChangeRewardDenomsResponse(): MsgChangeRewardDenomsResponse { + return {}; +} +export const MsgChangeRewardDenomsResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgChangeRewardDenomsResponse", + encode(_: MsgChangeRewardDenomsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgChangeRewardDenomsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgChangeRewardDenomsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgChangeRewardDenomsResponse { + const obj = createBaseMsgChangeRewardDenomsResponse(); + return obj; + }, + toJSON(_: MsgChangeRewardDenomsResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgChangeRewardDenomsResponse { + const message = createBaseMsgChangeRewardDenomsResponse(); + return message; + }, +}; +function createBaseMsgOptIn(): MsgOptIn { + return { + chainId: "", + providerAddr: "", + consumerKey: "", + signer: "", + }; +} +export const MsgOptIn = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgOptIn", + encode(message: MsgOptIn, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddr !== "") { + writer.uint32(18).string(message.providerAddr); + } + if (message.consumerKey !== "") { + writer.uint32(26).string(message.consumerKey); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgOptIn { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgOptIn(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddr = reader.string(); + break; + case 3: + message.consumerKey = reader.string(); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgOptIn { + const obj = createBaseMsgOptIn(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddr)) obj.providerAddr = String(object.providerAddr); + if (isSet(object.consumerKey)) obj.consumerKey = String(object.consumerKey); + if (isSet(object.signer)) obj.signer = String(object.signer); + return obj; + }, + toJSON(message: MsgOptIn): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddr !== undefined && (obj.providerAddr = message.providerAddr); + message.consumerKey !== undefined && (obj.consumerKey = message.consumerKey); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgOptIn { + const message = createBaseMsgOptIn(); + message.chainId = object.chainId ?? ""; + message.providerAddr = object.providerAddr ?? ""; + message.consumerKey = object.consumerKey ?? ""; + message.signer = object.signer ?? ""; + return message; + }, +}; +function createBaseMsgOptInResponse(): MsgOptInResponse { + return {}; +} +export const MsgOptInResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgOptInResponse", + encode(_: MsgOptInResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgOptInResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgOptInResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgOptInResponse { + const obj = createBaseMsgOptInResponse(); + return obj; + }, + toJSON(_: MsgOptInResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgOptInResponse { + const message = createBaseMsgOptInResponse(); + return message; + }, +}; +function createBaseMsgOptOut(): MsgOptOut { + return { + chainId: "", + providerAddr: "", + signer: "", + }; +} +export const MsgOptOut = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgOptOut", + encode(message: MsgOptOut, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chainId !== "") { + writer.uint32(10).string(message.chainId); + } + if (message.providerAddr !== "") { + writer.uint32(18).string(message.providerAddr); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgOptOut { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgOptOut(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chainId = reader.string(); + break; + case 2: + message.providerAddr = reader.string(); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgOptOut { + const obj = createBaseMsgOptOut(); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.providerAddr)) obj.providerAddr = String(object.providerAddr); + if (isSet(object.signer)) obj.signer = String(object.signer); + return obj; + }, + toJSON(message: MsgOptOut): JsonSafe { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.providerAddr !== undefined && (obj.providerAddr = message.providerAddr); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgOptOut { + const message = createBaseMsgOptOut(); + message.chainId = object.chainId ?? ""; + message.providerAddr = object.providerAddr ?? ""; + message.signer = object.signer ?? ""; + return message; + }, +}; +function createBaseMsgOptOutResponse(): MsgOptOutResponse { + return {}; +} +export const MsgOptOutResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgOptOutResponse", + encode(_: MsgOptOutResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgOptOutResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgOptOutResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgOptOutResponse { + const obj = createBaseMsgOptOutResponse(); + return obj; + }, + toJSON(_: MsgOptOutResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgOptOutResponse { + const message = createBaseMsgOptOutResponse(); + return message; + }, +}; +function createBaseMsgSetConsumerCommissionRate(): MsgSetConsumerCommissionRate { + return { + providerAddr: "", + chainId: "", + rate: "", + signer: "", + }; +} +export const MsgSetConsumerCommissionRate = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRate", + encode(message: MsgSetConsumerCommissionRate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.providerAddr !== "") { + writer.uint32(10).string(message.providerAddr); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.rate !== "") { + writer.uint32(26).string(Decimal.fromUserInput(message.rate, 18).atomics); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSetConsumerCommissionRate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetConsumerCommissionRate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerAddr = reader.string(); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.rate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSetConsumerCommissionRate { + const obj = createBaseMsgSetConsumerCommissionRate(); + if (isSet(object.providerAddr)) obj.providerAddr = String(object.providerAddr); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.rate)) obj.rate = String(object.rate); + if (isSet(object.signer)) obj.signer = String(object.signer); + return obj; + }, + toJSON(message: MsgSetConsumerCommissionRate): JsonSafe { + const obj: any = {}; + message.providerAddr !== undefined && (obj.providerAddr = message.providerAddr); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.rate !== undefined && (obj.rate = message.rate); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>( + object: I, + ): MsgSetConsumerCommissionRate { + const message = createBaseMsgSetConsumerCommissionRate(); + message.providerAddr = object.providerAddr ?? ""; + message.chainId = object.chainId ?? ""; + message.rate = object.rate ?? ""; + message.signer = object.signer ?? ""; + return message; + }, +}; +function createBaseMsgSetConsumerCommissionRateResponse(): MsgSetConsumerCommissionRateResponse { + return {}; +} +export const MsgSetConsumerCommissionRateResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRateResponse", + encode( + _: MsgSetConsumerCommissionRateResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSetConsumerCommissionRateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetConsumerCommissionRateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSetConsumerCommissionRateResponse { + const obj = createBaseMsgSetConsumerCommissionRateResponse(); + return obj; + }, + toJSON(_: MsgSetConsumerCommissionRateResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgSetConsumerCommissionRateResponse { + const message = createBaseMsgSetConsumerCommissionRateResponse(); + return message; + }, +}; +function createBaseMsgConsumerModification(): MsgConsumerModification { + return { + title: "", + description: "", + chainId: "", + topN: 0, + validatorsPowerCap: 0, + validatorSetCap: 0, + allowlist: [], + denylist: [], + authority: "", + }; +} +export const MsgConsumerModification = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerModification", + encode(message: MsgConsumerModification, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (message.topN !== 0) { + writer.uint32(32).uint32(message.topN); + } + if (message.validatorsPowerCap !== 0) { + writer.uint32(40).uint32(message.validatorsPowerCap); + } + if (message.validatorSetCap !== 0) { + writer.uint32(48).uint32(message.validatorSetCap); + } + for (const v of message.allowlist) { + writer.uint32(58).string(v!); + } + for (const v of message.denylist) { + writer.uint32(66).string(v!); + } + if (message.authority !== "") { + writer.uint32(74).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerModification { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerModification(); + 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.chainId = reader.string(); + break; + case 4: + message.topN = reader.uint32(); + break; + case 5: + message.validatorsPowerCap = reader.uint32(); + break; + case 6: + message.validatorSetCap = reader.uint32(); + break; + case 7: + message.allowlist.push(reader.string()); + break; + case 8: + message.denylist.push(reader.string()); + break; + case 9: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgConsumerModification { + const obj = createBaseMsgConsumerModification(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.topN)) obj.topN = Number(object.topN); + if (isSet(object.validatorsPowerCap)) obj.validatorsPowerCap = Number(object.validatorsPowerCap); + if (isSet(object.validatorSetCap)) obj.validatorSetCap = Number(object.validatorSetCap); + if (Array.isArray(object?.allowlist)) obj.allowlist = object.allowlist.map((e: any) => String(e)); + if (Array.isArray(object?.denylist)) obj.denylist = object.denylist.map((e: any) => String(e)); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgConsumerModification): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.topN !== undefined && (obj.topN = Math.round(message.topN)); + message.validatorsPowerCap !== undefined && + (obj.validatorsPowerCap = Math.round(message.validatorsPowerCap)); + message.validatorSetCap !== undefined && (obj.validatorSetCap = Math.round(message.validatorSetCap)); + if (message.allowlist) { + obj.allowlist = message.allowlist.map((e) => e); + } else { + obj.allowlist = []; + } + if (message.denylist) { + obj.denylist = message.denylist.map((e) => e); + } else { + obj.denylist = []; + } + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial, I>>(object: I): MsgConsumerModification { + const message = createBaseMsgConsumerModification(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.chainId = object.chainId ?? ""; + message.topN = object.topN ?? 0; + message.validatorsPowerCap = object.validatorsPowerCap ?? 0; + message.validatorSetCap = object.validatorSetCap ?? 0; + message.allowlist = object.allowlist?.map((e) => e) || []; + message.denylist = object.denylist?.map((e) => e) || []; + message.authority = object.authority ?? ""; + return message; + }, +}; +function createBaseMsgConsumerModificationResponse(): MsgConsumerModificationResponse { + return {}; +} +export const MsgConsumerModificationResponse = { + typeUrl: "/interchain_security.ccv.provider.v1.MsgConsumerModificationResponse", + encode(_: MsgConsumerModificationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConsumerModificationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConsumerModificationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgConsumerModificationResponse { + const obj = createBaseMsgConsumerModificationResponse(); + return obj; + }, + toJSON(_: MsgConsumerModificationResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( + _: I, + ): MsgConsumerModificationResponse { + const message = createBaseMsgConsumerModificationResponse(); + return message; + }, +}; diff --git a/src/interchain_security/ccv/v1/shared_consumer.ts b/src/interchain_security/ccv/v1/shared_consumer.ts new file mode 100644 index 0000000..f613db3 --- /dev/null +++ b/src/interchain_security/ccv/v1/shared_consumer.ts @@ -0,0 +1,459 @@ +/* eslint-disable */ +import { Duration } from "../../../google/protobuf/duration"; +import { ClientState, ConsensusState } from "../../../ibc/lightclients/tendermint/v1/tendermint"; +import { ValidatorUpdate } from "../../../tendermint/abci/types"; +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; +import { JsonSafe } from "../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.v1"; +/** + * ConsumerParams defines the parameters for CCV consumer module. + * + * Note this type is referenced in both the consumer and provider CCV modules, + * and persisted on the provider, see MakeConsumerGenesis and + * SetConsumerGenesis. + */ +export interface ConsumerParams { + /** + * TODO: Remove enabled flag and find a better way to setup integration tests + * See: https://github.com/cosmos/interchain-security/issues/339 + */ + enabled: boolean; + /** + * Distribution Params + * Number of blocks between ibc-token-transfers from the consumer chain to + * the provider chain. Note that at this transmission event a fraction of + * the accumulated tokens are divided and sent consumer redistribution + * address. + */ + blocksPerDistributionTransmission: bigint; + /** + * Channel, and provider-chain receiving address to send distribution token + * transfers over. These parameters is auto-set during the consumer <-> + * provider handshake procedure. + */ + distributionTransmissionChannel: string; + providerFeePoolAddrStr: string; + /** Sent CCV related IBC packets will timeout after this duration */ + ccvTimeoutPeriod: Duration; + /** Sent transfer related IBC packets will timeout after this duration */ + transferTimeoutPeriod: Duration; + /** + * The fraction of tokens allocated to the consumer redistribution address + * during distribution events. The fraction is a string representing a + * decimal number. For example "0.75" would represent 75%. + */ + consumerRedistributionFraction: string; + /** + * The number of historical info entries to persist in store. + * This param is a part of the cosmos sdk staking module. In the case of + * a ccv enabled consumer chain, the ccv module acts as the staking module. + */ + historicalEntries: bigint; + /** + * Unbonding period for the consumer, + * which should be smaller than that of the provider in general. + */ + unbondingPeriod: Duration; + /** !!! DEPRECATED !!! soft_opt_out_threshold is deprecated. see docs/docs/adrs/adr-015-partial-set-security.md */ + /** @deprecated */ + softOptOutThreshold: string; + /** + * Reward denoms. These are the denominations which are allowed to be sent to + * the provider as rewards. + */ + rewardDenoms: string[]; + /** + * Provider-originated reward denoms. These are denoms coming from the + * provider which are allowed to be used as rewards. e.g. "uatom" + */ + providerRewardDenoms: string[]; + /** The period after which a consumer can retry sending a throttled packet. */ + retryDelayPeriod: Duration; +} +/** + * ConsumerGenesisState defines shared genesis information between provider and + * consumer + */ +export interface ConsumerGenesisState { + params: ConsumerParams; + provider: ProviderInfo; + /** true for new chain, false for chain restart. */ + newChain: boolean; +} +/** + * ProviderInfo defines all information a consumer needs from a provider + * Shared data type between provider and consumer + */ +export interface ProviderInfo { + /** ProviderClientState filled in on new chain, nil on restart. */ + clientState?: ClientState; + /** ProviderConsensusState filled in on new chain, nil on restart. */ + consensusState?: ConsensusState; + /** InitialValset filled in on new chain and on restart. */ + initialValSet: ValidatorUpdate[]; +} +function createBaseConsumerParams(): ConsumerParams { + return { + enabled: false, + blocksPerDistributionTransmission: BigInt(0), + distributionTransmissionChannel: "", + providerFeePoolAddrStr: "", + ccvTimeoutPeriod: Duration.fromPartial({}), + transferTimeoutPeriod: Duration.fromPartial({}), + consumerRedistributionFraction: "", + historicalEntries: BigInt(0), + unbondingPeriod: Duration.fromPartial({}), + softOptOutThreshold: "", + rewardDenoms: [], + providerRewardDenoms: [], + retryDelayPeriod: Duration.fromPartial({}), + }; +} +export const ConsumerParams = { + typeUrl: "/interchain_security.ccv.v1.ConsumerParams", + encode(message: ConsumerParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enabled === true) { + writer.uint32(8).bool(message.enabled); + } + if (message.blocksPerDistributionTransmission !== BigInt(0)) { + writer.uint32(16).int64(message.blocksPerDistributionTransmission); + } + if (message.distributionTransmissionChannel !== "") { + writer.uint32(26).string(message.distributionTransmissionChannel); + } + if (message.providerFeePoolAddrStr !== "") { + writer.uint32(34).string(message.providerFeePoolAddrStr); + } + if (message.ccvTimeoutPeriod !== undefined) { + Duration.encode(message.ccvTimeoutPeriod, writer.uint32(42).fork()).ldelim(); + } + if (message.transferTimeoutPeriod !== undefined) { + Duration.encode(message.transferTimeoutPeriod, writer.uint32(50).fork()).ldelim(); + } + if (message.consumerRedistributionFraction !== "") { + writer.uint32(58).string(message.consumerRedistributionFraction); + } + if (message.historicalEntries !== BigInt(0)) { + writer.uint32(64).int64(message.historicalEntries); + } + if (message.unbondingPeriod !== undefined) { + Duration.encode(message.unbondingPeriod, writer.uint32(74).fork()).ldelim(); + } + if (message.softOptOutThreshold !== "") { + writer.uint32(82).string(message.softOptOutThreshold); + } + for (const v of message.rewardDenoms) { + writer.uint32(90).string(v!); + } + for (const v of message.providerRewardDenoms) { + writer.uint32(98).string(v!); + } + if (message.retryDelayPeriod !== undefined) { + Duration.encode(message.retryDelayPeriod, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enabled = reader.bool(); + break; + case 2: + message.blocksPerDistributionTransmission = reader.int64(); + break; + case 3: + message.distributionTransmissionChannel = reader.string(); + break; + case 4: + message.providerFeePoolAddrStr = reader.string(); + break; + case 5: + message.ccvTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 6: + message.transferTimeoutPeriod = Duration.decode(reader, reader.uint32()); + break; + case 7: + message.consumerRedistributionFraction = reader.string(); + break; + case 8: + message.historicalEntries = reader.int64(); + break; + case 9: + message.unbondingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 10: + message.softOptOutThreshold = reader.string(); + break; + case 11: + message.rewardDenoms.push(reader.string()); + break; + case 12: + message.providerRewardDenoms.push(reader.string()); + break; + case 13: + message.retryDelayPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerParams { + const obj = createBaseConsumerParams(); + if (isSet(object.enabled)) obj.enabled = Boolean(object.enabled); + if (isSet(object.blocksPerDistributionTransmission)) + obj.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + if (isSet(object.distributionTransmissionChannel)) + obj.distributionTransmissionChannel = String(object.distributionTransmissionChannel); + if (isSet(object.providerFeePoolAddrStr)) + obj.providerFeePoolAddrStr = String(object.providerFeePoolAddrStr); + if (isSet(object.ccvTimeoutPeriod)) obj.ccvTimeoutPeriod = Duration.fromJSON(object.ccvTimeoutPeriod); + if (isSet(object.transferTimeoutPeriod)) + obj.transferTimeoutPeriod = Duration.fromJSON(object.transferTimeoutPeriod); + if (isSet(object.consumerRedistributionFraction)) + obj.consumerRedistributionFraction = String(object.consumerRedistributionFraction); + if (isSet(object.historicalEntries)) obj.historicalEntries = BigInt(object.historicalEntries.toString()); + if (isSet(object.unbondingPeriod)) obj.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod); + if (isSet(object.softOptOutThreshold)) obj.softOptOutThreshold = String(object.softOptOutThreshold); + if (Array.isArray(object?.rewardDenoms)) + obj.rewardDenoms = object.rewardDenoms.map((e: any) => String(e)); + if (Array.isArray(object?.providerRewardDenoms)) + obj.providerRewardDenoms = object.providerRewardDenoms.map((e: any) => String(e)); + if (isSet(object.retryDelayPeriod)) obj.retryDelayPeriod = Duration.fromJSON(object.retryDelayPeriod); + return obj; + }, + toJSON(message: ConsumerParams): JsonSafe { + const obj: any = {}; + message.enabled !== undefined && (obj.enabled = message.enabled); + message.blocksPerDistributionTransmission !== undefined && + (obj.blocksPerDistributionTransmission = ( + message.blocksPerDistributionTransmission || BigInt(0) + ).toString()); + message.distributionTransmissionChannel !== undefined && + (obj.distributionTransmissionChannel = message.distributionTransmissionChannel); + message.providerFeePoolAddrStr !== undefined && + (obj.providerFeePoolAddrStr = message.providerFeePoolAddrStr); + message.ccvTimeoutPeriod !== undefined && + (obj.ccvTimeoutPeriod = message.ccvTimeoutPeriod + ? Duration.toJSON(message.ccvTimeoutPeriod) + : undefined); + message.transferTimeoutPeriod !== undefined && + (obj.transferTimeoutPeriod = message.transferTimeoutPeriod + ? Duration.toJSON(message.transferTimeoutPeriod) + : undefined); + message.consumerRedistributionFraction !== undefined && + (obj.consumerRedistributionFraction = message.consumerRedistributionFraction); + message.historicalEntries !== undefined && + (obj.historicalEntries = (message.historicalEntries || BigInt(0)).toString()); + message.unbondingPeriod !== undefined && + (obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined); + message.softOptOutThreshold !== undefined && (obj.softOptOutThreshold = message.softOptOutThreshold); + if (message.rewardDenoms) { + obj.rewardDenoms = message.rewardDenoms.map((e) => e); + } else { + obj.rewardDenoms = []; + } + if (message.providerRewardDenoms) { + obj.providerRewardDenoms = message.providerRewardDenoms.map((e) => e); + } else { + obj.providerRewardDenoms = []; + } + message.retryDelayPeriod !== undefined && + (obj.retryDelayPeriod = message.retryDelayPeriod + ? Duration.toJSON(message.retryDelayPeriod) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConsumerParams { + const message = createBaseConsumerParams(); + message.enabled = object.enabled ?? false; + if ( + object.blocksPerDistributionTransmission !== undefined && + object.blocksPerDistributionTransmission !== null + ) { + message.blocksPerDistributionTransmission = BigInt(object.blocksPerDistributionTransmission.toString()); + } + message.distributionTransmissionChannel = object.distributionTransmissionChannel ?? ""; + message.providerFeePoolAddrStr = object.providerFeePoolAddrStr ?? ""; + if (object.ccvTimeoutPeriod !== undefined && object.ccvTimeoutPeriod !== null) { + message.ccvTimeoutPeriod = Duration.fromPartial(object.ccvTimeoutPeriod); + } + if (object.transferTimeoutPeriod !== undefined && object.transferTimeoutPeriod !== null) { + message.transferTimeoutPeriod = Duration.fromPartial(object.transferTimeoutPeriod); + } + message.consumerRedistributionFraction = object.consumerRedistributionFraction ?? ""; + if (object.historicalEntries !== undefined && object.historicalEntries !== null) { + message.historicalEntries = BigInt(object.historicalEntries.toString()); + } + if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) { + message.unbondingPeriod = Duration.fromPartial(object.unbondingPeriod); + } + message.softOptOutThreshold = object.softOptOutThreshold ?? ""; + message.rewardDenoms = object.rewardDenoms?.map((e) => e) || []; + message.providerRewardDenoms = object.providerRewardDenoms?.map((e) => e) || []; + if (object.retryDelayPeriod !== undefined && object.retryDelayPeriod !== null) { + message.retryDelayPeriod = Duration.fromPartial(object.retryDelayPeriod); + } + return message; + }, +}; +function createBaseConsumerGenesisState(): ConsumerGenesisState { + return { + params: ConsumerParams.fromPartial({}), + provider: ProviderInfo.fromPartial({}), + newChain: false, + }; +} +export const ConsumerGenesisState = { + typeUrl: "/interchain_security.ccv.v1.ConsumerGenesisState", + encode(message: ConsumerGenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + ConsumerParams.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.provider !== undefined) { + ProviderInfo.encode(message.provider, writer.uint32(18).fork()).ldelim(); + } + if (message.newChain === true) { + writer.uint32(24).bool(message.newChain); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerGenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = ConsumerParams.decode(reader, reader.uint32()); + break; + case 2: + message.provider = ProviderInfo.decode(reader, reader.uint32()); + break; + case 3: + message.newChain = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerGenesisState { + const obj = createBaseConsumerGenesisState(); + if (isSet(object.params)) obj.params = ConsumerParams.fromJSON(object.params); + if (isSet(object.provider)) obj.provider = ProviderInfo.fromJSON(object.provider); + if (isSet(object.newChain)) obj.newChain = Boolean(object.newChain); + return obj; + }, + toJSON(message: ConsumerGenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? ConsumerParams.toJSON(message.params) : undefined); + message.provider !== undefined && + (obj.provider = message.provider ? ProviderInfo.toJSON(message.provider) : undefined); + message.newChain !== undefined && (obj.newChain = message.newChain); + return obj; + }, + fromPartial, I>>(object: I): ConsumerGenesisState { + const message = createBaseConsumerGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = ConsumerParams.fromPartial(object.params); + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = ProviderInfo.fromPartial(object.provider); + } + message.newChain = object.newChain ?? false; + return message; + }, +}; +function createBaseProviderInfo(): ProviderInfo { + return { + clientState: undefined, + consensusState: undefined, + initialValSet: [], + }; +} +export const ProviderInfo = { + typeUrl: "/interchain_security.ccv.v1.ProviderInfo", + encode(message: ProviderInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.clientState !== undefined) { + ClientState.encode(message.clientState, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + ConsensusState.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.initialValSet) { + ValidatorUpdate.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProviderInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProviderInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientState = ClientState.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = ConsensusState.decode(reader, reader.uint32()); + break; + case 3: + message.initialValSet.push(ValidatorUpdate.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProviderInfo { + const obj = createBaseProviderInfo(); + if (isSet(object.clientState)) obj.clientState = ClientState.fromJSON(object.clientState); + if (isSet(object.consensusState)) obj.consensusState = ConsensusState.fromJSON(object.consensusState); + if (Array.isArray(object?.initialValSet)) + obj.initialValSet = object.initialValSet.map((e: any) => ValidatorUpdate.fromJSON(e)); + return obj; + }, + toJSON(message: ProviderInfo): JsonSafe { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState ? ClientState.toJSON(message.clientState) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? ConsensusState.toJSON(message.consensusState) + : undefined); + if (message.initialValSet) { + obj.initialValSet = message.initialValSet.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.initialValSet = []; + } + return obj; + }, + fromPartial, I>>(object: I): ProviderInfo { + const message = createBaseProviderInfo(); + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = ClientState.fromPartial(object.clientState); + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = ConsensusState.fromPartial(object.consensusState); + } + message.initialValSet = object.initialValSet?.map((e) => ValidatorUpdate.fromPartial(e)) || []; + return message; + }, +}; diff --git a/src/interchain_security/ccv/v1/wire.ts b/src/interchain_security/ccv/v1/wire.ts new file mode 100644 index 0000000..eadae4b --- /dev/null +++ b/src/interchain_security/ccv/v1/wire.ts @@ -0,0 +1,642 @@ +/* eslint-disable */ +import { ValidatorUpdate, Validator } from "../../../tendermint/abci/types"; +import { Infraction, infractionFromJSON, infractionToJSON } from "../../../cosmos/staking/v1beta1/staking"; +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; +import { JsonSafe } from "../../../json-safe"; +export const protobufPackage = "interchain_security.ccv.v1"; +/** ConsumerPacketType indicates interchain security specific packet types. */ +export enum ConsumerPacketDataType { + /** CONSUMER_PACKET_TYPE_UNSPECIFIED - UNSPECIFIED packet type */ + CONSUMER_PACKET_TYPE_UNSPECIFIED = 0, + /** CONSUMER_PACKET_TYPE_SLASH - Slash packet */ + CONSUMER_PACKET_TYPE_SLASH = 1, + /** CONSUMER_PACKET_TYPE_VSCM - VSCMatured packet */ + CONSUMER_PACKET_TYPE_VSCM = 2, + UNRECOGNIZED = -1, +} +export function consumerPacketDataTypeFromJSON(object: any): ConsumerPacketDataType { + switch (object) { + case 0: + case "CONSUMER_PACKET_TYPE_UNSPECIFIED": + return ConsumerPacketDataType.CONSUMER_PACKET_TYPE_UNSPECIFIED; + case 1: + case "CONSUMER_PACKET_TYPE_SLASH": + return ConsumerPacketDataType.CONSUMER_PACKET_TYPE_SLASH; + case 2: + case "CONSUMER_PACKET_TYPE_VSCM": + return ConsumerPacketDataType.CONSUMER_PACKET_TYPE_VSCM; + case -1: + case "UNRECOGNIZED": + default: + return ConsumerPacketDataType.UNRECOGNIZED; + } +} +export function consumerPacketDataTypeToJSON(object: ConsumerPacketDataType): string { + switch (object) { + case ConsumerPacketDataType.CONSUMER_PACKET_TYPE_UNSPECIFIED: + return "CONSUMER_PACKET_TYPE_UNSPECIFIED"; + case ConsumerPacketDataType.CONSUMER_PACKET_TYPE_SLASH: + return "CONSUMER_PACKET_TYPE_SLASH"; + case ConsumerPacketDataType.CONSUMER_PACKET_TYPE_VSCM: + return "CONSUMER_PACKET_TYPE_VSCM"; + case ConsumerPacketDataType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * InfractionType indicates the infraction type a validator committed. + * Note ccv.InfractionType to maintain compatibility between ICS versions + * using different versions of the cosmos-sdk and ibc-go modules. + */ +export enum InfractionType { + /** INFRACTION_TYPE_UNSPECIFIED - UNSPECIFIED defines an empty infraction type. */ + INFRACTION_TYPE_UNSPECIFIED = 0, + /** INFRACTION_TYPE_DOUBLE_SIGN - DOUBLE_SIGN defines a validator that double-signs a block. */ + INFRACTION_TYPE_DOUBLE_SIGN = 1, + /** INFRACTION_TYPE_DOWNTIME - DOWNTIME defines a validator that missed signing too many blocks. */ + INFRACTION_TYPE_DOWNTIME = 2, + UNRECOGNIZED = -1, +} +export function infractionTypeFromJSON(object: any): InfractionType { + switch (object) { + case 0: + case "INFRACTION_TYPE_UNSPECIFIED": + return InfractionType.INFRACTION_TYPE_UNSPECIFIED; + case 1: + case "INFRACTION_TYPE_DOUBLE_SIGN": + return InfractionType.INFRACTION_TYPE_DOUBLE_SIGN; + case 2: + case "INFRACTION_TYPE_DOWNTIME": + return InfractionType.INFRACTION_TYPE_DOWNTIME; + case -1: + case "UNRECOGNIZED": + default: + return InfractionType.UNRECOGNIZED; + } +} +export function infractionTypeToJSON(object: InfractionType): string { + switch (object) { + case InfractionType.INFRACTION_TYPE_UNSPECIFIED: + return "INFRACTION_TYPE_UNSPECIFIED"; + case InfractionType.INFRACTION_TYPE_DOUBLE_SIGN: + return "INFRACTION_TYPE_DOUBLE_SIGN"; + case InfractionType.INFRACTION_TYPE_DOWNTIME: + return "INFRACTION_TYPE_DOWNTIME"; + case InfractionType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * This packet is sent from provider chain to consumer chain if the validator + * set for consumer chain changes (due to new bonding/unbonding messages or + * slashing events) A VSCMatured packet from consumer chain will be sent + * asynchronously once unbonding period is over, and this will function as + * `UnbondingOver` message for this packet. + */ +export interface ValidatorSetChangePacketData { + validatorUpdates: ValidatorUpdate[]; + valsetUpdateId: bigint; + /** + * consensus address of consumer chain validators + * successfully slashed on the provider chain + */ + slashAcks: string[]; +} +/** + * This packet is sent from the consumer chain to the provider chain + * to notify that a VSC packet reached maturity on the consumer chain. + */ +export interface VSCMaturedPacketData { + /** the id of the VSC packet that reached maturity */ + valsetUpdateId: bigint; +} +/** + * This packet is sent from the consumer chain to the provider chain + * to request the slashing of a validator as a result of an infraction + * committed on the consumer chain. + */ +export interface SlashPacketData { + validator: Validator; + /** map to the infraction block height on the provider */ + valsetUpdateId: bigint; + /** tell if the slashing is for a downtime or a double-signing infraction */ + infraction: Infraction; +} +/** ConsumerPacketData contains a consumer packet data and a type tag */ +export interface ConsumerPacketData { + type: ConsumerPacketDataType; + slashPacketData?: SlashPacketData; + vscMaturedPacketData?: VSCMaturedPacketData; +} +/** Note this type is used during IBC handshake methods for both the consumer and provider */ +export interface HandshakeMetadata { + providerFeePoolAddr: string; + version: string; +} +/** + * ConsumerPacketData contains a consumer packet data and a type tag + * that is compatible with ICS v1 and v2 over the wire. It is not used for internal storage. + */ +export interface ConsumerPacketDataV1 { + type: ConsumerPacketDataType; + slashPacketData?: SlashPacketDataV1; + vscMaturedPacketData?: VSCMaturedPacketData; +} +/** + * This packet is sent from the consumer chain to the provider chain + * It is backward compatible with the ICS v1 and v2 version of the packet. + */ +export interface SlashPacketDataV1 { + validator: Validator; + /** map to the infraction block height on the provider */ + valsetUpdateId: bigint; + /** tell if the slashing is for a downtime or a double-signing infraction */ + infraction: InfractionType; +} +function createBaseValidatorSetChangePacketData(): ValidatorSetChangePacketData { + return { + validatorUpdates: [], + valsetUpdateId: BigInt(0), + slashAcks: [], + }; +} +export const ValidatorSetChangePacketData = { + typeUrl: "/interchain_security.ccv.v1.ValidatorSetChangePacketData", + encode(message: ValidatorSetChangePacketData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.validatorUpdates) { + ValidatorUpdate.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(16).uint64(message.valsetUpdateId); + } + for (const v of message.slashAcks) { + writer.uint32(26).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSetChangePacketData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSetChangePacketData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorUpdates.push(ValidatorUpdate.decode(reader, reader.uint32())); + break; + case 2: + message.valsetUpdateId = reader.uint64(); + break; + case 3: + message.slashAcks.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSetChangePacketData { + const obj = createBaseValidatorSetChangePacketData(); + if (Array.isArray(object?.validatorUpdates)) + obj.validatorUpdates = object.validatorUpdates.map((e: any) => ValidatorUpdate.fromJSON(e)); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + if (Array.isArray(object?.slashAcks)) obj.slashAcks = object.slashAcks.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ValidatorSetChangePacketData): JsonSafe { + const obj: any = {}; + if (message.validatorUpdates) { + obj.validatorUpdates = message.validatorUpdates.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.validatorUpdates = []; + } + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + if (message.slashAcks) { + obj.slashAcks = message.slashAcks.map((e) => e); + } else { + obj.slashAcks = []; + } + return obj; + }, + fromPartial, I>>( + object: I, + ): ValidatorSetChangePacketData { + const message = createBaseValidatorSetChangePacketData(); + message.validatorUpdates = object.validatorUpdates?.map((e) => ValidatorUpdate.fromPartial(e)) || []; + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + message.slashAcks = object.slashAcks?.map((e) => e) || []; + return message; + }, +}; +function createBaseVSCMaturedPacketData(): VSCMaturedPacketData { + return { + valsetUpdateId: BigInt(0), + }; +} +export const VSCMaturedPacketData = { + typeUrl: "/interchain_security.ccv.v1.VSCMaturedPacketData", + encode(message: VSCMaturedPacketData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(8).uint64(message.valsetUpdateId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VSCMaturedPacketData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVSCMaturedPacketData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.valsetUpdateId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VSCMaturedPacketData { + const obj = createBaseVSCMaturedPacketData(); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + return obj; + }, + toJSON(message: VSCMaturedPacketData): JsonSafe { + const obj: any = {}; + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): VSCMaturedPacketData { + const message = createBaseVSCMaturedPacketData(); + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + return message; + }, +}; +function createBaseSlashPacketData(): SlashPacketData { + return { + validator: Validator.fromPartial({}), + valsetUpdateId: BigInt(0), + infraction: 0, + }; +} +export const SlashPacketData = { + typeUrl: "/interchain_security.ccv.v1.SlashPacketData", + encode(message: SlashPacketData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(16).uint64(message.valsetUpdateId); + } + if (message.infraction !== 0) { + writer.uint32(24).int32(message.infraction); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SlashPacketData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSlashPacketData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 2: + message.valsetUpdateId = reader.uint64(); + break; + case 3: + message.infraction = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SlashPacketData { + const obj = createBaseSlashPacketData(); + if (isSet(object.validator)) obj.validator = Validator.fromJSON(object.validator); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + if (isSet(object.infraction)) obj.infraction = infractionFromJSON(object.infraction); + return obj; + }, + toJSON(message: SlashPacketData): JsonSafe { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + message.infraction !== undefined && (obj.infraction = infractionToJSON(message.infraction)); + return obj; + }, + fromPartial, I>>(object: I): SlashPacketData { + const message = createBaseSlashPacketData(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + message.infraction = object.infraction ?? 0; + return message; + }, +}; +function createBaseConsumerPacketData(): ConsumerPacketData { + return { + type: 0, + slashPacketData: undefined, + vscMaturedPacketData: undefined, + }; +} +export const ConsumerPacketData = { + typeUrl: "/interchain_security.ccv.v1.ConsumerPacketData", + encode(message: ConsumerPacketData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.slashPacketData !== undefined) { + SlashPacketData.encode(message.slashPacketData, writer.uint32(18).fork()).ldelim(); + } + if (message.vscMaturedPacketData !== undefined) { + VSCMaturedPacketData.encode(message.vscMaturedPacketData, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerPacketData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerPacketData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.slashPacketData = SlashPacketData.decode(reader, reader.uint32()); + break; + case 3: + message.vscMaturedPacketData = VSCMaturedPacketData.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerPacketData { + const obj = createBaseConsumerPacketData(); + if (isSet(object.type)) obj.type = consumerPacketDataTypeFromJSON(object.type); + if (isSet(object.slashPacketData)) obj.slashPacketData = SlashPacketData.fromJSON(object.slashPacketData); + if (isSet(object.vscMaturedPacketData)) + obj.vscMaturedPacketData = VSCMaturedPacketData.fromJSON(object.vscMaturedPacketData); + return obj; + }, + toJSON(message: ConsumerPacketData): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = consumerPacketDataTypeToJSON(message.type)); + message.slashPacketData !== undefined && + (obj.slashPacketData = message.slashPacketData + ? SlashPacketData.toJSON(message.slashPacketData) + : undefined); + message.vscMaturedPacketData !== undefined && + (obj.vscMaturedPacketData = message.vscMaturedPacketData + ? VSCMaturedPacketData.toJSON(message.vscMaturedPacketData) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConsumerPacketData { + const message = createBaseConsumerPacketData(); + message.type = object.type ?? 0; + if (object.slashPacketData !== undefined && object.slashPacketData !== null) { + message.slashPacketData = SlashPacketData.fromPartial(object.slashPacketData); + } + if (object.vscMaturedPacketData !== undefined && object.vscMaturedPacketData !== null) { + message.vscMaturedPacketData = VSCMaturedPacketData.fromPartial(object.vscMaturedPacketData); + } + return message; + }, +}; +function createBaseHandshakeMetadata(): HandshakeMetadata { + return { + providerFeePoolAddr: "", + version: "", + }; +} +export const HandshakeMetadata = { + typeUrl: "/interchain_security.ccv.v1.HandshakeMetadata", + encode(message: HandshakeMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.providerFeePoolAddr !== "") { + writer.uint32(10).string(message.providerFeePoolAddr); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HandshakeMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHandshakeMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerFeePoolAddr = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HandshakeMetadata { + const obj = createBaseHandshakeMetadata(); + if (isSet(object.providerFeePoolAddr)) obj.providerFeePoolAddr = String(object.providerFeePoolAddr); + if (isSet(object.version)) obj.version = String(object.version); + return obj; + }, + toJSON(message: HandshakeMetadata): JsonSafe { + const obj: any = {}; + message.providerFeePoolAddr !== undefined && (obj.providerFeePoolAddr = message.providerFeePoolAddr); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + fromPartial, I>>(object: I): HandshakeMetadata { + const message = createBaseHandshakeMetadata(); + message.providerFeePoolAddr = object.providerFeePoolAddr ?? ""; + message.version = object.version ?? ""; + return message; + }, +}; +function createBaseConsumerPacketDataV1(): ConsumerPacketDataV1 { + return { + type: 0, + slashPacketData: undefined, + vscMaturedPacketData: undefined, + }; +} +export const ConsumerPacketDataV1 = { + typeUrl: "/interchain_security.ccv.v1.ConsumerPacketDataV1", + encode(message: ConsumerPacketDataV1, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.slashPacketData !== undefined) { + SlashPacketDataV1.encode(message.slashPacketData, writer.uint32(18).fork()).ldelim(); + } + if (message.vscMaturedPacketData !== undefined) { + VSCMaturedPacketData.encode(message.vscMaturedPacketData, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerPacketDataV1 { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerPacketDataV1(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.slashPacketData = SlashPacketDataV1.decode(reader, reader.uint32()); + break; + case 3: + message.vscMaturedPacketData = VSCMaturedPacketData.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerPacketDataV1 { + const obj = createBaseConsumerPacketDataV1(); + if (isSet(object.type)) obj.type = consumerPacketDataTypeFromJSON(object.type); + if (isSet(object.slashPacketData)) + obj.slashPacketData = SlashPacketDataV1.fromJSON(object.slashPacketData); + if (isSet(object.vscMaturedPacketData)) + obj.vscMaturedPacketData = VSCMaturedPacketData.fromJSON(object.vscMaturedPacketData); + return obj; + }, + toJSON(message: ConsumerPacketDataV1): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = consumerPacketDataTypeToJSON(message.type)); + message.slashPacketData !== undefined && + (obj.slashPacketData = message.slashPacketData + ? SlashPacketDataV1.toJSON(message.slashPacketData) + : undefined); + message.vscMaturedPacketData !== undefined && + (obj.vscMaturedPacketData = message.vscMaturedPacketData + ? VSCMaturedPacketData.toJSON(message.vscMaturedPacketData) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConsumerPacketDataV1 { + const message = createBaseConsumerPacketDataV1(); + message.type = object.type ?? 0; + if (object.slashPacketData !== undefined && object.slashPacketData !== null) { + message.slashPacketData = SlashPacketDataV1.fromPartial(object.slashPacketData); + } + if (object.vscMaturedPacketData !== undefined && object.vscMaturedPacketData !== null) { + message.vscMaturedPacketData = VSCMaturedPacketData.fromPartial(object.vscMaturedPacketData); + } + return message; + }, +}; +function createBaseSlashPacketDataV1(): SlashPacketDataV1 { + return { + validator: Validator.fromPartial({}), + valsetUpdateId: BigInt(0), + infraction: 0, + }; +} +export const SlashPacketDataV1 = { + typeUrl: "/interchain_security.ccv.v1.SlashPacketDataV1", + encode(message: SlashPacketDataV1, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + if (message.valsetUpdateId !== BigInt(0)) { + writer.uint32(16).uint64(message.valsetUpdateId); + } + if (message.infraction !== 0) { + writer.uint32(24).int32(message.infraction); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SlashPacketDataV1 { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSlashPacketDataV1(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 2: + message.valsetUpdateId = reader.uint64(); + break; + case 3: + message.infraction = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SlashPacketDataV1 { + const obj = createBaseSlashPacketDataV1(); + if (isSet(object.validator)) obj.validator = Validator.fromJSON(object.validator); + if (isSet(object.valsetUpdateId)) obj.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + if (isSet(object.infraction)) obj.infraction = infractionTypeFromJSON(object.infraction); + return obj; + }, + toJSON(message: SlashPacketDataV1): JsonSafe { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + message.valsetUpdateId !== undefined && + (obj.valsetUpdateId = (message.valsetUpdateId || BigInt(0)).toString()); + message.infraction !== undefined && (obj.infraction = infractionTypeToJSON(message.infraction)); + return obj; + }, + fromPartial, I>>(object: I): SlashPacketDataV1 { + const message = createBaseSlashPacketDataV1(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } + if (object.valsetUpdateId !== undefined && object.valsetUpdateId !== null) { + message.valsetUpdateId = BigInt(object.valsetUpdateId.toString()); + } + message.infraction = object.infraction ?? 0; + return message; + }, +}; diff --git a/src/interchain_security/rpc.query.ts b/src/interchain_security/rpc.query.ts new file mode 100644 index 0000000..3407292 --- /dev/null +++ b/src/interchain_security/rpc.query.ts @@ -0,0 +1,105 @@ +/* eslint-disable */ +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createRPCQueryClient = async ({ rpcEndpoint }: { rpcEndpoint: string | HttpEndpoint }) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + adminmodule: { + adminmodule: ( + await import("../cosmos/adminmodule/adminmodule/query.rpc.Query") + ).createRpcQueryExtension(client), + }, + app: { + v1alpha1: (await import("../cosmos/app/v1alpha1/query.rpc.Query")).createRpcQueryExtension(client), + }, + auth: { + v1beta1: (await import("../cosmos/auth/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + authz: { + v1beta1: (await import("../cosmos/authz/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + autocli: { + v1: (await import("../cosmos/autocli/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + bank: { + v1beta1: (await import("../cosmos/bank/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + base: { + node: { + v1beta1: (await import("../cosmos/base/node/v1beta1/query.rpc.Service")).createRpcQueryExtension( + client, + ), + }, + tendermint: { + v1beta1: ( + await import("../cosmos/base/tendermint/v1beta1/query.rpc.Service") + ).createRpcQueryExtension(client), + }, + }, + circuit: { + v1: (await import("../cosmos/circuit/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + consensus: { + v1: (await import("../cosmos/consensus/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + distribution: { + v1beta1: (await import("../cosmos/distribution/v1beta1/query.rpc.Query")).createRpcQueryExtension( + client, + ), + }, + evidence: { + v1beta1: (await import("../cosmos/evidence/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + feegrant: { + v1beta1: (await import("../cosmos/feegrant/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + gov: { + v1: (await import("../cosmos/gov/v1/query.rpc.Query")).createRpcQueryExtension(client), + v1beta1: (await import("../cosmos/gov/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + group: { + v1: (await import("../cosmos/group/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + mint: { + v1beta1: (await import("../cosmos/mint/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + nft: { + v1beta1: (await import("../cosmos/nft/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + orm: { + query: { + v1alpha1: (await import("../cosmos/orm/query/v1alpha1/query.rpc.Query")).createRpcQueryExtension( + client, + ), + }, + }, + params: { + v1beta1: (await import("../cosmos/params/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + slashing: { + v1beta1: (await import("../cosmos/slashing/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + staking: { + v1beta1: (await import("../cosmos/staking/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + tx: { + v1beta1: (await import("../cosmos/tx/v1beta1/service.rpc.Service")).createRpcQueryExtension(client), + }, + upgrade: { + v1beta1: (await import("../cosmos/upgrade/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, + }, + interchain_security: { + ccv: { + consumer: { + v1: (await import("./ccv/consumer/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + provider: { + v1: (await import("./ccv/provider/v1/query.rpc.Query")).createRpcQueryExtension(client), + }, + }, + }, + }; +}; diff --git a/src/interchain_security/rpc.tx.ts b/src/interchain_security/rpc.tx.ts new file mode 100644 index 0000000..6f9c422 --- /dev/null +++ b/src/interchain_security/rpc.tx.ts @@ -0,0 +1,71 @@ +/* eslint-disable */ +import { Rpc } from "../helpers"; +export const createRPCMsgClient = async ({ rpc }: { rpc: Rpc }) => ({ + cosmos: { + adminmodule: { + adminmodule: new (await import("../cosmos/adminmodule/adminmodule/tx.rpc.msg")).MsgClientImpl(rpc), + }, + auth: { + v1beta1: new (await import("../cosmos/auth/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + circuit: { + v1: new (await import("../cosmos/circuit/v1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + consensus: { + v1: new (await import("../cosmos/consensus/v1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + crisis: { + v1beta1: new (await import("../cosmos/crisis/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + gov: { + v1: new (await import("../cosmos/gov/v1/tx.rpc.msg")).MsgClientImpl(rpc), + v1beta1: new (await import("../cosmos/gov/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + group: { + v1: new (await import("../cosmos/group/v1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + mint: { + v1beta1: new (await import("../cosmos/mint/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + vesting: { + v1beta1: new (await import("../cosmos/vesting/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + }, + interchain_security: { + ccv: { + consumer: { + v1: new (await import("./ccv/consumer/v1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + provider: { + v1: new (await import("./ccv/provider/v1/tx.rpc.msg")).MsgClientImpl(rpc), + }, + }, + }, +}); diff --git a/src/neutron/dex/limit_order_tranche.ts b/src/neutron/dex/limit_order_tranche.ts index 1485e14..0ddb9e9 100644 --- a/src/neutron/dex/limit_order_tranche.ts +++ b/src/neutron/dex/limit_order_tranche.ts @@ -22,7 +22,11 @@ export interface LimitOrderTranche { * Order deletion still functions the same and the orders will be deleted at the end of the block */ expirationTime?: Timestamp; + /** DEPRECATED: price_taker_to_maker will be removed in future release, `maker_price` should always be used. */ + /** @deprecated */ priceTakerToMaker: string; + /** This is the price of the LimitOrder denominated in the opposite token. (ie. 1 TokenA with a maker_price of 10 is worth 10 TokenB ) */ + makerPrice: string; } function createBaseLimitOrderTrancheKey(): LimitOrderTrancheKey { return { @@ -106,6 +110,7 @@ function createBaseLimitOrderTranche(): LimitOrderTranche { totalTakerDenom: "", expirationTime: undefined, priceTakerToMaker: "", + makerPrice: "", }; } export const LimitOrderTranche = { @@ -132,6 +137,9 @@ export const LimitOrderTranche = { if (message.priceTakerToMaker !== "") { writer.uint32(58).string(message.priceTakerToMaker); } + if (message.makerPrice !== "") { + writer.uint32(66).string(message.makerPrice); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): LimitOrderTranche { @@ -162,6 +170,9 @@ export const LimitOrderTranche = { case 7: message.priceTakerToMaker = reader.string(); break; + case 8: + message.makerPrice = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -178,6 +189,7 @@ export const LimitOrderTranche = { if (isSet(object.totalTakerDenom)) obj.totalTakerDenom = String(object.totalTakerDenom); if (isSet(object.expirationTime)) obj.expirationTime = fromJsonTimestamp(object.expirationTime); if (isSet(object.priceTakerToMaker)) obj.priceTakerToMaker = String(object.priceTakerToMaker); + if (isSet(object.makerPrice)) obj.makerPrice = String(object.makerPrice); return obj; }, toJSON(message: LimitOrderTranche): JsonSafe { @@ -191,6 +203,7 @@ export const LimitOrderTranche = { message.expirationTime !== undefined && (obj.expirationTime = fromTimestamp(message.expirationTime).toISOString()); message.priceTakerToMaker !== undefined && (obj.priceTakerToMaker = message.priceTakerToMaker); + message.makerPrice !== undefined && (obj.makerPrice = message.makerPrice); return obj; }, fromPartial, I>>(object: I): LimitOrderTranche { @@ -206,6 +219,7 @@ export const LimitOrderTranche = { message.expirationTime = Timestamp.fromPartial(object.expirationTime); } message.priceTakerToMaker = object.priceTakerToMaker ?? ""; + message.makerPrice = object.makerPrice ?? ""; return message; }, }; diff --git a/src/neutron/dex/pool_reserves.ts b/src/neutron/dex/pool_reserves.ts index 50371ca..1f545af 100644 --- a/src/neutron/dex/pool_reserves.ts +++ b/src/neutron/dex/pool_reserves.ts @@ -12,8 +12,17 @@ export interface PoolReservesKey { export interface PoolReserves { key?: PoolReservesKey; reservesMakerDenom: string; + /** DEPRECATED: price_taker_to_maker will be removed in future release, `maker_price` should always be used. */ + /** @deprecated */ priceTakerToMaker: string; + /** + * DEPRECATED: price_opposite_taker_maker was an internal implementation detail and will be removed in a future release. + * It is being kept strictly for backwards compatibility. The actual field value is unused. + */ + /** @deprecated */ priceOppositeTakerToMaker: string; + /** This is the price of the PoolReserves denominated in the opposite token. (ie. 1 TokenA with a maker_price of 10 is worth 10 TokenB ) */ + makerPrice: string; } function createBasePoolReservesKey(): PoolReservesKey { return { @@ -96,6 +105,7 @@ function createBasePoolReserves(): PoolReserves { reservesMakerDenom: "", priceTakerToMaker: "", priceOppositeTakerToMaker: "", + makerPrice: "", }; } export const PoolReserves = { @@ -113,6 +123,9 @@ export const PoolReserves = { if (message.priceOppositeTakerToMaker !== "") { writer.uint32(34).string(message.priceOppositeTakerToMaker); } + if (message.makerPrice !== "") { + writer.uint32(42).string(message.makerPrice); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): PoolReserves { @@ -134,6 +147,9 @@ export const PoolReserves = { case 4: message.priceOppositeTakerToMaker = reader.string(); break; + case 5: + message.makerPrice = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -148,6 +164,7 @@ export const PoolReserves = { if (isSet(object.priceTakerToMaker)) obj.priceTakerToMaker = String(object.priceTakerToMaker); if (isSet(object.priceOppositeTakerToMaker)) obj.priceOppositeTakerToMaker = String(object.priceOppositeTakerToMaker); + if (isSet(object.makerPrice)) obj.makerPrice = String(object.makerPrice); return obj; }, toJSON(message: PoolReserves): JsonSafe { @@ -157,6 +174,7 @@ export const PoolReserves = { message.priceTakerToMaker !== undefined && (obj.priceTakerToMaker = message.priceTakerToMaker); message.priceOppositeTakerToMaker !== undefined && (obj.priceOppositeTakerToMaker = message.priceOppositeTakerToMaker); + message.makerPrice !== undefined && (obj.makerPrice = message.makerPrice); return obj; }, fromPartial, I>>(object: I): PoolReserves { @@ -167,6 +185,7 @@ export const PoolReserves = { message.reservesMakerDenom = object.reservesMakerDenom ?? ""; message.priceTakerToMaker = object.priceTakerToMaker ?? ""; message.priceOppositeTakerToMaker = object.priceOppositeTakerToMaker ?? ""; + message.makerPrice = object.makerPrice ?? ""; return message; }, }; diff --git a/src/neutron/dex/query.rpc.Query.ts b/src/neutron/dex/query.rpc.Query.ts index 782f41f..8f489c1 100644 --- a/src/neutron/dex/query.rpc.Query.ts +++ b/src/neutron/dex/query.rpc.Query.ts @@ -39,6 +39,18 @@ import { QueryGetPoolMetadataResponse, QueryAllPoolMetadataRequest, QueryAllPoolMetadataResponse, + QuerySimulateDepositRequest, + QuerySimulateDepositResponse, + QuerySimulateWithdrawalRequest, + QuerySimulateWithdrawalResponse, + QuerySimulatePlaceLimitOrderRequest, + QuerySimulatePlaceLimitOrderResponse, + QuerySimulateWithdrawFilledLimitOrderRequest, + QuerySimulateWithdrawFilledLimitOrderResponse, + QuerySimulateCancelLimitOrderRequest, + QuerySimulateCancelLimitOrderResponse, + QuerySimulateMultiHopSwapRequest, + QuerySimulateMultiHopSwapResponse, } from "./query"; /** Query defines the gRPC querier service. */ export interface Query { @@ -79,9 +91,9 @@ export interface Query { poolReservesAll(request: QueryAllPoolReservesRequest): Promise; /** Queries a PoolReserve by index */ poolReserves(request: QueryGetPoolReservesRequest): Promise; - /** Queries the simulated result of a multihop swap */ + /** DEPRECATED Queries the simulated result of a multihop swap */ estimateMultiHopSwap(request: QueryEstimateMultiHopSwapRequest): Promise; - /** Queries the simulated result of a PlaceLimit order */ + /** DEPRECATED Queries the simulated result of a PlaceLimit order */ estimatePlaceLimitOrder( request: QueryEstimatePlaceLimitOrderRequest, ): Promise; @@ -93,6 +105,24 @@ export interface Query { poolMetadata(request: QueryGetPoolMetadataRequest): Promise; /** Queries a list of PoolMetadata items. */ poolMetadataAll(request?: QueryAllPoolMetadataRequest): Promise; + /** Simulates MsgDeposit */ + simulateDeposit(request: QuerySimulateDepositRequest): Promise; + /** Simulates MsgWithdrawal */ + simulateWithdrawal(request: QuerySimulateWithdrawalRequest): Promise; + /** Simulates MsgPlaceLimitOrder */ + simulatePlaceLimitOrder( + request: QuerySimulatePlaceLimitOrderRequest, + ): Promise; + /** Simulates MsgWithdrawFilledLimitOrder */ + simulateWithdrawFilledLimitOrder( + request: QuerySimulateWithdrawFilledLimitOrderRequest, + ): Promise; + /** Simulates MsgCancelLimitOrder */ + simulateCancelLimitOrder( + request: QuerySimulateCancelLimitOrderRequest, + ): Promise; + /** Simulates MsgMultiHopSwap */ + simulateMultiHopSwap(request: QuerySimulateMultiHopSwapRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; @@ -116,6 +146,12 @@ export class QueryClientImpl implements Query { this.poolByID = this.poolByID.bind(this); this.poolMetadata = this.poolMetadata.bind(this); this.poolMetadataAll = this.poolMetadataAll.bind(this); + this.simulateDeposit = this.simulateDeposit.bind(this); + this.simulateWithdrawal = this.simulateWithdrawal.bind(this); + this.simulatePlaceLimitOrder = this.simulatePlaceLimitOrder.bind(this); + this.simulateWithdrawFilledLimitOrder = this.simulateWithdrawFilledLimitOrder.bind(this); + this.simulateCancelLimitOrder = this.simulateCancelLimitOrder.bind(this); + this.simulateMultiHopSwap = this.simulateMultiHopSwap.bind(this); } params(request: QueryParamsRequest = {}): Promise { const data = QueryParamsRequest.encode(request).finish(); @@ -233,6 +269,46 @@ export class QueryClientImpl implements Query { const promise = this.rpc.request("neutron.dex.Query", "PoolMetadataAll", data); return promise.then((data) => QueryAllPoolMetadataResponse.decode(new BinaryReader(data))); } + simulateDeposit(request: QuerySimulateDepositRequest): Promise { + const data = QuerySimulateDepositRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulateDeposit", data); + return promise.then((data) => QuerySimulateDepositResponse.decode(new BinaryReader(data))); + } + simulateWithdrawal(request: QuerySimulateWithdrawalRequest): Promise { + const data = QuerySimulateWithdrawalRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulateWithdrawal", data); + return promise.then((data) => QuerySimulateWithdrawalResponse.decode(new BinaryReader(data))); + } + simulatePlaceLimitOrder( + request: QuerySimulatePlaceLimitOrderRequest, + ): Promise { + const data = QuerySimulatePlaceLimitOrderRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulatePlaceLimitOrder", data); + return promise.then((data) => QuerySimulatePlaceLimitOrderResponse.decode(new BinaryReader(data))); + } + simulateWithdrawFilledLimitOrder( + request: QuerySimulateWithdrawFilledLimitOrderRequest, + ): Promise { + const data = QuerySimulateWithdrawFilledLimitOrderRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulateWithdrawFilledLimitOrder", data); + return promise.then((data) => + QuerySimulateWithdrawFilledLimitOrderResponse.decode(new BinaryReader(data)), + ); + } + simulateCancelLimitOrder( + request: QuerySimulateCancelLimitOrderRequest, + ): Promise { + const data = QuerySimulateCancelLimitOrderRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulateCancelLimitOrder", data); + return promise.then((data) => QuerySimulateCancelLimitOrderResponse.decode(new BinaryReader(data))); + } + simulateMultiHopSwap( + request: QuerySimulateMultiHopSwapRequest, + ): Promise { + const data = QuerySimulateMultiHopSwapRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.dex.Query", "SimulateMultiHopSwap", data); + return promise.then((data) => QuerySimulateMultiHopSwapResponse.decode(new BinaryReader(data))); + } } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); @@ -308,5 +384,31 @@ export const createRpcQueryExtension = (base: QueryClient) => { poolMetadataAll(request?: QueryAllPoolMetadataRequest): Promise { return queryService.poolMetadataAll(request); }, + simulateDeposit(request: QuerySimulateDepositRequest): Promise { + return queryService.simulateDeposit(request); + }, + simulateWithdrawal(request: QuerySimulateWithdrawalRequest): Promise { + return queryService.simulateWithdrawal(request); + }, + simulatePlaceLimitOrder( + request: QuerySimulatePlaceLimitOrderRequest, + ): Promise { + return queryService.simulatePlaceLimitOrder(request); + }, + simulateWithdrawFilledLimitOrder( + request: QuerySimulateWithdrawFilledLimitOrderRequest, + ): Promise { + return queryService.simulateWithdrawFilledLimitOrder(request); + }, + simulateCancelLimitOrder( + request: QuerySimulateCancelLimitOrderRequest, + ): Promise { + return queryService.simulateCancelLimitOrder(request); + }, + simulateMultiHopSwap( + request: QuerySimulateMultiHopSwapRequest, + ): Promise { + return queryService.simulateMultiHopSwap(request); + }, }; }; diff --git a/src/neutron/dex/query.ts b/src/neutron/dex/query.ts index 272c966..f257654 100644 --- a/src/neutron/dex/query.ts +++ b/src/neutron/dex/query.ts @@ -1,6 +1,23 @@ /* eslint-disable */ import { PageRequest, PageResponse } from "../../cosmos/base/query/v1beta1/pagination"; -import { MultiHopRoute, LimitOrderType, limitOrderTypeFromJSON, limitOrderTypeToJSON } from "./tx"; +import { + MultiHopRoute, + LimitOrderType, + MsgDeposit, + MsgWithdrawal, + MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, + MsgCancelLimitOrder, + MsgMultiHopSwap, + MsgDepositResponse, + MsgWithdrawalResponse, + MsgPlaceLimitOrderResponse, + MsgWithdrawFilledLimitOrderResponse, + MsgCancelLimitOrderResponse, + MsgMultiHopSwapResponse, + limitOrderTypeFromJSON, + limitOrderTypeToJSON, +} from "./tx"; import { Timestamp } from "../../google/protobuf/timestamp"; import { Params } from "./params"; import { LimitOrderTrancheUser } from "./limit_order_tranche_user"; @@ -117,6 +134,7 @@ export interface QueryGetPoolReservesResponse { poolReserves?: PoolReserves; } export interface QueryEstimateMultiHopSwapRequest { + /** DEPRECATED: Use QuerySimulateMultiHopSwap */ creator: string; receiver: string; routes: MultiHopRoute[]; @@ -132,6 +150,7 @@ export interface QueryEstimateMultiHopSwapResponse { coinOut: Coin; } export interface QueryEstimatePlaceLimitOrderRequest { + /** DEPRECATED: Use QuerySimulatePlaceLimitOrder */ creator: string; receiver: string; tokenIn: string; @@ -184,6 +203,42 @@ export interface QueryAllPoolMetadataResponse { poolMetadata: PoolMetadata[]; pagination?: PageResponse; } +export interface QuerySimulateDepositRequest { + msg?: MsgDeposit; +} +export interface QuerySimulateDepositResponse { + resp?: MsgDepositResponse; +} +export interface QuerySimulateWithdrawalRequest { + msg?: MsgWithdrawal; +} +export interface QuerySimulateWithdrawalResponse { + resp?: MsgWithdrawalResponse; +} +export interface QuerySimulatePlaceLimitOrderRequest { + msg?: MsgPlaceLimitOrder; +} +export interface QuerySimulatePlaceLimitOrderResponse { + resp?: MsgPlaceLimitOrderResponse; +} +export interface QuerySimulateWithdrawFilledLimitOrderRequest { + msg?: MsgWithdrawFilledLimitOrder; +} +export interface QuerySimulateWithdrawFilledLimitOrderResponse { + resp?: MsgWithdrawFilledLimitOrderResponse; +} +export interface QuerySimulateCancelLimitOrderRequest { + msg?: MsgCancelLimitOrder; +} +export interface QuerySimulateCancelLimitOrderResponse { + resp?: MsgCancelLimitOrderResponse; +} +export interface QuerySimulateMultiHopSwapRequest { + msg?: MsgMultiHopSwap; +} +export interface QuerySimulateMultiHopSwapResponse { + resp?: MsgMultiHopSwapResponse; +} function createBaseQueryParamsRequest(): QueryParamsRequest { return {}; } @@ -2537,3 +2592,645 @@ export const QueryAllPoolMetadataResponse = { return message; }, }; +function createBaseQuerySimulateDepositRequest(): QuerySimulateDepositRequest { + return { + msg: undefined, + }; +} +export const QuerySimulateDepositRequest = { + typeUrl: "/neutron.dex.QuerySimulateDepositRequest", + encode(message: QuerySimulateDepositRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msg !== undefined) { + MsgDeposit.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateDepositRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateDepositRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgDeposit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateDepositRequest { + const obj = createBaseQuerySimulateDepositRequest(); + if (isSet(object.msg)) obj.msg = MsgDeposit.fromJSON(object.msg); + return obj; + }, + toJSON(message: QuerySimulateDepositRequest): JsonSafe { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg ? MsgDeposit.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateDepositRequest { + const message = createBaseQuerySimulateDepositRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgDeposit.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulateDepositResponse(): QuerySimulateDepositResponse { + return { + resp: undefined, + }; +} +export const QuerySimulateDepositResponse = { + typeUrl: "/neutron.dex.QuerySimulateDepositResponse", + encode(message: QuerySimulateDepositResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.resp !== undefined) { + MsgDepositResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateDepositResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateDepositResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgDepositResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateDepositResponse { + const obj = createBaseQuerySimulateDepositResponse(); + if (isSet(object.resp)) obj.resp = MsgDepositResponse.fromJSON(object.resp); + return obj; + }, + toJSON(message: QuerySimulateDepositResponse): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgDepositResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateDepositResponse { + const message = createBaseQuerySimulateDepositResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgDepositResponse.fromPartial(object.resp); + } + return message; + }, +}; +function createBaseQuerySimulateWithdrawalRequest(): QuerySimulateWithdrawalRequest { + return { + msg: undefined, + }; +} +export const QuerySimulateWithdrawalRequest = { + typeUrl: "/neutron.dex.QuerySimulateWithdrawalRequest", + encode( + message: QuerySimulateWithdrawalRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.msg !== undefined) { + MsgWithdrawal.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateWithdrawalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateWithdrawalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgWithdrawal.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateWithdrawalRequest { + const obj = createBaseQuerySimulateWithdrawalRequest(); + if (isSet(object.msg)) obj.msg = MsgWithdrawal.fromJSON(object.msg); + return obj; + }, + toJSON(message: QuerySimulateWithdrawalRequest): JsonSafe { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg ? MsgWithdrawal.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateWithdrawalRequest { + const message = createBaseQuerySimulateWithdrawalRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgWithdrawal.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulateWithdrawalResponse(): QuerySimulateWithdrawalResponse { + return { + resp: undefined, + }; +} +export const QuerySimulateWithdrawalResponse = { + typeUrl: "/neutron.dex.QuerySimulateWithdrawalResponse", + encode( + message: QuerySimulateWithdrawalResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.resp !== undefined) { + MsgWithdrawalResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateWithdrawalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateWithdrawalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgWithdrawalResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateWithdrawalResponse { + const obj = createBaseQuerySimulateWithdrawalResponse(); + if (isSet(object.resp)) obj.resp = MsgWithdrawalResponse.fromJSON(object.resp); + return obj; + }, + toJSON(message: QuerySimulateWithdrawalResponse): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgWithdrawalResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateWithdrawalResponse { + const message = createBaseQuerySimulateWithdrawalResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgWithdrawalResponse.fromPartial(object.resp); + } + return message; + }, +}; +function createBaseQuerySimulatePlaceLimitOrderRequest(): QuerySimulatePlaceLimitOrderRequest { + return { + msg: undefined, + }; +} +export const QuerySimulatePlaceLimitOrderRequest = { + typeUrl: "/neutron.dex.QuerySimulatePlaceLimitOrderRequest", + encode( + message: QuerySimulatePlaceLimitOrderRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.msg !== undefined) { + MsgPlaceLimitOrder.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulatePlaceLimitOrderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulatePlaceLimitOrderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgPlaceLimitOrder.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulatePlaceLimitOrderRequest { + const obj = createBaseQuerySimulatePlaceLimitOrderRequest(); + if (isSet(object.msg)) obj.msg = MsgPlaceLimitOrder.fromJSON(object.msg); + return obj; + }, + toJSON(message: QuerySimulatePlaceLimitOrderRequest): JsonSafe { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg ? MsgPlaceLimitOrder.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulatePlaceLimitOrderRequest { + const message = createBaseQuerySimulatePlaceLimitOrderRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgPlaceLimitOrder.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulatePlaceLimitOrderResponse(): QuerySimulatePlaceLimitOrderResponse { + return { + resp: undefined, + }; +} +export const QuerySimulatePlaceLimitOrderResponse = { + typeUrl: "/neutron.dex.QuerySimulatePlaceLimitOrderResponse", + encode( + message: QuerySimulatePlaceLimitOrderResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.resp !== undefined) { + MsgPlaceLimitOrderResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulatePlaceLimitOrderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulatePlaceLimitOrderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgPlaceLimitOrderResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulatePlaceLimitOrderResponse { + const obj = createBaseQuerySimulatePlaceLimitOrderResponse(); + if (isSet(object.resp)) obj.resp = MsgPlaceLimitOrderResponse.fromJSON(object.resp); + return obj; + }, + toJSON(message: QuerySimulatePlaceLimitOrderResponse): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgPlaceLimitOrderResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulatePlaceLimitOrderResponse { + const message = createBaseQuerySimulatePlaceLimitOrderResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgPlaceLimitOrderResponse.fromPartial(object.resp); + } + return message; + }, +}; +function createBaseQuerySimulateWithdrawFilledLimitOrderRequest(): QuerySimulateWithdrawFilledLimitOrderRequest { + return { + msg: undefined, + }; +} +export const QuerySimulateWithdrawFilledLimitOrderRequest = { + typeUrl: "/neutron.dex.QuerySimulateWithdrawFilledLimitOrderRequest", + encode( + message: QuerySimulateWithdrawFilledLimitOrderRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.msg !== undefined) { + MsgWithdrawFilledLimitOrder.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateWithdrawFilledLimitOrderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateWithdrawFilledLimitOrderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgWithdrawFilledLimitOrder.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateWithdrawFilledLimitOrderRequest { + const obj = createBaseQuerySimulateWithdrawFilledLimitOrderRequest(); + if (isSet(object.msg)) obj.msg = MsgWithdrawFilledLimitOrder.fromJSON(object.msg); + return obj; + }, + toJSON( + message: QuerySimulateWithdrawFilledLimitOrderRequest, + ): JsonSafe { + const obj: any = {}; + message.msg !== undefined && + (obj.msg = message.msg ? MsgWithdrawFilledLimitOrder.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateWithdrawFilledLimitOrderRequest { + const message = createBaseQuerySimulateWithdrawFilledLimitOrderRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgWithdrawFilledLimitOrder.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulateWithdrawFilledLimitOrderResponse(): QuerySimulateWithdrawFilledLimitOrderResponse { + return { + resp: undefined, + }; +} +export const QuerySimulateWithdrawFilledLimitOrderResponse = { + typeUrl: "/neutron.dex.QuerySimulateWithdrawFilledLimitOrderResponse", + encode( + message: QuerySimulateWithdrawFilledLimitOrderResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.resp !== undefined) { + MsgWithdrawFilledLimitOrderResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateWithdrawFilledLimitOrderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateWithdrawFilledLimitOrderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgWithdrawFilledLimitOrderResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateWithdrawFilledLimitOrderResponse { + const obj = createBaseQuerySimulateWithdrawFilledLimitOrderResponse(); + if (isSet(object.resp)) obj.resp = MsgWithdrawFilledLimitOrderResponse.fromJSON(object.resp); + return obj; + }, + toJSON( + message: QuerySimulateWithdrawFilledLimitOrderResponse, + ): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgWithdrawFilledLimitOrderResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateWithdrawFilledLimitOrderResponse { + const message = createBaseQuerySimulateWithdrawFilledLimitOrderResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgWithdrawFilledLimitOrderResponse.fromPartial(object.resp); + } + return message; + }, +}; +function createBaseQuerySimulateCancelLimitOrderRequest(): QuerySimulateCancelLimitOrderRequest { + return { + msg: undefined, + }; +} +export const QuerySimulateCancelLimitOrderRequest = { + typeUrl: "/neutron.dex.QuerySimulateCancelLimitOrderRequest", + encode( + message: QuerySimulateCancelLimitOrderRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.msg !== undefined) { + MsgCancelLimitOrder.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateCancelLimitOrderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateCancelLimitOrderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgCancelLimitOrder.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateCancelLimitOrderRequest { + const obj = createBaseQuerySimulateCancelLimitOrderRequest(); + if (isSet(object.msg)) obj.msg = MsgCancelLimitOrder.fromJSON(object.msg); + return obj; + }, + toJSON(message: QuerySimulateCancelLimitOrderRequest): JsonSafe { + const obj: any = {}; + message.msg !== undefined && + (obj.msg = message.msg ? MsgCancelLimitOrder.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateCancelLimitOrderRequest { + const message = createBaseQuerySimulateCancelLimitOrderRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgCancelLimitOrder.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulateCancelLimitOrderResponse(): QuerySimulateCancelLimitOrderResponse { + return { + resp: undefined, + }; +} +export const QuerySimulateCancelLimitOrderResponse = { + typeUrl: "/neutron.dex.QuerySimulateCancelLimitOrderResponse", + encode( + message: QuerySimulateCancelLimitOrderResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.resp !== undefined) { + MsgCancelLimitOrderResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateCancelLimitOrderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateCancelLimitOrderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgCancelLimitOrderResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateCancelLimitOrderResponse { + const obj = createBaseQuerySimulateCancelLimitOrderResponse(); + if (isSet(object.resp)) obj.resp = MsgCancelLimitOrderResponse.fromJSON(object.resp); + return obj; + }, + toJSON(message: QuerySimulateCancelLimitOrderResponse): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgCancelLimitOrderResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateCancelLimitOrderResponse { + const message = createBaseQuerySimulateCancelLimitOrderResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgCancelLimitOrderResponse.fromPartial(object.resp); + } + return message; + }, +}; +function createBaseQuerySimulateMultiHopSwapRequest(): QuerySimulateMultiHopSwapRequest { + return { + msg: undefined, + }; +} +export const QuerySimulateMultiHopSwapRequest = { + typeUrl: "/neutron.dex.QuerySimulateMultiHopSwapRequest", + encode( + message: QuerySimulateMultiHopSwapRequest, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.msg !== undefined) { + MsgMultiHopSwap.encode(message.msg, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateMultiHopSwapRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateMultiHopSwapRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = MsgMultiHopSwap.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateMultiHopSwapRequest { + const obj = createBaseQuerySimulateMultiHopSwapRequest(); + if (isSet(object.msg)) obj.msg = MsgMultiHopSwap.fromJSON(object.msg); + return obj; + }, + toJSON(message: QuerySimulateMultiHopSwapRequest): JsonSafe { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg ? MsgMultiHopSwap.toJSON(message.msg) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateMultiHopSwapRequest { + const message = createBaseQuerySimulateMultiHopSwapRequest(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = MsgMultiHopSwap.fromPartial(object.msg); + } + return message; + }, +}; +function createBaseQuerySimulateMultiHopSwapResponse(): QuerySimulateMultiHopSwapResponse { + return { + resp: undefined, + }; +} +export const QuerySimulateMultiHopSwapResponse = { + typeUrl: "/neutron.dex.QuerySimulateMultiHopSwapResponse", + encode( + message: QuerySimulateMultiHopSwapResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.resp !== undefined) { + MsgMultiHopSwapResponse.encode(message.resp, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySimulateMultiHopSwapResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySimulateMultiHopSwapResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resp = MsgMultiHopSwapResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySimulateMultiHopSwapResponse { + const obj = createBaseQuerySimulateMultiHopSwapResponse(); + if (isSet(object.resp)) obj.resp = MsgMultiHopSwapResponse.fromJSON(object.resp); + return obj; + }, + toJSON(message: QuerySimulateMultiHopSwapResponse): JsonSafe { + const obj: any = {}; + message.resp !== undefined && + (obj.resp = message.resp ? MsgMultiHopSwapResponse.toJSON(message.resp) : undefined); + return obj; + }, + fromPartial, I>>( + object: I, + ): QuerySimulateMultiHopSwapResponse { + const message = createBaseQuerySimulateMultiHopSwapResponse(); + if (object.resp !== undefined && object.resp !== null) { + message.resp = MsgMultiHopSwapResponse.fromPartial(object.resp); + } + return message; + }, +}; diff --git a/src/neutron/dex/tx.ts b/src/neutron/dex/tx.ts index 59dc866..98f34eb 100644 --- a/src/neutron/dex/tx.ts +++ b/src/neutron/dex/tx.ts @@ -77,6 +77,7 @@ export interface MsgDepositResponse { reserve0Deposited: string[]; reserve1Deposited: string[]; failedDeposits: FailedDeposit[]; + sharesIssued: Coin[]; } export interface MsgWithdrawal { creator: string; @@ -87,7 +88,11 @@ export interface MsgWithdrawal { tickIndexesAToB: bigint[]; fees: bigint[]; } -export interface MsgWithdrawalResponse {} +export interface MsgWithdrawalResponse { + reserve0Withdrawn: string; + reserve1Withdrawn: string; + sharesBurned: Coin[]; +} export interface MsgPlaceLimitOrder { creator: string; receiver: string; @@ -102,6 +107,12 @@ export interface MsgPlaceLimitOrder { expirationTime?: Timestamp; maxAmountOut?: string; limitSellPrice?: string; + /** + * min_average_sell_price is an optional parameter that sets a required minimum average price for the entire trade. + * if the min_average_sell_price is not met the trade will fail. + * If min_average_sell_price is omitted limit_sell_price will be used instead + */ + minAverageSellPrice?: string; } export interface MsgPlaceLimitOrderResponse { trancheKey: string; @@ -114,17 +125,29 @@ export interface MsgPlaceLimitOrderResponse { * maker portion which will have withdrawn in the future */ takerCoinOut: Coin; + /** Total amount of the token in that was immediately swapped for takerOutCoin */ + takerCoinIn: Coin; } export interface MsgWithdrawFilledLimitOrder { creator: string; trancheKey: string; } -export interface MsgWithdrawFilledLimitOrderResponse {} +export interface MsgWithdrawFilledLimitOrderResponse { + /** Total amount of taker reserves that were withdrawn */ + takerCoinOut: Coin; + /** Total amount of maker reserves that were withdrawn --only applies to inactive LimitOrders */ + makerCoinOut: Coin; +} export interface MsgCancelLimitOrder { creator: string; trancheKey: string; } -export interface MsgCancelLimitOrderResponse {} +export interface MsgCancelLimitOrderResponse { + /** Total amount of taker reserves that were withdrawn */ + takerCoinOut: Coin; + /** Total amount of maker reserves that were canceled */ + makerCoinOut: Coin; +} export interface MultiHopRoute { hops: string[]; } @@ -142,6 +165,8 @@ export interface MsgMultiHopSwap { } export interface MsgMultiHopSwapResponse { coinOut: Coin; + route?: MultiHopRoute; + dust: Coin[]; } export interface MsgUpdateParams { /** Authority is the address of the governance account. */ @@ -441,6 +466,7 @@ function createBaseMsgDepositResponse(): MsgDepositResponse { reserve0Deposited: [], reserve1Deposited: [], failedDeposits: [], + sharesIssued: [], }; } export const MsgDepositResponse = { @@ -455,6 +481,9 @@ export const MsgDepositResponse = { for (const v of message.failedDeposits) { FailedDeposit.encode(v!, writer.uint32(26).fork()).ldelim(); } + for (const v of message.sharesIssued) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositResponse { @@ -473,6 +502,9 @@ export const MsgDepositResponse = { case 3: message.failedDeposits.push(FailedDeposit.decode(reader, reader.uint32())); break; + case 4: + message.sharesIssued.push(Coin.decode(reader, reader.uint32())); + break; default: reader.skipType(tag & 7); break; @@ -488,6 +520,8 @@ export const MsgDepositResponse = { obj.reserve1Deposited = object.reserve1Deposited.map((e: any) => String(e)); if (Array.isArray(object?.failedDeposits)) obj.failedDeposits = object.failedDeposits.map((e: any) => FailedDeposit.fromJSON(e)); + if (Array.isArray(object?.sharesIssued)) + obj.sharesIssued = object.sharesIssued.map((e: any) => Coin.fromJSON(e)); return obj; }, toJSON(message: MsgDepositResponse): JsonSafe { @@ -507,6 +541,11 @@ export const MsgDepositResponse = { } else { obj.failedDeposits = []; } + if (message.sharesIssued) { + obj.sharesIssued = message.sharesIssued.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.sharesIssued = []; + } return obj; }, fromPartial, I>>(object: I): MsgDepositResponse { @@ -514,6 +553,7 @@ export const MsgDepositResponse = { message.reserve0Deposited = object.reserve0Deposited?.map((e) => e) || []; message.reserve1Deposited = object.reserve1Deposited?.map((e) => e) || []; message.failedDeposits = object.failedDeposits?.map((e) => FailedDeposit.fromPartial(e)) || []; + message.sharesIssued = object.sharesIssued?.map((e) => Coin.fromPartial(e)) || []; return message; }, }; @@ -656,11 +696,24 @@ export const MsgWithdrawal = { }, }; function createBaseMsgWithdrawalResponse(): MsgWithdrawalResponse { - return {}; + return { + reserve0Withdrawn: "", + reserve1Withdrawn: "", + sharesBurned: [], + }; } export const MsgWithdrawalResponse = { typeUrl: "/neutron.dex.MsgWithdrawalResponse", - encode(_: MsgWithdrawalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + encode(message: MsgWithdrawalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.reserve0Withdrawn !== "") { + writer.uint32(10).string(message.reserve0Withdrawn); + } + if (message.reserve1Withdrawn !== "") { + writer.uint32(18).string(message.reserve1Withdrawn); + } + for (const v of message.sharesBurned) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawalResponse { @@ -670,6 +723,15 @@ export const MsgWithdrawalResponse = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.reserve0Withdrawn = reader.string(); + break; + case 2: + message.reserve1Withdrawn = reader.string(); + break; + case 3: + message.sharesBurned.push(Coin.decode(reader, reader.uint32())); + break; default: reader.skipType(tag & 7); break; @@ -677,16 +739,30 @@ export const MsgWithdrawalResponse = { } return message; }, - fromJSON(_: any): MsgWithdrawalResponse { + fromJSON(object: any): MsgWithdrawalResponse { const obj = createBaseMsgWithdrawalResponse(); + if (isSet(object.reserve0Withdrawn)) obj.reserve0Withdrawn = String(object.reserve0Withdrawn); + if (isSet(object.reserve1Withdrawn)) obj.reserve1Withdrawn = String(object.reserve1Withdrawn); + if (Array.isArray(object?.sharesBurned)) + obj.sharesBurned = object.sharesBurned.map((e: any) => Coin.fromJSON(e)); return obj; }, - toJSON(_: MsgWithdrawalResponse): JsonSafe { + toJSON(message: MsgWithdrawalResponse): JsonSafe { const obj: any = {}; + message.reserve0Withdrawn !== undefined && (obj.reserve0Withdrawn = message.reserve0Withdrawn); + message.reserve1Withdrawn !== undefined && (obj.reserve1Withdrawn = message.reserve1Withdrawn); + if (message.sharesBurned) { + obj.sharesBurned = message.sharesBurned.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.sharesBurned = []; + } return obj; }, - fromPartial, I>>(_: I): MsgWithdrawalResponse { + fromPartial, I>>(object: I): MsgWithdrawalResponse { const message = createBaseMsgWithdrawalResponse(); + message.reserve0Withdrawn = object.reserve0Withdrawn ?? ""; + message.reserve1Withdrawn = object.reserve1Withdrawn ?? ""; + message.sharesBurned = object.sharesBurned?.map((e) => Coin.fromPartial(e)) || []; return message; }, }; @@ -702,6 +778,7 @@ function createBaseMsgPlaceLimitOrder(): MsgPlaceLimitOrder { expirationTime: undefined, maxAmountOut: undefined, limitSellPrice: undefined, + minAverageSellPrice: undefined, }; } export const MsgPlaceLimitOrder = { @@ -737,6 +814,9 @@ export const MsgPlaceLimitOrder = { if (message.limitSellPrice !== undefined) { writer.uint32(90).string(message.limitSellPrice); } + if (message.minAverageSellPrice !== undefined) { + writer.uint32(98).string(message.minAverageSellPrice); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgPlaceLimitOrder { @@ -776,6 +856,9 @@ export const MsgPlaceLimitOrder = { case 11: message.limitSellPrice = reader.string(); break; + case 12: + message.minAverageSellPrice = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -795,6 +878,7 @@ export const MsgPlaceLimitOrder = { if (isSet(object.expirationTime)) obj.expirationTime = fromJsonTimestamp(object.expirationTime); if (isSet(object.maxAmountOut)) obj.maxAmountOut = String(object.maxAmountOut); if (isSet(object.limitSellPrice)) obj.limitSellPrice = String(object.limitSellPrice); + if (isSet(object.minAverageSellPrice)) obj.minAverageSellPrice = String(object.minAverageSellPrice); return obj; }, toJSON(message: MsgPlaceLimitOrder): JsonSafe { @@ -811,6 +895,7 @@ export const MsgPlaceLimitOrder = { (obj.expirationTime = fromTimestamp(message.expirationTime).toISOString()); message.maxAmountOut !== undefined && (obj.maxAmountOut = message.maxAmountOut); message.limitSellPrice !== undefined && (obj.limitSellPrice = message.limitSellPrice); + message.minAverageSellPrice !== undefined && (obj.minAverageSellPrice = message.minAverageSellPrice); return obj; }, fromPartial, I>>(object: I): MsgPlaceLimitOrder { @@ -829,6 +914,7 @@ export const MsgPlaceLimitOrder = { } message.maxAmountOut = object.maxAmountOut ?? undefined; message.limitSellPrice = object.limitSellPrice ?? undefined; + message.minAverageSellPrice = object.minAverageSellPrice ?? undefined; return message; }, }; @@ -837,6 +923,7 @@ function createBaseMsgPlaceLimitOrderResponse(): MsgPlaceLimitOrderResponse { trancheKey: "", coinIn: Coin.fromPartial({}), takerCoinOut: Coin.fromPartial({}), + takerCoinIn: Coin.fromPartial({}), }; } export const MsgPlaceLimitOrderResponse = { @@ -851,6 +938,9 @@ export const MsgPlaceLimitOrderResponse = { if (message.takerCoinOut !== undefined) { Coin.encode(message.takerCoinOut, writer.uint32(26).fork()).ldelim(); } + if (message.takerCoinIn !== undefined) { + Coin.encode(message.takerCoinIn, writer.uint32(34).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgPlaceLimitOrderResponse { @@ -869,6 +959,9 @@ export const MsgPlaceLimitOrderResponse = { case 3: message.takerCoinOut = Coin.decode(reader, reader.uint32()); break; + case 4: + message.takerCoinIn = Coin.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -881,6 +974,7 @@ export const MsgPlaceLimitOrderResponse = { if (isSet(object.trancheKey)) obj.trancheKey = String(object.trancheKey); if (isSet(object.coinIn)) obj.coinIn = Coin.fromJSON(object.coinIn); if (isSet(object.takerCoinOut)) obj.takerCoinOut = Coin.fromJSON(object.takerCoinOut); + if (isSet(object.takerCoinIn)) obj.takerCoinIn = Coin.fromJSON(object.takerCoinIn); return obj; }, toJSON(message: MsgPlaceLimitOrderResponse): JsonSafe { @@ -889,6 +983,8 @@ export const MsgPlaceLimitOrderResponse = { message.coinIn !== undefined && (obj.coinIn = message.coinIn ? Coin.toJSON(message.coinIn) : undefined); message.takerCoinOut !== undefined && (obj.takerCoinOut = message.takerCoinOut ? Coin.toJSON(message.takerCoinOut) : undefined); + message.takerCoinIn !== undefined && + (obj.takerCoinIn = message.takerCoinIn ? Coin.toJSON(message.takerCoinIn) : undefined); return obj; }, fromPartial, I>>( @@ -902,6 +998,9 @@ export const MsgPlaceLimitOrderResponse = { if (object.takerCoinOut !== undefined && object.takerCoinOut !== null) { message.takerCoinOut = Coin.fromPartial(object.takerCoinOut); } + if (object.takerCoinIn !== undefined && object.takerCoinIn !== null) { + message.takerCoinIn = Coin.fromPartial(object.takerCoinIn); + } return message; }, }; @@ -964,11 +1063,23 @@ export const MsgWithdrawFilledLimitOrder = { }, }; function createBaseMsgWithdrawFilledLimitOrderResponse(): MsgWithdrawFilledLimitOrderResponse { - return {}; + return { + takerCoinOut: Coin.fromPartial({}), + makerCoinOut: Coin.fromPartial({}), + }; } export const MsgWithdrawFilledLimitOrderResponse = { typeUrl: "/neutron.dex.MsgWithdrawFilledLimitOrderResponse", - encode(_: MsgWithdrawFilledLimitOrderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + encode( + message: MsgWithdrawFilledLimitOrderResponse, + writer: BinaryWriter = BinaryWriter.create(), + ): BinaryWriter { + if (message.takerCoinOut !== undefined) { + Coin.encode(message.takerCoinOut, writer.uint32(10).fork()).ldelim(); + } + if (message.makerCoinOut !== undefined) { + Coin.encode(message.makerCoinOut, writer.uint32(18).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawFilledLimitOrderResponse { @@ -978,6 +1089,12 @@ export const MsgWithdrawFilledLimitOrderResponse = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.takerCoinOut = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.makerCoinOut = Coin.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -985,18 +1102,30 @@ export const MsgWithdrawFilledLimitOrderResponse = { } return message; }, - fromJSON(_: any): MsgWithdrawFilledLimitOrderResponse { + fromJSON(object: any): MsgWithdrawFilledLimitOrderResponse { const obj = createBaseMsgWithdrawFilledLimitOrderResponse(); + if (isSet(object.takerCoinOut)) obj.takerCoinOut = Coin.fromJSON(object.takerCoinOut); + if (isSet(object.makerCoinOut)) obj.makerCoinOut = Coin.fromJSON(object.makerCoinOut); return obj; }, - toJSON(_: MsgWithdrawFilledLimitOrderResponse): JsonSafe { + toJSON(message: MsgWithdrawFilledLimitOrderResponse): JsonSafe { const obj: any = {}; + message.takerCoinOut !== undefined && + (obj.takerCoinOut = message.takerCoinOut ? Coin.toJSON(message.takerCoinOut) : undefined); + message.makerCoinOut !== undefined && + (obj.makerCoinOut = message.makerCoinOut ? Coin.toJSON(message.makerCoinOut) : undefined); return obj; }, fromPartial, I>>( - _: I, + object: I, ): MsgWithdrawFilledLimitOrderResponse { const message = createBaseMsgWithdrawFilledLimitOrderResponse(); + if (object.takerCoinOut !== undefined && object.takerCoinOut !== null) { + message.takerCoinOut = Coin.fromPartial(object.takerCoinOut); + } + if (object.makerCoinOut !== undefined && object.makerCoinOut !== null) { + message.makerCoinOut = Coin.fromPartial(object.makerCoinOut); + } return message; }, }; @@ -1057,11 +1186,20 @@ export const MsgCancelLimitOrder = { }, }; function createBaseMsgCancelLimitOrderResponse(): MsgCancelLimitOrderResponse { - return {}; + return { + takerCoinOut: Coin.fromPartial({}), + makerCoinOut: Coin.fromPartial({}), + }; } export const MsgCancelLimitOrderResponse = { typeUrl: "/neutron.dex.MsgCancelLimitOrderResponse", - encode(_: MsgCancelLimitOrderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + encode(message: MsgCancelLimitOrderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.takerCoinOut !== undefined) { + Coin.encode(message.takerCoinOut, writer.uint32(10).fork()).ldelim(); + } + if (message.makerCoinOut !== undefined) { + Coin.encode(message.makerCoinOut, writer.uint32(18).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgCancelLimitOrderResponse { @@ -1071,6 +1209,12 @@ export const MsgCancelLimitOrderResponse = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.takerCoinOut = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.makerCoinOut = Coin.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -1078,18 +1222,30 @@ export const MsgCancelLimitOrderResponse = { } return message; }, - fromJSON(_: any): MsgCancelLimitOrderResponse { + fromJSON(object: any): MsgCancelLimitOrderResponse { const obj = createBaseMsgCancelLimitOrderResponse(); + if (isSet(object.takerCoinOut)) obj.takerCoinOut = Coin.fromJSON(object.takerCoinOut); + if (isSet(object.makerCoinOut)) obj.makerCoinOut = Coin.fromJSON(object.makerCoinOut); return obj; }, - toJSON(_: MsgCancelLimitOrderResponse): JsonSafe { + toJSON(message: MsgCancelLimitOrderResponse): JsonSafe { const obj: any = {}; + message.takerCoinOut !== undefined && + (obj.takerCoinOut = message.takerCoinOut ? Coin.toJSON(message.takerCoinOut) : undefined); + message.makerCoinOut !== undefined && + (obj.makerCoinOut = message.makerCoinOut ? Coin.toJSON(message.makerCoinOut) : undefined); return obj; }, fromPartial, I>>( - _: I, + object: I, ): MsgCancelLimitOrderResponse { const message = createBaseMsgCancelLimitOrderResponse(); + if (object.takerCoinOut !== undefined && object.takerCoinOut !== null) { + message.takerCoinOut = Coin.fromPartial(object.takerCoinOut); + } + if (object.makerCoinOut !== undefined && object.makerCoinOut !== null) { + message.makerCoinOut = Coin.fromPartial(object.makerCoinOut); + } return message; }, }; @@ -1246,6 +1402,8 @@ export const MsgMultiHopSwap = { function createBaseMsgMultiHopSwapResponse(): MsgMultiHopSwapResponse { return { coinOut: Coin.fromPartial({}), + route: undefined, + dust: [], }; } export const MsgMultiHopSwapResponse = { @@ -1254,6 +1412,12 @@ export const MsgMultiHopSwapResponse = { if (message.coinOut !== undefined) { Coin.encode(message.coinOut, writer.uint32(10).fork()).ldelim(); } + if (message.route !== undefined) { + MultiHopRoute.encode(message.route, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.dust) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): MsgMultiHopSwapResponse { @@ -1266,6 +1430,12 @@ export const MsgMultiHopSwapResponse = { case 1: message.coinOut = Coin.decode(reader, reader.uint32()); break; + case 2: + message.route = MultiHopRoute.decode(reader, reader.uint32()); + break; + case 3: + message.dust.push(Coin.decode(reader, reader.uint32())); + break; default: reader.skipType(tag & 7); break; @@ -1276,12 +1446,21 @@ export const MsgMultiHopSwapResponse = { fromJSON(object: any): MsgMultiHopSwapResponse { const obj = createBaseMsgMultiHopSwapResponse(); if (isSet(object.coinOut)) obj.coinOut = Coin.fromJSON(object.coinOut); + if (isSet(object.route)) obj.route = MultiHopRoute.fromJSON(object.route); + if (Array.isArray(object?.dust)) obj.dust = object.dust.map((e: any) => Coin.fromJSON(e)); return obj; }, toJSON(message: MsgMultiHopSwapResponse): JsonSafe { const obj: any = {}; message.coinOut !== undefined && (obj.coinOut = message.coinOut ? Coin.toJSON(message.coinOut) : undefined); + message.route !== undefined && + (obj.route = message.route ? MultiHopRoute.toJSON(message.route) : undefined); + if (message.dust) { + obj.dust = message.dust.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.dust = []; + } return obj; }, fromPartial, I>>(object: I): MsgMultiHopSwapResponse { @@ -1289,6 +1468,10 @@ export const MsgMultiHopSwapResponse = { if (object.coinOut !== undefined && object.coinOut !== null) { message.coinOut = Coin.fromPartial(object.coinOut); } + if (object.route !== undefined && object.route !== null) { + message.route = MultiHopRoute.fromPartial(object.route); + } + message.dust = object.dust?.map((e) => Coin.fromPartial(e)) || []; return message; }, }; diff --git a/src/neutron/ibcratelimit/v1beta1/genesis.ts b/src/neutron/ibcratelimit/v1beta1/genesis.ts new file mode 100644 index 0000000..f4d8161 --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/genesis.ts @@ -0,0 +1,59 @@ +/* eslint-disable */ +import { Params } from "./params"; +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; +import { JsonSafe } from "../../../json-safe"; +export const protobufPackage = "neutron.ibcratelimit.v1beta1"; +/** GenesisState defines the ibc-rate-limit module's genesis state. */ +export interface GenesisState { + /** params are all the parameters of the module */ + params: Params; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + }; +} +export const GenesisState = { + typeUrl: "/neutron.ibcratelimit.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + 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): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, +}; diff --git a/src/neutron/ibcratelimit/v1beta1/params.ts b/src/neutron/ibcratelimit/v1beta1/params.ts new file mode 100644 index 0000000..f66210e --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/params.ts @@ -0,0 +1,55 @@ +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; +import { JsonSafe } from "../../../json-safe"; +export const protobufPackage = "neutron.ibcratelimit.v1beta1"; +/** Params defines the parameters for the ibc-rate-limit module. */ +export interface Params { + contractAddress?: string; +} +function createBaseParams(): Params { + return { + contractAddress: undefined, + }; +} +export const Params = { + typeUrl: "/neutron.ibcratelimit.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + message.contractAddress = object.contractAddress ?? undefined; + return message; + }, +}; diff --git a/src/neutron/ibcratelimit/v1beta1/query.rpc.Query.ts b/src/neutron/ibcratelimit/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000..1624e58 --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/query.rpc.Query.ts @@ -0,0 +1,34 @@ +/* eslint-disable */ +import { Rpc } from "../../../helpers"; +import { BinaryReader } from "../../../binary"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsResponse } from "./query"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** + * Params defines a gRPC query method that returns the ibc-rate-limit module's + * parameters. + */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("neutron.ibcratelimit.v1beta1.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + }; +}; diff --git a/src/neutron/ibcratelimit/v1beta1/query.ts b/src/neutron/ibcratelimit/v1beta1/query.ts new file mode 100644 index 0000000..fd14b31 --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/query.ts @@ -0,0 +1,96 @@ +/* eslint-disable */ +import { Params } from "./params"; +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { JsonSafe } from "../../../json-safe"; +import { DeepPartial, Exact, isSet } from "../../../helpers"; +export const protobufPackage = "neutron.ibcratelimit.v1beta1"; +/** ParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +/** aramsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/neutron.ibcratelimit.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}), + }; +} +export const QueryParamsResponse = { + typeUrl: "/neutron.ibcratelimit.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + 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 obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, +}; diff --git a/src/neutron/ibcratelimit/v1beta1/tx.rpc.msg.ts b/src/neutron/ibcratelimit/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000..ea4b621 --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,20 @@ +/* eslint-disable */ +import { Rpc } from "../../../helpers"; +import { BinaryReader } from "../../../binary"; +import { MsgUpdateParams, MsgUpdateParamsResponse } from "./tx"; +/** Msg defines the tokefactory module's gRPC message service. */ +export interface Msg { + updateParams(request: MsgUpdateParams): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.updateParams = this.updateParams.bind(this); + } + updateParams(request: MsgUpdateParams): Promise { + const data = MsgUpdateParams.encode(request).finish(); + const promise = this.rpc.request("neutron.ibcratelimit.v1beta1.Msg", "UpdateParams", data); + return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); + } +} diff --git a/src/neutron/ibcratelimit/v1beta1/tx.ts b/src/neutron/ibcratelimit/v1beta1/tx.ts new file mode 100644 index 0000000..9120e96 --- /dev/null +++ b/src/neutron/ibcratelimit/v1beta1/tx.ts @@ -0,0 +1,121 @@ +/* eslint-disable */ +import { Params } from "../../../cosmos/bank/v1beta1/bank"; +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; +import { JsonSafe } from "../../../json-safe"; +export const protobufPackage = "neutron.ibcratelimit.v1beta1"; +/** + * MsgUpdateParams is the MsgUpdateParams request type. + * + * Since: 0.47 + */ +export interface MsgUpdateParams { + /** Authority is the address of the governance account. */ + authority: string; + /** + * params defines the x/tokenfactory parameters to update. + * + * NOTE: All parameters must be supplied. + */ + params: Params; +} +/** + * MsgUpdateParamsResponse defines the response structure for executing a + * MsgUpdateParams message. + * + * Since: 0.47 + */ +export interface MsgUpdateParamsResponse {} +function createBaseMsgUpdateParams(): MsgUpdateParams { + return { + authority: "", + params: Params.fromPartial({}), + }; +} +export const MsgUpdateParams = { + typeUrl: "/neutron.ibcratelimit.v1beta1.MsgUpdateParams", + encode(message: MsgUpdateParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authority !== "") { + writer.uint32(10).string(message.authority); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateParams { + const obj = createBaseMsgUpdateParams(); + if (isSet(object.authority)) obj.authority = String(object.authority); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: MsgUpdateParams): JsonSafe { + const obj: any = {}; + message.authority !== undefined && (obj.authority = message.authority); + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateParams { + const message = createBaseMsgUpdateParams(); + message.authority = object.authority ?? ""; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, +}; +function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse { + return {}; +} +export const MsgUpdateParamsResponse = { + typeUrl: "/neutron.ibcratelimit.v1beta1.MsgUpdateParamsResponse", + encode(_: MsgUpdateParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateParamsResponse { + const obj = createBaseMsgUpdateParamsResponse(); + return obj; + }, + toJSON(_: MsgUpdateParamsResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateParamsResponse { + const message = createBaseMsgUpdateParamsResponse(); + return message; + }, +}; diff --git a/src/neutron/rpc.query.ts b/src/neutron/rpc.query.ts index e147667..8e64853 100644 --- a/src/neutron/rpc.query.ts +++ b/src/neutron/rpc.query.ts @@ -100,6 +100,9 @@ export const createRPCQueryClient = async ({ rpcEndpoint }: { rpcEndpoint: strin }, feeburner: (await import("./feeburner/query.rpc.Query")).createRpcQueryExtension(client), feerefunder: (await import("./feerefunder/query.rpc.Query")).createRpcQueryExtension(client), + ibcratelimit: { + v1beta1: (await import("./ibcratelimit/v1beta1/query.rpc.Query")).createRpcQueryExtension(client), + }, interchainqueries: (await import("./interchainqueries/query.rpc.Query")).createRpcQueryExtension( client, ), diff --git a/src/neutron/rpc.tx.ts b/src/neutron/rpc.tx.ts index 773280d..42f1068 100644 --- a/src/neutron/rpc.tx.ts +++ b/src/neutron/rpc.tx.ts @@ -67,6 +67,9 @@ export const createRPCMsgClient = async ({ rpc }: { rpc: Rpc }) => ({ }, feeburner: new (await import("./feeburner/tx.rpc.msg")).MsgClientImpl(rpc), feerefunder: new (await import("./feerefunder/tx.rpc.msg")).MsgClientImpl(rpc), + ibcratelimit: { + v1beta1: new (await import("./ibcratelimit/v1beta1/tx.rpc.msg")).MsgClientImpl(rpc), + }, interchainqueries: new (await import("./interchainqueries/tx.rpc.msg")).MsgClientImpl(rpc), interchaintxs: { v1: new (await import("./interchaintxs/v1/tx.rpc.msg")).MsgClientImpl(rpc), From 95a719604fecba39de5540b6ac99ded3e7aacfaa Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 25 Nov 2024 19:50:40 +0300 Subject: [PATCH 2/2] fixed typos --- scripts/set-versions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/set-versions.sh b/scripts/set-versions.sh index 24e3ccc..d2efbe4 100755 --- a/scripts/set-versions.sh +++ b/scripts/set-versions.sh @@ -11,7 +11,7 @@ readonly IBC_GO_DIR="ibc-go-src" readonly NEUTRON_DIR="neutron-src" readonly SLINKY_DIR="slinky-src" readonly WASMD_DIR="wasmd-src" -readonly ISC_DIR="interchain-security-src" +readonly ICS_DIR="interchain-security-src" readonly ADMIN_MODULE_REV="v2.0.2" readonly BLOCK_SDK_REV="v2.1.5" @@ -21,7 +21,7 @@ readonly IBC_GO_REV="v8.5.1" readonly NEUTRON_REV="main" readonly SLINKY_REV="v1.0.12" readonly WASMD_REV="v0.51.2-neutron" -readonly ISC_REV="v5.1.1" +readonly ICS_REV="v5.1.1" checkout_version () { git -C protos/$1 checkout $2 @@ -35,4 +35,4 @@ checkout_version $IBC_GO_DIR $IBC_GO_REV checkout_version $NEUTRON_DIR $NEUTRON_REV checkout_version $SLINKY_DIR $SLINKY_REV checkout_version $WASMD_DIR $WASMD_REV -checkout_version $ISC_DIR $ISC_REV +checkout_version $ICS_DIR $ICS_REV