From ff9baa2ca68e5957d9b8f73861da802536a12ebc Mon Sep 17 00:00:00 2001 From: Sebastian Scatularo Date: Sat, 12 Aug 2023 23:06:01 -0300 Subject: [PATCH] code review observation --- src/hooks/useHandleRedeem.tsx | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/hooks/useHandleRedeem.tsx b/src/hooks/useHandleRedeem.tsx index df336b0e1..92be801dc 100644 --- a/src/hooks/useHandleRedeem.tsx +++ b/src/hooks/useHandleRedeem.tsx @@ -352,19 +352,19 @@ async function solana( throw new Error("wallet.signTransaction is undefined"); } const connection = new Connection(SOLANA_HOST, "confirmed"); + // TODO compute the amount of tx that postVaaSolanaWithRetry + // will create to notice the user up front + // we could call createPostSignedVaaTransactions to create fake txs + // and read the length of the array + await postVaaSolanaWithRetry( + connection, + wallet.signTransaction.bind(wallet), + SOL_BRIDGE_ADDRESS, + payerAddress, + Buffer.from(signedVAA), + MAX_VAA_UPLOAD_RETRIES_SOLANA + ); if (isTbtc) { - // TODO compute the amount of tx that postVaaSolanaWithRetry - // will create to notice the user up front - // we could call createPostSignedVaaTransactions to create fake txs - // and read the length of the array - await postVaaSolanaWithRetry( - connection, - wallet.signTransaction.bind(wallet), - SOL_BRIDGE_ADDRESS, - payerAddress, - Buffer.from(signedVAA), - MAX_VAA_UPLOAD_RETRIES_SOLANA - ); const tbtcGateway = newThresholdWormholeGateway(connection, wallet); const transaction = await tbtcGateway.receiveTbtc( signedVAA, @@ -376,14 +376,6 @@ async function solana( content: Transaction confirmed, }); } else { - await postVaaSolanaWithRetry( - connection, - wallet.signTransaction.bind(wallet), - SOL_BRIDGE_ADDRESS, - payerAddress, - Buffer.from(signedVAA), - MAX_VAA_UPLOAD_RETRIES_SOLANA - ); // TODO: how do we retry in between these steps const transaction = isNative ? await redeemAndUnwrapOnSolana(