@nktkas/hyperliquid
Version:
Hyperliquid API SDK for all major JS runtimes, written in TypeScript.
47 lines (46 loc) • 2.23 kB
TypeScript
/// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/explorer/_methods/explorerTxs.ts" />
import * as v from "valibot";
import type { ExplorerTransaction } from "./_base/mod.js";
/**
* Subscription to explorer transaction events.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
export declare const ExplorerTxsRequest: v.ObjectSchema<{
/** Type of subscription. */
readonly type: v.LiteralSchema<"explorerTxs", undefined>;
}, undefined>;
export type ExplorerTxsRequest = v.InferOutput<typeof ExplorerTxsRequest>;
/**
* Event of array of transaction details.
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
export type ExplorerTxsEvent = ExplorerTransaction[];
import type { ISubscription, ISubscriptionTransport, TransportError } from "../../../transport/mod.js";
import type { ExplorerConfig } from "./_base/mod.js";
/**
* Subscribe to explorer transaction updates.
*
* @param config General configuration for Explorer API subscriptions.
* @param listener A callback function to be called when the event is received.
* @param onError An optional callback function to be called when the subscription fails.
* @return A request-promise that resolves with a {@link ISubscription} object to manage the subscription lifecycle.
*
* @throws {ValidationError} When the request parameters fail validation (before sending).
* @throws {TransportError} When the transport layer throws an error.
*
* @example
* ```ts
* import { WebSocketTransport } from "@nktkas/hyperliquid";
* import { explorerTxs } from "@nktkas/hyperliquid/api/explorer";
*
* const transport = new WebSocketTransport({ url: "wss://rpc.hyperliquid.xyz/ws" }); // only `WebSocketTransport` supports this API
*
* const sub = await explorerTxs(
* { transport },
* (data) => console.log(data),
* );
* ```
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
*/
export declare function explorerTxs(config: ExplorerConfig<ISubscriptionTransport>, listener: (data: ExplorerTxsEvent) => void, onError?: (error: TransportError) => void): Promise<ISubscription>;