/ src / components / AddressBlocked.tsx
AddressBlocked.tsx
 1  import { ReactNode } from 'react';
 2  import { useAddressAllowed } from 'src/hooks/useAddressAllowed';
 3  import { MainLayout } from 'src/layouts/MainLayout';
 4  import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
 5  import { ENABLE_TESTNET } from 'src/utils/marketsAndNetworksConfig';
 6  import { useDisconnect } from 'wagmi';
 7  
 8  import { AddressBlockedModal } from './AddressBlockedModal';
 9  
10  export const AddressBlocked = ({ children }: { children: ReactNode }) => {
11    const { currentAccount, readOnlyMode } = useWeb3Context();
12    const { disconnect } = useDisconnect();
13    const screenAddress = readOnlyMode || ENABLE_TESTNET ? '' : currentAccount;
14    const { isAllowed } = useAddressAllowed(screenAddress);
15  
16    if (!isAllowed) {
17      return (
18        <MainLayout>
19          <AddressBlockedModal address={currentAccount} onDisconnectWallet={() => disconnect()} />;
20        </MainLayout>
21      );
22    }
23  
24    return <>{children}</>;
25  };