Skip to content

Commit

Permalink
Show Failed transaction in the browser notification for on-chain fail…
Browse files Browse the repository at this point in the history
…ures (#5904)
  • Loading branch information
alextsg authored Dec 11, 2018
1 parent 1fbdce8 commit dde2397
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/scripts/platforms/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ class ExtensionPlatform {
}

showTransactionNotification (txMeta) {
const { status, txReceipt: { status: receiptStatus } = {} } = txMeta

const status = txMeta.status
if (status === 'confirmed') {
this._showConfirmedTransaction(txMeta)
// There was an on-chain failure
receiptStatus === '0x0'
? this._showFailedTransaction(txMeta, 'Transaction encountered an error.')
: this._showConfirmedTransaction(txMeta)
} else if (status === 'failed') {
this._showFailedTransaction(txMeta)
}
Expand Down Expand Up @@ -81,11 +84,11 @@ class ExtensionPlatform {
this._showNotification(title, message, url)
}

_showFailedTransaction (txMeta) {
_showFailedTransaction (txMeta, errorMessage) {

const nonce = parseInt(txMeta.txParams.nonce, 16)
const title = 'Failed transaction'
const message = `Transaction ${nonce} failed! ${txMeta.err.message}`
const message = `Transaction ${nonce} failed! ${errorMessage || txMeta.err.message}`
this._showNotification(title, message)
}

Expand Down

0 comments on commit dde2397

Please sign in to comment.