From bf02d49773ce94349b56a1462438e560bce6494e Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:44:37 +0900 Subject: [PATCH] fix: fix and catch more wallet rejection error (#115) * chore: remove console.log, already done by injected wallet * fix: fix assignement instead of comparison * fix: fix invalid code comparison * fix: ignore -32002 code * v0.2.6 --------- Co-authored-by: Chaitanya --- connectors/injected.ts | 8 +++----- package.json | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/connectors/injected.ts b/connectors/injected.ts index f6c02c2..076cf34 100644 --- a/connectors/injected.ts +++ b/connectors/injected.ts @@ -8,20 +8,18 @@ export default class Connector extends LockConnector { try { await window['ethereum'].request({ method: 'eth_requestAccounts' }) } catch (e: any) { - console.error(e); - if (e.message = "Already processing eth_requestAccounts. Please wait.") { + if (e.message.includes("Already processing eth_requestAccounts")) { 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 || e.code === -32002) return; } } - if (e.code === 4001) return; + if (e.code === 4001 || e.code === -32002) return; } } else if (window['web3']) { provider = window['web3'].currentProvider; diff --git a/package.json b/package.json index c46c997..746c31f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snapshot-labs/lock", - "version": "0.2.5", + "version": "0.2.6", "repository": "snapshot-labs/lock", "license": "MIT", "main": "dist/lock.cjs.js",