export type GetApiV1UtxosArgs = {start?: number | undefined, end?: number | undefined, limit?: number | undefined, 'X-Response-Layout'?: 'columnar' | undefined}; export type GetApiV1UtxosOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Paginated global UTXO query * * GET /v1/utxos */ export const getApiV1Utxos = async (args: GetApiV1UtxosArgs, options?: GetApiV1UtxosOptions) => { 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.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) 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/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() };