export type GetApiCommentPoolArgs = {poolId: string, limit?: number | undefined, lastId?: number | undefined, fetchType?: ('old' | 'new') | undefined, includeNsfw?: boolean | undefined}; export type GetApiCommentPoolOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get comments for a pool * * GET /comment/pool */ export const getApiCommentPool = async (args: GetApiCommentPoolArgs, options?: GetApiCommentPoolOptions) => { const {baseUrl = "https://api.raydium.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.poolId != null) query.append("poolId", String(args.poolId)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.lastId != null) query.append("lastId", String(args.lastId)) if (args.fetchType != null) query.append("fetchType", String(args.fetchType)) if (args.includeNsfw != null) query.append("includeNsfw", String(args.includeNsfw)) const url = `${baseUrl.replace(/\/+$/, '')}/comment/pool${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 };