From 95845a50415a4a7f9e0143705d3347a3ac350793 Mon Sep 17 00:00:00 2001 From: tommasini Date: Mon, 24 Jun 2024 15:51:44 +0100 Subject: [PATCH 1/2] awaiting for the result when adding a transaction before swapping for non approved tokens --- app/components/UI/Swaps/QuotesView.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/components/UI/Swaps/QuotesView.js b/app/components/UI/Swaps/QuotesView.js index 79044cba7a5..ecfe5d4c572 100644 --- a/app/components/UI/Swaps/QuotesView.js +++ b/app/components/UI/Swaps/QuotesView.js @@ -914,7 +914,8 @@ function SwapsQuotesView({ try { resetTransaction(); - const { transactionMeta } = await addTransaction( + console.log('ENTER hadnleSwapTRansaction'); + const { transactionMeta, result } = await addTransaction( { ...selectedQuote.trade, ...getTransactionPropertiesFromGasEstimates( @@ -928,6 +929,10 @@ function SwapsQuotesView({ origin: process.env.MM_FOX_CODE, }, ); + console.log('ENTER hadnleSwapTRansaction before await result', result); + + await result; + console.log('ENTER hadnleSwapTRansaction before after result', result); updateSwapsTransactions( transactionMeta, @@ -965,7 +970,7 @@ function SwapsQuotesView({ ) => { try { resetTransaction(); - const { transactionMeta } = await addTransaction( + const { transactionMeta, result } = await addTransaction( { ...approvalTransaction, ...getTransactionPropertiesFromGasEstimates( @@ -979,6 +984,7 @@ function SwapsQuotesView({ }, ); + await result; setRecipient(selectedAddress); approvalTransactionMetaId = transactionMeta.id; @@ -1041,9 +1047,9 @@ function SwapsQuotesView({ const newSwapsTransactions = TransactionController.state.swapsTransactions || {}; let approvalTransactionMetaId; - + console.log('ENTER handleCompleteSwap', approvalTransaction); if (approvalTransaction) { - handleApprovaltransaction( + await handleApprovaltransaction( TransactionController, newSwapsTransactions, approvalTransactionMetaId, @@ -1060,7 +1066,7 @@ function SwapsQuotesView({ !shouldUseSmartTransaction || (shouldUseSmartTransaction && !approvalTransaction) ) { - handleSwapTransaction( + await handleSwapTransaction( TransactionController, newSwapsTransactions, approvalTransactionMetaId, From b001488fd54d6f44f8a3e86e3644c6f659bed66d Mon Sep 17 00:00:00 2001 From: tommasini Date: Mon, 24 Jun 2024 15:54:33 +0100 Subject: [PATCH 2/2] remove unncessary lgos --- app/components/UI/Swaps/QuotesView.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/components/UI/Swaps/QuotesView.js b/app/components/UI/Swaps/QuotesView.js index ecfe5d4c572..f2b597fcb46 100644 --- a/app/components/UI/Swaps/QuotesView.js +++ b/app/components/UI/Swaps/QuotesView.js @@ -914,7 +914,6 @@ function SwapsQuotesView({ try { resetTransaction(); - console.log('ENTER hadnleSwapTRansaction'); const { transactionMeta, result } = await addTransaction( { ...selectedQuote.trade, @@ -929,10 +928,8 @@ function SwapsQuotesView({ origin: process.env.MM_FOX_CODE, }, ); - console.log('ENTER hadnleSwapTRansaction before await result', result); await result; - console.log('ENTER hadnleSwapTRansaction before after result', result); updateSwapsTransactions( transactionMeta, @@ -1047,7 +1044,6 @@ function SwapsQuotesView({ const newSwapsTransactions = TransactionController.state.swapsTransactions || {}; let approvalTransactionMetaId; - console.log('ENTER handleCompleteSwap', approvalTransaction); if (approvalTransaction) { await handleApprovaltransaction( TransactionController,