-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: re-connecting a locked wallet #2341
Conversation
Branch preview✅ Deploy successful! |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
|
||
// WalletConnect v2 | ||
if (walletName === WalletNames.WALLET_CONNECT_V2) { | ||
const wcSession = window.localStorage.getItem('wc@2:client:0.3//session') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the 0.3
is versioning.
You can call storageKey
(and maybe even get
) from WC here to avoid outdated session data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware of the trade-offs here and would sooner check local storage directly rather than call some internal WC method. This can be made more robust by searching for a key named wc@2:client:*//session
perhaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware of the trade-offs here and would sooner check local storage directly rather than call some internal WC method.
storageKey
would return the key with which you could check the localStorage
directly.
This can be made more robust by searching for a key named
wc@2:client:*//session
perhaps.
I'd personally prefer this.
I've made another PR that also fixes this issue: #2343 |
I'll close this PR to focus on the onboard's auto-connect solution. |
What it solves
Resolves #2306
How this PR fixes it
The cause of the bug was that
window.ethereum.isConnected()
returns true even if MetaMask is locked_metamask.isUnlocked
and it always returning falseI've removed
isConnected
and made it wait for the promise. Also added custom logic for WC v2 and tests for it.