diff --git a/ui/app/ducks/swaps/swaps.js b/ui/app/ducks/swaps/swaps.js index bd029d4ef..d67e8c994 100644 --- a/ui/app/ducks/swaps/swaps.js +++ b/ui/app/ducks/swaps/swaps.js @@ -23,6 +23,7 @@ import { setSwapsLiveness, setSelectedQuoteAggId, setSwapsTxGasLimit, + cancelTx, } from '../../store/actions' import { AWAITING_SWAP_ROUTE, @@ -705,6 +706,7 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => { // transactions that get published to the blockchain only to fail and thereby // waste the user's funds on gas. if (!approveTxParams && tradeTxMeta.simulationFails) { + await dispatch(cancelTx(tradeTxMeta, false)) await dispatch(setSwapsErrorKey(SWAP_FAILED_ERROR)) history.push(SWAPS_ERROR_ROUTE) return diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 0dd31dc9f..9cf6196d8 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -1048,9 +1048,9 @@ export function cancelTypedMsg(msgData) { } } -export function cancelTx(txData) { +export function cancelTx(txData, _showLoadingIndication = true) { return (dispatch) => { - dispatch(showLoadingIndication()) + _showLoadingIndication && dispatch(showLoadingIndication()) return new Promise((resolve, reject) => { background.cancelTransaction(txData.id, (error) => { if (error) {