From 43de189d067f8cf03cdd97380cbe2487319271eb Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Sun, 9 Sep 2018 10:07:23 -0700 Subject: Add createCancelTransaction method --- ui/app/actions.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 6d5b1ef3f..ae7d3b761 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -315,6 +315,8 @@ var actions = { CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS', setPendingTokens, clearPendingTokens, + + createCancelTransaction, } module.exports = actions @@ -1766,6 +1768,29 @@ function retryTransaction (txId) { } } +function createCancelTransaction (txId, customGasPrice) { + log.debug('background.cancelTransaction') + let newTxId + + return dispatch => { + return new Promise((resolve, reject) => { + background.createCancelTransaction(txId, customGasPrice, (err, newState) => { + if (err) { + dispatch(actions.displayWarning(err.message)) + reject(err) + } + + const { selectedAddressTxList } = newState + const { id } = selectedAddressTxList[selectedAddressTxList.length - 1] + newTxId = id + resolve(newState) + }) + }) + .then(newState => dispatch(actions.updateMetamaskState(newState))) + .then(() => newTxId) + } +} + // // config // -- cgit