export type AlgorithmId = string; export type GetApiGetBinaryBlobArgs = {algorithm_id: AlgorithmId}; export type GetApiGetBinaryBlobOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get binary blob for a specific algorithm * * GET /get-binary-blob */ export const getApiGetBinaryBlob = async (args: GetApiGetBinaryBlobArgs, options?: GetApiGetBinaryBlobOptions) => { const {baseUrl = "https://mainnet-api.tig.foundation", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.algorithm_id != null) query.append("algorithm_id", String(args.algorithm_id)) const url = `${baseUrl.replace(/\/+$/, '')}/get-binary-blob${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() };