From 37304c5c2ef02a639b8ef9ab271dce7cd92fcc81 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 23 Sep 2024 13:32:01 -0300 Subject: [PATCH] remove mocked values --- src/pages/swap/index.tsx | 11 ++++--- src/services/signedTransactions.ts | 46 ++++++++++++------------------ 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/pages/swap/index.tsx b/src/pages/swap/index.tsx index ede0126a..6b1e09e3 100644 --- a/src/pages/swap/index.tsx +++ b/src/pages/swap/index.tsx @@ -182,12 +182,11 @@ export const SwapPage = () => { // Do not show any error if the user is disconnected if (isDisconnected) return; - // TESTING - TODO: Remove comment - // if (typeof userInputTokenBalance === 'string') { - // if (Big(userInputTokenBalance).lt(fromAmount ?? 0)) { - // return `Insufficient balance. Your balance is ${userInputTokenBalance} ${fromToken?.assetSymbol}.`; - // } - // } + if (typeof userInputTokenBalance === 'string') { + if (Big(userInputTokenBalance).lt(fromAmount ?? 0)) { + return `Insufficient balance. Your balance is ${userInputTokenBalance} ${fromToken?.assetSymbol}.`; + } + } const amountOut = tokenOutData.data?.amountOut; diff --git a/src/services/signedTransactions.ts b/src/services/signedTransactions.ts index cabb1134..bd26cd9b 100644 --- a/src/services/signedTransactions.ts +++ b/src/services/signedTransactions.ts @@ -39,38 +39,28 @@ export async function prepareTransactions(state: OfframpingState, context: Execu squidRouterReceiverHash, } = state; - // TESTING - TODO: Remove commented - // const spacewalkRedeemTransaction = await prepareSpacewalkRedeemTransaction(state, context); - // const nablaApproveTransaction = await prepareNablaApproveTransaction(state, context); - // const nablaSwapTransaction = await prepareNablaSwapTransaction(state, context); + const spacewalkRedeemTransaction = await prepareSpacewalkRedeemTransaction(state, context); + const nablaApproveTransaction = await prepareNablaApproveTransaction(state, context); + const nablaSwapTransaction = await prepareNablaSwapTransaction(state, context); - // // Fund Stellar ephemeral only after all other transactions are prepared - // await stellarCreateEphemeral(stellarEphemeralSecret, outputTokenType); - // const stellarFundingAccountId = (await fetchSigningServiceAccountId()).stellar.public; + // Fund Stellar ephemeral only after all other transactions are prepared + await stellarCreateEphemeral(stellarEphemeralSecret, outputTokenType); + const stellarFundingAccountId = (await fetchSigningServiceAccountId()).stellar.public; const stellarEphemeralKeypair = Keypair.fromSecret(stellarEphemeralSecret); const stellarEphemeralPublicKey = stellarEphemeralKeypair.publicKey(); - // const { offrampingTransaction, mergeAccountTransaction } = await setUpAccountAndOperations( - // stellarFundingAccountId, - // stellarEphemeralKeypair, - // sepResult, - // outputTokenType, - // ); - - // const transactions = { - // stellarOfframpingTransaction: offrampingTransaction.toEnvelope().toXDR().toString('base64'), - // stellarCleanupTransaction: mergeAccountTransaction.toEnvelope().toXDR().toString('base64'), - // spacewalkRedeemTransaction: encodeSubmittableExtrinsic(spacewalkRedeemTransaction), - // nablaSwapTransaction: encodeSubmittableExtrinsic(nablaSwapTransaction), - // nablaApproveTransaction: encodeSubmittableExtrinsic(nablaApproveTransaction), - // }; + const { offrampingTransaction, mergeAccountTransaction } = await setUpAccountAndOperations( + stellarFundingAccountId, + stellarEphemeralKeypair, + sepResult, + outputTokenType, + ); - // mock all const transactions = { - stellarOfframpingTransaction: 'stellarOfframpingTransaction', - stellarCleanupTransaction: 'stellarCleanupTransaction', - spacewalkRedeemTransaction: 'spacewalkRedeemTransaction', - nablaSwapTransaction: 'nablaSwapTransaction', - nablaApproveTransaction: 'nablaApproveTransaction', + stellarOfframpingTransaction: offrampingTransaction.toEnvelope().toXDR().toString('base64'), + stellarCleanupTransaction: mergeAccountTransaction.toEnvelope().toXDR().toString('base64'), + spacewalkRedeemTransaction: encodeSubmittableExtrinsic(spacewalkRedeemTransaction), + nablaSwapTransaction: encodeSubmittableExtrinsic(nablaSwapTransaction), + nablaApproveTransaction: encodeSubmittableExtrinsic(nablaApproveTransaction), }; const apiManager = await getApiManagerInstance(); @@ -102,7 +92,7 @@ export async function prepareTransactions(state: OfframpingState, context: Execu squidRouterReceiverId, squidRouterReceiverHash, }; - //await storeDataInBackend(data); + await storeDataInBackend(data); } catch (error) { console.error('Error storing data', error); }