import type { SmartAccount } from "permissionless/accounts" import type { EntryPoint, Prettify } from "permissionless/types" import type { Address, Chain, Client, Transport } from "viem" import type { CABVault } from "../../types" import type { CabPaymasterRpcScheme, GetRpcCabPaymasterAllVaultsParameters } from "../../types" export type GetCabAllVaultsParameters = { chainId?: number token?: Address } export type GetCabAllVaultsReturnType = { vaults: CABVault[] } export async function getCabAllVaults< TEntryPoint extends EntryPoint, TChain extends Chain | undefined = Chain | undefined, TTransport extends Transport = Transport, TSmartAccount extends | SmartAccount | undefined = | SmartAccount | undefined >( client: Client< TTransport, TChain, TSmartAccount, CabPaymasterRpcScheme >, args: Prettify ): Promise { const { chainId, token } = args const params: unknown[] = [] if (chainId !== undefined || token !== undefined) { params.push(chainId ?? null) if (token !== undefined) { params.push(token) } } const response = await client.request({ method: "pm_getCabAllVaults", params: params as GetRpcCabPaymasterAllVaultsParameters }) return response }