Skip to content

Commit da78219

Browse files
committed
feat: added evidence module
1 parent 9bc5d4b commit da78219

File tree

9 files changed

+2606
-105
lines changed

9 files changed

+2606
-105
lines changed

contracts/README.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# @kleros/curate-v2-contracts
2+
3+
Smart contracts for CurateV2
4+
5+
## Deployments
6+
7+
Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh` or `./scripts/populateReadme.sh`.
8+
9+
### Official Testnet
10+
11+
#### Arbitrum Sepolia
12+
13+
#### Sepolia
14+
15+
### Devnet
16+
17+
#### Arbitrum Sepolia
18+
19+
- [CurateFactory](https://sepolia.arbiscan.io/address/0x334ccaF11CF578f5acF208eC588aA58253020547)
20+
- [CurateV2](https://sepolia.arbiscan.io/address/0xb2fe313cdC7e25627fCB7D585E98213e8A4655B2)
21+
- [CurateView](https://sepolia.arbiscan.io/address/0xaccB6CB6976a7cc935a2C36285E2a46B995d99a6)
22+
23+
#### Sepolia
24+
25+
## Getting Started
26+
27+
### Install the Dependencies
28+
29+
```bash
30+
yarn install
31+
```
32+
33+
### Run Tests
34+
35+
```bash
36+
yarn test
37+
```
38+
39+
### Compile the Contracts
40+
41+
```bash
42+
yarn build
43+
```
44+
45+
### Run Linter on Files
46+
47+
```bash
48+
yarn lint
49+
```
50+
51+
### Fix Linter Issues on Files
52+
53+
```bash
54+
yarn fix
55+
```
56+
57+
### Deploy Instructions
58+
59+
**NOTICE:** the commands below work only if you are inside the `contracts/` directory.
60+
61+
#### 0. Set the Environment Variables
62+
63+
Copy `.env.example` file as `.env` and edit it accordingly.
64+
65+
```bash
66+
cp .env.example .env
67+
```
68+
69+
The following env vars are required:
70+
71+
- `PRIVATE_KEY`: the private key of the deployer account used for the testnets.
72+
- `MAINNET_PRIVATE_KEY`: the private key of the deployer account used for Mainnet.
73+
- `INFURA_API_KEY`: the API key for infura.
74+
75+
The ones below are optional:
76+
77+
- `ETHERSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Etherscan**.
78+
- `ARBISCAN_API_KEY`: to verify the source of the newly deployed contracts on **Arbitrum**.
79+
- `GNOSISSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Gnosis chain**.
80+
81+
#### 1. Deploy to a Local Network
82+
83+
:warning: There is no mocks deployed for the kleros-v2 contracts currently so this would fail. For now consider deploying to a testnet fork (next section).
84+
85+
**Shell 1: the node**
86+
87+
```bash
88+
yarn hardhat node --tags nothing
89+
```
90+
91+
**Shell 2: the deploy script**
92+
93+
```bash
94+
yarn deploy --network localhost --tags CurateV2
95+
```
96+
97+
#### 2. Deploy to a Public Network Fork
98+
99+
**Shell 1: the node**
100+
101+
```bash
102+
yarn start-devnet-fork
103+
# or
104+
yarn start-testnet-fork
105+
```
106+
107+
**Shell 2: the deploy script**
108+
109+
```bash
110+
yarn deploy-devnet-fork
111+
# or
112+
yarn deploy-testnet-fork
113+
```
114+
115+
#### 3. Deploy to Public Testnets
116+
117+
```bash
118+
yarn deploy --network arbitrumSepolia --tags CurateV2
119+
```
120+
121+
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.
122+
123+
#### 4. Deploy a Devnet on Public Testnets
124+
125+
Same steps as above but append `Devnet` to the `--network` parameter.
126+
127+
#### Running Test Fixtures
128+
129+
**Shell 1: the node**
130+
131+
```bash
132+
yarn hardhat node --tags CurateV2
133+
```
134+
135+
**Shell 2: the test scripts**
136+
137+
```bash
138+
yarn test --network localhost
139+
```
140+
141+
#### 4. Verify the Source Code
142+
143+
This must be done for each network separately.
144+
145+
```bash
146+
# explorer
147+
yarn etherscan-verify --network arbitrumSepolia
148+
yarn etherscan-verify-proxies
149+
150+
# sourcify
151+
yarn sourcify --network arbitrumSepolia
152+
153+
```
154+
155+
## Ad-hoc procedures
156+
157+
### Generate deployment artifacts for existing contracts
158+
159+
#### Usage
160+
161+
```bash
162+
scripts/generateDeploymentArtifact.sh <network> <address>
163+
```
164+
165+
#### Example: WETH on Gnosis chain
166+
167+
```bash
168+
scripts/generateDeploymentArtifact.sh gnosischain 0xf8d1677c8a0c961938bf2f9adc3f3cfda759a9d9 > deployments/gnosischain/WETH.json
169+
```
170+
171+
### Push the contracts to a Tenderly project
172+
173+
Ensure that your `$TENDERLY_PROJECT` and `$TENDERLY_USERNAME` is set correctly in `.env`.
174+
175+
```bash
176+
yarn tenderly-verify --network sepolia
177+
yarn tenderly-verify --network arbitrumSepolia
178+
```

contracts/deploy/00-curate-v2.ts

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { ethers } from "hardhat";
12
import { HardhatRuntimeEnvironment } from "hardhat/types";
23
import { DeployFunction } from "hardhat-deploy/types";
34
import { HomeChains, isSkipped } from "./utils";
5+
import { CurateV2 } from "../typechain-types";
46

5-
const disputeTemplate = `{
7+
const registrationTemplate = `{
68
"$schema": "../NewDisputeTemplate.schema.json",
79
"title": "Let's do this",
810
"description": "We want to do this: %s",
@@ -27,9 +29,34 @@ const disputeTemplate = `{
2729
}
2830
`;
2931

32+
const removalTemplate = `{
33+
"$schema": "../NewDisputeTemplate.schema.json",
34+
"title": "Let's do this",
35+
"description": "We want to do this: %s",
36+
"question": "Should this be removed?",
37+
"answers": [
38+
{
39+
"title": "Yes",
40+
"description": "Select this if you agree that it must be done."
41+
},
42+
{
43+
"title": "No",
44+
"description": "Select this if you do not agree that it must be done."
45+
}
46+
],
47+
"policyURI": "/ipfs/Qmdvk...rSD6cE/policy.pdf",
48+
"frontendUrl": "https://kleros-v2.netlify.app/#/cases/%s/overview",
49+
"arbitratorChainID": "421614",
50+
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b",
51+
"category": "Others",
52+
"specification": "KIP001",
53+
"lang": "en_US"
54+
}
55+
`;
56+
3057
// General court, 3 jurors
3158
const extraData =
32-
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003";
59+
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003";
3360

3461
const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
3562
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -41,18 +68,42 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
4168
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
4269

4370
const klerosCore = await deployments.get("KlerosCore");
71+
const evidenceModule = await deployments.get("EvidenceModule");
4472
const disputeTemplateRegistry = await deployments.get("DisputeTemplateRegistry");
45-
46-
await deploy("CurateV2", {
73+
const fee = ethers.parseEther("0.00001");
74+
const timeout = 600; // 10 minutes
75+
76+
// TODO: use OZ's initializer
77+
const curateAddress = await deploy("CurateV2", {
78+
from: deployer,
79+
args: [],
80+
log: true,
81+
}).then((c) => c.address);
82+
83+
const curate = (await ethers.getContract("CurateV2")) as CurateV2;
84+
await curate.initialize(
85+
deployer,
86+
klerosCore.address,
87+
extraData,
88+
evidenceModule.address,
89+
ethers.ZeroAddress, // _connectedTCR
90+
[registrationTemplate, ""],
91+
[removalTemplate, ""],
92+
disputeTemplateRegistry.address,
93+
[fee, fee, fee, fee],
94+
timeout,
95+
deployer
96+
);
97+
98+
await deploy("CurateFactory", {
99+
from: deployer,
100+
args: [curateAddress],
101+
log: true,
102+
});
103+
104+
await deploy("CurateView", {
47105
from: deployer,
48-
args: [
49-
klerosCore.address,
50-
extraData,
51-
disputeTemplate,
52-
"disputeTemplateMapping: TODO",
53-
disputeTemplateRegistry.address,
54-
600, // feeTimeout: 10 minutes
55-
],
106+
args: [],
56107
log: true,
57108
});
58109
};

0 commit comments

Comments
 (0)