From 098e75d00753ee9f806d739d95686c5ab1b8e8d4 Mon Sep 17 00:00:00 2001 From: Hamza Khalid <36852564+hmzakhalid@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:59:23 +0500 Subject: [PATCH] sdk/js: Replace deprecated function with signSendAndConfirmTransaction (#3239) * sdk/js/solana: Replace deprecated function with signSendAndConfirmTransaction * chore: prettier formatting * sdk/js: deprecate postVaaWithRetry in favor of postVaa --- sdk/js/src/solana/sendAndConfirmPostVaa.ts | 42 ++++++++++++++-------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/sdk/js/src/solana/sendAndConfirmPostVaa.ts b/sdk/js/src/solana/sendAndConfirmPostVaa.ts index e6be2301a..f77fd4337 100644 --- a/sdk/js/src/solana/sendAndConfirmPostVaa.ts +++ b/sdk/js/src/solana/sendAndConfirmPostVaa.ts @@ -20,6 +20,10 @@ import { } from "./wormhole"; import { isBytes, ParsedVaa, parseVaa, SignedVaa } from "../vaa/wormhole"; +/** + * @deprecated Please use {@link postVaa} instead, which allows + * retries and commitment to be configured in {@link ConfirmOptions}. + */ export async function postVaaWithRetry( connection: Connection, signTransaction: SignTransaction, @@ -40,22 +44,32 @@ export async function postVaaWithRetry( const postVaaTransaction = unsignedTransactions.pop()!; - const responses = await sendAndConfirmTransactionsWithRetry( - connection, - modifySignTransaction(signTransaction, ...signers), - payer.toString(), - unsignedTransactions, - maxRetries - ); - //While the signature_set is used to create the final instruction, it doesn't need to sign it. - responses.push( - ...(await sendAndConfirmTransactionsWithRetry( + const options: ConfirmOptions = { + commitment, + maxRetries, + }; + + const responses: TransactionSignatureAndResponse[] = []; + for (const transaction of unsignedTransactions) { + const response = await signSendAndConfirmTransaction( connection, + payer, + modifySignTransaction(signTransaction, ...signers), + transaction, + options + ); + responses.push(response); + } + + // While the signature_set is used to create the final instruction, it doesn't need to sign it. + responses.push( + await signSendAndConfirmTransaction( + connection, + payer, signTransaction, - payer.toString(), - [postVaaTransaction], - maxRetries - )) + postVaaTransaction, + options + ) ); return responses; }