Commit 262d984f authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

check for support on all connectors, and disable when the connector (or lack...

check for support on all connectors, and disable when the connector (or lack thereof) no longer supports 3085 (#2824)
parent 7781f511
import { InjectedConnector } from '@web3-react/injected-connector'
import { WalletLinkConnector } from '@web3-react/walletlink-connector'
import useDebounce from 'hooks/useDebounce' import useDebounce from 'hooks/useDebounce'
import useIsWindowVisible from 'hooks/useIsWindowVisible' import useIsWindowVisible from 'hooks/useIsWindowVisible'
import { useActiveWeb3React } from 'hooks/web3' import { useActiveWeb3React } from 'hooks/web3'
...@@ -79,19 +77,19 @@ export default function Updater(): null { ...@@ -79,19 +77,19 @@ export default function Updater(): null {
) )
}, [dispatch, debouncedState.chainId]) }, [dispatch, debouncedState.chainId])
const implements3085 = useAppSelector((state) => state.application.implements3085)
useEffect(() => { useEffect(() => {
const isCbWalletDappBrowser = window?.ethereum?.isCoinbaseWallet if (!library?.provider?.request) {
const isWalletlink = dispatch(setImplements3085({ implements3085: false }))
connector instanceof WalletLinkConnector || (connector instanceof InjectedConnector && window.walletLinkExtension) } else if (account && !implements3085) {
const isCbWallet = isCbWalletDappBrowser || isWalletlink switchToNetwork({ library })
const isMetamaskOrCbWallet = library?.provider?.isMetaMask || isCbWallet .then((x) => x ?? dispatch(setImplements3085({ implements3085: true })))
if (!account || !library?.provider?.request || !isMetamaskOrCbWallet) { .catch(() => dispatch(setImplements3085({ implements3085: false })))
return } else if (!account && implements3085) {
dispatch(setImplements3085({ implements3085: false }))
} }
switchToNetwork({ library }) }, [account, dispatch, implements3085, library])
.then((x) => x ?? dispatch(setImplements3085({ implements3085: true })))
.catch(() => dispatch(setImplements3085({ implements3085: false })))
}, [account, chainId, dispatch, library])
return null return null
} }
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