export type GetApiV1TreesTreeIndexUtxosArgs = {tree_index: number, cursor?: number | undefined, limit?: number | undefined, 'X-Response-Layout'?: 'columnar' | undefined}; export type GetApiV1TreesTreeIndexUtxosOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Paginated UTXO records for a specific tree * * GET /v1/trees/{tree_index}/utxos */ export const getApiV1TreesTreeIndexUtxos = async (args: GetApiV1TreesTreeIndexUtxosArgs, options?: GetApiV1TreesTreeIndexUtxosOptions) => { const {baseUrl = "https://utxo-indexer.api.umbraprivacy.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-protobuf") if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.limit != null) query.append("limit", String(args.limit)) if (args['X-Response-Layout'] != null) headers.set("X-Response-Layout", String(args['X-Response-Layout'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/trees/${encodeURIComponent(String(args.tree_index))}/utxos${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 res.blob() };