-
Notifications
You must be signed in to change notification settings - Fork 47
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
Various contract scripts improvements #1853
Draft
jaybuidl
wants to merge
10
commits into
dev
Choose a base branch
from
chore/contract-scripts-improvements
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4e5bc87
chore: change governor script
jaybuidl 2bbb88f
fix: policy script, names
jaybuidl 4b3b100
fix: bad practice
jaybuidl ae8f482
chore: automated curation court config
jaybuidl e52bc67
chore: scripts handling of the governor being a contract
jaybuidl 708f000
chore: getDisputeTemplate task
jaybuidl 245f07d
chore: scripts support for KlerosCoreSnapshotProxy
jaybuidl ae5179c
feat: generate a tx batch file for the transaction builder Safe app
jaybuidl d11339d
fix: keeperBot handling of custom errors, use the getContracts() utility
jaybuidl b196265
chore: evidence period reduced for courtID 29
jaybuidl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { task } from "hardhat/config"; | ||
import { prompt, print } from "gluegun"; | ||
import { Cores, getContracts } from "./utils/contracts"; | ||
|
||
const { bold } = print.colors; | ||
|
||
task("change-governor", "Changes the governor for all the contracts") | ||
.addPositionalParam("newGovernor", "The address of the new governor") | ||
.addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE) | ||
.setAction(async (taskArgs, hre) => { | ||
const newGovernor = taskArgs.newGovernor; | ||
print.highlight(`💣 Changing governor to ${bold(newGovernor)}`); | ||
|
||
const { confirm } = await prompt.ask({ | ||
type: "confirm", | ||
name: "confirm", | ||
message: "Are you sure you want to proceed?", | ||
}); | ||
if (!confirm) { | ||
console.log("Operation cancelled by user."); | ||
return; | ||
} | ||
|
||
const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores]; | ||
if (coreType === undefined) { | ||
console.error("Invalid core type, must be one of base, neo, university"); | ||
return; | ||
} | ||
console.log("Using core type %s", coreType); | ||
|
||
const { | ||
core, | ||
disputeKitClassic, | ||
disputeResolver, | ||
disputeTemplateRegistry, | ||
policyRegistry, | ||
chainlinkRng, | ||
randomizerRng, | ||
snapshotProxy, | ||
} = await getContracts(hre, coreType); | ||
|
||
const updateGovernor = async (contractName: string, contractInstance: any) => { | ||
print.info(`Changing governor for ${contractName}`); | ||
|
||
const spinner = print.spin(`Executing transaction for ${contractName}...`); | ||
try { | ||
const tx = await contractInstance.changeGovernor(newGovernor); | ||
await tx.wait(); | ||
spinner.succeed(`Governor changed for ${contractName}, tx hash: ${tx.hash}`); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
spinner.fail(`Failed to change governor for ${contractName}: ${error.message}`); | ||
} else { | ||
spinner.fail(`Failed to change governor for ${contractName}: ${String(error)}`); | ||
} | ||
} | ||
}; | ||
|
||
// TODO: upgrade and add changeGovernor! | ||
// await updateGovernor("SortitionModule", sortition) | ||
|
||
await updateGovernor("KlerosCore", core); | ||
await updateGovernor("DisputeKitClassic", disputeKitClassic); | ||
await updateGovernor("DisputeResolver", disputeResolver); | ||
await updateGovernor("DisputeTemplateRegistry", disputeTemplateRegistry); | ||
await updateGovernor("PolicyRegistry", policyRegistry); | ||
await updateGovernor("KlerosCoreSnapshotProxy", snapshotProxy); | ||
if (chainlinkRng) await updateGovernor("ChainlinkRNG", chainlinkRng); | ||
if (randomizerRng) await updateGovernor("RandomizerRNG", randomizerRng); | ||
|
||
print.success("Governor changed successfully"); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance error handling and transaction validation.
The current implementation could be improved with better error handling and transaction receipt validation.
📝 Committable suggestion