Commit 9b0fa8a2 authored by Brendan Weinstein's avatar Brendan Weinstein Committed by GitHub

fix: Enable 3085 requests for coinbase wallet (#2753)

enable 3085 requests for coinbase wallet
parent 82c02687
......@@ -7,7 +7,11 @@ declare module '@metamask/jazzicon' {
declare module 'fortmatic'
interface Window {
// walletLinkExtension is injected by the Coinbase Wallet extension
walletLinkExtension?: any
ethereum?: {
// value that is populated and returns true by the Coinbase Wallet mobile dapp browser
isCoinbaseWallet?: true
isMetaMask?: true
on?: (...args: any[]) => void
removeListener?: (...args: any[]) => void
......
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'
......@@ -23,7 +25,7 @@ function useQueryCacheInvalidator() {
}
export default function Updater(): null {
const { account, chainId, library } = useActiveWeb3React()
const { account, chainId, library, connector } = useActiveWeb3React()
const dispatch = useAppDispatch()
const windowVisible = useIsWindowVisible()
......@@ -78,7 +80,12 @@ export default function Updater(): null {
}, [dispatch, debouncedState.chainId])
useEffect(() => {
if (!account || !library?.provider?.request || !library?.provider?.isMetaMask) {
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
}
switchToNetwork({ library })
......
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