diff --git a/src/hooks/useAccount.tsx b/src/hooks/useAccount.tsx index 7917dd8f33..f739b7a533 100644 --- a/src/hooks/useAccount.tsx +++ b/src/hooks/useAccount.tsx @@ -1,11 +1,9 @@ -import { useEffect, useState } from 'react'; import { useConnectWallet, useSetChain } from '@web3-onboard/react'; import { ethers } from 'ethers'; export const useAccount = () => { const [{ wallet, connecting }, connect, disconnect, updateBalances, setWalletModules, setPrimaryWallet] = useConnectWallet(); - const [address, setAddress] = useState(wallet && wallet.accounts.length > 0 ? wallet.accounts[0].address : undefined); const [{ chains, connectedChain, settingChain }, setChain] = useSetChain(); @@ -17,18 +15,6 @@ export const useAccount = () => { setChain({ chainId: ethers.utils.hexValue(desiredChain) }); }; - useEffect(() => { - if(wallet && wallet.accounts.length > 0) { - setAddress(wallet.accounts[0].address); - (async () => { - const ethersProvider = new ethers.providers.Web3Provider(wallet.provider); - const signer = ethersProvider.getSigner(); - const walletAddress = await signer.getAddress(); - setAddress(walletAddress); - })(); - } - }, [wallet]); - return { wallet, connecting, @@ -38,7 +24,7 @@ export const useAccount = () => { setWalletModules, setPrimaryWallet, provider: wallet ? new ethers.providers.Web3Provider(wallet.provider, 'any') : undefined, - account: address, + account: wallet && wallet.accounts.length > 0 ? ethers.utils.getAddress(wallet.accounts[0].address) : undefined, chainId: connectedChain ? Number(connectedChain.id) : undefined, isActive, setChain,