@bandprotocol/bandchain.js
Version:
TypeScript library for Cosmos SDK and BandChain
85 lines (84 loc) • 2.87 kB
JavaScript
//@ts-nocheck
import { Height } from "../../../core/client/v1/client";
import { BinaryReader, BinaryWriter } from "../../../../binary";
function createBaseClientState() {
return {
chainId: "",
height: Height.fromPartial({})
};
}
export const ClientState = {
typeUrl: "/ibc.lightclients.localhost.v1.ClientState",
encode(message, writer = BinaryWriter.create()) {
if (message.chainId !== "") {
writer.uint32(10).string(message.chainId);
}
if (message.height !== undefined) {
Height.encode(message.height, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseClientState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.chainId = reader.string();
break;
case 2:
message.height = Height.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseClientState();
message.chainId = object.chainId ?? "";
message.height = object.height !== undefined && object.height !== null ? Height.fromPartial(object.height) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseClientState();
if (object.chain_id !== undefined && object.chain_id !== null) {
message.chainId = object.chain_id;
}
if (object.height !== undefined && object.height !== null) {
message.height = Height.fromAmino(object.height);
}
return message;
},
toAmino(message) {
const obj = {};
obj.chain_id = message.chainId === "" ? undefined : message.chainId;
obj.height = message.height ? Height.toAmino(message.height) : {};
return obj;
},
fromAminoMsg(object) {
return ClientState.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/ClientState",
value: ClientState.toAmino(message)
};
},
fromProtoMsg(message) {
return ClientState.decode(message.value);
},
toProto(message) {
return ClientState.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/ibc.lightclients.localhost.v1.ClientState",
value: ClientState.encode(message).finish()
};
}
};