import { type SignActionsContext } from '@lifi/perps-sdk'; import type { ActionStep, EvmTxActionStep, EvmTxSignedActionStep, SignedActionStep, WasmBlobActionStep, WasmBlobSignedActionStep } from '@lifi/perps-types'; import { SigningMethod } from '@lifi/perps-types'; import type { Address } from 'viem'; import type { LighterApiClient } from '../utils/apiClient.js'; import type { LighterApiKey, LighterKeyStore } from './LighterKeyStore.js'; import type { LighterSigner } from './LighterSigner.js'; /** * Per-batch dependencies the Lighter `signActions` implementation needs: * the provider instance's WASM signer, its API-key store keyed on L1 address, * a REST client for the token-authenticated venue mutations that execute * client-side, and an `accountIndex` resolver for the REGISTER_API_KEY * hybrid flow. * * @internal */ export interface LighterSignActionsDeps { signer: LighterSigner; keyStore: LighterKeyStore; /** REST client bound to the user's Lighter base URL, used for the direct * `changeAccountTier` / `referral/use` POSTs so their auth token never * transits the LI.FI backend. */ apiClient: LighterApiClient; /** * Pre-sign guard that the stored API key still occupies its venue slot. * Created once per provider instance so its freshness window spans batches. */ apiKeyFreshness: LighterApiKeyFreshness; /** * Resolve the user's Lighter `accountIndex` for an L1 address. Required * by REGISTER_API_KEY so the ChangePubKey blob carries the right * account. Implementations typically call Lighter's `/api/v1/account` * with `by=l1_address`. */ resolveAccountIndex(address: Address): Promise; } /** * Pre-sign guard that the stored Lighter API key is still the key registered * in its venue slot. Owns the freshness window, so one instance is created per * provider instance and shared by every batch that instance signs. * * @internal */ export interface LighterApiKeyFreshness { assertStillRegistered(client: LighterApiClient, address: Address, apiKey: LighterApiKey): Promise; } /** * Build the guard {@link LighterSignActionsDeps.apiKeyFreshness} needs. * * @internal */ export declare const createLighterApiKeyFreshness: () => LighterApiKeyFreshness; /** * Sign a `WASM_BLOB` batch (Lighter). Ensures the user's API keypair is * registered first — generating one and running the REGISTER_API_KEY * hybrid flow via the L1 signer if not — then feeds each subsequent step * through the WASM signer. * * The token-authenticated mutations (`ACCOUNT_TYPE` → `/changeAccountTier`, * `SET_REFERRAL` → `/referral/use`) are NOT wasm-signed: they execute * client-side here via a direct Lighter POST authenticated with a short-lived * auth token, so the token never transits the LI.FI backend. They produce no * backend-bound step and are omitted from the returned array. * @internal */ export declare function signWasmBlobActions(deps: LighterSignActionsDeps, address: Address, steps: WasmBlobActionStep[], ctx: SignActionsContext | undefined): Promise; /** * Sign and broadcast a sequence of `EVM_TX` actions via the user's wallet * client. Each leg is broadcast then confirmed to a successful receipt before * the next is broadcast, so a later step (e.g. deposit) can rely on an earlier * step (e.g. approve) having mined. A reverted leg throws and aborts the * remaining legs. Each step's `txParams` carries chainId, target, function * name, args, and a human-readable abi from the backend. * * Before broadcasting a leg the SDK switches the wallet to the leg's * `txParams.chainId` via `ctx.switchToChain`, re-reading the returned client so * the broadcast lands on the right chain even when legs target different chains. * When no switch capability is supplied (local/private-key signer, or no * `switchChain` hook configured) a leg whose target chain differs from the * wallet's active chain throws before broadcasting, so a token approve/deposit * can never land on an unintended chain. * @internal */ export declare function signEvmTxActions(steps: EvmTxActionStep[], ctx: SignActionsContext | undefined): Promise; /** * Top-level dispatch: pick the per-method signer based on the descriptor's * `signingMethod` and forward. `EIP712` is rejected — Lighter declares no * EIP712 actions (its user-consent step uses an EIP-191 `signMessage` inside * the `WASM_BLOB` REGISTER_API_KEY flow). * @internal */ export declare function lighterSignActions(deps: LighterSignActionsDeps, method: SigningMethod, steps: ActionStep[], address: Address, ctx?: SignActionsContext): Promise; //# sourceMappingURL=signActions.d.ts.map