diff --git a/hooks/useIsUnsupportedChain.ts b/hooks/useIsUnsupportedChain.ts index c21935d7b..309deb4c3 100644 --- a/hooks/useIsUnsupportedChain.ts +++ b/hooks/useIsUnsupportedChain.ts @@ -1,29 +1,48 @@ +import { reservoirChains } from '@reservoir0x/reservoir-sdk' import { useEffect, useState } from 'react' import { useNetwork } from 'wagmi' -interface Chain { - name: string - chainId: number -} +type Chain = Omit<(typeof reservoirChains)['mainnet'], 'websocketUrl'> const TESTNET_CHAINS: Chain[] = [ - { name: 'Goerli', chainId: 5 }, - { name: 'Sepolia', chainId: 11155111 }, - { name: 'Polygon Mumbai', chainId: 80001 }, - { name: 'BaseGoerli', chainId: 84531 }, - { name: 'Scroll Testnet', chainId: 534352 }, - { name: 'Zora Testnet', chainId: 999 }, + reservoirChains.goerli, + reservoirChains.sepolia, + reservoirChains.mumbai, + reservoirChains.baseGoerli, + reservoirChains.scrollTestnet, + reservoirChains.zoraTestnet, +] + +const MAINNET_CHAINS: Chain[] = [ + reservoirChains.mainnet, + reservoirChains.polygon, + reservoirChains.arbitrum, + reservoirChains.optimism, + reservoirChains.zora, + reservoirChains.bsc, + reservoirChains.avalanche, + reservoirChains.base, + reservoirChains.linea, + reservoirChains.zkSync, + reservoirChains.polygonZkEvm, + reservoirChains.scroll, ] +const IS_TESTNET_DEPLOYMENT = process.env.NEXT_PUBLIC_HOST_URL?.includes( + 'testnets.reservoir.tools' +) + export default () => { - const [unsupportedChain, setUnsupportedChain] = useState< - { name: string; chainId: number } | undefined - >(undefined) + const [unsupportedChain, setUnsupportedChain] = useState( + undefined + ) const { chain } = useNetwork() useEffect(() => { setUnsupportedChain( - TESTNET_CHAINS.find(({ chainId }) => chain?.id === chainId) + (IS_TESTNET_DEPLOYMENT ? TESTNET_CHAINS : MAINNET_CHAINS).find( + ({ id }) => chain?.id === id + ) ) }, [chain]) return {