-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat: refactor wallet pairing #5817
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
This reverts commit 846d3bac909c0939d6063a3e5471491ccaf93f6a.
56e76af
to
5e47e2a
Compare
src/context/WalletProvider/NativeWallet/components/NativeLoad.tsx
Outdated
Show resolved
Hide resolved
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.
Huge task perfectly implemented ser
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.
Absolute goat PR.
Code-wise looking solid, will give a functional review before blessing with a green tick.
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.
Still a package checksum issue to resolve before we can merge, but functionally this is working very well!
The Metamask hack works as expected when overriding the hidden request state, wallet switching is happy, all accounts show as expected etc, console is happy.
Description
Published as alpha so ops can test this, but we'll want to wait for the actual version to be published before merging this⚠️ blocked by shapeshift/hdwallet#656
This PR refactors the whole wallet pairing flow entirely by:
localWallet
getter and setters and making it a persistedlocalWalletSlice
instead. This was a mistake from the beginning and is the root cause of us always having reactivity and/or performance issues. local storage is not reactive, hence us trying to be reactive onlocalWallet
values inWalletProvider
was producing absurd amounts of reactivityPull Request Type
Issue (if applicable)
closes #5453
Risk
Very high. This refactors wallet pairing flow entirely.
Testing
Note, before you test against develop. Note we were turbo broken for just about forever, and are having way too many event handlers / request to MetaMask. When testing against develop, you do not want to have develop and localhost open at the same time. When you test develop, you should test it in **isolation ** by ensuring you fully quit your browser, before starting to test with this PR.
Otherwise, this PR would inevitably be broken/ish (not as much as develop, but still) given the fact that there are many stale events in MM.
Alternatively, if this is too cumbersome. Test in two entirely different Chrome profiles - one with this PR, one with develop. Do not open develop in the profile use to test this, and keep things properly sandboxed to ensure sane testing.
Test ALL wallets for pairing regressions - no need to actually broadcast Txs here
When MM is in a locked state, clicking Connect Wallet prompts for unlock
When MM is (either manually, or automatically on idle) locked, the locked state is reflected in the app
When MM is unlocked, the locked state warning is gone and we properly consider MM as unlocked again
When connecting MM originally, then another wallet (e.g WalletConnect), then switching chains or accounts in MM, MM doesn't pop up as active again
Switching accounts or chains in MM is still properly detected when MM is connected
When refreshing the app with MM connected, chains and account switches are still detected
When refreshing the app, the connected wallet is still connected
Engineering
Operations
Screenshots (if applicable)
WalletConnectV2 - connect and refresh regression test against develop
Screen.Recording.2023-12-11.at.11.58.27.mov
MM - connect and refresh regression test against develop
Screen.Recording.2023-12-11.at.12.06.17.mov
MM - working locked state detection against borked develop
Screen.Recording.2023-12-11.at.12.07.15.mov
MM - working unlock prompts against borked develop
Screen.Recording.2023-12-11.at.12.23.52.mov
Screen.Recording.2023-12-11.at.12.25.11.mov
MM - borked event handlers resulting in MM being connected again when connecting MM -> another wallet -> switching accounts or chains in MM
no.wtf.mov
wtf.mov