Skip to content

Commit

Permalink
check for support on all connectors, and disable when the connector (…
Browse files Browse the repository at this point in the history
…or lack thereof) no longer supports 3085 (#2824)
  • Loading branch information
JFrankfurt authored Nov 22, 2021
1 parent 7781f51 commit 262d984
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/state/application/updater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
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 Down Expand Up @@ -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 })))
} else if (!account && implements3085) {
dispatch(setImplements3085({ implements3085: false }))
}
switchToNetwork({ library })
.then((x) => x ?? dispatch(setImplements3085({ implements3085: true })))
.catch(() => dispatch(setImplements3085({ implements3085: false })))
}, [account, chainId, dispatch, library])
}, [account, dispatch, implements3085, library])

return null
}

0 comments on commit 262d984

Please sign in to comment.