export type GetApiV1AgentPortfolioArgs = {addresses: string, aggregated?: boolean | undefined, includeNFTs?: boolean | undefined, includeImages?: boolean | undefined, includeExplorerUrls?: boolean | undefined, waitForSync?: boolean | undefined}; export type GetApiV1AgentPortfolioOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get the wallet and protocol holdings of a given address * * GET /v1/agent/portfolio */ export const getApiV1AgentPortfolio = async (args: GetApiV1AgentPortfolioArgs, options: GetApiV1AgentPortfolioOptions) => { 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.aggregated != null) query.append("aggregated", String(args.aggregated)) if (args.includeNFTs != null) query.append("includeNFTs", String(args.includeNFTs)) if (args.includeImages != null) query.append("includeImages", String(args.includeImages)) if (args.includeExplorerUrls != null) query.append("includeExplorerUrls", String(args.includeExplorerUrls)) if (args.waitForSync != null) query.append("waitForSync", String(args.waitForSync)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/agent/portfolio${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 };