From 1542ecb18d5b1325cad82cca99bc80ae486cba35 Mon Sep 17 00:00:00 2001 From: yys Date: Wed, 21 Oct 2020 02:35:44 +0900 Subject: [PATCH] Bugfix gov votes querier to use votes params (#7589) * bugfix gov votes querier to use votes params * move partially used statement to the proper block Co-authored-by: Aleksandr Bezobchuk Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- x/gov/client/rest/query.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/x/gov/client/rest/query.go b/x/gov/client/rest/query.go index d526629be9..ffdbd8bc02 100644 --- a/x/gov/client/rest/query.go +++ b/x/gov/client/rest/query.go @@ -337,9 +337,7 @@ func queryVotesOnProposalHandlerFn(clientCtx client.Context) http.HandlerFunc { return } - params := types.NewQueryProposalVotesParams(proposalID, page, limit) - - bz, err := clientCtx.LegacyAmino.MarshalJSON(params) + bz, err := clientCtx.LegacyAmino.MarshalJSON(types.NewQueryProposalParams(proposalID)) if rest.CheckBadRequestError(w, err) { return } @@ -356,10 +354,17 @@ func queryVotesOnProposalHandlerFn(clientCtx client.Context) 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(clientCtx, params) } else { + bz, err = clientCtx.LegacyAmino.MarshalJSON(params) + if rest.CheckBadRequestError(w, err) { + return + } + res, _, err = clientCtx.QueryWithData("custom/gov/votes", bz) }