Skip to content

Commit 85354e9

Browse files
authored
Merge pull request #120 from kleros/dev
Release to Beta
2 parents 50076f9 + 0e73cf4 commit 85354e9

25 files changed

+4888
-275
lines changed

contracts/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
1919
### Devnet
2020
#### Arbitrum Sepolia
2121

22+
- [EscrowCustomBuyer](https://sepolia.arbiscan.io/address/0xA01e6B988aeDae1fD4a748D6bfBcB8A438601DeE)
2223
- [EscrowUniversal](https://sepolia.arbiscan.io/address/0x5ef185810BCe41c03c9E5ca271B8C91F1024F953)
2324
- [EscrowView](https://sepolia.arbiscan.io/address/0x6451046caB9291a919FCba045bf6Bb8E0Bb71467)
25+
- [EscrowViewCustomBuyer](https://sepolia.arbiscan.io/address/0xe0892815E8958f0ad6Dab876995987c4F439954D)
2426

2527
## Getting Started
2628

@@ -91,7 +93,8 @@ yarn hardhat node --tags nothing
9193
**Shell 2: the deploy script**
9294

9395
```bash
94-
yarn deploy --network localhost --tags Escrow>
96+
yarn deploy --network localhost --tags EscrowUniversal
97+
yarn deploy --network localhost --tags EscrowCustomBuyer
9598
```
9699

97100
#### 2. Deploy to a Public Network Fork
@@ -115,7 +118,8 @@ yarn deploy-testnet-fork
115118
#### 3. Deploy to Public Testnets
116119

117120
```bash
118-
yarn deploy --network arbitrumSepolia --tags Escrow
121+
yarn deploy --network arbitrumSepolia --tags EscrowUniversal
122+
yarn deploy --network arbitrumSepolia --tags EscrowCustomBuyer
119123
```
120124

121125
The deployed addresses should be displayed to the screen after the deployment is complete. If you missed them, you can always go to the `deployments/<network>` directory and look for the respective file.
@@ -129,7 +133,7 @@ Same steps as above but append `Devnet` to the `--network` parameter.
129133
**Shell 1: the node**
130134

131135
```bash
132-
yarn hardhat node --tags Escrow
136+
yarn hardhat node --tags EscrowUniversal
133137
```
134138

135139
**Shell 2: the test scripts**

contracts/README.md.template

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ yarn hardhat node --tags nothing
7777
**Shell 2: the deploy script**
7878

7979
```bash
80-
yarn deploy --network localhost --tags Escrow>
80+
yarn deploy --network localhost --tags EscrowUniversal
81+
yarn deploy --network localhost --tags EscrowCustomBuyer
8182
```
8283

8384
#### 2. Deploy to a Public Network Fork
@@ -101,7 +102,8 @@ yarn deploy-testnet-fork
101102
#### 3. Deploy to Public Testnets
102103

103104
```bash
104-
yarn deploy --network arbitrumSepolia --tags Escrow
105+
yarn deploy --network arbitrumSepolia --tags EscrowUniversal
106+
yarn deploy --network arbitrumSepolia --tags EscrowCustomBuyer
105107
```
106108

107109
The deployed addresses should be displayed to the screen after the deployment is complete. If you missed them, you can always go to the `deployments/<network>` directory and look for the respective file.
@@ -115,7 +117,7 @@ Same steps as above but append `Devnet` to the `--network` parameter.
115117
**Shell 1: the node**
116118

117119
```bash
118-
yarn hardhat node --tags Escrow
120+
yarn hardhat node --tags EscrowUniversal
119121
```
120122

121123
**Shell 2: the test scripts**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HomeChains, isSkipped } from "./utils";
4+
import deployEscrow from "./shared";
5+
6+
const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7+
await deployEscrow(hre, "customBuyer");
8+
};
9+
10+
deploy.tags = ["EscrowCustomBuyer"];
11+
deploy.skip = async ({ network }) => {
12+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
13+
};
14+
15+
export default deploy;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { HomeChains, isSkipped } from "./utils";
4+
import deployEscrow from "./shared";
5+
6+
const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7+
await deployEscrow(hre, "universal");
8+
};
9+
10+
deploy.tags = ["EscrowUniversal"];
11+
deploy.skip = async ({ network }) => {
12+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
13+
};
14+
15+
export default deploy;
Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,54 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
2-
import { DeployFunction } from "hardhat-deploy/types";
3-
import { HomeChains, isSkipped } from "./utils";
2+
import { HomeChains } from "./utils";
43
import { EscrowUniversal } from "../typechain-types";
54
import { getArbitratorContracts } from "./utils/getContracts";
65

7-
const config = {
6+
export type EscrowDeployment = {
7+
escrow: string;
8+
view: string;
9+
};
10+
11+
export type EscrowDeployments = {
12+
universal: EscrowDeployment;
13+
customBuyer?: EscrowDeployment;
14+
};
15+
16+
export const config = {
817
arbitrumSepoliaDevnet: {
918
feeTimeout: 600, // 10 minutes
1019
settlementTimeout: 600, // 10 minutes
1120
jurors: 1,
1221
courtId: 1,
22+
escrowDeployments: {
23+
universal: {
24+
escrow: "EscrowUniversal",
25+
view: "EscrowView",
26+
},
27+
customBuyer: {
28+
escrow: "EscrowCustomBuyer",
29+
view: "EscrowViewCustomBuyer",
30+
},
31+
} satisfies EscrowDeployments,
1332
},
1433
arbitrum: {
1534
feeTimeout: 302400, // 84 hours
1635
settlementTimeout: 172800, // 48 hours
1736
jurors: 3,
1837
courtId: 1,
38+
escrowDeployments: {
39+
universal: {
40+
escrow: "EscrowUniversal",
41+
view: "EscrowView",
42+
},
43+
customBuyer: undefined,
44+
} satisfies EscrowDeployments,
1945
},
2046
};
2147

22-
const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
48+
const deployEscrow = async (
49+
hre: HardhatRuntimeEnvironment,
50+
escrowDeployment: keyof EscrowDeployments
51+
) => {
2352
const { deployments, getNamedAccounts, getChainId, ethers, network } = hre;
2453
const { deploy } = deployments;
2554

@@ -29,10 +58,10 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2958
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
3059

3160
const { disputeTemplateRegistry, klerosCore } = await getArbitratorContracts(hre);
32-
const { feeTimeout, settlementTimeout, jurors, courtId } = config[network.name];
61+
const { feeTimeout, settlementTimeout, jurors, courtId, escrowDeployments } = config[network.name];
3362
const extraData = ethers.AbiCoder.defaultAbiCoder().encode(["uint96", "uint96"], [courtId, jurors]);
3463

35-
await deploy("EscrowUniversal", {
64+
await deploy(escrowDeployments[escrowDeployment].escrow, {
3665
from: deployer,
3766
args: [
3867
klerosCore.target,
@@ -47,30 +76,38 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
4776
});
4877

4978
// Set the value cap to about USD 1000
50-
const escrow = (await ethers.getContract("EscrowUniversal")) as EscrowUniversal;
79+
const escrow = (await ethers.getContract(escrowDeployments[escrowDeployment].escrow)) as EscrowUniversal;
5180
const WETH = await deployments.get("WETH");
5281
const DAI = await deployments.get("DAI");
82+
const PNK = await deployments.getOrNull("PNK");
83+
const USDC = await deployments.getOrNull("USDC");
84+
const USDCe = await deployments.getOrNull("USDCe"); // USDC.e (Bridged USDC)
5385
const caps = {
5486
[ethers.ZeroAddress]: ethers.parseUnits("0.3"),
5587
[WETH.address]: ethers.parseUnits("0.3"),
5688
[DAI.address]: ethers.parseUnits("1000"),
5789
};
90+
if (PNK) {
91+
caps[PNK.address] = ethers.parseUnits("100000"); // 100,000 PNK
92+
}
93+
if (USDC) {
94+
caps[USDC.address] = ethers.parseUnits("1000", 6);
95+
}
96+
if (USDCe) {
97+
caps[USDCe.address] = ethers.parseUnits("1000", 6);
98+
}
5899
for (const [token, cap] of Object.entries(caps)) {
59100
console.log("Setting cap for", token, cap);
60101
await escrow.changeAmountCap(token, cap);
61102
}
62103

63-
await deploy("EscrowView", {
104+
await deploy(escrowDeployments[escrowDeployment].view, {
105+
contract: "EscrowView",
64106
from: deployer,
65107
args: [escrow.target],
66-
gasLimit: 50000000,
108+
gasLimit: 30000000,
67109
log: true,
68110
});
69111
};
70112

71-
deploy.tags = ["Escrow"];
72-
deploy.skip = async ({ network }) => {
73-
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
74-
};
75-
76-
export default deploy;
113+
export default deployEscrow;

contracts/deploy/utils/getContracts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeploymentName, getContractsEthers as _getArbitratorContracts } from "@kleros/kleros-v2-contracts";
3-
import { EscrowView, EscrowUniversal } from "../../typechain-types";
3+
import { EscrowView, EscrowUniversal, EscrowCustomBuyer } from "../../typechain-types";
44

55
const NETWORK_TO_DEPLOYMENT: Record<string, DeploymentName> = {
66
arbitrumSepoliaDevnet: "devnet",
@@ -24,5 +24,7 @@ export const getContracts = async (hre: HardhatRuntimeEnvironment) => {
2424
const { klerosCore, disputeTemplateRegistry } = await getArbitratorContracts(hre);
2525
const escrow = await ethers.getContract<EscrowUniversal>("EscrowUniversal");
2626
const view = await ethers.getContract<EscrowView>("EscrowView");
27-
return { escrow, view, disputeTemplateRegistry, klerosCore };
27+
const escrowCustomBuyer = await ethers.getContract<EscrowCustomBuyer>("EscrowCustomBuyer");
28+
const customBuyerView = await ethers.getContract<EscrowView>("EscrowViewCustomBuyer");
29+
return { escrow, view, escrowCustomBuyer, customBuyerView, disputeTemplateRegistry, klerosCore };
2830
};

0 commit comments

Comments
 (0)