diff --git a/src/chain/blockchain.ts b/src/chain/blockchain.ts index de42e76..b5ca101 100644 --- a/src/chain/blockchain.ts +++ b/src/chain/blockchain.ts @@ -215,8 +215,17 @@ export class Blockchain { provider = window.ethereum try { await provider.request({ method: 'eth_requestAccounts' }) - } catch (error) { - throw new Error('User Rejected') + } catch (error: any) { + if (error.code === -32002) { + // const hexChainId = toHexChainId(this.currentChain) + // await provider.request({ + // method: 'wallet_switchEthereumChain', + // params: [{ chainId: hexChainId }] + // }) + throw new Error('MeatMask not login, Open MeatMask and login first') + } else { + throw new Error('User Rejected') + } } } else if (window.web3) { provider = window.web3.currentProvider