diff --git a/connectors/injected.ts b/connectors/injected.ts index d60596d..f6c02c2 100644 --- a/connectors/injected.ts +++ b/connectors/injected.ts @@ -7,8 +7,20 @@ export default class Connector extends LockConnector { provider = window['ethereum']; try { await window['ethereum'].request({ method: 'eth_requestAccounts' }) - } catch (e) { + } catch (e: any) { console.error(e); + if (e.message = "Already processing eth_requestAccounts. Please wait.") { + try { + await provider.request({ + method: "wallet_requestPermissions", + params: [{ eth_accounts: {} }], + }); + } catch (e: any) { + console.error(e); + if (e.code === 4001 || -32002) return; + } + } + if (e.code === 4001) return; } } else if (window['web3']) { diff --git a/package.json b/package.json index b2d6a7f..c46c997 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snapshot-labs/lock", - "version": "0.2.4", + "version": "0.2.5", "repository": "snapshot-labs/lock", "license": "MIT", "main": "dist/lock.cjs.js",