refactor: x/gov audit changes (#14174)

* make proto changes

* wip

* wip

* wip

* `make lint-fix`

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Likhita Polavarapu 2022-12-07 06:21:34 +05:30 committed by GitHub
parent ed5124f932
commit f1062c7f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 943 additions and 336 deletions

View File

@ -500,6 +500,8 @@ type Module struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// max_metadata_len defines the maximum proposal metadata length.
// Defaults to 255 if not explicitly set.
MaxMetadataLen uint64 `protobuf:"varint,1,opt,name=max_metadata_len,json=maxMetadataLen,proto3" json:"max_metadata_len,omitempty"`
// authority defines the custom module authority. If not set, defaults to the governance module.
Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"`

View File

@ -6178,8 +6178,10 @@ type WeightedVoteOption struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// option defines the valid vote options, it must not contain duplicate vote options.
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
// weight is the vote weight associated with the vote option.
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
}
func (x *WeightedVoteOption) Reset() {
@ -6223,9 +6225,12 @@ type Deposit struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
}
func (x *Deposit) Reset() {
@ -6275,18 +6280,26 @@ type Proposal struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Messages []*anypb.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1.ProposalStatus" json:"status,omitempty"`
// id defines the unique id of the proposal.
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// messages are the arbitrary messages to be executed if the proposal passes.
Messages []*anypb.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
// status defines the proposal status.
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1.ProposalStatus" json:"status,omitempty"`
// 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 `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result,omitempty"`
SubmitTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3" json:"submit_time,omitempty"`
DepositEndTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3" json:"deposit_end_time,omitempty"`
TotalDeposit []*v1beta1.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"`
VotingStartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3" json:"voting_start_time,omitempty"`
VotingEndTime *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3" json:"voting_end_time,omitempty"`
FinalTallyResult *TallyResult `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result,omitempty"`
// submit_time is the time of proposal submission.
SubmitTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3" json:"submit_time,omitempty"`
// deposit_end_time is the end time for deposition.
DepositEndTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3" json:"deposit_end_time,omitempty"`
// total_deposit is the total deposit on the proposal.
TotalDeposit []*v1beta1.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"`
// voting_start_time is the starting time to vote on a proposal.
VotingStartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3" json:"voting_start_time,omitempty"`
// voting_end_time is the end time of voting on a proposal.
VotingEndTime *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3" json:"voting_end_time,omitempty"`
// metadata is any arbitrary metadata attached to the proposal.
Metadata string `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -6387,9 +6400,13 @@ type TallyResult struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
YesCount string `protobuf:"bytes,1,opt,name=yes_count,json=yesCount,proto3" json:"yes_count,omitempty"`
AbstainCount string `protobuf:"bytes,2,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"`
NoCount string `protobuf:"bytes,3,opt,name=no_count,json=noCount,proto3" json:"no_count,omitempty"`
// yes_count is the number of yes votes on a proposal.
YesCount string `protobuf:"bytes,1,opt,name=yes_count,json=yesCount,proto3" json:"yes_count,omitempty"`
// abstain_count is the number of abstain votes on a proposal.
AbstainCount string `protobuf:"bytes,2,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"`
// no_count is the number of no votes on a proposal.
NoCount string `protobuf:"bytes,3,opt,name=no_count,json=noCount,proto3" json:"no_count,omitempty"`
// no_with_veto_count is the number of no with veto votes on a proposal.
NoWithVetoCount string `protobuf:"bytes,4,opt,name=no_with_veto_count,json=noWithVetoCount,proto3" json:"no_with_veto_count,omitempty"`
}
@ -6448,9 +6465,12 @@ type Vote struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address of the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options is the weighted vote options.
Options []*WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"`
// metadata is any arbitrary metadata to attached to the vote.
Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -6556,7 +6576,7 @@ type VotingParams struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Length of the voting period.
// Duration of the voting period.
VotingPeriod *durationpb.Duration `protobuf:"bytes,1,opt,name=voting_period,json=votingPeriod,proto3" json:"voting_period,omitempty"`
}
@ -6657,7 +6677,7 @@ type Params struct {
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
MaxDepositPeriod *durationpb.Duration `protobuf:"bytes,2,opt,name=max_deposit_period,json=maxDepositPeriod,proto3" json:"max_deposit_period,omitempty"`
// Length of the voting period.
// Duration of the voting period.
VotingPeriod *durationpb.Duration `protobuf:"bytes,3,opt,name=voting_period,json=votingPeriod,proto3" json:"voting_period,omitempty"`
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.

View File

@ -7945,6 +7945,7 @@ type QueryProposalResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposal is the requested governance proposal.
Proposal *Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"`
}
@ -8046,6 +8047,7 @@ type QueryProposalsResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposals defines all the requested governance proposals.
Proposals []*Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -8137,7 +8139,7 @@ type QueryVoteResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// vote defined the queried vote.
// vote defines the queried vote.
Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"`
}
@ -8220,7 +8222,7 @@ type QueryVotesResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// votes defined the queried votes.
// votes defines the queried votes.
Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -8511,6 +8513,7 @@ type QueryDepositsResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// deposits defines the requested deposits.
Deposits []*Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`

View File

@ -5838,9 +5838,12 @@ type MsgSubmitProposal struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Messages []*anypb.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
// messages are the arbitrary messages to be executed if proposal passes.
Messages []*anypb.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
// initial_deposit is the deposit value that must be paid at proposal submission.
InitialDeposit []*v1beta1.Coin `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3" json:"initial_deposit,omitempty"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// proposer is the account address of the proposer.
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// metadata is any arbitrary metadata attached to the proposal.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -5899,6 +5902,7 @@ type MsgSubmitProposalResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
}
@ -6009,10 +6013,14 @@ type MsgVote struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// option defines the vote option.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
// metadata is any arbitrary metadata attached to the Vote.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (x *MsgVote) Reset() {
@ -6096,10 +6104,14 @@ type MsgVoteWeighted struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options defines the weighted vote options.
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
// metadata is any arbitrary metadata attached to the VoteWeighted.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (x *MsgVoteWeighted) Reset() {
@ -6183,9 +6195,12 @@ type MsgDeposit struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
}
func (x *MsgDeposit) Reset() {

View File

@ -22,7 +22,7 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MsgClient interface {
// SubmitProposal defines a method to create new proposal given a content.
// SubmitProposal defines a method to create new proposal given the messages.
SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error)
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
// to execute a legacy content-based proposal.
@ -106,7 +106,7 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
type MsgServer interface {
// SubmitProposal defines a method to create new proposal given a content.
// SubmitProposal defines a method to create new proposal given the messages.
SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error)
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
// to execute a legacy content-based proposal.

View File

@ -5621,8 +5621,10 @@ type WeightedVoteOption struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// option defines the valid vote options, it must not contain duplicate vote options.
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
// weight is the vote weight associated with the vote option.
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
}
func (x *WeightedVoteOption) Reset() {
@ -5666,7 +5668,9 @@ type TextProposal struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// title of the proposal.
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// description associated with the proposal.
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
@ -5711,9 +5715,12 @@ type Deposit struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
}
func (x *Deposit) Reset() {
@ -5763,18 +5770,26 @@ type Proposal struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Content *anypb.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"status,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// content is the proposal's content.
Content *anypb.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
// status defines the proposal status.
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"status,omitempty"`
// 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 `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result,omitempty"`
SubmitTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3" json:"submit_time,omitempty"`
DepositEndTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3" json:"deposit_end_time,omitempty"`
TotalDeposit []*v1beta1.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"`
VotingStartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3" json:"voting_start_time,omitempty"`
VotingEndTime *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3" json:"voting_end_time,omitempty"`
FinalTallyResult *TallyResult `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result,omitempty"`
// submit_time is the time of proposal submission.
SubmitTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3" json:"submit_time,omitempty"`
// deposit_end_time is the end time for deposition.
DepositEndTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3" json:"deposit_end_time,omitempty"`
// total_deposit is the total deposit on the proposal.
TotalDeposit []*v1beta1.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit,omitempty"`
// voting_start_time is the starting time to vote on a proposal.
VotingStartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3" json:"voting_start_time,omitempty"`
// voting_end_time is the end time of voting on a proposal.
VotingEndTime *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3" json:"voting_end_time,omitempty"`
}
func (x *Proposal) Reset() {
@ -5866,9 +5881,13 @@ type TallyResult struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Yes string `protobuf:"bytes,1,opt,name=yes,proto3" json:"yes,omitempty"`
Abstain string `protobuf:"bytes,2,opt,name=abstain,proto3" json:"abstain,omitempty"`
No string `protobuf:"bytes,3,opt,name=no,proto3" json:"no,omitempty"`
// yes is the number of yes votes on a proposal.
Yes string `protobuf:"bytes,1,opt,name=yes,proto3" json:"yes,omitempty"`
// abstain is the number of abstain votes on a proposal.
Abstain string `protobuf:"bytes,2,opt,name=abstain,proto3" json:"abstain,omitempty"`
// no is the number of no votes on a proposal.
No string `protobuf:"bytes,3,opt,name=no,proto3" json:"no,omitempty"`
// no_with_veto is the number of no with veto votes on a proposal.
NoWithVeto string `protobuf:"bytes,4,opt,name=no_with_veto,json=noWithVeto,proto3" json:"no_with_veto,omitempty"`
}
@ -5927,14 +5946,18 @@ type Vote struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// voter is the voter address of the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
//
// Deprecated: Do not use.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
// options is the weighted vote options.
//
// Since: cosmos-sdk 0.43
Options []*WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"`
}
@ -6041,7 +6064,7 @@ type VotingParams struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Length of the voting period.
// Duration of the voting period.
VotingPeriod *durationpb.Duration `protobuf:"bytes,1,opt,name=voting_period,json=votingPeriod,proto3" json:"voting_period,omitempty"`
}

View File

@ -7967,6 +7967,7 @@ type QueryProposalsResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposals defines all the requested governance proposals.
Proposals []*Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -8058,7 +8059,7 @@ type QueryVoteResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// vote defined the queried vote.
// vote defines the queried vote.
Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"`
}
@ -8141,7 +8142,7 @@ type QueryVotesResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// votes defined the queried votes.
// votes defines the queried votes.
Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -8409,6 +8410,7 @@ type QueryDepositsResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// deposits defines the requested deposits.
Deposits []*Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits,omitempty"`
// pagination defines the pagination in the response.
Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`

View File

@ -3875,9 +3875,12 @@ type MsgSubmitProposal struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Content *anypb.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// content is the proposal's content.
Content *anypb.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// initial_deposit is the deposit value that must be paid at proposal submission.
InitialDeposit []*v1beta1.Coin `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3" json:"initial_deposit,omitempty"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// proposer is the account address of the proposer.
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
}
func (x *MsgSubmitProposal) Reset() {
@ -3927,6 +3930,7 @@ type MsgSubmitProposalResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
}
@ -3963,9 +3967,12 @@ type MsgVote struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// option defines the vote option.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
}
func (x *MsgVote) Reset() {
@ -4044,9 +4051,12 @@ type MsgVoteWeighted struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options defines the weighted vote options.
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
}
func (x *MsgVoteWeighted) Reset() {
@ -4125,9 +4135,12 @@ type MsgDeposit struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []*v1beta1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount,omitempty"`
}
func (x *MsgDeposit) Reset() {

View File

@ -10,6 +10,8 @@ message Module {
go_import: "github.com/cosmos/cosmos-sdk/x/gov"
};
// max_metadata_len defines the maximum proposal metadata length.
// Defaults to 255 if not explicitly set.
uint64 max_metadata_len = 1;
// authority defines the custom module authority. If not set, defaults to the governance module.

View File

@ -28,31 +28,55 @@ enum VoteOption {
// WeightedVoteOption defines a unit of vote for vote split.
message WeightedVoteOption {
// option defines the valid vote options, it must not contain duplicate vote options.
VoteOption option = 1;
// weight is the vote weight associated with the vote option.
string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
// Deposit defines an amount deposited by an account address to an active
// proposal.
message Deposit {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount to be deposited by depositor.
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}
// Proposal defines the core field members of a governance proposal.
message Proposal {
// id defines the unique id of the proposal.
uint64 id = 1;
// messages are the arbitrary messages to be executed if the proposal passes.
repeated google.protobuf.Any messages = 2;
// status defines the proposal status.
ProposalStatus status = 3;
// 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.
TallyResult final_tally_result = 4;
// submit_time is the time of proposal submission.
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
// deposit_end_time is the end time for deposition.
google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true];
// total_deposit is the total deposit on the proposal.
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// voting_start_time is the starting time to vote on a proposal.
google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true];
// voting_end_time is the end time of voting on a proposal.
google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true];
// metadata is any arbitrary metadata attached to the proposal.
@ -82,18 +106,28 @@ enum ProposalStatus {
// TallyResult defines a standard tally for a governance proposal.
message TallyResult {
// yes_count is the number of yes votes on a proposal.
string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"];
// abstain_count is the number of abstain votes on a proposal.
string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"];
// no_count is the number of no votes on a proposal.
string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"];
// no_with_veto_count is the number of no with veto votes on a proposal.
string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"];
}
// Vote defines a vote on a governance proposal.
// A Vote consists of a proposal ID, the voter, and the vote option.
message Vote {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// voter is the voter address of the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
reserved 3;
// options is the weighted vote options.
repeated WeightedVoteOption options = 4;
// metadata is any arbitrary metadata to attached to the vote.
@ -102,33 +136,33 @@ message Vote {
// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
// Minimum deposit for a proposal to enter voting period.
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "min_deposit,omitempty"];
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
google.protobuf.Duration max_deposit_period = 2
[(gogoproto.stdduration) = true, (gogoproto.jsontag) = "max_deposit_period,omitempty"];
}
// VotingParams defines the params for voting on governance proposals.
message VotingParams {
// Length of the voting period.
// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];
}
// TallyParams defines the params for tallying votes on governance proposals.
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
string veto_threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
@ -136,14 +170,14 @@ message TallyParams {
//
// Since: cosmos-sdk 0.47
message Params {
// Minimum deposit for a proposal to enter voting period.
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
google.protobuf.Duration max_deposit_period = 2 [(gogoproto.stdduration) = true];
// Length of the voting period.
// Duration of the voting period.
google.protobuf.Duration voting_period = 3 [(gogoproto.stdduration) = true];
// Minimum percentage of total stake needed to vote for a result to be

View File

@ -61,6 +61,7 @@ message QueryProposalRequest {
// QueryProposalResponse is the response type for the Query/Proposal RPC method.
message QueryProposalResponse {
// proposal is the requested governance proposal.
Proposal proposal = 1;
}
@ -82,6 +83,7 @@ message QueryProposalsRequest {
// QueryProposalsResponse is the response type for the Query/Proposals RPC
// method.
message QueryProposalsResponse {
// proposals defines all the requested governance proposals.
repeated Proposal proposals = 1;
// pagination defines the pagination in the response.
@ -99,7 +101,7 @@ message QueryVoteRequest {
// QueryVoteResponse is the response type for the Query/Vote RPC method.
message QueryVoteResponse {
// vote defined the queried vote.
// vote defines the queried vote.
Vote vote = 1;
}
@ -114,7 +116,7 @@ message QueryVotesRequest {
// QueryVotesResponse is the response type for the Query/Votes RPC method.
message QueryVotesResponse {
// votes defined the queried votes.
// votes defines the queried votes.
repeated Vote votes = 1;
// pagination defines the pagination in the response.
@ -171,6 +173,7 @@ message QueryDepositsRequest {
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
// deposits defines the requested deposits.
repeated Deposit deposits = 1;
// pagination defines the pagination in the response.

View File

@ -16,7 +16,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1";
service Msg {
option (cosmos.msg.v1.service) = true;
// SubmitProposal defines a method to create new proposal given a content.
// SubmitProposal defines a method to create new proposal given the messages.
rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse);
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
@ -45,15 +45,22 @@ message MsgSubmitProposal {
option (cosmos.msg.v1.signer) = "proposer";
option (amino.name) = "cosmos-sdk/v1/MsgSubmitProposal";
// messages are the arbitrary messages to be executed if proposal passes.
repeated google.protobuf.Any messages = 1;
// initial_deposit is the deposit value that must be paid at proposal submission.
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// proposer is the account address of the proposer.
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// metadata is any arbitrary metadata attached to the proposal.
string metadata = 4;
}
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
message MsgSubmitProposalResponse {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
}
@ -77,9 +84,16 @@ message MsgVote {
option (cosmos.msg.v1.signer) = "voter";
option (amino.name) = "cosmos-sdk/v1/MsgVote";
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
// voter is the voter address for the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// option defines the vote option.
VoteOption option = 3;
// metadata is any arbitrary metadata attached to the Vote.
string metadata = 4;
}
@ -91,9 +105,16 @@ message MsgVoteWeighted {
option (cosmos.msg.v1.signer) = "voter";
option (amino.name) = "cosmos-sdk/v1/MsgVoteWeighted";
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
// voter is the voter address for the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// options defines the weighted vote options.
repeated WeightedVoteOption options = 3;
// metadata is any arbitrary metadata attached to the VoteWeighted.
string metadata = 4;
}
@ -105,8 +126,13 @@ message MsgDeposit {
option (cosmos.msg.v1.signer) = "depositor";
option (amino.name) = "cosmos-sdk/v1/MsgDeposit";
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount to be deposited by depositor.
repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

View File

@ -33,7 +33,10 @@ enum VoteOption {
//
// Since: cosmos-sdk 0.43
message WeightedVoteOption {
// option defines the valid vote options, it must not contain duplicate vote options.
VoteOption option = 1;
// weight is the vote weight associated with the vote option.
string weight = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
@ -49,7 +52,10 @@ message TextProposal {
option (gogoproto.equal) = true;
// title of the proposal.
string title = 1;
// description associated with the proposal.
string description = 2;
}
@ -59,8 +65,13 @@ message Deposit {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount to be deposited by depositor.
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
@ -72,24 +83,40 @@ message Deposit {
message Proposal {
option (gogoproto.equal) = true;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// content is the proposal's content.
google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"];
// status defines the proposal status.
ProposalStatus status = 3;
// 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.
TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// submit_time is the time of proposal submission.
google.protobuf.Timestamp submit_time = 5
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// deposit_end_time is the end time for deposition.
google.protobuf.Timestamp deposit_end_time = 6
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// total_deposit is the total deposit on the proposal.
repeated cosmos.base.v1beta1.Coin total_deposit = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// voting_start_time is the starting time to vote on a proposal.
google.protobuf.Timestamp voting_start_time = 8
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// voting_end_time is the end time of voting on a proposal.
google.protobuf.Timestamp voting_end_time = 9
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}
@ -121,21 +148,28 @@ enum ProposalStatus {
message TallyResult {
option (gogoproto.equal) = true;
// yes is the number of yes votes on a proposal.
string yes = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// abstain is the number of abstain votes on a proposal.
string abstain = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// no is the number of no votes on a proposal.
string no = 3 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// no_with_veto is the number of no with veto votes on a proposal.
string no_with_veto = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
@ -148,27 +182,33 @@ message TallyResult {
message Vote {
option (gogoproto.equal) = false;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true];
// voter is the voter address of the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
VoteOption option = 3 [deprecated = true];
// options is the weighted vote options.
//
// Since: cosmos-sdk 0.43
repeated WeightedVoteOption options = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}
// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
// Minimum deposit for a proposal to enter voting period.
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.jsontag) = "min_deposit,omitempty"
];
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
google.protobuf.Duration max_deposit_period = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
@ -178,30 +218,30 @@ message DepositParams {
// VotingParams defines the params for voting on governance proposals.
message VotingParams {
// Length of the voting period.
// Duration of the voting period.
google.protobuf.Duration voting_period = 1
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.jsontag) = "voting_period,omitempty"];
}
// TallyParams defines the params for tallying votes on governance proposals.
message TallyParams {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
bytes quorum = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "quorum,omitempty"
];
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
bytes threshold = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "threshold,omitempty"
];
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
bytes veto_threshold = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,

View File

@ -85,6 +85,7 @@ message QueryProposalsRequest {
// QueryProposalsResponse is the response type for the Query/Proposals RPC
// method.
message QueryProposalsResponse {
// proposals defines all the requested governance proposals.
repeated Proposal proposals = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// pagination defines the pagination in the response.
@ -105,7 +106,7 @@ message QueryVoteRequest {
// QueryVoteResponse is the response type for the Query/Vote RPC method.
message QueryVoteResponse {
// vote defined the queried vote.
// vote defines the queried vote.
Vote vote = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}
@ -120,7 +121,7 @@ message QueryVotesRequest {
// QueryVotesResponse is the response type for the Query/Votes RPC method.
message QueryVotesResponse {
// votes defined the queried votes.
// votes defines the queried votes.
repeated Vote votes = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// pagination defines the pagination in the response.
@ -173,6 +174,7 @@ message QueryDepositsRequest {
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
message QueryDepositsResponse {
// deposits defines the requested deposits.
repeated Deposit deposits = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
// pagination defines the pagination in the response.

View File

@ -39,17 +39,23 @@ message MsgSubmitProposal {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// content is the proposal's content.
google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"];
// initial_deposit is the deposit value that must be paid at proposal submission.
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// proposer is the account address of the proposer.
string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
message MsgSubmitProposalResponse {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
}
@ -61,8 +67,13 @@ message MsgVote {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// voter is the voter address for the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// option defines the vote option.
VoteOption option = 3;
}
@ -79,8 +90,13 @@ message MsgVoteWeighted {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
// voter is the voter address for the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// options defines the weighted vote options.
repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}
@ -98,8 +114,13 @@ message MsgDeposit {
option (gogoproto.stringer) = false;
option (gogoproto.goproto_getters) = false;
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true];
// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount to be deposited by depositor.
repeated cosmos.base.v1beta1.Coin amount = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,

View File

@ -302,7 +302,7 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() {
false, 2,
},
{
"deposit on non existing proposal",
"deposit on existing proposal",
[]string{
"1",
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake

View File

@ -27,9 +27,32 @@ const (
draftMetadataFileName = "draft_metadata.json"
)
var suggestedProposalTypes = []proposalType{
{
Name: proposalText,
MsgType: "", // no message for text proposal
},
{
Name: "community-pool-spend",
MsgType: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend",
},
{
Name: "software-upgrade",
MsgType: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
},
{
Name: "cancel-software-upgrade",
MsgType: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade",
},
{
Name: proposalOther,
MsgType: "", // user will input the message type
},
}
// Prompt prompts the user for all values of the given type.
// data is the struct to be filled
// namePrefix is the name to be display as "Enter <namePrefix> <field>"
// namePrefix is the name to be displayed as "Enter <namePrefix> <field>"
func Prompt[T any](data T, namePrefix string) (T, error) {
v := reflect.ValueOf(&data).Elem()
if v.Kind() == reflect.Interface {
@ -48,7 +71,7 @@ func Prompt[T any](data T, namePrefix string) (T, error) {
// create prompts
prompt := promptui.Prompt{
Label: fmt.Sprintf("Enter %s %s", namePrefix, strings.ToLower(client.CamelCaseToString(v.Type().Field(i).Name))),
Label: fmt.Sprintf("Enter %s's %s", namePrefix, strings.ToLower(client.CamelCaseToString(v.Type().Field(i).Name))),
Validate: client.ValidatePromptNotEmpty,
}
@ -150,29 +173,7 @@ func (p *proposalType) Prompt(cdc codec.Codec) (*proposal, types.ProposalMetadat
return proposal, metadata, nil
}
var suggestedProposalTypes = []proposalType{
{
Name: proposalText,
MsgType: "", // no message for text proposal
},
{
Name: "community-pool-spend",
MsgType: "/cosmos.distribution.v1beta1.MsgCommunityPoolSpend",
},
{
Name: "software-upgrade",
MsgType: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
},
{
Name: "cancel-software-upgrade",
MsgType: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade",
},
{
Name: proposalOther,
MsgType: "", // user will input the message type
},
}
// getProposalSuggestions suggests a list of proposal types
func getProposalSuggestions() []string {
types := make([]string, len(suggestedProposalTypes))
for i, p := range suggestedProposalTypes {
@ -264,6 +265,7 @@ func NewCmdDraftProposal() *cobra.Command {
return cmd
}
// writeFile writes the input to the file
func writeFile(fileName string, input any) error {
raw, err := json.MarshalIndent(input, "", " ")
if err != nil {

View File

@ -22,8 +22,8 @@ func (s *CLITestSuite) TestCmdParams() {
},
{
"text output",
[]string{},
"",
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
"--output=text",
},
}
@ -34,9 +34,7 @@ func (s *CLITestSuite) TestCmdParams() {
cmd := cli.GetCmdQueryParams()
cmd.SetArgs(tc.args)
if len(tc.args) != 0 {
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
}
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
})
}
}
@ -98,7 +96,7 @@ func (s *CLITestSuite) TestCmdProposer() {
"--output=json",
},
{
"json output",
"with proposal id",
[]string{
"1",
fmt.Sprintf("--%s=json", flags.FlagOutput),
@ -132,7 +130,7 @@ func (s *CLITestSuite) TestCmdTally() {
"--output=json",
},
{
"json output",
"with proposal id (json output)",
[]string{
"2",
fmt.Sprintf("--%s=json", flags.FlagOutput),
@ -140,12 +138,12 @@ func (s *CLITestSuite) TestCmdTally() {
"2 --output=json",
},
{
"json output",
"with proposal id (text output)",
[]string{
"1",
fmt.Sprintf("--%s=json", flags.FlagOutput),
fmt.Sprintf("--%s=text", flags.FlagOutput),
},
"1 --output=json",
"1 --output=text",
},
}
@ -166,14 +164,6 @@ func (s *CLITestSuite) TestCmdGetProposal() {
args []string
expCmdOutput string
}{
{
"get non existing proposal",
[]string{
"10",
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
"10 --output=json",
},
{
"get proposal with json response",
[]string{
@ -236,14 +226,14 @@ func (s *CLITestSuite) TestCmdQueryDeposits() {
expCmdOutput string
}{
{
"get deposits of non existing proposal",
"get deposits",
[]string{
"10",
},
"10",
},
{
"get deposits(valid req)",
"get deposits(json output)",
[]string{
"1",
fmt.Sprintf("--%s=json", flags.FlagOutput),
@ -257,10 +247,7 @@ func (s *CLITestSuite) TestCmdQueryDeposits() {
s.Run(tc.name, func() {
cmd := cli.GetCmdQueryDeposits()
cmd.SetArgs(tc.args)
if len(tc.args) != 0 {
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
}
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
})
}
}
@ -304,10 +291,7 @@ func (s *CLITestSuite) TestCmdQueryDeposit() {
s.Run(tc.name, func() {
cmd := cli.GetCmdQueryDeposit()
cmd.SetArgs(tc.args)
if len(tc.args) != 0 {
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
}
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
})
}
}
@ -321,17 +305,17 @@ func (s *CLITestSuite) TestCmdQueryVotes() {
{
"get votes with no proposal id",
[]string{},
"true",
"",
},
{
"get votes of non existed proposal",
"get votes of a proposal",
[]string{
"10",
},
"10",
},
{
"vote for invalid proposal",
"get votes of a proposal (json output)",
[]string{
"1",
fmt.Sprintf("--%s=json", flags.FlagOutput),
@ -345,10 +329,7 @@ func (s *CLITestSuite) TestCmdQueryVotes() {
s.Run(tc.name, func() {
cmd := cli.GetCmdQueryVotes()
cmd.SetArgs(tc.args)
if len(tc.args) != 0 {
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
}
s.Require().Contains(fmt.Sprint(cmd), strings.TrimSpace(tc.expCmdOutput))
})
}
}
@ -362,7 +343,7 @@ func (s *CLITestSuite) TestCmdQueryVote() {
expCmdOutput string
}{
{
"get vote of non existing proposal",
"get vote of a proposal",
[]string{
"10",
val[0].Address.String(),
@ -378,7 +359,7 @@ func (s *CLITestSuite) TestCmdQueryVote() {
"1 wrong address",
},
{
"vote for valid proposal",
"get vote of a proposal (json output)",
[]string{
"1",
val[0].Address.String(),
@ -386,15 +367,6 @@ func (s *CLITestSuite) TestCmdQueryVote() {
},
fmt.Sprintf("1 %s --output=json", val[0].Address.String()),
},
{
"split vote for valid proposal",
[]string{
"3",
val[0].Address.String(),
fmt.Sprintf("--%s=json", flags.FlagOutput),
},
fmt.Sprintf("3 %s --output=json", val[0].Address.String()),
},
}
for _, tc := range testCases {

View File

@ -171,7 +171,7 @@ $ %s tx gov submit-legacy-proposal --title="Test Proposal" --description="My awe
return err
}
proposal, err := parseSubmitLegacyProposalFlags(cmd.Flags())
proposal, err := parseSubmitLegacyProposal(cmd.Flags())
if err != nil {
return fmt.Errorf("failed to parse proposal: %w", err)
}

View File

@ -295,7 +295,7 @@ func (s *CLITestSuite) TestNewCmdDeposit() {
true,
},
{
"deposit on non existing proposal",
"deposit on a proposal",
[]string{
"10",
sdk.NewCoin("stake", sdk.NewInt(10)).String(), // 10stake

View File

@ -19,6 +19,7 @@ type legacyProposal struct {
Deposit string
}
// validate the legacyProposal
func (p legacyProposal) validate() error {
if p.Type == "" {
return fmt.Errorf("proposal type is required")
@ -34,7 +35,8 @@ func (p legacyProposal) validate() error {
return nil
}
func parseSubmitLegacyProposalFlags(fs *pflag.FlagSet) (*legacyProposal, error) {
// parseSubmitLegacyProposal reads and parses the legacy proposal.
func parseSubmitLegacyProposal(fs *pflag.FlagSet) (*legacyProposal, error) {
proposal := &legacyProposal{}
proposalFile, _ := fs.GetString(FlagProposal)
@ -82,6 +84,7 @@ type proposal struct {
Deposit string `json:"deposit"`
}
// parseSubmitProposal reads and parses the proposal.
func parseSubmitProposal(cdc codec.Codec, path string) ([]sdk.Msg, string, sdk.Coins, error) {
var proposal proposal

View File

@ -18,7 +18,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
func TestParseSubmitLegacyProposalFlags(t *testing.T) {
func TestParseSubmitLegacyProposal(t *testing.T) {
okJSON := testutil.WriteToNewTempFile(t, `
{
"title": "Test Proposal",
@ -33,17 +33,17 @@ func TestParseSubmitLegacyProposalFlags(t *testing.T) {
// nonexistent json
fs.Set(FlagProposal, "fileDoesNotExist")
_, err := parseSubmitLegacyProposalFlags(fs)
_, err := parseSubmitLegacyProposal(fs)
require.Error(t, err)
// invalid json
fs.Set(FlagProposal, badJSON.Name())
_, err = parseSubmitLegacyProposalFlags(fs)
_, err = parseSubmitLegacyProposal(fs)
require.Error(t, err)
// ok json
fs.Set(FlagProposal, okJSON.Name())
proposal1, err := parseSubmitLegacyProposalFlags(fs)
proposal1, err := parseSubmitLegacyProposal(fs)
require.Nil(t, err, "unexpected error")
require.Equal(t, "Test Proposal", proposal1.Title)
require.Equal(t, "My awesome proposal", proposal1.Description)
@ -53,7 +53,7 @@ func TestParseSubmitLegacyProposalFlags(t *testing.T) {
// flags that can't be used with --proposal
for _, incompatibleFlag := range ProposalFlags {
fs.Set(incompatibleFlag, "some value")
_, err := parseSubmitLegacyProposalFlags(fs)
_, err := parseSubmitLegacyProposal(fs)
require.Error(t, err)
fs.Set(incompatibleFlag, "")
}
@ -97,7 +97,7 @@ func TestParseSubmitLegacyProposalFlags(t *testing.T) {
fs.Set(FlagDescription, tc.pDescription)
fs.Set(FlagProposalType, tc.pType)
fs.Set(FlagDeposit, proposal1.Deposit)
proposal2, err := parseSubmitLegacyProposalFlags(fs)
proposal2, err := parseSubmitLegacyProposal(fs)
if tc.expErr {
require.Error(t, err)

View File

@ -46,6 +46,7 @@ func MsgVote(clientCtx client.Context, from, id, vote string, extraArgs ...strin
return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdWeightedVote(), args)
}
// MsgDeposit deposits on a proposal
func MsgDeposit(clientCtx client.Context, from, id, deposit string, extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{
id,

View File

@ -29,6 +29,7 @@ func NewProposer(proposalID uint64, proposer string) Proposer {
return Proposer{proposalID, proposer}
}
// String implements the fmt.Stringer interface.
func (p Proposer) String() string {
return fmt.Sprintf("Proposal with ID %d was proposed by %s", p.ProposalID, p.Proposer)
}

View File

@ -31,4 +31,7 @@ func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) {
},
})
})
gov.InitGenesis(ctx, suite.AccountKeeper, suite.BankKeeper, suite.GovKeeper, v1.DefaultGenesisState())
genState := gov.ExportGenesis(ctx, suite.GovKeeper)
require.Equal(t, genState, v1.DefaultGenesisState())
}

View File

@ -30,6 +30,7 @@ var (
TestProposal = getTestProposal()
)
// getTestProposal creates and returns a test proposal message.
func getTestProposal() []sdk.Msg {
legacyProposalMsg, err := v1.NewLegacyContent(v1beta1.NewTextProposal("Title", "description"), authtypes.NewModuleAddress(types.ModuleName).String())
if err != nil {

View File

@ -41,7 +41,7 @@ func (keeper Keeper) GetAllDeposits(ctx sdk.Context) (deposits v1.Deposits) {
return
}
// GetDeposits returns all the deposits from a proposal
// GetDeposits returns all the deposits of a proposal
func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits v1.Deposits) {
keeper.IterateDeposits(ctx, proposalID, func(deposit v1.Deposit) bool {
deposits = append(deposits, &deposit)
@ -51,7 +51,7 @@ func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits v
return
}
// DeleteAndBurnDeposits deletes and burn all the deposits on a specific proposal.
// DeleteAndBurnDeposits deletes and burns all the deposits on a specific proposal.
func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64) {
store := ctx.KVStore(keeper.storeKey)
@ -68,7 +68,7 @@ func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64) {
})
}
// IterateAllDeposits iterates over all the stored deposits and performs a callback function
// IterateAllDeposits iterates over all the stored deposits and performs a callback function.
func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit v1.Deposit) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DepositsKeyPrefix)

View File

@ -2,6 +2,8 @@ package keeper
import sdk "github.com/cosmos/cosmos-sdk/types"
// ValidateInitialDeposit is a helper function used only in deposit tests which returns the same
// functionality of validateInitialDeposit private function.
func (k Keeper) ValidateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins) error {
return k.validateInitialDeposit(ctx, initialDeposit)
}

View File

@ -287,6 +287,7 @@ type legacyQueryServer struct {
keeper *Keeper
}
// NewLegacyQueryServer returns an implementation of the v1beta1 legacy QueryServer interface.
func NewLegacyQueryServer(k *Keeper) v1beta1.QueryServer {
return &legacyQueryServer{keeper: k}
}

View File

@ -3,6 +3,7 @@ package keeper_test
import (
gocontext "context"
"fmt"
"time"
"cosmossdk.io/math"
@ -1346,3 +1347,275 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryDeposits() {
})
}
}
func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() {
suite.reset()
ctx, queryClient := suite.ctx, suite.queryClient
var (
req *v1.QueryTallyResultRequest
expTally *v1.TallyResult
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty request",
func() {
req = &v1.QueryTallyResultRequest{}
},
false,
},
{
"non existing proposal request",
func() {
req = &v1.QueryTallyResultRequest{ProposalId: 2}
},
false,
},
{
"zero proposal id request",
func() {
req = &v1.QueryTallyResultRequest{ProposalId: 0}
},
false,
},
{
"valid request with proposal status passed",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusPassed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
}
},
true,
},
{
"proposal status deposit",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusDepositPeriod,
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1.TallyResult{
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
NoWithVetoCount: "0",
}
},
true,
},
{
"proposal is in voting period",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusVotingPeriod,
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1.TallyResult{
YesCount: "0",
AbstainCount: "0",
NoCount: "0",
NoWithVetoCount: "0",
}
},
true,
},
}
for _, testCase := range testCases {
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
testCase.malleate()
tallyRes, err := queryClient.TallyResult(gocontext.Background(), req)
if testCase.expPass {
suite.Require().NoError(err)
suite.Require().NotEmpty(tallyRes.Tally.String())
suite.Require().Equal(expTally.String(), tallyRes.Tally.String())
} else {
suite.Require().Error(err)
suite.Require().Nil(tallyRes)
}
})
}
}
func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() {
suite.reset()
ctx, queryClient := suite.ctx, suite.legacyQueryClient
var (
req *v1beta1.QueryTallyResultRequest
expTally *v1beta1.TallyResult
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty request",
func() {
req = &v1beta1.QueryTallyResultRequest{}
},
false,
},
{
"non existing proposal request",
func() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: 2}
},
false,
},
{
"zero proposal id request",
func() {
req = &v1beta1.QueryTallyResultRequest{ProposalId: 0}
},
false,
},
{
"valid request with proposal status passed",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusPassed,
FinalTallyResult: &v1.TallyResult{
YesCount: "4",
AbstainCount: "1",
NoCount: "0",
NoWithVetoCount: "0",
},
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1beta1.TallyResult{
Yes: math.NewInt(4),
Abstain: math.NewInt(1),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
}
},
true,
},
{
"proposal status deposit",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusDepositPeriod,
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1beta1.TallyResult{
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
}
},
true,
},
{
"proposal is in voting period",
func() {
propTime := time.Now()
proposal := v1.Proposal{
Id: 1,
Status: v1.StatusVotingPeriod,
SubmitTime: &propTime,
VotingStartTime: &propTime,
VotingEndTime: &propTime,
Metadata: "proposal metadata",
}
suite.govKeeper.SetProposal(ctx, proposal)
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
expTally = &v1beta1.TallyResult{
Yes: math.NewInt(0),
Abstain: math.NewInt(0),
No: math.NewInt(0),
NoWithVeto: math.NewInt(0),
}
},
true,
},
}
for _, testCase := range testCases {
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
testCase.malleate()
tallyRes, err := queryClient.TallyResult(gocontext.Background(), req)
if testCase.expPass {
suite.Require().NoError(err)
suite.Require().NotEmpty(tallyRes.Tally.String())
suite.Require().Equal(expTally.String(), tallyRes.Tally.String())
} else {
suite.Require().Error(err)
suite.Require().Nil(tallyRes)
}
})
}
}

View File

@ -21,7 +21,7 @@ func AllInvariants(keeper *Keeper, bk types.BankKeeper) sdk.Invariant {
}
// ModuleAccountInvariant checks that the module account coins reflects the sum of
// deposit amounts held on store
// deposit amounts held on store.
func ModuleAccountInvariant(keeper *Keeper, bk types.BankKeeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
var expectedDeposits sdk.Coins

View File

@ -46,7 +46,7 @@ type Keeper struct {
authority string
}
// GetAuthority returns the x/distribution module's authority.
// GetAuthority returns the x/gov module's authority.
func (k Keeper) GetAuthority() string {
return k.authority
}
@ -110,6 +110,7 @@ func (keeper *Keeper) SetHooks(gh types.GovHooks) *Keeper {
return keeper
}
// SetLegacyRouter sets the legacy router for governance
func (keeper *Keeper) SetLegacyRouter(router v1beta1.Router) {
// It is vital to seal the governance proposal router here as to not allow
// further handlers to be registered after the keeper is created since this
@ -140,7 +141,7 @@ func (keeper Keeper) GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccou
// ProposalQueues
// InsertActiveProposalQueue inserts a ProposalID into the active proposal queue at endTime
// InsertActiveProposalQueue inserts a proposalID into the active proposal queue at endTime
func (keeper Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) {
store := ctx.KVStore(keeper.storeKey)
bz := types.GetProposalIDBytes(proposalID)
@ -153,7 +154,7 @@ func (keeper Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID u
store.Delete(types.ActiveProposalQueueKey(proposalID, endTime))
}
// InsertInactiveProposalQueue Inserts a ProposalID into the inactive proposal queue at endTime
// InsertInactiveProposalQueue inserts a proposalID into the inactive proposal queue at endTime
func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time) {
store := ctx.KVStore(keeper.storeKey)
bz := types.GetProposalIDBytes(proposalID)
@ -219,7 +220,7 @@ func (keeper Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time
}
// assertMetadataLength returns an error if given metadata length
// is greater than a pre-defined maxMetadataLen.
// is greater than a pre-defined MaxMetadataLen.
func (keeper Keeper) assertMetadataLength(metadata string) error {
if metadata != "" && uint64(len(metadata)) > keeper.config.MaxMetadataLen {
return types.ErrMetadataTooLong.Wrapf("got metadata with length %d", len(metadata))

View File

@ -32,7 +32,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
// Migrate2to3 migrates from version 2 to 3.
// Migrate3to4 migrates from version 3 to 4.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

View File

@ -27,6 +27,7 @@ func NewMsgServerImpl(keeper *Keeper) v1.MsgServer {
var _ v1.MsgServer = msgServer{}
// SubmitProposal implements the MsgServer.SubmitProposal method.
func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitProposal) (*v1.MsgSubmitProposalResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
@ -77,6 +78,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos
}, nil
}
// ExecLegacyContent implements the MsgServer.ExecLegacyContent method.
func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegacyContent) (*v1.MsgExecLegacyContentResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
@ -103,6 +105,7 @@ func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegac
return &v1.MsgExecLegacyContentResponse{}, nil
}
// Vote implements the MsgServer.Vote method.
func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, err := sdk.AccAddressFromBech32(msg.Voter)
@ -125,6 +128,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp
return &v1.MsgVoteResponse{}, nil
}
// VoteWeighted implements the MsgServer.VoteWeighted method.
func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted) (*v1.MsgVoteWeightedResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, accErr := sdk.AccAddressFromBech32(msg.Voter)
@ -147,6 +151,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted)
return &v1.MsgVoteWeightedResponse{}, nil
}
// Deposit implements the MsgServer.Deposit method.
func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDepositResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
accAddr, err := sdk.AccAddressFromBech32(msg.Depositor)
@ -178,6 +183,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
return &v1.MsgDepositResponse{}, nil
}
// UpdateParams implements the MsgServer.UpdateParams method.
func (k msgServer) UpdateParams(goCtx context.Context, msg *v1.MsgUpdateParams) (*v1.MsgUpdateParamsResponse, error) {
if k.authority != msg.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)

View File

@ -6,6 +6,7 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
// SetParams sets the gov module's parameters.
func (k Keeper) SetParams(ctx sdk.Context, params v1.Params) error {
store := ctx.KVStore(k.storeKey)
bz, err := k.cdc.Marshal(&params)
@ -17,6 +18,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params v1.Params) error {
return nil
}
// GetParams gets the gov module's parameters.
func (k Keeper) GetParams(clientCtx sdk.Context) (params v1.Params) {
store := clientCtx.KVStore(k.storeKey)
bz := store.Get(types.ParamsKey)

View File

@ -151,7 +151,7 @@ func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64) {
store.Delete(types.ProposalKey(proposalID))
}
// IterateProposals iterates over the all the proposals and performs a callback function.
// IterateProposals iterates over all the proposals and performs a callback function.
// Panics when the iterator encounters a proposal which can't be unmarshaled.
func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal v1.Proposal) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
@ -245,6 +245,7 @@ func (keeper Keeper) SetProposalID(ctx sdk.Context, proposalID uint64) {
store.Set(types.ProposalIDKey, types.GetProposalIDBytes(proposalID))
}
// ActivateVotingPeriod activates the voting period of a proposal
func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal v1.Proposal) {
startTime := ctx.BlockHeader().Time
proposal.VotingStartTime = &startTime
@ -258,6 +259,7 @@ func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal v1.Proposal)
keeper.InsertActiveProposalQueue(ctx, proposal.Id, *proposal.VotingEndTime)
}
// MarshalProposal marshals the proposal and returns binary encoded bytes.
func (keeper Keeper) MarshalProposal(proposal v1.Proposal) ([]byte, error) {
bz, err := keeper.cdc.Marshal(&proposal)
if err != nil {
@ -266,6 +268,7 @@ func (keeper Keeper) MarshalProposal(proposal v1.Proposal) ([]byte, error) {
return bz, nil
}
// UnmarshalProposal unmarshals the proposal.
func (keeper Keeper) UnmarshalProposal(bz []byte, proposal *v1.Proposal) error {
err := keeper.cdc.Unmarshal(bz, proposal)
if err != nil {

View File

@ -28,6 +28,23 @@ func (suite *KeeperTestSuite) TestGetSetProposal() {
suite.Require().Equal(proposal, gotProposal)
}
func (suite *KeeperTestSuite) TestDeleteProposal() {
// delete non-existing proposal
suite.Require().PanicsWithValue(fmt.Sprintf("couldn't find proposal with id#%d", 10),
func() {
suite.govKeeper.DeleteProposal(suite.ctx, 10)
},
)
tp := TestProposal
proposal, err := suite.govKeeper.SubmitProposal(suite.ctx, tp, "")
suite.Require().NoError(err)
proposalID := proposal.Id
suite.govKeeper.SetProposal(suite.ctx, proposal)
suite.Require().NotPanics(func() {
suite.govKeeper.DeleteProposal(suite.ctx, proposalID)
}, "")
}
func (suite *KeeperTestSuite) TestActivateVotingPeriod() {
tp := TestProposal
proposal, err := suite.govKeeper.SubmitProposal(suite.ctx, tp, "")

View File

@ -1,6 +1,6 @@
package v1
// Package v040 is copy-pasted from:
// Package v1 (v0.40) is copy-pasted from:
// https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/gov/types/keys.go
import (

View File

@ -4,7 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// migrateWeightedVotes migrates the ADR-037 weighted votes.
// migrateJSONWeightedVotes migrates the ADR-037 weighted votes.
func migrateJSONWeightedVotes(oldVotes v1beta1.Votes) v1beta1.Votes {
newVotes := make(v1beta1.Votes, len(oldVotes))
for i, oldVote := range oldVotes {
@ -14,8 +14,8 @@ func migrateJSONWeightedVotes(oldVotes v1beta1.Votes) v1beta1.Votes {
return newVotes
}
// MigrateJSON accepts exported v0.40 x/gov genesis state and migrates it to
// v0.43 x/gov genesis state. The migration includes:
// MigrateJSON accepts exported v1 (v0.40) x/gov genesis state and migrates it to
// v2 (v0.43) x/gov genesis state. The migration includes:
//
// - Gov weighted votes.
func MigrateJSON(oldState *v1beta1.GenesisState) *v1beta1.GenesisState {

View File

@ -71,7 +71,7 @@ func migrateStoreWeightedVotes(store sdk.KVStore, cdc codec.BinaryCodec) error {
return nil
}
// MigrateStore performs in-place store migrations from v0.40 to v0.43. The
// MigrateStore performs in-place store migrations from v1 (v0.40) to v2 (v0.43). The
// migration includes:
//
// - Change addresses to be length-prefixed.

View File

@ -5,8 +5,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// MigrateJSON accepts exported v0.43 x/gov genesis state and migrates it to
// v0.46 x/gov genesis state. The migration includes:
// MigrateJSON accepts exported v2 (v0.43) x/gov genesis state and migrates it to
// v3 (V0.46) x/gov genesis state. The migration includes:
//
// - Updating everything to v1.
// - Migrating proposals to be Msg-based.

View File

@ -40,7 +40,7 @@ func migrateProposals(store sdk.KVStore, cdc codec.BinaryCodec) error {
return nil
}
// MigrateStore performs in-place store migrations from v0.43 to v0.46. The
// MigrateStore performs in-place store migrations from v2 (v0.43) to v3 (v0.46). The
// migration includes:
//
// - Migrate proposals to be Msg-based.

View File

@ -4,6 +4,12 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
// MigrateJSON accepts exported v3 (v0.46) x/gov genesis state and migrates it to
// v4 (v0.47) x/gov genesis state. The migration includes:
//
// Params migrations from x/params to gov
// Addition of the new min initial deposit ratio parameter that is set to 0 by default.
// Proposals in voting period are tracked in a separate index.
func MigrateJSON(oldState *v1.GenesisState) (*v1.GenesisState, error) {
params := v1.NewParams(
oldState.DepositParams.MinDeposit,

View File

@ -7,6 +7,7 @@ import (
"time"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/simulation"
@ -25,37 +26,37 @@ const (
TallyParamsVeto = "tally_params_veto"
)
// GenDepositParamsDepositPeriod randomized DepositParamsDepositPeriod
// GenDepositParamsDepositPeriod returns randomized DepositParamsDepositPeriod
func GenDepositParamsDepositPeriod(r *rand.Rand) time.Duration {
return time.Duration(simulation.RandIntBetween(r, 1, 2*60*60*24*2)) * time.Second
}
// GenDepositParamsMinDeposit randomized DepositParamsMinDeposit
// GenDepositParamsMinDeposit returns randomized DepositParamsMinDeposit
func GenDepositParamsMinDeposit(r *rand.Rand) sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, int64(simulation.RandIntBetween(r, 1, 1e3))))
}
// GenDepositMinInitialRatio randomized DepositMinInitialRatio
// GenDepositMinInitialRatio returns randomized DepositMinInitialRatio
func GenDepositMinInitialDepositRatio(r *rand.Rand) sdk.Dec {
return sdk.NewDec(int64(simulation.RandIntBetween(r, 0, 99))).Quo(sdk.NewDec(100))
}
// GenVotingParamsVotingPeriod randomized VotingParamsVotingPeriod
// GenVotingParamsVotingPeriod returns randomized VotingParamsVotingPeriod
func GenVotingParamsVotingPeriod(r *rand.Rand) time.Duration {
return time.Duration(simulation.RandIntBetween(r, 1, 2*60*60*24*2)) * time.Second
}
// GenTallyParamsQuorum randomized TallyParamsQuorum
// GenTallyParamsQuorum returns randomized TallyParamsQuorum
func GenTallyParamsQuorum(r *rand.Rand) math.LegacyDec {
return sdk.NewDecWithPrec(int64(simulation.RandIntBetween(r, 334, 500)), 3)
}
// GenTallyParamsThreshold randomized TallyParamsThreshold
// GenTallyParamsThreshold returns randomized TallyParamsThreshold
func GenTallyParamsThreshold(r *rand.Rand) math.LegacyDec {
return sdk.NewDecWithPrec(int64(simulation.RandIntBetween(r, 450, 550)), 3)
}
// GenTallyParamsVeto randomized TallyParamsVeto
// GenTallyParamsVeto returns randomized TallyParamsVeto
func GenTallyParamsVeto(r *rand.Rand) math.LegacyDec {
return sdk.NewDecWithPrec(int64(simulation.RandIntBetween(r, 250, 334)), 3)
}

View File

@ -22,6 +22,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/gov/v1/MsgUpdateParams")
}
// RegisterInterfaces registers the interfaces types with the Interface Registry.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgSubmitProposal{},
@ -36,7 +37,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
}
func init() {
// Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be
// Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)

View File

@ -31,6 +31,7 @@ func (d Deposits) Equal(other Deposits) bool {
return true
}
// String implements stringer interface
func (d Deposits) String() string {
if len(d) == 0 {
return "[]"

View File

@ -123,8 +123,10 @@ func (ProposalStatus) EnumDescriptor() ([]byte, []int) {
// WeightedVoteOption defines a unit of vote for vote split.
type WeightedVoteOption struct {
// option defines the valid vote options, it must not contain duplicate vote options.
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
// weight is the vote weight associated with the vote option.
Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"`
}
func (m *WeightedVoteOption) Reset() { *m = WeightedVoteOption{} }
@ -177,9 +179,12 @@ func (m *WeightedVoteOption) GetWeight() string {
// Deposit defines an amount deposited by an account address to an active
// proposal.
type Deposit struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []types.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []types.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount"`
}
func (m *Deposit) Reset() { *m = Deposit{} }
@ -238,18 +243,26 @@ func (m *Deposit) GetAmount() []types.Coin {
// Proposal defines the core field members of a governance proposal.
type Proposal struct {
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Messages []*types1.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1.ProposalStatus" json:"status,omitempty"`
// id defines the unique id of the proposal.
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// messages are the arbitrary messages to be executed if the proposal passes.
Messages []*types1.Any `protobuf:"bytes,2,rep,name=messages,proto3" json:"messages,omitempty"`
// status defines the proposal status.
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1.ProposalStatus" json:"status,omitempty"`
// 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 `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result,omitempty"`
SubmitTime *time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time,omitempty"`
DepositEndTime *time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time,omitempty"`
TotalDeposit []types.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit"`
VotingStartTime *time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time,omitempty"`
VotingEndTime *time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time,omitempty"`
// submit_time is the time of proposal submission.
SubmitTime *time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time,omitempty"`
// deposit_end_time is the end time for deposition.
DepositEndTime *time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time,omitempty"`
// total_deposit is the total deposit on the proposal.
TotalDeposit []types.Coin `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3" json:"total_deposit"`
// voting_start_time is the starting time to vote on a proposal.
VotingStartTime *time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time,omitempty"`
// voting_end_time is the end time of voting on a proposal.
VotingEndTime *time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time,omitempty"`
// metadata is any arbitrary metadata attached to the proposal.
Metadata string `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -359,9 +372,13 @@ func (m *Proposal) GetMetadata() string {
// TallyResult defines a standard tally for a governance proposal.
type TallyResult struct {
YesCount string `protobuf:"bytes,1,opt,name=yes_count,json=yesCount,proto3" json:"yes_count,omitempty"`
AbstainCount string `protobuf:"bytes,2,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"`
NoCount string `protobuf:"bytes,3,opt,name=no_count,json=noCount,proto3" json:"no_count,omitempty"`
// yes_count is the number of yes votes on a proposal.
YesCount string `protobuf:"bytes,1,opt,name=yes_count,json=yesCount,proto3" json:"yes_count,omitempty"`
// abstain_count is the number of abstain votes on a proposal.
AbstainCount string `protobuf:"bytes,2,opt,name=abstain_count,json=abstainCount,proto3" json:"abstain_count,omitempty"`
// no_count is the number of no votes on a proposal.
NoCount string `protobuf:"bytes,3,opt,name=no_count,json=noCount,proto3" json:"no_count,omitempty"`
// no_with_veto_count is the number of no with veto votes on a proposal.
NoWithVetoCount string `protobuf:"bytes,4,opt,name=no_with_veto_count,json=noWithVetoCount,proto3" json:"no_with_veto_count,omitempty"`
}
@ -429,9 +446,12 @@ func (m *TallyResult) GetNoWithVetoCount() string {
// Vote defines a vote on a governance proposal.
// A Vote consists of a proposal ID, the voter, and the vote option.
type Vote struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address of the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options is the weighted vote options.
Options []*WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options,omitempty"`
// metadata is any arbitrary metadata to attached to the vote.
Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -555,7 +575,7 @@ func (m *DepositParams) GetMaxDepositPeriod() *time.Duration {
// VotingParams defines the params for voting on governance proposals.
type VotingParams struct {
// Length of the voting period.
// Duration of the voting period.
VotingPeriod *time.Duration `protobuf:"bytes,1,opt,name=voting_period,json=votingPeriod,proto3,stdduration" json:"voting_period,omitempty"`
}
@ -674,7 +694,7 @@ type Params struct {
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
MaxDepositPeriod *time.Duration `protobuf:"bytes,2,opt,name=max_deposit_period,json=maxDepositPeriod,proto3,stdduration" json:"max_deposit_period,omitempty"`
// Length of the voting period.
// Duration of the voting period.
VotingPeriod *time.Duration `protobuf:"bytes,3,opt,name=voting_period,json=votingPeriod,proto3,stdduration" json:"voting_period,omitempty"`
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.

View File

@ -4,6 +4,7 @@ import (
"fmt"
"cosmossdk.io/math"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -38,17 +39,18 @@ func NewMsgSubmitProposal(messages []sdk.Msg, initialDeposit sdk.Coins, proposer
return m, nil
}
// GetMsgs unpacks m.Messages Any's into sdk.Msg's
func (m *MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) {
return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal")
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (m MsgSubmitProposal) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (m MsgSubmitProposal) Type() string { return sdk.MsgTypeURL(&m) }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (m MsgSubmitProposal) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Proposer); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err)
@ -83,13 +85,13 @@ func (m MsgSubmitProposal) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (m MsgSubmitProposal) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgSubmitProposal.
func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress {
proposer, _ := sdk.AccAddressFromBech32(m.Proposer)
return []sdk.AccAddress{proposer}
@ -107,13 +109,13 @@ func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins
return &MsgDeposit{proposalID, depositor.String(), amount}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgDeposit) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgDeposit) Type() string { return sdk.MsgTypeURL(&msg) }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgDeposit) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Depositor); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid depositor address: %s", err)
@ -129,13 +131,13 @@ func (msg MsgDeposit) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgDeposit) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgDeposit.
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
depositor, _ := sdk.AccAddressFromBech32(msg.Depositor)
return []sdk.AccAddress{depositor}
@ -148,13 +150,13 @@ func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption, meta
return &MsgVote{proposalID, voter.String(), option, metadata}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgVote) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgVote) Type() string { return sdk.MsgTypeURL(&msg) }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgVote) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
@ -166,13 +168,13 @@ func (msg MsgVote) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgVote) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgVote.
func (msg MsgVote) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}
@ -185,13 +187,13 @@ func NewMsgVoteWeighted(voter sdk.AccAddress, proposalID uint64, options Weighte
return &MsgVoteWeighted{proposalID, voter.String(), options, metadata}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgVoteWeighted) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgVoteWeighted) Type() string { return sdk.MsgTypeURL(&msg) }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgVoteWeighted) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
@ -228,18 +230,21 @@ func (msg MsgVoteWeighted) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgVoteWeighted) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgVoteWeighted.
func (msg MsgVoteWeighted) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}
}
// NewMsgExecLegacyContent creates a new MsgExecLegacyContent instance
//
//nolint:interfacer
func NewMsgExecLegacyContent(content *codectypes.Any, authority string) *MsgExecLegacyContent {
return &MsgExecLegacyContent{
Content: content,
@ -247,11 +252,13 @@ func NewMsgExecLegacyContent(content *codectypes.Any, authority string) *MsgExec
}
}
// GetSigners returns the expected signers for a MsgExecLegacyContent.
func (c MsgExecLegacyContent) GetSigners() []sdk.AccAddress {
authority, _ := sdk.AccAddressFromBech32(c.Authority)
return []sdk.AccAddress{authority}
}
// ValidateBasic implements the sdk.Msg interface.
func (c MsgExecLegacyContent) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(c.Authority)
if err != nil {
@ -267,13 +274,13 @@ func (c MsgExecLegacyContent) UnpackInterfaces(unpacker codectypes.AnyUnpacker)
return unpacker.UnpackAny(c.Content, &content)
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgUpdateParams) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgUpdateParams) Type() string { return sdk.MsgTypeURL(&msg) }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err)
@ -282,13 +289,13 @@ func (msg MsgUpdateParams) ValidateBasic() error {
return msg.Params.ValidateBasic()
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgUpdateParams) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgUpdateParams.
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
authority, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{authority}

View File

@ -5,6 +5,7 @@ import (
"time"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -46,6 +47,7 @@ func NewVotingParams(votingPeriod *time.Duration) VotingParams {
}
}
// NewParams creates a new Params instance with given values.
func NewParams(
minDeposit sdk.Coins, maxDepositPeriod time.Duration, votingPeriod time.Duration,
quorum string, threshold string, vetoThreshold string, minInitialDepositRatio string,
@ -61,7 +63,7 @@ func NewParams(
}
}
// DefaultParams default governance params
// DefaultParams returns the default governance params
func DefaultParams() Params {
return NewParams(
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinDepositTokens)),
@ -74,6 +76,7 @@ func DefaultParams() Params {
)
}
// ValidateBasic performs basic validation on governance parameters.
func (p Params) ValidateBasic() error {
if minDeposit := sdk.Coins(p.MinDeposit); minDeposit.Empty() || !minDeposit.IsValid() {
return fmt.Errorf("invalid minimum deposit: %s", minDeposit)

View File

@ -95,7 +95,6 @@ func ProposalStatusFromString(str string) (ProposalStatus, error) {
}
// Format implements the fmt.Formatter interface.
func (status ProposalStatus) Format(s fmt.State, verb rune) {
switch verb {
case 's':

View File

@ -20,7 +20,7 @@ const (
ParamTallying = "tallying"
)
// QueryProposalParams Params for queries:
// QueryProposalParams is used for queries:
// - 'custom/gov/proposal'
// - 'custom/gov/deposits'
// - 'custom/gov/tally'
@ -35,7 +35,7 @@ func NewQueryProposalParams(proposalID uint64) QueryProposalParams {
}
}
// QueryProposalVotesParams used for queries to 'custom/gov/votes'.
// QueryProposalVotesParams is used to query 'custom/gov/votes'.
type QueryProposalVotesParams struct {
ProposalID uint64
Page int
@ -51,7 +51,7 @@ func NewQueryProposalVotesParams(proposalID uint64, page, limit int) QueryPropos
}
}
// QueryDepositParams params for query 'custom/gov/deposit'
// QueryDepositParams is used to query 'custom/gov/deposit'
type QueryDepositParams struct {
ProposalID uint64
Depositor sdk.AccAddress
@ -65,7 +65,7 @@ func NewQueryDepositParams(proposalID uint64, depositor sdk.AccAddress) QueryDep
}
}
// QueryVoteParams Params for query 'custom/gov/vote'
// QueryVoteParams is used to query 'custom/gov/vote'
type QueryVoteParams struct {
ProposalID uint64
Voter sdk.AccAddress
@ -79,7 +79,7 @@ func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams
}
}
// QueryProposalsParams Params for query 'custom/gov/proposals'
// QueryProposalsParams is used to query 'custom/gov/proposals'
type QueryProposalsParams struct {
Page int
Limit int

View File

@ -78,6 +78,7 @@ func (m *QueryProposalRequest) GetProposalId() uint64 {
// QueryProposalResponse is the response type for the Query/Proposal RPC method.
type QueryProposalResponse struct {
// proposal is the requested governance proposal.
Proposal *Proposal `protobuf:"bytes,1,opt,name=proposal,proto3" json:"proposal,omitempty"`
}
@ -197,6 +198,7 @@ func (m *QueryProposalsRequest) GetPagination() *query.PageRequest {
// QueryProposalsResponse is the response type for the Query/Proposals RPC
// method.
type QueryProposalsResponse struct {
// proposals defines all the requested governance proposals.
Proposals []*Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -306,7 +308,7 @@ func (m *QueryVoteRequest) GetVoter() string {
// QueryVoteResponse is the response type for the Query/Vote RPC method.
type QueryVoteResponse struct {
// vote defined the queried vote.
// vote defines the queried vote.
Vote *Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"`
}
@ -407,7 +409,7 @@ func (m *QueryVotesRequest) GetPagination() *query.PageRequest {
// QueryVotesResponse is the response type for the Query/Votes RPC method.
type QueryVotesResponse struct {
// votes defined the queried votes.
// votes defines the queried votes.
Votes []*Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -746,6 +748,7 @@ func (m *QueryDepositsRequest) GetPagination() *query.PageRequest {
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
type QueryDepositsResponse struct {
// deposits defines the requested deposits.
Deposits []*Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits,omitempty"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`

View File

@ -36,9 +36,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
type MsgSubmitProposal struct {
Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
// messages are the arbitrary messages to be executed if proposal passes.
Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
// initial_deposit is the deposit value that must be paid at proposal submission.
InitialDeposit []types1.Coin `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3" json:"initial_deposit"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// proposer is the account address of the proposer.
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// metadata is any arbitrary metadata attached to the proposal.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
@ -106,6 +109,7 @@ func (m *MsgSubmitProposal) GetMetadata() string {
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
type MsgSubmitProposalResponse struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
}
@ -244,10 +248,14 @@ var xxx_messageInfo_MsgExecLegacyContentResponse proto.InternalMessageInfo
// MsgVote defines a message to cast a vote.
type MsgVote struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// option defines the vote option.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1.VoteOption" json:"option,omitempty"`
// metadata is any arbitrary metadata attached to the Vote.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (m *MsgVote) Reset() { *m = MsgVote{} }
@ -350,10 +358,14 @@ var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo
// MsgVoteWeighted defines a message to cast a vote.
type MsgVoteWeighted struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options defines the weighted vote options.
Options []*WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"`
// metadata is any arbitrary metadata attached to the VoteWeighted.
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (m *MsgVoteWeighted) Reset() { *m = MsgVoteWeighted{} }
@ -456,9 +468,12 @@ var xxx_messageInfo_MsgVoteWeightedResponse proto.InternalMessageInfo
// MsgDeposit defines a message to submit a deposit to an existing proposal.
type MsgDeposit struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount []types1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount []types1.Coin `protobuf:"bytes,3,rep,name=amount,proto3" json:"amount"`
}
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
@ -739,7 +754,7 @@ const _ = grpc.SupportPackageIsVersion4
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type MsgClient interface {
// SubmitProposal defines a method to create new proposal given a content.
// SubmitProposal defines a method to create new proposal given the messages.
SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error)
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
// to execute a legacy content-based proposal.
@ -821,7 +836,7 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
// MsgServer is the server API for Msg service.
type MsgServer interface {
// SubmitProposal defines a method to create new proposal given a content.
// SubmitProposal defines a method to create new proposal given the messages.
SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error)
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
// to execute a legacy content-based proposal.

View File

@ -5,6 +5,7 @@ import (
"strings"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -46,6 +47,7 @@ func (v Votes) Equal(other Votes) bool {
return true
}
// String implements stringer interface
func (v Votes) String() string {
if len(v) == 0 {
return "[]"

View File

@ -22,6 +22,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
}
// RegisterInterfaces registers the interfaces types with the Interface Registry.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgSubmitProposal{},

View File

@ -36,6 +36,7 @@ func (d Deposits) Equal(other Deposits) bool {
return true
}
// String implements stringer interface
func (d Deposits) String() string {
if len(d) == 0 {
return "[]"

View File

@ -4,6 +4,7 @@ import (
"fmt"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec/types"
)
@ -27,6 +28,7 @@ func DefaultGenesisState() *GenesisState {
)
}
// Equal returns true if the GenesisStates are equal
func (data GenesisState) Equal(other GenesisState) bool {
return data.StartingProposalId == other.StartingProposalId &&
data.Deposits.Equal(other.Deposits) &&

View File

@ -126,7 +126,9 @@ func (ProposalStatus) EnumDescriptor() ([]byte, []int) {
//
// Since: cosmos-sdk 0.43
type WeightedVoteOption struct {
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
// option defines the valid vote options, it must not contain duplicate vote options.
Option VoteOption `protobuf:"varint,1,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
// weight is the vote weight associated with the vote option.
Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight"`
}
@ -166,7 +168,9 @@ var xxx_messageInfo_WeightedVoteOption proto.InternalMessageInfo
// TextProposal defines a standard text proposal whose changes need to be
// manually updated in case of approval.
type TextProposal struct {
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// title of the proposal.
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// description associated with the proposal.
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
@ -206,9 +210,12 @@ var xxx_messageInfo_TextProposal proto.InternalMessageInfo
// Deposit defines an amount deposited by an account address to an active
// proposal.
type Deposit struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
}
func (m *Deposit) Reset() { *m = Deposit{} }
@ -246,18 +253,26 @@ var xxx_messageInfo_Deposit proto.InternalMessageInfo
// Proposal defines the core field members of a governance proposal.
type Proposal struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Content *types1.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"status,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// content is the proposal's content.
Content *types1.Any `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
// status defines the proposal status.
Status ProposalStatus `protobuf:"varint,3,opt,name=status,proto3,enum=cosmos.gov.v1beta1.ProposalStatus" json:"status,omitempty"`
// 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 `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result"`
SubmitTime time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time"`
DepositEndTime time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time"`
TotalDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_deposit"`
VotingStartTime time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time"`
VotingEndTime time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time"`
FinalTallyResult TallyResult `protobuf:"bytes,4,opt,name=final_tally_result,json=finalTallyResult,proto3" json:"final_tally_result"`
// submit_time is the time of proposal submission.
SubmitTime time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time"`
// deposit_end_time is the end time for deposition.
DepositEndTime time.Time `protobuf:"bytes,6,opt,name=deposit_end_time,json=depositEndTime,proto3,stdtime" json:"deposit_end_time"`
// total_deposit is the total deposit on the proposal.
TotalDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=total_deposit,json=totalDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_deposit"`
// voting_start_time is the starting time to vote on a proposal.
VotingStartTime time.Time `protobuf:"bytes,8,opt,name=voting_start_time,json=votingStartTime,proto3,stdtime" json:"voting_start_time"`
// voting_end_time is the end time of voting on a proposal.
VotingEndTime time.Time `protobuf:"bytes,9,opt,name=voting_end_time,json=votingEndTime,proto3,stdtime" json:"voting_end_time"`
}
func (m *Proposal) Reset() { *m = Proposal{} }
@ -295,9 +310,13 @@ var xxx_messageInfo_Proposal proto.InternalMessageInfo
// TallyResult defines a standard tally for a governance proposal.
type TallyResult struct {
Yes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=yes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"yes"`
Abstain github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=abstain,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"abstain"`
No github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=no,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"no"`
// yes is the number of yes votes on a proposal.
Yes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=yes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"yes"`
// abstain is the number of abstain votes on a proposal.
Abstain github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=abstain,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"abstain"`
// no is the number of no votes on a proposal.
No github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=no,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"no"`
// no_with_veto is the number of no with veto votes on a proposal.
NoWithVeto github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=no_with_veto,json=noWithVeto,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"no_with_veto"`
}
@ -337,12 +356,16 @@ var xxx_messageInfo_TallyResult proto.InternalMessageInfo
// Vote defines a vote on a governance proposal.
// A Vote consists of a proposal ID, the voter, and the vote option.
type Vote struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"id"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// voter is the voter address of the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// Deprecated: Prefer to use `options` instead. This field is set in queries
// if and only if `len(options) == 1` and that option has weight 1. In all
// other cases, this field will default to VOTE_OPTION_UNSPECIFIED.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"` // Deprecated: Do not use.
// options is the weighted vote options.
//
// Since: cosmos-sdk 0.43
Options []WeightedVoteOption `protobuf:"bytes,4,rep,name=options,proto3" json:"options"`
}
@ -382,10 +405,10 @@ var xxx_messageInfo_Vote proto.InternalMessageInfo
// DepositParams defines the params for deposits on governance proposals.
type DepositParams struct {
// Minimum deposit for a proposal to enter voting period.
// Minimum deposit for a proposal to enter voting period.
MinDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=min_deposit,json=minDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"min_deposit,omitempty"`
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
// Maximum period for Atom holders to deposit on a proposal. Initial value: 2
// months.
MaxDepositPeriod time.Duration `protobuf:"bytes,2,opt,name=max_deposit_period,json=maxDepositPeriod,proto3,stdduration" json:"max_deposit_period,omitempty"`
}
@ -424,7 +447,7 @@ var xxx_messageInfo_DepositParams proto.InternalMessageInfo
// VotingParams defines the params for voting on governance proposals.
type VotingParams struct {
// Length of the voting period.
// Duration of the voting period.
VotingPeriod time.Duration `protobuf:"bytes,1,opt,name=voting_period,json=votingPeriod,proto3,stdduration" json:"voting_period,omitempty"`
}
@ -463,13 +486,13 @@ var xxx_messageInfo_VotingParams proto.InternalMessageInfo
// TallyParams defines the params for tallying votes on governance proposals.
type TallyParams struct {
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
Quorum github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=quorum,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"quorum,omitempty"`
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
// Minimum proportion of Yes votes for proposal to pass. Default value: 0.5.
Threshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=threshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"threshold,omitempty"`
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed. Default value: 1/3.
VetoThreshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=veto_threshold,json=vetoThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"veto_threshold,omitempty"`
}

View File

@ -41,13 +41,16 @@ func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sd
return m, nil
}
// GetInitialDeposit returns the initial deposit of MsgSubmitProposal.
func (m *MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return m.InitialDeposit }
// GetProposer returns the proposer address of MsgSubmitProposal.
func (m *MsgSubmitProposal) GetProposer() sdk.AccAddress {
proposer, _ := sdk.AccAddressFromBech32(m.Proposer)
return proposer
}
// GetContent returns the content of MsgSubmitProposal.
func (m *MsgSubmitProposal) GetContent() Content {
content, ok := m.Content.GetCachedValue().(Content)
if !ok {
@ -56,14 +59,17 @@ func (m *MsgSubmitProposal) GetContent() Content {
return content
}
// SetInitialDeposit sets the given initial deposit for MsgSubmitProposal.
func (m *MsgSubmitProposal) SetInitialDeposit(coins sdk.Coins) {
m.InitialDeposit = coins
}
// SetProposer sets the given proposer address for MsgSubmitProposal.
func (m *MsgSubmitProposal) SetProposer(address fmt.Stringer) {
m.Proposer = address.String()
}
// SetContent sets the content for MsgSubmitProposal.
func (m *MsgSubmitProposal) SetContent(content Content) error {
msg, ok := content.(proto.Message)
if !ok {
@ -77,13 +83,13 @@ func (m *MsgSubmitProposal) SetContent(content Content) error {
return nil
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (m MsgSubmitProposal) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (m MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (m MsgSubmitProposal) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Proposer); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address: %s", err)
@ -109,13 +115,13 @@ func (m MsgSubmitProposal) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (m MsgSubmitProposal) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgSubmitProposal.
func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress {
proposer, _ := sdk.AccAddressFromBech32(m.Proposer)
return []sdk.AccAddress{proposer}
@ -134,13 +140,13 @@ func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins
return &MsgDeposit{proposalID, depositor.String(), amount}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgDeposit) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgDeposit) Type() string { return TypeMsgDeposit }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgDeposit) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Depositor); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid depositor address: %s", err)
@ -155,13 +161,13 @@ func (msg MsgDeposit) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgDeposit) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgDeposit.
func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
depositor, _ := sdk.AccAddressFromBech32(msg.Depositor)
return []sdk.AccAddress{depositor}
@ -174,13 +180,13 @@ func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) *Msg
return &MsgVote{proposalID, voter.String(), option}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgVote) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgVote) Type() string { return TypeMsgVote }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgVote) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
@ -192,13 +198,13 @@ func (msg MsgVote) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgVote) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgVote.
func (msg MsgVote) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}
@ -211,13 +217,13 @@ func NewMsgVoteWeighted(voter sdk.AccAddress, proposalID uint64, options Weighte
return &MsgVoteWeighted{proposalID, voter.String(), options}
}
// Route implements Msg
// Route implements the sdk.Msg interface.
func (msg MsgVoteWeighted) Route() string { return types.RouterKey }
// Type implements Msg
// Type implements the sdk.Msg interface.
func (msg MsgVoteWeighted) Type() string { return TypeMsgVoteWeighted }
// ValidateBasic implements Msg
// ValidateBasic implements the sdk.Msg interface.
func (msg MsgVoteWeighted) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Voter); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid voter address: %s", err)
@ -250,13 +256,13 @@ func (msg MsgVoteWeighted) ValidateBasic() error {
return nil
}
// GetSignBytes implements Msg
// GetSignBytes returns the message bytes to sign over.
func (msg MsgVoteWeighted) GetSignBytes() []byte {
bz := codec.ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
// GetSigners returns the expected signers for a MsgVoteWeighted.
func (msg MsgVoteWeighted) GetSigners() []sdk.AccAddress {
voter, _ := sdk.AccAddressFromBech32(msg.Voter)
return []sdk.AccAddress{voter}

View File

@ -27,7 +27,7 @@ func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) Depo
}
}
// DefaultDepositParams default parameters for deposits
// DefaultDepositParams returns the default parameters for deposits
func DefaultDepositParams() DepositParams {
return NewDepositParams(
sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinDepositTokens)),
@ -49,7 +49,7 @@ func NewTallyParams(quorum, threshold, vetoThreshold sdk.Dec) TallyParams {
}
}
// DefaultTallyParams default parameters for tallying
// DefaultTallyParams returns default parameters for tallying
func DefaultTallyParams() TallyParams {
return NewTallyParams(DefaultQuorum, DefaultThreshold, DefaultVetoThreshold)
}
@ -83,6 +83,7 @@ type Params struct {
DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"`
}
// String implements stringer interface
func (gp Params) String() string {
return gp.VotingParams.String() + "\n" +
gp.TallyParams.String() + "\n" + gp.DepositParams.String()
@ -97,7 +98,7 @@ func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params {
}
}
// DefaultParams default governance params
// DefaultParams returns the default governance params
func DefaultParams() Params {
return NewParams(DefaultVotingParams(), DefaultTallyParams(), DefaultDepositParams())
}

View File

@ -16,6 +16,7 @@ import (
// DefaultStartingProposalID is 1
const DefaultStartingProposalID uint64 = 1
// NewProposal creates a new Proposal instance
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
msg, ok := content.(proto.Message)
if !ok {
@ -49,6 +50,7 @@ func (p Proposal) GetContent() Content {
return content
}
// ProposalType returns the proposal type
func (p Proposal) ProposalType() string {
content := p.GetContent()
if content == nil {
@ -57,6 +59,7 @@ func (p Proposal) ProposalType() string {
return content.ProposalType()
}
// ProposalRoute returns the proposal route
func (p Proposal) ProposalRoute() string {
content := p.GetContent()
if content == nil {
@ -65,6 +68,7 @@ func (p Proposal) ProposalRoute() string {
return content.ProposalRoute()
}
// GetTitle gets the proposal's title
func (p Proposal) GetTitle() string {
content := p.GetContent()
if content == nil {
@ -173,6 +177,7 @@ func (tp *TextProposal) ProposalType() string { return ProposalTypeText }
// ValidateBasic validates the content's title and description of the proposal
func (tp *TextProposal) ValidateBasic() error { return ValidateAbstract(tp) }
// ValidProposalStatus checks if the proposal status is valid
func ValidProposalStatus(status ProposalStatus) bool {
if status == StatusDepositPeriod ||
status == StatusVotingPeriod ||

View File

@ -171,6 +171,7 @@ var xxx_messageInfo_QueryProposalsRequest proto.InternalMessageInfo
// QueryProposalsResponse is the response type for the Query/Proposals RPC
// method.
type QueryProposalsResponse struct {
// proposals defines all the requested governance proposals.
Proposals []Proposal `protobuf:"bytes,1,rep,name=proposals,proto3" json:"proposals"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -266,7 +267,7 @@ var xxx_messageInfo_QueryVoteRequest proto.InternalMessageInfo
// QueryVoteResponse is the response type for the Query/Vote RPC method.
type QueryVoteResponse struct {
// vote defined the queried vote.
// vote defines the queried vote.
Vote Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote"`
}
@ -367,7 +368,7 @@ func (m *QueryVotesRequest) GetPagination() *query.PageRequest {
// QueryVotesResponse is the response type for the Query/Votes RPC method.
type QueryVotesResponse struct {
// votes defined the queried votes.
// votes defines the queried votes.
Votes []Vote `protobuf:"bytes,1,rep,name=votes,proto3" json:"votes"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
@ -675,6 +676,7 @@ func (m *QueryDepositsRequest) GetPagination() *query.PageRequest {
// QueryDepositsResponse is the response type for the Query/Deposits RPC method.
type QueryDepositsResponse struct {
// deposits defines the requested deposits.
Deposits []Deposit `protobuf:"bytes,1,rep,name=deposits,proto3" json:"deposits"`
// pagination defines the pagination in the response.
Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`

View File

@ -37,9 +37,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
type MsgSubmitProposal struct {
Content *types.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// content is the proposal's content.
Content *types.Any `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// initial_deposit is the deposit value that must be paid at proposal submission.
InitialDeposit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=initial_deposit,json=initialDeposit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"initial_deposit"`
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
// proposer is the account address of the proposer.
Proposer string `protobuf:"bytes,3,opt,name=proposer,proto3" json:"proposer,omitempty"`
}
func (m *MsgSubmitProposal) Reset() { *m = MsgSubmitProposal{} }
@ -77,6 +80,7 @@ var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
type MsgSubmitProposalResponse struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
}
@ -122,9 +126,12 @@ func (m *MsgSubmitProposalResponse) GetProposalId() uint64 {
// MsgVote defines a message to cast a vote.
type MsgVote struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// option defines the vote option.
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.gov.v1beta1.VoteOption" json:"option,omitempty"`
}
func (m *MsgVote) Reset() { *m = MsgVote{} }
@ -201,9 +208,12 @@ var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo
//
// Since: cosmos-sdk 0.43
type MsgVoteWeighted struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
Options []WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
// voter is the voter address for the proposal.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
// options defines the weighted vote options.
Options []WeightedVoteOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options"`
}
func (m *MsgVoteWeighted) Reset() { *m = MsgVoteWeighted{} }
@ -280,9 +290,12 @@ var xxx_messageInfo_MsgVoteWeightedResponse proto.InternalMessageInfo
// MsgDeposit defines a message to submit a deposit to an existing proposal.
type MsgDeposit struct {
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id"`
// depositor defines the deposit addresses from the proposals.
Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"`
// amount to be deposited by depositor.
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
}
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }

View File

@ -39,6 +39,7 @@ func (v Votes) Equal(other Votes) bool {
return true
}
// String implements stringer interface
func (v Votes) String() string {
if len(v) == 0 {
return "[]"