diff options
Merge pull request #5216 from MetaMask/tx-cancel
Add createCancelTransaction method
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 846a8cb8f..462d75d13 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 @@ -1772,6 +1774,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 // |