UNPKG

interchainjs

Version:

InterchainJS is a JavaScript library for interacting with Cosmos SDK based blockchains.

492 lines (491 loc) 18.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Params = exports.Height = exports.ClientConsensusStates = exports.ConsensusStateWithHeight = exports.IdentifiedClientState = void 0; const any_1 = require("../../../../google/protobuf/any"); const binary_1 = require("../../../../binary"); const registry_1 = require("../../../../registry"); function createBaseIdentifiedClientState() { return { clientId: "", clientState: undefined }; } /** * IdentifiedClientState defines a client state with an additional client * identifier field. * @name IdentifiedClientState * @package ibc.core.client.v1 * @see proto type: ibc.core.client.v1.IdentifiedClientState */ exports.IdentifiedClientState = { typeUrl: "/ibc.core.client.v1.IdentifiedClientState", aminoType: "cosmos-sdk/IdentifiedClientState", is(o) { return o && (o.$typeUrl === exports.IdentifiedClientState.typeUrl || typeof o.clientId === "string"); }, isAmino(o) { return o && (o.$typeUrl === exports.IdentifiedClientState.typeUrl || typeof o.client_id === "string"); }, encode(message, writer = binary_1.BinaryWriter.create()) { if (message.clientId !== "") { writer.uint32(10).string(message.clientId); } if (message.clientState !== undefined) { any_1.Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseIdentifiedClientState(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.clientId = reader.string(); break; case 2: message.clientState = any_1.Any.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object) { const message = createBaseIdentifiedClientState(); message.clientId = object.clientId ?? ""; message.clientState = object.clientState !== undefined && object.clientState !== null ? any_1.Any.fromPartial(object.clientState) : undefined; return message; }, fromAmino(object) { const message = createBaseIdentifiedClientState(); if (object.client_id !== undefined && object.client_id !== null) { message.clientId = object.client_id; } if (object.client_state !== undefined && object.client_state !== null) { message.clientState = any_1.Any.fromAmino(object.client_state); } return message; }, toAmino(message) { const obj = {}; obj.client_id = message.clientId === "" ? undefined : message.clientId; obj.client_state = message.clientState ? any_1.Any.toAmino(message.clientState) : undefined; return obj; }, fromAminoMsg(object) { return exports.IdentifiedClientState.fromAmino(object.value); }, toAminoMsg(message) { return { type: "cosmos-sdk/IdentifiedClientState", value: exports.IdentifiedClientState.toAmino(message) }; }, fromProtoMsg(message) { return exports.IdentifiedClientState.decode(message.value); }, toProto(message) { return exports.IdentifiedClientState.encode(message).finish(); }, toProtoMsg(message) { return { typeUrl: "/ibc.core.client.v1.IdentifiedClientState", value: exports.IdentifiedClientState.encode(message).finish() }; }, registerTypeUrl() { } }; function createBaseConsensusStateWithHeight() { return { height: exports.Height.fromPartial({}), consensusState: undefined }; } /** * ConsensusStateWithHeight defines a consensus state with an additional height * field. * @name ConsensusStateWithHeight * @package ibc.core.client.v1 * @see proto type: ibc.core.client.v1.ConsensusStateWithHeight */ exports.ConsensusStateWithHeight = { typeUrl: "/ibc.core.client.v1.ConsensusStateWithHeight", aminoType: "cosmos-sdk/ConsensusStateWithHeight", is(o) { return o && (o.$typeUrl === exports.ConsensusStateWithHeight.typeUrl || exports.Height.is(o.height)); }, isAmino(o) { return o && (o.$typeUrl === exports.ConsensusStateWithHeight.typeUrl || exports.Height.isAmino(o.height)); }, encode(message, writer = binary_1.BinaryWriter.create()) { if (message.height !== undefined) { exports.Height.encode(message.height, writer.uint32(10).fork()).ldelim(); } if (message.consensusState !== undefined) { any_1.Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseConsensusStateWithHeight(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.height = exports.Height.decode(reader, reader.uint32()); break; case 2: message.consensusState = any_1.Any.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object) { const message = createBaseConsensusStateWithHeight(); message.height = object.height !== undefined && object.height !== null ? exports.Height.fromPartial(object.height) : undefined; message.consensusState = object.consensusState !== undefined && object.consensusState !== null ? any_1.Any.fromPartial(object.consensusState) : undefined; return message; }, fromAmino(object) { const message = createBaseConsensusStateWithHeight(); if (object.height !== undefined && object.height !== null) { message.height = exports.Height.fromAmino(object.height); } if (object.consensus_state !== undefined && object.consensus_state !== null) { message.consensusState = any_1.Any.fromAmino(object.consensus_state); } return message; }, toAmino(message) { const obj = {}; obj.height = message.height ? exports.Height.toAmino(message.height) : undefined; obj.consensus_state = message.consensusState ? any_1.Any.toAmino(message.consensusState) : undefined; return obj; }, fromAminoMsg(object) { return exports.ConsensusStateWithHeight.fromAmino(object.value); }, toAminoMsg(message) { return { type: "cosmos-sdk/ConsensusStateWithHeight", value: exports.ConsensusStateWithHeight.toAmino(message) }; }, fromProtoMsg(message) { return exports.ConsensusStateWithHeight.decode(message.value); }, toProto(message) { return exports.ConsensusStateWithHeight.encode(message).finish(); }, toProtoMsg(message) { return { typeUrl: "/ibc.core.client.v1.ConsensusStateWithHeight", value: exports.ConsensusStateWithHeight.encode(message).finish() }; }, registerTypeUrl() { } }; function createBaseClientConsensusStates() { return { clientId: "", consensusStates: [] }; } /** * ClientConsensusStates defines all the stored consensus states for a given * client. * @name ClientConsensusStates * @package ibc.core.client.v1 * @see proto type: ibc.core.client.v1.ClientConsensusStates */ exports.ClientConsensusStates = { typeUrl: "/ibc.core.client.v1.ClientConsensusStates", aminoType: "cosmos-sdk/ClientConsensusStates", is(o) { return o && (o.$typeUrl === exports.ClientConsensusStates.typeUrl || typeof o.clientId === "string" && Array.isArray(o.consensusStates) && (!o.consensusStates.length || exports.ConsensusStateWithHeight.is(o.consensusStates[0]))); }, isAmino(o) { return o && (o.$typeUrl === exports.ClientConsensusStates.typeUrl || typeof o.client_id === "string" && Array.isArray(o.consensus_states) && (!o.consensus_states.length || exports.ConsensusStateWithHeight.isAmino(o.consensus_states[0]))); }, encode(message, writer = binary_1.BinaryWriter.create()) { if (message.clientId !== "") { writer.uint32(10).string(message.clientId); } for (const v of message.consensusStates) { exports.ConsensusStateWithHeight.encode(v, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseClientConsensusStates(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.clientId = reader.string(); break; case 2: message.consensusStates.push(exports.ConsensusStateWithHeight.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object) { const message = createBaseClientConsensusStates(); message.clientId = object.clientId ?? ""; message.consensusStates = object.consensusStates?.map(e => exports.ConsensusStateWithHeight.fromPartial(e)) || []; return message; }, fromAmino(object) { const message = createBaseClientConsensusStates(); if (object.client_id !== undefined && object.client_id !== null) { message.clientId = object.client_id; } message.consensusStates = object.consensus_states?.map(e => exports.ConsensusStateWithHeight.fromAmino(e)) || []; return message; }, toAmino(message) { const obj = {}; obj.client_id = message.clientId === "" ? undefined : message.clientId; if (message.consensusStates) { obj.consensus_states = message.consensusStates.map(e => e ? exports.ConsensusStateWithHeight.toAmino(e) : undefined); } else { obj.consensus_states = message.consensusStates; } return obj; }, fromAminoMsg(object) { return exports.ClientConsensusStates.fromAmino(object.value); }, toAminoMsg(message) { return { type: "cosmos-sdk/ClientConsensusStates", value: exports.ClientConsensusStates.toAmino(message) }; }, fromProtoMsg(message) { return exports.ClientConsensusStates.decode(message.value); }, toProto(message) { return exports.ClientConsensusStates.encode(message).finish(); }, toProtoMsg(message) { return { typeUrl: "/ibc.core.client.v1.ClientConsensusStates", value: exports.ClientConsensusStates.encode(message).finish() }; }, registerTypeUrl() { if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ClientConsensusStates.typeUrl)) { return; } exports.ConsensusStateWithHeight.registerTypeUrl(); } }; function createBaseHeight() { return { revisionNumber: BigInt(0), revisionHeight: BigInt(0) }; } /** * Height is a monotonically increasing data type * that can be compared against another Height for the purposes of updating and * freezing clients * * Normally the RevisionHeight is incremented at each height while keeping * RevisionNumber the same. However some consensus algorithms may choose to * reset the height in certain conditions e.g. hard forks, state-machine * breaking changes In these cases, the RevisionNumber is incremented so that * height continues to be monitonically increasing even as the RevisionHeight * gets reset * * Please note that json tags for generated Go code are overridden to explicitly exclude the omitempty jsontag. * This enforces the Go json marshaller to always emit zero values for both revision_number and revision_height. * @name Height * @package ibc.core.client.v1 * @see proto type: ibc.core.client.v1.Height */ exports.Height = { typeUrl: "/ibc.core.client.v1.Height", aminoType: "cosmos-sdk/Height", is(o) { return o && (o.$typeUrl === exports.Height.typeUrl || typeof o.revisionNumber === "bigint" && typeof o.revisionHeight === "bigint"); }, isAmino(o) { return o && (o.$typeUrl === exports.Height.typeUrl || typeof o.revision_number === "bigint" && typeof o.revision_height === "bigint"); }, encode(message, writer = binary_1.BinaryWriter.create()) { if (message.revisionNumber !== BigInt(0)) { writer.uint32(8).uint64(message.revisionNumber); } if (message.revisionHeight !== BigInt(0)) { writer.uint32(16).uint64(message.revisionHeight); } return writer; }, decode(input, length) { const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseHeight(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.revisionNumber = reader.uint64(); break; case 2: message.revisionHeight = reader.uint64(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object) { const message = createBaseHeight(); message.revisionNumber = object.revisionNumber !== undefined && object.revisionNumber !== null ? BigInt(object.revisionNumber.toString()) : BigInt(0); message.revisionHeight = object.revisionHeight !== undefined && object.revisionHeight !== null ? BigInt(object.revisionHeight.toString()) : BigInt(0); return message; }, fromAmino(object) { return { revisionNumber: BigInt(object.revision_number || "0"), revisionHeight: BigInt(object.revision_height || "0") }; }, toAmino(message) { const obj = {}; obj.revision_number = message.revisionNumber ? message.revisionNumber?.toString() : "0"; obj.revision_height = message.revisionHeight ? message.revisionHeight?.toString() : "0"; return obj; }, fromAminoMsg(object) { return exports.Height.fromAmino(object.value); }, toAminoMsg(message) { return { type: "cosmos-sdk/Height", value: exports.Height.toAmino(message) }; }, fromProtoMsg(message) { return exports.Height.decode(message.value); }, toProto(message) { return exports.Height.encode(message).finish(); }, toProtoMsg(message) { return { typeUrl: "/ibc.core.client.v1.Height", value: exports.Height.encode(message).finish() }; }, registerTypeUrl() { } }; function createBaseParams() { return { allowedClients: [] }; } /** * Params defines the set of IBC light client parameters. * @name Params * @package ibc.core.client.v1 * @see proto type: ibc.core.client.v1.Params */ exports.Params = { typeUrl: "/ibc.core.client.v1.Params", aminoType: "cosmos-sdk/Params", is(o) { return o && (o.$typeUrl === exports.Params.typeUrl || Array.isArray(o.allowedClients) && (!o.allowedClients.length || typeof o.allowedClients[0] === "string")); }, isAmino(o) { return o && (o.$typeUrl === exports.Params.typeUrl || Array.isArray(o.allowed_clients) && (!o.allowed_clients.length || typeof o.allowed_clients[0] === "string")); }, encode(message, writer = binary_1.BinaryWriter.create()) { for (const v of message.allowedClients) { writer.uint32(10).string(v); } return writer; }, decode(input, length) { const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.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.allowedClients.push(reader.string()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object) { const message = createBaseParams(); message.allowedClients = object.allowedClients?.map(e => e) || []; return message; }, fromAmino(object) { const message = createBaseParams(); message.allowedClients = object.allowed_clients?.map(e => e) || []; return message; }, toAmino(message) { const obj = {}; if (message.allowedClients) { obj.allowed_clients = message.allowedClients.map(e => e); } else { obj.allowed_clients = message.allowedClients; } return obj; }, fromAminoMsg(object) { return exports.Params.fromAmino(object.value); }, toAminoMsg(message) { return { type: "cosmos-sdk/Params", value: exports.Params.toAmino(message) }; }, fromProtoMsg(message) { return exports.Params.decode(message.value); }, toProto(message) { return exports.Params.encode(message).finish(); }, toProtoMsg(message) { return { typeUrl: "/ibc.core.client.v1.Params", value: exports.Params.encode(message).finish() }; }, registerTypeUrl() { } };