Skip to content

Commit 66b6cf4

Browse files
authored
Merge pull request #114 from kleros/dev
Release to Master
2 parents 64ecc14 + a7f4b01 commit 66b6cf4

File tree

16 files changed

+1413
-619
lines changed

16 files changed

+1413
-619
lines changed

contracts/deploy/00-escrow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { HomeChains, isSkipped } from "./utils";
44
import { EscrowUniversal } from "../typechain-types";
5-
import { getContracts } from "./utils/getContracts";
5+
import { getArbitratorContracts } from "./utils/getContracts";
66

77
const config = {
88
arbitrumSepoliaDevnet: {
@@ -28,7 +28,7 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2828
const chainId = Number(await getChainId());
2929
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
3030

31-
const { disputeTemplateRegistry, klerosCore } = await getContracts(hre);
31+
const { disputeTemplateRegistry, klerosCore } = await getArbitratorContracts(hre);
3232
const { feeTimeout, settlementTimeout, jurors, courtId } = config[network.name];
3333
const extraData = ethers.AbiCoder.defaultAbiCoder().encode(["uint96", "uint96"], [courtId, jurors]);
3434

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,28 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
2-
import {
3-
disputeTemplateRegistryConfig as devnetDtrConfig,
4-
klerosCoreConfig as devnetCoreConfig,
5-
} from "@kleros/kleros-v2-contracts/deployments/devnet.viem";
6-
import {
7-
disputeTemplateRegistryConfig as mainnetDtrConfig,
8-
klerosCoreNeoConfig as mainnetCoreConfig,
9-
} from "@kleros/kleros-v2-contracts/deployments/mainnet.viem";
10-
import {
11-
KlerosCore,
12-
DisputeTemplateRegistry__factory,
13-
KlerosCore__factory,
14-
KlerosCoreNeo__factory,
15-
KlerosCoreNeo,
16-
DisputeTemplateRegistry,
17-
} from "@kleros/kleros-v2-contracts/typechain-types";
2+
import { DeploymentName, getContractsEthers as _getArbitratorContracts } from "@kleros/kleros-v2-contracts";
183
import { EscrowView, EscrowUniversal } from "../../typechain-types";
194

5+
const NETWORK_TO_DEPLOYMENT: Record<string, DeploymentName> = {
6+
arbitrumSepoliaDevnet: "devnet",
7+
arbitrumSepolia: "testnet",
8+
arbitrum: "mainnetNeo",
9+
} as const;
10+
11+
export const getArbitratorContracts = async (hre: HardhatRuntimeEnvironment) => {
12+
const { ethers, deployments } = hre;
13+
const networkName = deployments.getNetworkName();
14+
const deploymentName = NETWORK_TO_DEPLOYMENT[networkName];
15+
if (!deploymentName)
16+
throw new Error(
17+
`Unsupported network: ${networkName}. Supported networks: ${Object.keys(NETWORK_TO_DEPLOYMENT).join(", ")}`
18+
);
19+
return await _getArbitratorContracts(ethers.provider, deploymentName);
20+
};
21+
2022
export const getContracts = async (hre: HardhatRuntimeEnvironment) => {
21-
const { getChainId, ethers, config } = hre;
22-
const chainId = Number(await getChainId());
23+
const { ethers } = hre;
24+
const { klerosCore, disputeTemplateRegistry } = await getArbitratorContracts(hre);
2325
const escrow = await ethers.getContract<EscrowUniversal>("EscrowUniversal");
2426
const view = await ethers.getContract<EscrowView>("EscrowView");
25-
let disputeTemplateRegistry: DisputeTemplateRegistry;
26-
let klerosCore: KlerosCore | KlerosCoreNeo;
27-
switch (chainId) {
28-
case config.networks.arbitrum.chainId:
29-
disputeTemplateRegistry = DisputeTemplateRegistry__factory.connect(
30-
mainnetDtrConfig.address[chainId],
31-
ethers.provider
32-
);
33-
klerosCore = KlerosCoreNeo__factory.connect(mainnetCoreConfig.address[chainId], ethers.provider);
34-
break;
35-
case config.networks.arbitrumSepolia.chainId:
36-
disputeTemplateRegistry = DisputeTemplateRegistry__factory.connect(
37-
devnetDtrConfig.address[chainId],
38-
ethers.provider
39-
);
40-
klerosCore = KlerosCore__factory.connect(devnetCoreConfig.address[chainId], ethers.provider);
41-
break;
42-
default:
43-
throw new Error(`Unsupported chainId: ${chainId}`);
44-
}
4527
return { escrow, view, disputeTemplateRegistry, klerosCore };
4628
};

contracts/hardhat.config.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,6 @@ const config: HardhatUserConfig = {
187187
mocha: {
188188
timeout: 20000,
189189
},
190-
external: {
191-
// https://github.com/wighawag/hardhat-deploy#importing-deployment-from-other-projects-with-truffle-support
192-
deployments: {
193-
localhost: process.env.HARDHAT_FORK
194-
? ["../node_modules/@kleros/kleros-v2-contracts/deployments/" + process.env.HARDHAT_FORK]
195-
: [],
196-
arbitrumSepoliaDevnet: ["../node_modules/@kleros/kleros-v2-contracts/deployments/arbitrumSepoliaDevnet"],
197-
arbitrumSepolia: ["../node_modules/@kleros/kleros-v2-contracts/deployments/arbitrumSepolia"],
198-
arbitrum: ["../node_modules/@kleros/kleros-v2-contracts/deployments/arbitrum"],
199-
},
200-
},
201190
};
202191

203192
export default config;

contracts/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@
6060
"@typechain/hardhat": "^9.1.0",
6161
"@types/chai": "^4.3.20",
6262
"@types/mocha": "^10.0.10",
63-
"@types/node": "^18.0.0",
64-
"@wagmi/cli": "^2.0.3",
65-
"abitype": "^0.10.3",
63+
"@types/node": "^18.19.86",
64+
"@wagmi/cli": "^2.2.1",
65+
"abitype": "^1.0.8",
6666
"chai": "^4.5.0",
6767
"dotenv": "^16.4.5",
6868
"ethereumjs-util": "^7.1.5",
69-
"ethers": "^6.13.5",
69+
"ethers": "^6.13.6",
7070
"graphql": "^16.10.0",
7171
"graphql-request": "^6.1.0",
72-
"hardhat": "2.22.18",
73-
"hardhat-deploy": "^0.14.0",
72+
"hardhat": "2.23.0",
73+
"hardhat-deploy": "^1.0.2",
7474
"hardhat-deploy-ethers": "^0.4.2",
7575
"hardhat-docgen": "^1.3.0",
76-
"hardhat-gas-reporter": "^2.2.2",
76+
"hardhat-gas-reporter": "^2.2.3",
7777
"hardhat-watcher": "^2.5.0",
7878
"pino": "^8.17.0",
7979
"pino-pretty": "^10.2.3",
@@ -83,7 +83,7 @@
8383
"typescript": "^5.7.3"
8484
},
8585
"dependencies": {
86-
"@kleros/kleros-v2-contracts": "^0.7.0",
87-
"@openzeppelin/contracts": "^5.2.0"
86+
"@kleros/kleros-v2-contracts": "^0.9.3",
87+
"@openzeppelin/contracts": "^5.3.0"
8888
}
8989
}

contracts/scripts/setDisputeTemplate.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ const parameters = {
66
arbitrumSepoliaDevnet: {
77
subgraphEndpoint:
88
"https://gateway.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/3aZxYcZpZL5BuVhuUupqVrCV8VeNyZEvjmPXibyPHDFQ",
9+
frontendUrl: "https://dev--kleros-escrow-v2.netlify.app/#/transactions/{{externalDisputeID}}",
910
},
1011
arbitrumSepoliaTestnet: {
1112
subgraphEndpoint: "TODO",
13+
frontendUrl: "TODO",
1214
},
1315
arbitrum: {
1416
subgraphEndpoint:
1517
"https://gateway.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/96vpnRJbRVkzF6usMNYMMoziSZEfSwGEDpXNi2h9WBSW",
18+
frontendUrl: "https://escrow-v2.kleros.builders/#/transactions/{{externalDisputeID}}",
1619
},
1720
};
1821

19-
const disputeTemplateFn = (chainId: number, klerosCore: string) => `{
22+
const disputeTemplateFn = (chainId: number, klerosCore: string, frontendUrl: string) => `{
2023
"$schema": "../NewDisputeTemplate.schema.json",
2124
"title": "Escrow dispute: {{escrowTitle}}",
2225
"description": "{{deliverableText}}",
@@ -43,7 +46,7 @@ const disputeTemplateFn = (chainId: number, klerosCore: string) => `{
4346
"label": "Transaction Terms",
4447
"uri": "{{{extraDescriptionUri}}}"
4548
},
46-
"frontendUrl": "https://escrow-v2.kleros.builders/#/transactions/{{externalDisputeID}}",
49+
"frontendUrl": "${frontendUrl}",
4750
"arbitratorChainID": "${chainId}",
4851
"arbitratorAddress": "${klerosCore}",
4952
"metadata": {
@@ -95,14 +98,14 @@ task("set-dispute-template", "Sets the dispute template").setAction(async (args,
9598
const { config, deployments } = hre;
9699
const { escrow, view, klerosCore } = await getContracts(hre);
97100
const networkName = await deployments.getNetworkName();
98-
const { subgraphEndpoint } = parameters[networkName];
101+
const { subgraphEndpoint, frontendUrl } = parameters[networkName];
99102
const chainId = config.networks[networkName].chainId;
100103

101104
if (!chainId || !klerosCore || !subgraphEndpoint) {
102105
throw new Error("Missing parameters");
103106
}
104107

105-
const disputeTemplate = disputeTemplateFn(chainId, klerosCore.target.toString());
108+
const disputeTemplate = disputeTemplateFn(chainId, klerosCore.target.toString(), frontendUrl);
106109
console.log("New disputeTemplate", disputeTemplate);
107110

108111
const mapping = mappingFn(subgraphEndpoint, view.target.toString());

subgraph/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/escrow-v2-subgraph",
3-
"version": "2.0.8",
3+
"version": "2.1.0",
44
"license": "MIT",
55
"scripts": {
66
"update:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia",
@@ -30,7 +30,7 @@
3030
"@graphprotocol/graph-cli": "0.95.0",
3131
"@kleros/escrow-v2-eslint-config": "workspace:^",
3232
"@kleros/escrow-v2-prettier-config": "workspace:^",
33-
"gluegun": "^5.1.2",
33+
"gluegun": "^5.2.0",
3434
"matchstick-as": "0.6.0"
3535
},
3636
"dependenciesComments": {

subgraph/subgraph.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ schema:
44
dataSources:
55
- kind: ethereum
66
name: EscrowUniversal
7-
network: arbitrum-one
7+
network: arbitrum-sepolia
88
source:
9-
address: '0x79530E7Bb3950A3a4b5a167816154715681F2f6c'
9+
address: '0x5ef185810BCe41c03c9E5ca271B8C91F1024F953'
1010
abi: EscrowUniversal
11-
startBlock: 305434342
11+
startBlock: 123526741
1212
mapping:
1313
kind: ethereum/events
1414
apiVersion: 0.0.6
@@ -22,7 +22,7 @@ dataSources:
2222
- SettlementProposal
2323
abis:
2424
- name: EscrowUniversal
25-
file: ../contracts/deployments/arbitrum/EscrowUniversal.json
25+
file: ../contracts/deployments/arbitrumSepoliaDevnet/EscrowUniversal.json
2626
eventHandlers:
2727
- event: Payment(indexed uint256,uint256,address)
2828
handler: handlePayment

web/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
"devDependencies": {
4646
"@graphql-codegen/cli": "^4.0.1",
4747
"@graphql-codegen/client-preset": "^4.6.2",
48+
"@kleros/kleros-v2-contracts": "^0.9.3",
4849
"@types/react": "^18.2.59",
4950
"@types/react-dom": "^18.2.18",
5051
"@types/react-modal": "^3.16.3",
5152
"@types/styled-components": "^5.1.34",
5253
"@typescript-eslint/eslint-plugin": "^5.62.0",
5354
"@typescript-eslint/parser": "^5.62.0",
5455
"@typescript-eslint/utils": "^5.62.0",
55-
"@wagmi/cli": "^2.1.15",
56+
"@wagmi/cli": "^2.2.1",
5657
"eslint": "^8.56.0",
5758
"eslint-config-prettier": "^8.10.0",
5859
"eslint-plugin-react": "^7.33.2",
@@ -66,7 +67,7 @@
6667
},
6768
"dependencies": {
6869
"@cyntler/react-doc-viewer": "^1.16.3",
69-
"@kleros/kleros-app": "^2.0.2",
70+
"@kleros/kleros-app": "^2.1.0",
7071
"@kleros/ui-components-library": "^2.19.0",
7172
"@reown/appkit": "^1.6.6",
7273
"@reown/appkit-adapter-wagmi": "^1.6.6",
@@ -78,7 +79,6 @@
7879
"chart.js": "^3.9.1",
7980
"chartjs-adapter-moment": "^1.0.1",
8081
"core-js": "^3.35.0",
81-
"ethers": "^5.7.2",
8282
"graphql": "^16.9.0",
8383
"graphql-request": "^7.1.2",
8484
"moment": "^2.30.1",
@@ -98,8 +98,8 @@
9898
"react-toastify": "^9.1.3",
9999
"react-use": "^17.4.3",
100100
"styled-components": "^5.3.11",
101-
"subgraph-status": "^1.2.3",
102-
"viem": "^2.22.22",
103-
"wagmi": "^2.14.10"
101+
"subgraph-status": "^1.2.4",
102+
"viem": "^2.27.2",
103+
"wagmi": "^2.14.16"
104104
}
105105
}

web/src/components/ScrollTop.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { useEffect, useRef } from "react";
2+
import { useLocation, useNavigate } from "react-router-dom";
3+
4+
import { useScrollTop } from "hooks/useScrollTop";
5+
6+
const ScrollTop: React.FC = () => {
7+
const scrollTop = useScrollTop();
8+
const { search, pathname } = useLocation();
9+
const navigate = useNavigate();
10+
const hasScrolled = useRef(false);
11+
12+
useEffect(() => {
13+
if (hasScrolled.current) return;
14+
const params = new URLSearchParams(search);
15+
const section = params.get("section");
16+
17+
if (section) {
18+
const targetElement = document.getElementById(section);
19+
if (targetElement) {
20+
targetElement.scrollIntoView({ behavior: "smooth" });
21+
hasScrolled.current = true;
22+
navigate(pathname, { replace: true });
23+
return;
24+
}
25+
}
26+
27+
scrollTop();
28+
}, []);
29+
30+
return null;
31+
};
32+
33+
export default ScrollTop;

web/src/hooks/queries/useArbitrationCostFromKlerosCore.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)