Add a public Governor.cancel function (#3983)

This commit is contained in:
Hadrien Croubois
2023-01-26 20:46:11 +01:00
committed by GitHub
parent 0320a718e8
commit 5e28952cbd
12 changed files with 157 additions and 63 deletions

View File

@ -62,14 +62,19 @@ class GovernorHelper {
);
}
cancel(opts = null) {
cancel(visibility = 'external', opts = null) {
const proposal = this.currentProposal;
return proposal.useCompatibilityInterface
? this.governor.methods['cancel(uint256)'](...concatOpts([proposal.id], opts))
: this.governor.methods['$_cancel(address[],uint256[],bytes[],bytes32)'](
switch (visibility) {
case 'external':
return this.governor.methods['cancel(uint256)'](...concatOpts([proposal.id], opts));
case 'internal':
return this.governor.methods['$_cancel(address[],uint256[],bytes[],bytes32)'](
...concatOpts(proposal.shortProposal, opts),
);
default:
throw new Error(`unsuported visibility "${visibility}"`);
}
}
vote(vote = {}, opts = null) {