Skip to content

Commit f46b018

Browse files
committed
Merge branch 'dev' into feat(web)/lazy-loading
2 parents df6df3f + ee63a5d commit f46b018

File tree

457 files changed

+37847
-6061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

457 files changed

+37847
-6061
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ web_modules/
8383
.env.test
8484
.env.production
8585

86-
# parcel-bundler cache (https://parceljs.org/)
87-
.cache
88-
.parcel-cache
89-
9086
# Next.js build output
9187
.next
9288
out

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
"sonarlint.connectedMode.project": {
1313
"connectionId": "kleros",
1414
"projectKey": "kleros_kleros-v2"
15+
},
16+
"editor.codeActionsOnSave": {
17+
"source.fixAll.eslint": "explicit"
1518
}
1619
}

contracts/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ typings/
9696
.env
9797
.env.test
9898

99-
# parcel-bundler cache (https://parceljs.org/)
100-
.cache
101-
10299
# Next.js build output
103100
.next
104101

contracts/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ Smart contracts for Kleros v2
66

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

9+
### V2 Neo (prelaunch)
10+
11+
#### Arbitrum One
12+
13+
- [DisputeKitClassicNeo: proxy](https://arbiscan.io/address/0xb7c292cD9Fd3d20De84a71AE1caF054eEB6374A9), [implementation](https://arbiscan.io/address/0x86Ac67e5550F837a650B4B0Cd4778D4293a2bDe3)
14+
- [DisputeResolverNeo](https://arbiscan.io/address/0x95eCE455bD817D6adB92F2383617d36eBE10D6EB)
15+
- [DisputeTemplateRegistry: proxy](https://arbiscan.io/address/0x52c9f5634361eD3641016e5d9783310f9EFf9e25), [implementation](https://arbiscan.io/address/0x4Ce87329d40f15509D5F9bF4D9Ce1A081A80CeFb)
16+
- [EvidenceModule: proxy](https://arbiscan.io/address/0xe62B776498F48061ef9425fCEf30F3d1370DB005), [implementation](https://arbiscan.io/address/0x827411b3e98bAe8c441efBf26842A1670f8f378F)
17+
- [KlerosCoreNeo: proxy](https://arbiscan.io/address/0xCd415C03dfa85B02646C7e2977F22a480c4354F1), [implementation](https://arbiscan.io/address/0x4DD8B69958eF1D7d5dA9347E9d9F57ADFC3dc284)
18+
- [KlerosV2NeoEarlyUser](https://arbiscan.io/address/0xfE34a72c55e512601E7d491A9c5b36373cE34d63)
19+
- [Pinakion](https://arbiscan.io/address/0x330bD769382cFc6d50175903434CCC8D206DCAE5)
20+
- [PolicyRegistry: proxy](https://arbiscan.io/address/0x26c1980120F1C82cF611D666CE81D2b54d018547), [implementation](https://arbiscan.io/address/0x2AC2EdFD336732bc6963f1AD03ED98B22dB949da)
21+
- [RandomizerRNG: proxy](https://arbiscan.io/address/0xC3dB344755b15c8Edfd834db79af4f8860029FB4), [implementation](https://arbiscan.io/address/0xA995C172d286f8F4eE137CC662e2844E59Cf4836)
22+
- [SortitionModuleNeo: proxy](https://arbiscan.io/address/0x614498118850184c62f82d08261109334bFB050f), [implementation](https://arbiscan.io/address/0xf327200420F21BAafce8F1C03B1EEdF926074B95)
23+
924
### Official Testnet
1025

1126
#### Arbitrum Sepolia
@@ -55,18 +70,23 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
5570
- [DAI](https://sepolia.arbiscan.io/address/0x593e89704D285B0c3fbF157c7CF2537456CE64b5)
5671
- [DAIFaucet](https://sepolia.arbiscan.io/address/0xB5b39A1bcD2D7097A8824B3cC18Ebd2dFb0D9B5E)
5772
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x9426F127116C3652A262AE1eA48391AC8F44D35b), [implementation](https://sepolia.arbiscan.io/address/0x692CC78F2570181FFB99297965FeAA8352ab12E8)
73+
- [DisputeKitClassicNeo: proxy](https://sepolia.arbiscan.io/address/0xd40aA608801a639E292e10C235B90488D04070b1), [implementation](https://sepolia.arbiscan.io/address/0xE636AB278fBfc8712E807c589A362dc2396d2d2F)
5874
- [DisputeKitClassicUniversity: proxy](https://sepolia.arbiscan.io/address/0xDaE66157D72Baa099cd63a833c353776206feea4), [implementation](https://sepolia.arbiscan.io/address/0xf36fa321Bb64b6E39f5DA3dbb053ccE63D077f8B)
5975
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xB8B36CC43f852f9F0484f53Eb38CaBBA28a81bF6)
76+
- [DisputeResolverNeo](https://sepolia.arbiscan.io/address/0xaBC213522c01354DC0Db2B3E89bDe0FCF44Acac6)
6077
- [DisputeResolverUniversity](https://sepolia.arbiscan.io/address/0x102Ba9488Df13842612e777aB16144cCACD38194)
6178
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0x596D3B09E684D62217682216e9b7a0De75933391), [implementation](https://sepolia.arbiscan.io/address/0xc53b813ed94AaEb6F5518D60bf6a8109954bE3f6)
6279
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0x57fd453FB0d16f8ca174E7386102D7170E17Be09), [implementation](https://sepolia.arbiscan.io/address/0x05AD81f245209b7f91885fd96e57c9da90554824)
6380
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xA54e7A16d7460e38a8F324eF46782FB520d58CE8), [implementation](https://sepolia.arbiscan.io/address/0x91a373BBdE0532F86410682F362e2Cf685e95085)
81+
- [KlerosCoreNeo: proxy](https://sepolia.arbiscan.io/address/0x26bf077037550e437605F07e25EfcAd510715C3A), [implementation](https://sepolia.arbiscan.io/address/0x3bE96b7eAF6A3640DBa1f7CE58776D5b790B74CB)
6482
- [KlerosCoreUniversity: proxy](https://sepolia.arbiscan.io/address/0x10BaAFDe8B4d3164CA781571e2F1513317f57980), [implementation](https://sepolia.arbiscan.io/address/0x8466ab62E7c923e8F2E61d0358C495676D6F939b)
83+
- [KlerosV2NeoEarlyUser](https://sepolia.arbiscan.io/address/0x0d60Ff8bbCF49Bc5352328E7E28e141834d7750F)
6584
- [PNKFaucet](https://sepolia.arbiscan.io/address/0x7EFE468003Ad6A858b5350CDE0A67bBED58739dD)
6685
- [PinakionV2](https://sepolia.arbiscan.io/address/0x34B944D42cAcfC8266955D07A80181D2054aa225)
6786
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0x2AC2EdFD336732bc6963f1AD03ED98B22dB949da), [implementation](https://sepolia.arbiscan.io/address/0xAA637C9E2831614158d7eB193D03af4a7223C56E)
6887
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0xA995C172d286f8F4eE137CC662e2844E59Cf4836), [implementation](https://sepolia.arbiscan.io/address/0xe62B776498F48061ef9425fCEf30F3d1370DB005)
6988
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0x19cb28BAB40C3585955798f5EEabd71Eec14471C), [implementation](https://sepolia.arbiscan.io/address/0xBC82B29e5aE8a749D82b7919118Ab7C0D41fA3D3)
89+
- [SortitionModuleNeo: proxy](https://sepolia.arbiscan.io/address/0x809533c303c10915BB5c0585f2d8D738e2a4fB64), [implementation](https://sepolia.arbiscan.io/address/0xD9ddceb7C399518F23b69D155a67C6AFF13f9fF0)
7090
- [SortitionModuleUniversity: proxy](https://sepolia.arbiscan.io/address/0xBEEb15EF1DEf96c569c97A703E649B0251ceFB04), [implementation](https://sepolia.arbiscan.io/address/0xaA2833b174D4e29ae2aFc0b11dF9160EDB28BF9d)
7191
- [WETH](https://sepolia.arbiscan.io/address/0x3829A2486d53ee984a0ca2D76552715726b77138)
7292
- [WETHFaucet](https://sepolia.arbiscan.io/address/0x6F8C10E0030aDf5B8030a5E282F026ADdB6525fd)

contracts/config/policies.v1.mainnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"name": "Token Listing",
2626
"description": "**Court Purpose:**\n\nThis court serves as the final validation for token listing for verified projects listing on the Ethfinex Exchange using Kleros’ Token Curated List Dapp.\nThis is a high level, high stake court requiring deep blockchain knowledge, legal experience and / or a knowledge of exchange listings in general. Jurors are required to stake a large amount of PNK and should only do so if they are confident in the above capabilities.",
27-
"summary": "[Ethfinex Court Policy](https://ipfs.kleros.io/ipfs/QmVzwEBpGsbFY3UgyjA3SxgGXx3r5gFGynNpaoXkp6jenu/Ethfinex%20Court%20Policy.pdf)",
27+
"summary": "[Ethfinex Court Policy](https://cdn.kleros.link/ipfs/QmVzwEBpGsbFY3UgyjA3SxgGXx3r5gFGynNpaoXkp6jenu/Ethfinex%20Court%20Policy.pdf)",
2828
"court": 3,
2929
"uri": "/ipfs/QmeyojE13mcQtWqQQddYypafDRChVND8z6dcHLbaarmbbx"
3030
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "Token Listing",
33
"description": "This court serves as the final validation for token listing for verified projects listing on the Ethfinex Exchange using Kleros’ Token Curated List Dapp.\nThis is a high level, high stake court requiring deep blockchain knowledge, legal experience and / or a knowledge of exchange listings in general. Jurors are required to stake a large amount of PNK and should only do so if they are confident in the above capabilities.",
4-
"summary": "[Ethfinex Court Policy](https://ipfs.kleros.io/ipfs/QmVzwEBpGsbFY3UgyjA3SxgGXx3r5gFGynNpaoXkp6jenu/Ethfinex%20Court%20Policy.pdf)"
4+
"summary": "[Ethfinex Court Policy](https://cdn.kleros.link/ipfs/QmVzwEBpGsbFY3UgyjA3SxgGXx3r5gFGynNpaoXkp6jenu/Ethfinex%20Court%20Policy.pdf)"
55
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { BigNumber, BigNumberish } from "ethers";
4+
import { getContractAddress } from "./utils/getContractAddress";
5+
import { deployUpgradable } from "./utils/deployUpgradable";
6+
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
7+
import { HomeChains, isSkipped, isDevnet, PNK, ETH, isMainnet } from "./utils";
8+
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
9+
import { deployERC20AndFaucet, deployERC721 } from "./utils/deployTokens";
10+
import { DisputeKitClassic, KlerosCoreNeo } from "../typechain-types";
11+
12+
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
13+
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
14+
const { deploy, execute } = deployments;
15+
const { AddressZero } = hre.ethers.constants;
16+
const RNG_LOOKAHEAD = 20;
17+
18+
// fallback to hardhat node signers on local network
19+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
20+
const chainId = Number(await getChainId());
21+
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
22+
23+
const pnk = await deployERC20AndFaucet(hre, deployer, "PNK");
24+
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
25+
const nft = await deployERC721(hre, deployer, "Kleros V2 Neo Early User", "KlerosV2NeoEarlyUser");
26+
27+
const randomizerOracle = await getContractOrDeploy(hre, "RandomizerOracle", {
28+
from: deployer,
29+
contract: "RandomizerMock",
30+
args: [],
31+
log: true,
32+
});
33+
34+
await deployUpgradable(deployments, "PolicyRegistry", { from: deployer, args: [deployer], log: true });
35+
36+
await deployUpgradable(deployments, "EvidenceModule", { from: deployer, args: [deployer], log: true });
37+
38+
const rng = await deployUpgradable(deployments, "RandomizerRNG", {
39+
from: deployer,
40+
args: [randomizerOracle.address, deployer],
41+
log: true,
42+
});
43+
44+
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicNeo", {
45+
from: deployer,
46+
contract: "DisputeKitClassic",
47+
args: [deployer, AddressZero],
48+
log: true,
49+
});
50+
51+
let klerosCoreAddress = await deployments.getOrNull("KlerosCoreNeo").then((deployment) => deployment?.address);
52+
if (!klerosCoreAddress) {
53+
const nonce = await ethers.provider.getTransactionCount(deployer);
54+
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
55+
console.log("calculated future KlerosCoreNeo address for nonce %d: %s", nonce + 3, klerosCoreAddress);
56+
}
57+
const devnet = isDevnet(hre.network);
58+
const minStakingTime = devnet ? 180 : 1800;
59+
const maxFreezingTime = devnet ? 600 : 1800;
60+
const maxStakePerJuror = PNK(2_000);
61+
const maxTotalStaked = PNK(2_000_000);
62+
const sortitionModule = await deployUpgradable(deployments, "SortitionModuleNeo", {
63+
from: deployer,
64+
args: [
65+
deployer,
66+
klerosCoreAddress,
67+
minStakingTime,
68+
maxFreezingTime,
69+
rng.address,
70+
RNG_LOOKAHEAD,
71+
maxStakePerJuror,
72+
maxTotalStaked,
73+
],
74+
log: true,
75+
}); // nonce (implementation), nonce+1 (proxy)
76+
77+
const minStake = PNK(200);
78+
const alpha = 10000;
79+
const feeForJuror = ETH(0.1);
80+
const jurorsForCourtJump = 256;
81+
const klerosCore = await deployUpgradable(deployments, "KlerosCoreNeo", {
82+
from: deployer,
83+
args: [
84+
deployer,
85+
deployer,
86+
pnk.address,
87+
AddressZero,
88+
disputeKit.address,
89+
false,
90+
[minStake, alpha, feeForJuror, jurorsForCourtJump],
91+
[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
93+
sortitionModule.address,
94+
nft.address,
95+
],
96+
log: true,
97+
}); // nonce+2 (implementation), nonce+3 (proxy)
98+
99+
// execute DisputeKitClassic.changeCore() only if necessary
100+
const disputeKitContract = (await hre.ethers.getContract("DisputeKitClassicNeo")) as DisputeKitClassic;
101+
const currentCore = await disputeKitContract.core();
102+
if (currentCore !== klerosCore.address) {
103+
console.log(`disputeKit.changeCore(${klerosCore.address})`);
104+
await disputeKitContract.changeCore(klerosCore.address);
105+
}
106+
107+
const core = (await hre.ethers.getContract("KlerosCoreNeo")) as KlerosCoreNeo;
108+
try {
109+
await changeCurrencyRate(core, weth.address, true, 1, 1);
110+
} catch (e) {
111+
console.error("failed to change currency rates:", e);
112+
}
113+
114+
const disputeTemplateRegistry = await getContractOrDeployUpgradable(hre, "DisputeTemplateRegistry", {
115+
from: deployer,
116+
args: [deployer],
117+
log: true,
118+
});
119+
120+
const resolver = await deploy("DisputeResolverNeo", {
121+
from: deployer,
122+
contract: "DisputeResolver",
123+
args: [core.address, disputeTemplateRegistry.address],
124+
log: true,
125+
});
126+
127+
console.log(`core.changeArbitrableWhitelist(${resolver.address}, true)`);
128+
await core.changeArbitrableWhitelist(resolver.address, true);
129+
};
130+
131+
deployArbitration.tags = ["ArbitrationNeo"];
132+
deployArbitration.skip = async ({ network }) => {
133+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
134+
};
135+
136+
export default deployArbitration;

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

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { BigNumber, BigNumberish } from "ethers";
44
import { getContractAddress } from "./utils/getContractAddress";
55
import { deployUpgradable } from "./utils/deployUpgradable";
6-
import { HomeChains, isSkipped } from "./utils";
7-
import { deployERC20AndFaucet } from "./utils/deployERC20AndFaucet";
8-
import { DisputeKitClassic, KlerosCore } from "../typechain-types";
6+
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
7+
import { ETH, HomeChains, PNK, isSkipped } from "./utils";
8+
import { deployERC20AndFaucet } from "./utils/deployTokens";
9+
import { DisputeKitClassic, KlerosCore, KlerosCoreUniversity } from "../typechain-types";
910
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
1011

1112
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
@@ -41,9 +42,10 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
4142
log: true,
4243
}); // nonce (implementation), nonce+1 (proxy)
4344

44-
const minStake = BigNumber.from(10).pow(20).mul(2);
45+
const minStake = PNK(200);
4546
const alpha = 10000;
46-
const feeForJuror = BigNumber.from(10).pow(17);
47+
const feeForJuror = ETH(0.1);
48+
const jurorsForCourtJump = 256;
4749
const klerosCore = await deployUpgradable(deployments, "KlerosCoreUniversity", {
4850
from: deployer,
4951
args: [
@@ -53,7 +55,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5355
AddressZero,
5456
disputeKit.address,
5557
false,
56-
[minStake, alpha, feeForJuror, 256], // minStake, alpha, feeForJuror, jurorsForCourtJump
58+
[minStake, alpha, feeForJuror, jurorsForCourtJump],
5759
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
5860
sortitionModule.address,
5961
],
@@ -64,32 +66,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6466
const disputeKitContract = (await ethers.getContract("DisputeKitClassicUniversity")) as DisputeKitClassic;
6567
const currentCore = await disputeKitContract.core();
6668
if (currentCore !== klerosCore.address) {
67-
console.log("changing DisputeKitClassicUniversity.core to %s", klerosCore.address);
69+
console.log(`disputeKit.changeCore(${klerosCore.address})`);
6870
await disputeKitContract.changeCore(klerosCore.address);
6971
}
7072

71-
const changeCurrencyRate = async (
72-
erc20: string,
73-
accepted: boolean,
74-
rateInEth: BigNumberish,
75-
rateDecimals: BigNumberish
76-
) => {
77-
const core = (await ethers.getContract("KlerosCoreUniversity")) as KlerosCore;
78-
const pnkRate = await core.currencyRates(erc20);
79-
if (pnkRate.feePaymentAccepted !== accepted) {
80-
console.log(`core.changeAcceptedFeeTokens(${erc20}, ${accepted})`);
81-
await core.changeAcceptedFeeTokens(erc20, accepted);
82-
}
83-
if (!pnkRate.rateInEth.eq(rateInEth) || pnkRate.rateDecimals !== rateDecimals) {
84-
console.log(`core.changeCurrencyRates(${erc20}, ${rateInEth}, ${rateDecimals})`);
85-
await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
86-
}
87-
};
88-
73+
const core = (await hre.ethers.getContract("KlerosCoreUniversity")) as KlerosCoreUniversity;
8974
try {
90-
await changeCurrencyRate(pnk.address, true, 12225583, 12);
91-
await changeCurrencyRate(dai.address, true, 60327783, 11);
92-
await changeCurrencyRate(weth.address, true, 1, 1);
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);
9378
} catch (e) {
9479
console.error("failed to change currency rates:", e);
9580
}
@@ -103,7 +88,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
10388
await deploy("DisputeResolverUniversity", {
10489
from: deployer,
10590
contract: "DisputeResolver",
106-
args: [klerosCore.address, disputeTemplateRegistry.address],
91+
args: [core.address, disputeTemplateRegistry.address],
10792
log: true,
10893
});
10994
};

0 commit comments

Comments
 (0)