Skip to content
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: remove methods from array used to determine which requests should be enqueued because they can be safely passed through #27315

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ import {
NotificationServicesPushController,
NotificationServicesController,
} from '@metamask/notification-services-controller';
import {
methodsRequiringNetworkSwitch,
methodsWithConfirmation,
} from '../../shared/constants/methods-tags';
import { methodsRequiringNetworkSwitch } from '../../shared/constants/methods-tags';

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
Expand Down Expand Up @@ -5511,16 +5508,7 @@ export default class MetamaskController extends EventEmitter {
this.preferencesController,
),
shouldEnqueueRequest: (request) => {
if (
request.method === 'eth_requestAccounts' &&
this.permissionController.hasPermission(
request.origin,
PermissionNames.eth_accounts,
)
) {
return false;
}
return methodsWithConfirmation.includes(request.method);
return methodsRequiringNetworkSwitch.includes(request.method);
},
});
engine.push(requestQueueMiddleware);
Expand Down
15 changes: 0 additions & 15 deletions shared/constants/methods-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,9 @@ export const methodsRequiringNetworkSwitch = [
'eth_sendTransaction',
'eth_sendRawTransaction',
'wallet_switchEthereumChain',
'wallet_addEthereumChain',
'wallet_watchAsset',
'eth_signTypedData',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
'personal_sign',
] as const;

/**
* This is a list of methods that can cause a confirmation to be
* presented to the user. Note that some of these methods may
* only sometimes cause a confirmation to appear.
*/
export const methodsWithConfirmation = [
...methodsRequiringNetworkSwitch,
'wallet_requestPermissions',
'wallet_requestSnaps',
'eth_decrypt',
'eth_requestAccounts',
'eth_getEncryptionPublicKey',
];
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,21 @@ describe('Request Queuing Dapp 1 Send Tx -> Dapp 2 Request Accounts Tx', functio

// Dapp Send Button
await driver.clickElement('#sendButton');
await driver.delay(regularDelayMs);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

// Leave the confirmation pending
await driver.waitForSelector({
text: 'Reject',
tag: 'button',
});

await driver.delay(regularDelayMs);

await driver.switchToWindowWithTitle(
WINDOW_TITLES.ExtensionInFullScreenView,
);

// Leave the confirmation pending
await openDapp(driver, undefined, DAPP_ONE_URL);

const accountsOnload = await (
Expand Down