Skip to content

Commit e567a48

Browse files
committed
feat: deployment to arbitrum
1 parent 31765b2 commit e567a48

File tree

14 files changed

+2128
-149
lines changed

14 files changed

+2128
-149
lines changed

contracts/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ Smart contracts for the Escrow v2
66

77
Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh` or `./scripts/populateReadme.sh`.
88

9-
### Official Testnet
10-
#### Arbitrum Sepolia
9+
### Production
10+
#### Arbitrum One
1111

12+
- [EscrowUniversal](https://arbiscan.io/address/0x79530E7Bb3950A3a4b5a167816154715681F2f6c)
13+
- [EscrowView](https://arbiscan.io/address/0x3Fed94ee4FA1B5665DB84489f913E2c7e1290459)
1214

13-
#### Sepolia
15+
### Official Testnet
16+
#### Arbitrum Sepolia
1417

1518

1619
### Devnet
@@ -19,8 +22,6 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
1922
- [EscrowUniversal](https://sepolia.arbiscan.io/address/0x11aB737EDB1c6b181919a95ccD07c8DAA3e8E687)
2023
- [EscrowView](https://sepolia.arbiscan.io/address/0x7aea8849539a23b25E1681041308aA90175aF026)
2124

22-
#### Sepolia
23-
2425
## Getting Started
2526

2627
### Install the Dependencies

contracts/deploy/00-escrow.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,44 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { HomeChains, isSkipped } from "./utils";
44
import { EscrowUniversal } from "../typechain-types";
5+
import { getContracts } from "./utils/getContracts";
6+
7+
const config = {
8+
arbitrumSepoliaDevnet: {
9+
feeTimeout: 600, // 10 minutes
10+
settlementTimeout: 600, // 10 minutes
11+
jurors: 1,
12+
courtId: 1,
13+
},
14+
arbitrum: {
15+
feeTimeout: 302400, // 84 hours
16+
settlementTimeout: 172800, // 48 hours
17+
jurors: 3,
18+
courtId: 1,
19+
},
20+
};
521

622
const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7-
const { deployments, getNamedAccounts, getChainId, ethers } = hre;
23+
const { deployments, getNamedAccounts, getChainId, ethers, network } = hre;
824
const { deploy } = deployments;
925

1026
// fallback to hardhat node signers on local network
1127
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1228
const chainId = Number(await getChainId());
1329
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
1430

15-
const klerosCore = await deployments.get("KlerosCore");
16-
const disputeTemplateRegistry = await deployments.get("DisputeTemplateRegistry");
17-
const feeTimeout = 600; // 10 minutes
18-
const settlementTimeout = 600; // 10 minutes
19-
20-
// General court, 3 jurors
21-
const extraData = ethers.AbiCoder.defaultAbiCoder().encode(["uint96", "uint96"], [1, 3]);
31+
const { disputeTemplateRegistry, klerosCore } = await getContracts(hre);
32+
const { feeTimeout, settlementTimeout, jurors, courtId } = config[network.name];
33+
const extraData = ethers.AbiCoder.defaultAbiCoder().encode(["uint96", "uint96"], [courtId, jurors]);
2234

2335
await deploy("EscrowUniversal", {
2436
from: deployer,
2537
args: [
26-
klerosCore.address,
38+
klerosCore.target,
2739
extraData,
2840
"", // configured in the next step by setDisputeTemplate
2941
"", // configured in the next step by setDisputeTemplate
30-
disputeTemplateRegistry.address,
42+
disputeTemplateRegistry.target,
3143
feeTimeout,
3244
settlementTimeout,
3345
],
@@ -54,7 +66,6 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5466
gasLimit: 50000000,
5567
log: true,
5668
});
57-
5869
};
5970

6071
deploy.tags = ["Escrow"];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import {
3+
disputeTemplateRegistryConfig as devnetDtrConfig,
4+
klerosCoreConfig as devnetCoreConfig,
5+
} from "@kleros/kleros-v2-contracts/deployments/devnet.viem";
6+
import {
7+
disputeTemplateRegistryConfig as mainnetDtrConfig,
8+
klerosCoreNeoConfig as mainnetCoreConfig,
9+
} from "@kleros/kleros-v2-contracts/deployments/mainnet.viem";
10+
import {
11+
KlerosCore,
12+
DisputeTemplateRegistry__factory,
13+
KlerosCore__factory,
14+
KlerosCoreNeo__factory,
15+
KlerosCoreNeo,
16+
DisputeTemplateRegistry,
17+
} from "@kleros/kleros-v2-contracts/typechain-types";
18+
import { EscrowView, EscrowUniversal } from "../../typechain-types";
19+
20+
export const getContracts = async (hre: HardhatRuntimeEnvironment) => {
21+
const { getChainId, ethers, config } = hre;
22+
const chainId = Number(await getChainId());
23+
const escrow = await ethers.getContract<EscrowUniversal>("EscrowUniversal");
24+
const view = await ethers.getContract<EscrowView>("EscrowView");
25+
let disputeTemplateRegistry: DisputeTemplateRegistry;
26+
let klerosCore: KlerosCore | KlerosCoreNeo;
27+
switch (chainId) {
28+
case config.networks.arbitrum.chainId:
29+
disputeTemplateRegistry = DisputeTemplateRegistry__factory.connect(
30+
mainnetDtrConfig.address[chainId],
31+
ethers.provider
32+
);
33+
klerosCore = KlerosCoreNeo__factory.connect(mainnetCoreConfig.address[chainId], ethers.provider);
34+
break;
35+
case config.networks.arbitrumSepolia.chainId:
36+
disputeTemplateRegistry = DisputeTemplateRegistry__factory.connect(
37+
devnetDtrConfig.address[chainId],
38+
ethers.provider
39+
);
40+
klerosCore = KlerosCore__factory.connect(devnetCoreConfig.address[chainId], ethers.provider);
41+
break;
42+
default:
43+
throw new Error(`Unsupported chainId: ${chainId}`);
44+
}
45+
return { escrow, view, disputeTemplateRegistry, klerosCore };
46+
};

0 commit comments

Comments
 (0)