@@ -3,10 +3,10 @@ import { DeployFunction } from "hardhat-deploy/types";
3
3
import { getContractAddress } from "./utils/getContractAddress" ;
4
4
import { deployUpgradable } from "./utils/deployUpgradable" ;
5
5
import { changeCurrencyRate } from "./utils/klerosCoreHelper" ;
6
- import { HomeChains , isSkipped , isDevnet , isMainnet , PNK , ETH } from "./utils" ;
6
+ import { HomeChains , isSkipped , isDevnet , PNK , ETH } from "./utils" ;
7
7
import { getContractOrDeploy , getContractOrDeployUpgradable } from "./utils/getContractOrDeploy" ;
8
8
import { deployERC20AndFaucet } from "./utils/deployTokens" ;
9
- import { DisputeKitClassic , KlerosCore } from "../typechain-types" ;
9
+ import { ChainlinkRNG , DisputeKitClassic , KlerosCore } from "../typechain-types" ;
10
10
11
11
const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
12
12
const { ethers, deployments, getNamedAccounts, getChainId } = hre ;
@@ -28,30 +28,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
28
28
29
29
await getContractOrDeployUpgradable ( hre , "EvidenceModule" , { from : deployer , args : [ deployer ] , log : true } ) ;
30
30
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
-
55
31
const disputeKit = await deployUpgradable ( deployments , "DisputeKitClassic" , {
56
32
from : deployer ,
57
33
args : [ deployer , ZeroAddress ] ,
@@ -67,6 +43,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
67
43
const devnet = isDevnet ( hre . network ) ;
68
44
const minStakingTime = devnet ? 180 : 1800 ;
69
45
const maxFreezingTime = devnet ? 600 : 1800 ;
46
+ const rng = ( await ethers . getContract ( "ChainlinkRNG" ) ) as ChainlinkRNG ;
70
47
const sortitionModule = await deployUpgradable ( deployments , "SortitionModule" , {
71
48
from : deployer ,
72
49
args : [ deployer , klerosCoreAddress , minStakingTime , maxFreezingTime , rng . target , RNG_LOOKAHEAD ] ,
@@ -83,7 +60,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
83
60
deployer ,
84
61
deployer ,
85
62
pnk . target ,
86
- ZeroAddress ,
63
+ ZeroAddress , // KlerosCore is configured later
87
64
disputeKit . address ,
88
65
false ,
89
66
[ minStake , alpha , feeForJuror , jurorsForCourtJump ] ,
@@ -94,14 +71,21 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
94
71
log : true ,
95
72
} ) ; // nonce+2 (implementation), nonce+3 (proxy)
96
73
97
- // changeCore() only if necessary
74
+ // disputeKit. changeCore() only if necessary
98
75
const disputeKitContract = ( await ethers . getContract ( "DisputeKitClassic" ) ) as DisputeKitClassic ;
99
76
const currentCore = await disputeKitContract . core ( ) ;
100
77
if ( currentCore !== klerosCore . address ) {
101
78
console . log ( `disputeKit.changeCore(${ klerosCore . address } )` ) ;
102
79
await disputeKitContract . changeCore ( klerosCore . address ) ;
103
80
}
104
81
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
+
105
89
const core = ( await hre . ethers . getContract ( "KlerosCore" ) ) as KlerosCore ;
106
90
try {
107
91
await changeCurrencyRate ( core , await pnk . getAddress ( ) , true , 12225583 , 12 ) ;
@@ -113,6 +97,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
113
97
} ;
114
98
115
99
deployArbitration . tags = [ "Arbitration" ] ;
100
+ deployArbitration . dependencies = [ "ChainlinkRNG" ] ;
116
101
deployArbitration . skip = async ( { network } ) => {
117
102
return isSkipped ( network , ! HomeChains [ network . config . chainId ?? 0 ] ) ;
118
103
} ;
0 commit comments