Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "hardhat-deploy-ethers";
import "hardhat-watcher";
import "hardhat-docgen";
require("./scripts/setDisputeTemplate");
require("./scripts/changeArbitrator");
// import "hardhat-contract-sizer"; // prevents hardhat-deploy from finding chalk...
// import "hardhat-tracer"; // prevents hardhat-deploy from finding chalk...

Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@
},
"dependencies": {
"@kleros/curate-v2-templates": "workspace:^",
"@kleros/kleros-v2-contracts": "^0.9.3"
"@kleros/kleros-v2-contracts": "^0.10.0"
}
}
58 changes: 58 additions & 0 deletions contracts/scripts/changeArbitrator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { task } from "hardhat/config";
import { CurateFactory, CurateV2 } from "../typechain-types";
import { DeploymentName, getContractsEthers } from "@kleros/kleros-v2-contracts";

const NETWORK_TO_DEPLOYMENT: Record<string, DeploymentName> = {
arbitrumSepoliaDevnet: "devnet",
arbitrumSepolia: "testnet",
arbitrum: "mainnetNeo",
} as const;

task("change-arbitrator", "Changes the arbitrator").setAction(async (args, hre) => {
const { ethers, deployments } = hre;
const deployer = await ethers.getSigners().then((signers) => signers[0].getAddress());
const networkName = deployments.getNetworkName();
const deploymentName = NETWORK_TO_DEPLOYMENT[networkName];
const { klerosCore, evidence } = await getContractsEthers(ethers.provider, deploymentName);

const changeArbitrator = async (curate: CurateV2) => {
const extraData = await curate.getArbitratorExtraData();
console.log("Changing the arbitrator for", curate.target);
console.log("klerosCore.target", klerosCore.target);
console.log("extraData", extraData);
console.log("evidence.target", evidence.target);
const tx = await curate
.changeArbitrationParams(klerosCore.target, extraData, evidence.target)
.then((tx) => tx.wait());
console.log("Arbitration params changed", tx?.hash);
};

// Update the master copy of CurateV2
console.log("Updating the CurateV2 master copy...");
const curateMaster = await ethers.getContract<CurateV2>("CurateV2");
await changeArbitrator(curateMaster);

// Update every curated lists created by the factory
const factory = await ethers.getContract<CurateFactory>("CurateFactory");
const events = await factory.queryFilter(factory.filters.NewList(), 0, "latest");
console.log(`Found ${events.length} NewList events:`);
for (let i = 0; i < events.length; i++) {
const event = events[i];
const curate = await ethers.getContractAtWithSignerAddress<CurateV2>("CurateV2", event.args._address, deployer);
const governor = await curate.governor();
console.log(
`${i + 1}. List address: ${
curate.target
}, governor: ${governor}, templateIdRegistration: ${await curate.templateIdRegistration()}, templateIdRemoval: ${await curate.templateIdRemoval()}`
);

if (deployer.toLowerCase() !== governor.toLowerCase()) {
console.log(`Skipping curate ${curate.target} - signer ${deployer} is not the governor ${governor}`);
continue;
}

await changeArbitrator(curate);
}

hre.run("set-dispute-template");
});
33 changes: 33 additions & 0 deletions contracts/scripts/getDisputeTemplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { IDisputeTemplateRegistry } from "@kleros/kleros-v2-contracts";

task("getDisputeTemplate", "Gets a dispute template by ID")
.addPositionalParam("templateId", "The ID of the template to query")
.setAction(async function ({ templateId }: { templateId: string }, hre: HardhatRuntimeEnvironment) {
const { ethers } = hre;

// Get the contract instance
const disputeTemplateRegistry = await ethers.getContract<IDisputeTemplateRegistry>("DisputeTemplateRegistry");

// Query the events
const filter = disputeTemplateRegistry.filters.DisputeTemplate(BigInt(templateId));
const events = await disputeTemplateRegistry.queryFilter(filter);

if (events.length === 0) {
console.log(`No template found with ID ${templateId}`);
return;
}

// Process events synchronously
for (const event of events) {
console.log("\nTemplate Details:");
console.log("----------------");
console.log(`Template ID: ${event.args._templateId}`);
console.log(`Template Tag: ${event.args._templateTag}`);
console.log(`Template Data: ${event.args._templateData}`);
console.log(`Template Data Mappings: ${event.args._templateDataMappings}`);
console.log(`Block Number: ${event.blockNumber}`);
console.log(`Transaction Hash: ${event.transactionHash}`);
}
});
1 change: 1 addition & 0 deletions contracts/scripts/setDisputeTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ task("set-dispute-template", "Sets the dispute template").setAction(async (args,
};

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

Expand Down
2 changes: 1 addition & 1 deletion templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const sharedTemplateProperties = `
"arbitrableChainID": "421614",
"arbitrableAddress": "{{arbitrableAddress}}",
"arbitratorChainID": "421614",
"arbitratorAddress": "0x4838e31E0ea315232c431598110FE677cAF2D6E6",
"arbitratorAddress": "0x1Bd44c4a4511DbFa7DC1d5BC201635596E7200f9",
"metadata": {
"itemName": "{{itemName}}",
"itemDescription": "{{itemDescription}}",
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/client-preset": "^4.2.0",
"@kleros/curate-v2-tsconfig": "workspace:^",
"@kleros/kleros-v2-contracts": "^0.9.3",
"@kleros/kleros-v2-contracts": "^0.10.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-modal": "^3.16.3",
Expand Down
Loading