@@ -3,69 +3,127 @@ import { DeployFunction } from "hardhat-deploy/types";
33import { getContractAddress } from "./utils/getContractAddress" ;
44import { deployUpgradable } from "./utils/deployUpgradable" ;
55import { changeCurrencyRate } from "./utils/klerosCoreHelper" ;
6- import { HomeChains , isSkipped , isDevnet , PNK , ETH , ONE_MINUTE_IN_SECONDS } from "./utils" ;
7- import { getContractOrDeploy , getContractOrDeployUpgradable } from "./utils/getContractOrDeploy" ;
6+ import {
7+ HomeChains ,
8+ isSkipped ,
9+ isDevnet ,
10+ PNK ,
11+ ETH ,
12+ ONE_MINUTE_IN_SECONDS ,
13+ } from "./utils" ;
14+ import {
15+ getContractOrDeploy ,
16+ getContractOrDeployUpgradable ,
17+ } from "./utils/getContractOrDeploy" ;
818import { deployERC20AndFaucet , deployERC721 } from "./utils/deployTokens" ;
9- import { DisputeKitClassic , KlerosCore , RatesConverter , RNGWithFallback } from "../typechain-types" ;
19+ import {
20+ DisputeKitClassic ,
21+ KlerosCore ,
22+ RatesConverter ,
23+ RNGWithFallback ,
24+ } from "../typechain-types" ;
1025
11- const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
26+ const deployArbitration : DeployFunction = async (
27+ hre : HardhatRuntimeEnvironment ,
28+ ) => {
1229 const { ethers, deployments, getNamedAccounts, getChainId } = hre ;
1330 const { deploy } = deployments ;
1431 const { ZeroAddress } = hre . ethers ;
1532
1633 // fallback to hardhat node signers on local network
17- const deployer = ( await getNamedAccounts ( ) ) . deployer ?? ( await hre . ethers . getSigners ( ) ) [ 0 ] . address ;
34+ const deployer =
35+ ( await getNamedAccounts ( ) ) . deployer ??
36+ ( await hre . ethers . getSigners ( ) ) [ 0 ] . address ;
1837 const chainId = Number ( await getChainId ( ) ) ;
19- console . log ( "deploying to %s with deployer %s" , HomeChains [ chainId ] , deployer ) ;
38+ console . log (
39+ "deploying to %s with deployer %s" ,
40+ HomeChains [ chainId ] ,
41+ deployer ,
42+ ) ;
2043
2144 const pnk = await deployERC20AndFaucet ( hre , deployer , "PNK" ) ;
2245 const weth = await deployERC20AndFaucet ( hre , deployer , "WETH" ) ;
23- const nft = await deployERC721 ( hre , deployer , "Kleros V2 Neo Early User" , "KlerosV2NeoEarlyUser" ) ;
46+ const nft = await deployERC721 (
47+ hre ,
48+ deployer ,
49+ "Kleros V2 Neo Early User" ,
50+ "KlerosV2NeoEarlyUser" ,
51+ ) ;
2452
25- const ratesConverter = await getContractOrDeploy < RatesConverter > ( hre , "RatesConverter" , {
53+ const ratesConverter = await getContractOrDeploy < RatesConverter > (
54+ hre ,
55+ "RatesConverter" ,
56+ {
57+ from : deployer ,
58+ args : [ ] ,
59+ log : true ,
60+ } ,
61+ ) ;
62+
63+ await getContractOrDeploy ( hre , "TransactionBatcher" , {
2664 from : deployer ,
2765 args : [ ] ,
2866 log : true ,
2967 } ) ;
3068
31- await getContractOrDeploy ( hre , "TransactionBatcher" , { from : deployer , args : [ ] , log : true } ) ;
32-
33- await deployUpgradable ( deployments , "PolicyRegistry" , { from : deployer , args : [ deployer ] , log : true } ) ;
69+ await deployUpgradable ( deployments , "PolicyRegistry" , {
70+ from : deployer ,
71+ args : [ deployer ] ,
72+ log : true ,
73+ } ) ;
3474
35- await deployUpgradable ( deployments , "EvidenceModule" , { from : deployer , args : [ deployer ] , log : true } ) ;
75+ await deployUpgradable ( deployments , "EvidenceModule" , {
76+ from : deployer ,
77+ args : [ deployer ] ,
78+ log : true ,
79+ } ) ;
3680
37- const classicDisputeKitID = 1 ; // Classic DK
3881 const disputeKit = await deployUpgradable ( deployments , "DisputeKitClassic" , {
3982 from : deployer ,
4083 args : [ deployer , ZeroAddress , weth . target ] ,
4184 log : true ,
4285 } ) ;
4386
44- let klerosCoreAddress = await deployments . getOrNull ( "KlerosCore" ) . then ( ( deployment ) => deployment ?. address ) ;
87+ let klerosCoreAddress = await deployments
88+ . getOrNull ( "KlerosCore" )
89+ . then ( ( deployment ) => deployment ?. address ) ;
4590 if ( ! klerosCoreAddress ) {
4691 const nonce = await ethers . provider . getTransactionCount ( deployer ) ;
4792 klerosCoreAddress = getContractAddress ( deployer , nonce + 3 ) ; // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
48- console . log ( "calculated future KlerosCore address for nonce %d: %s" , nonce + 3 , klerosCoreAddress ) ;
93+ console . log (
94+ "calculated future KlerosCore address for nonce %d: %s" ,
95+ nonce + 3 ,
96+ klerosCoreAddress ,
97+ ) ;
4998 }
5099 const devnet = isDevnet ( hre . network ) ;
51- const minStakingTime = devnet ? 3 * ONE_MINUTE_IN_SECONDS : 30 * ONE_MINUTE_IN_SECONDS ;
52- const maxFreezingTime = devnet ? 10 * ONE_MINUTE_IN_SECONDS : 30 * ONE_MINUTE_IN_SECONDS ;
53- const rngWithFallback = await ethers . getContract < RNGWithFallback > ( "RNGWithFallback" ) ;
100+ const minStakingTime = devnet
101+ ? 3 * ONE_MINUTE_IN_SECONDS
102+ : 30 * ONE_MINUTE_IN_SECONDS ;
103+ const maxFreezingTime = devnet
104+ ? 10 * ONE_MINUTE_IN_SECONDS
105+ : 30 * ONE_MINUTE_IN_SECONDS ;
106+ const rngWithFallback =
107+ await ethers . getContract < RNGWithFallback > ( "RNGWithFallback" ) ;
54108 const maxStakePerJuror = PNK ( 2_000 ) ;
55109 const maxTotalStaked = PNK ( 2_000_000 ) ;
56- const sortitionModule = await deployUpgradable ( deployments , "SortitionModule" , {
57- from : deployer ,
58- args : [
59- deployer ,
60- klerosCoreAddress ,
61- minStakingTime ,
62- maxFreezingTime ,
63- rngWithFallback . target ,
64- maxStakePerJuror ,
65- maxTotalStaked ,
66- ] ,
67- log : true ,
68- } ) ; // nonce (implementation), nonce+1 (proxy)
110+ const sortitionModule = await deployUpgradable (
111+ deployments ,
112+ "SortitionModule" ,
113+ {
114+ from : deployer ,
115+ args : [
116+ deployer ,
117+ klerosCoreAddress ,
118+ minStakingTime ,
119+ maxFreezingTime ,
120+ rngWithFallback . target ,
121+ maxStakePerJuror ,
122+ maxTotalStaked ,
123+ ] ,
124+ log : true ,
125+ } ,
126+ ) ; // nonce (implementation), nonce+1 (proxy)
69127
70128 const minStake = PNK ( 200 ) ;
71129 const alpha = 10000 ;
@@ -92,7 +150,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
92150 } ) ; // nonce+2 (implementation), nonce+3 (proxy)
93151
94152 // disputeKit.changeCore() only if necessary
95- const disputeKitContract = await hre . ethers . getContract < DisputeKitClassic > ( "DisputeKitClassic" ) ;
153+ const disputeKitContract =
154+ await hre . ethers . getContract < DisputeKitClassic > ( "DisputeKitClassic" ) ;
96155 const currentCore = await disputeKitContract . core ( ) ;
97156 if ( currentCore !== klerosCore . address ) {
98157 console . log ( `disputeKit.changeCore(${ klerosCore . address } )` ) ;
@@ -108,16 +167,27 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
108167
109168 const core = await hre . ethers . getContract < KlerosCore > ( "KlerosCore" ) ;
110169 try {
111- await changeCurrencyRate ( core , ratesConverter , await weth . getAddress ( ) , true , 1 , 1 ) ;
170+ await changeCurrencyRate (
171+ core ,
172+ ratesConverter ,
173+ await weth . getAddress ( ) ,
174+ true ,
175+ 1 ,
176+ 1 ,
177+ ) ;
112178 } catch ( e ) {
113179 console . error ( "failed to change currency rates:" , e ) ;
114180 }
115181
116- const disputeTemplateRegistry = await getContractOrDeployUpgradable ( hre , "DisputeTemplateRegistry" , {
117- from : deployer ,
118- args : [ deployer ] ,
119- log : true ,
120- } ) ;
182+ const disputeTemplateRegistry = await getContractOrDeployUpgradable (
183+ hre ,
184+ "DisputeTemplateRegistry" ,
185+ {
186+ from : deployer ,
187+ args : [ deployer ] ,
188+ log : true ,
189+ } ,
190+ ) ;
121191
122192 const resolver = await deploy ( "DisputeResolver" , {
123193 from : deployer ,
@@ -130,29 +200,38 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
130200 await core . changeArbitrableWhitelist ( resolver . address , true ) ;
131201
132202 // Extra dispute kits
133- const disputeKitShutter = await deployUpgradable ( deployments , "DisputeKitShutter" , {
134- from : deployer ,
135- args : [ deployer , core . target , weth . target ] ,
136- log : true ,
137- } ) ;
203+ const disputeKitShutter = await deployUpgradable (
204+ deployments ,
205+ "DisputeKitShutter" ,
206+ {
207+ from : deployer ,
208+ args : [ deployer , core . target , weth . target ] ,
209+ log : true ,
210+ } ,
211+ ) ;
138212 await core . addNewDisputeKit ( disputeKitShutter . address ) ;
139- const disputeKitShutterID = ( await core . getDisputeKitsLength ( ) ) - 1n ;
140213
141- const disputeKitGated = await deployUpgradable ( deployments , "DisputeKitGated" , {
142- from : deployer ,
143- args : [ deployer , core . target , weth . target ] ,
144- log : true ,
145- } ) ;
214+ const disputeKitGated = await deployUpgradable (
215+ deployments ,
216+ "DisputeKitGated" ,
217+ {
218+ from : deployer ,
219+ args : [ deployer , core . target , weth . target ] ,
220+ log : true ,
221+ } ,
222+ ) ;
146223 await core . addNewDisputeKit ( disputeKitGated . address ) ;
147- const disputeKitGatedID = ( await core . getDisputeKitsLength ( ) ) - 1n ;
148224
149- const disputeKitGatedShutter = await deployUpgradable ( deployments , "DisputeKitGatedShutter" , {
150- from : deployer ,
151- args : [ deployer , core . target , weth . target ] , // TODO: jump to a Shutter DK instead of a Classic one?
152- log : true ,
153- } ) ;
225+ const disputeKitGatedShutter = await deployUpgradable (
226+ deployments ,
227+ "DisputeKitGatedShutter" ,
228+ {
229+ from : deployer ,
230+ args : [ deployer , core . target , weth . target ] , // TODO: jump to a Shutter DK instead of a Classic one?
231+ log : true ,
232+ } ,
233+ ) ;
154234 await core . addNewDisputeKit ( disputeKitGatedShutter . address ) ;
155- const disputeKitGatedShutterID = ( await core . getDisputeKitsLength ( ) ) - 1n ;
156235
157236 // Snapshot proxy
158237 await getContractOrDeploy ( hre , "KlerosCoreSnapshotProxy" , {
0 commit comments