Skip to content

Commit

Permalink
fix: Enable 3085 requests for coinbase wallet (#2753)
Browse files Browse the repository at this point in the history
enable 3085 requests for coinbase wallet
  • Loading branch information
brendanww authored Nov 18, 2021
1 parent 82c0268 commit 9b0fa8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/state/application/updater.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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'
Expand All @@ -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()

Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 9b0fa8a

Please sign in to comment.