diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c08fd6566c3..451611a93617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Bug Fixes +* (x/gov) [#19725](https://github.com/cosmos/cosmos-sdk/pull/19725) Fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query. * (baseapp) [#18727](https://github.com/cosmos/cosmos-sdk/pull/18727) Ensure that `BaseApp.Init` firstly returns any errors from a nil commit multistore instead of panicking on nil dereferencing and before sealing the app. * (client) [#18622](https://github.com/cosmos/cosmos-sdk/pull/18622) Fixed a potential under/overflow from `uint64->int64` when computing gas fees as a LegacyDec. * (client/keys) [#18562](https://github.com/cosmos/cosmos-sdk/pull/18562) `keys delete` won't terminate when a key is not found. diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index e163d9a373ef..c863e84ee37e 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -319,7 +319,7 @@ func (q queryServer) TallyResult(ctx context.Context, req *v1.QueryTallyResultRe case proposal.Status == v1.StatusDepositPeriod: tallyResult = v1.EmptyTallyResult() - case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected: + case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected || proposal.Status == v1.StatusFailed: tallyResult = *proposal.FinalTallyResult default: diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index f0fac0d4df6a..28ceb6236d9e 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -1640,6 +1640,48 @@ func (suite *KeeperTestSuite) TestGRPCQueryTallyResult() { }, true, }, + { + "proposal status failed", + func() { + propTime := time.Now() + proposal := v1.Proposal{ + Id: 1, + Status: v1.StatusFailed, + FinalTallyResult: &v1.TallyResult{ + YesCount: "4", + AbstainCount: "1", + NoCount: "0", + NoWithVetoCount: "0", + OptionOneCount: "4", + OptionTwoCount: "1", + OptionThreeCount: "0", + OptionFourCount: "0", + SpamCount: "0", + }, + SubmitTime: &propTime, + VotingStartTime: &propTime, + VotingEndTime: &propTime, + Metadata: "proposal metadata", + } + err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal) + suite.Require().NoError(err) + + req = &v1.QueryTallyResultRequest{ProposalId: proposal.Id} + + expTally = &v1.TallyResult{ + YesCount: "4", + AbstainCount: "1", + NoCount: "0", + NoWithVetoCount: "0", + OptionOneCount: "4", + OptionTwoCount: "1", + OptionThreeCount: "0", + OptionFourCount: "0", + SpamCount: "0", + } + }, + true, + }, } for _, tc := range testCases { @@ -1781,6 +1823,39 @@ func (suite *KeeperTestSuite) TestLegacyGRPCQueryTallyResult() { }, true, }, + { + "proposal status failed", + func() { + propTime := time.Now() + proposal := v1.Proposal{ + Id: 1, + Status: v1.StatusFailed, + FinalTallyResult: &v1.TallyResult{ + YesCount: "4", + AbstainCount: "1", + NoCount: "0", + NoWithVetoCount: "0", + SpamCount: "0", + }, + SubmitTime: &propTime, + VotingStartTime: &propTime, + VotingEndTime: &propTime, + Metadata: "proposal metadata", + } + err := suite.govKeeper.Proposals.Set(suite.ctx, proposal.Id, proposal) + suite.Require().NoError(err) + + req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id} + + expTally = &v1beta1.TallyResult{ + Yes: math.NewInt(4), + Abstain: math.NewInt(1), + No: math.NewInt(0), + NoWithVeto: math.NewInt(0), + } + }, + true, + }, } for _, tc := range testCases {