export { P as PaymasterConfig, S as SuperPaymasterAdminClient, c as checkEligibility, g as getSuperPaymasterMiddleware } from './index-B6SfEQxo.cjs'; import { Address, Hex } from 'viem'; type PaymasterV4MiddlewareConfig = { paymasterAddress: Address; gasToken: Address; verificationGasLimit?: bigint; postOpGasLimit?: bigint; }; type GaslessReadinessReport = { isReady: boolean; issues: string[]; details: { paymasterStake: bigint; paymasterDeposit: bigint; ethUsdPrice: bigint; tokenSupported: boolean; tokenPrice: bigint; userTokenBalance: bigint; userPaymasterDeposit: bigint; }; }; /** * Constructs the middleware for Paymaster V4. * Returns the `paymasterAndData` hex string. */ declare function getPaymasterV4Middleware(config: PaymasterV4MiddlewareConfig): { sponsorUserOperation: (args: { userOperation: any; }) => Promise<{ paymasterAndData: `0x${string}`; verificationGasLimit: bigint; preVerificationGas: any; }>; }; /** * Build paymasterAndData for gasless UserOperation. * Layout: [Paymaster(20)] [VerificationGasLimit(16)] [PostOpGasLimit(16)] [Token(20)] [ValidUntil(6)] [ValidAfter(6)] */ declare function buildPaymasterData(paymasterAddress: Address, token: Address, options?: { validityWindow?: number; verificationGasLimit?: bigint; postOpGasLimit?: bigint; }): `0x${string}`; /** * Build paymasterAndData for SuperPaymaster V3. * Layout: [Paymaster(20)] [verGas(16)] [postGas(16)] [operator(20)] [maxRate(32)] * Total: 104 bytes * * IMPORTANT: SuperPaymaster contract generates validUntil internally using: * validUntil = cachedPrice.updatedAt + priceStalenessThreshold * Do NOT include validUntil/validAfter in paymasterAndData! */ declare function buildSuperPaymasterData(paymasterAddress: Address, operator: Address, options?: { verificationGasLimit?: bigint; postOpGasLimit?: bigint; maxRate?: bigint; }): `0x${string}`; /** * Helper to format UserOp for Alchemy/Standard Bundlers (v0.7 Decomposed) */ declare function formatUserOpV07(userOp: any): any; declare function getUserOpHashV07(userOp: any, entryPoint: Address, chainId: bigint): Hex; /** * Tune gas limit using a dynamic nominal ceiling to satisfy Bundler efficiency (0.4) * Target: Actual / Limit >= targetEfficiency */ declare function tuneGasLimit(estimate: bigint, nominalActual: bigint, targetEfficiency?: number): bigint; /** * PaymasterClient * Focus: Integration, Funding, Interaction. */ declare class PaymasterClient { /** * @private * Static utility class, should not be instantiated. */ private constructor(); /** * Sign a UserOp hash for the EntryPoint. * * airaccount-contract v0.20.0 `_validateSignature` routes on `signature[0]` as an algId * prefix BEFORE the raw-65-byte fallback. A raw 65-byte ECDSA sig whose first byte happens * to equal an algId const (e.g. `0x02` = ALG_ECDSA) is misrouted → intermittent AA24. * For v0.20.0 AirAccounts pass `airAccountSig: true` to emit the deterministic algId-prefixed * `[0x02][r][s][v]` (66-byte) format (matches `auth/hardware/ledger.ts`). Default is the raw * 65-byte form — unchanged for SimpleAccount and other account types. */ private static signUserOpHash; private static makePlaceholderSignature; private static estimatePreVerificationGasV07; /** * Get user's deposited balance on the Paymaster. */ static getDepositedBalance(publicClient: any, address: Address, user: Address, token: Address): Promise; /** * Deposit tokens to Paymaster for a user (enables gasless transactions). */ static depositFor(wallet: any, address: Address, user: Address, token: Address, amount: bigint): Promise; /** * Approve the Paymaster (or any spender) to spend gas tokens. */ static approveGasToken(wallet: any, token: Address, spender: Address, amount: bigint): Promise; /** * Estimate Gas for a UserOperation. */ static estimateUserOperationGas(client: any, wallet: any, aaAddress: Address, entryPoint: Address, paymasterAddress: Address, token: Address, bundlerUrl: string, callData: `0x${string}`, options?: { validityWindow?: number; airAccountSig?: boolean; operator?: Address; factory?: Address; factoryData?: Hex; }): Promise<{ preVerificationGas: bigint; verificationGasLimit: bigint; callGasLimit: bigint; paymasterVerificationGasLimit: bigint; paymasterPostOpGasLimit: bigint; }>; /** * High-level API to submit a gasless UserOperation. * Automatically handles nonce fetching, gas estimation (if not provided), signing, and submission. */ static submitGaslessUserOperation(client: any, wallet: any, aaAddress: Address, entryPoint: Address, paymasterAddress: Address, token: Address, bundlerUrl: string, callData: `0x${string}`, options?: { validityWindow?: number; airAccountSig?: boolean; verificationGasLimit?: bigint; callGasLimit?: bigint; preVerificationGas?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; autoEstimate?: boolean; operator?: Address; paymasterVerificationGasLimit?: bigint; paymasterPostOpGasLimit?: bigint; factory?: Address; factoryData?: Hex; }): Promise<`0x${string}`>; /** * Helper to extract the actual Gas Token fee from a UserOperation receipt. * Looks for the 'PostOpProcessed' event emitted by the Paymaster. */ static getFeeFromReceipt(receipt: any, paymasterAddress: Address): { tokenCost: bigint; actualGasCostWei: bigint; } | null; /** * Get the fee for a specific transaction hash. * Fetches the receipt (no scanning required) and decodes the log. */ static getTransactionFee(publicClient: any, txHash: `0x${string}`, paymasterAddress: Address): Promise<{ tokenCost: bigint; actualGasCostWei: bigint; } | null>; /** * Helper: Encode a standardized ERC-20 Transfer. * Returns the raw function data: `transfer(to, amount)` */ static encodeTokenTransfer(recipient: Address, amount: bigint): `0x${string}`; /** * Helper: Encode a SimpleAccount execution. * Wraps the inner call into: `execute(target, value, data)` * This is the payload signed by the user. */ static encodeExecution(target: Address, value: bigint, data: `0x${string}`): `0x${string}`; /** * More robust version of waitForUserOperationReceipt. * Catches timeouts and returns a cleaner result. */ static waitForUserOperation(bundlerClient: any, hash: `0x${string}`, timeout?: number): Promise; } /** * PaymasterOperator * Focus: Deployment, Configuration, Maintenance, Keeper Bots. */ declare class PaymasterOperator { /** * Update the cached ETH/USD price from Chainlink Oracle. * Must be called if cachedPrice is 0 (uninitialized). */ static updatePrice(wallet: any, address: Address): Promise; /** * Set the token price (in 8 decimals, e.g., 1e8 = $1 USD). */ static setTokenPrice(wallet: any, address: Address, token: Address, priceUSD: bigint): Promise; static getCachedPrice(publicClient: any, address: Address): Promise<{ price: bigint; updatedAt: bigint; }>; static getTokenPrice(publicClient: any, address: Address, token: Address): Promise; static getDepositedBalance(publicClient: any, address: Address, user: Address, token: Address): Promise; static ensurePriceInitialized(wallet: any, publicClient: any, address: Address): Promise; static addStake(wallet: any, address: Address, amount: bigint, unstakeDelaySec: number): Promise; static addDeposit(wallet: any, address: Address, amount: bigint): Promise; static addGasToken(wallet: any, address: Address, token: Address): Promise; static removeGasToken(wallet: any, address: Address, token: Address): Promise; static setServiceFeeRate(wallet: any, address: Address, rate: bigint): Promise; static setMaxGasCostCap(wallet: any, address: Address, cap: bigint): Promise; static withdrawPNT(wallet: any, address: Address, to: Address, token: Address, amount: bigint): Promise; static checkGaslessReadiness(publicClient: any, entryPoint: Address, paymasterAddress: Address, user: Address, token: Address): Promise; static prepareGaslessEnvironment(operatorWallet: any, publicClient: any, entryPoint: Address, paymasterAddress: Address, token: Address, options?: { minStake?: bigint; minDeposit?: bigint; tokenPriceUSD?: bigint; }): Promise<{ step: string; hash?: string; status: string; }[]>; } type GaslessTransactionConfig = { token: Address; recipient: Address; amount: bigint; operator: Address; paymasterAddress: Address; factory?: Address; factoryData?: Hex; }; /** * SuperPaymasterClient * High-level API for SuperPaymaster operations, including dynamic gas estimation. */ declare class SuperPaymasterClient { /** * @private * Static utility class, should not be instantiated. */ private constructor(); /** * Submit a gasless transaction using SuperPaymaster. * Automatically handles gas estimation with a smart efficiency buffer. */ static submitGaslessTransaction(client: any, wallet: any, aaAddress: Address, entryPoint: Address, bundlerUrl: string, config: GaslessTransactionConfig): Promise; } /** * Supported paymaster types. * - 'v4' → PaymasterV4 layout (84 bytes): [paymaster(20)][verGas(16)][postGas(16)][token(20)][validUntil(6)][validAfter(6)] * - 'super' → SuperPaymaster layout (104 bytes): [paymaster(20)][verGas(16)][postGas(16)][operator(20)][maxRate(32)] */ type PaymasterType = 'v4' | 'super'; /** * Unified parameters for building `paymasterAndData`. * * The byte layout differs by paymaster type; this shape carries the union of * both packers' inputs. `buildPaymasterData` validates that the fields required * for the resolved type are present, and dispatches to the correct existing * packer. Callers no longer need to know which format a given paymaster uses. */ interface BuildPaymasterDataParams { /** * Explicit paymaster type. Preferred over address-based heuristics. * If omitted, the type is resolved from `paymasterAddress` against the * manager's registered known-paymaster map (throws if unresolved). */ type?: PaymasterType; /** Paymaster contract address (first 20 bytes of the layout). */ paymasterAddress: Address; /** Paymaster verification gas limit (16-byte field, both layouts). */ verificationGasLimit?: bigint; /** Paymaster postOp gas limit (16-byte field, both layouts). */ postOpGasLimit?: bigint; /** Gas token address. Required for type 'v4'. */ token?: Address; /** Validity window in seconds (used to compute validUntil/validAfter). 'v4' only. */ validityWindow?: number; /** Operator address. Required for type 'super'. */ operator?: Address; /** Optional max rate commitment (rug-pull protection). 'super' only. */ maxRate?: bigint; } /** * PaymasterManager — unifies the per-type `paymasterAndData` packers behind a * single `buildPaymasterData` entry point that AUTO-SELECTS the correct byte * format by paymaster type. * * Type resolution order: * 1. Explicit `params.type` (preferred — no guessing). * 2. Address-based lookup against the registered known-paymaster map. * * The underlying packers (`buildPaymasterData` / `buildSuperPaymasterData` in * PaymasterUtils) remain exported and are reused verbatim here — this class * does NOT reimplement byte-packing. */ declare class PaymasterManager { private readonly knownPaymasters; constructor(opts?: { knownPaymasters?: Record; }); /** * Register a known paymaster address → type mapping so that callers can * omit the explicit `type` and have it resolved from the address. */ registerPaymaster(address: Address, type: PaymasterType): void; /** * Record an address → type mapping, throwing on a CONFLICTING re-registration. * Silently overwriting a v4 address with `super` (or vice-versa) would later * pack the wrong-length paymasterData for a `type`-less call, so a conflicting * re-registration is treated as a programmer error. Re-registering the SAME * type (including a case-variant of the address) is an idempotent no-op. */ private setKnownPaymaster; /** * Resolve a paymaster's type from a registered address. Returns undefined * if the address is not registered. */ resolveType(address: Address): PaymasterType | undefined; /** * Build `paymasterAndData`, auto-selecting the correct byte layout for the * paymaster type. Dispatches to the existing per-type packers. */ buildPaymasterData(params: BuildPaymasterDataParams): Hex; /** * Static helper: build `paymasterAndData` for an explicit type without an * instance. Useful when the caller already knows the type. */ static buildPaymasterData(type: PaymasterType, params: Omit): Hex; private static dispatch; } export { type BuildPaymasterDataParams, type GaslessReadinessReport, type GaslessTransactionConfig, PaymasterClient, PaymasterManager, PaymasterOperator, type PaymasterType, type PaymasterV4MiddlewareConfig, SuperPaymasterClient, buildPaymasterData, buildSuperPaymasterData, formatUserOpV07, getPaymasterV4Middleware, getUserOpHashV07, tuneGasLimit };