Delegate override vote (#5192)

Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
This commit is contained in:
Hadrien Croubois
2024-10-18 14:17:20 +02:00
committed by GitHub
parent 0034c30224
commit 378914ceab
15 changed files with 924 additions and 22 deletions

View File

@ -32,6 +32,13 @@ module.exports = mapValues(
reason: 'string',
params: 'bytes',
},
OverrideBallot: {
proposalId: 'uint256',
support: 'uint8',
voter: 'address',
nonce: 'uint256',
reason: 'string',
},
Delegation: {
delegatee: 'address',
nonce: 'uint256',

View File

@ -128,6 +128,23 @@ class GovernorHelper {
return await this.governor[method](...args);
}
async overrideVote(vote = {}) {
let method = 'castOverrideVote';
let args = [this.id, vote.support];
vote.reason = vote.reason ?? '';
if (vote.signature) {
let message = this.forgeMessage(vote);
message.reason = message.reason ?? '';
const sign = await vote.signature(this.governor, message);
method = 'castOverrideVoteBySig';
args.push(vote.voter, vote.reason ?? '', sign);
}
return await this.governor[method](...args);
}
/// Clock helpers
async waitForSnapshot(offset = 0n) {
const timepoint = await this.governor.proposalSnapshot(this.id);