Skip to content

Commit

Permalink
feat: sendAndConfirmTransaction handle signing (#54)
Browse files Browse the repository at this point in the history
* feat: sendAndConfirmTransaction handle signing

* refactor: type
  • Loading branch information
nickfrosty authored Feb 26, 2025
1 parent 2658159 commit 8139481
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nervous-rivers-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gill": minor
---

allow `sendAndConfirmTransaction` to also handle signing
7 changes: 6 additions & 1 deletion packages/gill/src/kit/send-and-confirm-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import {
import type { FullySignedTransaction, TransactionWithBlockhashLifetime } from '@solana/transactions';

import { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';
import type { CompilableTransactionMessage } from '@solana/transaction-messages';
import { signTransactionMessageWithSigners } from '@solana/signers';

export type SendAndConfirmTransactionWithBlockhashLifetimeFunction = (
transaction: FullySignedTransaction & TransactionWithBlockhashLifetime,
transaction: (FullySignedTransaction & TransactionWithBlockhashLifetime) | CompilableTransactionMessage,
config?: Omit<
Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],
'confirmRecentTransaction' | 'rpc' | 'transaction'
Expand Down Expand Up @@ -65,6 +67,9 @@ export function sendAndConfirmTransactionFactory<TCluster extends 'devnet' | 'ma
}

return async function sendAndConfirmTransaction(transaction, config = { commitment: "confirmed" }) {
if ("messageBytes" in transaction == false){
transaction = await signTransactionMessageWithSigners(transaction) as Readonly<FullySignedTransaction & TransactionWithBlockhashLifetime>;
}
return await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({
...config,
confirmRecentTransaction,
Expand Down

0 comments on commit 8139481

Please sign in to comment.