From ee288577478bb761fba04da150572e71c5263691 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Tue, 7 Mar 2023 13:35:51 -0800 Subject: [PATCH] fix: show connect to ethereum button for unsupported chains (#536) * fix: show connect to ethereum button for unsupported chains * fix: correct logic * fix: check supported token chain id --- src/components/Swap/SwapActionButton/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Swap/SwapActionButton/index.tsx b/src/components/Swap/SwapActionButton/index.tsx index 874ce10de..f7a6b8e73 100644 --- a/src/components/Swap/SwapActionButton/index.tsx +++ b/src/components/Swap/SwapActionButton/index.tsx @@ -1,4 +1,5 @@ import { useWeb3React } from '@web3-react/core' +import { isSupportedChainId } from 'constants/chainInfo' import { SupportedChainId } from 'constants/chains' import { ChainError, useSwapInfo } from 'hooks/swap' import { SwapApprovalState } from 'hooks/swap/useSwapApproval' @@ -36,9 +37,10 @@ export default function SwapActionButton() { if (!account || !isActive) { return - } else if (error === ChainError.MISMATCHED_CHAINS) { - const tokenChainId = inputCurrency?.chainId ?? outputCurrency?.chainId ?? SupportedChainId.MAINNET - return + } else if (error === ChainError.MISMATCHED_CHAINS || error === ChainError.UNSUPPORTED_CHAIN) { + const tokenChainId = inputCurrency?.chainId ?? outputCurrency?.chainId + const supportedTokenChainId = isSupportedChainId(tokenChainId) ? tokenChainId : SupportedChainId.MAINNET + return } else if (isWrap) { return } else {