浏览代码

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
Hamza Khalid 1 年之前
父节点
当前提交
098e75d007
共有 1 个文件被更改,包括 27 次插入13 次删除
  1. 27 13
      sdk/js/src/solana/sendAndConfirmPostVaa.ts

+ 27 - 13
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.
+  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;
 }