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