Skip to content

Commit b3a23ab

Browse files
committed
feat: add UnsupportedChain component to handle unsupported blockchain scenarios
1 parent de7aed3 commit b3a23ab

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { SUPPORTED_CHAINS } from '@/config';
2+
import { Terminal } from 'lucide-react';
3+
import useUserStore from '@/stores/useUser.store';
4+
import { Alert, AlertDescription, AlertTitle } from './ui/alert';
5+
6+
const SUPPORTED_CHAIN_IDS = SUPPORTED_CHAINS.map((chain) => chain.id);
7+
8+
export function UnsupportedChain() {
9+
const { chainId } = useUserStore();
10+
11+
const isChainSupported =
12+
chainId !== undefined && SUPPORTED_CHAIN_IDS.includes(chainId);
13+
14+
if (isChainSupported) {
15+
return null;
16+
}
17+
18+
return (
19+
<Alert variant="destructive" className="mx-auto mt-8 text-left">
20+
<Terminal className="h-4 w-4" />
21+
<AlertTitle>Error</AlertTitle>
22+
<AlertDescription>
23+
It seems that you are using a chain that is not supported.
24+
</AlertDescription>
25+
</Alert>
26+
);
27+
}

src/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
export const PREVIEW_TABLE_LENGTH = 5;
22
export const PREVIEW_TABLE_REFETCH_INTERVAL = 10_000;
3+
export const SUPPORTED_CHAINS = [
4+
{
5+
id: 134,
6+
name: 'Bellecour',
7+
icon: 'src/assets/iexec-logo.svg',
8+
blockExplorerUrl: 'https://blockscout-bellecour.iex.ec',
9+
subgraphUrl: 'https://thegraph.iex.ec/subgraphs/name/bellecour/poco-v5',
10+
},
11+
];

src/routes/__root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createRootRoute, Outlet } from '@tanstack/react-router';
22
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools';
33
import { Footer } from '@/components/Footer';
4+
import { UnsupportedChain } from '@/components/UnsupportedChain';
45
import { Navbar } from '@/components/navbar/NavBar';
56
import { useSyncAccountWithUserStore } from '@/hooks/useSyncAccountWithUserStore';
67

@@ -14,6 +15,7 @@ function Root() {
1415
return (
1516
<div className="mx-auto mb-20 w-full px-6 md:px-10 lg:px-20">
1617
<Navbar />
18+
<UnsupportedChain />
1719
<Outlet />
1820
<Footer className="mt-32" />
1921
<TanStackRouterDevtools />

0 commit comments

Comments
 (0)