diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8acf69a68..2e5326f10 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -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( diff --git a/ui/pages/confirmation/templates/add-ethereum-chain.js b/ui/pages/confirmation/templates/add-ethereum-chain.js index 2a16852dd..db7dac420 100644 --- a/ui/pages/confirmation/templates/add-ethereum-chain.js +++ b/ui/pages/confirmation/templates/add-ethereum-chain.js @@ -204,7 +204,7 @@ function getValues(pendingApproval, t, actions) { onCancel: () => actions.rejectPendingApproval( pendingApproval.id, - ethErrors.provider.userRejectedRequest(), + ethErrors.provider.userRejectedRequest().serialize(), ), networkDisplay: true, }; diff --git a/ui/pages/confirmation/templates/switch-ethereum-chain.js b/ui/pages/confirmation/templates/switch-ethereum-chain.js index cd28f21b0..3b09fd00e 100644 --- a/ui/pages/confirmation/templates/switch-ethereum-chain.js +++ b/ui/pages/confirmation/templates/switch-ethereum-chain.js @@ -83,7 +83,7 @@ function getValues(pendingApproval, t, actions) { onCancel: () => actions.rejectPendingApproval( pendingApproval.id, - ethErrors.provider.userRejectedRequest(), + ethErrors.provider.userRejectedRequest().serialize(), ), networkDisplay: true, };