aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-12-19 22:46:11 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-12-21 09:37:18 +0800
commit1f1fc2c49ecbb5c6a0a1d925d5c02cf48f795b2f (patch)
tree0f955a1491de5363cf49e5b6c6ccafdd1c058d64
parentbccbf14b39ab2b1670c9c30b276404fe4f949cd7 (diff)
downloadtangerine-wallet-browser-1f1fc2c49ecbb5c6a0a1d925d5c02cf48f795b2f.tar.gz
tangerine-wallet-browser-1f1fc2c49ecbb5c6a0a1d925d5c02cf48f795b2f.tar.zst
tangerine-wallet-browser-1f1fc2c49ecbb5c6a0a1d925d5c02cf48f795b2f.zip
Canceled, edited transactions show edited amount.
-rw-r--r--app/scripts/controllers/transactions.js5
-rw-r--r--app/scripts/metamask-controller.js1
-rw-r--r--ui/app/actions.js19
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js9
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js9
5 files changed, 41 insertions, 2 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index ce709bd28..0d6b97d51 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -189,6 +189,11 @@ module.exports = class TransactionController extends EventEmitter {
await this.approveTransaction(txMeta.id)
}
+ async updateAndCancelTransaction (txMeta) {
+ this.txStateManager.updateTx(txMeta, 'confTx: user rejected transaction')
+ await this.cancelTransaction(txMeta.id)
+ }
+
async approveTransaction (txId) {
let nonceLock
try {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 018eb2c76..935a3e76e 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -366,6 +366,7 @@ module.exports = class MetamaskController extends EventEmitter {
// txController
cancelTransaction: nodeify(txController.cancelTransaction, txController),
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
+ updateAndCancelTransaction: nodeify(txController.updateAndCancelTransaction, txController),
// messageManager
signMessage: nodeify(this.signMessage, this),
diff --git a/ui/app/actions.js b/ui/app/actions.js
index e694152a2..9d3d7184e 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -126,6 +126,7 @@ var actions = {
signTx: signTx,
signTokenTx: signTokenTx,
updateAndApproveTx,
+ updateAndCancelTx,
cancelTx: cancelTx,
completedTx: completedTx,
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) {
return {
type: actions.COMPLETED_TX,
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index 1264da153..01195502e 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -55,6 +55,7 @@ function mapDispatchToProps (dispatch) {
dispatch(actions.showSendPage())
},
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) {
event.preventDefault()
- this.props.cancelTransaction(txMeta)
+ const { send, updateAndCancelTx, cancelTransaction } = this.props
+
+ if (send.editingTransactionId) {
+ updateAndCancelTx(txMeta)
+ } else {
+ cancelTransaction(txMeta)
+ }
}
ConfirmSendEther.prototype.checkValidity = function () {
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index 727cd260b..e6ce3f6e6 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -89,6 +89,7 @@ function mapDispatchToProps (dispatch, ownProps) {
}))
dispatch(actions.showSendTokenPage())
},
+ updateAndCancelTx: txMeta => dispatch(actions.updateAndCancelTx(txMeta)),
}
}
@@ -415,7 +416,13 @@ ConfirmSendToken.prototype.onSubmit = function (event) {
ConfirmSendToken.prototype.cancel = function (event, txMeta) {
event.preventDefault()
- this.props.cancelTransaction(txMeta)
+ const { send, updateAndCancelTx, cancelTransaction } = this.props
+
+ if (send.editingTransactionId) {
+ updateAndCancelTx(txMeta)
+ } else {
+ cancelTransaction(txMeta)
+ }
}
ConfirmSendToken.prototype.checkValidity = function () {