export type GetApiV1AgentApprovalsChainArgs = {chain: string, addresses: string, limit?: number | undefined, cursor?: string | undefined}; export type GetApiV1AgentApprovalsChainOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get the token approvals for a given address on a specific chain * * GET /v1/agent/approvals/{chain} */ export const getApiV1AgentApprovalsChain = async (args: GetApiV1AgentApprovalsChainArgs, options: GetApiV1AgentApprovalsChainOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.addresses != null) query.append("addresses", String(args.addresses)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/agent/approvals/${encodeURIComponent(String(args.chain))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };