1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00

Fixed serialization of error parameter for rejectPendingApproval across JSON-RPC (#13847)

* Fixed serialization of error parameter for rejectPendingApproval across JSON-RPC

* Fixed linting

* Added serialize error to add-ethereum-chain
This commit is contained in:
Shane 2022-03-10 09:55:25 -08:00 committed by GitHub
parent f09459cb84
commit adce5c558d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -9,7 +9,11 @@ import createFilterMiddleware from 'eth-json-rpc-filters';
import createSubscriptionManager from 'eth-json-rpc-filters/subscriptionManager';
import { providerAsMiddleware } from 'eth-json-rpc-middleware';
import KeyringController from 'eth-keyring-controller';
import { errorCodes as rpcErrorCodes, ethErrors } from 'eth-rpc-errors';
import {
errorCodes as rpcErrorCodes,
EthereumRpcError,
ethErrors,
} from 'eth-rpc-errors';
import { Mutex } from 'await-semaphore';
import { stripHexPrefix } from 'ethereumjs-util';
import log from 'loglevel';
@ -1723,7 +1727,12 @@ export default class MetamaskController extends EventEmitter {
resolvePendingApproval: approvalController.accept.bind(
approvalController,
),
rejectPendingApproval: approvalController.reject.bind(approvalController),
rejectPendingApproval: async (id, error) => {
approvalController.reject(
id,
new EthereumRpcError(error.code, error.message, error.data),
);
},
// Notifications
updateViewedNotifications: notificationController.updateViewed.bind(

View File

@ -204,7 +204,7 @@ function getValues(pendingApproval, t, actions) {
onCancel: () =>
actions.rejectPendingApproval(
pendingApproval.id,
ethErrors.provider.userRejectedRequest(),
ethErrors.provider.userRejectedRequest().serialize(),
),
networkDisplay: true,
};

View File

@ -83,7 +83,7 @@ function getValues(pendingApproval, t, actions) {
onCancel: () =>
actions.rejectPendingApproval(
pendingApproval.id,
ethErrors.provider.userRejectedRequest(),
ethErrors.provider.userRejectedRequest().serialize(),
),
networkDisplay: true,
};