import { ApiRejectedDetails } from "./shared/api_response"; export type HttpErrorVariant = "Request" | "ServerError" | "RateLimited" | "Unauthorized" | "NotFound" | "BadRequest" | "Timeout" | "MaxRetriesExceeded"; export declare class HttpError extends Error { readonly variant: HttpErrorVariant; readonly status?: number; readonly body?: string; readonly retryAfterMs?: number; readonly attempts?: number; constructor(params: { variant: HttpErrorVariant; message: string; status?: number; body?: string; retryAfterMs?: number; attempts?: number; }); static request(message: string): HttpError; static timeout(): HttpError; static unauthorized(): HttpError; static notFound(body: string): HttpError; static badRequest(body: string): HttpError; static rateLimited(retryAfterMs?: number): HttpError; static serverError(status: number, body: string): HttpError; /** * NOT produced by the SDK's HTTP retry loop. On retry exhaustion the FINAL * attempt's error propagates unchanged — structured rejection details, * status classification (isUnauthorized etc.), and request id intact — * because flattening it into this wrapper's message string would destroy * everything callers switch on (see the retry-exhaustion tests). The * factory stays public for consumers that build their own retry loops on * the raw/no-restore primitives and want a conventional exhaustion error. */ static maxRetriesExceeded(attempts: number, lastError: string): HttpError; } export type WsErrorVariant = "NotConnected" | "ConnectionFailed" | "SendFailed" | "DeserializationError" | "ProtocolError" | "Closed"; export declare class WsError extends Error { readonly variant: WsErrorVariant; readonly code?: number; constructor(variant: WsErrorVariant, message: string, code?: number); } export type AuthErrorVariant = "NotAuthenticated" | "LoginFailed" | "SignatureVerificationFailed" | "TokenExpired"; export declare class AuthError extends Error { readonly variant: AuthErrorVariant; constructor(variant: AuthErrorVariant, message: string); } export type SdkErrorVariant = "Http" | "Ws" | "Auth" | "Validation" | "InsufficientSolForTransactionFees" | "Serde" | "MissingMarketContext" | "Signing" | "UserCancelled" | "TransactionFailed" | "TransactionExpired" | "SubmissionUnknown" | "SubmissionRejected" | "ConfirmationTimeout" | "ApiRejected" | "Program" | "Other"; export declare class SdkError extends Error { readonly variant: SdkErrorVariant; readonly causeError?: Error; readonly apiRejectedDetails?: ApiRejectedDetails; /** Transaction signature, set on submission and confirmation errors. */ readonly signature?: string; readonly lastValidBlockHeight?: number; /** JSON-RPC rejection code, when the node rejected this send before queuing it. */ readonly rpcCode?: number; /** Confirmed Native SOL Balance in the declared fee payer, in lamports. */ readonly availableLamports?: bigint; /** Exact transaction fee or planner-owned reserve required, in lamports. */ readonly requiredLamports?: bigint; constructor(variant: SdkErrorVariant, message: string, causeError?: Error, apiRejectedDetails?: ApiRejectedDetails, signature?: string, availableLamports?: bigint, requiredLamports?: bigint, lastValidBlockHeight?: number, rpcCode?: number); /** Submission may have reached the cluster; reconcile before rebuilding. */ static submissionUnknown(signature: string, lastValidBlockHeight: number, reason: string): SdkError; /** A definite RPC rejection before queuing this send; never retried automatically. */ static submissionRejected(signature: string, code: number, reason: string): SdkError; static from(error: unknown): SdkError; static validation(message: string): SdkError; /** Return the typed contract for a proven transaction-fee funding shortfall. */ static insufficientSolForTransactionFees(availableLamports: bigint, requiredLamports: bigint): SdkError; static serde(message: string): SdkError; static missingMarketContext(message: string): SdkError; static signing(message: string): SdkError; static userCancelled(): SdkError; static transactionFailed(signature: string, error: string): SdkError; static transactionExpired(signature: string): SdkError; static confirmationTimeout(signature: string): SdkError; static apiRejected(details: ApiRejectedDetails): SdkError; } /** * True when the backend rejected a request as unauthenticated (HTTP 401) — * either a bare 401 (`HttpError` with variant `Unauthorized`) or a 401 that * carried a structured rejection envelope (`SdkError` `ApiRejected` with an * `httpStatus` of 401). Lets callers decide whether refreshing credentials * and retrying makes sense without matching on backend error strings. * Accepts `unknown` because the transport surfaces both `HttpError` and * `SdkError` to callers. */ export declare function isUnauthorized(error: unknown): boolean; //# sourceMappingURL=error.d.ts.map