@deeeed/hyperliquid-node20
Version:
Unofficial Hyperliquid API SDK for all major JS runtimes, written in TypeScript. Fork with Node.js 20.18.0+ compatibility.
68 lines • 3.97 kB
TypeScript
import type { Hex } from "../base.js";
import type { IRequestTransport } from "../transports/base.js";
import type { CreateSubAccountResponse, CreateVaultResponse, SuccessResponse } from "../types/exchange/responses.js";
import { type AbstractEthersSigner, type AbstractEthersV5Signer, type AbstractViemWalletClient, type AbstractWallet, type AbstractWindowEthereum, actionSorter } from "../signing/mod.js";
import { type CancelResponseSuccess, ExchangeClient, type ExchangeClientParameters, type OrderResponseSuccess, type TwapCancelResponseSuccess, type TwapOrderResponseSuccess } from "./exchange.js";
type Signers = [AbstractWalletWithAddress, ...AbstractWallet[]];
/** Parameters for the {@linkcode MultiSignClient} constructor. */
export interface MultiSignClientParameters<T extends IRequestTransport = IRequestTransport, S extends Readonly<Signers> = Signers> extends Omit<ExchangeClientParameters<T, S[0]>, "wallet"> {
/** The multi-signature account address. */
multiSignAddress: Hex;
/** Array of wallets used for multi-signature operations. The first wallet acts as the leader. */
signers: S;
}
/** Abstract interface for a wallet that can sign typed data and has wallet address. */
export type AbstractWalletWithAddress = Hex | AbstractViemWalletClientWithAddress | AbstractEthersSignerWithAddress | AbstractEthersV5SignerWithAddress | AbstractWindowEthereum;
/** Abstract interface for a [viem wallet](https://viem.sh/docs/clients/wallet) with wallet address. */
export interface AbstractViemWalletClientWithAddress extends AbstractViemWalletClient {
address: Hex;
}
/** Abstract interface for an [ethers.js signer](https://docs.ethers.org/v6/api/providers/#Signer) with wallet address. */
export interface AbstractEthersSignerWithAddress extends AbstractEthersSigner {
getAddress(): Promise<string>;
}
/** Abstract interface for an [ethers.js v5 signer](https://docs.ethers.org/v5/api/signer/) with wallet address. */
export interface AbstractEthersV5SignerWithAddress extends AbstractEthersV5Signer {
getAddress(): Promise<string>;
}
/**
* Multi-signature exchange client for interacting with the Hyperliquid API.
* @typeParam T The transport used to connect to the Hyperliquid API.
* @typeParam S Array of wallets where the first wallet acts as the leader.
*/
export declare class MultiSignClient<T extends IRequestTransport = IRequestTransport, S extends Readonly<Signers> = Signers> extends ExchangeClient<T, S[0]> implements MultiSignClientParameters<T, S> {
multiSignAddress: Hex;
signers: S;
/**
* @multisign Is the first wallet from {@linkcode signers}. Changing the property also changes the first element in the {@linkcode signers} array.
*/
wallet: S[0];
/**
* Initialises a new multi-signature client instance.
* @param args - The parameters for the multi-signature client.
*
* @example
* ```ts
* import * as hl from "@nktkas/hyperliquid";
*
* const multiSignAddress = "0x...";
* const signers = [
* "0x...", // Private key; or any other wallet libraries
* ] as const;
*
* const transport = new hl.HttpTransport();
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
* ```
*/
constructor(args: MultiSignClientParameters<T, S>);
protected _executeAction<T extends SuccessResponse | CancelResponseSuccess | CreateSubAccountResponse | CreateVaultResponse | OrderResponseSuccess | TwapOrderResponseSuccess | TwapCancelResponseSuccess>(args: {
action: Parameters<typeof actionSorter[keyof typeof actionSorter]>[0];
vaultAddress?: Hex;
expiresAfter?: number;
multiSigNonce?: number;
}, signal?: AbortSignal): Promise<T>;
/** Extracts the wallet address from different wallet types. */
protected _getWalletAddress(wallet: AbstractWalletWithAddress): Promise<Hex>;
}
export {};
//# sourceMappingURL=multiSign.d.ts.map