Skip to content

Commit

Permalink
fix: adapt wrong majority voting status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik authored Nov 23, 2023
1 parent d789045 commit df34f23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
5 changes: 2 additions & 3 deletions modules/client/src/addresslistVoting/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ export function computeProposalStatusFilter(status: ProposalStatus) {
case ProposalStatus.SUCCEEDED:
where = {
or: [
{ approvalReached: true, endDate_lt: now, isSignaling: false },
{ approvalReached: true, earlyExecutable: true, isSignaling: false },
{ approvalReached: true, isSignaling: true },
{ approvalReached: true, endDate_lt: now },
{ earlyExecutable: true },
],
};
break;
Expand Down
32 changes: 14 additions & 18 deletions modules/client/src/tokenVoting/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,18 @@ export function computeProposalStatus(
if (startDate >= now) {
return ProposalStatus.PENDING;
}
// The proposal is not executed and the start date is in the past
// So we must check if the proposal reached the approval threshold
// If it reached the approval threshold and it's a signaling proposal
// the status becomes SUCCEEDED
// If it reached the approval threshold and it's not a signaling proposal
// the status becomes SUCCEEDED if the end date is in the past or if the
// proposal is early executable
if (proposal.approvalReached) {
if(proposal.isSignaling) {
return ProposalStatus.SUCCEEDED;
} else {
if (now >= endDate || proposal.earlyExecutable) {
return ProposalStatus.SUCCEEDED;
}
}
// The proposal is not executed and the start date is in the past.
// Accordingly, we check if the proposal reached enough approval
// (i.e., that the supportThreshold and minParticipation criteria are both met).
// If the approval is reached and the vote has ended (end date is in the past) it has succeded.
// This applies to normal mode and vote replacement mode.
if (proposal.approvalReached && endDate <= now) {
return ProposalStatus.SUCCEEDED;
}
// In early exeuction mode, we calculate if subsequent voting can change the result of the vote.
// If not, the proposal is early executable and is therefore succeeded as well.
if(proposal.earlyExecutable){
return ProposalStatus.SUCCEEDED;
}
// The proposal is not executed and the start date is in the past
// and the approval threshold is not reached
Expand Down Expand Up @@ -353,9 +350,8 @@ export function computeProposalStatusFilter(status: ProposalStatus) {
case ProposalStatus.SUCCEEDED:
where = {
or: [
{ approvalReached: true, endDate_lt: now, isSignaling: false },
{ approvalReached: true, earlyExecutable: true, isSignaling: false },
{ approvalReached: true, isSignaling: true },
{ approvalReached: true, endDate_lt: now },
{ earlyExecutable: true },
],
};
break;
Expand Down

0 comments on commit df34f23

Please sign in to comment.