@@ -3,10 +3,10 @@ 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 , isMainnet , PNK , ETH } from "./utils" ;
6+ import { HomeChains , isSkipped , isDevnet , PNK , ETH } from "./utils" ;
77import { getContractOrDeploy , getContractOrDeployUpgradable } from "./utils/getContractOrDeploy" ;
88import { deployERC20AndFaucet } from "./utils/deployTokens" ;
9- import { DisputeKitClassic , KlerosCore } from "../typechain-types" ;
9+ import { ChainlinkRNG , DisputeKitClassic , KlerosCore } from "../typechain-types" ;
1010
1111const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
1212 const { ethers, deployments, getNamedAccounts, getChainId } = hre ;
@@ -28,30 +28,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2828
2929 await getContractOrDeployUpgradable ( hre , "EvidenceModule" , { from : deployer , args : [ deployer ] , log : true } ) ;
3030
31- // Randomizer.ai: https://randomizer.ai/docs#addresses
32- const randomizerOracle = await getContractOrDeploy ( hre , "RandomizerOracle" , {
33- from : deployer ,
34- contract : "RandomizerMock" , // The mock is deployed only on the Hardhat network
35- args : [ ] ,
36- log : true ,
37- } ) ;
38-
39- const randomizerRng = await getContractOrDeployUpgradable ( hre , "RandomizerRNG" , {
40- from : deployer ,
41- args : [ randomizerOracle . target , deployer ] ,
42- log : true ,
43- } ) ;
44-
45- const blockhashRng = await getContractOrDeploy ( hre , "BlockHashRNG" , {
46- from : deployer ,
47- args : [ ] ,
48- log : true ,
49- } ) ;
50-
51- // RNG fallback on Arbitrum Sepolia because the Randomizer.ai oracle contract is unverified and not officially supported.
52- const rng = isMainnet ( hre . network ) ? randomizerRng : blockhashRng ;
53- console . log ( isMainnet ( hre . network ) ? "using RandomizerRNG on mainnet" : "using BlockHashRNG on testnet/devnet" ) ;
54-
5531 const disputeKit = await deployUpgradable ( deployments , "DisputeKitClassic" , {
5632 from : deployer ,
5733 args : [ deployer , ZeroAddress ] ,
@@ -67,6 +43,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6743 const devnet = isDevnet ( hre . network ) ;
6844 const minStakingTime = devnet ? 180 : 1800 ;
6945 const maxFreezingTime = devnet ? 600 : 1800 ;
46+ const rng = ( await ethers . getContract ( "ChainlinkRNG" ) ) as ChainlinkRNG ;
7047 const sortitionModule = await deployUpgradable ( deployments , "SortitionModule" , {
7148 from : deployer ,
7249 args : [ deployer , klerosCoreAddress , minStakingTime , maxFreezingTime , rng . target , RNG_LOOKAHEAD ] ,
@@ -83,7 +60,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8360 deployer ,
8461 deployer ,
8562 pnk . target ,
86- ZeroAddress ,
63+ ZeroAddress , // KlerosCore is configured later
8764 disputeKit . address ,
8865 false ,
8966 [ minStake , alpha , feeForJuror , jurorsForCourtJump ] ,
@@ -94,14 +71,21 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
9471 log : true ,
9572 } ) ; // nonce+2 (implementation), nonce+3 (proxy)
9673
97- // changeCore() only if necessary
74+ // disputeKit. changeCore() only if necessary
9875 const disputeKitContract = ( await ethers . getContract ( "DisputeKitClassic" ) ) as DisputeKitClassic ;
9976 const currentCore = await disputeKitContract . core ( ) ;
10077 if ( currentCore !== klerosCore . address ) {
10178 console . log ( `disputeKit.changeCore(${ klerosCore . address } )` ) ;
10279 await disputeKitContract . changeCore ( klerosCore . address ) ;
10380 }
10481
82+ // rng.changeSortitionModule() only if necessary
83+ const rngSortitionModule = await rng . sortitionModule ( ) ;
84+ if ( rngSortitionModule !== sortitionModule . address ) {
85+ console . log ( `rng.changeSortitionModule(${ sortitionModule . address } )` ) ;
86+ await rng . changeSortitionModule ( sortitionModule . address ) ;
87+ }
88+
10589 const core = ( await hre . ethers . getContract ( "KlerosCore" ) ) as KlerosCore ;
10690 try {
10791 await changeCurrencyRate ( core , await pnk . getAddress ( ) , true , 12225583 , 12 ) ;
@@ -113,6 +97,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
11397} ;
11498
11599deployArbitration . tags = [ "Arbitration" ] ;
100+ deployArbitration . dependencies = [ "ChainlinkRNG" ] ;
116101deployArbitration . skip = async ( { network } ) => {
117102 return isSkipped ( network , ! HomeChains [ network . config . chainId ?? 0 ] ) ;
118103} ;
0 commit comments