mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Canceled, edited transactions show edited amount.
This commit is contained in:
parent
bccbf14b39
commit
1f1fc2c49e
@ -189,6 +189,11 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
await this.approveTransaction(txMeta.id)
|
await this.approveTransaction(txMeta.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateAndCancelTransaction (txMeta) {
|
||||||
|
this.txStateManager.updateTx(txMeta, 'confTx: user rejected transaction')
|
||||||
|
await this.cancelTransaction(txMeta.id)
|
||||||
|
}
|
||||||
|
|
||||||
async approveTransaction (txId) {
|
async approveTransaction (txId) {
|
||||||
let nonceLock
|
let nonceLock
|
||||||
try {
|
try {
|
||||||
|
@ -366,6 +366,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
// txController
|
// txController
|
||||||
cancelTransaction: nodeify(txController.cancelTransaction, txController),
|
cancelTransaction: nodeify(txController.cancelTransaction, txController),
|
||||||
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
|
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
|
||||||
|
updateAndCancelTransaction: nodeify(txController.updateAndCancelTransaction, txController),
|
||||||
|
|
||||||
// messageManager
|
// messageManager
|
||||||
signMessage: nodeify(this.signMessage, this),
|
signMessage: nodeify(this.signMessage, this),
|
||||||
|
@ -126,6 +126,7 @@ var actions = {
|
|||||||
signTx: signTx,
|
signTx: signTx,
|
||||||
signTokenTx: signTokenTx,
|
signTokenTx: signTokenTx,
|
||||||
updateAndApproveTx,
|
updateAndApproveTx,
|
||||||
|
updateAndCancelTx,
|
||||||
cancelTx: cancelTx,
|
cancelTx: cancelTx,
|
||||||
completedTx: completedTx,
|
completedTx: completedTx,
|
||||||
txError: txError,
|
txError: txError,
|
||||||
@ -710,6 +711,24 @@ function updateAndApproveTx (txData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateAndCancelTx (txData) {
|
||||||
|
log.info('actions: updateAndCancelTx: ' + JSON.stringify(txData))
|
||||||
|
return (dispatch) => {
|
||||||
|
log.debug(`actions calling background.updateAndCancelTx`)
|
||||||
|
background.updateAndCancelTransaction(txData, (err) => {
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
dispatch(actions.updateTransactionParams(txData.id, txData.txParams))
|
||||||
|
dispatch(actions.clearSend())
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.txError(err))
|
||||||
|
dispatch(actions.goHome())
|
||||||
|
return log.error(err.message)
|
||||||
|
}
|
||||||
|
dispatch(actions.completedTx(txData.id))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function completedTx (id) {
|
function completedTx (id) {
|
||||||
return {
|
return {
|
||||||
type: actions.COMPLETED_TX,
|
type: actions.COMPLETED_TX,
|
||||||
|
@ -55,6 +55,7 @@ function mapDispatchToProps (dispatch) {
|
|||||||
dispatch(actions.showSendPage())
|
dispatch(actions.showSendPage())
|
||||||
},
|
},
|
||||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||||
|
updateAndCancelTx: txMeta => dispatch(actions.updateAndCancelTx(txMeta)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +422,13 @@ ConfirmSendEther.prototype.onSubmit = function (event) {
|
|||||||
|
|
||||||
ConfirmSendEther.prototype.cancel = function (event, txMeta) {
|
ConfirmSendEther.prototype.cancel = function (event, txMeta) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.props.cancelTransaction(txMeta)
|
const { send, updateAndCancelTx, cancelTransaction } = this.props
|
||||||
|
|
||||||
|
if (send.editingTransactionId) {
|
||||||
|
updateAndCancelTx(txMeta)
|
||||||
|
} else {
|
||||||
|
cancelTransaction(txMeta)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendEther.prototype.checkValidity = function () {
|
ConfirmSendEther.prototype.checkValidity = function () {
|
||||||
|
@ -89,6 +89,7 @@ function mapDispatchToProps (dispatch, ownProps) {
|
|||||||
}))
|
}))
|
||||||
dispatch(actions.showSendTokenPage())
|
dispatch(actions.showSendTokenPage())
|
||||||
},
|
},
|
||||||
|
updateAndCancelTx: txMeta => dispatch(actions.updateAndCancelTx(txMeta)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +416,13 @@ ConfirmSendToken.prototype.onSubmit = function (event) {
|
|||||||
|
|
||||||
ConfirmSendToken.prototype.cancel = function (event, txMeta) {
|
ConfirmSendToken.prototype.cancel = function (event, txMeta) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.props.cancelTransaction(txMeta)
|
const { send, updateAndCancelTx, cancelTransaction } = this.props
|
||||||
|
|
||||||
|
if (send.editingTransactionId) {
|
||||||
|
updateAndCancelTx(txMeta)
|
||||||
|
} else {
|
||||||
|
cancelTransaction(txMeta)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmSendToken.prototype.checkValidity = function () {
|
ConfirmSendToken.prototype.checkValidity = function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user