@@ -7,6 +7,8 @@ import courtsV2ArbitrumTestnet from "../config/courts.v2.testnet.json";
7
7
import courtsV2ArbitrumDevnet from "../config/courts.v2.devnet.json" ;
8
8
import courtsV2MainnetNeo from "../config/courts.v2.mainnet-neo.json" ;
9
9
import { isDevnet } from "../deploy/utils" ;
10
+ import { execute } from "./utils/execution" ;
11
+ import { getContracts , Cores } from "./utils/contracts" ;
10
12
11
13
enum HomeChains {
12
14
ARBITRUM_ONE = 42161 ,
@@ -22,12 +24,6 @@ enum Sources {
22
24
V2_MAINNET_NEO ,
23
25
}
24
26
25
- enum Cores {
26
- BASE ,
27
- NEO ,
28
- UNIVERSITY ,
29
- }
30
-
31
27
type Court = {
32
28
id : number ;
33
29
parent : number ;
@@ -57,11 +53,7 @@ task("populate:courts", "Populates the courts and their parameters")
57
53
undefined ,
58
54
types . int
59
55
)
60
- . addOptionalParam (
61
- "coreType" ,
62
- "The type of core to use between base, neo, university (default: base)" ,
63
- Cores . BASE . toString ( )
64
- )
56
+ . addOptionalParam ( "coreType" , "The type of core to use between base, neo, university (default: base)" , Cores . BASE )
65
57
. addFlag ( "reverse" , "Iterates the courts in reverse order, useful to increase minStake in the child courts first" )
66
58
. addFlag ( "forceV1ParametersToDev" , "Use development values for the v1 courts parameters" )
67
59
. setAction ( async ( taskArgs , hre ) => {
@@ -90,13 +82,12 @@ task("populate:courts", "Populates the courts and their parameters")
90
82
}
91
83
console . log ( "Populating from source %s" , Sources [ from ] ) ;
92
84
93
- let coreType = Cores . BASE ;
94
- coreType = Cores [ taskArgs . coreType . toUpperCase ( ) as keyof typeof Cores ] ;
85
+ const coreType = Cores [ taskArgs . coreType . toUpperCase ( ) as keyof typeof Cores ] ;
95
86
if ( coreType === undefined ) {
96
87
console . error ( "Invalid core type, must be one of base, neo, university" ) ;
97
88
return ;
98
89
}
99
- console . log ( "Using core type %s" , Cores [ coreType ] ) ;
90
+ console . log ( "Using core type %s" , coreType ) ;
100
91
101
92
const truncateWei = ( x : bigint ) => ( x / TEN_THOUSAND_GWEI ) * TEN_THOUSAND_GWEI ;
102
93
@@ -163,21 +154,7 @@ task("populate:courts", "Populates the courts and their parameters")
163
154
164
155
console . log ( "courtsV2 = %O" , courtsV2 ) ;
165
156
166
- let core : KlerosCore | KlerosCoreNeo | KlerosCoreUniversity ;
167
- switch ( coreType ) {
168
- case Cores . UNIVERSITY :
169
- console . log ( "Using KlerosCoreUniversity" ) ;
170
- core = ( await ethers . getContract ( "KlerosCoreUniversity" ) ) as KlerosCoreUniversity ;
171
- break ;
172
- case Cores . NEO :
173
- console . log ( "Using KlerosCoreNeo" ) ;
174
- core = ( await ethers . getContract ( "KlerosCoreNeo" ) ) as KlerosCoreNeo ;
175
- break ;
176
- default :
177
- console . log ( "Using KlerosCore" ) ;
178
- core = ( await ethers . getContract ( "KlerosCore" ) ) as KlerosCore ;
179
- break ;
180
- }
157
+ const { core } = await getContracts ( hre , coreType ) ;
181
158
182
159
for ( const court of courtsV2 ) {
183
160
const courtPresent = await core . courts ( court . id ) . catch ( ( ) => { } ) ;
@@ -244,43 +221,49 @@ task("populate:courts", "Populates the courts and their parameters")
244
221
continue ;
245
222
}
246
223
try {
247
- await core . changeCourtParameters (
248
- court . id ,
249
- court . hiddenVotes ,
250
- court . minStake ,
251
- court . alpha ,
252
- court . feeForJuror ,
253
- court . jurorsForCourtJump ,
254
- [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ]
255
- ) ;
224
+ await core . changeCourtParameters
225
+ . populateTransaction (
226
+ court . id ,
227
+ court . hiddenVotes ,
228
+ court . minStake ,
229
+ court . alpha ,
230
+ court . feeForJuror ,
231
+ court . jurorsForCourtJump ,
232
+ [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ]
233
+ )
234
+ . then ( execute ) ;
256
235
} catch ( error ) {
257
236
console . error ( "Error changing court parameters: %s" , error ) ;
258
237
}
259
238
} else {
260
239
console . log ( "Court %d not found, creating it with" , court . id , court ) ;
261
240
if ( coreType === Cores . UNIVERSITY ) {
262
- await ( core as KlerosCoreUniversity ) . createCourt (
263
- court . parent ,
264
- court . hiddenVotes ,
265
- court . minStake ,
266
- court . alpha ,
267
- court . feeForJuror ,
268
- court . jurorsForCourtJump ,
269
- [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ] ,
270
- [ DISPUTE_KIT_CLASSIC ]
271
- ) ;
241
+ await ( core as KlerosCoreUniversity ) . createCourt
242
+ . populateTransaction (
243
+ court . parent ,
244
+ court . hiddenVotes ,
245
+ court . minStake ,
246
+ court . alpha ,
247
+ court . feeForJuror ,
248
+ court . jurorsForCourtJump ,
249
+ [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ] ,
250
+ [ DISPUTE_KIT_CLASSIC ]
251
+ )
252
+ . then ( execute ) ;
272
253
} else {
273
- await ( core as KlerosCore ) . createCourt (
274
- court . parent ,
275
- court . hiddenVotes ,
276
- court . minStake ,
277
- court . alpha ,
278
- court . feeForJuror ,
279
- court . jurorsForCourtJump ,
280
- [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ] ,
281
- ethers . toBeHex ( 5 ) , // Not accessible on-chain, but has always been set to the same value so far.
282
- [ DISPUTE_KIT_CLASSIC ]
283
- ) ;
254
+ await ( core as KlerosCore ) . createCourt
255
+ . populateTransaction (
256
+ court . parent ,
257
+ court . hiddenVotes ,
258
+ court . minStake ,
259
+ court . alpha ,
260
+ court . feeForJuror ,
261
+ court . jurorsForCourtJump ,
262
+ [ court . timesPerPeriod [ 0 ] , court . timesPerPeriod [ 1 ] , court . timesPerPeriod [ 2 ] , court . timesPerPeriod [ 3 ] ] ,
263
+ ethers . toBeHex ( 5 ) , // Not accessible on-chain, but has always been set to the same value so far.
264
+ [ DISPUTE_KIT_CLASSIC ]
265
+ )
266
+ . then ( execute ) ;
284
267
}
285
268
}
286
269
0 commit comments