export type GetApiV2BlockchainBlocksBlockIdBocArgs = {block_id: string}; export type GetApiV2BlockchainBlocksBlockIdBocOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download blockchain block BOC * * GET /v2/blockchain/blocks/{block_id}/boc */ export const getApiV2BlockchainBlocksBlockIdBoc = async (args: GetApiV2BlockchainBlocksBlockIdBocArgs, options?: GetApiV2BlockchainBlocksBlockIdBocOptions) => { const {baseUrl = "https://tonapi.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") const url = `${baseUrl.replace(/\/+$/, '')}/v2/blockchain/blocks/${encodeURIComponent(String(args.block_id))}/boc${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() };