Skip to content

Commit

Permalink
fix: show connect to ethereum button for unsupported chains (#536)
Browse files Browse the repository at this point in the history
* fix: show connect to ethereum button for unsupported chains

* fix: correct logic

* fix: check supported token chain id
  • Loading branch information
just-toby authored Mar 7, 2023
1 parent f74946e commit ee28857
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/Swap/SwapActionButton/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -36,9 +37,10 @@ export default function SwapActionButton() {

if (!account || !isActive) {
return <ConnectWalletButton />
} else if (error === ChainError.MISMATCHED_CHAINS) {
const tokenChainId = inputCurrency?.chainId ?? outputCurrency?.chainId ?? SupportedChainId.MAINNET
return <SwitchChainButton chainId={tokenChainId} />
} else if (error === ChainError.MISMATCHED_CHAINS || error === ChainError.UNSUPPORTED_CHAIN) {
const tokenChainId = inputCurrency?.chainId ?? outputCurrency?.chainId
const supportedTokenChainId = isSupportedChainId(tokenChainId) ? tokenChainId : SupportedChainId.MAINNET
return <SwitchChainButton chainId={supportedTokenChainId} />
} else if (isWrap) {
return <WrapButton disabled={isDisabled} />
} else {
Expand Down

1 comment on commit ee28857

@vercel
Copy link

@vercel vercel bot commented on ee28857 Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-seven-tau.vercel.app
widgets-git-main-uniswap.vercel.app
widgets-uniswap.vercel.app

Please sign in to comment.