1
1
import { HardhatRuntimeEnvironment } from "hardhat/types" ;
2
2
import { DeployFunction } from "hardhat-deploy/types" ;
3
- import { BigNumber , BigNumberish } from "ethers" ;
4
3
import { deployUpgradable } from "./utils/deployUpgradable" ;
5
4
import { HomeChains , isSkipped } from "./utils" ;
6
5
import { deployERC20AndFaucet } from "./utils/deployTokens" ;
7
- import { KlerosCore } from "../typechain-types" ;
6
+ import { KlerosCore , KlerosCoreRuler } from "../typechain-types" ;
8
7
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy" ;
8
+ import { changeCurrencyRate } from "./utils/klerosCoreHelper" ;
9
9
10
10
const deployArbitration : DeployFunction = async ( hre : HardhatRuntimeEnvironment ) => {
11
- const { ethers , deployments, getNamedAccounts, getChainId } = hre ;
11
+ const { deployments, getNamedAccounts, getChainId } = hre ;
12
12
const { deploy } = deployments ;
13
13
14
14
// fallback to hardhat node signers on local network
@@ -22,40 +22,23 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
22
22
23
23
const minStake = 0 ;
24
24
const alpha = 10000 ;
25
- const feeForJuror = BigNumber . from ( 10 ) . pow ( 17 ) ;
25
+ const feeForJuror = 10n ** 17n ;
26
26
const jurorsForCourtJump = 16 ;
27
- const klerosCore = await deployUpgradable ( deployments , "KlerosCoreRuler" , {
27
+ await deployUpgradable ( deployments , "KlerosCoreRuler" , {
28
28
from : deployer ,
29
29
args : [
30
30
deployer , // governor
31
- pnk . address ,
31
+ pnk . target ,
32
32
[ minStake , alpha , feeForJuror , jurorsForCourtJump ] ,
33
33
] ,
34
34
log : true ,
35
35
} ) ;
36
-
37
- const changeCurrencyRate = async (
38
- erc20 : string ,
39
- accepted : boolean ,
40
- rateInEth : BigNumberish ,
41
- rateDecimals : BigNumberish
42
- ) => {
43
- const core = ( await ethers . getContract ( "KlerosCoreRuler" ) ) as KlerosCore ;
44
- const pnkRate = await core . currencyRates ( erc20 ) ;
45
- if ( pnkRate . feePaymentAccepted !== accepted ) {
46
- console . log ( `core.changeAcceptedFeeTokens(${ erc20 } , ${ accepted } )` ) ;
47
- await core . changeAcceptedFeeTokens ( erc20 , accepted ) ;
48
- }
49
- if ( ! pnkRate . rateInEth . eq ( rateInEth ) || pnkRate . rateDecimals !== rateDecimals ) {
50
- console . log ( `core.changeCurrencyRates(${ erc20 } , ${ rateInEth } , ${ rateDecimals } )` ) ;
51
- await core . changeCurrencyRates ( erc20 , rateInEth , rateDecimals ) ;
52
- }
53
- } ;
36
+ const core = ( await hre . ethers . getContract ( "KlerosCoreRuler" ) ) as KlerosCoreRuler ;
54
37
55
38
try {
56
- await changeCurrencyRate ( pnk . address , true , 12225583 , 12 ) ;
57
- await changeCurrencyRate ( dai . address , true , 60327783 , 11 ) ;
58
- await changeCurrencyRate ( weth . address , true , 1 , 1 ) ;
39
+ await changeCurrencyRate ( core , await pnk . getAddress ( ) , true , 12225583 , 12 ) ;
40
+ await changeCurrencyRate ( core , await dai . getAddress ( ) , true , 60327783 , 11 ) ;
41
+ await changeCurrencyRate ( core , await weth . getAddress ( ) , true , 1 , 1 ) ;
59
42
} catch ( e ) {
60
43
console . error ( "failed to change currency rates:" , e ) ;
61
44
}
@@ -68,7 +51,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
68
51
69
52
await deploy ( "DisputeResolverRuler" , {
70
53
from : deployer ,
71
- args : [ klerosCore . address , disputeTemplateRegistry . address ] ,
54
+ args : [ core . target , disputeTemplateRegistry . target ] ,
72
55
log : true ,
73
56
} ) ;
74
57
} ;
0 commit comments