Skip to content

Commit df6df3f

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

File tree

155 files changed

+13584
-935
lines changed

Some content is hidden

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

155 files changed

+13584
-935
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<p align="center">
1212
<a href="https://app.netlify.com/sites/kleros-v2/deploys"><img src="https://api.netlify.com/api/v1/badges/86d94ae8-f655-46a4-a859-d68696173f3a/deploy-status" alt="Netlify Build Status"></a>
13+
<a href="https://app.netlify.com/sites/kleros-v2-university/deploys"><img src="https://api.netlify.com/api/v1/badges/085e1305-e434-4d36-91a4-88e8cbc3aa46/deploy-status" alt="Netlify Build Status"></a>
1314
<a href="https://www.gitpoap.io/gh/kleros/kleros-v2"><img src="https://public-api.gitpoap.io/v1/repo/kleros/kleros-v2/badge" alt="GitPoap badge"></a>
1415
</br>
1516
<a href="https://api.securityscorecards.dev/projects/github.com/kleros/kleros-v2"><img src="https://api.securityscorecards.dev/projects/github.com/kleros/kleros-v2/badge" alt="OpenSSF Scorecard"></a>

contracts/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
5555
- [DAI](https://sepolia.arbiscan.io/address/0x593e89704D285B0c3fbF157c7CF2537456CE64b5)
5656
- [DAIFaucet](https://sepolia.arbiscan.io/address/0xB5b39A1bcD2D7097A8824B3cC18Ebd2dFb0D9B5E)
5757
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x9426F127116C3652A262AE1eA48391AC8F44D35b), [implementation](https://sepolia.arbiscan.io/address/0x692CC78F2570181FFB99297965FeAA8352ab12E8)
58+
- [DisputeKitClassicUniversity: proxy](https://sepolia.arbiscan.io/address/0xDaE66157D72Baa099cd63a833c353776206feea4), [implementation](https://sepolia.arbiscan.io/address/0xf36fa321Bb64b6E39f5DA3dbb053ccE63D077f8B)
5859
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xB8B36CC43f852f9F0484f53Eb38CaBBA28a81bF6)
60+
- [DisputeResolverUniversity](https://sepolia.arbiscan.io/address/0x102Ba9488Df13842612e777aB16144cCACD38194)
5961
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0x596D3B09E684D62217682216e9b7a0De75933391), [implementation](https://sepolia.arbiscan.io/address/0xc53b813ed94AaEb6F5518D60bf6a8109954bE3f6)
6062
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0x57fd453FB0d16f8ca174E7386102D7170E17Be09), [implementation](https://sepolia.arbiscan.io/address/0x05AD81f245209b7f91885fd96e57c9da90554824)
6163
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xA54e7A16d7460e38a8F324eF46782FB520d58CE8), [implementation](https://sepolia.arbiscan.io/address/0x91a373BBdE0532F86410682F362e2Cf685e95085)
64+
- [KlerosCoreUniversity: proxy](https://sepolia.arbiscan.io/address/0x10BaAFDe8B4d3164CA781571e2F1513317f57980), [implementation](https://sepolia.arbiscan.io/address/0x8466ab62E7c923e8F2E61d0358C495676D6F939b)
6265
- [PNKFaucet](https://sepolia.arbiscan.io/address/0x7EFE468003Ad6A858b5350CDE0A67bBED58739dD)
6366
- [PinakionV2](https://sepolia.arbiscan.io/address/0x34B944D42cAcfC8266955D07A80181D2054aa225)
6467
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0x2AC2EdFD336732bc6963f1AD03ED98B22dB949da), [implementation](https://sepolia.arbiscan.io/address/0xAA637C9E2831614158d7eB193D03af4a7223C56E)
6568
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0xA995C172d286f8F4eE137CC662e2844E59Cf4836), [implementation](https://sepolia.arbiscan.io/address/0xe62B776498F48061ef9425fCEf30F3d1370DB005)
6669
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0x19cb28BAB40C3585955798f5EEabd71Eec14471C), [implementation](https://sepolia.arbiscan.io/address/0xBC82B29e5aE8a749D82b7919118Ab7C0D41fA3D3)
70+
- [SortitionModuleUniversity: proxy](https://sepolia.arbiscan.io/address/0xBEEb15EF1DEf96c569c97A703E649B0251ceFB04), [implementation](https://sepolia.arbiscan.io/address/0xaA2833b174D4e29ae2aFc0b11dF9160EDB28BF9d)
6771
- [WETH](https://sepolia.arbiscan.io/address/0x3829A2486d53ee984a0ca2D76552715726b77138)
6872
- [WETHFaucet](https://sepolia.arbiscan.io/address/0x6F8C10E0030aDf5B8030a5E282F026ADdB6525fd)
6973

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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 { HomeChains, isSkipped } from "./utils";
7+
import { deployERC20AndFaucet } from "./utils/deployERC20AndFaucet";
8+
import { DisputeKitClassic, KlerosCore } from "../typechain-types";
9+
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
10+
11+
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
12+
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
13+
const { deploy } = deployments;
14+
const { AddressZero } = hre.ethers.constants;
15+
16+
// fallback to hardhat node signers on local network
17+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
18+
const chainId = Number(await getChainId());
19+
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
20+
21+
const pnk = await deployERC20AndFaucet(hre, deployer, "PNK");
22+
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
23+
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
24+
25+
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicUniversity", {
26+
from: deployer,
27+
contract: "DisputeKitClassic",
28+
args: [deployer, AddressZero],
29+
log: true,
30+
});
31+
32+
let klerosCoreAddress = await deployments.getOrNull("KlerosCoreUniversity").then((deployment) => deployment?.address);
33+
if (!klerosCoreAddress) {
34+
const nonce = await ethers.provider.getTransactionCount(deployer);
35+
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
36+
console.log("calculated future KlerosCoreUniversity address for nonce %d: %s", nonce + 3, klerosCoreAddress);
37+
}
38+
const sortitionModule = await deployUpgradable(deployments, "SortitionModuleUniversity", {
39+
from: deployer,
40+
args: [deployer, klerosCoreAddress],
41+
log: true,
42+
}); // nonce (implementation), nonce+1 (proxy)
43+
44+
const minStake = BigNumber.from(10).pow(20).mul(2);
45+
const alpha = 10000;
46+
const feeForJuror = BigNumber.from(10).pow(17);
47+
const klerosCore = await deployUpgradable(deployments, "KlerosCoreUniversity", {
48+
from: deployer,
49+
args: [
50+
deployer, // governor
51+
deployer, // instructor
52+
pnk.address,
53+
AddressZero,
54+
disputeKit.address,
55+
false,
56+
[minStake, alpha, feeForJuror, 256], // minStake, alpha, feeForJuror, jurorsForCourtJump
57+
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
58+
sortitionModule.address,
59+
],
60+
log: true,
61+
}); // nonce+2 (implementation), nonce+3 (proxy)
62+
63+
// changeCore() only if necessary
64+
const disputeKitContract = (await ethers.getContract("DisputeKitClassicUniversity")) as DisputeKitClassic;
65+
const currentCore = await disputeKitContract.core();
66+
if (currentCore !== klerosCore.address) {
67+
console.log("changing DisputeKitClassicUniversity.core to %s", klerosCore.address);
68+
await disputeKitContract.changeCore(klerosCore.address);
69+
}
70+
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+
89+
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);
93+
} catch (e) {
94+
console.error("failed to change currency rates:", e);
95+
}
96+
97+
const disputeTemplateRegistry = await getContractOrDeployUpgradable(hre, "DisputeTemplateRegistry", {
98+
from: deployer,
99+
args: [deployer],
100+
log: true,
101+
});
102+
103+
await deploy("DisputeResolverUniversity", {
104+
from: deployer,
105+
contract: "DisputeResolver",
106+
args: [klerosCore.address, disputeTemplateRegistry.address],
107+
log: true,
108+
});
109+
};
110+
111+
deployArbitration.tags = ["ArbitrationUniversity"];
112+
deployArbitration.skip = async ({ network }) => {
113+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
114+
};
115+
116+
export default deployArbitration;

contracts/deploy/utils/getContractOrDeploy.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Contract } from "@ethersproject/contracts";
22
import { DeployOptions } from "hardhat-deploy/types";
33
import { HardhatRuntimeEnvironment } from "hardhat/types";
4+
import { deployUpgradable } from "./deployUpgradable";
45

56
export const getContractOrDeploy = async (
67
hre: HardhatRuntimeEnvironment,
@@ -17,3 +18,19 @@ export const getContractOrDeploy = async (
1718
}
1819
return contract;
1920
};
21+
22+
export const getContractOrDeployUpgradable = async (
23+
hre: HardhatRuntimeEnvironment,
24+
contractName: string,
25+
options: DeployOptions
26+
): Promise<Contract> => {
27+
let contract = await hre.ethers.getContractOrNull(contractName);
28+
if (!contract) {
29+
console.log(`contract ${contractName} not deployed, deploying as upgradable now...`);
30+
await deployUpgradable(hre.deployments, contractName, options);
31+
contract = await hre.ethers.getContract(contractName);
32+
} else {
33+
console.log(`contract ${contractName} already deployed`);
34+
}
35+
return contract;
36+
};

0 commit comments

Comments
 (0)