import type { SmartAccount } from "permissionless/accounts" import type { EntryPoint, Prettify } from "permissionless/types" import type { Chain, Client, Transport } from "viem" import type { CABToken } from "../../types" import type { CabPaymasterRpcScheme, GetRpcCabPaymasterAllTokensParameters } from "../../types" export type GetCabAllTokensParameters = { chainId?: number } export type GetCabAllTokensReturnType = { tokens: CABToken[] } export async function getCabAllTokens< 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 } = args const params: unknown[] = [] if (chainId !== undefined) { params.push(chainId ?? null) } const response = await client.request({ method: "pm_getCabAllTokens", params: params as GetRpcCabPaymasterAllTokensParameters }) return response }