diff --git a/src/constants/index.ts b/src/constants/index.ts index 287f57bac7..4711fc4648 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -317,27 +317,9 @@ export const CHAINS_SUPPORT_CROSS_CHAIN = ChainId.ARBITRUM, ChainId.OPTIMISM, ChainId.FANTOM, + ChainId.LINEA, ] - : [ - ChainId.MAINNET, - ChainId.GĂ–RLI, - ChainId.MATIC, - ChainId.MUMBAI, - ChainId.BSCTESTNET, - ChainId.BSCMAINNET, - ChainId.AVAXTESTNET, - ChainId.AVAXMAINNET, - ChainId.FANTOM, - ChainId.CRONOS, - ChainId.ARBITRUM, - ChainId.BTTC, - ChainId.VELAS, - ChainId.AURORA, - ChainId.OASIS, - ChainId.OPTIMISM, - ChainId.ZKSYNC, - ChainId.SOLANA, - ] + : SUPPORTED_NETWORKS export const TYPE_AND_SWAP_NOT_SUPPORTED_CHAINS: ChainId[] = [ChainId.ZKSYNC, ChainId.LINEA_TESTNET, ChainId.LINEA] diff --git a/src/pages/CrossChain/index.tsx b/src/pages/CrossChain/index.tsx index 5d6c17a7bb..7c33a645ce 100644 --- a/src/pages/CrossChain/index.tsx +++ b/src/pages/CrossChain/index.tsx @@ -1,6 +1,6 @@ import { Squid } from '@0xsquid/sdk' import { Trans } from '@lingui/macro' -import { memo, useEffect, useMemo, useRef } from 'react' +import { memo, useEffect, useRef } from 'react' import { Navigate } from 'react-router-dom' import { Flex, Text } from 'rebass' @@ -21,8 +21,7 @@ export const getAxelarScanUrl = (srcTxHash: string) => `${CROSS_CHAIN_CONFIG.AXE function CrossChain({ visible }: { visible: boolean }) { const theme = useTheme() const { chainId, isSolana } = useActiveWeb3React() - const [{ squidInstance, chainIdOut, chains }, setCrossChainState] = useCrossChainState() - const listChainOut = useMemo(() => chains.filter(e => e !== chainId), [chains, chainId]) + const [{ squidInstance, chainIdOut, listChainOut }, setCrossChainState] = useCrossChainState() const curChainId = useRef(chainId) @@ -48,10 +47,11 @@ function CrossChain({ visible }: { visible: boolean }) { let squid = squidInstance if (loading.current) return loading.current = true + const config = { baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID } if (!squid) { - squid = new Squid({ baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID }) + squid = new Squid(config) } else { - squid.setConfig({ baseUrl: CROSS_CHAIN_CONFIG.API_DOMAIN, integratorId: CROSS_CHAIN_CONFIG.INTEGRATOR_ID }) + squid.setConfig(config) } await squid.init() const { chains = [], tokens = [] } = squid diff --git a/src/state/crossChain/hooks.ts b/src/state/crossChain/hooks.ts index cc589e7c4e..d212c79721 100644 --- a/src/state/crossChain/hooks.ts +++ b/src/state/crossChain/hooks.ts @@ -3,6 +3,7 @@ import { ChainId, NativeCurrency } from '@kyberswap/ks-sdk-core' import { useCallback, useMemo } from 'react' import { useDispatch, useSelector } from 'react-redux' +import { CHAINS_SUPPORT_CROSS_CHAIN } from 'constants/index' import { useActiveWeb3React } from 'hooks' import { MultiChainTokenInfo } from 'pages/Bridge/type' import { AppDispatch, AppState } from 'state' @@ -100,7 +101,10 @@ export function useCrossChainState(): [ const { chainId } = useActiveWeb3React() const setState = useCallback((data: CrossChainStateParams) => dispatch(setCrossChainState(data)), [dispatch]) - const listChainOut = useMemo(() => chains.filter(e => e !== chainId), [chains, chainId]) + const listChainOut = useMemo( + () => chains.filter(e => e !== chainId && CHAINS_SUPPORT_CROSS_CHAIN.includes(e)), + [chains, chainId], + ) const listTokenOut = useMemo(() => tokens.filter(e => e.chainId === chainIdOut), [tokens, chainIdOut]) const listTokenIn = useMemo(() => tokens.filter(e => e.chainId === chainId), [tokens, chainId])