Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/gov): min amount per deposit #13

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions proto/atomone/gov/module/v1/module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import "cosmos/app/v1alpha1/module.proto";
// Module is the config object of the gov module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/atomone-hub/atomone/x/gov"
go_import : "github.com/atomone-hub/atomone/x/gov"
};

// max_metadata_len defines the maximum proposal metadata length.
// 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.
// authority defines the custom module authority. If not set, defaults to the
// governance module.
string authority = 2;
}
6 changes: 3 additions & 3 deletions proto/atomone/gov/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ message GenesisState {
repeated Proposal proposals = 4;
// Deprecated: Prefer to use `params` instead.
// deposit_params defines all the paramaters of related to deposit.
DepositParams deposit_params = 5 [deprecated = true];
DepositParams deposit_params = 5 [ deprecated = true ];
// Deprecated: Prefer to use `params` instead.
// voting_params defines all the paramaters of related to voting.
VotingParams voting_params = 6 [deprecated = true];
VotingParams voting_params = 6 [ deprecated = true ];
// Deprecated: Prefer to use `params` instead.
// tally_params defines all the paramaters of related to tally.
TallyParams tally_params = 7 [deprecated = true];
TallyParams tally_params = 7 [ deprecated = true ];
// params defines all the paramaters of x/gov module.
//
// Since: cosmos-sdk 0.47
Expand Down
90 changes: 56 additions & 34 deletions proto/atomone/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,60 @@ 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.
// 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"];
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;
uint64 proposal_id = 1;

// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
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];
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;
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;
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;
TallyResult final_tally_result = 4;

// submit_time is the time of proposal submission.
google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true];
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];
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];

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];

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];
google.protobuf.Timestamp voting_end_time = 9 [ (gogoproto.stdtime) = true ];

// metadata is any arbitrary metadata attached to the proposal.
string metadata = 10;
Expand All @@ -93,7 +97,7 @@ message Proposal {
// Proposer is the address of the proposal sumbitter
//
// Since: cosmos-sdk 0.47
string proposer = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string proposer = 13 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// ProposalStatus enumerates the valid statuses of a proposal.
Expand All @@ -120,9 +124,9 @@ 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"];
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"];
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"];
}
Expand All @@ -134,8 +138,8 @@ message Vote {
uint64 proposal_id = 1;

// voter is the voter address of the proposal.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string voter = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

reserved 3;

// options is the weighted vote options.
Expand All @@ -148,26 +152,30 @@ message Vote {
// DepositParams defines the params for deposits on governance proposals.
message DepositParams {
// 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"];
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.
google.protobuf.Duration max_deposit_period = 2
[(gogoproto.stdduration) = true, (gogoproto.jsontag) = "max_deposit_period,omitempty"];
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 {
// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];
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.
string quorum = 1 [(cosmos_proto.scalar) = "cosmos.Dec"];
string quorum = 1 [ (cosmos_proto.scalar) = "cosmos.Dec" ];

// Minimum proportion of Yes votes for proposal to pass. Default value: 2/3.
string threshold = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];
Expand All @@ -178,14 +186,16 @@ message TallyParams {
// Since: cosmos-sdk 0.47
message Params {
// Minimum deposit for a proposal to enter voting period.
repeated cosmos.base.v1beta1.Coin min_deposit = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
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.
google.protobuf.Duration max_deposit_period = 2 [(gogoproto.stdduration) = true];
google.protobuf.Duration max_deposit_period = 2
[ (gogoproto.stdduration) = true ];

// Duration of the voting period.
google.protobuf.Duration voting_period = 3 [(gogoproto.stdduration) = true];
google.protobuf.Duration voting_period = 3 [ (gogoproto.stdduration) = true ];

// Minimum percentage of total stake needed to vote for a result to be
// considered valid. Default value: 0.25.
Expand All @@ -202,4 +212,16 @@ message Params {

// burn deposits if the proposal does not enter voting period
bool burn_proposal_deposit_prevote = 14;

// burn deposits if quorum with vote type no_veto is met
bool burn_vote_veto = 15;

// The ratio representing the proportion of the deposit value minimum that
// must be met when making a deposit. Default value: 0.01. Meaning that for a
// chain with a min_deposit of 100stake, a deposit of 1stake would be
// required.
//
// Since: cosmos-sdk 0.50
// NOTE: backported from v50 (https://github.com/cosmos/cosmos-sdk/pull/18146)
string min_deposit_ratio = 16 [ (cosmos_proto.scalar) = "cosmos.Dec" ];
}
29 changes: 17 additions & 12 deletions proto/atomone/gov/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ service Query {

// Vote queries voted information based on proposalID, voterAddr.
rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) {
option (google.api.http).get = "/atomone/gov/v1/proposals/{proposal_id}/votes/{voter}";
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/votes/{voter}";
}

// Votes queries votes of a given proposal.
rpc Votes(QueryVotesRequest) returns (QueryVotesResponse) {
option (google.api.http).get = "/atomone/gov/v1/proposals/{proposal_id}/votes";
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/votes";
}

// Params queries all parameters of the gov module.
Expand All @@ -44,17 +46,20 @@ service Query {

// Deposit queries single deposit information based proposalID, depositAddr.
rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) {
option (google.api.http).get = "/atomone/gov/v1/proposals/{proposal_id}/deposits/{depositor}";
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/deposits/{depositor}";
}

// Deposits queries all deposits of a single proposal.
rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) {
option (google.api.http).get = "/atomone/gov/v1/proposals/{proposal_id}/deposits";
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/deposits";
}

// TallyResult queries the tally of a proposal vote.
rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) {
option (google.api.http).get = "/atomone/gov/v1/proposals/{proposal_id}/tally";
option (google.api.http).get =
"/atomone/gov/v1/proposals/{proposal_id}/tally";
}
}

Expand Down Expand Up @@ -84,10 +89,10 @@ message QueryProposalsRequest {
ProposalStatus proposal_status = 1;

// voter defines the voter address for the proposals.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string voter = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// depositor defines the deposit addresses from the proposals.
string depositor = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string depositor = 3 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 4;
Expand All @@ -109,7 +114,7 @@ message QueryVoteRequest {
uint64 proposal_id = 1;

// voter defines the voter address for the proposals.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string voter = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// QueryVoteResponse is the response type for the Query/Vote RPC method.
Expand Down Expand Up @@ -147,13 +152,13 @@ message QueryParamsRequest {
message QueryParamsResponse {
// Deprecated: Prefer to use `params` instead.
// voting_params defines the parameters related to voting.
VotingParams voting_params = 1 [deprecated = true];
VotingParams voting_params = 1 [ deprecated = true ];
// Deprecated: Prefer to use `params` instead.
// deposit_params defines the parameters related to deposit.
DepositParams deposit_params = 2 [deprecated = true];
DepositParams deposit_params = 2 [ deprecated = true ];
// Deprecated: Prefer to use `params` instead.
// tally_params defines the parameters related to tally.
TallyParams tally_params = 3 [deprecated = true];
TallyParams tally_params = 3 [ deprecated = true ];
// params defines all the paramaters of x/gov module.
//
// Since: cosmos-sdk 0.47
Expand All @@ -166,7 +171,7 @@ message QueryDepositRequest {
uint64 proposal_id = 1;

// depositor defines the deposit addresses from the proposals.
string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string depositor = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// QueryDepositResponse is the response type for the Query/Deposit RPC method.
Expand Down
Loading
Loading