/** * Function table installed by the Lighter Go WASM runtime. Methods mirror the * venue signer ABI and return a result containing either signed transaction * fields or an error; positional argument contracts are documented per method. * * @public */ export interface LighterWasmExports { GenerateAPIKey: () => { publicKey?: string; privateKey?: string; error?: string; }; CreateClient: (url: string, privateKey: string, chainId: number, apiKeyIndex: number, accountIndex: number) => { error?: string; }; /** * Returns `{authToken}` on success — note the field name is `authToken`, * NOT `token`. Reading the wrong field silently fails (Go sets nothing * else on the result), which is why early code paths returned undefined * tokens with no error. */ CreateAuthToken: (deadline: number, apiKeyIndex: number, accountIndex: number) => { authToken?: string; error?: string; }; /** * Signature mirrors lighter-python's `signer.SignChangePubKey(...)` call — * 5 positional args including `skipNonce` (use 0 to embed our supplied * nonce; 1 to leave it out for server-fill scenarios). Earlier versions * here had only 4 args, which silently shifted all arguments by one and * produced txInfo with garbage AccountIndex / ApiKeyIndex fields → * Lighter rejected with code 20001 "invalid param". */ SignChangePubKey: (pubKeyHex: string, skipNonce: number, nonce: number, apiKeyIndex: number, accountIndex: number) => SignResult & { messageToSign?: string; }; /** * Go WASM exports take positional primitives, so TS cannot type the * arguments — `WASM_FUNCTION_NAMES` only validates that each function * *exists* at load time, never its arity or order. A `.wasm` bump that * shifts or adds an argument therefore compiles, passes the existence * check, and only fails at runtime (Lighter code 20001 "invalid param"). * The expected positional contract below is the authority; it MUST stay in * sync with the call site in `LighterSigner.dispatch`. All sign exports end * with `(nonce, apiKeyIndex, accountIndex)`. * * 19 args: marketIndex, clientOrderIndex, baseAmount, price, isAsk, * orderType, timeInForce, reduceOnly, triggerPrice, orderExpiry, * integratorAccountIndex, integratorTakerFee, integratorMakerFee, * selfTradeBehaviorMode, selfTradeEqualityMode, skipNonce, then the trailing * three. */ SignCreateOrder: (...args: unknown[]) => SignResult; /** 6 args: marketIndex, orderIndex, skipNonce, then the trailing three. */ SignCancelOrder: (...args: unknown[]) => SignResult; /** * 7 args: timeInForce, time, cancelAllMarketIndex, skipNonce, then the * trailing three. */ SignCancelAllOrders: (...args: unknown[]) => SignResult; /** * 11 args: toAccountIndex, assetIndex, fromRouteType, toRouteType, amount, * usdcFee, memo, skipNonce, then the trailing three. `memo` is copied into a * Go `[32]byte`, so its UTF-8 byte length must be exactly 32 or Go rejects it * before signing. `messageToSign` is the EIP-191 `Transfer` L1 body that * binds the destination account and the amount to the owner's Ethereum * wallet; a cross-account transfer needs the resulting `L1Sig`, a * same-account route move does not. */ SignTransfer: (...args: unknown[]) => SignResult & { messageToSign?: string; }; /** 7 args: assetIndex, routeType, amount, skipNonce, then the trailing three. */ SignWithdraw: (...args: unknown[]) => SignResult; /** * 7 args: marketIndex, fraction, marginMode, skipNonce, then the trailing * three. */ SignUpdateLeverage: (...args: unknown[]) => SignResult; /** * 14 args: marketIndex, orderIndex, baseAmount, price, triggerPrice, * integratorAccountIndex, integratorTakerFee, integratorMakerFee, * selfTradeBehaviorMode, selfTradeEqualityMode, skipNonce, then the trailing * three. */ SignModifyOrder: (...args: unknown[]) => SignResult; /** * 7 args: marketIndex, usdcAmount, direction, skipNonce, then the trailing * three. */ SignUpdateMargin: (...args: unknown[]) => SignResult; /** * 10 args: integratorAccountIndex, maxPerpsTakerFee, maxPerpsMakerFee, * maxSpotTakerFee, maxSpotMakerFee, approvalExpiry, skipNonce, then the * trailing three. Fees are uint32 ppm of `FeeTick` (1_000_000); a non-nil * fee requires a non-nil integrator index. `messageToSign` is the EIP-191 * `L2ApproveIntegrator` L1 body the user's wallet must countersign — the * venue rejects the tx without the resulting `L1Sig`. */ SignApproveIntegrator: (...args: unknown[]) => SignResult & { messageToSign?: string; }; /** * 5 args: accountTradingMode (0 = Classic/Simple, 1 = Unified), skipNonce, * then the trailing three. `accountTradingMode` is validated to {0, 1} by * lighter-go before signing. */ SignUpdateAccountConfig: (...args: unknown[]) => SignResult; /** * 6 args: assetIndex, assetMarginMode (0 = MarginDisabled, 1 = MarginEnabled), * skipNonce, then the trailing three. Keyed per spot asset, not per market — * signs `L2UpdateAccountAssetConfigTx` (tx type 42). */ SignUpdateAccountAssetConfig: (...args: unknown[]) => SignResult; } /** @internal */ export interface SignResult { txType?: number; txInfo?: string; txHash?: string; error?: string; } /** * Load the Lighter WASM signer from the binary shipped with this package — * resolved by the package itself, so callers need no bundler configuration and * pass no URL. Memoized per-process: subsequent calls return the cached * exports, while a failed load is not cached — the next call retries. The Go * runtime keeps a long-running goroutine to service JS calls — we start it once * and never stop it. * * @public */ export declare function loadLighterWasm(): Promise; /** * Testing helper — drop the cached WASM instance so the next load reinitializes. * * @internal */ export declare function resetLighterWasmCache(): void; //# sourceMappingURL=wasmLoader.d.ts.map