mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Disable rate limiting for signature approval requests (#18594)
This commit is contained in:
parent
d85d2318a3
commit
fa32c5deb9
@ -409,6 +409,14 @@ describe('SignController', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('does not throw if accepting approval throws', async () => {
|
||||
messengerMock.call.mockImplementation(() => {
|
||||
throw new Error('Test Error');
|
||||
});
|
||||
|
||||
await signController[signMethodName](messageParamsMock);
|
||||
});
|
||||
|
||||
it('rejects message on error', async () => {
|
||||
keyringControllerMock[signMethodName].mockReset();
|
||||
keyringControllerMock[signMethodName].mockRejectedValue(
|
||||
@ -468,6 +476,14 @@ describe('SignController', () => {
|
||||
'Cancel',
|
||||
);
|
||||
});
|
||||
|
||||
it('does not throw if rejecting approval throws', async () => {
|
||||
messengerMock.call.mockImplementation(() => {
|
||||
throw new Error('Test Error');
|
||||
});
|
||||
|
||||
await signController[cancelMethodName](messageParamsMock);
|
||||
});
|
||||
});
|
||||
|
||||
describe('message manager events', () => {
|
||||
|
@ -33,12 +33,13 @@ import {
|
||||
RejectRequest,
|
||||
} from '@metamask/approval-controller';
|
||||
import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics';
|
||||
import { MESSAGE_TYPE } from '../../../shared/constants/app';
|
||||
import PreferencesController from './preferences';
|
||||
|
||||
const controllerName = 'SignController';
|
||||
const methodNameSign = 'eth_sign';
|
||||
const methodNamePersonalSign = 'personal_sign';
|
||||
const methodNameTypedSign = 'eth_signTypedData';
|
||||
const methodNameSign = MESSAGE_TYPE.ETH_SIGN;
|
||||
const methodNamePersonalSign = MESSAGE_TYPE.PERSONAL_SIGN;
|
||||
const methodNameTypedSign = MESSAGE_TYPE.ETH_SIGN_TYPED_DATA;
|
||||
|
||||
const stateMetadata = {
|
||||
unapprovedMsgs: { persist: false, anonymous: false },
|
||||
@ -636,14 +637,22 @@ export default class SignController extends BaseControllerV2<
|
||||
}
|
||||
|
||||
private _acceptApproval(messageId: string) {
|
||||
this.messagingSystem.call('ApprovalController:acceptRequest', messageId);
|
||||
try {
|
||||
this.messagingSystem.call('ApprovalController:acceptRequest', messageId);
|
||||
} catch (error) {
|
||||
log.info('Failed to accept signature approval request', error);
|
||||
}
|
||||
}
|
||||
|
||||
private _rejectApproval(messageId: string) {
|
||||
this.messagingSystem.call(
|
||||
'ApprovalController:rejectRequest',
|
||||
messageId,
|
||||
'Cancel',
|
||||
);
|
||||
try {
|
||||
this.messagingSystem.call(
|
||||
'ApprovalController:rejectRequest',
|
||||
messageId,
|
||||
'Cancel',
|
||||
);
|
||||
} catch (error) {
|
||||
log.info('Failed to reject signature approval request', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ import {
|
||||
import { MILLISECOND, SECOND } from '../../shared/constants/time';
|
||||
import {
|
||||
ORIGIN_METAMASK,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||
MESSAGE_TYPE,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||
SNAP_DIALOG_TYPES,
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
POLLING_TOKEN_ENVIRONMENT_TYPES,
|
||||
@ -260,6 +260,11 @@ export default class MetamaskController extends EventEmitter {
|
||||
name: 'ApprovalController',
|
||||
}),
|
||||
showApprovalRequest: opts.showUserConfirmation,
|
||||
typesExcludedFromRateLimiting: [
|
||||
MESSAGE_TYPE.ETH_SIGN,
|
||||
MESSAGE_TYPE.PERSONAL_SIGN,
|
||||
MESSAGE_TYPE.ETH_SIGN_TYPED_DATA,
|
||||
],
|
||||
});
|
||||
|
||||
const networkControllerMessenger = this.controllerMessenger.getRestricted({
|
||||
|
@ -228,7 +228,7 @@
|
||||
"@material-ui/core": "^4.11.0",
|
||||
"@metamask/address-book-controller": "^2.0.0",
|
||||
"@metamask/announcement-controller": "^3.0.0",
|
||||
"@metamask/approval-controller": "^2.0.0",
|
||||
"@metamask/approval-controller": "^2.1.0",
|
||||
"@metamask/assets-controllers": "^5.0.0",
|
||||
"@metamask/base-controller": "^2.0.0",
|
||||
"@metamask/contract-metadata": "^2.3.1",
|
||||
|
12
yarn.lock
12
yarn.lock
@ -3602,16 +3602,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@metamask/approval-controller@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "@metamask/approval-controller@npm:2.0.0"
|
||||
"@metamask/approval-controller@npm:^2.0.0, @metamask/approval-controller@npm:^2.1.0":
|
||||
version: 2.1.0
|
||||
resolution: "@metamask/approval-controller@npm:2.1.0"
|
||||
dependencies:
|
||||
"@metamask/base-controller": ^2.0.0
|
||||
"@metamask/controller-utils": ^3.0.0
|
||||
"@metamask/controller-utils": ^3.1.0
|
||||
eth-rpc-errors: ^4.0.0
|
||||
immer: ^9.0.6
|
||||
nanoid: ^3.1.31
|
||||
checksum: 1db5f9c21b04fa4688c17cdfb7da0a14b3fee084fbd8c0cfdcc41572e54140ce093c24b811b85e8ee9d3ccd8987db04d9150d7c6d5ab21daf72b4364a05f3428
|
||||
checksum: 207380e3ed0007aec3b9efcde62ac3ece9fa46cc7b9e6157c0d54271e0936b5a9a05e59adcfb1e47e3f3df397d2d2dc757f3b97745528695182e7c66a5207aca
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -24159,7 +24159,7 @@ __metadata:
|
||||
"@material-ui/core": ^4.11.0
|
||||
"@metamask/address-book-controller": ^2.0.0
|
||||
"@metamask/announcement-controller": ^3.0.0
|
||||
"@metamask/approval-controller": ^2.0.0
|
||||
"@metamask/approval-controller": ^2.1.0
|
||||
"@metamask/assets-controllers": ^5.0.0
|
||||
"@metamask/auto-changelog": ^2.1.0
|
||||
"@metamask/base-controller": ^2.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user