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 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 })))
}, [account, chainId, dispatch, library])
} else if (!account && implements3085) {
dispatch(setImplements3085({ implements3085: false }))
}
}, [account, dispatch, implements3085, library])
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