-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: Bump QueuedRequestController
from ^2.0.0
to ^7.0.0
#28090
feat: Bump QueuedRequestController
from ^2.0.0
to ^7.0.0
#28090
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@metamask/[email protected] |
@metamaskbot update-policies |
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
app/scripts/lib/rpc-method-middleware/handlers/ethereum-chain-utils.js
Outdated
Show resolved
Hide resolved
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
…-add-switch-chain' into jl/fix-queued-request-controller-add-switch-chain
…stController.canRequestSwitchNetworkWithoutApproval
Builds ready [fbc055b]
Page Load Metrics (1725 ± 58 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
… switch the network without prompting user approval (#4846) ## Explanation The release of Chain Permissions in Extension have changed the behavior of `wallet_switchEthereumChain` and `wallet_addEthereumChain` which breaks previous assumptions that the `QueuedRequestController` operated from. Specifically, it was previously assumed that the above methods would ALWAYS generate an approval that the user must accept or reject. This is important because the side effect of this behavior was that it was not possible for those two methods to immediately switch the chain if there happened to be existing pending approvals. The result of this new behavior was that pending approvals were being immediately cleared if one of the method calls above were to a chain that was already permitted which is the case where a network switch happens immediately without user interaction. This PR fixes this new case by: * explicitly waiting for any batch of processing requests to finish before proceeding with processing a request that has the potential to switch the globally selected network * processing a request that has the potential to switch the globally selected network by itself (rather than releasing it within a batch of several requests for the same origin) * flushing the request queue for the origin IF a request that has the potential to switch the globally selected network actually does change the globally selected network ## References Related: MetaMask/metamask-extension#28090 ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/queued-request-controller` - **BREAKING**: `QueuedRequestController` now requires the `canRequestSwitchNetworkWithoutApproval` callback in its constructor params. - **CHANGED**: `QueuedRequestController` now ensures that any queued requests for a origin are failed if a request that can switch the globally selected network without approval actually does change the globally selected network for that origin. - **CHANGED**: `QueuedRequestController` now ensures that a request that can switch the globally selected network without approval is queued behind any existing pending requests. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes --------- Co-authored-by: Mark Stacey <[email protected]>
Builds ready [31d8bdc]
Page Load Metrics (2011 ± 64 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
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.
LGTM!
…-add-switch-chain' into jl/fix-queued-request-controller-add-switch-chain
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.
LGTM!
Builds ready [f8ca8b5]
Page Load Metrics (2196 ± 157 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [951bd80]
Page Load Metrics (1939 ± 78 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
I have manually tested and confirmed that this fixes #28102 as well. I have added it to the description. |
Builds ready [ae936a0]
Page Load Metrics (1963 ± 133 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
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.
Followed the manual testing steps and they all worked for me.
Description
Bumps
@metamask/queued-request-controller
to fix queueing issue with Chain Permissionwallet_switchEthereumChain
andwallet_addEthereumChain
when switching to a previously permitted chain and withwallet_addEthereumChain
not being enqueued when it still should be.Related issues
Related: MetaMask/core#4846
Fixes: #28101
Fixes: #27977
Fixes: #28102
Manual testing steps
The easiest way to test this would be a combination of using the test dapp and the following request to switch chains
The behaviors you should see include:
One dapp:
Two dapps:
Screenshots/Recordings
Before
After
Screen.Recording.2024-10-24.at.1.57.19.PM.mov
Screen.Recording.2024-10-30.at.8.44.54.AM.mov
Pre-merge author checklist
Pre-merge reviewer checklist