/** * Contract error decoding. * * Maps on-chain smart-wallet failure codes (surfaced in simulation/submission * diagnostics as `Error(Contract, #N)`) to typed {@link ContractError}s with the * enum variant name and a human-readable message. * * The `SmartWallet` family is the source of truth in the generated bindings' * `Errors` map; `contract-errors.test.ts` asserts this registry stays in sync * with it, so a bindings regen surfaces any drift. * * The v1 contract deliberately renumbered its error space to 100-129 so it is * disjoint from the legacy (pre-1.0) 1-9 range: a decoded code < 100 means the * client is talking to a legacy wallet. Both ranges are kept here so errors * from legacy deployed wallets still decode (family `SmartWalletLegacy`). * * @packageDocumentation */ import { ContractError, PasskeyKitError } from "./errors.js"; import type { TransactionFailure } from "./types.js"; /** * Contract families that expose custom error codes. */ export type ContractErrorFamily = "SmartWallet" | "SmartWalletLegacy"; /** * A single contract error entry: code, enum variant name, family, and a * human-readable message. */ export interface ContractErrorInfo { code: number; name: string; family: ContractErrorFamily; message: string; } /** * Registry of every known contract error code, keyed by numeric code. */ export declare const CONTRACT_ERROR_REGISTRY: Readonly>; /** * Build a {@link ContractError} for a known contract code, or `null` if the code * is not in the registry. */ export declare function contractErrorFromCode(code: number, context?: Record): ContractError | null; /** * Decode a simulation/submission diagnostic into a typed {@link ContractError}. * * Scans the (stringified) diagnostic for an `Error(Contract, #N)` marker and * looks the code up in {@link CONTRACT_ERROR_REGISTRY}. Returns `null` when no * contract code is present or the code is unknown, letting callers fall back to * a generic {@link SimulationError}/{@link SubmissionError}. */ export declare function decodeContractError(diagnostic: unknown): ContractError | null; /** * Build a {@link TransactionFailure} from an already-typed error. */ export declare function failedTransaction(error: PasskeyKitError, hash?: string): TransactionFailure; /** * Build a {@link TransactionFailure} from a simulation diagnostic, decoding a * contract error when present and otherwise wrapping it in a * {@link SimulationError}. */ export declare function simulationFailure(diagnostic: unknown, hash?: string): TransactionFailure; /** * Build a {@link TransactionFailure} from a submission diagnostic, decoding a * contract error when present and otherwise wrapping it in a * {@link SubmissionError}. */ export declare function submissionFailure(diagnostic: unknown, hash?: string): TransactionFailure; //# sourceMappingURL=contract-errors.d.ts.map