import type { SmartAccount } from "permissionless/accounts" import type { EntryPoint } from "permissionless/types" import type { Chain, Client, Transport } from "viem" import { type PrepareUserOperationRequestCABParameters, type PrepareUserOperationRequestCABReturnType, type SendUserOperationCABParameters, type SendUserOperationCABReturnType, prepareUserOperationRequestCAB, sendUserOperationCAB } from "../../actions/cab" import type { CAB_VERSION } from "../../types" import { getCabPaymasterAddress } from "../../utils" export type CABActions< TEntryPoint extends EntryPoint, TTransport extends Transport, TChain extends Chain | undefined, TSmartAccount extends | SmartAccount | undefined = | SmartAccount | undefined > = { prepareUserOperationRequestCAB: ( args: PrepareUserOperationRequestCABParameters< TEntryPoint, TTransport, TChain, TSmartAccount > ) => Promise> sendUserOperationCAB: ( args: SendUserOperationCABParameters ) => Promise } export const cabActions = < TEntryPoint extends EntryPoint, TTransport extends Transport, TChain extends Chain | undefined >( transport: Transport, cabVersion?: CAB_VERSION ) => ( client: Client< TTransport, TChain, SmartAccount > ): CABActions => ({ prepareUserOperationRequestCAB: async (args) => prepareUserOperationRequestCAB< TEntryPoint, TChain, TTransport, SmartAccount >( client, { ...args, cabPaymasterAddress: getCabPaymasterAddress(cabVersion) }, transport ), sendUserOperationCAB: async (args) => sendUserOperationCAB< TEntryPoint, TChain, TTransport, SmartAccount >( client, { ...args, cabPaymasterAddress: getCabPaymasterAddress(cabVersion) }, transport ) })