import { web3 } from "@coral-xyz/anchor"; import { type TransactionExecutionOptions } from "../utils"; /** * Async callback that accepts a built transaction, signs it with the * caller's wallet (in-place is fine), and returns the same transaction. * * Generic over both legacy and versioned transactions so the same function * signature can be used regardless of which {@link TransactionPayload} * produces internally. Callers typically branch on `instanceof web3.Transaction` * vs `instanceof web3.VersionedTransaction` to pick the right signing API. */ export type SignTransactionFunction = (transaction: T) => Promise; /** * High-level builder for a single Solana transaction. * * Wraps the standard "build → (optionally simulate for priority fee) → * sign → send → confirm" pipeline with: * - automatic compute-budget / priority-fee instruction injection, * - retry on transient send errors, * - error translation via {@link parseSolanaSendTransactionError}. * * For sending multiple independent transactions in one call, see * `MultiTransactionPayload`. */ export declare class TransactionPayload { private readonly _connection; private readonly _errors; readonly transactionData: { readonly instructions: web3.TransactionInstruction[]; readonly feePayer: web3.PublicKey; readonly signers?: web3.Signer[]; readonly addressLookupTableAccounts?: web3.AddressLookupTableAccount[]; }; private readonly _signTransaction?; private static readonly ERROR_MESSAGES; /** * @param _connection Solana RPC connection used for blockhash fetch, * simulation, send, and confirm. * @param _errors Map of program error codes → messages from the * program's IDL. Forwarded to * {@link parseSolanaSendTransactionError}. * @param transactionData Instructions + fee payer + (optional) signers * and address-lookup tables that make up the * single transaction. * @param _signTransaction Wallet-supplied signing callback. Required by * {@link execute}; optional only when the caller * is going to use {@link buildVersionTransaction} * or {@link simulate} without `sigVerify`. */ constructor(_connection: web3.Connection, _errors: Map, transactionData: { readonly instructions: web3.TransactionInstruction[]; readonly feePayer: web3.PublicKey; readonly signers?: web3.Signer[]; readonly addressLookupTableAccounts?: web3.AddressLookupTableAccount[]; }, _signTransaction?: SignTransactionFunction | undefined); /** * Simulates the transaction against the cluster. * * Used in two modes: * - `sigVerify: false` (default) — cheap dry-run that returns * `unitsConsumed` and any execution `err`, used by {@link execute} * to size the compute-unit limit before sending. * - `sigVerify: true` — performs full signature verification; requires * a `_signTransaction` callback because the transaction needs real * signatures for the RPC to accept it. * * Note: this resolves successfully with `result.value.err !== null` when * the transaction would fail at runtime (e.g. insufficient funds). It * only throws on RPC-level errors (bad blockhash, sigVerify mismatch), * which are then routed through Anchor's `translateError`. */ simulate(options?: web3.SimulateTransactionConfig): Promise>; /** * Builds — but does **not** broadcast — a `VersionedTransaction` from the * configured `transactionData`. Useful when the caller wants full control * over signing or wants to inspect the compiled message before sending. * * If `transactionData.signers` is non-empty, they are applied here so the * returned transaction has its non-fee-payer signatures already populated. * The fee-payer signature still has to be supplied externally. */ buildVersionTransaction(blockhash: string): web3.VersionedTransaction; /** * Returns the compute-budget instructions that need to be prepended to the * transaction. Skips either instruction kind (`SetComputeUnitLimit` / * `SetComputeUnitPrice`) when the caller already supplied one in * `transactionData.instructions`, so user-provided budget settings always * win. */ private getPriorityFeeInstructions; /** * Resolves the per-CU priority fee to attach. * * - If `exactPriorityFeeSol` is set: pay exactly that much (in SOL) * above the base fee, distributed across the compute budget. Useful * when the caller wants deterministic spend. * - Otherwise: derive a fee from recent cluster activity via * `getRecentPriorityFee`, capped by `maxPriorityFeeSol` so a bursty * network can't accidentally drain wallets. */ private calculatePriorityFee; /** * End-to-end happy path: simulate (for compute units) → attach priority * fee → fetch blockhash → build VersionedTransaction → sign → send + * confirm. * * Any error from any step is funneled through * {@link parseSolanaSendTransactionError} so callers always see a * normalized `Error` (Anchor error / insufficient-funds / etc). * * @param options Standard `ConfirmOptions` plus retry / priority-fee * tuning. `enablePriorityFee` defaults to `true`. * @returns bs58-encoded transaction signature. */ execute(options?: TransactionExecutionOptions): Promise; }