@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
55 lines (54 loc) • 1.97 kB
JavaScript
import * as v from "valibot";
// ============================================================
// API Schemas
// ============================================================
import { Hex } from "../../_schemas.js";
/**
* Request transaction details by transaction hash.
* @see null
*/ export const TxDetailsRequest = /* @__PURE__ */ (()=>{
return v.object({
/** Type of request. */ type: v.literal("txDetails"),
/** Transaction hash. */ hash: v.pipe(Hex, v.length(66))
});
})();
// ============================================================
// Execution Logic
// ============================================================
import { parse } from "../../../_base.js";
import { assertSuccessResponse } from "./_base/mod.js";
/**
* Request transaction details by transaction hash.
*
* @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 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 { txDetails } from "@nktkas/hyperliquid/api/explorer";
*
* const transport = new HttpTransport(); // only `HttpTransport` supports this API
*
* const data = await txDetails({ transport }, {
* hash: "0x...",
* });
* ```
*
* @see null
*/ export async function txDetails(config, params, signal) {
const request = parse(TxDetailsRequest, {
type: "txDetails",
...params
});
const response = await config.transport.request("explorer", request, signal);
assertSuccessResponse(response);
return response;
}
//# sourceMappingURL=txDetails.js.map