export type GetApiApiV1HeadersToCommonAncestorHashHexArgs = {hash: string}; export type GetApiApiV1HeadersToCommonAncestorHashHexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get block headers to the common ancestor in hexadecimal format. * * GET /api/v1/headers_to_common_ancestor/{hash}/hex */ export const getApiApiV1HeadersToCommonAncestorHashHex = async (args: GetApiApiV1HeadersToCommonAncestorHashHexArgs, options: GetApiApiV1HeadersToCommonAncestorHashHexOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/headers_to_common_ancestor/${encodeURIComponent(String(args.hash))}/hex${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 undefined };