UNPKG

@nktkas/hyperliquid

Version:

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

30 lines (29 loc) 1.5 kB
/** * Common execution shell shared by L1 and user-signed Exchange API actions. * @module */ /// <amd-module name="file:///home/runner/work/hyperliquid/hyperliquid/src/api/exchange/_methods/_base/_shell.ts" /> import { type Signature } from "../../../../signing/mod.js"; import type { ExchangeConfig } from "./_config.js"; /** Result returned by the {@linkcode executeWithShell} `build` callback. */ export interface BuildResult { /** The final action to send (post-signing). Shape is opaque to the shell — passed through to the transport. */ action: unknown; /** The signature to send. */ signature: Signature; /** Optional extra fields to merge into the request payload (e.g., `vaultAddress`, `expiresAfter`). */ extras?: Record<string, unknown>; } /** * Common shell for executing an Exchange API request: * acquires per-`(walletAddress × isTestnet)` lock, generates nonce, calls `build` to construct * the signed payload, sends to the Exchange endpoint, and validates the response. * * @param config Exchange API configuration. * @param build Callback that, given the nonce, returns the action, signature, and any extras. * @param signal Optional {@link AbortSignal} to cancel the request. * @return The validated API response. * * @throws {ApiRequestError} If the API returns an error response. */ export declare function executeWithShell<T>(config: ExchangeConfig, build: (nonce: number) => Promise<BuildResult>, signal?: AbortSignal): Promise<T>;