@@ -7,6 +7,8 @@ import courtsV2ArbitrumTestnet from "../config/courts.v2.testnet.json";
77import courtsV2ArbitrumDevnet from "../config/courts.v2.devnet.json" ;
88import courtsV2MainnetNeo from "../config/courts.v2.mainnet-neo.json" ;
99import { isDevnet } from "../deploy/utils" ;
10+ import { execute } from "./utils/execution" ;
11+ import { getContracts , Cores } from "./utils/contracts" ;
1012
1113enum HomeChains {
1214 ARBITRUM_ONE = 42161 ,
@@ -22,12 +24,6 @@ enum Sources {
2224 V2_MAINNET_NEO ,
2325}
2426
25- enum Cores {
26- BASE ,
27- NEO ,
28- UNIVERSITY ,
29- }
30-
3127type Court = {
3228 id : number ;
3329 parent : number ;
@@ -57,11 +53,7 @@ task("populate:courts", "Populates the courts and their parameters")
5753 undefined ,
5854 types . int
5955 )
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 )
6557 . addFlag ( "reverse" , "Iterates the courts in reverse order, useful to increase minStake in the child courts first" )
6658 . addFlag ( "forceV1ParametersToDev" , "Use development values for the v1 courts parameters" )
6759 . setAction ( async ( taskArgs , hre ) => {
@@ -90,13 +82,12 @@ task("populate:courts", "Populates the courts and their parameters")
9082 }
9183 console . log ( "Populating from source %s" , Sources [ from ] ) ;
9284
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 ] ;
9586 if ( coreType === undefined ) {
9687 console . error ( "Invalid core type, must be one of base, neo, university" ) ;
9788 return ;
9889 }
99- console . log ( "Using core type %s" , Cores [ coreType ] ) ;
90+ console . log ( "Using core type %s" , coreType ) ;
10091
10192 const truncateWei = ( x : bigint ) => ( x / TEN_THOUSAND_GWEI ) * TEN_THOUSAND_GWEI ;
10293
@@ -163,21 +154,7 @@ task("populate:courts", "Populates the courts and their parameters")
163154
164155 console . log ( "courtsV2 = %O" , courtsV2 ) ;
165156
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 ) ;
181158
182159 for ( const court of courtsV2 ) {
183160 const courtPresent = await core . courts ( court . id ) . catch ( ( ) => { } ) ;
@@ -244,43 +221,49 @@ task("populate:courts", "Populates the courts and their parameters")
244221 continue ;
245222 }
246223 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 ) ;
256235 } catch ( error ) {
257236 console . error ( "Error changing court parameters: %s" , error ) ;
258237 }
259238 } else {
260239 console . log ( "Court %d not found, creating it with" , court . id , court ) ;
261240 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 ) ;
272253 } 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 ) ;
284267 }
285268 }
286269
0 commit comments