Skip to content

Commit 9badc57

Browse files
committed
chore: deploy scripts
1 parent 13a8931 commit 9badc57

15 files changed

+73
-75
lines changed

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

Lines changed: 8 additions & 9 deletions
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
@@ -44,7 +43,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
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-university.ts

Lines changed: 8 additions & 9 deletions
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,9 +71,9 @@ 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) {
7978
console.error("failed to change currency rates:", e);
8079
}
@@ -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

Lines changed: 9 additions & 10 deletions
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

Lines changed: 2 additions & 7 deletions
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

Lines changed: 4 additions & 4 deletions
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",

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { parseUnits } from "ethers/lib/utils";
1+
import { parseUnits } from "ethers";
2+
import { BigNumber } from "@ethersproject/bignumber";
23
import { HardhatRuntimeEnvironment, HttpNetworkConfig } from "hardhat/types";
34
import { DeployFunction } from "hardhat-deploy/types";
45
import { getContractAddress } from "./utils/getContractAddress";
56
import { KlerosCore__factory } from "../typechain-types";
67
import { Courts, ForeignChains, isSkipped } from "./utils";
78
import { deployUpgradable } from "./utils/deployUpgradable";
89

9-
const ONE_GWEI = parseUnits("1", "gwei");
10+
const ONE_GWEI = BigNumber.from(parseUnits("1", "gwei"));
1011

1112
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1213
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
1314
const { deploy, execute } = deployments;
14-
const { hexZeroPad, hexlify } = ethers.utils;
15+
const { zeroPadValue, toBeHex } = ethers;
1516

1617
// fallback to hardhat node signers on local network
1718
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
@@ -22,7 +23,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2223
// TODO: use deterministic deployments
2324
const network = config.networks[hre.network.name];
2425
const homeNetwork = config.networks[network.companionNetworks.home] as HttpNetworkConfig;
25-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetwork.url);
26+
const homeChainProvider = new ethers.JsonRpcProvider(homeNetwork.url);
2627
let nonce = await homeChainProvider.getTransactionCount(deployer);
2728
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.
2829
const homeGatewayAddress = getContractAddress(deployer, nonce); // HomeGateway deploy tx will be the next tx home network
@@ -32,7 +33,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
3233
console.log("using VeaOutboxArbToGnosisDevnet at %s", veaOutbox.address);
3334

3435
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
35-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
36+
const homeChainIdAsBytes32 = zeroPadValue(toBeHex(homeChainId), 32);
3637
await deployUpgradable(deployments, "ForeignGatewayOnGnosis", {
3738
from: deployer,
3839
contract: "ForeignGateway",

contracts/deploy/02-home-gateway-to-ethereum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3232
veaInbox.address,
3333
foreignChainId,
3434
foreignGateway.address,
35-
ethers.constants.AddressZero, // feeToken is ETH
35+
ethers.ZeroAddress, // feeToken is ETH
3636
],
3737
log: true,
3838
}); // nonce+0

contracts/deploy/03-vea-mock.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { deployUpgradable } from "./utils/deployUpgradable";
1111
const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1212
const { ethers, deployments, getNamedAccounts } = hre;
1313
const { deploy, execute } = deployments;
14-
const { hexZeroPad, hexlify } = ethers.utils;
14+
const { zeroPadValue, toBeHex } = ethers;
1515

1616
// fallback to hardhat node signers on local network
1717
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
@@ -29,7 +29,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2929
const homeGatewayAddress = getContractAddress(deployer, nonce);
3030
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
3131

32-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(HardhatChain.HARDHAT), 32);
32+
const homeChainIdAsBytes32 = zeroPadValue(toBeHex(HardhatChain.HARDHAT), 32);
3333
const foreignGateway = await deployUpgradable(deployments, "ForeignGatewayOnEthereum", {
3434
from: deployer,
3535
contract: "ForeignGateway",
@@ -48,7 +48,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
4848
vea.address,
4949
HardhatChain.HARDHAT,
5050
foreignGateway.address,
51-
ethers.constants.AddressZero, // feeToken
51+
ethers.ZeroAddress, // feeToken
5252
],
5353
gasLimit: 4000000,
5454
log: true,
@@ -80,7 +80,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8080
"disputeTemplateMapping: TODO",
8181
extraData,
8282
disputeTemplateRegistry.address,
83-
ethers.constants.AddressZero,
83+
ethers.ZeroAddress,
8484
],
8585
log: true,
8686
});

contracts/deploy/04-foreign-arbitrable.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { parseUnits } from "ethers/lib/utils";
3+
import { parseUnits } from "ethers";
44
import disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
55
import { ForeignChains, isSkipped } from "./utils";
6+
import { BigNumber } from "@ethersproject/bignumber";
67

78
const foreignGatewayArtifactByChain = new Map<ForeignChains, string>([
89
[ForeignChains.ETHEREUM_MAINNET, "ForeignGatewayOnEthereum"],
@@ -11,7 +12,7 @@ const foreignGatewayArtifactByChain = new Map<ForeignChains, string>([
1112
[ForeignChains.GNOSIS_CHIADO, "ForeignGatewayOnGnosis"],
1213
]);
1314

14-
const ONE_GWEI = parseUnits("1", "gwei");
15+
const ONE_GWEI = BigNumber.from(parseUnits("1", "gwei"));
1516

1617
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1718
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
@@ -22,7 +23,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2223
const chainId = Number(await getChainId());
2324
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
2425

25-
const foreignGatewayArtifact = foreignGatewayArtifactByChain.get(chainId) ?? ethers.constants.AddressZero;
26+
const foreignGatewayArtifact = foreignGatewayArtifactByChain.get(chainId) ?? ethers.ZeroAddress;
2627
const foreignGateway = await deployments.get(foreignGatewayArtifact);
2728
console.log("using foreign gateway: %s", foreignGatewayArtifact);
2829

contracts/deploy/04-klerosliquid-to-v2-gnosis.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { parseUnits, parseEther } from "ethers/lib/utils";
1+
import { parseUnits, parseEther } from "ethers";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
44
import disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
55
import { ForeignChains, isSkipped } from "./utils";
6+
import { BigNumber } from "@ethersproject/bignumber";
67

78
const wrappedPNKByChain = new Map<ForeignChains, string>([
89
[ForeignChains.GNOSIS_MAINNET, "0xcb3231aBA3b451343e0Fddfc45883c842f223846"],
910
]);
1011

11-
const ONE_GWEI = parseUnits("1", "gwei");
12+
const ONE_GWEI = BigNumber.from(parseUnits("1", "gwei"));
1213

1314
const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1415
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
@@ -40,7 +41,7 @@ const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment
4041
}
4142

4243
const wPnkAddress = wrappedPNKByChain.get(ForeignChains[ForeignChains[chainId]]);
43-
const rng = ethers.constants.AddressZero;
44+
const rng = ethers.ZeroAddress;
4445
const minStakingTime = 99999999;
4546
const maxFreezingTime = 0;
4647
const minStake = parseEther("9999999");

0 commit comments

Comments
 (0)