export type GetApiApiConvictionLatestV1Args = {coldkey?: string | undefined, hotkey?: string | undefined, netuid?: string | undefined, limit?: number | undefined, page?: number | undefined}; export type GetApiApiConvictionLatestV1Options = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Conviction * * GET /api/conviction/latest/v1 */ export const getApiApiConvictionLatestV1 = async (args: GetApiApiConvictionLatestV1Args, options?: GetApiApiConvictionLatestV1Options) => { const {baseUrl = "https://api.taostats.io", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.coldkey != null) query.append("coldkey", String(args.coldkey)) if (args.hotkey != null) query.append("hotkey", String(args.hotkey)) if (args.netuid != null) query.append("netuid", String(args.netuid)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) if (sec0 !== undefined) headers.set("Authorization", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/api/conviction/latest/v1${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 (await res.json()) as unknown };