Skip to content

Commit

Permalink
fix: fix and catch more wallet rejection error (#115)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
wa0x6e and ChaituVR authored Aug 1, 2024
1 parent c371f9a commit bf02d49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions connectors/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit bf02d49

Please sign in to comment.