-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path00-home-chain-arbitration.ts
104 lines (91 loc) · 3.08 KB
/
00-home-chain-arbitration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { BigNumber } from "ethers";
enum HomeChains {
ARBITRUM_ONE = 42161,
ARBITRUM_RINKEBY = 421611,
ARBITRUM_GOERLI = 421613,
HARDHAT = 31337,
}
const pnkByChain = new Map<HomeChains, string>([
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
[HomeChains.ARBITRUM_RINKEBY, "0x364530164a2338cdba211f72c1438eb811b5c639"],
[HomeChains.ARBITRUM_GOERLI, "0x4DEeeFD054434bf6721eF39Aa18EfB3fd0D12610"],
]);
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy, execute } = deployments;
const { AddressZero } = hre.ethers.constants;
// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
await deploy("PolicyRegistry", {
from: deployer,
args: [deployer],
log: true,
});
const rng = await deploy("IncrementalNG", {
from: deployer,
args: [67193503189],
log: true,
});
const disputeKit = await deploy("DisputeKitClassic", {
from: deployer,
args: [deployer, AddressZero, rng.address],
log: true,
});
const sortitionSumTreeLibrary = await deploy("SortitionSumTreeFactory", {
from: deployer,
log: true,
});
if (chainId === HomeChains.HARDHAT) {
pnkByChain.set(
HomeChains.HARDHAT,
(
await deploy("PNK", {
from: deployer,
log: true,
})
).address
);
}
const pnk = pnkByChain.get(Number(await getChainId())) ?? AddressZero;
const minStake = BigNumber.from(10).pow(20).mul(2);
const alpha = 10000;
const feeForJuror = BigNumber.from(10).pow(17);
const klerosCore = await deploy("KlerosCore", {
from: deployer,
libraries: {
SortitionSumTreeFactory: sortitionSumTreeLibrary.address,
},
args: [
deployer,
pnk,
AddressZero,
disputeKit.address,
[120, 120], // minStakingTime, maxFreezingTime
false,
[minStake, alpha, feeForJuror, 3], // minStake, alpha, feeForJuror, jurorsForCourtJump
[0, 0, 0, 0], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
3,
],
log: true,
});
// execute DisputeKitClassic.changeCore() only if necessary
const currentCore = await hre.ethers.getContractAt("DisputeKitClassic", disputeKit.address).then((dk) => dk.core());
if (currentCore !== klerosCore.address) {
await execute("DisputeKitClassic", { from: deployer, log: true }, "changeCore", klerosCore.address);
}
await deploy("DisputeResolver", {
from: deployer,
args: [klerosCore.address],
log: true,
});
};
deployArbitration.tags = ["HomeChain", "Arbitration"];
deployArbitration.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !HomeChains[chainId];
};
export default deployArbitration;