From fc466e0237b5e7d7595e3d05b3dd1399785545e7 Mon Sep 17 00:00:00 2001 From: "Michael D. Norman" Date: Thu, 12 May 2022 08:37:41 -0500 Subject: [PATCH] chore: [#3] don't try to connect to mainnet at startup --- hooks/useWallet.tsx | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/hooks/useWallet.tsx b/hooks/useWallet.tsx index ec37583..320fc6d 100644 --- a/hooks/useWallet.tsx +++ b/hooks/useWallet.tsx @@ -2,7 +2,7 @@ import { Provider } from '@ethersproject/abstract-provider'; import { JsonRpcProvider } from '@ethersproject/providers'; import WalletConnectProvider from '@walletconnect/web3-provider'; -import { ethers, providers } from 'ethers'; +import { providers } from 'ethers'; import { useCallback, useEffect } from 'react'; import Web3Modal from 'web3modal'; import { useAppContext } from '../context/StateProvider'; @@ -18,6 +18,7 @@ const providerOptions = { }, }, }; + let web3Modal: any; if (typeof window !== 'undefined') { web3Modal = new Web3Modal({ @@ -80,26 +81,8 @@ const useWallet = (): WalletHook => { if (web3Modal.cachedProvider) { // noinspection JSIgnoredPromiseFromCall connect(); - } else { - const rpcProvider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/' + INFURA_ID); - dispatch({ - type: ActionTypes.initialWeb3Provider, - payload: { - web3Provider: rpcProvider, - }, - }); } }, []); - // useEffect(() => { - // if (provider) { - // if (state.chainId !== Number("0x13881")) { - // provider?.request({ - // method: "wallet_switchEthereumChain", - // params: [{ chainId: "0x13881" }], - // }); - // } - // } - // }, [state, provider]); useEffect(() => { if (provider?.on) {