Skip to content

Commit e687038

Browse files
authored
Update GovernorCountingOverridable.sol
1 parent 6308fdc commit e687038

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contracts/governance/extensions/GovernorCountingOverridable.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
4545

4646
error GovernorAlreadyOverriddenVote(address account);
4747

48+
error GovernorInsufficientDelegateVotes(uint256 available, uint256 required);
49+
4850
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
4951

5052
/// @inheritdoc IGovernor
@@ -153,7 +155,11 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
153155
proposalVote.voteReceipt[delegate].overriddenWeight += SafeCast.toUint208(overriddenWeight);
154156
} else {
155157
uint8 delegateSupport = delegateCasted - 1;
156-
proposalVote.votes[delegateSupport] -= overriddenWeight;
158+
uint256 currentVotes = proposalVote.votes[delegateSupport];
159+
if (currentVotes < overriddenWeight) {
160+
revert GovernorInsufficientDelegateVotes(currentVotes, overriddenWeight);
161+
}
162+
proposalVote.votes[delegateSupport] = currentVotes - overriddenWeight;
157163
emit VoteReduced(delegate, proposalId, delegateSupport, overriddenWeight);
158164
}
159165

0 commit comments

Comments
 (0)