Skip to content

Commit 1252cab

Browse files
committed
fix: handle wrong networks
1 parent f293528 commit 1252cab

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

bridge-ui/src/components/bridge/modals/ManualClaimModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ManualClaimModal: React.FC<ManualClaimModalProps> = ({ handleNoClose, hand
2323
No
2424
</Button>
2525
<Link
26-
href="#"
26+
href="https://docs.linea.build/developers/guides/bridge/how-to-bridge-eth"
2727
rel="noopener noreferrer"
2828
target="_blank"
2929
className="hover:border-b-1 border-b-1 btn btn-ghost btn-sm rounded-none border-b-primary p-0 font-normal text-[#E5E5E5] hover:border-b-primary hover:bg-transparent"

bridge-ui/src/components/layouts/Layout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ import { ToastContainer } from "react-toastify";
44
import { Header } from "./header";
55
import { useInitialiseChain, useInitialiseToken } from "@/hooks";
66
import Sidebar from "./Sidebar";
7+
import { useAccount } from "wagmi";
8+
import { linea, lineaSepolia, mainnet, sepolia } from "viem/chains";
9+
import WrongNetwork from "./WrongNetwork";
710

811
export function Layout({ children }: { children: React.ReactNode }) {
912
useInitialiseChain();
1013
useInitialiseToken();
1114

12-
return (
15+
const { chainId } = useAccount();
16+
17+
return chainId &&
18+
![mainnet.id, sepolia.id, linea.id, lineaSepolia.id].includes(chainId as 1 | 11155111 | 59144 | 59141) ? (
19+
<WrongNetwork />
20+
) : (
1321
<div className="flex min-h-screen flex-col bg-cover bg-no-repeat">
1422
<ToastContainer
1523
position="top-center"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { switchChain } from "@wagmi/core";
2+
import Image from "next/image";
3+
import { linea, lineaSepolia, mainnet, sepolia } from "viem/chains";
4+
import { wagmiConfig } from "@/config";
5+
import { Button } from "../ui";
6+
7+
const supportedChains = [
8+
{
9+
title: "Ethereum",
10+
iconPath: "/images/logo/ethereum-rounded.svg",
11+
chainId: mainnet.id,
12+
},
13+
{
14+
title: "Linea Mainnet",
15+
iconPath: "/images/logo/linea-mainnet.svg",
16+
chainId: linea.id,
17+
},
18+
{
19+
title: "Sepolia",
20+
iconPath: "/images/logo/ethereum-rounded.svg",
21+
chainId: sepolia.id,
22+
},
23+
{
24+
title: "Linea Sepolia",
25+
iconPath: "/images/logo/linea-sepolia.svg",
26+
chainId: lineaSepolia.id,
27+
},
28+
];
29+
30+
export default function WrongNetwork() {
31+
return (
32+
<div className="flex min-h-screen items-center justify-center bg-cover bg-no-repeat p-8">
33+
<div className="flex min-w-fit flex-col items-center gap-8 rounded-lg border-2 border-card bg-cardBg p-8">
34+
<span className="text-center">
35+
This app doesn&apos;t support your current network. Switch to an available option to continue.
36+
</span>
37+
<div className="flex flex-col gap-4">
38+
{supportedChains.map(({ title, iconPath, chainId }) => (
39+
<div key={`dropdown-item-${title}`}>
40+
<Button
41+
className={"w-full justify-start"}
42+
size="sm"
43+
variant="outline"
44+
onClick={() => switchChain(wagmiConfig, { chainId })}
45+
>
46+
<Image src={iconPath} alt={title} width={18} height={18} style={{ width: "18px", height: "auto" }} />
47+
{title}
48+
</Button>
49+
</div>
50+
))}
51+
</div>
52+
</div>
53+
</div>
54+
);
55+
}

0 commit comments

Comments
 (0)