export type GetApiV1StatsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Global UTXO index statistics * * GET /v1/stats */ export const getApiV1Stats = async (options?: GetApiV1StatsOptions) => { 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") const url = `${baseUrl.replace(/\/+$/, '')}/v1/stats${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() };