-
-
Notifications
You must be signed in to change notification settings - Fork 192
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: change queued-request-controller
methods array params to callbacks
#4423
feat: change queued-request-controller
methods array params to callbacks
#4423
Conversation
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
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!
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, great solution!
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Bumps `@metamask/queued-request-controller` to `^1.0.0` in order to handle the case where `eth_requestAccounts` requests that would not cause a confirmation to be presented to the user (because they have permitted some accounts for that dapp) would be stuck behind the request queue when they could just be passed through. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25310?quickstart=1) ## **Related issues** See: MetaMask/core#4423 Fixes: #25407 ## **Manual testing steps** 1. Open https://metamask.github.io/test-dapp/ and https://app.odos.xyz/, connect to both 1. On the Test Dapp, send an EIP 1559 txn, but do not confirm/reject the confirmation nor close the popup 1. Reload ODOS 1. ODOS should show that is connected to MetaMask in the top right of the webpage 1. Open console on the ODOS page 1. run `await window.ethereum.request({method: 'eth_requestAccounts'})`, it should return immediately with the permitted accounts ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** ### **After** https://github.com/MetaMask/metamask-extension/assets/918701/b76607ef-b0a3-4943-b1d5-85f8cd766343 ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> Bumps `@metamask/queued-request-controller` to `^1.0.0` in order to handle the case where `eth_requestAccounts` requests that would not cause a confirmation to be presented to the user (because they have permitted some accounts for that dapp) would be stuck behind the request queue when they could just be passed through. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25310?quickstart=1) See: MetaMask/core#4423 Fixes: #25407 1. Open https://metamask.github.io/test-dapp/ and https://app.odos.xyz/, connect to both 1. On the Test Dapp, send an EIP 1559 txn, but do not confirm/reject the confirmation nor close the popup 1. Reload ODOS 1. ODOS should show that is connected to MetaMask in the top right of the webpage 1. Open console on the ODOS page 1. run `await window.ethereum.request({method: 'eth_requestAccounts'})`, it should return immediately with the permitted accounts <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> https://github.com/MetaMask/metamask-extension/assets/918701/b76607ef-b0a3-4943-b1d5-85f8cd766343 - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
Explanation
The existing
methodsWithConfirmation
array param is not sufficient for determining if a method will cause a confirmation to be presented to the user or not because some methods such aseth_requestAccounts
may only cause a prompt in some scenarios but not others.This PR replaces the array params used in the QueuedRequestController and its middleware to be callbacks that accept the entire request object instead.
References
See: MetaMask/metamask-extension#25310
Changelog
@metamask/queued-request-controller
QueuedRequestController
constructor no longer accepts themethodsRequiringNetworkSwitch
array param. It's now replaced with theshouldRequestSwitchNetwork
function param which should return true when a request requires the globally selected network to match that of the dapp.createQueuedRequestMiddleware
no longer accepts themethodsWithConfirmation
array param. It's now replaced with theshouldEnqueueRequest
function param which should return true when a request should be handled by the QueuedRequestControllerChecklist