add user rejected errors

feature/default_network_editable
Erik Marks 5 years ago
parent 79e0a9c1a6
commit 672ade33a6
  1. 3
      app/scripts/lib/message-manager.js
  2. 3
      app/scripts/lib/personal-message-manager.js
  3. 3
      app/scripts/lib/typed-message-manager.js
  4. 2
      package.json

@ -1,6 +1,7 @@
const EventEmitter = require('events') const EventEmitter = require('events')
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const { errors: rpcErrors } = require('eth-json-rpc-errors')
const createId = require('./random-id') const createId = require('./random-id')
/** /**
@ -82,7 +83,7 @@ module.exports = class MessageManager extends EventEmitter {
case 'signed': case 'signed':
return resolve(data.rawSig) return resolve(data.rawSig)
case 'rejected': 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: default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
} }

@ -1,6 +1,7 @@
const EventEmitter = require('events') const EventEmitter = require('events')
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const { errors: rpcErrors } = require('eth-json-rpc-errors')
const createId = require('./random-id') const createId = require('./random-id')
const hexRe = /^[0-9A-Fa-f]+$/g const hexRe = /^[0-9A-Fa-f]+$/g
const log = require('loglevel') const log = require('loglevel')
@ -88,7 +89,7 @@ module.exports = class PersonalMessageManager extends EventEmitter {
case 'signed': case 'signed':
return resolve(data.rawSig) return resolve(data.rawSig)
case 'rejected': 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: default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
} }

@ -2,6 +2,7 @@ const EventEmitter = require('events')
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const createId = require('./random-id') const createId = require('./random-id')
const assert = require('assert') const assert = require('assert')
const { errors: rpcErrors } = require('eth-json-rpc-errors')
const sigUtil = require('eth-sig-util') const sigUtil = require('eth-sig-util')
const log = require('loglevel') const log = require('loglevel')
const jsonschema = require('jsonschema') const jsonschema = require('jsonschema')
@ -78,7 +79,7 @@ module.exports = class TypedMessageManager extends EventEmitter {
case 'signed': case 'signed':
return resolve(data.rawSig) return resolve(data.rawSig)
case 'rejected': 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': case 'errored':
return reject(new Error(`MetaMask Message Signature: ${data.error}`)) return reject(new Error(`MetaMask Message Signature: ${data.error}`))
default: default:

@ -85,7 +85,7 @@
"eth-block-tracker": "^4.4.2", "eth-block-tracker": "^4.4.2",
"eth-contract-metadata": "^1.9.2", "eth-contract-metadata": "^1.9.2",
"eth-ens-namehash": "^2.0.8", "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-filters": "^4.1.0",
"eth-json-rpc-infura": "^4.0.1", "eth-json-rpc-infura": "^4.0.1",
"eth-json-rpc-middleware": "^4.2.0", "eth-json-rpc-middleware": "^4.2.0",

Loading…
Cancel
Save