|
1 | 1 | import { expect } from "chai"; |
2 | | -import { ethers } from "hardhat"; |
| 2 | +import { deployments, ethers } from "hardhat"; |
3 | 3 | import { BigNumber } from "ethers"; |
4 | 4 | import getContractAddress from "../../deploy-helpers/getContractAddress"; |
5 | 5 |
|
@@ -83,34 +83,65 @@ async function deployContracts(deployer) { |
83 | 83 | await disputeKit.deployed(); |
84 | 84 | let nonce; |
85 | 85 | nonce = await deployer.getTransactionCount(); |
86 | | - nonce += 1; |
| 86 | + nonce += 3; // SortitionModule is upgradeable, it deploys an implementation and a proxy |
87 | 87 | const KlerosCoreAddress = getContractAddress(deployer.address, nonce); |
88 | 88 |
|
89 | | - const sortitionModuleFactory = await ethers.getContractFactory("SortitionModule", deployer); |
90 | | - const sortitionModule = await sortitionModuleFactory.deploy( |
91 | | - deployer.address, |
92 | | - KlerosCoreAddress, |
93 | | - 120, |
94 | | - 120, |
95 | | - rng.address, |
96 | | - LOOKAHEAD |
97 | | - ); // minStakingTime, maxFreezingTime |
98 | | - |
99 | | - const klerosCoreFactory = await ethers.getContractFactory("KlerosCore", { |
100 | | - signer: deployer, |
| 89 | + const sortitionModuleDeployment = await deployments.deploy("SortitionModule_DisputeKitClassic", { |
| 90 | + contract: "SortitionModule", |
| 91 | + from: deployer.address, |
| 92 | + proxy: { |
| 93 | + proxyContract: "UUPSProxy", |
| 94 | + proxyArgs: ["{implementation}", "{data}"], |
| 95 | + execute: { |
| 96 | + init: { |
| 97 | + methodName: "initialize", |
| 98 | + args: [deployer.address, KlerosCoreAddress, 120, 120, rng.address, LOOKAHEAD], // minStakingTime, maxFreezingTime |
| 99 | + }, |
| 100 | + onUpgrade: { |
| 101 | + methodName: "governor", |
| 102 | + args: [], |
| 103 | + }, |
| 104 | + }, |
| 105 | + }, |
| 106 | + log: true, |
| 107 | + args: [], |
101 | 108 | }); |
102 | | - const core = await klerosCoreFactory.deploy( |
103 | | - deployer.address, |
104 | | - ethers.constants.AddressZero, // should be an ERC20 |
105 | | - ethers.constants.AddressZero, // should be a Juror Prosecution module |
106 | | - disputeKit.address, |
107 | | - false, |
108 | | - [200, 10000, 100, 3], |
109 | | - [0, 0, 0, 0], |
110 | | - 0xfa, |
111 | | - sortitionModule.address |
112 | | - ); |
113 | | - await core.deployed(); |
| 109 | + |
| 110 | + const sortitionModule = await ethers.getContractAt("SortitionModule", sortitionModuleDeployment.address); |
| 111 | + |
| 112 | + const coreDeployment = await deployments.deploy("KlerosCore_DisputeKitClassic", { |
| 113 | + contract: "KlerosCore", |
| 114 | + from: deployer.address, |
| 115 | + proxy: { |
| 116 | + proxyContract: "UUPSProxy", |
| 117 | + proxyArgs: ["{implementation}", "{data}"], |
| 118 | + checkProxyAdmin: false, |
| 119 | + checkABIConflict: false, |
| 120 | + execute: { |
| 121 | + init: { |
| 122 | + methodName: "initialize", |
| 123 | + args: [ |
| 124 | + deployer.address, |
| 125 | + ethers.constants.AddressZero, // should be an ERC20 |
| 126 | + ethers.constants.AddressZero, // should be a Juror Prosecution module |
| 127 | + disputeKit.address, |
| 128 | + false, |
| 129 | + [200, 10000, 100, 3], |
| 130 | + [0, 0, 0, 0], |
| 131 | + "0xfa", |
| 132 | + sortitionModule.address, |
| 133 | + ], |
| 134 | + }, |
| 135 | + onUpgrade: { |
| 136 | + methodName: "governor", |
| 137 | + args: [], |
| 138 | + }, |
| 139 | + }, |
| 140 | + }, |
| 141 | + args: [], |
| 142 | + log: true, |
| 143 | + }); |
| 144 | + const core = await ethers.getContractAt("KlerosCore", coreDeployment.address); |
114 | 145 |
|
115 | 146 | await disputeKit.changeCore(core.address); |
116 | 147 |
|
|
0 commit comments