Эх сурвалжийг харах

refactor: optional blockhash (#7)

* refactor: optional blockhash

* chore: changeset
Nick Frostbutter 11 сар өмнө
parent
commit
d3e7220c8f

+ 5 - 0
.changeset/flat-carrots-hang.md

@@ -0,0 +1,5 @@
+---
+"gill": patch
+---
+
+make the `latestBlockhash` in `createTransaction` optional

+ 3 - 1
packages/gill/src/core/transactions.ts

@@ -21,11 +21,13 @@ export function createTransaction({
   return pipe(
     createTransactionMessage({ version }),
     (tx) => {
+      if (latestBlockhash) {
+        tx = setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx);
+      }
       if ("address" in feePayer && isTransactionSigner(feePayer)) {
         return setTransactionMessageFeePayerSigner(feePayer, tx);
       } else return setTransactionMessageFeePayer(feePayer, tx);
     },
-    (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
     (tx) => appendTransactionMessageInstructions(instructions, tx),
   );
 }

+ 1 - 1
packages/gill/src/types/transactions.ts

@@ -21,7 +21,7 @@ export type CreateTransactionInput = {
    * Latest blockhash (aka transaction lifetime) for this transaction to
    * accepted for execution on the Solana network
    * */
-  latestBlockhash: Readonly<{
+  latestBlockhash?: Readonly<{
     blockhash: Blockhash;
     lastValidBlockHeight: bigint;
   }>;