import { AnchorProvider } from '@coral-xyz/anchor'; import { type Commitment, type ConfirmOptions, type Connection, type Signer, type Transaction, type TransactionSignature, type VersionedTransaction } from '@solana/web3.js'; /** Delay between signature-status polls. */ export declare const CONFIRM_POLL_INTERVAL_MS = 2000; /** * Wall-clock backstop, also bounding every in-flight RPC read (web3.js sets no * request timeout). Expiry is normally seen first: a blockhash lasts ~150 * blocks (~60s, longer when slots are skipped), and the finalized height it is checked against lags ~13s. */ export declare const CONFIRM_TIMEOUT_MS = 120000; /** Cap on a single RPC read, so a hung request counts as a failed read rather than eating the backstop. */ export declare const CONFIRM_READ_TIMEOUT_MS = 10000; /** Ceiling for the doubling wait after polls whose reads failed. */ export declare const CONFIRM_MAX_BACKOFF_MS = 16000; /** * Wait for a sent transaction to reach `commitment`, over HTTP only. * * Anchor's `.rpc()` confirms by signature alone: a WebSocket * `signatureSubscribe` raced against a fixed 30s (`confirmed`) or 60s * (`finalized`) timer, so a transaction that landed is reported as failed * whenever the notification is missed. This polls `getSignatureStatuses`, and * ends on the blockhash's real expiry rather than a timer. * * It never reports that resubmitting is safe. An expired transaction that no * lookup can find very likely never landed, but an RPC node with incomplete * history cannot prove it, and a wrong "safe" duplicates a deposit or redeem. * * @param connection - Connection the transaction was sent through. * @param signature - Signature returned by `sendRawTransaction`. * @param lastValidBlockHeight - Expiry of the blockhash the signed * transaction carries, checked against the finalized block height. Omit * when unknown (or for a durable-nonce transaction): the wait then ends only * on confirmation, failure or `timeoutMs`. * @param commitment - Level the transaction must reach. * @param pollIntervalMs - Delay between polls; must be positive. Defaults to {@link CONFIRM_POLL_INTERVAL_MS}. * @param timeoutMs - Wall-clock backstop; must be positive. Defaults to {@link CONFIRM_TIMEOUT_MS}. * @param readTimeoutMs - Cap on each RPC read; must be positive. Defaults to {@link CONFIRM_READ_TIMEOUT_MS}. * @returns `signature`, once its status reaches `commitment` with no error. * @throws {@link SendTransactionError} when the transaction failed at * `commitment`, with logs attached for Anchor's `translateError`. * @throws {@link AugustTransactionError} `TRANSACTION_UNCONFIRMED` when no * outcome was established: the blockhash expired with the transaction * nowhere to be found, or `timeoutMs` passed. `context.reason` is * `expired_not_found` (very likely never landed — still check before * resubmitting), `below_commitment` (seen landing without error), * `failed_below_commitment` (seen failing, not yet final), `rpc_failing` * (reads failed) or `not_visible`; `context` also carries the last status * seen and read counts, and `cause` the last failed read. * @throws {@link AugustValidationError} for a non-positive or non-finite interval or timeout. * @remarks **RPC cost.** The first poll runs right after sending. Per poll: one `getSignatureStatuses`, plus one * finalized `getBlockHeight` while the transaction is not visible (and, past * expiry, one history lookup). Typically 1–3 calls at `confirmed`, ~7–10 at * `finalized`, ~60 for an expiring transaction; the `timeoutMs` backstop * allows ~60 polls of 1–3 calls, fewer while reads fail: the wait doubles * after each poll with a failed read, up to {@link CONFIRM_MAX_BACKOFF_MS}. Failed reads are tolerated, so a transient RPC * error never misreports a landed transaction. */ export declare function confirmByBlockhash({ connection, signature, lastValidBlockHeight, commitment, pollIntervalMs, timeoutMs, readTimeoutMs, }: { connection: Connection; signature: TransactionSignature; lastValidBlockHeight?: number; commitment: Commitment; pollIntervalMs?: number; timeoutMs?: number; readTimeoutMs?: number; }): Promise; /** * `AnchorProvider` whose `sendAndConfirm` — what `program.methods…rpc()` calls — * confirms with {@link confirmByBlockhash} instead of Anchor's signature-only * WebSocket wait. Signing and Anchor's error translation are unchanged. */ export declare class BlockhashConfirmingProvider extends AnchorProvider { /** * Sign, send and confirm a transaction. * * @param tx - Transaction to send. Its blockhash (and fee payer, if unset) * are set here. A `VersionedTransaction` already carries a blockhash this * cannot learn the expiry of, so it takes Anchor's default path. * @param signers - Extra signers besides the wallet. * @param opts - Defaults to the provider's options. * @returns The transaction signature. * @throws See {@link confirmByBlockhash}; also whatever the wallet or * `sendRawTransaction` throws (user rejection, preflight failure). * @remarks **RPC cost.** `getLatestBlockhash` + `sendRawTransaction`, then * the confirmation polls described on {@link confirmByBlockhash}. */ sendAndConfirm(tx: Transaction | VersionedTransaction, signers?: Signer[], opts?: ConfirmOptions): Promise; }