diff --git a/three-id/src/provider/web3.ts b/three-id/src/provider/web3.ts index 0e73aaa30c..21f8891383 100644 --- a/three-id/src/provider/web3.ts +++ b/three-id/src/provider/web3.ts @@ -9,7 +9,10 @@ const eth = (window as any).ethereum; export const isMetamask = () => eth?.isMetaMask === true; -export const clearAccount = () => accountSubj.next(null); +export const clearAccount = async () => { + accountSubj.next(null); + sessionStorage.clear(); +}; const handleAccountsChanged = (accounts: string[]) => { const currentAccount = accountSubj.getValue(); @@ -34,7 +37,11 @@ export const connect = async (): Promise => { web3Provider = new ethers.providers.Web3Provider(eth); } - await web3Provider?.send("eth_requestAccounts", []); + if (!accountSubj.getValue()) { + await web3Provider?.send("wallet_requestPermissions", [ + { eth_accounts: {} }, + ]); + } await forceAccounts(); return web3Provider;