Commit c3d2c438 authored by eddie's avatar eddie Committed by GitHub

fix: unsupported chain bugs (#6098)

* feat: upgrade widget again

* fix: verify chainId is supported
parent de5816e5
......@@ -16,6 +16,7 @@ import {
getIsInjected,
getIsMetaMaskWallet,
} from 'connection/utils'
import { isSupportedChain } from 'constants/chains'
import usePrevious from 'hooks/usePrevious'
import { useCallback, useEffect, useState } from 'react'
import { ArrowLeft } from 'react-feather'
......@@ -207,7 +208,7 @@ export default function WalletModal({
// Keep the network connector in sync with any active user connector to prevent chain-switching on wallet disconnection.
useEffect(() => {
if (chainId && connector !== networkConnection.connector) {
if (chainId && isSupportedChain(chainId) && connector !== networkConnection.connector) {
networkConnection.connector.activate(chainId)
}
}, [chainId, connector])
......
......@@ -3,6 +3,7 @@ import { InterfaceSectionName, SwapEventName } from '@uniswap/analytics-events'
import { Currency, Field, SwapController, SwapEventHandlers, TradeType } from '@uniswap/widgets'
import { useWeb3React } from '@web3-react/core'
import CurrencySearchModal from 'components/SearchModal/CurrencySearchModal'
import { isSupportedChain } from 'constants/chains'
import usePrevious from 'hooks/usePrevious'
import { useCallback, useEffect, useMemo, useState } from 'react'
......@@ -50,7 +51,7 @@ export function useSyncWidgetInputs({
}, [defaultTokens, tokens])
useEffect(() => {
if (chainId !== previousChainId && !!previousChainId) {
if (chainId !== previousChainId && !!previousChainId && isSupportedChain(chainId)) {
setTokens({
...tokens,
[Field.INPUT]: undefined,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment