From eddee8cb26e3be1d1fb8facbffdc1cb16018c4d1 Mon Sep 17 00:00:00 2001 From: Yun Yeo Date: Thu, 22 Oct 2020 12:31:12 +0900 Subject: [PATCH 1/3] bugfix gov votes querier to use proper params --- x/gov/client/rest/query.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/x/gov/client/rest/query.go b/x/gov/client/rest/query.go index 3eb5800d7a99..37fa089e4d8d 100644 --- a/x/gov/client/rest/query.go +++ b/x/gov/client/rest/query.go @@ -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 @@ -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) } From 2005181d96c15aa4b174b4d238c7ec2fbc62faec Mon Sep 17 00:00:00 2001 From: Yun Yeo Date: Thu, 22 Oct 2020 20:42:11 +0900 Subject: [PATCH 2/3] add changelog --- CHANGELOG.md | 1 + x/gov/client/rest/query.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c34dde4ec31a..ae3488e7f077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (client) [\#7642](https://github.com/cosmos/cosmos-sdk/pull/7624) 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. diff --git a/x/gov/client/rest/query.go b/x/gov/client/rest/query.go index 37fa089e4d8d..59aaa735a03a 100644 --- a/x/gov/client/rest/query.go +++ b/x/gov/client/rest/query.go @@ -383,7 +383,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) { res, err = gcutils.QueryVotesByTxQuery(cliCtx, params) } else { - bz, err := cliCtx.Codec.MarshalJSON(params) + bz, err = cliCtx.Codec.MarshalJSON(params) if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return From d3315aa5af352186b25665cfbf29d6060f161788 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Thu, 22 Oct 2020 13:37:11 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae3488e7f077..36f92a0a2451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -* (client) [\#7642](https://github.com/cosmos/cosmos-sdk/pull/7624) Fix gov votes querier to use proper query params +* (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.