Skip to content

Commit

Permalink
launchpad: fix query params on governance votes querier (#7624)
Browse files Browse the repository at this point in the history
From: #7589
Closes: #7588
Thanks: @YunSuk-Yeo 

Co-authored-by: Alessio Treglia <[email protected]>
  • Loading branch information
yun-yeo and Alessio Treglia authored Oct 23, 2020
1 parent 792c7bc commit c4f4d03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (client) [\#7588](https://github.com/cosmos/cosmos-sdk/issues/7588) Fix gov votes querier to use proper query params.
* (types) [\#7038](https://github.com/cosmos/cosmos-sdk/issues/7038) Fix infinite looping of `ApproxRoot` by including a hard-coded maximum iterations limit of 100.
* (types) [\#7084](https://github.com/cosmos/cosmos-sdk/pull/7084) Fix panic when calling `BigInt()` on an uninitialized `Int`.
* (client) [\#7048](https://github.com/cosmos/cosmos-sdk/issues/7048) Fix client `keys add` failure when generating mnemonic in interactive mode.
Expand Down
12 changes: 9 additions & 3 deletions x/gov/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}

params := types.NewQueryProposalVotesParams(proposalID, page, limit)

bz, err := cliCtx.Codec.MarshalJSON(params)
bz, err := cliCtx.Codec.MarshalJSON(types.NewQueryProposalParams(proposalID))
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
Expand All @@ -379,10 +377,18 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {

// For inactive proposals we must query the txs directly to get the votes
// as they're no longer in state.
params := types.NewQueryProposalVotesParams(proposalID, page, limit)

propStatus := proposal.Status
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
res, err = gcutils.QueryVotesByTxQuery(cliCtx, params)
} else {
bz, err = cliCtx.Codec.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

res, _, err = cliCtx.QueryWithData("custom/gov/votes", bz)
}

Expand Down

0 comments on commit c4f4d03

Please sign in to comment.