Skip to content

Commit

Permalink
sdk/js: Replace deprecated function with signSendAndConfirmTransaction (
Browse files Browse the repository at this point in the history
#3239)

* sdk/js/solana: Replace deprecated function with signSendAndConfirmTransaction

* chore: prettier formatting

* sdk/js: deprecate postVaaWithRetry in favor of postVaa
  • Loading branch information
hmzakhalid authored Mar 14, 2024
1 parent 5700b3c commit 098e75d
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions sdk/js/src/solana/sendAndConfirmPostVaa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
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 sendAndConfirmTransactionsWithRetry(
await signSendAndConfirmTransaction(
connection,
payer,
signTransaction,
payer.toString(),
[postVaaTransaction],
maxRetries
))
postVaaTransaction,
options
)
);
return responses;
}
Expand Down

0 comments on commit 098e75d

Please sign in to comment.