UNPKG

@nktkas/hyperliquid

Version:

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

55 lines (54 loc) 1.97 kB
import * as v from "valibot"; // ============================================================ // API Schemas // ============================================================ import { Address } from "../../_schemas.js"; /** * Request array of user transaction details. * @see null */ export const UserDetailsRequest = /* @__PURE__ */ (()=>{ return v.object({ /** Type of request. */ type: v.literal("userDetails"), /** User address. */ user: Address }); })(); // ============================================================ // Execution Logic // ============================================================ import { parse } from "../../../_base.js"; import { assertSuccessResponse } from "./_base/mod.js"; /** * Request array of user transaction details. * * @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 Array of user transaction details. * * @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 { userDetails } from "@nktkas/hyperliquid/api/explorer"; * * const transport = new HttpTransport(); // only `HttpTransport` supports this API * * const data = await userDetails({ transport }, { * user: "0x...", * }); * ``` * * @see null */ export async function userDetails(config, params, signal) { const request = parse(UserDetailsRequest, { type: "userDetails", ...params }); const response = await config.transport.request("explorer", request, signal); assertSuccessResponse(response); return response; } //# sourceMappingURL=userDetails.js.map