UNPKG

@nktkas/hyperliquid

Version:

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

75 lines (74 loc) 2.96 kB
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/explorer/_methods/blockDetails.ts" /> import * as v from "valibot"; import type { ExplorerTransaction } from "./_base/mod.js"; /** * Request block details by block height. * @see null */ export declare const BlockDetailsRequest: v.ObjectSchema<{ /** Type of request. */ readonly type: v.LiteralSchema<"blockDetails", undefined>; /** Block height. */ readonly height: v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.ToNumberAction<string | number, undefined>, v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>; }, undefined>; export type BlockDetailsRequest = v.InferOutput<typeof BlockDetailsRequest>; /** * Response containing block information. * @see null */ export type BlockDetailsResponse = { /** Type of response. */ type: "blockDetails"; /** The details of a block. */ blockDetails: { /** Block creation timestamp. */ blockTime: number; /** * Block hash. * @pattern ^0x[a-fA-F0-9]{64}$ */ hash: `0x${string}`; /** Block height in chain. */ height: number; /** Total transactions in block. */ numTxs: number; /** * Block proposer address. * @pattern ^0x[a-fA-F0-9]{40}$ */ proposer: `0x${string}`; /** Array of transactions in the block. */ txs: ExplorerTransaction[]; }; }; import type { IRequestTransport } from "../../../transport/mod.js"; import { type ExplorerConfig } from "./_base/mod.js"; /** Request parameters for the {@linkcode blockDetails} function. */ export type BlockDetailsParameters = Omit<v.InferInput<typeof BlockDetailsRequest>, "type">; /** * 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 declare function blockDetails(config: ExplorerConfig<IRequestTransport<"explorer">>, params: BlockDetailsParameters, signal?: AbortSignal): Promise<BlockDetailsResponse>;