diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index 898378389..8e1ff34b7 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -1,6 +1,7 @@ const EventEmitter = require('events') const ObservableStore = require('obs-store') const ethUtil = require('ethereumjs-util') +const { errors: rpcErrors } = require('eth-json-rpc-errors') const createId = require('./random-id') /** @@ -82,7 +83,7 @@ module.exports = class MessageManager extends EventEmitter { case 'signed': return resolve(data.rawSig) case 'rejected': - return reject(new Error('MetaMask Message Signature: User denied message signature.')) + return reject(rpcErrors.eth.userRejectedRequest('MetaMask Message Signature: User denied message signature.')) default: return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) } diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index d259f4f19..2a2ab481a 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -1,6 +1,7 @@ const EventEmitter = require('events') const ObservableStore = require('obs-store') const ethUtil = require('ethereumjs-util') +const { errors: rpcErrors } = require('eth-json-rpc-errors') const createId = require('./random-id') const hexRe = /^[0-9A-Fa-f]+$/g const log = require('loglevel') @@ -88,7 +89,7 @@ module.exports = class PersonalMessageManager extends EventEmitter { case 'signed': return resolve(data.rawSig) case 'rejected': - return reject(new Error('MetaMask Message Signature: User denied message signature.')) + return reject(rpcErrors.eth.userRejectedRequest('MetaMask Message Signature: User denied message signature.')) default: return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) } diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index 5e2a4cd0a..e4d3e842b 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -2,6 +2,7 @@ const EventEmitter = require('events') const ObservableStore = require('obs-store') const createId = require('./random-id') const assert = require('assert') +const { errors: rpcErrors } = require('eth-json-rpc-errors') const sigUtil = require('eth-sig-util') const log = require('loglevel') const jsonschema = require('jsonschema') @@ -78,7 +79,7 @@ module.exports = class TypedMessageManager extends EventEmitter { case 'signed': return resolve(data.rawSig) case 'rejected': - return reject(new Error('MetaMask Message Signature: User denied message signature.')) + return reject(rpcErrors.eth.userRejectedRequest('MetaMask Message Signature: User denied message signature.')) case 'errored': return reject(new Error(`MetaMask Message Signature: ${data.error}`)) default: diff --git a/package.json b/package.json index 1eaac6851..8cd8aa694 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "eth-block-tracker": "^4.4.2", "eth-contract-metadata": "^1.9.2", "eth-ens-namehash": "^2.0.8", - "eth-json-rpc-errors": "^1.0.1", + "eth-json-rpc-errors": "^1.1.0", "eth-json-rpc-filters": "^4.1.0", "eth-json-rpc-infura": "^4.0.1", "eth-json-rpc-middleware": "^4.2.0",