|
| 1 | +import { task } from "hardhat/config"; |
| 2 | +import { CurateFactory, CurateV2 } from "../typechain-types"; |
| 3 | +import { DeploymentName, getContractsEthers } from "@kleros/kleros-v2-contracts"; |
| 4 | + |
| 5 | +const NETWORK_TO_DEPLOYMENT: Record<string, DeploymentName> = { |
| 6 | + arbitrumSepoliaDevnet: "devnet", |
| 7 | + arbitrumSepolia: "testnet", |
| 8 | + arbitrum: "mainnetNeo", |
| 9 | +} as const; |
| 10 | + |
| 11 | +task("change-arbitrator", "Changes the arbitrator").setAction(async (args, hre) => { |
| 12 | + const { ethers, deployments } = hre; |
| 13 | + const deployer = await ethers.getSigners().then((signers) => signers[0].getAddress()); |
| 14 | + const networkName = deployments.getNetworkName(); |
| 15 | + const deploymentName = NETWORK_TO_DEPLOYMENT[networkName]; |
| 16 | + const { klerosCore, evidence } = await getContractsEthers(ethers.provider, deploymentName); |
| 17 | + |
| 18 | + const changeArbitrator = async (curate: CurateV2) => { |
| 19 | + const extraData = await curate.getArbitratorExtraData(); |
| 20 | + console.log("Changing the arbitrator for", curate.target); |
| 21 | + console.log("klerosCore.target", klerosCore.target); |
| 22 | + console.log("extraData", extraData); |
| 23 | + console.log("evidence.target", evidence.target); |
| 24 | + const tx = await curate |
| 25 | + .changeArbitrationParams(klerosCore.target, extraData, evidence.target) |
| 26 | + .then((tx) => tx.wait()); |
| 27 | + console.log("Arbitration params changed", tx?.hash); |
| 28 | + }; |
| 29 | + |
| 30 | + // Update the master copy of CurateV2 |
| 31 | + console.log("Updating the CurateV2 master copy..."); |
| 32 | + const curateMaster = await ethers.getContract<CurateV2>("CurateV2"); |
| 33 | + await changeArbitrator(curateMaster); |
| 34 | + |
| 35 | + // Update every curated lists created by the factory |
| 36 | + const factory = await ethers.getContract<CurateFactory>("CurateFactory"); |
| 37 | + const events = await factory.queryFilter(factory.filters.NewList(), 0, "latest"); |
| 38 | + console.log(`Found ${events.length} NewList events:`); |
| 39 | + for (let i = 0; i < events.length; i++) { |
| 40 | + const event = events[i]; |
| 41 | + const curate = await ethers.getContractAtWithSignerAddress<CurateV2>("CurateV2", event.args._address, deployer); |
| 42 | + const governor = await curate.governor(); |
| 43 | + console.log( |
| 44 | + `${i + 1}. List address: ${ |
| 45 | + curate.target |
| 46 | + }, governor: ${governor}, templateIdRegistration: ${await curate.templateIdRegistration()}, templateIdRemoval: ${await curate.templateIdRemoval()}` |
| 47 | + ); |
| 48 | + |
| 49 | + if (deployer.toLowerCase() !== governor.toLowerCase()) { |
| 50 | + console.log(`Skipping curate ${curate.target} - signer ${deployer} is not the governor ${governor}`); |
| 51 | + continue; |
| 52 | + } |
| 53 | + |
| 54 | + await changeArbitrator(curate); |
| 55 | + } |
| 56 | + |
| 57 | + hre.run("set-dispute-template"); |
| 58 | +}); |
0 commit comments