UNPKG

@nktkas/hyperliquid

Version:

Hyperliquid API SDK for all major JS runtimes, written in TypeScript.

55 lines (54 loc) 1.99 kB
import * as v from "valibot"; // ============================================================ // API Schemas // ============================================================ import { UnsignedInteger } from "../../_schemas.js"; /** * Request block details by block height. * @see null */ export const BlockDetailsRequest = /* @__PURE__ */ (()=>{ return v.object({ /** Type of request. */ type: v.literal("blockDetails"), /** Block height. */ height: UnsignedInteger }); })(); // ============================================================ // Execution Logic // ============================================================ import { parse } from "../../../_base.js"; import { assertSuccessResponse } from "./_base/mod.js"; /** * Request block details by block height. * * @param config General configuration for Explorer API requests. * @param params Parameters specific to the API request. * @param signal {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | AbortSignal} to cancel the request. * @return Response containing block information. * * @throws {ValidationError} When the request parameters fail validation (before sending). * @throws {TransportError} When the transport layer throws an error. * @throws {ApiRequestError} When the API returns an unsuccessful response. * * @example * ```ts * import { HttpTransport } from "@nktkas/hyperliquid"; * import { blockDetails } from "@nktkas/hyperliquid/api/explorer"; * * const transport = new HttpTransport(); // only `HttpTransport` supports this API * * const data = await blockDetails({ transport }, { * height: 123, * }); * ``` * * @see null */ export async function blockDetails(config, params, signal) { const request = parse(BlockDetailsRequest, { type: "blockDetails", ...params }); const response = await config.transport.request("explorer", request, signal); assertSuccessResponse(response); return response; } //# sourceMappingURL=blockDetails.js.map