import { ActionType } from '@lifi/perps-types'; /** * Credentials needed to initialize the Lighter WASM client for one account * and API-key slot. The private key is Lighter-native signing material; the * account and slot indexes select the registered L2 key. * * @internal */ export interface LighterSignerContext { /** Lighter-native private key (from GenerateAPIKey, NOT an Ethereum key). */ apiKeyPrivateKey: string; /** API key slot registered on-chain (0-255). */ apiKeyIndex: number; /** Lighter account index — looked up from the user's L1 Ethereum address. */ accountIndex: number; } /** * Deployment facts {@link LighterSigner} signs against: the venue's REST base * URL, its zkLighter L2 signing chain id, and the L2 asset index its * withdrawals and transfers settle in. * * @internal */ export interface LighterSignerConfig { apiUrl: string; signerChainId: number; collateralAssetIndex: number; } /** * Signed Lighter transaction blob returned by the WASM signer. `txType`, * `txInfo`, and `txHash` are passed to the venue's transaction submission * endpoint; `txInfo` is an encoded transaction payload. * * @internal */ export interface LighterSignedBlob { txType: number; txInfo: string; txHash: string; } /** * Signed REGISTER_API_KEY (ChangePubKey) result, including the EIP-191 message * that the user's L1 wallet must countersign before submission. * * @internal */ export interface ChangePubKeyResult extends LighterSignedBlob { /** EIP-191 message the L1 Ethereum wallet must sign to authorize the key rotation. */ messageToSign: string; } /** * Signed APPROVE_INTEGRATOR result, including the EIP-191 L1 message required * to authorize the integrator approval. * * @internal */ export interface ApproveIntegratorResult extends LighterSignedBlob { /** EIP-191 `L2ApproveIntegrator` L1 body the user's wallet must countersign to authorize the integrator approval. */ messageToSign: string; } /** * Signed TRANSFER result, including the EIP-191 L1 message required to * authorize a cross-account transfer. * * @internal */ export interface TransferResult extends LighterSignedBlob { /** EIP-191 `Transfer` L1 body the user's wallet must countersign to bind the destination account and the amount to the account owner. */ messageToSign: string; } /** * Lighter-native API keypair generated by the WASM signer. These keys are * distinct from an Ethereum wallet keypair. * * @internal */ export interface ApiKeyPair { publicKey: string; privateKey: string; } /** * WASM-backed signer for Lighter API-key transactions and L1-countersigned * hybrid flows. The instance memoizes WASM initialization and registered * `(apiKeyIndex, accountIndex)` clients. * * @internal */ export declare class LighterSigner { private readonly apiUrl; private readonly chainId; private readonly collateralAssetIndex; private wasm; private readonly registeredClients; constructor(config: LighterSignerConfig); /** * Load and cache the Go WASM signer exports. Most signing methods initialize * lazily, so callers only need this method when they want an explicit warm-up. */ initialize(): Promise; /** * Generate a fresh random Lighter API keypair. The signer binary samples a * random scalar; seeded/deterministic generation is not available. */ generateAPIKey(): Promise; /** * Sign an action blob with the provided (apiKeyPrivateKey, apiKeyIndex, * accountIndex) context. `wasmSignParams` comes straight from the backend's * `WasmBlobActionStep`. Returns the signed `{ txType, txInfo, txHash }` * triple the backend forwards to Lighter's `sendTx` endpoint. * * For REGISTER_API_KEY use `signChangePubKey`, for APPROVE_INTEGRATOR use * `signApproveIntegrator`, and for TRANSFER use `signTransfer` — all three * return an additional `messageToSign` the L1 wallet must countersign. */ sign(action: ActionType, wasmSignParams: Record, context: LighterSignerContext): Promise; /** * Step 1 of the REGISTER_API_KEY flow. Generates the WASM blob for a * ChangePubKey tx with `L1Sig` left empty, plus the canonical EIP-191 * message the L1 Ethereum wallet must sign next. * * Requires the freshly-generated `privateKey` (returned by * {@link generateAPIKey}) — the Go WASM signer registers a per-slot client * keyed on `(apiKeyIndex, accountIndex)` before it'll sign anything for * that slot, including the ChangePubKey that's about to register the key * on-chain. This is purely client-side bookkeeping; it does not touch the * Lighter API. */ signChangePubKey(pubKeyHex: string, privateKey: string, nonce: number, apiKeyIndex: number, accountIndex: number, skipNonce?: 0 | 1): Promise; /** * Sign an APPROVE_INTEGRATOR action with the stored API key and return the * signed blob alongside the EIP-191 `L2ApproveIntegrator` L1 message the * user's Ethereum wallet must countersign. Unlike {@link sign}, this exposes * `messageToSign`: Lighter requires `L1Sig` (injected via * {@link embedL1Signature} before submission) when the integrator account * belongs to a different L1 address with non-zero fee caps. */ signApproveIntegrator(wasmSignParams: Record, context: LighterSignerContext): Promise; /** * Sign a TRANSFER action with the stored API key and return the signed blob * alongside the EIP-191 `Transfer` L1 message the user's Ethereum wallet * must countersign. Unlike {@link sign}, this exposes `messageToSign`: the * L1 signature (injected via {@link embedL1Signature} before submission) * binds the destination account and the amount to the account owner, so the * API key alone cannot move funds to an address the owner never approved. */ signTransfer(wasmSignParams: Record, context: LighterSignerContext): Promise; /** * Inject the L1 signature produced by the user's Ethereum wallet into a * signed txInfo JSON. `L1Sig` is the only field that depends on the L1 * signature; txHash does NOT include it (so we do not recompute it). Shared * by the REGISTER_API_KEY (ChangePubKey), APPROVE_INTEGRATOR, and TRANSFER * flows; SEND_ASSET stays on the bare signer call and keeps `L1Sig` empty. */ embedL1Signature(txInfo: string, l1Signature: string): string; /** * Create an auth token for authenticated WebSocket subscriptions. * `deadline` is a Unix timestamp in seconds — tokens have an 8h hard cap. */ createAuthToken(deadline: number, context: LighterSignerContext): Promise; private ensureLoaded; private ensureClient; /** * Map an ActionType + backend-provided params object to the positional-arg * WASM call. The Go signer exports take primitives in order, not an object * — so we pick fields in the exact order the Go side expects. Integrator * fee fields pass through when present, falling back to the nil sentinels * when absent; unrecognised fields are ignored. */ private dispatch; } //# sourceMappingURL=LighterSigner.d.ts.map