mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Add No Vote Information to Polling Status for Committee Proposals (#1023)
* add no votes information to polling status, updating events and querier cli/rest responses. This allows clients to differeniate between no and abstain votes * update querier test to include no vote assertion
This commit is contained in:
parent
55e36665f0
commit
45c7785859
@ -258,12 +258,12 @@ func (k Keeper) CloseProposal(ctx sdk.Context, proposal types.Proposal, outcome
|
|||||||
case types.MemberCommittee:
|
case types.MemberCommittee:
|
||||||
currVotes := k.TallyMemberCommitteeVotes(ctx, proposal.ID)
|
currVotes := k.TallyMemberCommitteeVotes(ctx, proposal.ID)
|
||||||
possibleVotes := sdk.NewDec(int64(len(com.Members)))
|
possibleVotes := sdk.NewDec(int64(len(com.Members)))
|
||||||
memberPollingStatus := types.NewProposalPollingStatus(proposal.ID, currVotes,
|
memberPollingStatus := types.NewProposalPollingStatus(proposal.ID, currVotes, sdk.ZeroDec(),
|
||||||
currVotes, possibleVotes, com.VoteThreshold, sdk.Dec{Int: nil})
|
currVotes, possibleVotes, com.VoteThreshold, sdk.Dec{Int: nil})
|
||||||
proposalTally = memberPollingStatus
|
proposalTally = memberPollingStatus
|
||||||
case types.TokenCommittee:
|
case types.TokenCommittee:
|
||||||
yesVotes, _, currVotes, possibleVotes := k.TallyTokenCommitteeVotes(ctx, proposal.ID, com.TallyDenom)
|
yesVotes, noVotes, currVotes, possibleVotes := k.TallyTokenCommitteeVotes(ctx, proposal.ID, com.TallyDenom)
|
||||||
tokenPollingStatus := types.NewProposalPollingStatus(proposal.ID, yesVotes,
|
tokenPollingStatus := types.NewProposalPollingStatus(proposal.ID, yesVotes, noVotes,
|
||||||
currVotes, possibleVotes, com.VoteThreshold, com.Quorum)
|
currVotes, possibleVotes, com.VoteThreshold, com.Quorum)
|
||||||
proposalTally = tokenPollingStatus
|
proposalTally = tokenPollingStatus
|
||||||
}
|
}
|
||||||
|
@ -188,12 +188,12 @@ func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Ke
|
|||||||
case types.MemberCommittee:
|
case types.MemberCommittee:
|
||||||
currVotes := keeper.TallyMemberCommitteeVotes(ctx, params.ProposalID)
|
currVotes := keeper.TallyMemberCommitteeVotes(ctx, params.ProposalID)
|
||||||
possibleVotes := sdk.NewDec(int64(len(com.Members)))
|
possibleVotes := sdk.NewDec(int64(len(com.Members)))
|
||||||
memberPollingStatus := types.NewProposalPollingStatus(params.ProposalID, currVotes,
|
memberPollingStatus := types.NewProposalPollingStatus(params.ProposalID, currVotes, sdk.ZeroDec(),
|
||||||
currVotes, possibleVotes, com.VoteThreshold, sdk.Dec{Int: nil})
|
currVotes, possibleVotes, com.VoteThreshold, sdk.Dec{Int: nil})
|
||||||
pollingStatus = memberPollingStatus
|
pollingStatus = memberPollingStatus
|
||||||
case types.TokenCommittee:
|
case types.TokenCommittee:
|
||||||
yesVotes, _, currVotes, possibleVotes := keeper.TallyTokenCommitteeVotes(ctx, params.ProposalID, com.TallyDenom)
|
yesVotes, noVotes, currVotes, possibleVotes := keeper.TallyTokenCommitteeVotes(ctx, params.ProposalID, com.TallyDenom)
|
||||||
tokenPollingStatus := types.NewProposalPollingStatus(params.ProposalID, yesVotes,
|
tokenPollingStatus := types.NewProposalPollingStatus(params.ProposalID, yesVotes, noVotes,
|
||||||
currVotes, possibleVotes, com.VoteThreshold, com.Quorum)
|
currVotes, possibleVotes, com.VoteThreshold, com.Quorum)
|
||||||
pollingStatus = tokenPollingStatus
|
pollingStatus = tokenPollingStatus
|
||||||
}
|
}
|
||||||
|
@ -245,6 +245,7 @@ func (suite *QuerierTestSuite) TestQueryTally() {
|
|||||||
expectedPollingStatus := types.ProposalPollingStatus{
|
expectedPollingStatus := types.ProposalPollingStatus{
|
||||||
ProposalID: 1,
|
ProposalID: 1,
|
||||||
YesVotes: sdk.NewDec(int64(len(suite.votes[propID]))),
|
YesVotes: sdk.NewDec(int64(len(suite.votes[propID]))),
|
||||||
|
NoVotes: sdk.ZeroDec(),
|
||||||
CurrentVotes: sdk.NewDec(int64(len(suite.votes[propID]))),
|
CurrentVotes: sdk.NewDec(int64(len(suite.votes[propID]))),
|
||||||
PossibleVotes: d("3.0"),
|
PossibleVotes: d("3.0"),
|
||||||
VoteThreshold: d("0.667"),
|
VoteThreshold: d("0.667"),
|
||||||
|
@ -66,17 +66,19 @@ func NewQueryRawParamsParams(subspace, key string) QueryRawParamsParams {
|
|||||||
type ProposalPollingStatus struct {
|
type ProposalPollingStatus struct {
|
||||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"`
|
||||||
YesVotes sdk.Dec `json:"yes_votes" yaml:"yes_votes"`
|
YesVotes sdk.Dec `json:"yes_votes" yaml:"yes_votes"`
|
||||||
|
NoVotes sdk.Dec `json:"no_votes" yaml:"no_votes"`
|
||||||
CurrentVotes sdk.Dec `json:"current_votes" yaml:"current_votes"`
|
CurrentVotes sdk.Dec `json:"current_votes" yaml:"current_votes"`
|
||||||
PossibleVotes sdk.Dec `json:"possible_votes" yaml:"possible_votes"`
|
PossibleVotes sdk.Dec `json:"possible_votes" yaml:"possible_votes"`
|
||||||
VoteThreshold sdk.Dec `json:"vote_threshold" yaml:"vote_threshold"`
|
VoteThreshold sdk.Dec `json:"vote_threshold" yaml:"vote_threshold"`
|
||||||
Quorum sdk.Dec `json:"quorum" yaml:"quorum"`
|
Quorum sdk.Dec `json:"quorum" yaml:"quorum"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProposalPollingStatus(proposalID uint64, yesVotes, currentVotes, possibleVotes,
|
func NewProposalPollingStatus(proposalID uint64, yesVotes, noVotes, currentVotes, possibleVotes,
|
||||||
voteThreshold, quorum sdk.Dec) ProposalPollingStatus {
|
voteThreshold, quorum sdk.Dec) ProposalPollingStatus {
|
||||||
return ProposalPollingStatus{
|
return ProposalPollingStatus{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
YesVotes: yesVotes,
|
YesVotes: yesVotes,
|
||||||
|
NoVotes: noVotes,
|
||||||
CurrentVotes: currentVotes,
|
CurrentVotes: currentVotes,
|
||||||
PossibleVotes: possibleVotes,
|
PossibleVotes: possibleVotes,
|
||||||
VoteThreshold: voteThreshold,
|
VoteThreshold: voteThreshold,
|
||||||
@ -88,11 +90,12 @@ func NewProposalPollingStatus(proposalID uint64, yesVotes, currentVotes, possibl
|
|||||||
func (p ProposalPollingStatus) String() string {
|
func (p ProposalPollingStatus) String() string {
|
||||||
return fmt.Sprintf(`Proposal ID: %d
|
return fmt.Sprintf(`Proposal ID: %d
|
||||||
Yes votes: %d
|
Yes votes: %d
|
||||||
|
No votes: %d
|
||||||
Current votes: %d
|
Current votes: %d
|
||||||
Possible votes: %d
|
Possible votes: %d
|
||||||
Vote threshold: %d
|
Vote threshold: %d
|
||||||
Quorum: %d`,
|
Quorum: %d`,
|
||||||
p.ProposalID, p.YesVotes, p.CurrentVotes,
|
p.ProposalID, p.YesVotes, p.NoVotes, p.CurrentVotes,
|
||||||
p.PossibleVotes, p.VoteThreshold, p.Quorum,
|
p.PossibleVotes, p.VoteThreshold, p.Quorum,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user