From ac337b0c3aedb5484bcb8069daf1884d2d8b7f0b Mon Sep 17 00:00:00 2001 From: dan437 <80175477+dan437@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:12:03 +0200 Subject: [PATCH 1/2] Allow to re-submit cancelled swap if cancelled via a HW wallet --- ui/ducks/swaps/swaps.js | 1 + ui/pages/swaps/prepare-swap-page/review-quote.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index 6032d46814ef..8abb63aa4a14 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -1029,6 +1029,7 @@ export const signAndSendSwapsSmartTransaction = ({ dispatch(setSwapsSTXSubmitLoading(false)); } catch (e) { console.log('signAndSendSwapsSmartTransaction error', e); + dispatch(setSwapsSTXSubmitLoading(false)); const { swaps: { isFeatureFlagLoaded }, } = getState(); diff --git a/ui/pages/swaps/prepare-swap-page/review-quote.js b/ui/pages/swaps/prepare-swap-page/review-quote.js index 0dc3f89009cb..7713c871adc1 100644 --- a/ui/pages/swaps/prepare-swap-page/review-quote.js +++ b/ui/pages/swaps/prepare-swap-page/review-quote.js @@ -963,17 +963,19 @@ export default function ReviewQuote({ setReceiveToAmount }) { }, [dispatch, trackViewQuotePageLoadedEvent, reviewSwapClickedTimestamp]); useEffect(() => { - // if smart transaction error is turned off, reset submit clicked boolean if ( - !currentSmartTransactionsEnabled && - currentSmartTransactionsError && - submitClicked + (!currentSmartTransactionsEnabled && + currentSmartTransactionsError && + submitClicked) || + (isSmartTransaction && !swapsSTXLoading && submitClicked) ) { setSubmitClicked(false); } }, [ currentSmartTransactionsEnabled, currentSmartTransactionsError, + isSmartTransaction, + swapsSTXLoading, submitClicked, ]); From 92749ba61cb672277860f33a74880d4cba13f2fa Mon Sep 17 00:00:00 2001 From: dan437 <80175477+dan437@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:53:52 +0200 Subject: [PATCH 2/2] Small refactor --- ui/ducks/swaps/swaps.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index 8abb63aa4a14..fab4e3288237 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -973,7 +973,6 @@ export const signAndSendSwapsSmartTransaction = ({ ); if (!fees) { log.error('"fetchSwapsSmartTransactionFees" failed'); - dispatch(setSwapsSTXSubmitLoading(false)); dispatch(setCurrentSmartTransactionsError(StxErrorTypes.unavailable)); return; } @@ -1026,10 +1025,8 @@ export const signAndSendSwapsSmartTransaction = ({ ); } history.push(SMART_TRANSACTION_STATUS_ROUTE); - dispatch(setSwapsSTXSubmitLoading(false)); } catch (e) { console.log('signAndSendSwapsSmartTransaction error', e); - dispatch(setSwapsSTXSubmitLoading(false)); const { swaps: { isFeatureFlagLoaded }, } = getState(); @@ -1037,6 +1034,8 @@ export const signAndSendSwapsSmartTransaction = ({ const errorObj = parseSmartTransactionsError(e.message); dispatch(setCurrentSmartTransactionsError(errorObj?.error)); } + } finally { + dispatch(setSwapsSTXSubmitLoading(false)); } }; };