export type GetApiV1TreesTreeIndexArgs = {tree_index: number}; export type GetApiV1TreesTreeIndexOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Merkle tree metadata * * GET /v1/trees/{tree_index} */ export const getApiV1TreesTreeIndex = async (args: GetApiV1TreesTreeIndexArgs, options?: GetApiV1TreesTreeIndexOptions) => { 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/trees/${encodeURIComponent(String(args.tree_index))}${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() };