Skip to content

Commit

Permalink
fix: skip authentication on locked metamask (#114)
Browse files Browse the repository at this point in the history
* fix: fix deprecated usage of `selectedAddress`

* chore: bump version

* fix: do not return provider on locked wallet

* fix: handle error when the requestPermission is request is pending

* v0.2.5

---------

Co-authored-by: ChaituVR <[email protected]>
  • Loading branch information
wa0x6e and ChaituVR authored Jul 27, 2024
1 parent 503f4b0 commit b5a3203
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion connectors/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
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.4",
"version": "0.2.5",
"repository": "snapshot-labs/lock",
"license": "MIT",
"main": "dist/lock.cjs.js",
Expand Down

0 comments on commit b5a3203

Please sign in to comment.