Skip to content

Commit 9e66e2f

Browse files
rnkrttarr00ernestognw
authored
Replace overriden with overridden in GovernorCountingOverridable.sol (#5446)
Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com> Co-authored-by: ernestognw <ernestognw@gmail.com>
1 parent 332bcb5 commit 9e66e2f

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
### Breaking Changes
4+
5+
- Replace `GovernorCountingOverridable.VoteReceipt` struct parameter member names `hasOverriden` and `overridenWeight` for `hasOverridden` and `overriddenWeight` respectively.
6+
7+
#### Custom error changes
8+
9+
- Replace `GovernorAlreadyOverridenVote` with `GovernorAlreadyOverriddenVote`.
10+
311
## 5.2.0 (2025-01-08)
412

513
### Breaking Changes

contracts/governance/extensions/GovernorCountingOverridable.sol

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
2727

2828
struct VoteReceipt {
2929
uint8 casted; // 0 if vote was not casted. Otherwise: support + 1
30-
bool hasOverriden;
31-
uint208 overridenWeight;
30+
bool hasOverridden;
31+
uint208 overriddenWeight;
3232
}
3333

3434
struct ProposalVote {
@@ -42,7 +42,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
4242
/// @dev A delegated vote on `proposalId` was overridden by `weight`
4343
event OverrideVoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
4444

45-
error GovernorAlreadyOverridenVote(address account);
45+
error GovernorAlreadyOverriddenVote(address account);
4646

4747
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
4848

@@ -70,7 +70,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
7070
* @dev Check if an `account` has overridden their delegate for a proposal.
7171
*/
7272
function hasVotedOverride(uint256 proposalId, address account) public view virtual returns (bool) {
73-
return _proposalVotes[proposalId].voteReceipt[account].hasOverriden;
73+
return _proposalVotes[proposalId].voteReceipt[account].hasOverridden;
7474
}
7575

7676
/**
@@ -122,7 +122,7 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
122122
revert GovernorAlreadyCastVote(account);
123123
}
124124

125-
totalWeight -= proposalVote.voteReceipt[account].overridenWeight;
125+
totalWeight -= proposalVote.voteReceipt[account].overriddenWeight;
126126
proposalVote.votes[support] += totalWeight;
127127
proposalVote.voteReceipt[account].casted = support + 1;
128128

@@ -141,26 +141,26 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
141141
revert GovernorInvalidVoteType();
142142
}
143143

144-
if (proposalVote.voteReceipt[account].hasOverriden) {
145-
revert GovernorAlreadyOverridenVote(account);
144+
if (proposalVote.voteReceipt[account].hasOverridden) {
145+
revert GovernorAlreadyOverriddenVote(account);
146146
}
147147

148148
uint256 snapshot = proposalSnapshot(proposalId);
149-
uint256 overridenWeight = VotesExtended(address(token())).getPastBalanceOf(account, snapshot);
149+
uint256 overriddenWeight = VotesExtended(address(token())).getPastBalanceOf(account, snapshot);
150150
address delegate = VotesExtended(address(token())).getPastDelegate(account, snapshot);
151151
uint8 delegateCasted = proposalVote.voteReceipt[delegate].casted;
152152

153-
proposalVote.voteReceipt[account].hasOverriden = true;
154-
proposalVote.votes[support] += overridenWeight;
153+
proposalVote.voteReceipt[account].hasOverridden = true;
154+
proposalVote.votes[support] += overriddenWeight;
155155
if (delegateCasted == 0) {
156-
proposalVote.voteReceipt[delegate].overridenWeight += SafeCast.toUint208(overridenWeight);
156+
proposalVote.voteReceipt[delegate].overriddenWeight += SafeCast.toUint208(overriddenWeight);
157157
} else {
158158
uint8 delegateSupport = delegateCasted - 1;
159-
proposalVote.votes[delegateSupport] -= overridenWeight;
160-
emit VoteReduced(delegate, proposalId, delegateSupport, overridenWeight);
159+
proposalVote.votes[delegateSupport] -= overriddenWeight;
160+
emit VoteReduced(delegate, proposalId, delegateSupport, overriddenWeight);
161161
}
162162

163-
return overridenWeight;
163+
return overriddenWeight;
164164
}
165165

166166
/// @dev Variant of {Governor-_castVote} that deals with vote overrides. Returns the overridden weight.
@@ -172,13 +172,13 @@ abstract contract GovernorCountingOverridable is GovernorVotes {
172172
) internal virtual returns (uint256) {
173173
_validateStateBitmap(proposalId, _encodeStateBitmap(ProposalState.Active));
174174

175-
uint256 overridenWeight = _countOverride(proposalId, account, support);
175+
uint256 overriddenWeight = _countOverride(proposalId, account, support);
176176

177-
emit OverrideVoteCast(account, proposalId, support, overridenWeight, reason);
177+
emit OverrideVoteCast(account, proposalId, support, overriddenWeight, reason);
178178

179179
_tallyUpdated(proposalId);
180180

181-
return overridenWeight;
181+
return overriddenWeight;
182182
}
183183

184184
/// @dev Public function for casting an override vote. Returns the overridden weight.

test/governance/extensions/GovernorCountingOverridable.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('GovernorCountingOverridable', function () {
264264
.to.emit(this.mock, 'OverrideVoteCast')
265265
.withArgs(this.voter1, this.helper.id, VoteType.Against, ethers.parseEther('10'), '');
266266
await expect(this.mock.connect(this.voter1).castOverrideVote(this.helper.id, VoteType.Abstain, ''))
267-
.to.be.revertedWithCustomError(this.mock, 'GovernorAlreadyOverridenVote')
267+
.to.be.revertedWithCustomError(this.mock, 'GovernorAlreadyOverriddenVote')
268268
.withArgs(this.voter1.address);
269269
});
270270

0 commit comments

Comments
 (0)