Skip to content

Commit

Permalink
bugfix gov votes querier to use proper params
Browse files Browse the repository at this point in the history
  • Loading branch information
yun-yeo committed Oct 22, 2020
1 parent 792c7bc commit eddee8c
Showing 1 changed file with 9 additions and 3 deletions.
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 eddee8c

Please sign in to comment.