-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path04-foreign-arbitrable.ts
48 lines (40 loc) · 1.94 KB
/
04-foreign-arbitrable.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import disputeTemplate from "../config/DisputeTemplate.simple.json";
enum ForeignChains {
ETHEREUM_MAINNET = 1,
ETHEREUM_GOERLI = 5,
GNOSIS_MAINNET = 100,
GNOSIS_CHIADO = 10200,
}
const foreignGatewayArtifactByChain = new Map<ForeignChains, string>([
[ForeignChains.ETHEREUM_MAINNET, "ForeignGatewayOnEthereum"],
[ForeignChains.ETHEREUM_GOERLI, "ForeignGatewayOnEthereum"],
[ForeignChains.GNOSIS_MAINNET, "ForeignGatewayOnGnosis"],
[ForeignChains.GNOSIS_CHIADO, "ForeignGatewayOnGnosis"],
]);
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
const { deploy, execute } = deployments;
// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
const foreignGatewayArtifact = foreignGatewayArtifactByChain.get(chainId) ?? ethers.constants.AddressZero;
const foreignGateway = await deployments.get(foreignGatewayArtifact);
console.log("Using foreign gateway: %s", foreignGatewayArtifact);
const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const weth = await deployments.get("WETH");
await deploy("ArbitrableExample", {
from: deployer,
args: [foreignGateway.address, disputeTemplate, extraData, weth.address],
log: true,
});
};
deployForeignGateway.tags = ["ForeignArbitrable"];
deployForeignGateway.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !ForeignChains[chainId];
};
export default deployForeignGateway;