Skip to content

Commit

Permalink
feat: add module_query_safe on x/gov queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Teyz committed Oct 3, 2024
1 parent 09aff1b commit 8e8c5f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions x/distribution/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/distribution` does not depend on `x/protocolpool` anymore, now `x/distribution` only does token transfers and `x/protocolpool` does the rest.
* [#20219](https://github.com/cosmos/cosmos-sdk/issues/20219#event-14494455201) Mark more queries with module_query_safe.

### API Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions x/gov/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#19167](https://github.com/cosmos/cosmos-sdk/pull/19167) Add `YesQuorum` parameter specifying a minimum of yes vote in the total proposal voting power for the proposal to pass.
* [#18445](https://github.com/cosmos/cosmos-sdk/pull/18445) Extend gov config.
* [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) Repurpose `govcliutils.NormalizeProposalType` to work for gov v1 proposal types.
* [#20219](https://github.com/cosmos/cosmos-sdk/issues/20219#event-14494455201) Mark more queries with module_query_safe.

### State Machine Breaking

Expand Down
9 changes: 9 additions & 0 deletions x/gov/proto/cosmos/gov/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/gov/v1beta1/gov.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/query/v1/query.proto";
import "amino/amino.proto";

option go_package = "cosmossdk.io/x/gov/types/v1beta1";
Expand All @@ -14,42 +15,50 @@ option go_package = "cosmossdk.io/x/gov/types/v1beta1";
service Query {
// Proposal queries proposal details based on ProposalID.
rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}";
}

// Proposals queries all proposals based on given status.
rpc Proposals(QueryProposalsRequest) returns (QueryProposalsResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/proposals";
}

// Vote queries voted information based on proposalID, voterAddr.
// Due to how we handle state, this query would error for proposals that has already been finished.
rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}";
}

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

// Params queries all parameters of the gov module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}";
}

// Deposit queries single deposit information based on proposalID, depositor address.
rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}";
}

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

// TallyResult queries the tally of a proposal vote.
rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally";
}
}
Expand Down

0 comments on commit 8e8c5f1

Please sign in to comment.