interchainjs
Version:
InterchainJS is a JavaScript library for interacting with Cosmos SDK based blockchains.
111 lines (110 loc) • 4.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenesisState = void 0;
const types_1 = require("./types");
const binary_1 = require("../../../binary");
const registry_1 = require("../../../registry");
function createBaseGenesisState() {
return {
continuousFunds: [],
params: types_1.Params.fromPartial({})
};
}
/**
* GenesisState defines the protocolpool module's genesis state.
* @name GenesisState
* @package cosmos.protocolpool.v1
* @see proto type: cosmos.protocolpool.v1.GenesisState
*/
exports.GenesisState = {
typeUrl: "/cosmos.protocolpool.v1.GenesisState",
aminoType: "cosmos-sdk/GenesisState",
is(o) {
return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.continuousFunds) && (!o.continuousFunds.length || types_1.ContinuousFund.is(o.continuousFunds[0])) && types_1.Params.is(o.params));
},
isAmino(o) {
return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.continuous_funds) && (!o.continuous_funds.length || types_1.ContinuousFund.isAmino(o.continuous_funds[0])) && types_1.Params.isAmino(o.params));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
for (const v of message.continuousFunds) {
types_1.ContinuousFund.encode(v, writer.uint32(10).fork()).ldelim();
}
if (message.params !== undefined) {
types_1.Params.encode(message.params, 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 = createBaseGenesisState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.continuousFunds.push(types_1.ContinuousFund.decode(reader, reader.uint32()));
break;
case 2:
message.params = types_1.Params.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseGenesisState();
message.continuousFunds = object.continuousFunds?.map(e => types_1.ContinuousFund.fromPartial(e)) || [];
message.params = object.params !== undefined && object.params !== null ? types_1.Params.fromPartial(object.params) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseGenesisState();
message.continuousFunds = object.continuous_funds?.map(e => types_1.ContinuousFund.fromAmino(e)) || [];
if (object.params !== undefined && object.params !== null) {
message.params = types_1.Params.fromAmino(object.params);
}
return message;
},
toAmino(message) {
const obj = {};
if (message.continuousFunds) {
obj.continuous_funds = message.continuousFunds.map(e => e ? types_1.ContinuousFund.toAmino(e) : undefined);
}
else {
obj.continuous_funds = message.continuousFunds;
}
obj.params = message.params ? types_1.Params.toAmino(message.params) : undefined;
return obj;
},
fromAminoMsg(object) {
return exports.GenesisState.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/GenesisState",
value: exports.GenesisState.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.GenesisState.decode(message.value);
},
toProto(message) {
return exports.GenesisState.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.protocolpool.v1.GenesisState",
value: exports.GenesisState.encode(message).finish()
};
},
registerTypeUrl() {
if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.GenesisState.typeUrl)) {
return;
}
types_1.ContinuousFund.registerTypeUrl();
types_1.Params.registerTypeUrl();
}
};