diff --git a/src/state/application/updater.ts b/src/state/application/updater.ts index afd8a9b7a2..757fc0de2d 100644 --- a/src/state/application/updater.ts +++ b/src/state/application/updater.ts @@ -1,5 +1,3 @@ -import { InjectedConnector } from '@web3-react/injected-connector' -import { WalletLinkConnector } from '@web3-react/walletlink-connector' import useDebounce from 'hooks/useDebounce' import useIsWindowVisible from 'hooks/useIsWindowVisible' import { useActiveWeb3React } from 'hooks/web3' @@ -79,19 +77,19 @@ export default function Updater(): null { ) }, [dispatch, debouncedState.chainId]) + const implements3085 = useAppSelector((state) => state.application.implements3085) + useEffect(() => { - const isCbWalletDappBrowser = window?.ethereum?.isCoinbaseWallet - const isWalletlink = - connector instanceof WalletLinkConnector || (connector instanceof InjectedConnector && window.walletLinkExtension) - const isCbWallet = isCbWalletDappBrowser || isWalletlink - const isMetamaskOrCbWallet = library?.provider?.isMetaMask || isCbWallet - if (!account || !library?.provider?.request || !isMetamaskOrCbWallet) { - return + if (!library?.provider?.request) { + dispatch(setImplements3085({ implements3085: false })) + } else if (account && !implements3085) { + switchToNetwork({ library }) + .then((x) => x ?? dispatch(setImplements3085({ implements3085: true }))) + .catch(() => dispatch(setImplements3085({ implements3085: false }))) + } else if (!account && implements3085) { + dispatch(setImplements3085({ implements3085: false })) } - switchToNetwork({ library }) - .then((x) => x ?? dispatch(setImplements3085({ implements3085: true }))) - .catch(() => dispatch(setImplements3085({ implements3085: false }))) - }, [account, chainId, dispatch, library]) + }, [account, dispatch, implements3085, library]) return null }