@bandprotocol/bandchain.js
Version:
TypeScript library for Cosmos SDK and BandChain
125 lines (124 loc) • 5.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenesisState = void 0;
//@ts-nocheck
const params_1 = require("./params");
const tunnel_1 = require("./tunnel");
const binary_1 = require("../../../binary");
function createBaseGenesisState() {
return {
params: params_1.Params.fromPartial({}),
tunnelCount: BigInt(0),
tunnels: [],
deposits: [],
totalFees: tunnel_1.TotalFees.fromPartial({})
};
}
exports.GenesisState = {
typeUrl: "/band.tunnel.v1beta1.GenesisState",
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.params !== undefined) {
params_1.Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}
if (message.tunnelCount !== BigInt(0)) {
writer.uint32(16).uint64(message.tunnelCount);
}
for (const v of message.tunnels) {
tunnel_1.Tunnel.encode(v, writer.uint32(26).fork()).ldelim();
}
for (const v of message.deposits) {
tunnel_1.Deposit.encode(v, writer.uint32(34).fork()).ldelim();
}
if (message.totalFees !== undefined) {
tunnel_1.TotalFees.encode(message.totalFees, writer.uint32(42).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 = createBaseGenesisState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.params = params_1.Params.decode(reader, reader.uint32());
break;
case 2:
message.tunnelCount = reader.uint64();
break;
case 3:
message.tunnels.push(tunnel_1.Tunnel.decode(reader, reader.uint32()));
break;
case 4:
message.deposits.push(tunnel_1.Deposit.decode(reader, reader.uint32()));
break;
case 5:
message.totalFees = tunnel_1.TotalFees.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? params_1.Params.fromPartial(object.params) : undefined;
message.tunnelCount = object.tunnelCount !== undefined && object.tunnelCount !== null ? BigInt(object.tunnelCount.toString()) : BigInt(0);
message.tunnels = object.tunnels?.map(e => tunnel_1.Tunnel.fromPartial(e)) || [];
message.deposits = object.deposits?.map(e => tunnel_1.Deposit.fromPartial(e)) || [];
message.totalFees = object.totalFees !== undefined && object.totalFees !== null ? tunnel_1.TotalFees.fromPartial(object.totalFees) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseGenesisState();
if (object.params !== undefined && object.params !== null) {
message.params = params_1.Params.fromAmino(object.params);
}
if (object.tunnel_count !== undefined && object.tunnel_count !== null) {
message.tunnelCount = BigInt(object.tunnel_count);
}
message.tunnels = object.tunnels?.map(e => tunnel_1.Tunnel.fromAmino(e)) || [];
message.deposits = object.deposits?.map(e => tunnel_1.Deposit.fromAmino(e)) || [];
if (object.total_fees !== undefined && object.total_fees !== null) {
message.totalFees = tunnel_1.TotalFees.fromAmino(object.total_fees);
}
return message;
},
toAmino(message) {
const obj = {};
obj.params = message.params ? params_1.Params.toAmino(message.params) : undefined;
obj.tunnel_count = message.tunnelCount !== BigInt(0) ? message.tunnelCount?.toString() : undefined;
if (message.tunnels) {
obj.tunnels = message.tunnels.map(e => e ? tunnel_1.Tunnel.toAmino(e) : undefined);
}
else {
obj.tunnels = message.tunnels;
}
if (message.deposits) {
obj.deposits = message.deposits.map(e => e ? tunnel_1.Deposit.toAmino(e) : undefined);
}
else {
obj.deposits = message.deposits;
}
obj.total_fees = message.totalFees ? tunnel_1.TotalFees.toAmino(message.totalFees) : undefined;
return obj;
},
fromAminoMsg(object) {
return exports.GenesisState.fromAmino(object.value);
},
fromProtoMsg(message) {
return exports.GenesisState.decode(message.value);
},
toProto(message) {
return exports.GenesisState.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/band.tunnel.v1beta1.GenesisState",
value: exports.GenesisState.encode(message).finish()
};
}
};