1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

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.
This commit is contained in:
Mark Stacey 2020-06-24 16:38:53 -03:00 committed by GitHub
parent 1d2644423e
commit 828ec0530a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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) => {