mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Show Failed transaction in the browser notification for on-chain failures (#5904)
This commit is contained in:
parent
1fbdce8916
commit
dde239797b
@ -48,10 +48,13 @@ class ExtensionPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showTransactionNotification (txMeta) {
|
showTransactionNotification (txMeta) {
|
||||||
|
const { status, txReceipt: { status: receiptStatus } = {} } = txMeta
|
||||||
|
|
||||||
const status = txMeta.status
|
|
||||||
if (status === 'confirmed') {
|
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') {
|
} else if (status === 'failed') {
|
||||||
this._showFailedTransaction(txMeta)
|
this._showFailedTransaction(txMeta)
|
||||||
}
|
}
|
||||||
@ -81,11 +84,11 @@ class ExtensionPlatform {
|
|||||||
this._showNotification(title, message, url)
|
this._showNotification(title, message, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
_showFailedTransaction (txMeta) {
|
_showFailedTransaction (txMeta, errorMessage) {
|
||||||
|
|
||||||
const nonce = parseInt(txMeta.txParams.nonce, 16)
|
const nonce = parseInt(txMeta.txParams.nonce, 16)
|
||||||
const title = 'Failed transaction'
|
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)
|
this._showNotification(title, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user