Skip to content

Commit 247ff22

Browse files
committed
Merge branch 'feat(web)/estuary-netlify-function' of github.com:kleros/kleros-v2 into feat(web)/estuary-netlify-function
2 parents 3c73f4e + bae4b5c commit 247ff22

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

contracts/scripts/populateCourts.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { deployments, getNamedAccounts, getChainId, ethers } from "hardhat";
22
import { KlerosCore } from "../typechain-types";
33
import { BigNumber } from "ethers";
4-
import courtsV1 from "../courts.v1.mainnet.json";
4+
import courtsV1Mainnet from "../config/courts.v1.mainnet.json";
5+
import courtsV1GnosisChain from "../config/courts.v1.gnosischain.json";
56

67
enum HomeChains {
78
ARBITRUM_ONE = 42161,
@@ -10,8 +11,11 @@ enum HomeChains {
1011
HARDHAT = 31337,
1112
}
1213

14+
const TESTING_PARAMETERS = true;
15+
const FROM_GNOSIS = true;
16+
const ETH_USD = BigNumber.from(1500);
1317
const DISPUTE_KIT_CLASSIC = BigNumber.from(1);
14-
const TESTING_PARAMETERS = false;
18+
const TEN_THOUSAND_GWEI = BigNumber.from(10).pow(13);
1519

1620
async function main() {
1721
// fallback to hardhat node signers on local network
@@ -25,15 +29,31 @@ async function main() {
2529
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
2630
}
2731

32+
const truncateWei = (x: BigNumber) => x.div(TEN_THOUSAND_GWEI).mul(TEN_THOUSAND_GWEI);
33+
34+
const parametersUsdToEth = (court) => ({
35+
...court,
36+
minStake: truncateWei(BigNumber.from(court.minStake).div(ETH_USD)),
37+
feeForJuror: truncateWei(BigNumber.from(court.feeForJuror).div(ETH_USD)),
38+
});
39+
40+
const parametersProductionToTesting = (court) => ({
41+
...court,
42+
minStake: truncateWei(BigNumber.from(court.minStake).div(10000)),
43+
feeForJuror: truncateWei(ethers.utils.parseEther("0.00001")),
44+
timesPerPeriod: [120, 120, 120, 120],
45+
});
46+
2847
// WARNING: skip the Forking court at id 0, so the v1 courts are shifted by 1
29-
const courtsV2 = courtsV1.map((court) => ({
48+
const parametersV1ToV2 = (court) => ({
3049
...court,
3150
id: BigNumber.from(court.id).add(1),
3251
parent: BigNumber.from(court.parent).add(1),
33-
minStake: TESTING_PARAMETERS ? BigNumber.from(court.minStake).div(100) : court.minStake,
34-
feeForJuror: TESTING_PARAMETERS ? ethers.utils.parseEther("0.001") : court.feeForJuror,
35-
timesPerPeriod: TESTING_PARAMETERS ? [120, 120, 120, 120] : court.timesPerPeriod,
36-
}));
52+
});
53+
54+
let courtsV1 = FROM_GNOSIS ? courtsV1GnosisChain.map(parametersUsdToEth) : courtsV1Mainnet;
55+
courtsV1 = TESTING_PARAMETERS ? courtsV1.map(parametersProductionToTesting) : courtsV1;
56+
const courtsV2 = courtsV1.map(parametersV1ToV2);
3757

3858
console.log("courtsV2 = %O", courtsV2);
3959

contracts/scripts/populatePolicyRegistry.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { deployments, getNamedAccounts, getChainId, ethers } from "hardhat";
22
import { PolicyRegistry } from "../typechain-types";
3-
import policiesV1 from "../policies.v1.mainnet.json";
3+
import policiesV1Mainnet from "../config/policies.v1.mainnet.json";
4+
import policiesV1GnosisChain from "../config/policies.v1.gnosischain.json";
45

56
enum HomeChains {
67
ARBITRUM_ONE = 42161,
@@ -9,6 +10,8 @@ enum HomeChains {
910
HARDHAT = 31337,
1011
}
1112

13+
const FROM_GNOSIS = true;
14+
1215
async function main() {
1316
// fallback to hardhat node signers on local network
1417
const deployer = (await getNamedAccounts()).deployer ?? (await ethers.getSigners())[0].address;
@@ -21,6 +24,8 @@ async function main() {
2124
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
2225
}
2326

27+
const policiesV1 = FROM_GNOSIS ? policiesV1GnosisChain : policiesV1Mainnet;
28+
2429
// WARNING: skip the Forking court at id 0, so the v1 courts are shifted by 1
2530
const policiesV2 = policiesV1.map((policy) => ({ ...policy, court: policy.court + 1 }));
2631

0 commit comments

Comments
 (0)