/** * Unified WASM Signer Client for Lighter Protocol * * This module provides a TypeScript wrapper for the Go WASM signer, * enabling cryptographic operations in both browser and Node.js environments. * Automatically detects the environment and uses the appropriate initialization method. */ export interface WasmSignerConfig { /** Wait for fresh instance exports instead of a fixed initialization delay (Node.js only). */ waitForReady?: boolean; wasmPath?: string; wasmExecPath?: string; } export interface ApiKeyPair { privateKey: string; publicKey: string; } export interface CreateClientParams { url: string; privateKey: string; chainId: number; apiKeyIndex: number; accountIndex: number; } export interface CreateOrderParams { marketIndex: number; clientOrderIndex: number; baseAmount: number; price: number; isAsk: number; orderType: number; timeInForce: number; reduceOnly: number; triggerPrice: number; orderExpiry: number; nonce: number; } export interface CancelOrderParams { marketIndex: number; orderIndex: number; nonce: number; } export interface CancelAllOrdersParams { timeInForce: number; time: number; nonce: number; } export interface TransferParams { toAccountIndex: number; assetIndex: number; fromRouteType: number; toRouteType: number; amount: number; usdcFee: number; memo: string; nonce?: number; } export interface UpdateLeverageParams { marketIndex: number; fraction: number; marginMode: number; nonce: number; } export interface WithdrawParams { assetIndex: number; routeType: number; amount: number; nonce: number; } export interface WasmSignerResponse { success?: boolean; error?: string; data?: T; } export declare class WasmSignerClient { private wasmModule; private wasmInstance; private isInitialized; private config; private isBrowser; private apiKeyIndex; private accountIndex; constructor(config: WasmSignerConfig); /** * Initialize the WASM module (unified for both browser and Node.js) */ initialize(): Promise; /** * Browser-specific initialization */ private initializeBrowser; /** * Node.js-specific initialization */ private initializeNode; /** * Generate a new API key pair */ generateAPIKey(): Promise; /** * Get public key from private key */ getPublicKey(privateKey: string): Promise; /** * Sign a ChangePubKey transaction */ signChangePubKey(params: { pubkey: string; l1Sig: string; newApiKeyIndex: number; nonce: number; expiredAt: number; }): Promise<{ txInfo: string; error?: string; }>; /** * Create a client for signing transactions */ createClient(params: CreateClientParams): Promise; /** * Sign a create order transaction */ signCreateOrder(params: CreateOrderParams): Promise; /** * Sign a cancel order transaction */ signCancelOrder(params: CancelOrderParams): Promise; /** * Create an authentication token */ createAuthToken(deadline?: number): Promise; /** * Sign a cancel all orders transaction */ signCancelAllOrders(params: CancelAllOrdersParams): Promise<{ txInfo: string; error?: string; }>; /** * Sign a transfer transaction */ signTransfer(params: TransferParams): Promise<{ txInfo: string; error?: string; }>; /** * Sign a withdraw transaction */ signWithdraw(params: WithdrawParams): Promise<{ txInfo: string; error?: string; }>; /** * Sign an update leverage transaction */ signUpdateLeverage(params: UpdateLeverageParams): Promise<{ txInfo: string; error?: string; }>; checkClient(apiKeyIndex: number, accountIndex: number): Promise; /** * Ensure the WASM module is initialized */ private ensureInitialized; /** * Load script for browser environment */ private loadScript; /** * Load wasm_exec.js for Node.js */ private loadWasmExec; /** * Resolve WASM path relative to package root */ private resolveWasmPath; /** * Find the package root directory */ private findPackageRoot; /** * Load WASM binary for Node.js */ private loadWasmBinary; } /** * Create a unified WASM signer client instance * Automatically detects browser vs Node.js environment */ export declare function createWasmSignerClient(config: WasmSignerConfig): WasmSignerClient; export { WasmSignerClient as NodeWasmSignerClient }; export declare const createNodeWasmSignerClient: typeof createWasmSignerClient; //# sourceMappingURL=wasm-signer.d.ts.map