//@ts-nocheck
import { Coin } from "../../base/v1beta1/coin";
import { Any } from "../../../google/protobuf/any";
import { Timestamp } from "../../../google/protobuf/timestamp";
import { Duration } from "../../../google/protobuf/duration";
import { isSet, toTimestamp, fromTimestamp, bytesFromBase64, base64FromBytes } from "../../../helpers";
import { BinaryReader, BinaryWriter } from "../../../binary";
import { Decimal } from "@cosmjs/math";
import { GlobalDecoderRegistry } from "../../../registry";
/** VoteOption enumerates the valid vote options for a given governance proposal. */
export var VoteOption;
(function (VoteOption) {
/** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */
VoteOption[VoteOption["VOTE_OPTION_UNSPECIFIED"] = 0] = "VOTE_OPTION_UNSPECIFIED";
/** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */
VoteOption[VoteOption["VOTE_OPTION_YES"] = 1] = "VOTE_OPTION_YES";
/** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */
VoteOption[VoteOption["VOTE_OPTION_ABSTAIN"] = 2] = "VOTE_OPTION_ABSTAIN";
/** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */
VoteOption[VoteOption["VOTE_OPTION_NO"] = 3] = "VOTE_OPTION_NO";
/** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */
VoteOption[VoteOption["VOTE_OPTION_NO_WITH_VETO"] = 4] = "VOTE_OPTION_NO_WITH_VETO";
VoteOption[VoteOption["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(VoteOption || (VoteOption = {}));
export const VoteOptionSDKType = VoteOption;
export const VoteOptionAmino = VoteOption;
export function voteOptionFromJSON(object) {
switch (object) {
case 0:
case "VOTE_OPTION_UNSPECIFIED":
return VoteOption.VOTE_OPTION_UNSPECIFIED;
case 1:
case "VOTE_OPTION_YES":
return VoteOption.VOTE_OPTION_YES;
case 2:
case "VOTE_OPTION_ABSTAIN":
return VoteOption.VOTE_OPTION_ABSTAIN;
case 3:
case "VOTE_OPTION_NO":
return VoteOption.VOTE_OPTION_NO;
case 4:
case "VOTE_OPTION_NO_WITH_VETO":
return VoteOption.VOTE_OPTION_NO_WITH_VETO;
case -1:
case "UNRECOGNIZED":
default:
return VoteOption.UNRECOGNIZED;
}
}
export function voteOptionToJSON(object) {
switch (object) {
case VoteOption.VOTE_OPTION_UNSPECIFIED:
return "VOTE_OPTION_UNSPECIFIED";
case VoteOption.VOTE_OPTION_YES:
return "VOTE_OPTION_YES";
case VoteOption.VOTE_OPTION_ABSTAIN:
return "VOTE_OPTION_ABSTAIN";
case VoteOption.VOTE_OPTION_NO:
return "VOTE_OPTION_NO";
case VoteOption.VOTE_OPTION_NO_WITH_VETO:
return "VOTE_OPTION_NO_WITH_VETO";
case VoteOption.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/** ProposalStatus enumerates the valid statuses of a proposal. */
export var ProposalStatus;
(function (ProposalStatus) {
/** PROPOSAL_STATUS_UNSPECIFIED - PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status. */
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_UNSPECIFIED"] = 0] = "PROPOSAL_STATUS_UNSPECIFIED";
/**
* PROPOSAL_STATUS_DEPOSIT_PERIOD - PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
* period.
*/
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_DEPOSIT_PERIOD"] = 1] = "PROPOSAL_STATUS_DEPOSIT_PERIOD";
/**
* PROPOSAL_STATUS_VOTING_PERIOD - PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting
* period.
*/
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_VOTING_PERIOD"] = 2] = "PROPOSAL_STATUS_VOTING_PERIOD";
/**
* PROPOSAL_STATUS_PASSED - PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has
* passed.
*/
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_PASSED"] = 3] = "PROPOSAL_STATUS_PASSED";
/**
* PROPOSAL_STATUS_REJECTED - PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has
* been rejected.
*/
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_REJECTED"] = 4] = "PROPOSAL_STATUS_REJECTED";
/**
* PROPOSAL_STATUS_FAILED - PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has
* failed.
*/
ProposalStatus[ProposalStatus["PROPOSAL_STATUS_FAILED"] = 5] = "PROPOSAL_STATUS_FAILED";
ProposalStatus[ProposalStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ProposalStatus || (ProposalStatus = {}));
export const ProposalStatusSDKType = ProposalStatus;
export const ProposalStatusAmino = ProposalStatus;
export function proposalStatusFromJSON(object) {
switch (object) {
case 0:
case "PROPOSAL_STATUS_UNSPECIFIED":
return ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED;
case 1:
case "PROPOSAL_STATUS_DEPOSIT_PERIOD":
return ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD;
case 2:
case "PROPOSAL_STATUS_VOTING_PERIOD":
return ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD;
case 3:
case "PROPOSAL_STATUS_PASSED":
return ProposalStatus.PROPOSAL_STATUS_PASSED;
case 4:
case "PROPOSAL_STATUS_REJECTED":
return ProposalStatus.PROPOSAL_STATUS_REJECTED;
case 5:
case "PROPOSAL_STATUS_FAILED":
return ProposalStatus.PROPOSAL_STATUS_FAILED;
case -1:
case "UNRECOGNIZED":
default:
return ProposalStatus.UNRECOGNIZED;
}
}
export function proposalStatusToJSON(object) {
switch (object) {
case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED:
return "PROPOSAL_STATUS_UNSPECIFIED";
case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD:
return "PROPOSAL_STATUS_DEPOSIT_PERIOD";
case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD:
return "PROPOSAL_STATUS_VOTING_PERIOD";
case ProposalStatus.PROPOSAL_STATUS_PASSED:
return "PROPOSAL_STATUS_PASSED";
case ProposalStatus.PROPOSAL_STATUS_REJECTED:
return "PROPOSAL_STATUS_REJECTED";
case ProposalStatus.PROPOSAL_STATUS_FAILED:
return "PROPOSAL_STATUS_FAILED";
case ProposalStatus.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseWeightedVoteOption() {
return {
option: 0,
weight: ""
};
}
export const WeightedVoteOption = {
typeUrl: "/cosmos.gov.v1beta1.WeightedVoteOption",
aminoType: "cosmos-sdk/WeightedVoteOption",
is(o) {
return o && (o.$typeUrl === WeightedVoteOption.typeUrl || isSet(o.option) && typeof o.weight === "string");
},
isSDK(o) {
return o && (o.$typeUrl === WeightedVoteOption.typeUrl || isSet(o.option) && typeof o.weight === "string");
},
isAmino(o) {
return o && (o.$typeUrl === WeightedVoteOption.typeUrl || isSet(o.option) && typeof o.weight === "string");
},
encode(message, writer = BinaryWriter.create()) {
if (message.option !== 0) {
writer.uint32(8).int32(message.option);
}
if (message.weight !== "") {
writer.uint32(18).string(Decimal.fromUserInput(message.weight, 18).atomics);
}
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 = createBaseWeightedVoteOption();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.option = reader.int32();
break;
case 2:
message.weight = Decimal.fromAtomics(reader.string(), 18).toString();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseWeightedVoteOption();
message.option = object.option ?? 0;
message.weight = object.weight ?? "";
return message;
},
fromAmino(object) {
const message = createBaseWeightedVoteOption();
if (object.option !== undefined && object.option !== null) {
message.option = object.option;
}
if (object.weight !== undefined && object.weight !== null) {
message.weight = object.weight;
}
return message;
},
toAmino(message) {
const obj = {};
obj.option = message.option === 0 ? undefined : message.option;
obj.weight = message.weight === "" ? undefined : message.weight;
return obj;
},
fromAminoMsg(object) {
return WeightedVoteOption.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/WeightedVoteOption",
value: WeightedVoteOption.toAmino(message)
};
},
fromProtoMsg(message) {
return WeightedVoteOption.decode(message.value);
},
toProto(message) {
return WeightedVoteOption.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.WeightedVoteOption",
value: WeightedVoteOption.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(WeightedVoteOption.typeUrl, WeightedVoteOption);
GlobalDecoderRegistry.registerAminoProtoMapping(WeightedVoteOption.aminoType, WeightedVoteOption.typeUrl);
function createBaseTextProposal() {
return {
$typeUrl: "/cosmos.gov.v1beta1.TextProposal",
title: "",
description: ""
};
}
export const TextProposal = {
typeUrl: "/cosmos.gov.v1beta1.TextProposal",
aminoType: "cosmos-sdk/TextProposal",
is(o) {
return o && (o.$typeUrl === TextProposal.typeUrl || typeof o.title === "string" && typeof o.description === "string");
},
isSDK(o) {
return o && (o.$typeUrl === TextProposal.typeUrl || typeof o.title === "string" && typeof o.description === "string");
},
isAmino(o) {
return o && (o.$typeUrl === TextProposal.typeUrl || typeof o.title === "string" && typeof o.description === "string");
},
encode(message, writer = BinaryWriter.create()) {
if (message.title !== "") {
writer.uint32(10).string(message.title);
}
if (message.description !== "") {
writer.uint32(18).string(message.description);
}
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 = createBaseTextProposal();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.title = reader.string();
break;
case 2:
message.description = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseTextProposal();
message.title = object.title ?? "";
message.description = object.description ?? "";
return message;
},
fromAmino(object) {
const message = createBaseTextProposal();
if (object.title !== undefined && object.title !== null) {
message.title = object.title;
}
if (object.description !== undefined && object.description !== null) {
message.description = object.description;
}
return message;
},
toAmino(message) {
const obj = {};
obj.title = message.title === "" ? undefined : message.title;
obj.description = message.description === "" ? undefined : message.description;
return obj;
},
fromAminoMsg(object) {
return TextProposal.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/TextProposal",
value: TextProposal.toAmino(message)
};
},
fromProtoMsg(message) {
return TextProposal.decode(message.value);
},
toProto(message) {
return TextProposal.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.TextProposal",
value: TextProposal.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(TextProposal.typeUrl, TextProposal);
GlobalDecoderRegistry.registerAminoProtoMapping(TextProposal.aminoType, TextProposal.typeUrl);
function createBaseDeposit() {
return {
proposalId: BigInt(0),
depositor: "",
amount: []
};
}
export const Deposit = {
typeUrl: "/cosmos.gov.v1beta1.Deposit",
aminoType: "cosmos-sdk/Deposit",
is(o) {
return o && (o.$typeUrl === Deposit.typeUrl || typeof o.proposalId === "bigint" && typeof o.depositor === "string" && Array.isArray(o.amount) && (!o.amount.length || Coin.is(o.amount[0])));
},
isSDK(o) {
return o && (o.$typeUrl === Deposit.typeUrl || typeof o.proposal_id === "bigint" && typeof o.depositor === "string" && Array.isArray(o.amount) && (!o.amount.length || Coin.isSDK(o.amount[0])));
},
isAmino(o) {
return o && (o.$typeUrl === Deposit.typeUrl || typeof o.proposal_id === "bigint" && typeof o.depositor === "string" && Array.isArray(o.amount) && (!o.amount.length || Coin.isAmino(o.amount[0])));
},
encode(message, writer = BinaryWriter.create()) {
if (message.proposalId !== BigInt(0)) {
writer.uint32(8).uint64(message.proposalId);
}
if (message.depositor !== "") {
writer.uint32(18).string(message.depositor);
}
for (const v of message.amount) {
Coin.encode(v, writer.uint32(26).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 = createBaseDeposit();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.proposalId = reader.uint64();
break;
case 2:
message.depositor = reader.string();
break;
case 3:
message.amount.push(Coin.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDeposit();
message.proposalId = object.proposalId !== undefined && object.proposalId !== null ? BigInt(object.proposalId.toString()) : BigInt(0);
message.depositor = object.depositor ?? "";
message.amount = object.amount?.map(e => Coin.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseDeposit();
if (object.proposal_id !== undefined && object.proposal_id !== null) {
message.proposalId = BigInt(object.proposal_id);
}
if (object.depositor !== undefined && object.depositor !== null) {
message.depositor = object.depositor;
}
message.amount = object.amount?.map(e => Coin.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId.toString() : undefined;
obj.depositor = message.depositor === "" ? undefined : message.depositor;
if (message.amount) {
obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined);
}
else {
obj.amount = message.amount;
}
return obj;
},
fromAminoMsg(object) {
return Deposit.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Deposit",
value: Deposit.toAmino(message)
};
},
fromProtoMsg(message) {
return Deposit.decode(message.value);
},
toProto(message) {
return Deposit.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.Deposit",
value: Deposit.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(Deposit.typeUrl, Deposit);
GlobalDecoderRegistry.registerAminoProtoMapping(Deposit.aminoType, Deposit.typeUrl);
function createBaseProposal() {
return {
proposalId: BigInt(0),
content: undefined,
status: 0,
finalTallyResult: TallyResult.fromPartial({}),
submitTime: new Date(),
depositEndTime: new Date(),
totalDeposit: [],
votingStartTime: new Date(),
votingEndTime: new Date()
};
}
export const Proposal = {
typeUrl: "/cosmos.gov.v1beta1.Proposal",
aminoType: "cosmos-sdk/Proposal",
is(o) {
return o && (o.$typeUrl === Proposal.typeUrl || typeof o.proposalId === "bigint" && isSet(o.status) && TallyResult.is(o.finalTallyResult) && Timestamp.is(o.submitTime) && Timestamp.is(o.depositEndTime) && Array.isArray(o.totalDeposit) && (!o.totalDeposit.length || Coin.is(o.totalDeposit[0])) && Timestamp.is(o.votingStartTime) && Timestamp.is(o.votingEndTime));
},
isSDK(o) {
return o && (o.$typeUrl === Proposal.typeUrl || typeof o.proposal_id === "bigint" && isSet(o.status) && TallyResult.isSDK(o.final_tally_result) && Timestamp.isSDK(o.submit_time) && Timestamp.isSDK(o.deposit_end_time) && Array.isArray(o.total_deposit) && (!o.total_deposit.length || Coin.isSDK(o.total_deposit[0])) && Timestamp.isSDK(o.voting_start_time) && Timestamp.isSDK(o.voting_end_time));
},
isAmino(o) {
return o && (o.$typeUrl === Proposal.typeUrl || typeof o.proposal_id === "bigint" && isSet(o.status) && TallyResult.isAmino(o.final_tally_result) && Timestamp.isAmino(o.submit_time) && Timestamp.isAmino(o.deposit_end_time) && Array.isArray(o.total_deposit) && (!o.total_deposit.length || Coin.isAmino(o.total_deposit[0])) && Timestamp.isAmino(o.voting_start_time) && Timestamp.isAmino(o.voting_end_time));
},
encode(message, writer = BinaryWriter.create()) {
if (message.proposalId !== BigInt(0)) {
writer.uint32(8).uint64(message.proposalId);
}
if (message.content !== undefined) {
Any.encode(GlobalDecoderRegistry.wrapAny(message.content), writer.uint32(18).fork()).ldelim();
}
if (message.status !== 0) {
writer.uint32(24).int32(message.status);
}
if (message.finalTallyResult !== undefined) {
TallyResult.encode(message.finalTallyResult, writer.uint32(34).fork()).ldelim();
}
if (message.submitTime !== undefined) {
Timestamp.encode(toTimestamp(message.submitTime), writer.uint32(42).fork()).ldelim();
}
if (message.depositEndTime !== undefined) {
Timestamp.encode(toTimestamp(message.depositEndTime), writer.uint32(50).fork()).ldelim();
}
for (const v of message.totalDeposit) {
Coin.encode(v, writer.uint32(58).fork()).ldelim();
}
if (message.votingStartTime !== undefined) {
Timestamp.encode(toTimestamp(message.votingStartTime), writer.uint32(66).fork()).ldelim();
}
if (message.votingEndTime !== undefined) {
Timestamp.encode(toTimestamp(message.votingEndTime), writer.uint32(74).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 = createBaseProposal();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.proposalId = reader.uint64();
break;
case 2:
message.content = GlobalDecoderRegistry.unwrapAny(reader);
break;
case 3:
message.status = reader.int32();
break;
case 4:
message.finalTallyResult = TallyResult.decode(reader, reader.uint32());
break;
case 5:
message.submitTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;
case 6:
message.depositEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;
case 7:
message.totalDeposit.push(Coin.decode(reader, reader.uint32()));
break;
case 8:
message.votingStartTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;
case 9:
message.votingEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseProposal();
message.proposalId = object.proposalId !== undefined && object.proposalId !== null ? BigInt(object.proposalId.toString()) : BigInt(0);
message.content = object.content !== undefined && object.content !== null ? GlobalDecoderRegistry.fromPartial(object.content) : undefined;
message.status = object.status ?? 0;
message.finalTallyResult = object.finalTallyResult !== undefined && object.finalTallyResult !== null ? TallyResult.fromPartial(object.finalTallyResult) : undefined;
message.submitTime = object.submitTime ?? undefined;
message.depositEndTime = object.depositEndTime ?? undefined;
message.totalDeposit = object.totalDeposit?.map(e => Coin.fromPartial(e)) || [];
message.votingStartTime = object.votingStartTime ?? undefined;
message.votingEndTime = object.votingEndTime ?? undefined;
return message;
},
fromAmino(object) {
const message = createBaseProposal();
if (object.proposal_id !== undefined && object.proposal_id !== null) {
message.proposalId = BigInt(object.proposal_id);
}
if (object.content !== undefined && object.content !== null) {
message.content = GlobalDecoderRegistry.fromAminoMsg(object.content);
}
if (object.status !== undefined && object.status !== null) {
message.status = object.status;
}
if (object.final_tally_result !== undefined && object.final_tally_result !== null) {
message.finalTallyResult = TallyResult.fromAmino(object.final_tally_result);
}
if (object.submit_time !== undefined && object.submit_time !== null) {
message.submitTime = fromTimestamp(Timestamp.fromAmino(object.submit_time));
}
if (object.deposit_end_time !== undefined && object.deposit_end_time !== null) {
message.depositEndTime = fromTimestamp(Timestamp.fromAmino(object.deposit_end_time));
}
message.totalDeposit = object.total_deposit?.map(e => Coin.fromAmino(e)) || [];
if (object.voting_start_time !== undefined && object.voting_start_time !== null) {
message.votingStartTime = fromTimestamp(Timestamp.fromAmino(object.voting_start_time));
}
if (object.voting_end_time !== undefined && object.voting_end_time !== null) {
message.votingEndTime = fromTimestamp(Timestamp.fromAmino(object.voting_end_time));
}
return message;
},
toAmino(message) {
const obj = {};
obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId.toString() : undefined;
obj.content = message.content ? GlobalDecoderRegistry.toAminoMsg(message.content) : undefined;
obj.status = message.status === 0 ? undefined : message.status;
obj.final_tally_result = message.finalTallyResult ? TallyResult.toAmino(message.finalTallyResult) : TallyResult.toAmino(TallyResult.fromPartial({}));
obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : new Date();
obj.deposit_end_time = message.depositEndTime ? Timestamp.toAmino(toTimestamp(message.depositEndTime)) : new Date();
if (message.totalDeposit) {
obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toAmino(e) : undefined);
}
else {
obj.total_deposit = message.totalDeposit;
}
obj.voting_start_time = message.votingStartTime ? Timestamp.toAmino(toTimestamp(message.votingStartTime)) : new Date();
obj.voting_end_time = message.votingEndTime ? Timestamp.toAmino(toTimestamp(message.votingEndTime)) : new Date();
return obj;
},
fromAminoMsg(object) {
return Proposal.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Proposal",
value: Proposal.toAmino(message)
};
},
fromProtoMsg(message) {
return Proposal.decode(message.value);
},
toProto(message) {
return Proposal.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.Proposal",
value: Proposal.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(Proposal.typeUrl, Proposal);
GlobalDecoderRegistry.registerAminoProtoMapping(Proposal.aminoType, Proposal.typeUrl);
function createBaseTallyResult() {
return {
yes: "",
abstain: "",
no: "",
noWithVeto: ""
};
}
export const TallyResult = {
typeUrl: "/cosmos.gov.v1beta1.TallyResult",
aminoType: "cosmos-sdk/TallyResult",
is(o) {
return o && (o.$typeUrl === TallyResult.typeUrl || typeof o.yes === "string" && typeof o.abstain === "string" && typeof o.no === "string" && typeof o.noWithVeto === "string");
},
isSDK(o) {
return o && (o.$typeUrl === TallyResult.typeUrl || typeof o.yes === "string" && typeof o.abstain === "string" && typeof o.no === "string" && typeof o.no_with_veto === "string");
},
isAmino(o) {
return o && (o.$typeUrl === TallyResult.typeUrl || typeof o.yes === "string" && typeof o.abstain === "string" && typeof o.no === "string" && typeof o.no_with_veto === "string");
},
encode(message, writer = BinaryWriter.create()) {
if (message.yes !== "") {
writer.uint32(10).string(message.yes);
}
if (message.abstain !== "") {
writer.uint32(18).string(message.abstain);
}
if (message.no !== "") {
writer.uint32(26).string(message.no);
}
if (message.noWithVeto !== "") {
writer.uint32(34).string(message.noWithVeto);
}
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 = createBaseTallyResult();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.yes = reader.string();
break;
case 2:
message.abstain = reader.string();
break;
case 3:
message.no = reader.string();
break;
case 4:
message.noWithVeto = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseTallyResult();
message.yes = object.yes ?? "";
message.abstain = object.abstain ?? "";
message.no = object.no ?? "";
message.noWithVeto = object.noWithVeto ?? "";
return message;
},
fromAmino(object) {
const message = createBaseTallyResult();
if (object.yes !== undefined && object.yes !== null) {
message.yes = object.yes;
}
if (object.abstain !== undefined && object.abstain !== null) {
message.abstain = object.abstain;
}
if (object.no !== undefined && object.no !== null) {
message.no = object.no;
}
if (object.no_with_veto !== undefined && object.no_with_veto !== null) {
message.noWithVeto = object.no_with_veto;
}
return message;
},
toAmino(message) {
const obj = {};
obj.yes = message.yes === "" ? undefined : message.yes;
obj.abstain = message.abstain === "" ? undefined : message.abstain;
obj.no = message.no === "" ? undefined : message.no;
obj.no_with_veto = message.noWithVeto === "" ? undefined : message.noWithVeto;
return obj;
},
fromAminoMsg(object) {
return TallyResult.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/TallyResult",
value: TallyResult.toAmino(message)
};
},
fromProtoMsg(message) {
return TallyResult.decode(message.value);
},
toProto(message) {
return TallyResult.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.TallyResult",
value: TallyResult.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(TallyResult.typeUrl, TallyResult);
GlobalDecoderRegistry.registerAminoProtoMapping(TallyResult.aminoType, TallyResult.typeUrl);
function createBaseVote() {
return {
proposalId: BigInt(0),
voter: "",
option: 0,
options: []
};
}
export const Vote = {
typeUrl: "/cosmos.gov.v1beta1.Vote",
aminoType: "cosmos-sdk/Vote",
is(o) {
return o && (o.$typeUrl === Vote.typeUrl || typeof o.proposalId === "bigint" && typeof o.voter === "string" && isSet(o.option) && Array.isArray(o.options) && (!o.options.length || WeightedVoteOption.is(o.options[0])));
},
isSDK(o) {
return o && (o.$typeUrl === Vote.typeUrl || typeof o.proposal_id === "bigint" && typeof o.voter === "string" && isSet(o.option) && Array.isArray(o.options) && (!o.options.length || WeightedVoteOption.isSDK(o.options[0])));
},
isAmino(o) {
return o && (o.$typeUrl === Vote.typeUrl || typeof o.proposal_id === "bigint" && typeof o.voter === "string" && isSet(o.option) && Array.isArray(o.options) && (!o.options.length || WeightedVoteOption.isAmino(o.options[0])));
},
encode(message, writer = BinaryWriter.create()) {
if (message.proposalId !== BigInt(0)) {
writer.uint32(8).uint64(message.proposalId);
}
if (message.voter !== "") {
writer.uint32(18).string(message.voter);
}
if (message.option !== 0) {
writer.uint32(24).int32(message.option);
}
for (const v of message.options) {
WeightedVoteOption.encode(v, writer.uint32(34).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 = createBaseVote();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.proposalId = reader.uint64();
break;
case 2:
message.voter = reader.string();
break;
case 3:
message.option = reader.int32();
break;
case 4:
message.options.push(WeightedVoteOption.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseVote();
message.proposalId = object.proposalId !== undefined && object.proposalId !== null ? BigInt(object.proposalId.toString()) : BigInt(0);
message.voter = object.voter ?? "";
message.option = object.option ?? 0;
message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseVote();
if (object.proposal_id !== undefined && object.proposal_id !== null) {
message.proposalId = BigInt(object.proposal_id);
}
if (object.voter !== undefined && object.voter !== null) {
message.voter = object.voter;
}
if (object.option !== undefined && object.option !== null) {
message.option = object.option;
}
message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
obj.proposal_id = message.proposalId ? message.proposalId.toString() : "0";
obj.voter = message.voter === "" ? undefined : message.voter;
obj.option = message.option === 0 ? undefined : message.option;
if (message.options) {
obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined);
}
else {
obj.options = message.options;
}
return obj;
},
fromAminoMsg(object) {
return Vote.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Vote",
value: Vote.toAmino(message)
};
},
fromProtoMsg(message) {
return Vote.decode(message.value);
},
toProto(message) {
return Vote.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.Vote",
value: Vote.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(Vote.typeUrl, Vote);
GlobalDecoderRegistry.registerAminoProtoMapping(Vote.aminoType, Vote.typeUrl);
function createBaseDepositParams() {
return {
minDeposit: [],
maxDepositPeriod: Duration.fromPartial({})
};
}
export const DepositParams = {
typeUrl: "/cosmos.gov.v1beta1.DepositParams",
aminoType: "cosmos-sdk/DepositParams",
is(o) {
return o && (o.$typeUrl === DepositParams.typeUrl || Array.isArray(o.minDeposit) && (!o.minDeposit.length || Coin.is(o.minDeposit[0])) && Duration.is(o.maxDepositPeriod));
},
isSDK(o) {
return o && (o.$typeUrl === DepositParams.typeUrl || Array.isArray(o.min_deposit) && (!o.min_deposit.length || Coin.isSDK(o.min_deposit[0])) && Duration.isSDK(o.max_deposit_period));
},
isAmino(o) {
return o && (o.$typeUrl === DepositParams.typeUrl || Array.isArray(o.min_deposit) && (!o.min_deposit.length || Coin.isAmino(o.min_deposit[0])) && Duration.isAmino(o.max_deposit_period));
},
encode(message, writer = BinaryWriter.create()) {
for (const v of message.minDeposit) {
Coin.encode(v, writer.uint32(10).fork()).ldelim();
}
if (message.maxDepositPeriod !== undefined) {
Duration.encode(message.maxDepositPeriod, 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 = createBaseDepositParams();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.minDeposit.push(Coin.decode(reader, reader.uint32()));
break;
case 2:
message.maxDepositPeriod = Duration.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDepositParams();
message.minDeposit = object.minDeposit?.map(e => Coin.fromPartial(e)) || [];
message.maxDepositPeriod = object.maxDepositPeriod !== undefined && object.maxDepositPeriod !== null ? Duration.fromPartial(object.maxDepositPeriod) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseDepositParams();
message.minDeposit = object.min_deposit?.map(e => Coin.fromAmino(e)) || [];
if (object.max_deposit_period !== undefined && object.max_deposit_period !== null) {
message.maxDepositPeriod = Duration.fromAmino(object.max_deposit_period);
}
return message;
},
toAmino(message) {
const obj = {};
if (message.minDeposit) {
obj.min_deposit = message.minDeposit.map(e => e ? Coin.toAmino(e) : undefined);
}
else {
obj.min_deposit = message.minDeposit;
}
obj.max_deposit_period = message.maxDepositPeriod ? Duration.toAmino(message.maxDepositPeriod) : undefined;
return obj;
},
fromAminoMsg(object) {
return DepositParams.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/DepositParams",
value: DepositParams.toAmino(message)
};
},
fromProtoMsg(message) {
return DepositParams.decode(message.value);
},
toProto(message) {
return DepositParams.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.DepositParams",
value: DepositParams.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(DepositParams.typeUrl, DepositParams);
GlobalDecoderRegistry.registerAminoProtoMapping(DepositParams.aminoType, DepositParams.typeUrl);
function createBaseVotingParams() {
return {
votingPeriod: Duration.fromPartial({})
};
}
export const VotingParams = {
typeUrl: "/cosmos.gov.v1beta1.VotingParams",
aminoType: "cosmos-sdk/VotingParams",
is(o) {
return o && (o.$typeUrl === VotingParams.typeUrl || Duration.is(o.votingPeriod));
},
isSDK(o) {
return o && (o.$typeUrl === VotingParams.typeUrl || Duration.isSDK(o.voting_period));
},
isAmino(o) {
return o && (o.$typeUrl === VotingParams.typeUrl || Duration.isAmino(o.voting_period));
},
encode(message, writer = BinaryWriter.create()) {
if (message.votingPeriod !== undefined) {
Duration.encode(message.votingPeriod, writer.uint32(10).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 = createBaseVotingParams();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.votingPeriod = Duration.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseVotingParams();
message.votingPeriod = object.votingPeriod !== undefined && object.votingPeriod !== null ? Duration.fromPartial(object.votingPeriod) : undefined;
return message;
},
fromAmino(object) {
const message = createBaseVotingParams();
if (object.voting_period !== undefined && object.voting_period !== null) {
message.votingPeriod = Duration.fromAmino(object.voting_period);
}
return message;
},
toAmino(message) {
const obj = {};
obj.voting_period = message.votingPeriod ? Duration.toAmino(message.votingPeriod) : undefined;
return obj;
},
fromAminoMsg(object) {
return VotingParams.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/VotingParams",
value: VotingParams.toAmino(message)
};
},
fromProtoMsg(message) {
return VotingParams.decode(message.value);
},
toProto(message) {
return VotingParams.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.VotingParams",
value: VotingParams.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(VotingParams.typeUrl, VotingParams);
GlobalDecoderRegistry.registerAminoProtoMapping(VotingParams.aminoType, VotingParams.typeUrl);
function createBaseTallyParams() {
return {
quorum: new Uint8Array(),
threshold: new Uint8Array(),
vetoThreshold: new Uint8Array()
};
}
export const TallyParams = {
typeUrl: "/cosmos.gov.v1beta1.TallyParams",
aminoType: "cosmos-sdk/TallyParams",
is(o) {
return o && (o.$typeUrl === TallyParams.typeUrl || (o.quorum instanceof Uint8Array || typeof o.quorum === "string") && (o.threshold instanceof Uint8Array || typeof o.threshold === "string") && (o.vetoThreshold instanceof Uint8Array || typeof o.vetoThreshold === "string"));
},
isSDK(o) {
return o && (o.$typeUrl === TallyParams.typeUrl || (o.quorum instanceof Uint8Array || typeof o.quorum === "string") && (o.threshold instanceof Uint8Array || typeof o.threshold === "string") && (o.veto_threshold instanceof Uint8Array || typeof o.veto_threshold === "string"));
},
isAmino(o) {
return o && (o.$typeUrl === TallyParams.typeUrl || (o.quorum instanceof Uint8Array || typeof o.quorum === "string") && (o.threshold instanceof Uint8Array || typeof o.threshold === "string") && (o.veto_threshold instanceof Uint8Array || typeof o.veto_threshold === "string"));
},
encode(message, writer = BinaryWriter.create()) {
if (message.quorum.length !== 0) {
writer.uint32(10).bytes(message.quorum);
}
if (message.threshold.length !== 0) {
writer.uint32(18).bytes(message.threshold);
}
if (message.vetoThreshold.length !== 0) {
writer.uint32(26).bytes(message.vetoThreshold);
}
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 = createBaseTallyParams();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.quorum = reader.bytes();
break;
case 2:
message.threshold = reader.bytes();
break;
case 3:
message.vetoThreshold = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseTallyParams();
message.quorum = object.quorum ?? new Uint8Array();
message.threshold = object.threshold ?? new Uint8Array();
message.vetoThreshold = object.vetoThreshold ?? new Uint8Array();
return message;
},
fromAmino(object) {
const message = createBaseTallyParams();
if (object.quorum !== undefined && object.quorum !== null) {
message.quorum = bytesFromBase64(object.quorum);
}
if (object.threshold !== undefined && object.threshold !== null) {
message.threshold = bytesFromBase64(object.threshold);
}
if (object.veto_threshold !== undefined && object.veto_threshold !== null) {
message.vetoThreshold = bytesFromBase64(object.veto_threshold);
}
return message;
},
toAmino(message) {
const obj = {};
obj.quorum = message.quorum ? base64FromBytes(message.quorum) : undefined;
obj.threshold = message.threshold ? base64FromBytes(message.threshold) : undefined;
obj.veto_threshold = message.vetoThreshold ? base64FromBytes(message.vetoThreshold) : undefined;
return obj;
},
fromAminoMsg(object) {
return TallyParams.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/TallyParams",
value: TallyParams.toAmino(message)
};
},
fromProtoMsg(message) {
return TallyParams.decode(message.value);
},
toProto(message) {
return TallyParams.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.gov.v1beta1.TallyParams",
value: TallyParams.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(TallyParams.typeUrl, TallyParams);
GlobalDecoderRegistry.registerAminoProtoMapping(TallyParams.aminoType, TallyParams.typeUrl);