Skip to content

Commit 3b864e0

Browse files
authored
Merge pull request #1620 from kleros/chore(hardhat)/hardhat-ether-version-update
Chore(hardhat)/hardhat ether version update
2 parents c3599ac + 8c91784 commit 3b864e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1518
-1814
lines changed

.github/workflows/contracts-testing.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Harden Runner
27-
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
27+
uses: step-security/harden-runner@v2.10.1
2828
with:
2929
disable-sudo: true
3030
egress-policy: block
@@ -40,14 +40,14 @@ jobs:
4040
54.185.253.63:443
4141
4242
- name: Setup Node.js environment
43-
uses: actions/setup-node@2a017f350dbf6c4b6bb4508cc83809719115162e
43+
uses: actions/setup-node@v4
4444
with:
4545
node-version: 18.x
4646

47-
- uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
47+
- uses: actions/checkout@v4
4848

4949
- name: Cache node modules
50-
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
50+
uses: actions/cache@v4
5151
env:
5252
cache-name: cache-node-modules
5353
with:
@@ -74,11 +74,11 @@ jobs:
7474

7575
- name: Test with coverage
7676
run: |
77-
yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\" --show-stack-traces
77+
yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles './test/**/*.ts' --show-stack-traces
7878
working-directory: contracts
7979

8080
- name: Upload a build artifact
81-
uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05
81+
uses: actions/upload-artifact@v4
8282
with:
8383
name: code-coverage-report
8484
path: contracts/coverage

contracts/deploy/00-home-chain-arbitration-neo.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { BigNumber, BigNumberish } from "ethers";
43
import { getContractAddress } from "./utils/getContractAddress";
54
import { deployUpgradable } from "./utils/deployUpgradable";
65
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
@@ -12,7 +11,7 @@ import { DisputeKitClassic, KlerosCoreNeo } from "../typechain-types";
1211
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1312
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
1413
const { deploy, execute } = deployments;
15-
const { AddressZero } = hre.ethers.constants;
14+
const { ZeroAddress } = hre.ethers;
1615
const RNG_LOOKAHEAD = 20;
1716

1817
// fallback to hardhat node signers on local network
@@ -37,14 +36,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3736

3837
const rng = await deployUpgradable(deployments, "RandomizerRNG", {
3938
from: deployer,
40-
args: [randomizerOracle.address, deployer],
39+
args: [randomizerOracle.target, deployer],
4140
log: true,
4241
});
4342

4443
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
4544
from: deployer,
4645
contract: "DisputeKitClassic",
47-
args: [deployer, AddressZero],
46+
args: [deployer, ZeroAddress],
4847
log: true,
4948
});
5049

@@ -83,15 +82,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8382
args: [
8483
deployer,
8584
deployer,
86-
pnk.address,
87-
AddressZero,
85+
pnk.target,
86+
ZeroAddress,
8887
disputeKit.address,
8988
false,
9089
[minStake, alpha, feeForJuror, jurorsForCourtJump],
9190
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
92-
ethers.utils.hexlify(5), // Extra data for sortition module will return the default value of K
91+
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
9392
sortitionModule.address,
94-
nft.address,
93+
nft.target,
9594
],
9695
log: true,
9796
}); // nonce+2 (implementation), nonce+3 (proxy)
@@ -106,7 +105,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
106105

107106
const core = (await hre.ethers.getContract("KlerosCoreNeo")) as KlerosCoreNeo;
108107
try {
109-
await changeCurrencyRate(core, weth.address, true, 1, 1);
108+
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
110109
} catch (e) {
111110
console.error("failed to change currency rates:", e);
112111
}
@@ -120,7 +119,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
120119
const resolver = await deploy("DisputeResolverNeo", {
121120
from: deployer,
122121
contract: "DisputeResolver",
123-
args: [core.address, disputeTemplateRegistry.address],
122+
args: [core.target, disputeTemplateRegistry.target],
124123
log: true,
125124
});
126125

contracts/deploy/00-home-chain-arbitration-ruler.ts

+11-28
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { BigNumber, BigNumberish } from "ethers";
43
import { deployUpgradable } from "./utils/deployUpgradable";
54
import { HomeChains, isSkipped } from "./utils";
65
import { deployERC20AndFaucet } from "./utils/deployTokens";
7-
import { KlerosCore } from "../typechain-types";
6+
import { KlerosCore, KlerosCoreRuler } from "../typechain-types";
87
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
8+
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
99

1010
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
11-
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
11+
const { deployments, getNamedAccounts, getChainId } = hre;
1212
const { deploy } = deployments;
1313

1414
// fallback to hardhat node signers on local network
@@ -22,40 +22,23 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2222

2323
const minStake = 0;
2424
const alpha = 10000;
25-
const feeForJuror = BigNumber.from(10).pow(17);
25+
const feeForJuror = 10n ** 17n;
2626
const jurorsForCourtJump = 16;
27-
const klerosCore = await deployUpgradable(deployments, "KlerosCoreRuler", {
27+
await deployUpgradable(deployments, "KlerosCoreRuler", {
2828
from: deployer,
2929
args: [
3030
deployer, // governor
31-
pnk.address,
31+
pnk.target,
3232
[minStake, alpha, feeForJuror, jurorsForCourtJump],
3333
],
3434
log: true,
3535
});
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;
5437

5538
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);
5942
} catch (e) {
6043
console.error("failed to change currency rates:", e);
6144
}
@@ -68,7 +51,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6851

6952
await deploy("DisputeResolverRuler", {
7053
from: deployer,
71-
args: [klerosCore.address, disputeTemplateRegistry.address],
54+
args: [core.target, disputeTemplateRegistry.target],
7255
log: true,
7356
});
7457
};

contracts/deploy/00-home-chain-arbitration-university.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { BigNumber, BigNumberish } from "ethers";
43
import { getContractAddress } from "./utils/getContractAddress";
54
import { deployUpgradable } from "./utils/deployUpgradable";
65
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
@@ -12,7 +11,7 @@ import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
1211
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1312
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
1413
const { deploy } = deployments;
15-
const { AddressZero } = hre.ethers.constants;
14+
const { ZeroAddress } = hre.ethers;
1615

1716
// fallback to hardhat node signers on local network
1817
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
@@ -26,7 +25,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2625
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicUniversity", {
2726
from: deployer,
2827
contract: "DisputeKitClassic",
29-
args: [deployer, AddressZero],
28+
args: [deployer, ZeroAddress],
3029
log: true,
3130
});
3231

@@ -51,8 +50,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5150
args: [
5251
deployer, // governor
5352
deployer, // instructor
54-
pnk.address,
55-
AddressZero,
53+
pnk.target,
54+
ZeroAddress,
5655
disputeKit.address,
5756
false,
5857
[minStake, alpha, feeForJuror, jurorsForCourtJump],
@@ -72,11 +71,11 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7271

7372
const core = (await hre.ethers.getContract("KlerosCoreUniversity")) as KlerosCoreUniversity;
7473
try {
75-
await changeCurrencyRate(core, pnk.address, true, 12225583, 12);
76-
await changeCurrencyRate(core, dai.address, true, 60327783, 11);
77-
await changeCurrencyRate(core, weth.address, true, 1, 1);
74+
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
75+
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);
76+
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
7877
} catch (e) {
79-
console.error("failed to change currency rates:", e);
78+
console.error("Failed to change currency rates for token, with error:", e);
8079
}
8180

8281
const disputeTemplateRegistry = await getContractOrDeployUpgradable(hre, "DisputeTemplateRegistry", {
@@ -88,7 +87,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8887
await deploy("DisputeResolverUniversity", {
8988
from: deployer,
9089
contract: "DisputeResolver",
91-
args: [core.address, disputeTemplateRegistry.address],
90+
args: [core.target, disputeTemplateRegistry.target],
9291
log: true,
9392
});
9493
};

contracts/deploy/00-home-chain-arbitration.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { BigNumber, BigNumberish } from "ethers";
43
import { getContractAddress } from "./utils/getContractAddress";
54
import { deployUpgradable } from "./utils/deployUpgradable";
65
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
@@ -11,7 +10,7 @@ import { DisputeKitClassic, KlerosCore } from "../typechain-types";
1110

1211
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1312
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
14-
const { AddressZero } = hre.ethers.constants;
13+
const { ZeroAddress } = hre.ethers;
1514
const RNG_LOOKAHEAD = 20;
1615

1716
// fallback to hardhat node signers on local network
@@ -36,13 +35,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3635

3736
const rng = await deployUpgradable(deployments, "RandomizerRNG", {
3837
from: deployer,
39-
args: [randomizerOracle.address, deployer],
38+
args: [randomizerOracle.target, deployer],
4039
log: true,
4140
});
4241

4342
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
4443
from: deployer,
45-
args: [deployer, AddressZero],
44+
args: [deployer, ZeroAddress],
4645
log: true,
4746
});
4847

@@ -70,13 +69,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7069
args: [
7170
deployer,
7271
deployer,
73-
pnk.address,
74-
AddressZero,
72+
pnk.target,
73+
ZeroAddress,
7574
disputeKit.address,
7675
false,
7776
[minStake, alpha, feeForJuror, jurorsForCourtJump],
7877
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
79-
ethers.utils.hexlify(5), // Extra data for sortition module will return the default value of K
78+
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
8079
sortitionModule.address,
8180
],
8281
log: true,
@@ -92,9 +91,9 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
9291

9392
const core = (await hre.ethers.getContract("KlerosCore")) as KlerosCore;
9493
try {
95-
await changeCurrencyRate(core, pnk.address, true, 12225583, 12);
96-
await changeCurrencyRate(core, dai.address, true, 60327783, 11);
97-
await changeCurrencyRate(core, weth.address, true, 1, 1);
94+
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
95+
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);
96+
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
9897
} catch (e) {
9998
console.error("failed to change currency rates:", e);
10099
}

contracts/deploy/00-home-chain-pnk-faucet.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const pnkByChain = new Map<HomeChains, string>([
88
]);
99

1010
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
11-
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
11+
const { deployments, getNamedAccounts, getChainId } = hre;
1212
const { deploy, execute } = deployments;
1313

1414
// fallback to hardhat node signers on local network
@@ -24,12 +24,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2424
args: [pnkAddress],
2525
log: true,
2626
});
27-
await execute(
28-
"PNKFaucet",
29-
{ from: deployer, log: true },
30-
"changeAmount",
31-
hre.ethers.utils.parseUnits("10000", "ether")
32-
);
27+
await execute("PNKFaucet", { from: deployer, log: true }, "changeAmount", hre.ethers.parseUnits("10000", "ether"));
3328
}
3429
};
3530

contracts/deploy/01-foreign-gateway-on-ethereum.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { deployUpgradable } from "./utils/deployUpgradable";
77

88
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
99
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
10-
const { deploy, execute } = deployments;
11-
const { hexZeroPad, hexlify } = ethers.utils;
10+
const { execute } = deployments;
11+
const { zeroPadValue, toBeHex } = ethers;
1212

1313
// fallback to hardhat node signers on local network
1414
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
@@ -19,7 +19,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
1919
// TODO: use deterministic deployments
2020
const network = config.networks[hre.network.name];
2121
const homeNetwork = config.networks[network.companionNetworks.home] as HttpNetworkConfig;
22-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetwork.url);
22+
const homeChainProvider = new ethers.JsonRpcProvider(homeNetwork.url);
2323
let nonce = await homeChainProvider.getTransactionCount(deployer);
2424
nonce += 1; // HomeGatewayToEthereum Proxy deploy tx will be the 2nd tx after this on its home network, so we add 1 to the current nonce.
2525
const homeGatewayAddress = getContractAddress(deployer, nonce);
@@ -29,7 +29,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2929
console.log("using VeaOutboxArbToEthDevnet at %s", veaOutbox.address);
3030

3131
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
32-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
32+
const homeChainIdAsBytes32 = zeroPadValue(toBeHex(homeChainId), 32);
3333
await deployUpgradable(deployments, "ForeignGatewayOnEthereum", {
3434
from: deployer,
3535
contract: "ForeignGateway",

0 commit comments

Comments
 (0)