Skip to content

Commit 1277bec

Browse files
authored
Merge branch 'dev' into fix(web)/fix-links-and-modal-behavior
2 parents 173a2a5 + 5acd04a commit 1277bec

File tree

34 files changed

+3028
-3930
lines changed

34 files changed

+3028
-3930
lines changed

.github/workflows/deploy-subgraph.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
options:
1212
- arbitrum-goerli
1313
- arbitrum
14+
update:
15+
description: Whether to update the subgraph with the current artifacts for the selected network.
16+
required: true
17+
default: true
18+
type: boolean
1419

1520
permissions:
1621
contents: read
@@ -33,16 +38,38 @@ jobs:
3338
with:
3439
node-version: 16
3540

41+
- name: Install Yarn if running locally
42+
if: ${{ env.ACT }}
43+
run: npm install -g yarn
44+
3645
- name: Install the dependencies
3746
run: yarn install
3847

48+
- name: Install jq and yq
49+
if: ${{ inputs.update }}
50+
run: |
51+
mkdir bin
52+
wget -qO bin/jq https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64
53+
wget -qO bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
54+
chmod a+x bin/jq bin/yq
55+
56+
- name: Update the subgraph definition
57+
if: ${{ inputs.update }}
58+
run: |
59+
export PATH=$PWD/../bin:$PATH
60+
yarn update:${{ inputs.network }}
61+
working-directory: subgraph
62+
3963
- name: Build the subgraph
4064
run: |
4165
yarn codegen
4266
yarn build
43-
67+
working-directory: subgraph
68+
4469
- name: Authenticate with TheGraph
4570
run: yarn graph auth "${{ secrets.SUBGRAPH_AUTH_TOKEN }}" --product hosted-service
71+
working-directory: subgraph
4672

4773
- name: Deploy the subgraph
4874
run: yarn deploy:${{ inputs.network }}
75+
working-directory: subgraph

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ jobs:
8484

8585
# Upload the results to GitHub's code scanning dashboard.
8686
- name: "Upload to code-scanning"
87-
uses: github/codeql-action/upload-sarif@807578363a7869ca324a79039e6db9c843e0e100 # v2.1.27
87+
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
8888
with:
8989
sarif_file: results.sarif

contracts/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@
4141
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
4242
"@nomiclabs/hardhat-ethers": "^2.2.3",
4343
"@nomiclabs/hardhat-solhint": "^3.0.1",
44-
"@openzeppelin/contracts": "^4.9.1",
44+
"@openzeppelin/contracts": "^4.9.2",
4545
"@typechain/ethers-v5": "^11.0.0",
4646
"@typechain/hardhat": "^7.0.0",
4747
"@types/chai": "^4.3.5",
4848
"@types/mocha": "^10.0.1",
4949
"@types/node": "^16.18.36",
5050
"chai": "^4.3.7",
51-
"dotenv": "^16.1.4",
51+
"dotenv": "^16.3.1",
5252
"ethereumjs-util": "^7.1.5",
5353
"ethers": "^5.7.2",
5454
"hardhat": "^2.15.0",
5555
"hardhat-contract-sizer": "^2.10.0",
56-
"hardhat-deploy": "^0.11.30",
56+
"hardhat-deploy": "^0.11.31",
5757
"hardhat-deploy-ethers": "^0.4.0-next.1",
5858
"hardhat-deploy-tenderly": "^0.2.0",
5959
"hardhat-docgen": "^1.3.0",

prettier-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"eslint": "^8.42.0",
7+
"eslint": "^8.43.0",
88
"prettier": "^2.8.8",
99
"prettier-plugin-solidity": "^1.1.3"
1010
},

scripts/act-subgraph.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
act workflow_dispatch -j buildAndDeploy --input network=arbitrum-goerli,update=true

scripts/check-prerequisites.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ function require() #cmd
1111
fi
1212
}
1313

14+
# for the NPM and toolchain version management
15+
require volta
16+
17+
# for the local subgraph node
1418
require docker
1519
require docker-compose
20+
21+
# for some contracts utilities
22+
require cast
23+
require forge
24+
25+
# for the subgraph and contracts utilities
1626
require jq
1727
require yq
18-
require volta
28+
29+
# for the local testing of Github Actions
30+
require act
1931

2032
exit $status

web/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@
6565
"@sentry/react": "^7.55.2",
6666
"@sentry/tracing": "^7.55.2",
6767
"@types/react-modal": "^3.16.0",
68-
"@web3-react/core": "^6.1.9",
69-
"@web3-react/injected-connector": "^6.0.7",
70-
"@web3-react/types": "^6.0.7",
7168
"@web3modal/ethereum": "^2.2.2",
7269
"@web3modal/react": "^2.2.2",
7370
"chart.js": "^3.9.1",

web/src/app.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import { Routes, Route } from "react-router-dom";
55
import "react-loading-skeleton/dist/skeleton.css";
66
import Web3Provider from "context/Web3Provider";
77
import StyledComponentsProvider from "context/StyledComponentsProvider";
8-
import WrongChainBoundary from "components/WrongChainBoundary";
98
import Layout from "layout/index";
109
import Home from "./pages/Home";
1110
import Cases from "./pages/Cases";
1211
import Dashboard from "./pages/Dashboard";
1312
import Courts from "./pages/Courts";
14-
1513
import "react-toastify/dist/ReactToastify.css";
1614

1715
const fetcherBuilder =
@@ -27,26 +25,20 @@ const App: React.FC = () => {
2725
<SWRConfig
2826
value={{
2927
fetcher: fetcherBuilder(
30-
process.env.REACT_APP_SUBGRAPH_ENDPOINT ??
31-
"https://api.thegraph.com/subgraphs/name/alcercu/kleroscoretest"
28+
process.env.REACT_APP_SUBGRAPH_ENDPOINT ?? "https://api.thegraph.com/subgraphs/name/alcercu/kleroscoretest"
3229
),
3330
}}
3431
>
3532
<Web3Provider>
36-
<WrongChainBoundary>
37-
<Routes>
38-
<Route path="/" element={<Layout />}>
39-
<Route index element={<Home />} />
40-
<Route path="cases/*" element={<Cases />} />
41-
<Route path="courts/*" element={<Courts />} />
42-
<Route path="dashboard" element={<Dashboard />} />
43-
<Route
44-
path="*"
45-
element={<h1>Justice not found here ¯\_( ͡° ͜ʖ ͡°)_/¯</h1>}
46-
/>
47-
</Route>
48-
</Routes>
49-
</WrongChainBoundary>
33+
<Routes>
34+
<Route path="/" element={<Layout />}>
35+
<Route index element={<Home />} />
36+
<Route path="cases/*" element={<Cases />} />
37+
<Route path="courts/*" element={<Courts />} />
38+
<Route path="dashboard" element={<Dashboard />} />
39+
<Route path="*" element={<h1>Justice not found here ¯\_( ͡° ͜ʖ ͡°)_/¯</h1>} />
40+
</Route>
41+
</Routes>
5042
</Web3Provider>
5143
</SWRConfig>
5244
</StyledComponentsProvider>
Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
import React from "react";
22
import styled from "styled-components";
3-
import { useAccount, useNetwork } from "wagmi";
4-
import { arbitrumGoerli } from "wagmi/chains";
3+
import { useAccount, useNetwork, useSwitchNetwork } from "wagmi";
54
import { useWeb3Modal } from "@web3modal/react";
65
import { shortenAddress } from "utils/shortenAddress";
76
import { Button } from "@kleros/ui-components-library";
8-
9-
const AccountDisplay: React.FC = () => {
10-
return (
11-
<StyledContainer>
12-
<ChainDisplay />
13-
<AddressDisplay />
14-
</StyledContainer>
15-
);
16-
};
17-
18-
export const ChainDisplay: React.FC = () => {
19-
const { chain } = useNetwork();
20-
return <small>{chain?.name}</small>;
21-
};
22-
23-
export const AddressDisplay: React.FC = () => {
24-
const { address } = useAccount();
25-
return <label>{address && shortenAddress(address)}</label>;
26-
};
7+
import { SUPPORTED_CHAINS, DEFAULT_CHAIN } from "consts/chains";
278

289
const StyledContainer = styled.div`
2910
width: fit-content;
@@ -46,15 +27,63 @@ const StyledContainer = styled.div`
4627
}
4728
`;
4829

30+
const AccountDisplay: React.FC = () => {
31+
return (
32+
<StyledContainer>
33+
<ChainDisplay />
34+
<AddressDisplay />
35+
</StyledContainer>
36+
);
37+
};
38+
39+
export const ChainDisplay: React.FC = () => {
40+
const { chain } = useNetwork();
41+
return <small>{chain?.name}</small>;
42+
};
43+
44+
export const AddressDisplay: React.FC = () => {
45+
const { address } = useAccount();
46+
return <label>{address && shortenAddress(address)}</label>;
47+
};
48+
49+
export const SwitchChainButton: React.FC = () => {
50+
const { switchNetwork, isLoading } = useSwitchNetwork();
51+
const handleSwitch = () => {
52+
if (!switchNetwork) {
53+
console.error("Cannot switch network. Please do it manually.");
54+
return;
55+
}
56+
try {
57+
switchNetwork(DEFAULT_CHAIN);
58+
} catch (err) {
59+
console.error(err);
60+
}
61+
};
62+
return (
63+
<Button
64+
isLoading={isLoading}
65+
disabled={isLoading}
66+
text={`Switch to ${SUPPORTED_CHAINS[DEFAULT_CHAIN].chainName}`}
67+
onClick={handleSwitch}
68+
/>
69+
);
70+
};
71+
4972
const ConnectButton: React.FC = () => {
50-
const { isConnected } = useAccount();
51-
const { open, setDefaultChain, isOpen } = useWeb3Modal();
52-
setDefaultChain(arbitrumGoerli);
53-
return isConnected ? (
54-
<AccountDisplay />
55-
) : (
73+
const { open, isOpen } = useWeb3Modal();
74+
return (
5675
<Button disabled={isOpen} small text={"Connect"} onClick={async () => await open({ route: "ConnectWallet" })} />
5776
);
5877
};
5978

60-
export default ConnectButton;
79+
const ConnectWallet: React.FC = () => {
80+
const { chain } = useNetwork();
81+
const { isConnected } = useAccount();
82+
if (isConnected) {
83+
if (chain && chain.id !== DEFAULT_CHAIN) {
84+
return <SwitchChainButton />;
85+
} else return <AccountDisplay />;
86+
} else return <ConnectButton />;
87+
};
88+
89+
export default ConnectWallet;

web/src/components/DisputeCard/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const StyledCard = styled(Card)`
1616
min-width: 312px;
1717
width: auto;
1818
height: 260px;
19+
20+
.react-loading-skeleton {
21+
z-index: 0;
22+
}
1923
`;
2024

2125
const Container = styled.div`

web/src/components/EnsureChain.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react";
2+
import { DEFAULT_CHAIN } from "consts/chains";
3+
import { useNetwork } from "wagmi";
4+
import ConnectWallet from "components/ConnectWallet";
5+
6+
interface IEnsureChain {
7+
children: React.ReactElement;
8+
}
9+
10+
export const EnsureChain: React.FC<IEnsureChain> = ({ children }) => {
11+
const { chain } = useNetwork();
12+
13+
return chain && chain.id === DEFAULT_CHAIN ? children : <ConnectWallet />;
14+
};

web/src/components/Overlay.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import styled from "styled-components";
2+
3+
export const Overlay = styled.div`
4+
position: fixed;
5+
top: 0;
6+
left: 0;
7+
width: 100vw;
8+
height: 100vh;
9+
background-color: ${({ theme }) => theme.blackLowOpacity};
10+
z-index: 1;
11+
`;

web/src/components/WrongChainBoundary.tsx

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

web/src/connectors/injected.ts

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

0 commit comments

Comments
 (0)