export type CreateApiCommentArgs = {'ray-token': string, body: BodyInit}; export type CreateApiCommentOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Post a comment on a pool * * POST /comment */ export const createApiComment = async (args: CreateApiCommentArgs, options?: CreateApiCommentOptions) => { const {baseUrl = "https://api.raydium.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['ray-token'] != null) headers.set("ray-token", String(args['ray-token'])) const url = `${baseUrl.replace(/\/+$/, '')}/comment${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };