mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Cancel transaction when swaps submission is failed because the simulation fails (#10288)
* Cancel transaction when swaps submission is failed because the simulation fails * Cleanup
This commit is contained in:
parent
b441b7cfdc
commit
d0df03b89a
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user