@latchprotocol/widgets 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +649 -0
- package/dist/adapters/binDistribution.d.ts +19 -0
- package/dist/adapters/binDistribution.d.ts.map +1 -0
- package/dist/adapters/protocol.d.ts +409 -0
- package/dist/adapters/protocol.d.ts.map +1 -0
- package/dist/adapters/sale.d.ts +142 -0
- package/dist/adapters/sale.d.ts.map +1 -0
- package/dist/adapters/viem.d.ts +89 -0
- package/dist/adapters/viem.d.ts.map +1 -0
- package/dist/callpath/constants.d.ts +218 -0
- package/dist/callpath/constants.d.ts.map +1 -0
- package/dist/callpath/launch.d.ts +1979 -0
- package/dist/callpath/launch.d.ts.map +1 -0
- package/dist/callpath/liquidity.d.ts +103 -0
- package/dist/callpath/liquidity.d.ts.map +1 -0
- package/dist/callpath/plan.d.ts +34 -0
- package/dist/callpath/plan.d.ts.map +1 -0
- package/dist/callpath/swap.d.ts +129 -0
- package/dist/callpath/swap.d.ts.map +1 -0
- package/dist/chunks/SwapWidget-DgyHAVc8.js +2404 -0
- package/dist/chunks/SwapWidget-DgyHAVc8.js.map +1 -0
- package/dist/chunks/scan-Dhu7f4Nl.js +2497 -0
- package/dist/chunks/scan-Dhu7f4Nl.js.map +1 -0
- package/dist/chunks/useLocker-D1c_NTk-.js +1613 -0
- package/dist/chunks/useLocker-D1c_NTk-.js.map +1 -0
- package/dist/components/LaunchWidget.d.ts +117 -0
- package/dist/components/LaunchWidget.d.ts.map +1 -0
- package/dist/components/LiquidityWidget.d.ts +33 -0
- package/dist/components/LiquidityWidget.d.ts.map +1 -0
- package/dist/components/LockerWidget.d.ts +51 -0
- package/dist/components/LockerWidget.d.ts.map +1 -0
- package/dist/components/LocksWidgets.d.ts +61 -0
- package/dist/components/LocksWidgets.d.ts.map +1 -0
- package/dist/components/SwapWidget.d.ts +165 -0
- package/dist/components/SwapWidget.d.ts.map +1 -0
- package/dist/components/TokenTrustPanel.d.ts +32 -0
- package/dist/components/TokenTrustPanel.d.ts.map +1 -0
- package/dist/components/lockCharts.d.ts +29 -0
- package/dist/components/lockCharts.d.ts.map +1 -0
- package/dist/components/portal.d.ts +10 -0
- package/dist/components/portal.d.ts.map +1 -0
- package/dist/components/primitives.d.ts +139 -0
- package/dist/components/primitives.d.ts.map +1 -0
- package/dist/components/swap/SwapSettings.d.ts +12 -0
- package/dist/components/swap/SwapSettings.d.ts.map +1 -0
- package/dist/components/swap/TokenSelect.d.ts +61 -0
- package/dist/components/swap/TokenSelect.d.ts.map +1 -0
- package/dist/components/swap/state.d.ts +208 -0
- package/dist/components/swap/state.d.ts.map +1 -0
- package/dist/config/chain.d.ts +163 -0
- package/dist/config/chain.d.ts.map +1 -0
- package/dist/config/integrator.d.ts +121 -0
- package/dist/config/integrator.d.ts.map +1 -0
- package/dist/context/WidgetProvider.d.ts +78 -0
- package/dist/context/WidgetProvider.d.ts.map +1 -0
- package/dist/core/clMath.d.ts +98 -0
- package/dist/core/clMath.d.ts.map +1 -0
- package/dist/core/errors.d.ts +18 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/format.d.ts +47 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/liquidityGuards.d.ts +53 -0
- package/dist/core/liquidityGuards.d.ts.map +1 -0
- package/dist/core/liquidityRefresh.d.ts +35 -0
- package/dist/core/liquidityRefresh.d.ts.map +1 -0
- package/dist/core/math.d.ts +129 -0
- package/dist/core/math.d.ts.map +1 -0
- package/dist/core/pool.d.ts +33 -0
- package/dist/core/pool.d.ts.map +1 -0
- package/dist/core/tokenLists.d.ts +46 -0
- package/dist/core/tokenLists.d.ts.map +1 -0
- package/dist/embed/iframe.d.ts +185 -0
- package/dist/embed/iframe.d.ts.map +1 -0
- package/dist/embed/lockBadge.d.ts +55 -0
- package/dist/embed/lockBadge.d.ts.map +1 -0
- package/dist/embed/webComponent.d.ts +83 -0
- package/dist/embed/webComponent.d.ts.map +1 -0
- package/dist/embed.d.ts +25 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +543 -0
- package/dist/embed.js.map +1 -0
- package/dist/headless.d.ts +60 -0
- package/dist/headless.d.ts.map +1 -0
- package/dist/headless.js +223 -0
- package/dist/headless.js.map +1 -0
- package/dist/hooks/useAsyncResource.d.ts +38 -0
- package/dist/hooks/useAsyncResource.d.ts.map +1 -0
- package/dist/hooks/useLaunch.d.ts +140 -0
- package/dist/hooks/useLaunch.d.ts.map +1 -0
- package/dist/hooks/useLiquidity.d.ts +91 -0
- package/dist/hooks/useLiquidity.d.ts.map +1 -0
- package/dist/hooks/useLocker.d.ts +77 -0
- package/dist/hooks/useLocker.d.ts.map +1 -0
- package/dist/hooks/useLocks.d.ts +33 -0
- package/dist/hooks/useLocks.d.ts.map +1 -0
- package/dist/hooks/useSwapExecute.d.ts +46 -0
- package/dist/hooks/useSwapExecute.d.ts.map +1 -0
- package/dist/hooks/useSwapQuote.d.ts +51 -0
- package/dist/hooks/useSwapQuote.d.ts.map +1 -0
- package/dist/hooks/useTokenLists.d.ts +26 -0
- package/dist/hooks/useTokenLists.d.ts.map +1 -0
- package/dist/hooks/useTokenTrust.d.ts +40 -0
- package/dist/hooks/useTokenTrust.d.ts.map +1 -0
- package/dist/hooks/useTokens.d.ts +15 -0
- package/dist/hooks/useTokens.d.ts.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1052 -0
- package/dist/index.js.map +1 -0
- package/dist/latch-embed.d.ts +19 -0
- package/dist/latch-embed.d.ts.map +1 -0
- package/dist/latch-embed.js +950 -0
- package/dist/latch-embed.js.map +1 -0
- package/dist/latch-embed.mjs +13162 -0
- package/dist/latch-embed.mjs.map +1 -0
- package/dist/locker/model.d.ts +73 -0
- package/dist/locker/model.d.ts.map +1 -0
- package/dist/locks/embedModel.d.ts +22 -0
- package/dist/locks/embedModel.d.ts.map +1 -0
- package/dist/locks/fetch.d.ts +60 -0
- package/dist/locks/fetch.d.ts.map +1 -0
- package/dist/locks/model.d.ts +143 -0
- package/dist/locks/model.d.ts.map +1 -0
- package/dist/locks/scan.d.ts +25 -0
- package/dist/locks/scan.d.ts.map +1 -0
- package/dist/styles/css.d.ts +32 -0
- package/dist/styles/css.d.ts.map +1 -0
- package/dist/styles.css +895 -0
- package/dist/trust/model.d.ts +48 -0
- package/dist/trust/model.d.ts.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","sources":["../src/embed/webComponent.tsx","../src/embed/iframe.ts","../src/embed/lockBadge.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n/**\n * Custom-element wrappers, for hosts that are not React.\n *\n * Vue, Svelte, Angular, Astro and plain HTML can all render a custom element.\n * These mount the same React components into a shadow root, so the widget's CSS\n * cannot leak into the host page and the host's CSS cannot break the widget -\n * while `--latch-*` custom properties still inherit through the shadow boundary,\n * which is exactly the theming behaviour an embedder wants.\n *\n * ```html\n * <script type=\"module\" src=\"/latch-widgets.js\"></script>\n * <latch-swap-widget theme=\"dark\"></latch-swap-widget>\n * ```\n *\n * The adapter cannot come from an attribute - a viem transport is not JSON -\n * so set it as a property:\n *\n * ```js\n * document.querySelector(\"latch-swap-widget\").adapter = createViemAdapter({...});\n * ```\n */\n\nimport { createElement, type ComponentType } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport type { ProtocolAdapter } from \"../adapters/protocol.js\";\nimport type { IntegratorConfig } from \"../config/integrator.js\";\nimport { WidgetProvider, type WidgetTheme } from \"../context/WidgetProvider.js\";\nimport { LaunchWidget } from \"../components/LaunchWidget.js\";\nimport { LiquidityWidget } from \"../components/LiquidityWidget.js\";\nimport { SwapWidget } from \"../components/SwapWidget.js\";\nimport { WIDGET_CSS } from \"../styles/css.js\";\n\n/** Attributes every Latch widget element understands. */\nconst COMMON_ATTRIBUTES = [\n \"integrator\",\n \"theme\",\n \"slippage-bps\",\n \"title-text\",\n] as const;\n\nfunction parseJsonAttribute<T>(value: string | null, label: string): T | null {\n if (value === null || value.trim() === \"\") return null;\n try {\n return JSON.parse(value) as T;\n } catch (cause: unknown) {\n throw new Error(\n `[@latchprotocol/widgets] the ${label} attribute is not valid JSON: ${String(cause)}`,\n );\n }\n}\n\n/**\n * SSR-safe `HTMLElement`.\n *\n * `class X extends HTMLElement` is evaluated at module load, so importing this\n * file in Node - which any host doing server-side rendering does - would throw\n * `HTMLElement is not defined` before a single line of user code ran. On the\n * server the classes extend an inert stand-in instead. They are never\n * instantiated there: `defineLatchWidgets` no-ops without `customElements`, and\n * only the browser's custom-element machinery constructs them.\n */\nconst ElementBase: typeof HTMLElement =\n typeof HTMLElement === \"undefined\"\n ? (class {} as unknown as typeof HTMLElement)\n : HTMLElement;\n\n/** Base class shared by every widget element. */\nabstract class LatchWidgetElement extends ElementBase {\n #root: Root | null = null;\n #shadow: ShadowRoot | null = null;\n #adapter: ProtocolAdapter | null = null;\n #error: string | null = null;\n\n /** Observed attributes, extended by each subclass. */\n static get observedAttributes(): readonly string[] {\n return COMMON_ATTRIBUTES;\n }\n\n /** The adapter, when set imperatively. Takes precedence over the attribute. */\n get adapter(): ProtocolAdapter | null {\n return this.#adapter;\n }\n\n set adapter(value: ProtocolAdapter | null) {\n this.#adapter = value;\n this.#render();\n }\n\n connectedCallback(): void {\n if (this.#shadow === null) {\n this.#shadow = this.attachShadow({ mode: \"open\" });\n const style = document.createElement(\"style\");\n style.textContent = WIDGET_CSS;\n this.#shadow.appendChild(style);\n const mount = document.createElement(\"div\");\n this.#shadow.appendChild(mount);\n this.#root = createRoot(mount);\n }\n this.#render();\n }\n\n disconnectedCallback(): void {\n const root = this.#root;\n this.#root = null;\n // Unmount asynchronously: React refuses to unmount during a commit, and a\n // custom element can be disconnected from inside one.\n if (root !== null) queueMicrotask(() => root.unmount());\n }\n\n attributeChangedCallback(): void {\n this.#render();\n }\n\n /** The React component this element renders. */\n protected abstract component(): ComponentType<Record<string, unknown>>;\n\n /** Extra props derived from element attributes. */\n protected widgetProps(): Record<string, unknown> {\n const title = this.getAttribute(\"title-text\");\n return title === null ? {} : { title };\n }\n\n #resolveAdapter(): ProtocolAdapter | null {\n return this.#adapter;\n }\n\n #render(): void {\n if (this.#root === null) return;\n try {\n const adapter = this.#resolveAdapter();\n if (adapter === null) {\n this.#root.render(\n createElement(\n \"div\",\n { className: \"latch-widget\" },\n createElement(\n \"p\",\n { className: \"latch-error\", role: \"alert\" },\n \"No adapter. Set the element's `adapter` property to a live adapter \" +\n \"(createViemAdapter).\",\n ),\n ),\n );\n return;\n }\n\n const integrator = parseJsonAttribute<IntegratorConfig>(\n this.getAttribute(\"integrator\"),\n \"integrator\",\n );\n const theme = (this.getAttribute(\"theme\") ?? \"system\") as WidgetTheme;\n const slippageRaw = this.getAttribute(\"slippage-bps\");\n\n this.#error = null;\n this.#root.render(\n createElement(WidgetProvider, {\n adapter,\n theme,\n ...(integrator === null ? {} : { integrator }),\n ...(slippageRaw === null ? {} : { defaultSlippageBps: Number(slippageRaw) }),\n children: createElement(this.component(), this.widgetProps()),\n }),\n );\n } catch (cause: unknown) {\n this.#error = cause instanceof Error ? cause.message : String(cause);\n this.#root.render(\n createElement(\n \"div\",\n { className: \"latch-widget\" },\n createElement(\"p\", { className: \"latch-error\", role: \"alert\" }, this.#error),\n ),\n );\n }\n }\n}\n\n/** `<latch-swap-widget>`. */\nexport class LatchSwapWidgetElement extends LatchWidgetElement {\n static override get observedAttributes(): readonly string[] {\n return [...COMMON_ATTRIBUTES, \"token-in\", \"token-out\", \"account\", \"variant\"];\n }\n\n protected override component(): ComponentType<Record<string, unknown>> {\n return SwapWidget as ComponentType<Record<string, unknown>>;\n }\n\n protected override widgetProps(): Record<string, unknown> {\n const tokenIn = this.getAttribute(\"token-in\");\n const tokenOut = this.getAttribute(\"token-out\");\n /* `variant=\"compact\"`: the Buy / Sell pill and the always-visible lines; anything else is the default. */\n const variant = this.getAttribute(\"variant\");\n return {\n ...super.widgetProps(),\n ...(tokenIn === null ? {} : { defaultTokenIn: tokenIn }),\n ...(tokenOut === null ? {} : { defaultTokenOut: tokenOut }),\n ...(variant === \"compact\" ? { variant: \"compact\" } : {}),\n };\n }\n}\n\n/** `<latch-liquidity-widget>`. */\nexport class LatchLiquidityWidgetElement extends LatchWidgetElement {\n static override get observedAttributes(): readonly string[] {\n return [...COMMON_ATTRIBUTES, \"pool-id\", \"mode\", \"account\"];\n }\n\n protected override component(): ComponentType<Record<string, unknown>> {\n return LiquidityWidget as ComponentType<Record<string, unknown>>;\n }\n\n protected override widgetProps(): Record<string, unknown> {\n const poolId = this.getAttribute(\"pool-id\");\n const mode = this.getAttribute(\"mode\");\n return {\n ...super.widgetProps(),\n ...(poolId === null ? {} : { defaultPoolId: poolId }),\n ...(mode === \"remove\" || mode === \"add\" ? { defaultMode: mode } : {}),\n };\n }\n}\n\n/** `<latch-launch-widget>`. */\nexport class LatchLaunchWidgetElement extends LatchWidgetElement {\n static override get observedAttributes(): readonly string[] {\n return [...COMMON_ATTRIBUTES, \"pool-id\", \"account\"];\n }\n\n protected override component(): ComponentType<Record<string, unknown>> {\n return LaunchWidget as ComponentType<Record<string, unknown>>;\n }\n\n protected override widgetProps(): Record<string, unknown> {\n // A pool id, not a launchpad address: LaunchGuardHook keys every launch\n // by PoolId, and there is no per-launch contract to point at.\n const poolId = this.getAttribute(\"pool-id\");\n return {\n ...super.widgetProps(),\n ...(poolId === null ? {} : { poolId }),\n };\n }\n}\n\n/** Element tag names, so hosts do not have to hardcode strings. */\nexport const WIDGET_TAG_NAMES = {\n swap: \"latch-swap-widget\",\n liquidity: \"latch-liquidity-widget\",\n launch: \"latch-launch-widget\",\n} as const;\n\n/**\n * Registers every widget element.\n *\n * Safe to call more than once; already-registered tags are skipped rather than\n * throwing, so two copies of the bundle on one page do not break it.\n */\nexport function defineLatchWidgets(): void {\n if (typeof customElements === \"undefined\") return;\n const registry: readonly [string, CustomElementConstructor][] = [\n [WIDGET_TAG_NAMES.swap, LatchSwapWidgetElement],\n [WIDGET_TAG_NAMES.liquidity, LatchLiquidityWidgetElement],\n [WIDGET_TAG_NAMES.launch, LatchLaunchWidgetElement],\n ];\n for (const [tag, constructor] of registry) {\n if (customElements.get(tag) === undefined) {\n customElements.define(tag, constructor);\n }\n }\n}\n","// SPDX-License-Identifier: MIT\n/**\n * Iframe embedding: the postMessage contract.\n *\n * The web component is the right answer for most hosts. The iframe exists for\n * the case the web component cannot serve: a host that will not run third-party\n * script in its own realm - which, for a widget asking users to sign\n * transactions, is a reasonable position for a host to take.\n *\n * ## The split\n *\n * The **widget** runs inside the iframe and owns only rendering. It holds no\n * keys and opens no RPC connections. Every chain read and write is a request to\n * the host.\n *\n * The **host** runs in the parent page, owns the wallet and a real\n * {@link ../adapters/protocol.js | ProtocolAdapter}, and answers those requests.\n *\n * ```text\n * iframe (widget) parent (host)\n * ──────────────── ─────────────\n * ready ─────────────────────────────────▶\n * ◀───────────────────────────── init { chain, integrator, theme }\n * invoke { id, method, args } ───────────▶\n * ◀────────── result { id, ok, value } | { id, ok: false, error }\n * resize { height } ─────────────────────▶\n * event { name, payload } ──────────────▶\n * ```\n *\n * ## Message contract\n *\n * Every message is `{ channel: \"latch-widget\", version: 1, ... }`. Anything\n * without that envelope is ignored. Both sides pin the counterpart origin -\n * the host passes the widget's origin, the widget receives the host's in\n * `init` - and every later message is checked against it. `event.origin` is the\n * only trustworthy field on a `MessageEvent`; nothing inside `data` is trusted\n * for identity.\n *\n * `BigInt` survives structured clone, so amounts cross the boundary as exact\n * integers. Never stringify them for transport - a float round-trip is how\n * money goes missing.\n *\n * ## What the host must validate\n *\n * The host is the security boundary. Before signing anything it should check:\n *\n * - the transaction's `to` is a contract it expects (its own router address);\n * - `value` matches what the user was shown;\n * - `integratorFee.referrer` is the host's own address, if it configured one.\n *\n * A widget in an iframe is still third-party code. This contract makes it\n * *inspectable*, not trusted.\n */\n\nimport type {\n ProtocolAdapter,\n WidgetTransactionRequest,\n} from \"../adapters/protocol.js\";\nimport type { IntegratorConfig } from \"../config/integrator.js\";\nimport type { WidgetTheme } from \"../context/WidgetProvider.js\";\n\n/** Channel name on every message in this protocol. */\nexport const WIDGET_CHANNEL = \"latch-widget\";\n\n/** Version of the message contract. Bumped on any breaking change. */\nexport const WIDGET_PROTOCOL_VERSION = 1;\n\n/** Adapter methods the widget may invoke on the host. */\nexport type BridgeMethod = Extract<\n keyof ProtocolAdapter,\n | \"getAccount\"\n | \"listTokens\"\n | \"getToken\"\n | \"getBalance\"\n | \"listPools\"\n | \"getPoolState\"\n | \"getApprovalRequirements\"\n | \"buildApproval\"\n | \"quoteSwap\"\n | \"buildSwap\"\n | \"quoteAddLiquidity\"\n | \"buildAddLiquidity\"\n | \"listPositions\"\n | \"quoteRemoveLiquidity\"\n | \"buildRemoveLiquidity\"\n | \"listLaunches\"\n | \"getLaunch\"\n | \"getLaunchesForToken\"\n | \"sendTransaction\"\n | \"waitForTransaction\"\n>;\n\n/** Sent by the widget once it has mounted and is ready for `init`. */\nexport interface WidgetReadyMessage {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"ready\";\n}\n\n/** Sent by the host in response to `ready`. */\nexport interface HostInitMessage {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"init\";\n readonly widget: \"swap\" | \"liquidity\" | \"launch\";\n readonly integrator: IntegratorConfig | null;\n readonly theme: WidgetTheme;\n /** Chain metadata, minus anything unserialisable (no transport). */\n readonly chain: {\n readonly chainId: number;\n readonly name: string;\n readonly nativeCurrency: { name: string; symbol: string; decimals: number };\n readonly blockExplorerUrl?: string;\n };\n /** `true` when the host's adapter is a mock, so the widget can warn. */\n readonly isMock: boolean;\n}\n\n/** A remote adapter call, widget to host. */\nexport interface WidgetInvokeMessage {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"invoke\";\n readonly id: string;\n readonly method: BridgeMethod;\n readonly args: readonly unknown[];\n}\n\n/** The host's answer to an `invoke`. */\nexport type HostResultMessage =\n | {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"result\";\n readonly id: string;\n readonly ok: true;\n readonly value: unknown;\n }\n | {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"result\";\n readonly id: string;\n readonly ok: false;\n readonly error: { readonly name: string; readonly message: string };\n };\n\n/** Height report, so the host can size the iframe without scrollbars. */\nexport interface WidgetResizeMessage {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"resize\";\n readonly height: number;\n}\n\n/** Lifecycle notifications the host may log or act on. */\nexport interface WidgetEventMessage {\n readonly channel: typeof WIDGET_CHANNEL;\n readonly version: number;\n readonly type: \"event\";\n readonly name: \"quote\" | \"transaction-submitted\" | \"transaction-confirmed\" | \"error\";\n readonly payload: Record<string, unknown>;\n}\n\n/** Anything the widget sends. */\nexport type WidgetMessage =\n | WidgetReadyMessage\n | WidgetInvokeMessage\n | WidgetResizeMessage\n | WidgetEventMessage;\n\n/** Anything the host sends. */\nexport type HostMessage = HostInitMessage | HostResultMessage;\n\nfunction isEnvelope(data: unknown): data is { channel: string; version: number; type: string } {\n if (typeof data !== \"object\" || data === null) return false;\n const record = data as Record<string, unknown>;\n return (\n record[\"channel\"] === WIDGET_CHANNEL &&\n record[\"version\"] === WIDGET_PROTOCOL_VERSION &&\n typeof record[\"type\"] === \"string\"\n );\n}\n\n/** Options for {@link serveWidgetIframe}. */\nexport interface ServeWidgetIframeOptions {\n /** The iframe element the widget is running in. */\n readonly iframe: HTMLIFrameElement;\n /** Exact origin the iframe is served from. Never `\"*\"`. */\n readonly widgetOrigin: string;\n /** The adapter that answers the widget's requests. */\n readonly adapter: ProtocolAdapter;\n readonly widget: \"swap\" | \"liquidity\" | \"launch\";\n readonly integrator?: IntegratorConfig;\n readonly theme?: WidgetTheme;\n /**\n * Last-line inspection before a transaction is signed. Return `false` to\n * refuse. Use it to assert the fee recipient is you.\n */\n readonly approveTransaction?: (request: WidgetTransactionRequest) => boolean | Promise<boolean>;\n /** Called on every widget event, for analytics. */\n readonly onEvent?: (message: WidgetEventMessage) => void;\n /** Called when the widget reports its height. */\n readonly onResize?: (height: number) => void;\n}\n\n/**\n * Host side of the bridge: answers the widget's adapter calls.\n *\n * @returns a disposer that removes the listener.\n */\nexport function serveWidgetIframe(options: ServeWidgetIframeOptions): () => void {\n const { iframe, widgetOrigin, adapter } = options;\n\n if (widgetOrigin === \"*\" || widgetOrigin.trim() === \"\") {\n throw new Error(\n '[@latchprotocol/widgets] widgetOrigin must be an exact origin, never \"*\". ' +\n \"A wildcard origin lets any framed page impersonate the widget.\",\n );\n }\n\n const post = (message: HostMessage): void => {\n iframe.contentWindow?.postMessage(message, widgetOrigin);\n };\n\n const handler = async (event: MessageEvent<unknown>): Promise<void> => {\n if (event.origin !== widgetOrigin) return;\n if (event.source !== iframe.contentWindow) return;\n if (!isEnvelope(event.data)) return;\n const message = event.data as WidgetMessage;\n\n if (message.type === \"ready\") {\n post({\n channel: WIDGET_CHANNEL,\n version: WIDGET_PROTOCOL_VERSION,\n type: \"init\",\n widget: options.widget,\n integrator: options.integrator ?? null,\n theme: options.theme ?? \"system\",\n chain: {\n chainId: adapter.chain.chainId,\n name: adapter.chain.name,\n nativeCurrency: adapter.chain.nativeCurrency,\n ...(adapter.chain.blockExplorerUrl === undefined\n ? {}\n : { blockExplorerUrl: adapter.chain.blockExplorerUrl }),\n },\n isMock: adapter.isMock,\n });\n return;\n }\n\n if (message.type === \"resize\") {\n options.onResize?.(message.height);\n return;\n }\n\n if (message.type === \"event\") {\n options.onEvent?.(message);\n return;\n }\n\n if (message.type !== \"invoke\") return;\n\n try {\n if (message.method === \"sendTransaction\" && options.approveTransaction !== undefined) {\n const request = message.args[0] as WidgetTransactionRequest;\n const approved = await options.approveTransaction(request);\n if (!approved) {\n throw new Error(\"The host refused this transaction\");\n }\n }\n const method = adapter[message.method] as (...args: unknown[]) => Promise<unknown>;\n if (typeof method !== \"function\") {\n throw new Error(`Unknown bridge method: ${String(message.method)}`);\n }\n const value: unknown = await method.apply(adapter, [...message.args]);\n post({\n channel: WIDGET_CHANNEL,\n version: WIDGET_PROTOCOL_VERSION,\n type: \"result\",\n id: message.id,\n ok: true,\n value,\n });\n } catch (cause: unknown) {\n const error = cause instanceof Error ? cause : new Error(String(cause));\n post({\n channel: WIDGET_CHANNEL,\n version: WIDGET_PROTOCOL_VERSION,\n type: \"result\",\n id: message.id,\n ok: false,\n error: { name: error.name, message: error.message },\n });\n }\n };\n\n const listener = (event: MessageEvent<unknown>): void => {\n void handler(event);\n };\n\n window.addEventListener(\"message\", listener);\n return () => window.removeEventListener(\"message\", listener);\n}\n\n/** A pending remote call. */\ninterface PendingCall {\n resolve(value: unknown): void;\n reject(reason: Error): void;\n}\n\n/** Options for {@link createIframeBridgeAdapter}. */\nexport interface IframeBridgeOptions {\n /** Exact origin of the host page. */\n readonly hostOrigin: string;\n /** How long to wait for a reply before failing, in ms. */\n readonly timeoutMs?: number;\n}\n\n/**\n * Widget side of the bridge: a {@link ProtocolAdapter} that forwards every call\n * to the host page.\n *\n * Runs inside the iframe. Resolves once the host's `init` arrives, so a widget\n * never renders against a half-configured bridge.\n */\nexport async function createIframeBridgeAdapter(\n options: IframeBridgeOptions,\n): Promise<{ adapter: ProtocolAdapter; init: HostInitMessage; dispose(): void }> {\n const { hostOrigin } = options;\n const timeoutMs = options.timeoutMs ?? 60_000;\n\n if (hostOrigin === \"*\" || hostOrigin.trim() === \"\") {\n throw new Error('[@latchprotocol/widgets] hostOrigin must be an exact origin, never \"*\"');\n }\n\n const pending = new Map<string, PendingCall>();\n let counter = 0;\n let init: HostInitMessage | null = null;\n let resolveInit: ((message: HostInitMessage) => void) | null = null;\n\n const initPromise = new Promise<HostInitMessage>((resolve) => {\n resolveInit = resolve;\n });\n\n const listener = (event: MessageEvent<unknown>): void => {\n if (event.origin !== hostOrigin) return;\n if (!isEnvelope(event.data)) return;\n const message = event.data as HostMessage;\n\n if (message.type === \"init\") {\n init = message;\n resolveInit?.(message);\n return;\n }\n if (message.type !== \"result\") return;\n\n const call = pending.get(message.id);\n if (call === undefined) return;\n pending.delete(message.id);\n if (message.ok) call.resolve(message.value);\n else {\n const error = new Error(message.error.message);\n error.name = message.error.name;\n call.reject(error);\n }\n };\n\n window.addEventListener(\"message\", listener);\n\n const send = (message: WidgetMessage): void => {\n window.parent.postMessage(message, hostOrigin);\n };\n\n const invoke = (method: BridgeMethod, args: readonly unknown[]): Promise<unknown> => {\n counter += 1;\n const id = `${Date.now().toString(36)}-${counter}`;\n return new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n pending.delete(id);\n reject(new Error(`[@latchprotocol/widgets] host did not answer ${method} in ${timeoutMs}ms`));\n }, timeoutMs);\n pending.set(id, {\n resolve: (value) => {\n clearTimeout(timer);\n resolve(value);\n },\n reject: (reason) => {\n clearTimeout(timer);\n reject(reason);\n },\n });\n send({\n channel: WIDGET_CHANNEL,\n version: WIDGET_PROTOCOL_VERSION,\n type: \"invoke\",\n id,\n method,\n args,\n });\n });\n };\n\n send({ channel: WIDGET_CHANNEL, version: WIDGET_PROTOCOL_VERSION, type: \"ready\" });\n const resolved = await initPromise;\n\n const call =\n (method: BridgeMethod) =>\n (...args: unknown[]): Promise<never> =>\n invoke(method, args) as Promise<never>;\n\n const adapter: ProtocolAdapter = {\n kind: \"iframe-bridge\",\n isMock: resolved.isMock,\n chain: {\n chainId: resolved.chain.chainId,\n name: resolved.chain.name,\n nativeCurrency: resolved.chain.nativeCurrency,\n // The bridge deliberately carries no addresses: the widget never builds\n // calldata itself, the host does.\n contracts: { vault: \"0x0000000000000000000000000000000000000000\" },\n ...(resolved.chain.blockExplorerUrl === undefined\n ? {}\n : { blockExplorerUrl: resolved.chain.blockExplorerUrl }),\n },\n getAccount: call(\"getAccount\"),\n listTokens: call(\"listTokens\"),\n getToken: call(\"getToken\"),\n getBalance: call(\"getBalance\"),\n listPools: call(\"listPools\"),\n getPoolState: call(\"getPoolState\"),\n getApprovalRequirements: call(\"getApprovalRequirements\"),\n buildApproval: call(\"buildApproval\"),\n quoteSwap: call(\"quoteSwap\"),\n buildSwap: call(\"buildSwap\"),\n quoteAddLiquidity: call(\"quoteAddLiquidity\"),\n buildAddLiquidity: call(\"buildAddLiquidity\"),\n listPositions: call(\"listPositions\"),\n quoteRemoveLiquidity: call(\"quoteRemoveLiquidity\"),\n buildRemoveLiquidity: call(\"buildRemoveLiquidity\"),\n listLaunches: call(\"listLaunches\"),\n getLaunch: call(\"getLaunch\"),\n getLaunchesForToken: call(\"getLaunchesForToken\"),\n sendTransaction: call(\"sendTransaction\"),\n waitForTransaction: call(\"waitForTransaction\"),\n };\n\n return {\n adapter,\n init: resolved,\n dispose: () => {\n window.removeEventListener(\"message\", listener);\n pending.clear();\n init = null;\n void init;\n },\n };\n}\n\n/** Reports the widget's height to the host, so the iframe can be sized to it. */\nexport function reportWidgetHeight(hostOrigin: string, element: HTMLElement): () => void {\n const send = (): void => {\n const message: WidgetResizeMessage = {\n channel: WIDGET_CHANNEL,\n version: WIDGET_PROTOCOL_VERSION,\n type: \"resize\",\n height: Math.ceil(element.getBoundingClientRect().height),\n };\n window.parent.postMessage(message, hostOrigin);\n };\n send();\n if (typeof ResizeObserver === \"undefined\") return () => undefined;\n const observer = new ResizeObserver(send);\n observer.observe(element);\n return () => observer.disconnect();\n}\n","// SPDX-License-Identifier: MIT\n/**\n * `<latch-lock-badge>`: the lock badge for any web page, with no framework.\n *\n * ```html\n * <script src=\"https://<latch site>/embed/latch-embed.js\" defer></script>\n * <latch-lock-badge chain=\"4663\" pool=\"0x…\"></latch-lock-badge>\n * <latch-lock-badge chain=\"4663\" token=\"0x…\" site=\"https://<latch site>\"></latch-lock-badge>\n * ```\n *\n * Attributes:\n * chain chain id (required); must be a chain in the SDK's address book\n * pool a pool id (bytes32), or\n * token a token address\n * pool-type `cl` (default) or `bin`\n * rpc an RPC URL to read through instead of the chain's public RPCs\n * site the Latch site origin; with it the badge links to its public\n * lock page (`/locks/pool/<id>?net=<chain>`); without it, no link\n * theme `light` | `dark` | `system` (default)\n * refresh seconds between re-reads (default 60, 0 = never)\n *\n * It reads the chain directly, through the MIT SDK, with the same readers as\n * `LocksBadge`, and renders plain DOM into a shadow root: no React, no wallet,\n * no writes. The words are only what was read (see `../locks/embedModel.ts`).\n */\n\nimport { createClient, http, isAddress, type Address, type Hex, type PublicClient } from \"viem\";\nimport { getBlock, getBlockNumber, getLogs, readContract } from \"viem/actions\";\nimport { getDeployment } from \"@latchprotocol/sdk/deployments\";\nimport { latchTransport } from \"@latchprotocol/sdk\";\n\nimport { fetchPoolLocks, fetchTokenLocks, type PoolLocksData, type TokenLocksData } from \"../locks/fetch.js\";\nimport { poolEmbedView, tokenEmbedView } from \"../locks/embedModel.js\";\nimport { advanceChainNow, formatCountdown, lockPageUrl, type LocksBadgeView } from \"../locks/model.js\";\nimport { scanClLpLockerTokenIds } from \"../locks/scan.js\";\nimport { WIDGET_CSS } from \"../styles/css.js\";\n\nexport const LOCK_BADGE_TAG = \"latch-lock-badge\";\n\n/* Latch chrome in the brand kit's colours and type: on dark grounds Latch Blue\n and Success (\"locked\"); on light grounds Deep Blue and the widget's darker\n green, which keep 4.5:1 for text. IBM Plex Sans / Mono first, then the host's\n own stack when Plex is not loaded. A host overrides with --latch-brand-*. */\nconst HOST_CSS = `\n:host { display: inline-block; max-width: 100%; vertical-align: middle; }\n.latch-embed-badge[data-latch-theme] {\n --latch-accent: var(--latch-brand-accent, #0A63E0);\n --latch-font: var(--latch-brand-font, \"IBM Plex Sans\", system-ui, -apple-system, \"Segoe UI\", sans-serif);\n --latch-font-mono: var(--latch-brand-font-mono, \"IBM Plex Mono\", ui-monospace, monospace);\n}\n.latch-embed-badge[data-latch-theme=\"dark\"] { --latch-accent: var(--latch-brand-accent, #2B8BFF); --latch-success: var(--latch-brand-success, #5FD39A); }\n@media (prefers-color-scheme: dark) {\n .latch-embed-badge[data-latch-theme=\"system\"] { --latch-accent: var(--latch-brand-accent, #2B8BFF); --latch-success: var(--latch-brand-success, #5FD39A); }\n}\n:host([hidden]) { display: none; }\n.latch-embed-badge { gap: 4px; }\n.latch-embed-badge__retry { font: inherit; font-size: 11px; background: none; border: 0; padding: 0; color: var(--latch-accent); cursor: pointer; text-decoration: underline; }\n`;\n\nconst ElementBase: typeof HTMLElement = typeof HTMLElement === \"undefined\" ? (class {} as unknown as typeof HTMLElement) : HTMLElement;\n\n/** CL LP-locker ids per chain, scanned once per page load and shared by every badge. */\nconst lpIdCache = new Map<string, Promise<bigint[]>>();\n\ntype Parsed =\n | { readonly ok: false; readonly message: string }\n | {\n readonly ok: true;\n readonly chainId: number;\n readonly target: { readonly kind: \"pool\"; readonly poolId: Hex; readonly poolType: \"cl\" | \"bin\" } | { readonly kind: \"token\"; readonly token: Address };\n };\n\n/** Pure: the element's attributes, validated. */\nexport function parseLockBadgeAttributes(get: (name: string) => string | null): Parsed {\n const chain = Number(get(\"chain\") ?? \"\");\n if (!Number.isInteger(chain) || chain <= 0) return { ok: false, message: \"Set the chain attribute to a chain id, e.g. chain=\\\"4663\\\".\" };\n const pool = get(\"pool\");\n const token = get(\"token\");\n if (pool !== null && pool !== \"\") {\n if (!/^0x[0-9a-fA-F]{64}$/.test(pool)) return { ok: false, message: \"The pool attribute is not a 32-byte pool id.\" };\n const t = (get(\"pool-type\") ?? \"cl\").toLowerCase();\n return { ok: true, chainId: chain, target: { kind: \"pool\", poolId: pool as Hex, poolType: t === \"bin\" ? \"bin\" : \"cl\" } };\n }\n if (token !== null && token !== \"\") {\n if (!isAddress(token, { strict: false })) return { ok: false, message: \"The token attribute is not an address.\" };\n return { ok: true, chainId: chain, target: { kind: \"token\", token: token as Address } };\n }\n return { ok: false, message: \"Set a pool or a token attribute.\" };\n}\n\ntype State =\n | { readonly k: \"message\"; readonly tone: \"none\" | \"error\"; readonly text: string; readonly retry: boolean }\n | { readonly k: \"loading\" }\n | { readonly k: \"ready\"; readonly view: LocksBadgeView; readonly chainNow: bigint; readonly readAtMs: number; readonly href: string | null };\n\nexport class LatchLockBadgeElement extends ElementBase {\n static get observedAttributes(): readonly string[] {\n return [\"chain\", \"pool\", \"token\", \"pool-type\", \"rpc\", \"site\", \"theme\", \"refresh\"];\n }\n\n #shadow: ShadowRoot | null = null;\n #root: HTMLDivElement | null = null;\n #state: State = { k: \"loading\" };\n #read = 0;\n #refreshTimer: ReturnType<typeof setInterval> | null = null;\n #tickTimer: ReturnType<typeof setInterval> | null = null;\n #client: { key: string; client: PublicClient } | null = null;\n\n connectedCallback(): void {\n if (this.#shadow === null) {\n this.#shadow = this.attachShadow({ mode: \"open\" });\n const style = document.createElement(\"style\");\n style.textContent = `${WIDGET_CSS}\\n${HOST_CSS}`;\n this.#shadow.appendChild(style);\n this.#root = document.createElement(\"div\");\n this.#shadow.appendChild(this.#root);\n }\n this.#start();\n }\n\n disconnectedCallback(): void {\n this.#stopTimers();\n this.#read += 1;\n }\n\n attributeChangedCallback(): void {\n if (this.#shadow !== null && this.isConnected) this.#start();\n }\n\n #stopTimers(): void {\n if (this.#refreshTimer !== null) clearInterval(this.#refreshTimer);\n if (this.#tickTimer !== null) clearInterval(this.#tickTimer);\n this.#refreshTimer = null;\n this.#tickTimer = null;\n }\n\n #start(): void {\n this.#stopTimers();\n this.#state = { k: \"loading\" };\n this.#render();\n void this.#load();\n const refresh = Number(this.getAttribute(\"refresh\") ?? \"60\");\n if (Number.isFinite(refresh) && refresh > 0) this.#refreshTimer = setInterval(() => void this.#load(), Math.max(15, refresh) * 1000);\n this.#tickTimer = setInterval(() => {\n if (this.#state.k === \"ready\" && this.#state.view.countdownTo !== null) this.#render();\n }, 1000);\n }\n\n #clientFor(chainId: number): PublicClient {\n const rpc = this.getAttribute(\"rpc\");\n const key = `${chainId}|${rpc ?? \"\"}`;\n if (this.#client?.key === key) return this.#client.client;\n const transport = rpc !== null && rpc.trim() !== \"\" ? http(rpc.trim()) : latchTransport(chainId);\n /* Only the four actions the lock readers call: a full public client would\n carry signature verification and every other action into the bundle. */\n const base = createClient({ transport });\n const client = {\n ...base,\n readContract: (args: unknown) => readContract(base, args as never),\n getBlock: (args?: unknown) => getBlock(base, args as never),\n getBlockNumber: (args?: unknown) => getBlockNumber(base, args as never),\n getLogs: (args?: unknown) => getLogs(base, args as never),\n } as unknown as PublicClient;\n this.#client = { key, client };\n return client;\n }\n\n async #load(): Promise<void> {\n const id = ++this.#read;\n const parsed = parseLockBadgeAttributes((n) => this.getAttribute(n));\n if (!parsed.ok) return this.#set(id, { k: \"message\", tone: \"error\", text: parsed.message, retry: false });\n const d = getDeployment(parsed.chainId);\n if (d === undefined) return this.#set(id, { k: \"message\", tone: \"none\", text: `Latch does not support chain ${parsed.chainId}.`, retry: false });\n const native = { symbol: d.nativeCurrency.symbol, decimals: d.nativeCurrency.decimals };\n const clLocker = d.launchpadV2.clLPLocker;\n const binLocker = d.launchpadV2.binLPLocker;\n const t = parsed.target;\n const hasLocker = t.kind === \"pool\" ? (t.poolType === \"bin\" ? binLocker !== null : d.positionLock !== null || clLocker !== null) : d.tokenLock !== null || clLocker !== null || binLocker !== null;\n if (!hasLocker) return this.#set(id, { k: \"message\", tone: \"none\", text: `Latch locks are coming soon on ${d.name}.`, retry: false });\n try {\n const client = this.#clientFor(parsed.chainId);\n let ids: bigint[] = [];\n if (clLocker !== null && !(t.kind === \"pool\" && t.poolType === \"bin\")) {\n const k = `${parsed.chainId}|${clLocker.toLowerCase()}|${this.getAttribute(\"rpc\") ?? \"\"}`;\n let p = lpIdCache.get(k);\n if (p === undefined) {\n p = scanClLpLockerTokenIds(client, clLocker, { fromBlock: d.deployedAtBlock });\n lpIdCache.set(k, p);\n p.catch(() => lpIdCache.delete(k));\n }\n ids = await p;\n }\n const lp = {\n ...(clLocker !== null ? { lpLocker: clLocker, lpLockerTokenIds: ids } : {}),\n ...(binLocker !== null ? { binLpLocker: binLocker } : {}),\n };\n let data: PoolLocksData | TokenLocksData;\n let view: LocksBadgeView;\n if (t.kind === \"pool\") {\n const pd = await fetchPoolLocks(client, d.positionLock, t.poolId, { native, lp: { ...lp, poolType: t.poolType } });\n data = pd;\n view = poolEmbedView(pd);\n } else {\n const td = await fetchTokenLocks(client, d.tokenLock, t.token, { native, lp });\n data = td;\n view = tokenEmbedView(td);\n }\n const site = this.getAttribute(\"site\");\n const href =\n site === null || site.trim() === \"\"\n ? null\n : lockPageUrl(site.trim(), t.kind === \"pool\" ? { kind: \"pool\", poolId: t.poolId } : { kind: \"token\", token: t.token }, { pathBase: \"/locks\", query: `net=${d.key}` });\n this.#set(id, { k: \"ready\", view, chainNow: data.chainNow, readAtMs: data.readAtMs, href });\n } catch {\n /* A failed refresh keeps the last good read on screen. */\n if (this.#state.k === \"ready\") return;\n this.#set(id, { k: \"message\", tone: \"error\", text: \"Locks could not be read: the chain did not answer.\", retry: true });\n }\n }\n\n #set(id: number, state: State): void {\n if (id !== this.#read) return;\n this.#state = state;\n this.#render();\n }\n\n #render(): void {\n const root = this.#root;\n if (root === null) return;\n const theme = this.getAttribute(\"theme\");\n const s = this.#state;\n const box = document.createElement(\"div\");\n box.className = \"latch-widget latch-locks latch-locks--badge latch-embed-badge\";\n box.dataset[\"latchTheme\"] = theme === \"light\" || theme === \"dark\" ? theme : \"system\";\n const line = (cls: string, text: string, tone?: string): HTMLParagraphElement => {\n const p = document.createElement(\"p\");\n p.className = cls;\n if (tone !== undefined) {\n const dot = document.createElement(\"span\");\n dot.className = `latch-locks__dot latch-locks__dot--${tone}`;\n dot.setAttribute(\"aria-hidden\", \"true\");\n p.appendChild(dot);\n }\n const span = document.createElement(\"span\");\n span.textContent = text;\n p.appendChild(span);\n return p;\n };\n if (s.k === \"loading\") {\n box.appendChild(line(\"latch-locks__headline latch-locks__headline--muted\", \"Reading locks…\"));\n box.setAttribute(\"role\", \"status\");\n } else if (s.k === \"message\") {\n const p = line(`latch-locks__headline${s.tone === \"error\" ? \" latch-locks__headline--error\" : \"\"}`, s.text, s.tone === \"none\" ? \"none\" : undefined);\n box.appendChild(p);\n if (s.retry) {\n const b = document.createElement(\"button\");\n b.type = \"button\";\n b.className = \"latch-embed-badge__retry\";\n b.textContent = \"Retry\";\n b.addEventListener(\"click\", () => this.#start());\n box.appendChild(b);\n }\n } else {\n const headline = line(\"latch-locks__headline\", s.view.headline, s.view.tone);\n headline.title = s.view.detail ?? \"\";\n box.dataset[\"tone\"] = s.view.tone;\n box.appendChild(headline);\n if (s.view.countdownTo !== null) {\n const now = advanceChainNow(s.chainNow, s.readAtMs, Date.now());\n const p = document.createElement(\"p\");\n p.className = \"latch-locks__countdown\";\n const timer = document.createElement(\"span\");\n timer.className = \"latch-locks__timer\";\n timer.textContent = formatCountdown(s.view.countdownTo - now);\n p.append(timer, ` to ${s.view.countdownLabel ?? \"the next unlock\"}`);\n box.appendChild(p);\n }\n }\n const brand = document.createElement(\"p\");\n brand.className = \"latch-brand\";\n const site = this.getAttribute(\"site\");\n if (site !== null && site.trim() !== \"\") {\n /* The brand kit's mark, as shipped, from the Latch site: never redrawn, 24 px (the kit's\n minimum WIDTH here; the kit states 24px tall as the floor and this clears it).\n\n THE VECTOR, AND THE RIGHT ONE FOR THE GROUND. This pointed at `latch-mark-blue.png`,\n which no longer exists — the kit that replaced it drops the flat single-blue mark, so\n every third-party page embedding this badge was 404ing the image. The retired mark was\n one flat blue that read on either ground; the current one is TWO-TONE, so it needs the\n `-onlight` master on a light ground or the dark half disappears.\n\n The element already resolves its own theme (see `data-latch-theme` above), including\n `system` via matchMedia, so this reads the same value rather than guessing.\n\n INTRINSIC SIZE IS THE REAL viewBox (665 x 765), not the display size. The old code set\n 24 x 30, which is 0.800 against the master's 0.869 — a ~9% horizontal squash the moment\n the stylesheet had not loaded, against the kit's own \"do not stretch\" rule. The CSS\n (`.latch-brand__mark { width: 24px; height: auto }`) decides how big it draws; these\n attributes only reserve the correct shape. */\n const mark = document.createElement(\"img\");\n mark.className = \"latch-brand__mark\";\n /* `system` is the DEFAULT and the common case for an embed — it runs inside somebody else's\n page — so it must be resolved, not lumped in with dark. Treating it as dark would show\n the dark-ground mark on every light-themed host site. */\n const declared = box.dataset[\"latchTheme\"];\n const light =\n declared === \"light\" ||\n (declared === \"system\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-color-scheme: light)\").matches);\n const ground = light ? \"-onlight\" : \"\";\n mark.src = `${site.trim().replace(/\\/+$/, \"\")}/brand/masters/latch-mark${ground}.svg`;\n mark.width = 665;\n mark.height = 765;\n mark.alt = \"Latch\";\n brand.appendChild(mark);\n }\n const src = document.createElement(\"span\");\n src.textContent = \"Read from chain\";\n brand.appendChild(src);\n const spacer = document.createElement(\"span\");\n spacer.className = \"latch-brand__spacer\";\n brand.appendChild(spacer);\n if (s.k === \"ready\" && s.href !== null) {\n const a = document.createElement(\"a\");\n a.className = \"latch-locks__link\";\n a.href = s.href;\n a.target = \"_blank\";\n a.rel = \"noopener\";\n a.textContent = \"Lock details →\";\n brand.appendChild(a);\n }\n box.appendChild(brand);\n root.replaceChildren(box);\n }\n}\n\n/** Registers `<latch-lock-badge>`. Safe to call twice. */\nexport function defineLatchLockBadge(): void {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(LOCK_BADGE_TAG) === undefined) customElements.define(LOCK_BADGE_TAG, LatchLockBadgeElement);\n}\n"],"names":["COMMON_ATTRIBUTES","parseJsonAttribute","value","label","cause","ElementBase","LatchWidgetElement","#root","#shadow","#adapter","#error","#render","style","WIDGET_CSS","mount","createRoot","root","title","#resolveAdapter","adapter","createElement","integrator","theme","slippageRaw","WidgetProvider","LatchSwapWidgetElement","SwapWidget","tokenIn","tokenOut","variant","LatchLiquidityWidgetElement","LiquidityWidget","poolId","mode","LatchLaunchWidgetElement","LaunchWidget","WIDGET_TAG_NAMES","defineLatchWidgets","registry","tag","constructor","WIDGET_CHANNEL","WIDGET_PROTOCOL_VERSION","isEnvelope","data","record","serveWidgetIframe","options","iframe","widgetOrigin","post","message","handler","event","request","method","error","listener","createIframeBridgeAdapter","hostOrigin","timeoutMs","pending","counter","resolveInit","initPromise","resolve","call","send","invoke","args","id","reject","timer","reason","resolved","reportWidgetHeight","element","observer","LOCK_BADGE_TAG","HOST_CSS","lpIdCache","parseLockBadgeAttributes","get","chain","pool","token","t","isAddress","LatchLockBadgeElement","#state","#read","#refreshTimer","#tickTimer","#client","#start","#stopTimers","#load","refresh","#clientFor","chainId","rpc","key","transport","http","latchTransport","base","createClient","client","readContract","getBlock","getBlockNumber","getLogs","parsed","n","#set","d","getDeployment","native","clLocker","binLocker","ids","k","p","scanClLpLockerTokenIds","lp","view","pd","fetchPoolLocks","poolEmbedView","td","fetchTokenLocks","tokenEmbedView","site","href","lockPageUrl","state","s","box","line","cls","text","tone","dot","span","b","headline","now","advanceChainNow","formatCountdown","brand","mark","declared","ground","src","spacer","a","defineLatchLockBadge"],"mappings":";;;;;;;;;AAkCA,MAAMA,IAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAASC,EAAsBC,GAAsBC,GAAyB;AAC5E,MAAID,MAAU,QAAQA,EAAM,KAAA,MAAW,GAAI,QAAO;AAClD,MAAI;AACF,WAAO,KAAK,MAAMA,CAAK;AAAA,EACzB,SAASE,GAAgB;AACvB,UAAM,IAAI;AAAA,MACR,gCAAgCD,CAAK,iCAAiC,OAAOC,CAAK,CAAC;AAAA,IAAA;AAAA,EAEvF;AACF;AAYA,MAAMC,IACJ,OAAO,cAAgB,MAClB,MAAM;AAAC,IACR;AAGN,MAAeC,UAA2BD,EAAY;AAAA,EACpDE,KAAqB;AAAA,EACrBC,KAA6B;AAAA,EAC7BC,KAAmC;AAAA,EACnCC,KAAwB;AAAA;AAAA,EAGxB,WAAW,qBAAwC;AACjD,WAAOV;AAAA,EACT;AAAA;AAAA,EAGA,IAAI,UAAkC;AACpC,WAAO,KAAKS;AAAA,EACd;AAAA,EAEA,IAAI,QAAQP,GAA+B;AACzC,SAAKO,KAAWP,GAChB,KAAKS,GAAA;AAAA,E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EAAO,QAAQ,QAAQ,EAAE,CAAC,4BAA4BoB,CAAM,QAC/EF,EAAK,QAAQ,KACbA,EAAK,SAAS,KACdA,EAAK,MAAM,SACXD,EAAM,YAAYC,CAAI;AAAA,IACxB;AACA,UAAMG,IAAM,SAAS,cAAc,MAAM;AACzC,IAAAA,EAAI,cAAc,mBAClBJ,EAAM,YAAYI,CAAG;AACrB,UAAMC,IAAS,SAAS,cAAc,MAAM;AAG5C,QAFAA,EAAO,YAAY,uBACnBL,EAAM,YAAYK,CAAM,GACpBlB,EAAE,MAAM,WAAWA,EAAE,SAAS,MAAM;AACtC,YAAMmB,IAAI,SAAS,cAAc,GAAG;AACpC,MAAAA,EAAE,YAAY,qBACdA,EAAE,OAAOnB,EAAE,MACXmB,EAAE,SAAS,UACXA,EAAE,MAAM,YACRA,EAAE,cAAc,kBAChBN,EAAM,YAAYM,CAAC;AAAA,IACrB;AACA,IAAAlB,EAAI,YAAYY,CAAK,GACrBrI,EAAK,gBAAgByH,CAAG;AAAA,EAC1B;AACF;AAGO,SAASmB,KAA6B;AAC3C,EAAI,OAAO,iBAAmB,OAC1B,eAAe,IAAI9E,CAAc,MAAM,UAAW,eAAe,OAAOA,GAAgBU,EAAqB;AACnH;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless entry point: logic without markup.
|
|
3
|
+
*
|
|
4
|
+
* Import from here when you are building your own UI. It carries the config
|
|
5
|
+
* validation, the quote math, the chain adapters, the call-path encoders and
|
|
6
|
+
* the React controllers - and no components, no stylesheet, and no
|
|
7
|
+
* `react-dom/client`.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import {
|
|
11
|
+
* WidgetProvider,
|
|
12
|
+
* useSwapQuote,
|
|
13
|
+
* useSwapExecute,
|
|
14
|
+
* validateIntegratorConfig,
|
|
15
|
+
* } from "@latchprotocol/widgets/headless";
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The one thing you do not get to skip by going headless is fee validation:
|
|
19
|
+
* `WidgetProvider` validates the integrator config, and the call-path builders
|
|
20
|
+
* refuse a `ResolvedIntegratorConfig` that did not come from it.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
export * from "./config/integrator.js";
|
|
25
|
+
export * from "./config/chain.js";
|
|
26
|
+
export * from "./core/math.js";
|
|
27
|
+
export * from "./core/format.js";
|
|
28
|
+
export * from "./core/clMath.js";
|
|
29
|
+
export * from "./core/errors.js";
|
|
30
|
+
export * from "./core/pool.js";
|
|
31
|
+
export * from "./core/tokenLists.js";
|
|
32
|
+
export * from "./core/liquidityGuards.js";
|
|
33
|
+
export * from "./core/liquidityRefresh.js";
|
|
34
|
+
export { buildUniformBinDistribution } from "./adapters/binDistribution.js";
|
|
35
|
+
export * from "./adapters/protocol.js";
|
|
36
|
+
export * from "./adapters/sale.js";
|
|
37
|
+
export { createViemAdapter, type ViemAdapterOptions, type ViemAdapterOverrides, type WidgetWallet, } from "./adapters/viem.js";
|
|
38
|
+
export * from "./callpath/constants.js";
|
|
39
|
+
export * from "./callpath/plan.js";
|
|
40
|
+
export * from "./callpath/swap.js";
|
|
41
|
+
export * from "./callpath/liquidity.js";
|
|
42
|
+
export * from "./callpath/launch.js";
|
|
43
|
+
export * from "./context/WidgetProvider.js";
|
|
44
|
+
export * from "./hooks/useAsyncResource.js";
|
|
45
|
+
export * from "./hooks/useSwapQuote.js";
|
|
46
|
+
export * from "./hooks/useSwapExecute.js";
|
|
47
|
+
export * from "./hooks/useLiquidity.js";
|
|
48
|
+
export * from "./hooks/useLaunch.js";
|
|
49
|
+
export * from "./hooks/useTokens.js";
|
|
50
|
+
export * from "./hooks/useTokenLists.js";
|
|
51
|
+
export * from "./hooks/useLocks.js";
|
|
52
|
+
export * from "./locks/model.js";
|
|
53
|
+
export * from "./locks/embedModel.js";
|
|
54
|
+
export * from "./locks/scan.js";
|
|
55
|
+
export * from "./trust/model.js";
|
|
56
|
+
export * from "./hooks/useTokenTrust.js";
|
|
57
|
+
export * from "./locker/model.js";
|
|
58
|
+
export * from "./hooks/useLocker.js";
|
|
59
|
+
export * from "./components/swap/state.js";
|
|
60
|
+
//# sourceMappingURL=headless.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless.d.ts","sourceRoot":"","sources":["../src/headless.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAElC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
package/dist/headless.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { A as e, a as o, b as t, B as r, c as i, d as n, C as u, e as c, f as l, D as b, g as d, E as A, H as p, I as T, h as L, i as S, L as E, M as I, j as m, k as _, l as k, m as C, n as P, o as B, p as N, N as g, q as f, r as O, O as R, P as h, s as D, t as F, u as U, v as w, Q as y, S as M, T as v, U as x, w as V, W as q, x as G, y as K, Z as W, z as H, F as X, G as Q, J as z, K as j, R as Y, V as Z, X as J, Y as $, _ as aa, $ as sa, a0 as ea, a1 as oa, a2 as ta, a3 as ra, a4 as ia, a5 as na, a6 as ua, a7 as ca, a8 as la, a9 as ba, aa as da, ab as Aa, ac as pa, ad as Ta, ae as La, af as Sa, ag as Ea, ah as Ia, ai as ma, aj as _a, ak as ka, al as Ca, am as Pa, an as Ba, ao as Na, ap as ga, aq as fa, ar as Oa, as as Ra, at as ha, au as Da, av as Fa, aw as Ua, ax as wa, ay as ya, az as Ma, aA as va, aB as xa, aC as Va, aD as qa, aE as Ga, aF as Ka, aG as Wa, aH as Ha, aI as Xa, aJ as Qa, aK as za, aL as ja, aM as Ya, aN as Za, aO as Ja, aP as $a, aQ as as, aR as ss, aS as es, aT as os, aU as ts, aV as rs, aW as is, aX as ns, aY as us, aZ as cs, a_ as ls, a$ as bs, b0 as ds, b1 as As, b2 as ps, b3 as Ts, b4 as Ls, b5 as Ss, b6 as Es, b7 as Is, b8 as ms, b9 as _s, ba as ks, bb as Cs, bc as Ps, bd as Bs, be as Ns, bf as gs, bg as fs, bh as Os, bi as Rs, bj as hs, bk as Ds, bl as Fs, bm as Us, bn as ws, bo as ys, bp as Ms, bq as vs, br as xs, bs as Vs, bt as qs, bu as Gs, bv as Ks, bw as Ws, bx as Hs, by as Xs, bz as Qs, bA as zs, bB as js, bC as Ys, bD as Zs, bE as Js, bF as $s, bG as ae, bH as se, bI as ee, bJ as oe, bK as te, bL as re, bM as ie, bN as ne, bO as ue, bP as ce, bQ as le, bR as be, bS as de, bT as Ae, bU as pe, bV as Te, bW as Le, bX as Se, bY as Ee, bZ as Ie, b_ as me } from "./chunks/scan-Dhu7f4Nl.js";
|
|
2
|
+
import { N as ke, P as Ce, T as Pe, a as Be, b as Ne, c as ge, d as fe, e as Oe, f as Re, g as he, h as De, i as Fe, l as Ue, j as we, p as ye, k as Me, m as ve, n as xe, o as Ve, q as qe, s as Ge, t as Ke, r as We, u as He, v as Xe, w as Qe, x as ze, y as je, z as Ye, A as Ze, B as Je, C as $e, D as ao } from "./chunks/useLocker-D1c_NTk-.js";
|
|
3
|
+
import { LAUNCH_GUARD_HOOK_ABI as eo, LAUNCH_GUARD_HOOK_BLOCK_ABI as oo, poolKeyToTuple as to } from "@latchprotocol/sdk";
|
|
4
|
+
export {
|
|
5
|
+
e as ACTIONS,
|
|
6
|
+
o as ADDRESS_THIS,
|
|
7
|
+
t as ActionPlan,
|
|
8
|
+
r as BIN_DISTRIBUTION_SCALE,
|
|
9
|
+
i as BPS,
|
|
10
|
+
n as BPS_DENOMINATOR,
|
|
11
|
+
u as COMMANDS,
|
|
12
|
+
c as CONTRACT_BALANCE,
|
|
13
|
+
l as ChainConfigError,
|
|
14
|
+
b as DEFAULT_PORTIONS,
|
|
15
|
+
d as DEFAULT_SLIPPAGE_BPS,
|
|
16
|
+
A as ERC20_ABI,
|
|
17
|
+
p as HIGH_PRICE_IMPACT_BPS,
|
|
18
|
+
T as INITIAL_SWAP_STATE,
|
|
19
|
+
L as InsufficientBalanceError,
|
|
20
|
+
S as IntegratorConfigError,
|
|
21
|
+
E as LAUNCH_FEE_DENOMINATOR,
|
|
22
|
+
eo as LAUNCH_GUARD_HOOK_ABI,
|
|
23
|
+
oo as LAUNCH_GUARD_HOOK_BLOCK_ABI,
|
|
24
|
+
I as MAX_INTEGRATOR_FEE_BPS,
|
|
25
|
+
m as MAX_SLIPPAGE_BPS,
|
|
26
|
+
_ as MAX_TICK,
|
|
27
|
+
k as MAX_UINT160,
|
|
28
|
+
C as MAX_UINT256,
|
|
29
|
+
P as MAX_UINT48,
|
|
30
|
+
B as MIN_TICK,
|
|
31
|
+
N as MSG_SENDER,
|
|
32
|
+
g as NATIVE_SENTINEL,
|
|
33
|
+
f as NO_INTEGRATOR_FEE,
|
|
34
|
+
O as NoRouteError,
|
|
35
|
+
ke as NoSaleAdapterError,
|
|
36
|
+
R as OPEN_DELTA,
|
|
37
|
+
h as PERMIT2_ABI,
|
|
38
|
+
D as PIPS,
|
|
39
|
+
F as POOL_KEY_COMPONENTS,
|
|
40
|
+
Ce as POSITION_ACTION_LABEL,
|
|
41
|
+
U as POSITION_MANAGER_ABI,
|
|
42
|
+
w as POSITION_STATUS_LABEL,
|
|
43
|
+
y as Q96,
|
|
44
|
+
M as SEVERE_PRICE_IMPACT_BPS,
|
|
45
|
+
Pe as TOKEN_ACTION_LABEL,
|
|
46
|
+
v as TOKEN_STATUS_LABEL,
|
|
47
|
+
Be as TransactionRevertedError,
|
|
48
|
+
x as UNIVERSAL_ROUTER_ABI,
|
|
49
|
+
V as UnsupportedOperationError,
|
|
50
|
+
q as WalletNotConnectedError,
|
|
51
|
+
G as WidgetContext,
|
|
52
|
+
K as WidgetProvider,
|
|
53
|
+
W as ZERO_ADDRESS,
|
|
54
|
+
H as adjustRange,
|
|
55
|
+
X as advanceChainNow,
|
|
56
|
+
Q as amountsForLiquidity,
|
|
57
|
+
z as assertTickMathSelfConsistent,
|
|
58
|
+
j as assertValidChainConfig,
|
|
59
|
+
Y as balancePortion,
|
|
60
|
+
Z as binPoolBadgeView,
|
|
61
|
+
J as binShareAmounts,
|
|
62
|
+
$ as binShareBar,
|
|
63
|
+
aa as binStepOf,
|
|
64
|
+
sa as binTokenId,
|
|
65
|
+
ea as blockWindows,
|
|
66
|
+
Ne as buildBinAddCall,
|
|
67
|
+
ge as buildBinRemoveCall,
|
|
68
|
+
fe as buildCLDecreaseCall,
|
|
69
|
+
Oe as buildCLMintCall,
|
|
70
|
+
oa as buildLaunchBuyCall,
|
|
71
|
+
ta as buildLaunchView,
|
|
72
|
+
ra as buildQuoteBreakdown,
|
|
73
|
+
ia as buildSwapCall,
|
|
74
|
+
na as buildSwapPlan,
|
|
75
|
+
ua as buildSwapQuoteView,
|
|
76
|
+
Re as buildUniformBinDistribution,
|
|
77
|
+
ca as bumpOnConfirmed,
|
|
78
|
+
la as calculateIntegratorFee,
|
|
79
|
+
ba as ceilTickToSpacing,
|
|
80
|
+
da as chainDeadline,
|
|
81
|
+
Aa as clRangeSide,
|
|
82
|
+
pa as clampBigInt,
|
|
83
|
+
Ta as combineTokens,
|
|
84
|
+
he as createViemAdapter,
|
|
85
|
+
La as decodeLaunchGuard,
|
|
86
|
+
Sa as decodeRevertName,
|
|
87
|
+
Ea as defaultDeadline,
|
|
88
|
+
Ia as defaultRangeFor,
|
|
89
|
+
ma as depositRequirements,
|
|
90
|
+
_a as describeError,
|
|
91
|
+
ka as describeRange,
|
|
92
|
+
Ca as evaluateLaunchBuy,
|
|
93
|
+
Pa as exchangeRate,
|
|
94
|
+
Ba as explorerTxUrl,
|
|
95
|
+
Na as fetchPoolLocks,
|
|
96
|
+
ga as fetchTokenLocks,
|
|
97
|
+
De as fetchTokenTrust,
|
|
98
|
+
fa as findShortfall,
|
|
99
|
+
Oa as findToken,
|
|
100
|
+
Ra as floorTickToSpacing,
|
|
101
|
+
ha as formatAmount,
|
|
102
|
+
Da as formatBps,
|
|
103
|
+
Fa as formatCountdown,
|
|
104
|
+
Ua as formatDuration,
|
|
105
|
+
wa as formatLockAmount,
|
|
106
|
+
ya as formatLockBps,
|
|
107
|
+
Ma as formatPercentFromBps,
|
|
108
|
+
va as formatPercentFromPips,
|
|
109
|
+
xa as formatRate,
|
|
110
|
+
Va as formatTimestamp,
|
|
111
|
+
qa as formatUtc,
|
|
112
|
+
Ga as getAmount0Delta,
|
|
113
|
+
Ka as getAmount1Delta,
|
|
114
|
+
Wa as getLiquidityForAmount0,
|
|
115
|
+
Ha as getLiquidityForAmount1,
|
|
116
|
+
Xa as getLiquidityForAmounts,
|
|
117
|
+
Qa as getSqrtRatioAtTick,
|
|
118
|
+
za as groupBySource,
|
|
119
|
+
Fe as hasSaleAdapter,
|
|
120
|
+
ja as hopIsLaunchBuy,
|
|
121
|
+
Ya as initialSwapState,
|
|
122
|
+
Za as isLaunchConfigured,
|
|
123
|
+
Ja as isLaunchKitNotConfigured,
|
|
124
|
+
$a as isLaunchpadNotConfigured,
|
|
125
|
+
as as isNativeToken,
|
|
126
|
+
ss as isTokenListUrl,
|
|
127
|
+
es as launchFeeAt,
|
|
128
|
+
os as launchGuardAbiFor,
|
|
129
|
+
ts as launchScheduleAt,
|
|
130
|
+
rs as lockPageUrl,
|
|
131
|
+
Ue as lockSchedule,
|
|
132
|
+
we as lockerFeeView,
|
|
133
|
+
is as maximumSpent,
|
|
134
|
+
ns as minimumReceived,
|
|
135
|
+
us as nextBlockClock,
|
|
136
|
+
cs as normalizePair,
|
|
137
|
+
ls as normalizePortions,
|
|
138
|
+
bs as oppositeSide,
|
|
139
|
+
ds as orientPair,
|
|
140
|
+
As as pairEntryAddress,
|
|
141
|
+
ps as pairKey,
|
|
142
|
+
Ts as pairedAmountForRange,
|
|
143
|
+
Ls as parseAmount,
|
|
144
|
+
ye as parseDays,
|
|
145
|
+
Me as parseLockAmount,
|
|
146
|
+
ve as parseUtcInput,
|
|
147
|
+
Ss as pipsOf,
|
|
148
|
+
Es as plan,
|
|
149
|
+
xe as planPositionLock,
|
|
150
|
+
Ve as planTokenLock,
|
|
151
|
+
Is as poolBadgeView,
|
|
152
|
+
ms as poolEmbedView,
|
|
153
|
+
to as poolKeyToTuple,
|
|
154
|
+
_s as poolLocksEnabled,
|
|
155
|
+
ks as poolShareBar,
|
|
156
|
+
Cs as portionAmountText,
|
|
157
|
+
Ps as portionLabel,
|
|
158
|
+
Bs as portionOf,
|
|
159
|
+
qe as positionLockActions,
|
|
160
|
+
Ns as priceImpactBps,
|
|
161
|
+
gs as priceImpactSeverity,
|
|
162
|
+
fs as progressPercent,
|
|
163
|
+
Os as reconcileSelection,
|
|
164
|
+
Rs as releaseSchedule,
|
|
165
|
+
hs as requireContract,
|
|
166
|
+
Ds as resolveIntegratorConfig,
|
|
167
|
+
Fs as resolveLaunchDataState,
|
|
168
|
+
Us as resolveLogoUrl,
|
|
169
|
+
ws as resolvePairEntry,
|
|
170
|
+
ys as routeSymbols,
|
|
171
|
+
Ms as scanClLpLockerTokenIds,
|
|
172
|
+
vs as shareBarFromBps,
|
|
173
|
+
xs as shortAddress,
|
|
174
|
+
Ge as simulateSendConfirm,
|
|
175
|
+
Vs as splitIntegratorFee,
|
|
176
|
+
qs as swapWidgetReducer,
|
|
177
|
+
Gs as tickSpacingOf,
|
|
178
|
+
Ke as toUtcInput,
|
|
179
|
+
Ks as tokenBadgeView,
|
|
180
|
+
Ws as tokenEmbedView,
|
|
181
|
+
We as tokenLockActions,
|
|
182
|
+
Hs as tokenShareBar,
|
|
183
|
+
He as tokenTrustView,
|
|
184
|
+
Xs as tokensFromLists,
|
|
185
|
+
Qs as tokensFromMergedList,
|
|
186
|
+
zs as uncollectedFees,
|
|
187
|
+
js as unorientPair,
|
|
188
|
+
Ys as useAccount,
|
|
189
|
+
Zs as useAddLiquidityExecute,
|
|
190
|
+
Js as useAddLiquidityQuote,
|
|
191
|
+
$s as useAsyncResource,
|
|
192
|
+
Xe as useChainClock,
|
|
193
|
+
ae as useIntegrator,
|
|
194
|
+
se as useLaunch,
|
|
195
|
+
ee as useLaunchBuy,
|
|
196
|
+
oe as useLaunchList,
|
|
197
|
+
te as useLaunchesForToken,
|
|
198
|
+
Qe as useLockerAccount,
|
|
199
|
+
ze as useLockerFees,
|
|
200
|
+
je as useLockerRunner,
|
|
201
|
+
Ye as useLockerWallet,
|
|
202
|
+
Ze as useMyLocks,
|
|
203
|
+
re as useOptionalWidgetContext,
|
|
204
|
+
Je as usePoolLocks,
|
|
205
|
+
ie as usePoolState,
|
|
206
|
+
ne as usePools,
|
|
207
|
+
ue as usePositions,
|
|
208
|
+
ce as useProtocolAdapter,
|
|
209
|
+
le as useRemoveLiquidity,
|
|
210
|
+
be as useSlippageSetting,
|
|
211
|
+
de as useSwapExecute,
|
|
212
|
+
Ae as useSwapQuote,
|
|
213
|
+
pe as useTokenBalance,
|
|
214
|
+
Te as useTokenList,
|
|
215
|
+
Le as useTokenLists,
|
|
216
|
+
$e as useTokenLocks,
|
|
217
|
+
ao as useTokenTrust,
|
|
218
|
+
Se as useWidgetContext,
|
|
219
|
+
Ee as validateIntegratorConfig,
|
|
220
|
+
Ie as vestedBps,
|
|
221
|
+
me as withdrawablePositions
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=headless.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small async-resource hook.
|
|
3
|
+
*
|
|
4
|
+
* The widgets deliberately do not depend on a data-fetching library: an
|
|
5
|
+
* embeddable widget that drags TanStack Query into a host's bundle - and its
|
|
6
|
+
* provider into the host's tree - is a widget teams decline to embed. This is
|
|
7
|
+
* the minimum that behaves correctly: it cancels stale results, exposes a real
|
|
8
|
+
* status enum rather than a pile of booleans, and never resolves into a
|
|
9
|
+
* component that has unmounted.
|
|
10
|
+
*/
|
|
11
|
+
/** Lifecycle of an async resource. */
|
|
12
|
+
export type AsyncStatus = "idle" | "loading" | "success" | "error";
|
|
13
|
+
/** State of an async resource. */
|
|
14
|
+
export interface AsyncResource<T> {
|
|
15
|
+
readonly status: AsyncStatus;
|
|
16
|
+
readonly data: T | null;
|
|
17
|
+
readonly error: Error | null;
|
|
18
|
+
/** `Date.now()` of the last successful load. */
|
|
19
|
+
readonly updatedAt: number | null;
|
|
20
|
+
/** True while refreshing over previously loaded data. */
|
|
21
|
+
readonly isRefreshing: boolean;
|
|
22
|
+
refetch(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Options for {@link useAsyncResource}. */
|
|
25
|
+
export interface UseAsyncResourceOptions {
|
|
26
|
+
/** Skip fetching entirely. The resource stays `idle`. */
|
|
27
|
+
readonly enabled?: boolean;
|
|
28
|
+
/** Poll interval in milliseconds. Omit or set 0 to disable polling. */
|
|
29
|
+
readonly refetchIntervalMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runs `loader` whenever `deps` change, with cancellation of stale results.
|
|
33
|
+
*
|
|
34
|
+
* `loader` must be stable or memoised by the caller; `deps` is what actually
|
|
35
|
+
* triggers a refetch.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useAsyncResource<T>(loader: () => Promise<T>, deps: readonly unknown[], options?: UseAsyncResourceOptions): AsyncResource<T>;
|
|
38
|
+
//# sourceMappingURL=useAsyncResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAsyncResource.d.ts","sourceRoot":"","sources":["../../src/hooks/useAsyncResource.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAIH,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEnE,kCAAkC;AAClC,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAOD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,OAAO,GAAE,uBAA4B,GACpC,aAAa,CAAC,CAAC,CAAC,CAqElB"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless launch participation.
|
|
3
|
+
*
|
|
4
|
+
* A launch is a pool with `LaunchGuardHook` attached, so buying into one is a
|
|
5
|
+
* swap and this module owns exactly two things a swap does not have:
|
|
6
|
+
*
|
|
7
|
+
* 1. **The schedule.** `startBlock`, `decayBlocks`, and the fee decaying from
|
|
8
|
+
* `initialFeePips` to `finalFeePips` between them. All block-denominated,
|
|
9
|
+
* never time-denominated: the hook counts blocks, and converting to seconds
|
|
10
|
+
* would require a block time this package cannot know.
|
|
11
|
+
* 2. **The gates.** `TradingNotOpen` before the open, and `BuyExceedsMaxPerTx`
|
|
12
|
+
* while the window is live. Both are evaluated here so the button can be
|
|
13
|
+
* disabled with the reason, rather than reverting inside the vault lock
|
|
14
|
+
* after the user has paid for the whole plan.
|
|
15
|
+
*
|
|
16
|
+
* There is no third thing. In particular there is no per-account state to load:
|
|
17
|
+
* the hook cannot identify a buyer (see {@link ../callpath/launch.js}), so a
|
|
18
|
+
* "your remaining allocation" row would be fiction with a number on it.
|
|
19
|
+
*/
|
|
20
|
+
import type { Address, Hex } from "viem";
|
|
21
|
+
import type { PoolId } from "@latchprotocol/sdk";
|
|
22
|
+
import type { LaunchInfo } from "../adapters/protocol.js";
|
|
23
|
+
import { type LaunchBuyGate, type LaunchSchedule } from "../callpath/launch.js";
|
|
24
|
+
import type { QuoteBreakdown } from "../core/math.js";
|
|
25
|
+
import { type AsyncResource, type AsyncStatus } from "./useAsyncResource.js";
|
|
26
|
+
import { type UseSwapExecuteResult } from "./useSwapExecute.js";
|
|
27
|
+
/**
|
|
28
|
+
* The four states a launch surface can be in, plus the one where it works.
|
|
29
|
+
*
|
|
30
|
+
* They are kept distinct on purpose, because they call for four different
|
|
31
|
+
* sentences and only one of them is the user's problem:
|
|
32
|
+
*
|
|
33
|
+
* - `loading` — a read is in flight.
|
|
34
|
+
* - `error` — the read failed. The chain is unreachable or the address is not
|
|
35
|
+
* a `LaunchGuardHook`. Say so; never fall back to an example.
|
|
36
|
+
* - `not-configured` — this chain's config carries no `launchGuardHook`
|
|
37
|
+
* address, because no `LaunchGuardHook` is deployed on it. Nothing is wrong
|
|
38
|
+
* and nothing will load.
|
|
39
|
+
* - `empty` — the hook is there and answered, and no launch is registered for
|
|
40
|
+
* the pool (or for any configured pool).
|
|
41
|
+
* - `ready` — a launch record was read.
|
|
42
|
+
*/
|
|
43
|
+
export type LaunchDataState = "loading" | "error" | "not-configured" | "empty" | "ready";
|
|
44
|
+
/**
|
|
45
|
+
* `true` when the failure was "there is no launchpad on this chain" rather than
|
|
46
|
+
* "the read broke".
|
|
47
|
+
*
|
|
48
|
+
* The adapters signal it by throwing `ChainConfigError` naming
|
|
49
|
+
* `launchGuardHook`, which is the same mechanism every other missing-contract
|
|
50
|
+
* path in this package uses.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isLaunchpadNotConfigured(error: Error | null): boolean;
|
|
53
|
+
/** Maps an async resource onto {@link LaunchDataState}. */
|
|
54
|
+
export declare function resolveLaunchDataState(resource: {
|
|
55
|
+
readonly status: AsyncStatus;
|
|
56
|
+
readonly error: Error | null;
|
|
57
|
+
readonly data: unknown;
|
|
58
|
+
}): LaunchDataState;
|
|
59
|
+
/**
|
|
60
|
+
* Every launch the adapter surfaces.
|
|
61
|
+
*
|
|
62
|
+
* Polled, because the schedule is a function of the block height and a stale
|
|
63
|
+
* "opens in 12 blocks" is worse than no number.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useLaunchList(): AsyncResource<readonly LaunchInfo[]>;
|
|
66
|
+
/**
|
|
67
|
+
* `true` when the failure was "no `LaunchpadKitV2` is configured" — the
|
|
68
|
+
* by-token lookup's own not-configured state.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isLaunchKitNotConfigured(error: Error | null): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Every pool a `LaunchpadKitV2` launch opened for `token`, as launches, in
|
|
73
|
+
* leg order. Polled like the list. `[]` for a token the kit never launched.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useLaunchesForToken(token: Address | null): AsyncResource<readonly LaunchInfo[]>;
|
|
76
|
+
/** One launch, by pool id. */
|
|
77
|
+
export declare function useLaunch(poolId: PoolId | null): AsyncResource<LaunchInfo | null>;
|
|
78
|
+
/** Everything a launch UI needs, derived from one read. Pure. */
|
|
79
|
+
export interface LaunchView {
|
|
80
|
+
readonly launch: LaunchInfo;
|
|
81
|
+
/** The schedule as of the point (on the hook's clock) the launch was read at. */
|
|
82
|
+
readonly schedule: LaunchSchedule;
|
|
83
|
+
/**
|
|
84
|
+
* Where the fee the hook is charging sits between `initialFeePips` and
|
|
85
|
+
* `finalFeePips`, in bps: `0` at the opening tax, `10_000` once settled.
|
|
86
|
+
* `null` when the two ends are equal, where there is no span to be inside of.
|
|
87
|
+
*/
|
|
88
|
+
readonly feeSpanProgressBps: number | null;
|
|
89
|
+
/**
|
|
90
|
+
* `currentFeePips` (read from the hook) minus the locally projected fee for
|
|
91
|
+
* the same block.
|
|
92
|
+
*
|
|
93
|
+
* Expected to be exactly `0`: {@link ../callpath/launch.js | launchFeeAt}
|
|
94
|
+
* reproduces `LaunchGuardHook.feeAt` including its rounding. Anything else
|
|
95
|
+
* means the two disagree, and a UI should show the chain's number and say the
|
|
96
|
+
* projection is off rather than quietly preferring one.
|
|
97
|
+
*/
|
|
98
|
+
readonly feeProjectionDriftPips: number | null;
|
|
99
|
+
}
|
|
100
|
+
/** Derives the presentational view of a launch. Pure. */
|
|
101
|
+
export declare function buildLaunchView(launch: LaunchInfo): LaunchView;
|
|
102
|
+
/** Parameters for {@link useLaunchBuy}. */
|
|
103
|
+
export interface UseLaunchBuyParams {
|
|
104
|
+
readonly launch: LaunchInfo | null;
|
|
105
|
+
/** Input amount in the quote currency's smallest unit. */
|
|
106
|
+
readonly amountIn: bigint | null;
|
|
107
|
+
readonly slippageBps?: number;
|
|
108
|
+
readonly recipient?: `0x${string}`;
|
|
109
|
+
readonly onSuccess?: (hash: Hex) => void;
|
|
110
|
+
}
|
|
111
|
+
/** Result of {@link useLaunchBuy}. */
|
|
112
|
+
export interface UseLaunchBuyResult {
|
|
113
|
+
/** The hook's gates, evaluated against the point the launch was read at. */
|
|
114
|
+
readonly gate: LaunchBuyGate;
|
|
115
|
+
/** Swap quote breakdown, or `null` while there is nothing to quote. */
|
|
116
|
+
readonly breakdown: QuoteBreakdown | null;
|
|
117
|
+
readonly quoteStatus: AsyncStatus;
|
|
118
|
+
readonly quoteError: Error | null;
|
|
119
|
+
readonly quoteIsRefreshing: boolean;
|
|
120
|
+
/** Output units per input unit, for display only. */
|
|
121
|
+
readonly rate: number | null;
|
|
122
|
+
/** The swap execution controller. Approvals, signature, confirmation. */
|
|
123
|
+
readonly execution: UseSwapExecuteResult;
|
|
124
|
+
/** `true` when the gates pass and the swap layer is ready to send. */
|
|
125
|
+
readonly canBuy: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Quotes and executes a launch buy.
|
|
129
|
+
*
|
|
130
|
+
* Deliberately a thin composition of `useSwapQuote` and `useSwapExecute` rather
|
|
131
|
+
* than a parallel implementation: a launch buy that took a different code path
|
|
132
|
+
* from a swap would be a second call path to keep correct, and the second one
|
|
133
|
+
* is always the one that rots.
|
|
134
|
+
*
|
|
135
|
+
* Quoting is suppressed while the hook would reject the swap. Quoting a trade
|
|
136
|
+
* that reverts in `beforeSwap` gets a revert, not a price, and rendering that
|
|
137
|
+
* as a failed quote would blame the pool for a closed gate.
|
|
138
|
+
*/
|
|
139
|
+
export declare function useLaunchBuy(params: UseLaunchBuyParams): UseLaunchBuyResult;
|
|
140
|
+
//# sourceMappingURL=useLaunch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLaunch.d.ts","sourceRoot":"","sources":["../../src/hooks/useLaunch.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAoB,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzF;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAErE;AAED,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,GAAG,eA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