import { type Address, type Chain, type Client, type Hex, type Transport } from "viem"; import type { ClientMiddlewareConfig } from "../client/types"; import type { EntryPointVersion } from "../entrypoint/types"; import type { UserOperationFeeOptions, UserOperationOverrides, UserOperationRequest, UserOperationStruct } from "../types"; import { type Deferrable } from "../utils/index.js"; export type Erc7677RpcSchema = Record> = [ { Method: "pm_getPaymasterStubData"; Parameters: [UserOperationRequest, Address, Hex, TContext]; ReturnType: { sponsor?: { name: string; icon?: string; }; paymaster?: Address; paymasterData?: Hex; paymasterVerificationGasLimit?: Hex; paymasterPostOpGasLimit?: Hex; paymasterAndData?: Hex; isFinal?: boolean; }; }, { Method: "pm_getPaymasterData"; Parameters: [UserOperationRequest, Address, Hex, TContext]; ReturnType: { paymaster?: Address; paymasterData?: Hex; paymasterVerificationGasLimit?: Hex; paymasterPostOpGasLimit?: Hex; paymasterAndData?: Hex; }; } ]; export type Erc7677Client = Record> = Client>; export type Erc7677MiddlewareParams | undefined = Record | undefined, TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = { context?: ((struct: Deferrable>, args: { overrides?: UserOperationOverrides; feeOptions?: UserOperationFeeOptions; }) => Promise) | TContext; }; /** * Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations. * This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData). * * @example * ```ts * import { createSmartAccountClient, erc7677Middleware } from "@aa-sdk/core"; * import { http } from "viem"; * import { sepolia } from "viem/chains"; * * const client = createSmartAccountClient({ * transport: http("rpc-url"), * chain: sepolia, * // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context * ...erc7677Middleware(), * }) * ``` * * @param {Erc7677MiddlewareParams} params Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op * @returns {Pick} An object containing middleware functions `dummyPaymasterAndData` and `paymasterAndData` for processing user operations with the paymaster data */ export declare function erc7677Middleware | undefined = Record | undefined>(params?: Erc7677MiddlewareParams): Required>;