From e5d4809a5019a897809081b597ec836fefa41887 Mon Sep 17 00:00:00 2001 From: jiexi Date: Tue, 25 Jun 2024 11:34:38 -0700 Subject: [PATCH] feat: bump `@metamask/queued-request controller` to `^2.0.0` to fix confirmation popup focus in request queue (#25497) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25497?quickstart=1) ## **Related issues** See: https://github.com/MetaMask/core/pull/4457 See: https://github.com/MetaMask/metamask-extension/issues/25397 ## **Manual testing steps** 1. Ensure request queue is toggled on 2. In Tab 1, Visit the test dapp 3. run `await window.ethereum.request({method: 'wallet_switchEthereumChain', params: [{"chainId": "0xaa36a7"}]})` in console to change the network to sepolia for this dapp 4. In Tab 2, Visit a different dapp 5. run `await window.ethereum.request({method: 'wallet_switchEthereumChain', params: [{"chainId": "1"}]})` in console to change the network to mainnet for this dapp 6. In Tab 1, click the Send Transaction button, but ignore the confirmation notification (leave it open) 7. In Tab 2, run `await window.ethereum.request({method: 'eth_requestAccounts'})` 8. The confirmation notification window should be focused and visible now, but still be displaying the pending transaction from before ## **Screenshots/Recordings** ### **Before** ### **After** https://github.com/MetaMask/metamask-extension/assets/918701/48693083-fe60-402f-8798-c32b5db541b6 ## **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. --- app/scripts/metamask-controller.js | 1 + package.json | 2 +- .../dapp1-switch-dapp2-eth-request-accounts.spec.js | 2 +- yarn.lock | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7a43f01fdcf1..aa165151f736 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -452,6 +452,7 @@ export default class MetamaskController extends EventEmitter { shouldRequestSwitchNetwork: ({ method }) => methodsRequiringNetworkSwitch.includes(method), clearPendingConfirmations, + showApprovalRequest: opts.showUserConfirmation, }); this.approvalController = new ApprovalController({ diff --git a/package.json b/package.json index b1bd0fe251dd..75b51bccadbd 100644 --- a/package.json +++ b/package.json @@ -329,7 +329,7 @@ "@metamask/post-message-stream": "^8.0.0", "@metamask/ppom-validator": "^0.30.0", "@metamask/providers": "^14.0.2", - "@metamask/queued-request-controller": "^1.0.0", + "@metamask/queued-request-controller": "^2.0.0", "@metamask/rate-limit-controller": "^5.0.1", "@metamask/safe-event-emitter": "^3.1.1", "@metamask/scure-bip39": "^2.0.3", diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js index 60690d4ab66b..e448c995e077 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-eth-request-accounts.spec.js @@ -67,7 +67,7 @@ describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', functio assert.deepStrictEqual(accountsBeforeConnect, ''); // Reject the pending confirmation from the first dapp - await switchToNotificationWindow(driver); + await switchToNotificationWindow(driver, 4); await driver.clickElement({ text: 'Reject', tag: 'button' }); // Wait for switch confirmation to close then request accounts confirmation to show for the second dapp diff --git a/yarn.lock b/yarn.lock index d18a17c67c4a..030b52ea622a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6086,9 +6086,9 @@ __metadata: languageName: node linkType: hard -"@metamask/queued-request-controller@npm:^1.0.0": - version: 1.0.0 - resolution: "@metamask/queued-request-controller@npm:1.0.0" +"@metamask/queued-request-controller@npm:^2.0.0": + version: 2.0.0 + resolution: "@metamask/queued-request-controller@npm:2.0.0" dependencies: "@metamask/base-controller": "npm:^6.0.0" "@metamask/controller-utils": "npm:^11.0.0" @@ -6099,7 +6099,7 @@ __metadata: peerDependencies: "@metamask/network-controller": ^19.0.0 "@metamask/selected-network-controller": ^15.0.0 - checksum: 10/84b5442035ef4843ad5c3effdb961c9725c07fa3caf37928c4315ffb4929160a1032b8e0f814061fa8487f499d147766f3cfdd4172c8a3941c2996b11628a46b + checksum: 10/b618fa05465a52e5b689d932d99b47552b5987a9141d58260966611f1057190132f14b1a2123c48399f218fc57c577e1c86375e8ee2b43871cdc597fbaeedb7a languageName: node linkType: hard @@ -25092,7 +25092,7 @@ __metadata: "@metamask/post-message-stream": "npm:^8.0.0" "@metamask/ppom-validator": "npm:^0.30.0" "@metamask/providers": "npm:^14.0.2" - "@metamask/queued-request-controller": "npm:^1.0.0" + "@metamask/queued-request-controller": "npm:^2.0.0" "@metamask/rate-limit-controller": "npm:^5.0.1" "@metamask/safe-event-emitter": "npm:^3.1.1" "@metamask/scure-bip39": "npm:^2.0.3"