I developed metamask auto-login function after refresh browser.
However, there is a problem when metamask is locked because It's been a long time since user visited.
I don't want show metamask popup when it is locked.
Is there anyway I can check metamask is locked ?
web3.eth.getAccounts is not a solution because it returns empty array when refresh browser. so it is not reliable.
useEffect(() => {
const walletCompany = getWalletFromLocalStorage('wallet');
const metamaskWalletAutoLogin = async () => {
const res = await connectWithMetamask();
res.address && saveWalletAddress(res.address);
setIsLoading(false);
};
const coinbaseWalletAutoLogin = async () => {
const res = await connectWithCoinbase();
res.address && saveWalletAddress(res.address);
setIsLoading(false);
};
if (walletCompany) {
walletCompany === 'metamask' ? metamaskWalletAutoLogin() : coinbaseWalletAutoLogin();
} else setIsLoading(false);
}, []);