import { Coin, CoinAmino, CoinSDKType } from "../../base/v1beta1/coin"; import { Any, AnyAmino, AnySDKType } from "../../../google/protobuf/any"; import { Timestamp } from "../../../google/protobuf/timestamp"; import { Duration, DurationAmino, DurationSDKType } from "../../../google/protobuf/duration"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { toTimestamp, fromTimestamp } from "../../../helpers"; /** VoteOption enumerates the valid vote options for a given governance proposal. */ export enum VoteOption { /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ VOTE_OPTION_UNSPECIFIED = 0, /** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */ VOTE_OPTION_YES = 1, /** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */ VOTE_OPTION_ABSTAIN = 2, /** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */ VOTE_OPTION_NO = 3, /** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */ VOTE_OPTION_NO_WITH_VETO = 4, UNRECOGNIZED = -1, } export const VoteOptionSDKType = VoteOption; export const VoteOptionAmino = VoteOption; export function voteOptionFromJSON(object: any): VoteOption { 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: VoteOption): string { 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 enum ProposalStatus { /** PROPOSAL_STATUS_UNSPECIFIED - PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. */ PROPOSAL_STATUS_UNSPECIFIED = 0, /** * PROPOSAL_STATUS_DEPOSIT_PERIOD - PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit * period. */ PROPOSAL_STATUS_DEPOSIT_PERIOD = 1, /** * PROPOSAL_STATUS_VOTING_PERIOD - PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting * period. */ PROPOSAL_STATUS_VOTING_PERIOD = 2, /** * PROPOSAL_STATUS_PASSED - PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has * passed. */ PROPOSAL_STATUS_PASSED = 3, /** * PROPOSAL_STATUS_REJECTED - PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has * been rejected. */ PROPOSAL_STATUS_REJECTED = 4, /** * PROPOSAL_STATUS_FAILED - PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has * failed. */ PROPOSAL_STATUS_FAILED = 5, UNRECOGNIZED = -1, } export const ProposalStatusSDKType = ProposalStatus; export const ProposalStatusAmino = ProposalStatus; export function proposalStatusFromJSON(object: any): ProposalStatus { 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: ProposalStatus): string { 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"; } } /** WeightedVoteOption defines a unit of vote for vote split. */ export interface WeightedVoteOption { option: VoteOption; weight: string; } export interface WeightedVoteOptionProtoMsg { typeUrl: "/cosmos.gov.v1.WeightedVoteOption"; value: Uint8Array; } /** WeightedVoteOption defines a unit of vote for vote split. */ export interface WeightedVoteOptionAmino { option?: VoteOption; weight?: string; } export interface WeightedVoteOptionAminoMsg { type: "cosmos-sdk/v1/WeightedVoteOption"; value: WeightedVoteOptionAmino; } /** WeightedVoteOption defines a unit of vote for vote split. */ export interface WeightedVoteOptionSDKType { option: VoteOption; weight: string; } /** * Deposit defines an amount deposited by an account address to an active * proposal. */ export interface Deposit { proposalId: bigint; depositor: string; amount: Coin[]; } export interface DepositProtoMsg { typeUrl: "/cosmos.gov.v1.Deposit"; value: Uint8Array; } /** * Deposit defines an amount deposited by an account address to an active * proposal. */ export interface DepositAmino { proposal_id?: string; depositor?: string; amount?: CoinAmino[]; } export interface DepositAminoMsg { type: "cosmos-sdk/v1/Deposit"; value: DepositAmino; } /** * Deposit defines an amount deposited by an account address to an active * proposal. */ export interface DepositSDKType { proposal_id: bigint; depositor: string; amount: CoinSDKType[]; } /** Proposal defines the core field members of a governance proposal. */ export interface Proposal { id: bigint; messages: Any[]; status: ProposalStatus; /** * final_tally_result is the final tally result of the proposal. When * querying a proposal via gRPC, this field is not populated until the * proposal's voting period has ended. */ finalTallyResult?: TallyResult; submitTime?: Date; depositEndTime?: Date; totalDeposit: Coin[]; votingStartTime?: Date; votingEndTime?: Date; /** metadata is any arbitrary metadata attached to the proposal. */ metadata: string; } export interface ProposalProtoMsg { typeUrl: "/cosmos.gov.v1.Proposal"; value: Uint8Array; } /** Proposal defines the core field members of a governance proposal. */ export interface ProposalAmino { id?: string; messages?: AnyAmino[]; status?: ProposalStatus; /** * final_tally_result is the final tally result of the proposal. When * querying a proposal via gRPC, this field is not populated until the * proposal's voting period has ended. */ final_tally_result?: TallyResultAmino; submit_time?: string; deposit_end_time?: string; total_deposit?: CoinAmino[]; voting_start_time?: string; voting_end_time?: string; /** metadata is any arbitrary metadata attached to the proposal. */ metadata?: string; } export interface ProposalAminoMsg { type: "cosmos-sdk/v1/Proposal"; value: ProposalAmino; } /** Proposal defines the core field members of a governance proposal. */ export interface ProposalSDKType { id: bigint; messages: AnySDKType[]; status: ProposalStatus; final_tally_result?: TallyResultSDKType; submit_time?: Date; deposit_end_time?: Date; total_deposit: CoinSDKType[]; voting_start_time?: Date; voting_end_time?: Date; metadata: string; } /** TallyResult defines a standard tally for a governance proposal. */ export interface TallyResult { yesCount: string; abstainCount: string; noCount: string; noWithVetoCount: string; } export interface TallyResultProtoMsg { typeUrl: "/cosmos.gov.v1.TallyResult"; value: Uint8Array; } /** TallyResult defines a standard tally for a governance proposal. */ export interface TallyResultAmino { yes_count?: string; abstain_count?: string; no_count?: string; no_with_veto_count?: string; } export interface TallyResultAminoMsg { type: "cosmos-sdk/v1/TallyResult"; value: TallyResultAmino; } /** TallyResult defines a standard tally for a governance proposal. */ export interface TallyResultSDKType { yes_count: string; abstain_count: string; no_count: string; no_with_veto_count: string; } /** * Vote defines a vote on a governance proposal. * A Vote consists of a proposal ID, the voter, and the vote option. */ export interface Vote { proposalId: bigint; voter: string; options: WeightedVoteOption[]; /** metadata is any arbitrary metadata to attached to the vote. */ metadata: string; } export interface VoteProtoMsg { typeUrl: "/cosmos.gov.v1.Vote"; value: Uint8Array; } /** * Vote defines a vote on a governance proposal. * A Vote consists of a proposal ID, the voter, and the vote option. */ export interface VoteAmino { proposal_id?: string; voter?: string; options?: WeightedVoteOptionAmino[]; /** metadata is any arbitrary metadata to attached to the vote. */ metadata?: string; } export interface VoteAminoMsg { type: "cosmos-sdk/v1/Vote"; value: VoteAmino; } /** * Vote defines a vote on a governance proposal. * A Vote consists of a proposal ID, the voter, and the vote option. */ export interface VoteSDKType { proposal_id: bigint; voter: string; options: WeightedVoteOptionSDKType[]; metadata: string; } /** DepositParams defines the params for deposits on governance proposals. */ export interface DepositParams { /** Minimum deposit for a proposal to enter voting period. */ minDeposit: Coin[]; /** * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 * months. */ maxDepositPeriod?: Duration; } export interface DepositParamsProtoMsg { typeUrl: "/cosmos.gov.v1.DepositParams"; value: Uint8Array; } /** DepositParams defines the params for deposits on governance proposals. */ export interface DepositParamsAmino { /** Minimum deposit for a proposal to enter voting period. */ min_deposit?: CoinAmino[]; /** * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 * months. */ max_deposit_period?: DurationAmino; } export interface DepositParamsAminoMsg { type: "cosmos-sdk/v1/DepositParams"; value: DepositParamsAmino; } /** DepositParams defines the params for deposits on governance proposals. */ export interface DepositParamsSDKType { min_deposit: CoinSDKType[]; max_deposit_period?: DurationSDKType; } /** VotingParams defines the params for voting on governance proposals. */ export interface VotingParams { /** Length of the voting period. */ votingPeriod?: Duration; } export interface VotingParamsProtoMsg { typeUrl: "/cosmos.gov.v1.VotingParams"; value: Uint8Array; } /** VotingParams defines the params for voting on governance proposals. */ export interface VotingParamsAmino { /** Length of the voting period. */ voting_period?: DurationAmino; } export interface VotingParamsAminoMsg { type: "cosmos-sdk/v1/VotingParams"; value: VotingParamsAmino; } /** VotingParams defines the params for voting on governance proposals. */ export interface VotingParamsSDKType { voting_period?: DurationSDKType; } /** TallyParams defines the params for tallying votes on governance proposals. */ export interface TallyParams { /** * Minimum percentage of total stake needed to vote for a result to be * considered valid. */ quorum: string; /** Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. */ threshold: string; /** * Minimum value of Veto votes to Total votes ratio for proposal to be * vetoed. Default value: 1/3. */ vetoThreshold: string; } export interface TallyParamsProtoMsg { typeUrl: "/cosmos.gov.v1.TallyParams"; value: Uint8Array; } /** TallyParams defines the params for tallying votes on governance proposals. */ export interface TallyParamsAmino { /** * Minimum percentage of total stake needed to vote for a result to be * considered valid. */ quorum?: string; /** Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. */ threshold?: string; /** * Minimum value of Veto votes to Total votes ratio for proposal to be * vetoed. Default value: 1/3. */ veto_threshold?: string; } export interface TallyParamsAminoMsg { type: "cosmos-sdk/v1/TallyParams"; value: TallyParamsAmino; } /** TallyParams defines the params for tallying votes on governance proposals. */ export interface TallyParamsSDKType { quorum: string; threshold: string; veto_threshold: string; } function createBaseWeightedVoteOption(): WeightedVoteOption { return { option: 0, weight: "" }; } export const WeightedVoteOption = { typeUrl: "/cosmos.gov.v1.WeightedVoteOption", encode(message: WeightedVoteOption, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.option !== 0) { writer.uint32(8).int32(message.option); } if (message.weight !== "") { writer.uint32(18).string(message.weight); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): WeightedVoteOption { 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() as any); break; case 2: message.weight = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: Partial): WeightedVoteOption { const message = createBaseWeightedVoteOption(); message.option = object.option ?? 0; message.weight = object.weight ?? ""; return message; }, fromAmino(object: WeightedVoteOptionAmino): WeightedVoteOption { const message = createBaseWeightedVoteOption(); if (object.option !== undefined && object.option !== null) { message.option = voteOptionFromJSON(object.option); } if (object.weight !== undefined && object.weight !== null) { message.weight = object.weight; } return message; }, toAmino(message: WeightedVoteOption): WeightedVoteOptionAmino { const obj: any = {}; obj.option = voteOptionToJSON(message.option); obj.weight = message.weight; return obj; }, fromAminoMsg(object: WeightedVoteOptionAminoMsg): WeightedVoteOption { return WeightedVoteOption.fromAmino(object.value); }, toAminoMsg(message: WeightedVoteOption): WeightedVoteOptionAminoMsg { return { type: "cosmos-sdk/v1/WeightedVoteOption", value: WeightedVoteOption.toAmino(message) }; }, fromProtoMsg(message: WeightedVoteOptionProtoMsg): WeightedVoteOption { return WeightedVoteOption.decode(message.value); }, toProto(message: WeightedVoteOption): Uint8Array { return WeightedVoteOption.encode(message).finish(); }, toProtoMsg(message: WeightedVoteOption): WeightedVoteOptionProtoMsg { return { typeUrl: "/cosmos.gov.v1.WeightedVoteOption", value: WeightedVoteOption.encode(message).finish() }; } }; function createBaseDeposit(): Deposit { return { proposalId: BigInt(0), depositor: "", amount: [] }; } export const Deposit = { typeUrl: "/cosmos.gov.v1.Deposit", encode(message: Deposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { 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: BinaryReader | Uint8Array, length?: number): Deposit { 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: Partial): Deposit { 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: DepositAmino): Deposit { 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: Deposit): DepositAmino { const obj: any = {}; obj.proposal_id = message.proposalId ? message.proposalId.toString() : undefined; obj.depositor = message.depositor; if (message.amount) { obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); } else { obj.amount = []; } return obj; }, fromAminoMsg(object: DepositAminoMsg): Deposit { return Deposit.fromAmino(object.value); }, toAminoMsg(message: Deposit): DepositAminoMsg { return { type: "cosmos-sdk/v1/Deposit", value: Deposit.toAmino(message) }; }, fromProtoMsg(message: DepositProtoMsg): Deposit { return Deposit.decode(message.value); }, toProto(message: Deposit): Uint8Array { return Deposit.encode(message).finish(); }, toProtoMsg(message: Deposit): DepositProtoMsg { return { typeUrl: "/cosmos.gov.v1.Deposit", value: Deposit.encode(message).finish() }; } }; function createBaseProposal(): Proposal { return { id: BigInt(0), messages: [], status: 0, finalTallyResult: undefined, submitTime: undefined, depositEndTime: undefined, totalDeposit: [], votingStartTime: undefined, votingEndTime: undefined, metadata: "" }; } export const Proposal = { typeUrl: "/cosmos.gov.v1.Proposal", encode(message: Proposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.id !== BigInt(0)) { writer.uint32(8).uint64(message.id); } for (const v of message.messages) { Any.encode(v!, 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(); } if (message.metadata !== "") { writer.uint32(82).string(message.metadata); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Proposal { 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.id = reader.uint64(); break; case 2: message.messages.push(Any.decode(reader, reader.uint32())); break; case 3: message.status = (reader.int32() as any); 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; case 10: message.metadata = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: Partial): Proposal { const message = createBaseProposal(); message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0); message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; 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; message.metadata = object.metadata ?? ""; return message; }, fromAmino(object: ProposalAmino): Proposal { const message = createBaseProposal(); if (object.id !== undefined && object.id !== null) { message.id = BigInt(object.id); } message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; if (object.status !== undefined && object.status !== null) { message.status = proposalStatusFromJSON(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)); } if (object.metadata !== undefined && object.metadata !== null) { message.metadata = object.metadata; } return message; }, toAmino(message: Proposal): ProposalAmino { const obj: any = {}; obj.id = message.id ? message.id.toString() : undefined; if (message.messages) { obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); } else { obj.messages = []; } obj.status = proposalStatusToJSON(message.status); obj.final_tally_result = message.finalTallyResult ? TallyResult.toAmino(message.finalTallyResult) : undefined; obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : undefined; obj.deposit_end_time = message.depositEndTime ? Timestamp.toAmino(toTimestamp(message.depositEndTime)) : undefined; if (message.totalDeposit) { obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toAmino(e) : undefined); } else { obj.total_deposit = []; } obj.voting_start_time = message.votingStartTime ? Timestamp.toAmino(toTimestamp(message.votingStartTime)) : undefined; obj.voting_end_time = message.votingEndTime ? Timestamp.toAmino(toTimestamp(message.votingEndTime)) : undefined; obj.metadata = message.metadata; return obj; }, fromAminoMsg(object: ProposalAminoMsg): Proposal { return Proposal.fromAmino(object.value); }, toAminoMsg(message: Proposal): ProposalAminoMsg { return { type: "cosmos-sdk/v1/Proposal", value: Proposal.toAmino(message) }; }, fromProtoMsg(message: ProposalProtoMsg): Proposal { return Proposal.decode(message.value); }, toProto(message: Proposal): Uint8Array { return Proposal.encode(message).finish(); }, toProtoMsg(message: Proposal): ProposalProtoMsg { return { typeUrl: "/cosmos.gov.v1.Proposal", value: Proposal.encode(message).finish() }; } }; function createBaseTallyResult(): TallyResult { return { yesCount: "", abstainCount: "", noCount: "", noWithVetoCount: "" }; } export const TallyResult = { typeUrl: "/cosmos.gov.v1.TallyResult", encode(message: TallyResult, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.yesCount !== "") { writer.uint32(10).string(message.yesCount); } if (message.abstainCount !== "") { writer.uint32(18).string(message.abstainCount); } if (message.noCount !== "") { writer.uint32(26).string(message.noCount); } if (message.noWithVetoCount !== "") { writer.uint32(34).string(message.noWithVetoCount); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): TallyResult { 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.yesCount = reader.string(); break; case 2: message.abstainCount = reader.string(); break; case 3: message.noCount = reader.string(); break; case 4: message.noWithVetoCount = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: Partial): TallyResult { const message = createBaseTallyResult(); message.yesCount = object.yesCount ?? ""; message.abstainCount = object.abstainCount ?? ""; message.noCount = object.noCount ?? ""; message.noWithVetoCount = object.noWithVetoCount ?? ""; return message; }, fromAmino(object: TallyResultAmino): TallyResult { const message = createBaseTallyResult(); if (object.yes_count !== undefined && object.yes_count !== null) { message.yesCount = object.yes_count; } if (object.abstain_count !== undefined && object.abstain_count !== null) { message.abstainCount = object.abstain_count; } if (object.no_count !== undefined && object.no_count !== null) { message.noCount = object.no_count; } if (object.no_with_veto_count !== undefined && object.no_with_veto_count !== null) { message.noWithVetoCount = object.no_with_veto_count; } return message; }, toAmino(message: TallyResult): TallyResultAmino { const obj: any = {}; obj.yes_count = message.yesCount; obj.abstain_count = message.abstainCount; obj.no_count = message.noCount; obj.no_with_veto_count = message.noWithVetoCount; return obj; }, fromAminoMsg(object: TallyResultAminoMsg): TallyResult { return TallyResult.fromAmino(object.value); }, toAminoMsg(message: TallyResult): TallyResultAminoMsg { return { type: "cosmos-sdk/v1/TallyResult", value: TallyResult.toAmino(message) }; }, fromProtoMsg(message: TallyResultProtoMsg): TallyResult { return TallyResult.decode(message.value); }, toProto(message: TallyResult): Uint8Array { return TallyResult.encode(message).finish(); }, toProtoMsg(message: TallyResult): TallyResultProtoMsg { return { typeUrl: "/cosmos.gov.v1.TallyResult", value: TallyResult.encode(message).finish() }; } }; function createBaseVote(): Vote { return { proposalId: BigInt(0), voter: "", options: [], metadata: "" }; } export const Vote = { typeUrl: "/cosmos.gov.v1.Vote", encode(message: Vote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.proposalId !== BigInt(0)) { writer.uint32(8).uint64(message.proposalId); } if (message.voter !== "") { writer.uint32(18).string(message.voter); } for (const v of message.options) { WeightedVoteOption.encode(v!, writer.uint32(34).fork()).ldelim(); } if (message.metadata !== "") { writer.uint32(42).string(message.metadata); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Vote { 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 4: message.options.push(WeightedVoteOption.decode(reader, reader.uint32())); break; case 5: message.metadata = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: Partial): Vote { const message = createBaseVote(); message.proposalId = object.proposalId !== undefined && object.proposalId !== null ? BigInt(object.proposalId.toString()) : BigInt(0); message.voter = object.voter ?? ""; message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || []; message.metadata = object.metadata ?? ""; return message; }, fromAmino(object: VoteAmino): Vote { 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; } message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || []; if (object.metadata !== undefined && object.metadata !== null) { message.metadata = object.metadata; } return message; }, toAmino(message: Vote): VoteAmino { const obj: any = {}; obj.proposal_id = message.proposalId ? message.proposalId.toString() : undefined; obj.voter = message.voter; if (message.options) { obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined); } else { obj.options = []; } obj.metadata = message.metadata; return obj; }, fromAminoMsg(object: VoteAminoMsg): Vote { return Vote.fromAmino(object.value); }, toAminoMsg(message: Vote): VoteAminoMsg { return { type: "cosmos-sdk/v1/Vote", value: Vote.toAmino(message) }; }, fromProtoMsg(message: VoteProtoMsg): Vote { return Vote.decode(message.value); }, toProto(message: Vote): Uint8Array { return Vote.encode(message).finish(); }, toProtoMsg(message: Vote): VoteProtoMsg { return { typeUrl: "/cosmos.gov.v1.Vote", value: Vote.encode(message).finish() }; } }; function createBaseDepositParams(): DepositParams { return { minDeposit: [], maxDepositPeriod: undefined }; } export const DepositParams = { typeUrl: "/cosmos.gov.v1.DepositParams", encode(message: DepositParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { 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: BinaryReader | Uint8Array, length?: number): DepositParams { 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: Partial): DepositParams { 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: DepositParamsAmino): DepositParams { 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: DepositParams): DepositParamsAmino { const obj: any = {}; if (message.minDeposit) { obj.min_deposit = message.minDeposit.map(e => e ? Coin.toAmino(e) : undefined); } else { obj.min_deposit = []; } obj.max_deposit_period = message.maxDepositPeriod ? Duration.toAmino(message.maxDepositPeriod) : undefined; return obj; }, fromAminoMsg(object: DepositParamsAminoMsg): DepositParams { return DepositParams.fromAmino(object.value); }, toAminoMsg(message: DepositParams): DepositParamsAminoMsg { return { type: "cosmos-sdk/v1/DepositParams", value: DepositParams.toAmino(message) }; }, fromProtoMsg(message: DepositParamsProtoMsg): DepositParams { return DepositParams.decode(message.value); }, toProto(message: DepositParams): Uint8Array { return DepositParams.encode(message).finish(); }, toProtoMsg(message: DepositParams): DepositParamsProtoMsg { return { typeUrl: "/cosmos.gov.v1.DepositParams", value: DepositParams.encode(message).finish() }; } }; function createBaseVotingParams(): VotingParams { return { votingPeriod: undefined }; } export const VotingParams = { typeUrl: "/cosmos.gov.v1.VotingParams", encode(message: VotingParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.votingPeriod !== undefined) { Duration.encode(message.votingPeriod, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): VotingParams { 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: Partial): VotingParams { const message = createBaseVotingParams(); message.votingPeriod = object.votingPeriod !== undefined && object.votingPeriod !== null ? Duration.fromPartial(object.votingPeriod) : undefined; return message; }, fromAmino(object: VotingParamsAmino): VotingParams { const message = createBaseVotingParams(); if (object.voting_period !== undefined && object.voting_period !== null) { message.votingPeriod = Duration.fromAmino(object.voting_period); } return message; }, toAmino(message: VotingParams): VotingParamsAmino { const obj: any = {}; obj.voting_period = message.votingPeriod ? Duration.toAmino(message.votingPeriod) : undefined; return obj; }, fromAminoMsg(object: VotingParamsAminoMsg): VotingParams { return VotingParams.fromAmino(object.value); }, toAminoMsg(message: VotingParams): VotingParamsAminoMsg { return { type: "cosmos-sdk/v1/VotingParams", value: VotingParams.toAmino(message) }; }, fromProtoMsg(message: VotingParamsProtoMsg): VotingParams { return VotingParams.decode(message.value); }, toProto(message: VotingParams): Uint8Array { return VotingParams.encode(message).finish(); }, toProtoMsg(message: VotingParams): VotingParamsProtoMsg { return { typeUrl: "/cosmos.gov.v1.VotingParams", value: VotingParams.encode(message).finish() }; } }; function createBaseTallyParams(): TallyParams { return { quorum: "", threshold: "", vetoThreshold: "" }; } export const TallyParams = { typeUrl: "/cosmos.gov.v1.TallyParams", encode(message: TallyParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.quorum !== "") { writer.uint32(10).string(message.quorum); } if (message.threshold !== "") { writer.uint32(18).string(message.threshold); } if (message.vetoThreshold !== "") { writer.uint32(26).string(message.vetoThreshold); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): TallyParams { 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.string(); break; case 2: message.threshold = reader.string(); break; case 3: message.vetoThreshold = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: Partial): TallyParams { const message = createBaseTallyParams(); message.quorum = object.quorum ?? ""; message.threshold = object.threshold ?? ""; message.vetoThreshold = object.vetoThreshold ?? ""; return message; }, fromAmino(object: TallyParamsAmino): TallyParams { const message = createBaseTallyParams(); if (object.quorum !== undefined && object.quorum !== null) { message.quorum = object.quorum; } if (object.threshold !== undefined && object.threshold !== null) { message.threshold = object.threshold; } if (object.veto_threshold !== undefined && object.veto_threshold !== null) { message.vetoThreshold = object.veto_threshold; } return message; }, toAmino(message: TallyParams): TallyParamsAmino { const obj: any = {}; obj.quorum = message.quorum; obj.threshold = message.threshold; obj.veto_threshold = message.vetoThreshold; return obj; }, fromAminoMsg(object: TallyParamsAminoMsg): TallyParams { return TallyParams.fromAmino(object.value); }, toAminoMsg(message: TallyParams): TallyParamsAminoMsg { return { type: "cosmos-sdk/v1/TallyParams", value: TallyParams.toAmino(message) }; }, fromProtoMsg(message: TallyParamsProtoMsg): TallyParams { return TallyParams.decode(message.value); }, toProto(message: TallyParams): Uint8Array { return TallyParams.encode(message).finish(); }, toProtoMsg(message: TallyParams): TallyParamsProtoMsg { return { typeUrl: "/cosmos.gov.v1.TallyParams", value: TallyParams.encode(message).finish() }; } };