@relayprotocol/relay-lighter-wallet-adapter 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":";;;AAAA,wDAKiC;AAEpB,QAAA,gBAAgB,GAAG,OAAO,CAAA;AAKvC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAEpC,MAAM,eAAe,GAAG,qCAAqC,CAAA;AAC7D,MAAM,qBAAqB,GAAG,CAAC,CAAA;AAI/B,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAC3C,MAAM,iBAAiB,GAAG,+DAA+D,mBAAmB,2BAA2B,CAAA;AACvI,MAAM,sBAAsB,GAAG,+DAA+D,mBAAmB,oBAAoB,CAAA;AAKrI,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAE5C,MAAM,iBAAiB,GAAG;IACxB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;CACH,CAAA;AAqDV,IAAI,gBAAgB,GAET,IAAI,CAAA;AACf,MAAM,cAAc,GAAG,GAErB,EAAE;IACF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,qCAAO,gCAAgC,GAAE,KAAK,CAC/D,CAAC,KAAK,EAAE,EAAE;YAGR,gBAAgB,GAAG,IAAI,CAAA;YACvB,MAAM,IAAI,KAAK,CACb,wEAAwE;gBACtE,gEAAgE;gBAChE,sEAAsE;gBACtE,2BAA2B,EAC7B,EAAE,KAAK,EAAE,CACV,CAAA;QACH,CAAC,CACF,CAAA;IACH,CAAC;IACD,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,mB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A;AACH,CAAC,CAAA;AA3QY,QAAA,kBAAkB,sBA2Q9B","sourcesContent":["import {\n getClient,\n LogLevel,\n type AdaptedWallet,\n type LvmReceipt\n} from '@relayprotocol/relay-sdk'\n\nexport const LIGHTER_CHAIN_ID = 3586256\n\n// The chain id baked into L2 signatures by the Lighter WASM signer. This is\n// different from `LIGHTER_CHAIN_ID` — it's the value Lighter's zk circuit\n// validates against on mainnet.\nconst LIGHTER_CIRCUIT_CHAIN_ID = 304\n\nconst DEFAULT_API_URL = 'https://mainnet.zklighter.elliot.ai'\nconst DEFAULT_API_KEY_INDEX = 2\n\n// WASM assets hosted on jsDelivr.\n// Override via `options.wasmConfig` if you'd rather self-host.\nconst LIGHTER_SDK_VERSION = '1.0.7-alpha18'\nconst DEFAULT_WASM_PATH = `https://cdn.jsdelivr.net/npm/@relay-protocol/lighter-ts-sdk@${LIGHTER_SDK_VERSION}/wasm/lighter-signer.wasm`\nconst DEFAULT_WASM_EXEC_PATH = `https://cdn.jsdelivr.net/npm/@relay-protocol/lighter-ts-sdk@${LIGHTER_SDK_VERSION}/wasm/wasm_exec.js`\n\n// Dummy key used only to bootstrap the throwaway SignerClient that performs\n// the `generateAPIKey` / `changeApiKey` dance. `changeApiKey` uses the L1\n// signature as its root of trust, not this value.\nconst DUMMY_API_KEY = '0x' + '00'.repeat(40)\n\nconst LIGHTER_TX_STATUS = {\n PENDING: 0,\n QUEUED: 1,\n COMMITTED: 2,\n EXECUTED: 3,\n FAILED: 4,\n REJECTED: 5\n} as const\n\n/**\n * Minimal L1 signer shape the adapter passes into `transfer()`. The real\n * Lighter SDK accepts `string | ethers.Signer`; we only ever use\n * `signMessage`, so that's all we require structurally.\n */\nexport type LighterEthSigner = {\n signMessage: (message: string) => Promise<string>\n}\n\nexport type LighterTransferParams = {\n toAccountIndex: number\n assetIndex: number\n fromRouteType: number\n toRouteType: number\n amount: number\n usdcFee: number\n memo: string\n /**\n * L1 signer used for the per-transfer authorization. Only omitted when\n * the caller's `signerClient` handles L1 signing internally — the stock\n * `@relay-protocol/lighter-ts-sdk` `SignerClient` requires it.\n */\n ethSigner?: LighterEthSigner\n nonce?: number\n}\n\n/** Subset of the SDK's `Transaction` shape that the adapter actually reads. */\nexport type LighterTransaction = {\n hash: string\n status: number | 'pending' | 'confirmed' | 'failed'\n block_height?: number\n message?: string\n}\n\n/**\n * Minimal Lighter signer contract the adapter depends on. Integrators\n * passing a pre-built signer only need to implement these two methods;\n * the full `@relay-protocol/lighter-ts-sdk` `SignerClient` satisfies this\n * structurally and can be passed directly.\n */\nexport type LighterSigner = {\n transfer: (\n params: LighterTransferParams\n ) => Promise<[unknown, string, string | null]>\n getTransaction: (txHash: string) => Promise<LighterTransaction>\n}\n\n// Lazy, cached dynamic import of `@relay-protocol/lighter-ts-sdk`. Only fires\n// when the adapter needs to bootstrap its own SignerClient. Integrators who\n// always supply a pre-built `signerClient` don't need the package installed\n// at all — it's declared as an optional peer dependency.\nlet sdkModulePromise: Promise<\n typeof import('@relay-protocol/lighter-ts-sdk')\n> | null = null\nconst loadLighterSdk = (): Promise<\n typeof import('@relay-protocol/lighter-ts-sdk')\n> => {\n if (!sdkModulePromise) {\n sdkModulePromise = import('@relay-protocol/lighter-ts-sdk').catch(\n (cause) => {\n // Reset so the next attempt re-tries the import — callers who install\n // the peer mid-session shouldn't have to reload.\n sdkModulePromise = null\n throw new Error(\n 'Lighter adapter: `@relay-protocol/lighter-ts-sdk` is required for the ' +\n 'bootstrap path (fresh keygen, `accountApiKey`, or `storage`). ' +\n 'Install it as a peer dependency, or pass a pre-built `signerClient` ' +\n 'to skip the SDK entirely.',\n { cause }\n )\n }\n )\n }\n return sdkModulePromise\n}\n\nconst coerceLighterStatus = (\n status: LighterTransaction['status']\n): (typeof LIGHTER_TX_STATUS)[keyof typeof LIGHTER_TX_STATUS] => {\n if (typeof status === 'number') {\n return status as (typeof LIGHTER_TX_STATUS)[keyof typeof LIGHTER_TX_STATUS]\n }\n switch (status) {\n case 'confirmed':\n return LIGHTER_TX_STATUS.EXECUTED\n case 'failed':\n return LIGHTER_TX_STATUS.FAILED\n case 'pending':\n default:\n return LIGHTER_TX_STATUS.PENDING\n }\n}\n\nconst pollLighterTransaction = async (\n signerClient: Pick<LighterSigner, 'getTransaction'>,\n txHash: string,\n options: {\n pollIntervalMs: number\n timeoutMs: number\n waitFor: 'findable' | 'committed'\n }\n): Promise<LighterTransaction> => {\n const { pollIntervalMs, timeoutMs, waitFor } = options\n const maxAttempts = Math.max(1, Math.ceil(timeoutMs / pollIntervalMs))\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n let tx: LighterTransaction | undefined\n try {\n tx = await signerClient.getTransaction(txHash)\n } catch {\n // Transient fetch / indexing errors — retry below.\n }\n\n if (tx && tx.hash) {\n const numericStatus = coerceLighterStatus(tx.status)\n\n if (\n numericStatus === LIGHTER_TX_STATUS.FAILED ||\n numericStatus === LIGHTER_TX_STATUS.REJECTED\n ) {\n const label =\n numericStatus === LIGHTER_TX_STATUS.FAILED ? 'failed' : 'rejected'\n throw new Error(\n `Lighter transaction ${label}: ${tx.message ?? 'unknown error'}`\n )\n }\n\n if (waitFor === 'findable') {\n return tx\n }\n\n if (\n numericStatus === LIGHTER_TX_STATUS.COMMITTED ||\n numericStatus === LIGHTER_TX_STATUS.EXECUTED\n ) {\n return tx\n }\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs))\n }\n\n throw new Error(\n `Lighter transaction ${txHash} did not reach '${waitFor}' within ${timeoutMs}ms`\n )\n}\n\n/**\n * Optional per-origin persistent storage for the generated API key. If\n * omitted the adapter regenerates a fresh key on every page load (the\n * conservative default — key never leaves memory). If you want to skip the\n * per-session `changeApiKey` signature prompt, plug in something like\n * `localStorage` or IndexedDB.\n */\nexport type LighterKeyStorage = {\n get: (storageKey: string) => Promise<string | null> | string | null\n set: (storageKey: string, value: string) => Promise<void> | void\n}\n\n/** Callback that signs a plain-text L1 authorization message. */\nexport type LighterSignL1Message = (message: string) => Promise<string>\n\ntype AdaptLighterWalletBaseOptions = {\n /**\n * The user's L1 (EVM) wallet address. Used to resolve their Lighter\n * account index and to key the optional persistent storage.\n */\n l1Address: `0x${string}`\n /**\n * Callback that signs an L1 authorization message with the user's\n * connected wallet. Typically a thin wrapper around a viem\n * `WalletClient.signMessage` call.\n *\n * Required unless `signerClient` is supplied — when the integrator\n * provides their own signer, it's assumed to handle L1 signing\n * internally (or to accept `signL1Message` as a separate concern).\n *\n * When both are supplied, `signL1Message` is still forwarded to the\n * signer's `transfer()` calls via the `ethSigner` param.\n *\n * Not invoked for the bootstrap step when `accountApiKey` or\n * `signerClient` is supplied — only for per-transfer authorization.\n */\n signL1Message?: LighterSignL1Message\n //Lighter HTTP API base URL. Default: mainnet. Recommended to host a proxy.\n apiUrl?: string\n //API key slot to (re)register. Default: 2.\n apiKeyIndex?: number\n /** Paths to the Lighter WASM signer + Go runtime shim. Default: jsDelivr CDN. */\n wasmConfig?: {\n wasmPath?: string\n wasmExecPath?: string\n }\n /**\n * Pre-registered Lighter account API key (hex-encoded, with or without\n * `0x` prefix). This is the Lighter protocol's session key — not a\n * wallet private key. When supplied, the adapter skips the\n * `generateAPIKey` + `changeApiKey` bootstrap entirely (no signature\n * prompt, no on-chain key-rotation wait) and uses this key directly for\n * the `SignerClient`.\n *\n * The caller is responsible for:\n * - Having already registered the corresponding public key on the\n * user's Lighter account at `apiKeyIndex`\n * - Storing the key securely\n *\n * Use this when you've built your own API-key lifecycle (e.g. a\n * backend service that provisions keys, or a wallet-level integration\n * that manages keys outside this adapter). Mutually exclusive with\n * `storage` — if both are set, `accountApiKey` wins and `storage` is\n * ignored.\n */\n accountApiKey?: string\n /**\n * Optional API-key persistence. When provided, the adapter reuses the\n * stored key across sessions instead of re-running `changeApiKey`.\n * Ignored when `accountApiKey` or `signerClient` is supplied.\n */\n storage?: LighterKeyStorage\n /** Confirmation poll interval. Default: 2000ms. */\n pollIntervalMs?: number\n /** Confirmation timeout. Default: 120000ms. */\n timeoutMs?: number\n}\n\n/**\n * Pre-built-signer path. `signerClient` and `accountIndex` must be paired\n * — the adapter can't pull account index out of a `SignerClient` instance\n * (the SDK's config is private), and it needs the value for\n * `AdaptedWallet.address()`. Pairing them lets the adapter run with\n * zero runtime dependency on `@relay-protocol/lighter-ts-sdk`.\n */\ntype AdaptLighterWalletPreBuiltOptions = AdaptLighterWalletBaseOptions & {\n /**\n * Pre-built Lighter signer. When supplied, the adapter bypasses the\n * `generateAPIKey` / `changeApiKey` bootstrap entirely and uses this\n * signer for all `transfer()` and `getTransaction()` calls.\n *\n * The caller is responsible for ensuring the signer is ready to use\n * (initialized, WASM loaded, API key registered) and for caching it\n * if desired. A full `SignerClient` from `@relay-protocol/lighter-ts-sdk`\n * satisfies `LighterSigner` structurally and can be passed directly.\n *\n * When set, `apiUrl`, `apiKeyIndex`, `wasmConfig`, `accountApiKey`,\n * and `storage` are all ignored (baked into the signer).\n */\n signerClient: LighterSigner\n /** The user's Lighter account index. Required when `signerClient` is set. */\n accountIndex: number\n}\n\n/** Bootstrap path — the adapter owns the signer lifecycle. */\ntype AdaptLighterWalletBootstrapOptions = AdaptLighterWalletBaseOptions & {\n signerClient?: never\n accountIndex?: never\n}\n\nexport type AdaptLighterWalletOptions =\n | AdaptLighterWalletBootstrapOptions\n | AdaptLighterWalletPreBuiltOptions\n\n/**\n * Adapts a Lighter wallet to work with the Relay SDK.\n *\n * The adapter owns the full Lighter session lifecycle so integrators only\n * have to provide the user's L1 address and a message-signing callback:\n *\n * ```ts\n * const wallet = adaptLighterWallet({\n * l1Address: account.address,\n * signL1Message: (msg) =>\n * walletClient.signMessage({ account, message: msg })\n * })\n * ```\n *\n * On construction the adapter does nothing interactive — no network calls,\n * no signature prompts. The first call into `handleSendTransactionStep`\n * triggers the lazy bootstrap, which:\n * 1. Resolves the user's Lighter `accountIndex` from their L1 address.\n * 2. Either loads a persisted API key (if `storage` is provided) or\n * generates a fresh keypair in memory.\n * 3. For a fresh key, prompts the user to sign an L1 authorization and\n * calls `changeApiKey` to register it against the account.\n * 4. Waits for the key rotation to execute on Lighter.\n * 5. Constructs the real `SignerClient` backed by the new key.\n *\n * Subsequent transactions reuse the cached session (in-memory at minimum).\n *\n * Passing `signerClient` skips the entire bootstrap and avoids any runtime\n * dependency on `@relay-protocol/lighter-ts-sdk`.\n *\n */\nexport const adaptLighterWallet = (\n options: AdaptLighterWalletOptions\n): AdaptedWallet => {\n const {\n l1Address,\n signL1Message,\n apiUrl = DEFAULT_API_URL,\n apiKeyIndex = DEFAULT_API_KEY_INDEX,\n wasmConfig,\n accountApiKey,\n signerClient: preConfiguredSigner,\n accountIndex: preConfiguredAccountIndex,\n storage,\n pollIntervalMs = 2_000,\n timeoutMs = 120_000\n } = options\n\n // `signL1Message` is only optional when the caller supplies a\n // `signerClient`; otherwise the adapter's own bootstrap + `transfer()`\n // path calls the stock `SignerClient`, which requires an ethSigner.\n if (!preConfiguredSigner && !signL1Message) {\n throw new Error(\n 'Lighter adapter: `signL1Message` is required unless a pre-built `signerClient` is supplied.'\n )\n }\n\n const normalizedL1Address = l1Address.toLowerCase()\n\n const resolvedWasmConfig = {\n wasmPath: wasmConfig?.wasmPath ?? DEFAULT_WASM_PATH,\n wasmExecPath: wasmConfig?.wasmExecPath ?? DEFAULT_WASM_EXEC_PATH\n }\n\n // The SDK's `SignerClient.transfer()` only calls `.signMessage(msg)` on\n // whatever is passed as `ethSigner`. We forward to the supplied callback.\n // `undefined` when the caller's `signerClient` handles L1 signing on its\n // own — forwarded as-is to their `transfer()` implementation.\n const ethSignerShim: LighterEthSigner | undefined = signL1Message\n ? {\n signMessage: (message: string): Promise<string> =>\n signL1Message(message)\n }\n : undefined\n\n // Account-index cache. Resolved via public API — no signature required.\n // Pre-populated from the `accountIndex` option when supplied, so we\n // never hit the network (or the SDK) in that path.\n let cachedAccountIndex: number | null = preConfiguredAccountIndex ?? null\n const resolveAccountIndex = async (): Promise<number> => {\n if (cachedAccountIndex !== null) return cachedAccountIndex\n const { AccountApi, ApiClient } = await loadLighterSdk()\n const apiClient = new ApiClient({ host: apiUrl })\n const accountApi = new AccountApi(apiClient)\n const response = (await accountApi.getAccount({\n by: 'l1_address',\n value: normalizedL1Address\n })) as unknown as {\n code?: number\n total?: number\n accounts?: Array<{ index?: number | string }>\n }\n const firstAccount = response?.accounts?.[0]\n const rawIndex = firstAccount?.index\n const index = typeof rawIndex === 'number' ? rawIndex : Number(rawIndex)\n if (!firstAccount || !Number.isFinite(index)) {\n throw new Error(\n `Lighter adapter: could not resolve accountIndex for ${l1Address}. ` +\n 'Has the user created a Lighter account via an L1 deposit?'\n )\n }\n cachedAccountIndex = index\n return index\n }\n\n // Signer resolution. When `signerClient` is supplied, this is a direct\n // pass-through — no network, no SDK import, no account-index lookup.\n // Otherwise the first call triggers the lazy bootstrap, which fires the\n // `changeApiKey` signature prompt if we have to generate a fresh key.\n let signerPromise: Promise<LighterSigner> | null = preConfiguredSigner\n ? Promise.resolve(preConfiguredSigner)\n : null\n const getSigner = (): Promise<LighterSigner> => {\n if (signerPromise) return signerPromise\n\n signerPromise = (async () => {\n const { SignerClient, ApiClient, TransactionApi } = await loadLighterSdk()\n const accountIndex = await resolveAccountIndex()\n\n // Precedence: explicit `accountApiKey` > persisted via `storage` >\n // fresh bootstrap. The first two both bypass the `changeApiKey` prompt.\n const storageKey = `lighter-api-key:${normalizedL1Address}:${apiKeyIndex}`\n\n let hydratedAccountApiKey: string | null = accountApiKey ?? null\n if (!hydratedAccountApiKey && storage) {\n const stored = await storage.get(storageKey)\n hydratedAccountApiKey = stored ?? null\n }\n\n if (hydratedAccountApiKey) {\n const signerClient = new SignerClient({\n url: apiUrl,\n privateKey: hydratedAccountApiKey,\n accountIndex,\n apiKeyIndex,\n chainId: LIGHTER_CIRCUIT_CHAIN_ID,\n wasmConfig: resolvedWasmConfig\n })\n await signerClient.initialize()\n await signerClient.ensureWasmClient()\n // Cast: SignerClient's `transfer` accepts `string | Signer` for\n // `ethSigner`, which is structurally wider than our\n // `LighterEthSigner`. Safe because the SDK only calls\n // `.signMessage()` on it.\n return signerClient as unknown as LighterSigner\n }\n\n // No stored key — generate one and register it.\n //\n // Step 1: keygen-only client. A dummy key is fine because\n // `generateAPIKey` is a stateless WASM call that doesn't use the\n // current signing context. We deliberately DO NOT call\n // `ensureWasmClient` here — doing so would lock the WASM's signing\n // context to the dummy key, and the ChangePubKey `Sig` (which proves\n // ownership of the new key) would be produced with the dummy key\n // instead of the freshly generated one, causing Lighter to reject\n // the tx as \"invalid signature\".\n const keygenClient = new SignerClient({\n url: apiUrl,\n privateKey: DUMMY_API_KEY,\n accountIndex,\n apiKeyIndex,\n chainId: LIGHTER_CIRCUIT_CHAIN_ID,\n wasmConfig: resolvedWasmConfig\n })\n await keygenClient.initialize()\n const keypair = await keygenClient.generateAPIKey()\n if (!keypair) {\n throw new Error('Lighter adapter: failed to generate an API keypair')\n }\n\n // Step 2: the real client, backed by the newly generated key. Calling\n // `ensureWasmClient` now registers that key as the signing context\n // for the target slot, so `changeApiKey` produces a valid ownership\n // proof for the pubkey it's registering.\n const signerClient = new SignerClient({\n url: apiUrl,\n privateKey: keypair.privateKey,\n accountIndex,\n apiKeyIndex,\n chainId: LIGHTER_CIRCUIT_CHAIN_ID,\n wasmConfig: resolvedWasmConfig\n })\n await signerClient.initialize()\n await signerClient.ensureWasmClient()\n const nonceApiClient = new ApiClient({ host: apiUrl })\n const transactionApi = new TransactionApi(nonceApiClient)\n const nextNonceResponse = (await transactionApi.getNextNonce(\n accountIndex,\n apiKeyIndex\n )) as unknown as { nonce?: number | string }\n const rawNonce = nextNonceResponse?.nonce\n const nonceForChangeKey =\n typeof rawNonce === 'number' ? rawNonce : Number(rawNonce ?? 0)\n\n const [, changeKeyTxHash, changeKeyError] =\n await signerClient.changeApiKey({\n // Cast through `unknown`: the SDK types `ethSigner` as\n // `string | ethers.Signer`, but it only ever invokes\n // `.signMessage()` on it — which our shim provides.\n ethSigner: ethSignerShim as unknown as Parameters<\n typeof signerClient.changeApiKey\n >[0]['ethSigner'],\n newPubkey: keypair.publicKey,\n newApiKeyIndex: apiKeyIndex,\n nonce: Number.isFinite(nonceForChangeKey) ? nonceForChangeKey : 0\n })\n if (changeKeyError) {\n throw new Error(`Lighter changeApiKey failed: ${changeKeyError}`)\n }\n if (!changeKeyTxHash) {\n throw new Error('Lighter changeApiKey returned no transaction hash')\n }\n\n await pollLighterTransaction(signerClient, changeKeyTxHash, {\n pollIntervalMs,\n timeoutMs,\n waitFor: 'committed'\n })\n\n if (storage) {\n await storage.set(storageKey, keypair.privateKey)\n }\n\n // Same narrowing cast as the hydrated-key branch above.\n return signerClient as unknown as LighterSigner\n })()\n\n // If bootstrap fails, clear the promise so a retry can start fresh.\n signerPromise.catch(() => {\n signerPromise = null\n })\n\n return signerPromise\n }\n\n return {\n vmType: 'lvm',\n getChainId: async () => LIGHTER_CHAIN_ID,\n address: async () => (await resolveAccountIndex()).toString(),\n handleSignMessageStep: async () => {\n throw new Error('Message signing not implemented for Lighter')\n },\n handleSendTransactionStep: async (_chainId, stepItem, _step) => {\n const client = getClient()\n const action = stepItem.data?.action\n\n if (!action || action.type !== 'transfer') {\n throw new Error(\n `Unsupported Lighter action: ${action?.type ?? 'undefined'}`\n )\n }\n\n const signerClient = await getSigner()\n const params = action.parameters\n client.log(['Executing Lighter transfer', params], LogLevel.Verbose)\n\n const [, txHash, error] = await signerClient.transfer({\n toAccountIndex: params.toAccountIndex,\n assetIndex: params.assetIndex,\n fromRouteType: params.fromRouteType,\n toRouteType: params.toRouteType,\n amount: params.amount,\n usdcFee: params.usdcFee,\n memo: params.memo,\n ethSigner: ethSignerShim\n })\n\n if (error) {\n throw new Error(`Lighter transfer failed: ${error}`)\n }\n if (!txHash) {\n throw new Error('Lighter transfer returned no transaction hash')\n }\n\n client.log(['Lighter transaction broadcasted', txHash], LogLevel.Verbose)\n\n return txHash\n },\n handleConfirmTransactionStep: async (\n txHash: string\n ): Promise<LvmReceipt> => {\n const signerClient = await getSigner()\n const tx = await pollLighterTransaction(signerClient, txHash, {\n pollIntervalMs,\n timeoutMs,\n waitFor: 'findable'\n })\n return {\n txHash: tx.hash,\n blockHeight: tx.block_height ?? 0,\n status: tx.status\n }\n },\n switchChain: async () => {\n // Lighter is a single-chain network — nothing to switch\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B","sourcesContent":["export * from './adapter.js'\n"]}