Skip to content

Commit

Permalink
refactor: optional blockhash (#7)
Browse files Browse the repository at this point in the history
* refactor: optional blockhash

* chore: changeset
  • Loading branch information
nickfrosty authored Dec 17, 2024
1 parent 89321b7 commit d3e7220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-carrots-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gill": patch
---

make the `latestBlockhash` in `createTransaction` optional
4 changes: 3 additions & 1 deletion packages/gill/src/core/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
2 changes: 1 addition & 1 deletion packages/gill/src/types/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>;
Expand Down

0 comments on commit d3e7220

Please sign in to comment.