Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate override vote #5192

Merged
merged 31 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ad82b2
Initial commit
arr00 Aug 12, 2024
e5dc350
use only one extension. add counting
arr00 Aug 14, 2024
ed3da11
Update docs
arr00 Aug 18, 2024
4bc3b1d
Use existing castVoteWithReasonAndParams for override
arr00 Aug 18, 2024
c6a048b
fix: override per proposalId instead of timepoint
arr00 Aug 19, 2024
1e6e530
update comments
arr00 Aug 20, 2024
d7550a4
Use hardhat testing
arr00 Aug 21, 2024
5cdcb44
Inherit `GovernorVotes` to avoid code duplication
arr00 Aug 21, 2024
45cb330
suggestions
arr00 Aug 22, 2024
ff25d10
Iterate following discussion with Tally
Amxx Sep 9, 2024
dfc7a17
up
Amxx Sep 9, 2024
e5f4f53
update + more testing
Amxx Sep 9, 2024
2510af2
fix tests
Amxx Sep 9, 2024
9ecbb13
rename VoteCast event to OverrideVoteCast on override vote
Oct 10, 2024
74aff19
use `_tallyUpdated` when vote tally is updated
arr00 Oct 10, 2024
24bf708
rename contracts
arr00 Oct 14, 2024
428723c
fix lint
arr00 Oct 14, 2024
d2e815a
remove `.only`
arr00 Oct 14, 2024
ae5e042
suggestion
arr00 Oct 14, 2024
fe3ea67
fix tests
arr00 Oct 14, 2024
90f4177
test override vote by sig
arr00 Oct 14, 2024
2acf074
add docs
arr00 Oct 14, 2024
3d30f11
Merge branch 'master' into feat/delegate-override-vote
arr00 Oct 14, 2024
e6c1f01
additional tests
arr00 Oct 15, 2024
f0b4aa1
add changesets
arr00 Oct 15, 2024
dfcb745
Update README.adoc
Amxx Oct 16, 2024
14eb39b
refactor to minimize diff
Amxx Oct 16, 2024
614576e
Rename `GovernorAlreadyCastVoteOverride` to `GovernorAlreadyOverriden…
arr00 Oct 16, 2024
93c668d
Update .changeset/pink-wasps-hammer.md
arr00 Oct 16, 2024
99bfb73
Update contracts/governance/Governor.sol
arr00 Oct 16, 2024
ca6feb3
Rename `VotesAdditionalCheckpoints` to `VotesExtended`
arr00 Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
additional tests
  • Loading branch information
arr00 committed Oct 15, 2024
commit e6c1f012a201a67eb2fa99f5a44272c7b1f6e174
74 changes: 64 additions & 10 deletions test/governance/extensions/GovernorCountingOverridable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,75 @@ describe('GovernorCountingOverridable', function () {
.withArgs(this.voter1.address);
});

it('override vote with EOA sig', async function () {
const nonce = await this.mock.nonces(this.voter1);
it('can not vote twice', async function () {
await expect(this.mock.connect(this.voter1).castVote(this.helper.id, VoteType.Against));
await expect(this.mock.connect(this.voter1).castVote(this.helper.id, VoteType.Abstain))
.to.be.revertedWithCustomError(this.mock, 'GovernorAlreadyCastVote')
.withArgs(this.voter1.address);
});

describe('invalid vote type', function () {
it('override vote', async function () {
await expect(
this.mock.connect(this.voter1).castOverrideVote(this.helper.id, 3, ''),
).to.be.revertedWithCustomError(this.mock, 'GovernorInvalidVoteType');
});

it('traditional vote', async function () {
await expect(this.mock.connect(this.voter1).castVote(this.helper.id, 3)).to.be.revertedWithCustomError(
this.mock,
'GovernorInvalidVoteType',
);
});
});

describe('by signature', function () {
it('EOA signature', async function () {
const nonce = await this.mock.nonces(this.voter1);

await expect(
this.helper.overrideVote({
support: VoteType.For,
voter: this.voter1.address,
nonce,
signature: signBallot(this.voter1),
}),
)
.to.emit(this.mock, 'OverrideVoteCast')
.withArgs(this.voter1, this.helper.id, VoteType.For, ethers.parseEther('10'), '');

expect(await this.mock.hasVotedOverride(this.proposal.id, this.voter1)).to.be.true;
});

it('revert if signature does not match signer', async function () {
const nonce = await this.mock.nonces(this.voter1);

await expect(
this.helper.overrideVote({
const voteParams = {
support: VoteType.For,
voter: this.voter1.address,
voter: this.voter2.address,
nonce,
signature: signBallot(this.voter1),
}),
)
.to.emit(this.mock, 'OverrideVoteCast')
.withArgs(this.voter1, this.helper.id, VoteType.For, ethers.parseEther('10'), '');
};

await expect(this.helper.overrideVote(voteParams))
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidSignature')
.withArgs(voteParams.voter);
});

it('revert if vote nonce is incorrect', async function () {
const nonce = await this.mock.nonces(this.voter1);

const voteParams = {
support: VoteType.For,
voter: this.voter1.address,
nonce: nonce + 1n,
signature: signBallot(this.voter1),
};

expect(await this.mock.hasVotedOverride(this.proposal.id, this.voter1)).to.be.true;
await expect(this.helper.overrideVote(voteParams))
.to.be.revertedWithCustomError(this.mock, 'GovernorInvalidSignature')
.withArgs(voteParams.voter);
});
});
});
});
Expand Down
Loading