File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Spin } from '~/adapters/antd' ;
3+ import { NETWORKS } from '~/consts/supportedChains' ;
4+
5+ import { useWeb3 } from '~/hooks/useWeb3' ;
6+
7+ export const withRedirectFromMainnet = WrappedComponent => {
8+ const WithRedirectFromMainnet = props => {
9+ const { chainId } = useWeb3 ( ) ;
10+ const isOnMainnet = chainId === NETWORKS . ethereum ;
11+
12+ return isOnMainnet ? (
13+ < Spin $centered spinning = { isOnMainnet } tip = "Waiting for network redirection" />
14+ ) : (
15+ < WrappedComponent { ...props } />
16+ ) ;
17+ } ;
18+ WithRedirectFromMainnet . displayName = `withRedirectFromMainnet(${
19+ WrappedComponent . displayName || WrappedComponent . name || 'Component'
20+ } )`;
21+
22+ return WithRedirectFromMainnet ;
23+ } ;
You can’t perform that action at this time.
0 commit comments