Skip to content

Commit d9adb8f

Browse files
committed
chore: deploy script to fix #1148
1 parent 7eb8634 commit d9adb8f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

contracts/deploy/fix1148.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { DisputeKitClassic, KlerosCore } from "../typechain-types";
4+
import assert from "node:assert";
5+
6+
enum HomeChains {
7+
ARBITRUM_ONE = 42161,
8+
ARBITRUM_GOERLI = 421613,
9+
HARDHAT = 31337,
10+
}
11+
12+
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
13+
const { deployments, getNamedAccounts, getChainId } = hre;
14+
const { deploy, execute } = deployments;
15+
const { AddressZero } = hre.ethers.constants;
16+
17+
// fallback to hardhat node signers on local network
18+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
19+
const chainId = Number(await getChainId());
20+
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
21+
22+
const oldDisputeKitId = 1;
23+
const newDisputeKitId = 2;
24+
25+
const klerosCore = (await hre.ethers.getContract("KlerosCore")) as KlerosCore;
26+
const oldDisputeKit = (await hre.ethers.getContract("DisputeKitClassic")) as DisputeKitClassic;
27+
28+
await deploy("DisputeKitClassic", {
29+
from: deployer,
30+
args: [deployer, AddressZero],
31+
log: true,
32+
});
33+
34+
const newDisputeKit = (await hre.ethers.getContract("DisputeKitClassic")) as DisputeKitClassic;
35+
36+
await execute("KlerosCore", { from: deployer, log: true }, "addNewDisputeKit", newDisputeKit.address, 0);
37+
38+
assert(
39+
await klerosCore.disputeKitNodes(oldDisputeKitId).then((node) => node.disputeKit === oldDisputeKit.address),
40+
`wrong dispute kit id ${oldDisputeKitId}`
41+
);
42+
assert(
43+
await klerosCore.disputeKitNodes(newDisputeKitId).then((node) => node.disputeKit === newDisputeKit.address),
44+
`wrong dispute kit id ${newDisputeKitId}`
45+
);
46+
47+
await execute("KlerosCore", { from: deployer, log: true }, "enableDisputeKits", 1, newDisputeKitId, true); // enable the new dispute kit
48+
await execute("KlerosCore", { from: deployer, log: true }, "enableDisputeKits", 1, oldDisputeKitId, false); // disable the old dispute kit
49+
};
50+
51+
deployArbitration.tags = ["Fix1148"];
52+
deployArbitration.skip = async ({ getChainId }) => {
53+
const chainId = Number(await getChainId());
54+
return !HomeChains[chainId];
55+
};
56+
57+
export default deployArbitration;

0 commit comments

Comments
 (0)