From 31f61889ff641859a5dc2190867a43293e3d54e1 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 10 Jan 2019 07:02:55 -0800 Subject: [PATCH] Merge PR #3269: Rename tallyresult to finaltallyresult --- PENDING.md | 1 + client/lcd/swagger-ui/swagger.yaml | 2 +- x/gov/handler.go | 2 +- x/gov/keeper.go | 16 ++++++++-------- x/gov/proposals.go | 22 ++++++++++++---------- x/gov/querier.go | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/PENDING.md b/PENDING.md index 4090cadce4..b47dcdcd51 100644 --- a/PENDING.md +++ b/PENDING.md @@ -70,6 +70,7 @@ IMPROVEMENTS * [\#3158](https://github.com/cosmos/cosmos-sdk/pull/3158) Validate slashing genesis * [\#3172](https://github.com/cosmos/cosmos-sdk/pull/3172) Support minimum fees in a local testnet. * [\#3250](https://github.com/cosmos/cosmos-sdk/pull/3250) Refactor integration tests and increase coverage + * [\#2859](https://github.com/cosmos/cosmos-sdk/issues/2859) Rename `TallyResult` in gov proposals to `FinalTallyResult` * SDK * [\#3137](https://github.com/cosmos/cosmos-sdk/pull/3137) Add tag documentation diff --git a/client/lcd/swagger-ui/swagger.yaml b/client/lcd/swagger-ui/swagger.yaml index 41b0558910..3696c6c5ac 100644 --- a/client/lcd/swagger-ui/swagger.yaml +++ b/client/lcd/swagger-ui/swagger.yaml @@ -2271,7 +2271,7 @@ definitions: type: string proposal_status: type: string - tally_result: + final_tally_result: $ref: "#/definitions/TallyResult" submit_time: type: string diff --git a/x/gov/handler.go b/x/gov/handler.go index a394689672..a5faab122c 100644 --- a/x/gov/handler.go +++ b/x/gov/handler.go @@ -136,7 +136,7 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) sdk.Tags { tagValue = tags.ActionProposalRejected } - activeProposal.SetTallyResult(tallyResults) + activeProposal.SetFinalTallyResult(tallyResults) keeper.SetProposal(ctx, activeProposal) keeper.RemoveFromActiveProposalQueue(ctx, activeProposal.GetVotingEndTime(), activeProposal.GetProposalID()) diff --git a/x/gov/keeper.go b/x/gov/keeper.go index abb9e77b2a..19fd65734b 100644 --- a/x/gov/keeper.go +++ b/x/gov/keeper.go @@ -99,14 +99,14 @@ func (keeper Keeper) NewTextProposal(ctx sdk.Context, title string, description return nil } var proposal Proposal = &TextProposal{ - ProposalID: proposalID, - Title: title, - Description: description, - ProposalType: proposalType, - Status: StatusDepositPeriod, - TallyResult: EmptyTallyResult(), - TotalDeposit: sdk.Coins{}, - SubmitTime: ctx.BlockHeader().Time, + ProposalID: proposalID, + Title: title, + Description: description, + ProposalType: proposalType, + Status: StatusDepositPeriod, + FinalTallyResult: EmptyTallyResult(), + TotalDeposit: sdk.Coins{}, + SubmitTime: ctx.BlockHeader().Time, } depositPeriod := keeper.GetDepositParams(ctx).MaxDepositPeriod diff --git a/x/gov/proposals.go b/x/gov/proposals.go index e943fe1169..fd50e079dd 100644 --- a/x/gov/proposals.go +++ b/x/gov/proposals.go @@ -28,8 +28,8 @@ type Proposal interface { GetStatus() ProposalStatus SetStatus(ProposalStatus) - GetTallyResult() TallyResult - SetTallyResult(TallyResult) + GetFinalTallyResult() TallyResult + SetFinalTallyResult(TallyResult) GetSubmitTime() time.Time SetSubmitTime(time.Time) @@ -54,7 +54,7 @@ func ProposalEqual(proposalA Proposal, proposalB Proposal) bool { proposalA.GetDescription() == proposalB.GetDescription() && proposalA.GetProposalType() == proposalB.GetProposalType() && proposalA.GetStatus() == proposalB.GetStatus() && - proposalA.GetTallyResult().Equals(proposalB.GetTallyResult()) && + proposalA.GetFinalTallyResult().Equals(proposalB.GetFinalTallyResult()) && proposalA.GetSubmitTime().Equal(proposalB.GetSubmitTime()) && proposalA.GetDepositEndTime().Equal(proposalB.GetDepositEndTime()) && proposalA.GetTotalDeposit().IsEqual(proposalB.GetTotalDeposit()) && @@ -73,8 +73,8 @@ type TextProposal struct { Description string `json:"description"` // Description of the proposal ProposalType ProposalKind `json:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal} - Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} - TallyResult TallyResult `json:"tally_result"` // Result of Tallys + Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} + FinalTallyResult TallyResult `json:"final_tally_result"` // Result of Tallys SubmitTime time.Time `json:"submit_time"` // Time of the block where TxGovSubmitProposal was included DepositEndTime time.Time `json:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met @@ -98,11 +98,13 @@ func (tp TextProposal) GetProposalType() ProposalKind { return tp.P func (tp *TextProposal) SetProposalType(proposalType ProposalKind) { tp.ProposalType = proposalType } func (tp TextProposal) GetStatus() ProposalStatus { return tp.Status } func (tp *TextProposal) SetStatus(status ProposalStatus) { tp.Status = status } -func (tp TextProposal) GetTallyResult() TallyResult { return tp.TallyResult } -func (tp *TextProposal) SetTallyResult(tallyResult TallyResult) { tp.TallyResult = tallyResult } -func (tp TextProposal) GetSubmitTime() time.Time { return tp.SubmitTime } -func (tp *TextProposal) SetSubmitTime(submitTime time.Time) { tp.SubmitTime = submitTime } -func (tp TextProposal) GetDepositEndTime() time.Time { return tp.DepositEndTime } +func (tp TextProposal) GetFinalTallyResult() TallyResult { return tp.FinalTallyResult } +func (tp *TextProposal) SetFinalTallyResult(tallyResult TallyResult) { + tp.FinalTallyResult = tallyResult +} +func (tp TextProposal) GetSubmitTime() time.Time { return tp.SubmitTime } +func (tp *TextProposal) SetSubmitTime(submitTime time.Time) { tp.SubmitTime = submitTime } +func (tp TextProposal) GetDepositEndTime() time.Time { return tp.DepositEndTime } func (tp *TextProposal) SetDepositEndTime(depositEndTime time.Time) { tp.DepositEndTime = depositEndTime } diff --git a/x/gov/querier.go b/x/gov/querier.go index 8b985929ed..bc4eb0d2ba 100644 --- a/x/gov/querier.go +++ b/x/gov/querier.go @@ -214,7 +214,7 @@ func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke if proposal.GetStatus() == StatusDepositPeriod { tallyResult = EmptyTallyResult() } else if proposal.GetStatus() == StatusPassed || proposal.GetStatus() == StatusRejected { - tallyResult = proposal.GetTallyResult() + tallyResult = proposal.GetFinalTallyResult() } else { // proposal is in voting period _, tallyResult = tally(ctx, keeper, proposal)