Skip to content

Commit 46838e7

Browse files
committed
chore: changeArbitrator script
1 parent 7f9c439 commit 46838e7

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

contracts/hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import "hardhat-deploy-ethers";
1111
import "hardhat-watcher";
1212
import "hardhat-docgen";
1313
require("./scripts/setDisputeTemplate");
14+
require("./scripts/changeArbitrator");
1415
// import "hardhat-contract-sizer"; // prevents hardhat-deploy from finding chalk...
1516
// import "hardhat-tracer"; // prevents hardhat-deploy from finding chalk...
1617

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { task } from "hardhat/config";
2+
import { HardhatRuntimeEnvironment } from "hardhat/types";
3+
import { IDisputeTemplateRegistry } from "@kleros/kleros-v2-contracts";
4+
5+
task("getDisputeTemplate", "Gets a dispute template by ID")
6+
.addPositionalParam("templateId", "The ID of the template to query")
7+
.setAction(async function ({ templateId }: { templateId: string }, hre: HardhatRuntimeEnvironment) {
8+
const { ethers } = hre;
9+
10+
// Get the contract instance
11+
const disputeTemplateRegistry = await ethers.getContract<IDisputeTemplateRegistry>("DisputeTemplateRegistry");
12+
13+
// Query the events
14+
const filter = disputeTemplateRegistry.filters.DisputeTemplate(BigInt(templateId));
15+
const events = await disputeTemplateRegistry.queryFilter(filter);
16+
17+
if (events.length === 0) {
18+
console.log(`No template found with ID ${templateId}`);
19+
return;
20+
}
21+
22+
// Process events synchronously
23+
for (const event of events) {
24+
console.log("\nTemplate Details:");
25+
console.log("----------------");
26+
console.log(`Template ID: ${event.args._templateId}`);
27+
console.log(`Template Tag: ${event.args._templateTag}`);
28+
console.log(`Template Data: ${event.args._templateData}`);
29+
console.log(`Template Data Mappings: ${event.args._templateDataMappings}`);
30+
console.log(`Block Number: ${event.blockNumber}`);
31+
console.log(`Transaction Hash: ${event.transactionHash}`);
32+
}
33+
});

contracts/scripts/setDisputeTemplate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ task("set-dispute-template", "Sets the dispute template").setAction(async (args,
1818
};
1919

2020
// Update the master copy of CurateV2
21+
console.log("Updating the CurateV2 master copy...");
2122
const curateMaster = await ethers.getContract<CurateV2>("CurateV2");
2223
await changeTemplates(curateMaster);
2324

0 commit comments

Comments
 (0)