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
This commit is contained in:
Hamza Khalid 2024-03-14 19:59:23 +05:00 committed by GitHub
parent 5700b3cf8f
commit 098e75d007
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 14 deletions

View File

@ -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;
}