interchainjs
Version:
InterchainJS is a JavaScript library for interacting with Cosmos SDK based blockchains.
489 lines (488 loc) • 18 kB
JavaScript
import { Any } from "../../../../google/protobuf/any";
import { BinaryReader, BinaryWriter } from "../../../../binary";
import { GlobalDecoderRegistry } from "../../../../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
*/
export const IdentifiedClientState = {
typeUrl: "/ibc.core.client.v1.IdentifiedClientState",
aminoType: "cosmos-sdk/IdentifiedClientState",
is(o) {
return o && (o.$typeUrl === IdentifiedClientState.typeUrl || typeof o.clientId === "string");
},
isAmino(o) {
return o && (o.$typeUrl === IdentifiedClientState.typeUrl || typeof o.client_id === "string");
},
encode(message, writer = BinaryWriter.create()) {
if (message.clientId !== "") {
writer.uint32(10).string(message.clientId);
}
if (message.clientState !== undefined) {
Any.encode(message.clientState, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new 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.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.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.fromAmino(object.client_state);
}
return message;
},
toAmino(message) {
const obj = {};
obj.client_id = message.clientId === "" ? undefined : message.clientId;
obj.client_state = message.clientState ? Any.toAmino(message.clientState) : undefined;
return obj;
},
fromAminoMsg(object) {
return IdentifiedClientState.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/IdentifiedClientState",
value: IdentifiedClientState.toAmino(message)
};
},
fromProtoMsg(message) {
return IdentifiedClientState.decode(message.value);
},
toProto(message) {
return IdentifiedClientState.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.core.client.v1.IdentifiedClientState",
value: IdentifiedClientState.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseConsensusStateWithHeight() {
return {
height: 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
*/
export const ConsensusStateWithHeight = {
typeUrl: "/ibc.core.client.v1.ConsensusStateWithHeight",
aminoType: "cosmos-sdk/ConsensusStateWithHeight",
is(o) {
return o && (o.$typeUrl === ConsensusStateWithHeight.typeUrl || Height.is(o.height));
},
isAmino(o) {
return o && (o.$typeUrl === ConsensusStateWithHeight.typeUrl || Height.isAmino(o.height));
},
encode(message, writer = BinaryWriter.create()) {
if (message.height !== undefined) {
Height.encode(message.height, writer.uint32(10).fork()).ldelim();
}
if (message.consensusState !== undefined) {
Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new 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 = Height.decode(reader, reader.uint32());
break;
case 2:
message.consensusState = 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 ? Height.fromPartial(object.height) : undefined;
message.consensusState = object.consensusState !== undefined && object.consensusState !== null ? Any.fromPartial(object.consensusState) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseConsensusStateWithHeight();
if (object.height !== undefined && object.height !== null) {
message.height = Height.fromAmino(object.height);
}
if (object.consensus_state !== undefined && object.consensus_state !== null) {
message.consensusState = Any.fromAmino(object.consensus_state);
}
return message;
},
toAmino(message) {
const obj = {};
obj.height = message.height ? Height.toAmino(message.height) : undefined;
obj.consensus_state = message.consensusState ? Any.toAmino(message.consensusState) : undefined;
return obj;
},
fromAminoMsg(object) {
return ConsensusStateWithHeight.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/ConsensusStateWithHeight",
value: ConsensusStateWithHeight.toAmino(message)
};
},
fromProtoMsg(message) {
return ConsensusStateWithHeight.decode(message.value);
},
toProto(message) {
return ConsensusStateWithHeight.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.core.client.v1.ConsensusStateWithHeight",
value: 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
*/
export const ClientConsensusStates = {
typeUrl: "/ibc.core.client.v1.ClientConsensusStates",
aminoType: "cosmos-sdk/ClientConsensusStates",
is(o) {
return o && (o.$typeUrl === ClientConsensusStates.typeUrl || typeof o.clientId === "string" && Array.isArray(o.consensusStates) && (!o.consensusStates.length || ConsensusStateWithHeight.is(o.consensusStates[0])));
},
isAmino(o) {
return o && (o.$typeUrl === ClientConsensusStates.typeUrl || typeof o.client_id === "string" && Array.isArray(o.consensus_states) && (!o.consensus_states.length || ConsensusStateWithHeight.isAmino(o.consensus_states[0])));
},
encode(message, writer = BinaryWriter.create()) {
if (message.clientId !== "") {
writer.uint32(10).string(message.clientId);
}
for (const v of message.consensusStates) {
ConsensusStateWithHeight.encode(v, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new 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(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 => 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 => 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 ? ConsensusStateWithHeight.toAmino(e) : undefined);
}
else {
obj.consensus_states = message.consensusStates;
}
return obj;
},
fromAminoMsg(object) {
return ClientConsensusStates.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/ClientConsensusStates",
value: ClientConsensusStates.toAmino(message)
};
},
fromProtoMsg(message) {
return ClientConsensusStates.decode(message.value);
},
toProto(message) {
return ClientConsensusStates.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.core.client.v1.ClientConsensusStates",
value: ClientConsensusStates.encode(message).finish()
};
},
registerTypeUrl() {
if (!GlobalDecoderRegistry.registerExistingTypeUrl(ClientConsensusStates.typeUrl)) {
return;
}
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
*/
export const Height = {
typeUrl: "/ibc.core.client.v1.Height",
aminoType: "cosmos-sdk/Height",
is(o) {
return o && (o.$typeUrl === Height.typeUrl || typeof o.revisionNumber === "bigint" && typeof o.revisionHeight === "bigint");
},
isAmino(o) {
return o && (o.$typeUrl === Height.typeUrl || typeof o.revision_number === "bigint" && typeof o.revision_height === "bigint");
},
encode(message, writer = 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 BinaryReader ? input : new 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 Height.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Height",
value: Height.toAmino(message)
};
},
fromProtoMsg(message) {
return Height.decode(message.value);
},
toProto(message) {
return Height.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.core.client.v1.Height",
value: 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
*/
export const Params = {
typeUrl: "/ibc.core.client.v1.Params",
aminoType: "cosmos-sdk/Params",
is(o) {
return o && (o.$typeUrl === Params.typeUrl || Array.isArray(o.allowedClients) && (!o.allowedClients.length || typeof o.allowedClients[0] === "string"));
},
isAmino(o) {
return o && (o.$typeUrl === Params.typeUrl || Array.isArray(o.allowed_clients) && (!o.allowed_clients.length || typeof o.allowed_clients[0] === "string"));
},
encode(message, writer = BinaryWriter.create()) {
for (const v of message.allowedClients) {
writer.uint32(10).string(v);
}
return writer;
},
decode(input, length) {
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.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 Params.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Params",
value: Params.toAmino(message)
};
},
fromProtoMsg(message) {
return Params.decode(message.value);
},
toProto(message) {
return Params.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.core.client.v1.Params",
value: Params.encode(message).finish()
};
},
registerTypeUrl() { }
};