Return after 'reject' in Promise constructor (#8857)

There were three cases where execution unintentionally continued after
an error was encountered. These cases likely are impossible to
encounter in practice due to recent validation improvements in the
`eth-json-rpc-middleware/wallet` module, but they were broken
nonetheless.

Execution inside the Promise constructor now halts immediately after
`reject` is called.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent 1d2644423e
commit 828ec0530a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/scripts/lib/decrypt-message-manager.js
  2. 2
      app/scripts/lib/encryption-public-key-manager.js
  3. 2
      app/scripts/lib/personal-message-manager.js

@ -82,7 +82,7 @@ export default class DecryptMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => {
if (!msgParams.from) {
reject(new Error('MetaMask Decryption: from field is required.'))
return reject(new Error('MetaMask Decryption: from field is required.'))
}
const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => {

@ -79,7 +79,7 @@ export default class EncryptionPublicKeyManager extends EventEmitter {
addUnapprovedMessageAsync (address, req) {
return new Promise((resolve, reject) => {
if (!address) {
reject(new Error('MetaMask Message: address field is required.'))
return reject(new Error('MetaMask Message: address field is required.'))
}
const msgId = this.addUnapprovedMessage(address, req)
this.once(`${msgId}:finished`, (data) => {

@ -85,7 +85,7 @@ export default class PersonalMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => {
if (!msgParams.from) {
reject(new Error('MetaMask Message Signature: from field is required.'))
return reject(new Error('MetaMask Message Signature: from field is required.'))
}
const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => {

Loading…
Cancel
Save