Skip to content

Commit

Permalink
feat: sendAndConfirmTransaction handle signing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty committed Feb 26, 2025
1 parent 2658159 commit e58ed47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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
9 changes: 7 additions & 2 deletions packages/gill/src/kit/send-and-confirm-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
createRecentSignatureConfirmationPromiseFactory,
waitForRecentTransactionConfirmation,
} from '@solana/transaction-confirmation';
import type { FullySignedTransaction, TransactionWithBlockhashLifetime } from '@solana/transactions';
import { type FullySignedTransaction, type 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 e58ed47

Please sign in to comment.