@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,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `LockerWidget`: lock liquidity and tokens with Latch from any React app.
|
|
3
|
+
*
|
|
4
|
+
* Lock liquidity time-lock a CL position NFT in `LatchPositionLock`
|
|
5
|
+
* Lock tokens a time lock or cliff + linear vesting in `LatchTokenLock`
|
|
6
|
+
* My locks the connected wallet's locks: collect fees, extend,
|
|
7
|
+
* withdraw after the date, claim what has vested, accept an
|
|
8
|
+
* offered lock
|
|
9
|
+
*
|
|
10
|
+
* The fee is read live from each contract (`feeWei` and any announced
|
|
11
|
+
* `pendingFee`) and shown before anything is signed; it is the contract's, not
|
|
12
|
+
* this widget's, so every caller pays the same. Approvals are exact (this one
|
|
13
|
+
* NFT; exactly the amount), and only when the chain says one is missing. Every
|
|
14
|
+
* call is simulated with its exact bytes before the wallet sees it, and every
|
|
15
|
+
* receipt is checked: a mined revert is reported as one. Errors read through
|
|
16
|
+
* the widgets' decoder.
|
|
17
|
+
*
|
|
18
|
+
* The wallet is `wallet` (the `WidgetWallet` surface `createViemAdapter`
|
|
19
|
+
* takes), else the mounted `WidgetProvider`'s adapter. Reads go through
|
|
20
|
+
* `client`, on the lock contracts' chain.
|
|
21
|
+
*/
|
|
22
|
+
import { type Address, type Hex, type PublicClient } from "viem";
|
|
23
|
+
import type { WidgetWallet } from "../adapters/viem.js";
|
|
24
|
+
import { type WidgetTheme } from "../context/WidgetProvider.js";
|
|
25
|
+
import { type LockerContracts } from "../hooks/useLocker.js";
|
|
26
|
+
export interface LockerWidgetProps {
|
|
27
|
+
readonly client: PublicClient;
|
|
28
|
+
readonly contracts: LockerContracts;
|
|
29
|
+
readonly wallet?: WidgetWallet;
|
|
30
|
+
readonly native?: {
|
|
31
|
+
readonly symbol: string;
|
|
32
|
+
readonly decimals: number;
|
|
33
|
+
};
|
|
34
|
+
readonly theme?: WidgetTheme;
|
|
35
|
+
readonly title?: string;
|
|
36
|
+
readonly defaultTab?: LockerTab;
|
|
37
|
+
/** Prefill the token tab. */
|
|
38
|
+
readonly defaultToken?: Address;
|
|
39
|
+
/** Opens the host's wallet connect flow; falls back to the provider's. */
|
|
40
|
+
readonly onConnectRequest?: () => void;
|
|
41
|
+
/** Links a transaction hash to an explorer; `null` for no link. */
|
|
42
|
+
readonly explorerTxUrl?: (hash: Hex) => string | null;
|
|
43
|
+
/** The Latch mark (brand kit `masters/latch-mark.svg`, or `-onlight` on a light ground) beside the
|
|
44
|
+
* title, at the kit's 24 px minimum. The intrinsic size is the master's real viewBox so the shape
|
|
45
|
+
* is reserved correctly; CSS decides how big it draws. Omit for none. */
|
|
46
|
+
readonly brandMarkUrl?: string;
|
|
47
|
+
readonly className?: string;
|
|
48
|
+
}
|
|
49
|
+
export type LockerTab = "position" | "token" | "mine";
|
|
50
|
+
export declare function LockerWidget(props: LockerWidgetProps): JSX.Element;
|
|
51
|
+
//# sourceMappingURL=LockerWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LockerWidget.d.ts","sourceRoot":"","sources":["../../src/components/LockerWidget.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAgD,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAsB/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE1F,OAAO,EAAiF,KAAK,eAAe,EAAqC,MAAM,uBAAuB,CAAC;AAoB/K,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAChC,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,mEAAmE;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;IACtD;;6EAEyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAictD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CA8DlE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `LocksBadge` and `LocksPanel`: "is this liquidity (or this token) locked,
|
|
3
|
+
* until when?", read live from the Latch lock contracts.
|
|
4
|
+
*
|
|
5
|
+
* - `LocksBadge` is one line: the locked share of a pool's ACTIVE liquidity
|
|
6
|
+
* (or of a token's supply), a countdown to the next unlock, and a link to
|
|
7
|
+
* the lock page. For beside a pool or a token, anywhere.
|
|
8
|
+
* - `LocksPanel` is the list: every lock with its owner, liquidity or amount,
|
|
9
|
+
* unlock date, countdown and status.
|
|
10
|
+
*
|
|
11
|
+
* Both take a viem `PublicClient` and the lock contract's address from the
|
|
12
|
+
* host's address book; `null` renders the not-deployed state instead of a
|
|
13
|
+
* read. No provider, no wallet, no writes. Themed by the same `--latch-*`
|
|
14
|
+
* properties as every other widget; `theme` falls back to a mounted
|
|
15
|
+
* `WidgetProvider`'s, then to `system`.
|
|
16
|
+
*/
|
|
17
|
+
import type { PublicClient } from "viem";
|
|
18
|
+
import { type WidgetTheme } from "../context/WidgetProvider.js";
|
|
19
|
+
import { type NativeCurrencyMeta } from "../hooks/useLocks.js";
|
|
20
|
+
import { type LocksTarget } from "../locks/model.js";
|
|
21
|
+
/** Props shared by {@link LocksBadge} and {@link LocksPanel}. */
|
|
22
|
+
export interface LocksWidgetProps {
|
|
23
|
+
/** Reads go here. The chain it is connected to is the chain the lock address is on. */
|
|
24
|
+
readonly client: PublicClient;
|
|
25
|
+
/** A pool id with the chain's `LatchPositionLock`, or a token with its `LatchTokenLock`. `null` address = the chain has no such contract in the host address book; the widget renders "coming soon". */
|
|
26
|
+
readonly target: LocksTarget;
|
|
27
|
+
/** Base URL of a Latch app; the widget links to `<siteUrl>/app/locks/...`. Omit to render no link. */
|
|
28
|
+
readonly siteUrl?: string;
|
|
29
|
+
/** The lock pages' path under `siteUrl`; default `/app/locks` (e.g. `/locks` for the public pages). */
|
|
30
|
+
readonly lockPathBase?: string;
|
|
31
|
+
/** Appended to the lock page URL, e.g. `net=robinhood`. */
|
|
32
|
+
readonly lockQuery?: string;
|
|
33
|
+
/** Anchor target for the lock page link, e.g. `_blank` when the badge is inside an iframe. */
|
|
34
|
+
readonly linkTarget?: "_blank" | "_top" | "_self";
|
|
35
|
+
/**
|
|
36
|
+
* `embed`: the "Locked by Latch" badge's words (`../locks/embedModel.ts`): a
|
|
37
|
+
* token reads as the share of supply NOT YET VESTED ("Y% of supply locked")
|
|
38
|
+
* rather than what the locker holds. Same reads either way.
|
|
39
|
+
*/
|
|
40
|
+
readonly wording?: "default" | "embed";
|
|
41
|
+
/**
|
|
42
|
+
* The Latch mark (the brand kit's `masters/latch-mark.svg`, e.g.
|
|
43
|
+
* `<latch site>/brand/masters/latch-mark.svg` — or `latch-mark-onlight.svg` on a light
|
|
44
|
+
* ground, because the current mark is two-tone), shown at the kit's 24 px minimum
|
|
45
|
+
* beside "Read from chain". Omit for no mark.
|
|
46
|
+
*/
|
|
47
|
+
readonly brandMarkUrl?: string;
|
|
48
|
+
readonly theme?: WidgetTheme;
|
|
49
|
+
/** Native currency display facts (default ETH, 18). */
|
|
50
|
+
readonly native?: NativeCurrencyMeta;
|
|
51
|
+
/** Re-read interval in ms; default 60,000. */
|
|
52
|
+
readonly refetchIntervalMs?: number;
|
|
53
|
+
readonly className?: string;
|
|
54
|
+
}
|
|
55
|
+
/** One line: the share locked, the countdown to the next unlock, a link. */
|
|
56
|
+
export declare function LocksBadge(props: LocksWidgetProps): JSX.Element;
|
|
57
|
+
/** The list of every lock for the target, under the badge's summary. */
|
|
58
|
+
export declare function LocksPanel(props: LocksWidgetProps & {
|
|
59
|
+
readonly title?: string;
|
|
60
|
+
}): JSX.Element;
|
|
61
|
+
//# sourceMappingURL=LocksWidgets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocksWidgets.d.ts","sourceRoot":"","sources":["../../src/components/LocksWidgets.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAIL,KAAK,kBAAkB,EAGxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAkBL,KAAK,WAAW,EACjB,MAAM,m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
+
* `useSwapExecute` do the work, this file only renders it. An integrator who
|
|
6
|
+
* wants their own look imports those two hooks and deletes this component from
|
|
7
|
+
* their bundle.
|
|
8
|
+
*
|
|
9
|
+
* The presentation is the one people expect from a swap: two large amount
|
|
10
|
+
* panels (You pay / You receive) with a token selector dialog each, a flip button between
|
|
11
|
+
* them, one call-to-action that always says what the next step is (connect,
|
|
12
|
+
* enter an amount, insufficient balance, approve, swap, confirming), and a
|
|
13
|
+
* details disclosure with the rate, price impact, every fee, the guaranteed
|
|
14
|
+
* minimum and the route. Overlays are Radix primitives (MIT) portalled into the
|
|
15
|
+
* widget so they work inside the shadow-root embed.
|
|
16
|
+
*
|
|
17
|
+
* The integrator fee, when configured, is shown as its own line in the details.
|
|
18
|
+
* That is a deliberate product decision, not a legal one: a fee the user can see
|
|
19
|
+
* is a fee that does not become a scandal, and an integrator whose users trust
|
|
20
|
+
* the widget keeps earning from it.
|
|
21
|
+
*
|
|
22
|
+
* There is no dollar figure anywhere. Nothing in the adapter prices a token in
|
|
23
|
+
* USD, and a number that looks priced and is not would be an invented one.
|
|
24
|
+
*
|
|
25
|
+
* A host that frames the widget - a token page with Buy / Sell tabs, a swap
|
|
26
|
+
* page that deep-links a pair - drives it through props rather than remounts:
|
|
27
|
+
* `pair` pins the pair (`lockPair` makes the selectors read-only chips), `side`
|
|
28
|
+
* orients it, `onQuote` reports every quote, `slots` add the host's own chrome,
|
|
29
|
+
* and a `ref` gives an imperative handle for the host's own percent chips. All
|
|
30
|
+
* of it is opt-in; without those props the widget is the one it always was.
|
|
31
|
+
*
|
|
32
|
+
* `variant="compact"` is the token page's trade box: a Buy / Sell pill where
|
|
33
|
+
* the title and the flip button were, one "You pay" panel with its quick-amount
|
|
34
|
+
* chips, and every line - you receive, price impact, pool fee, the creator tax
|
|
35
|
+
* when the host passes it, minimum received - always visible, each on its own
|
|
36
|
+
* line, above the call to action. Same quote, same simulation, same button.
|
|
37
|
+
* The state behind them is pure (`swap/state.ts`) and tested without a DOM.
|
|
38
|
+
*/
|
|
39
|
+
import { type ReactNode } from "react";
|
|
40
|
+
import { type TokenListInput } from "../core/tokenLists.js";
|
|
41
|
+
import { type SwapPair, type SwapQuoteView, type SwapSide } from "./swap/state.js";
|
|
42
|
+
/** Props for {@link SwapWidget}. */
|
|
43
|
+
export interface SwapWidgetProps {
|
|
44
|
+
/** Pre-selects the input token by address. */
|
|
45
|
+
readonly defaultTokenIn?: string;
|
|
46
|
+
/** Pre-selects the output token by address. */
|
|
47
|
+
readonly defaultTokenOut?: string;
|
|
48
|
+
readonly title?: string;
|
|
49
|
+
/** Show the slippage control. Defaults to `true`. */
|
|
50
|
+
readonly showSlippageControl?: boolean;
|
|
51
|
+
readonly onSwapConfirmed?: (hash: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Token lists (Uniswap Token Lists standard) to offer beside the adapter's
|
|
54
|
+
* own tokens: documents already in hand, or URLs fetched and schema-validated
|
|
55
|
+
* through the SDK. Order is precedence - the first list to name an address
|
|
56
|
+
* wins - and the picker groups entries by list and badges tokenised stocks.
|
|
57
|
+
* The adapter's tokens (the pools this site routes through) always come first.
|
|
58
|
+
*/
|
|
59
|
+
readonly tokenLists?: readonly TokenListInput[];
|
|
60
|
+
/**
|
|
61
|
+
* Makes the "Connect wallet" call to action a working button that opens
|
|
62
|
+
* the host's connect flow. Absent (and absent on the provider too), the CTA
|
|
63
|
+
* is a disabled label and the visitor connects through the host's control.
|
|
64
|
+
*/
|
|
65
|
+
readonly onConnectRequest?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* The pair to trade, pinned: by address (resolved against the token list,
|
|
68
|
+
* then read off the contract when the list lacks it) or as `TokenInfo`s
|
|
69
|
+
* (selected on the first frame). `{ token, quote }` is anchored - `side`
|
|
70
|
+
* says which way it is traded; `{ tokenIn, tokenOut }` is the same pair in
|
|
71
|
+
* its buy orientation. A change of `pair` re-pins without a remount, so the
|
|
72
|
+
* typed amount survives a host switching legs. Without `lockPair` the
|
|
73
|
+
* visitor may still pick other tokens; the pin returns when the prop changes.
|
|
74
|
+
*/
|
|
75
|
+
readonly pair?: SwapPair;
|
|
76
|
+
/**
|
|
77
|
+
* With `pair`: the token selectors become read-only chips (the token, no
|
|
78
|
+
* dropdown) and the pair cannot be changed from inside the widget. The flip
|
|
79
|
+
* button stays - it flips the side, not the pair. Defaults to `false`.
|
|
80
|
+
*/
|
|
81
|
+
readonly lockPair?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The direction, controlled: `buy` pays the quote and receives the token,
|
|
84
|
+
* `sell` the reverse. When set, the widget's flip button only reports through
|
|
85
|
+
* `onSideChange` and the host decides; when absent the widget owns its side
|
|
86
|
+
* and still reports. A side change keeps the typed amount as the amount you
|
|
87
|
+
* pay and re-quotes - it never clears the field.
|
|
88
|
+
*/
|
|
89
|
+
readonly side?: SwapSide;
|
|
90
|
+
/** Fired by the flip button and by `flip()`, with the side the widget wants to be on. */
|
|
91
|
+
readonly onSideChange?: (side: SwapSide) => void;
|
|
92
|
+
/**
|
|
93
|
+
* The balance portions offered as chips under the input, as fractions in
|
|
94
|
+
* `(0, 1]`; `1` renders as "Max". Defaults to `[0.25, 0.5, 0.75, 1]`; an empty
|
|
95
|
+
* list hides the chips. The chips only show once a balance has been read -
|
|
96
|
+
* without a wallet there is no balance to take a portion of.
|
|
97
|
+
*/
|
|
98
|
+
readonly portions?: readonly number[];
|
|
99
|
+
/**
|
|
100
|
+
* Called when a portion is asked for (a chip, or `setPortion` on the handle)
|
|
101
|
+
* and there is no balance to take it from because no wallet is connected.
|
|
102
|
+
* The widget never estimates a balance; the host may open its connect flow
|
|
103
|
+
* here. Absent, the request is a no-op.
|
|
104
|
+
*/
|
|
105
|
+
readonly onNeedsWallet?: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Reports every quote the widget holds - the net output, the guaranteed
|
|
108
|
+
* minimum, the price impact (`null` when the pool's fee is hook-set), the LP
|
|
109
|
+
* fee label and the route - and `null` when there is none (empty amount, no
|
|
110
|
+
* route, unmounted). Fires when the quote changes, including on refresh.
|
|
111
|
+
*/
|
|
112
|
+
readonly onQuote?: (quote: SwapQuoteView | null) => void;
|
|
113
|
+
/**
|
|
114
|
+
* The host's own chrome, rendered inside the widget: `header` between the
|
|
115
|
+
* title row and the panels (a leg switcher, a note), `aboveButton` between
|
|
116
|
+
* the panels and the call to action, `footer` after the details and before
|
|
117
|
+
* the brand line. The brand line itself is not a slot.
|
|
118
|
+
*/
|
|
119
|
+
readonly slots?: {
|
|
120
|
+
readonly header?: ReactNode;
|
|
121
|
+
readonly aboveButton?: ReactNode;
|
|
122
|
+
readonly footer?: ReactNode;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* `"default"` (two panels, the flip button, a details disclosure under the
|
|
126
|
+
* button) or `"compact"`: a Buy / Sell pill in the header in place of the
|
|
127
|
+
* title and the flip button, one "You pay" panel, and the lines always
|
|
128
|
+
* visible above the button. Meant with a pinned `pair`; the pill changes the
|
|
129
|
+
* side exactly as `side` / `onSideChange` do, never the pair.
|
|
130
|
+
*/
|
|
131
|
+
readonly variant?: "default" | "compact";
|
|
132
|
+
/**
|
|
133
|
+
* The pool's creator tax as the host read it from the launch guard: the rate
|
|
134
|
+
* a buy and a sell pay NOW, in bps (pass 0 once the tax has expired - it
|
|
135
|
+
* ends with no transaction). Rendered as its own line for the current side,
|
|
136
|
+
* never folded into the pool fee or the price impact. Absent, there is no
|
|
137
|
+
* line; `null` says the pool takes none.
|
|
138
|
+
*/
|
|
139
|
+
readonly creatorTax?: {
|
|
140
|
+
readonly buyBps: number;
|
|
141
|
+
readonly sellBps: number;
|
|
142
|
+
} | null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* What a `ref` on {@link SwapWidget} gives the host: the amount, the balance
|
|
146
|
+
* portions and the direction, so a page can draw its own percent chips or
|
|
147
|
+
* Buy / Sell tabs and still leave the trade to the widget.
|
|
148
|
+
*/
|
|
149
|
+
export interface SwapWidgetHandle {
|
|
150
|
+
/** Writes the input amount, as the user would type it (`"1.5"`). */
|
|
151
|
+
setAmountIn(text: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Writes a fraction of the input balance (`0.75`, `1` for Max with the
|
|
154
|
+
* native gas sliver kept back). Returns `false` - and calls `onNeedsWallet` -
|
|
155
|
+
* when there is no balance to take it from; nothing is written then.
|
|
156
|
+
*/
|
|
157
|
+
setPortion(fraction: number): boolean;
|
|
158
|
+
/** Flips the direction, exactly like the widget's own flip button. */
|
|
159
|
+
flip(): void;
|
|
160
|
+
/** Re-reads the quote now rather than on the next interval. */
|
|
161
|
+
refreshQuote(): void;
|
|
162
|
+
}
|
|
163
|
+
/** The styled swap widget. */
|
|
164
|
+
export declare const SwapWidget: import("react").ForwardRefExoticComponent<SwapWidgetProps & import("react").RefAttributes<SwapWidgetHandle>>;
|
|
165
|
+
//# sourceMappingURL=SwapWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapWidget.d.ts","sourceRoot":"","sources":["../../src/components/SwapWidget.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAgB3E,OAAO,EAcL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAIzB,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,+CAA+C;IAC/C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,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;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACtC,sEAAsE;IACtE,IAAI,IAAI,IAAI,CAAC;IACb,+DAA+D;IAC/D,YAAY,IAAI,IAAI,CAAC;CACtB;AAuDD,8BAA8B;AAC9B,eAAO,MAAM,UAAU,8GAserB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `TokenTrustPanel`: one place, for one token, with what the Latch contracts
|
|
3
|
+
* hold about it - its liquidity locks per pool (time-locked and permanent LP
|
|
4
|
+
* locker, as the locked share of ACTIVE liquidity), its token locks and
|
|
5
|
+
* vesting, the creator tax a Kit v2 launch guard takes, each pool's LP fee and
|
|
6
|
+
* protocol fee, and what LatchRegistry records about each pool's hook. Every
|
|
7
|
+
* row names the contract, the view and the blocks it was read at.
|
|
8
|
+
*
|
|
9
|
+
* Read-only: a viem `PublicClient` and the chain's contract addresses from the
|
|
10
|
+
* host's address book. No wallet, no provider. Four states, each distinct:
|
|
11
|
+
* reading, the rows, "could not be read" when the chain does not answer, and
|
|
12
|
+
* "coming soon" when `contracts` is `null` — a feature that has not arrived is not an outage, and the two read differently. It never says
|
|
13
|
+
* "safe": a listing is what the registry records, not an audit.
|
|
14
|
+
*/
|
|
15
|
+
import type { Address, Hex, PublicClient } from "viem";
|
|
16
|
+
import { type WidgetTheme } from "../context/WidgetProvider.js";
|
|
17
|
+
import { type TokenTrustTarget } from "../hooks/useTokenTrust.js";
|
|
18
|
+
export interface TokenTrustPanelProps extends TokenTrustTarget {
|
|
19
|
+
readonly client: PublicClient;
|
|
20
|
+
readonly theme?: WidgetTheme;
|
|
21
|
+
readonly title?: string;
|
|
22
|
+
/** Links each source contract to an explorer. Return `null` for no link (e.g. a devnet). */
|
|
23
|
+
readonly explorerAddressUrl?: (address: Address) => string | null;
|
|
24
|
+
/** Links each pool to its lock page. Return `null` for no link. */
|
|
25
|
+
readonly poolLockUrl?: (poolId: Hex) => string | null;
|
|
26
|
+
/** Anchor target for those links, e.g. `_blank` inside an iframe. */
|
|
27
|
+
readonly linkTarget?: "_blank" | "_top" | "_self";
|
|
28
|
+
readonly refetchIntervalMs?: number;
|
|
29
|
+
readonly className?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function TokenTrustPanel(props: TokenTrustPanelProps): JSX.Element;
|
|
32
|
+
//# sourceMappingURL=TokenTrustPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenTrustPanel.d.ts","sourceRoot":"","sources":["../../src/components/TokenTrustPanel.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAAC;IAClE,mEAAmE;IACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;IACtD,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAClD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAyCD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CA4FxE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two compact lock visuals the lock widgets share, in plain SVG / CSS (no
|
|
3
|
+
* chart library, so the embed bundle stays small):
|
|
4
|
+
*
|
|
5
|
+
* - `ShareBar`: a whole split into its locked parts (permanent LP locker,
|
|
6
|
+
* time-locked, unvested, vested-unclaimed); the empty track is "not
|
|
7
|
+
* locked". Grows in from the left. Each part states its exact share on
|
|
8
|
+
* hover (title) and to a screen reader (the bar's label).
|
|
9
|
+
* - `ScheduleSpark`: a token's cumulative release schedule (the SDK's
|
|
10
|
+
* `vestedAt`, the contract's own formula), drawn on, with a "now" rule.
|
|
11
|
+
* Pointer or arrow keys read any point: its date and the amount vested by
|
|
12
|
+
* then.
|
|
13
|
+
*
|
|
14
|
+
* Themed only by `--latch-*` properties; motion is CSS and is switched off
|
|
15
|
+
* under `prefers-reduced-motion`. Nothing is drawn that was not read.
|
|
16
|
+
*/
|
|
17
|
+
import { type LocksTokenMeta, type SchedulePoint, type ShareBarView } from "../locks/model.js";
|
|
18
|
+
export declare function ShareBar({ view, label, keyed }: {
|
|
19
|
+
view: ShareBarView;
|
|
20
|
+
label: string;
|
|
21
|
+
keyed?: boolean;
|
|
22
|
+
}): JSX.Element;
|
|
23
|
+
export declare function ScheduleSpark({ points, total, now, token, }: {
|
|
24
|
+
points: readonly SchedulePoint[];
|
|
25
|
+
total: bigint;
|
|
26
|
+
now: bigint | null;
|
|
27
|
+
token: Pick<LocksTokenMeta, "symbol" | "decimals">;
|
|
28
|
+
}): JSX.Element | null;
|
|
29
|
+
//# sourceMappingURL=lockCharts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lockCharts.d.ts","sourceRoot":"","sources":["../../src/components/lockCharts.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAA8C,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI3I,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAY,EAAE,EAAE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CA4B3H;AAKD,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,GAAG,EACH,KAAK,GACN,EAAE;IACD,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAC;CACpD,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA4DrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where overlays render. Radix portals default to `document.body`, which is
|
|
3
|
+
* outside a shadow root and outside the `.latch-widget` theme scope. The shell
|
|
4
|
+
* provides its own element instead, so dialogs and popovers inherit the theme
|
|
5
|
+
* variables and stay styled inside the web component.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PortalContainerProvider: import("react").Provider<HTMLElement | null>;
|
|
8
|
+
/** The element overlays should portal into, or `undefined` for Radix's default. */
|
|
9
|
+
export declare function usePortalContainer(): HTMLElement | undefined;
|
|
10
|
+
//# sourceMappingURL=portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/components/portal.tsx"],"names":[],"mappings":"AACA;;;;;GAKG;AAMH,eAAO,MAAM,uBAAuB,8CAAkC,CAAC;AAEvE,mFAAmF;AACnF,wBAAgB,kBAAkB,IAAI,WAAW,GAAG,SAAS,CAE5D"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presentational primitives shared by the three styled widgets.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here holds protocol state. Each piece is a thin, accessible shell
|
|
5
|
+
* over native form elements: a real `<label>` for every input, a real `<button>`
|
|
6
|
+
* for every action, and one polite live region per widget so a screen reader
|
|
7
|
+
* hears quote and transaction changes without the focus moving.
|
|
8
|
+
*/
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
|
+
import type { TokenInfo } from "../adapters/protocol.js";
|
|
11
|
+
/** Props for {@link WidgetShell}. */
|
|
12
|
+
export interface WidgetShellProps {
|
|
13
|
+
readonly title: string;
|
|
14
|
+
readonly subtitle?: string;
|
|
15
|
+
readonly children: ReactNode;
|
|
16
|
+
/** Rendered at the top-right of the header, e.g. a settings control. */
|
|
17
|
+
readonly headerAction?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Rendered in the header in place of the visible title (the swap widget's
|
|
20
|
+
* Buy / Sell pill). The title stays the section's name and its heading, for
|
|
21
|
+
* assistive technology only.
|
|
22
|
+
*/
|
|
23
|
+
readonly headerContent?: ReactNode;
|
|
24
|
+
readonly className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The outer frame: theme attribute, stylesheet injection and the mock warning.
|
|
28
|
+
*
|
|
29
|
+
* The mock banner is rendered from `adapter.isMock` and takes no prop, so an
|
|
30
|
+
* integrator cannot configure it away while still showing fabricated numbers.
|
|
31
|
+
*/
|
|
32
|
+
export declare function WidgetShell(props: WidgetShellProps): JSX.Element;
|
|
33
|
+
/** Permanent, non-dismissible warning shown whenever the adapter is a mock. */
|
|
34
|
+
export declare function MockBanner(): JSX.Element;
|
|
35
|
+
/** Props for {@link AmountField}. */
|
|
36
|
+
export interface AmountFieldProps {
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly value: string;
|
|
39
|
+
readonly onValueChange?: (value: string) => void;
|
|
40
|
+
readonly readOnly?: boolean;
|
|
41
|
+
readonly token: TokenInfo | null;
|
|
42
|
+
readonly tokens: readonly TokenInfo[];
|
|
43
|
+
readonly onTokenChange?: (token: TokenInfo) => void;
|
|
44
|
+
readonly balance?: bigint | null;
|
|
45
|
+
readonly onUseMax?: () => void;
|
|
46
|
+
readonly error?: string | null;
|
|
47
|
+
readonly secondaryText?: string;
|
|
48
|
+
readonly placeholder?: string;
|
|
49
|
+
}
|
|
50
|
+
/** An amount input paired with a token selector and a balance line. */
|
|
51
|
+
export declare function AmountField(props: AmountFieldProps): JSX.Element;
|
|
52
|
+
/** One label/value pair inside a summary block. */
|
|
53
|
+
export interface SummaryRowProps {
|
|
54
|
+
readonly label: string;
|
|
55
|
+
readonly value: ReactNode;
|
|
56
|
+
readonly emphasis?: "fee";
|
|
57
|
+
readonly severity?: "low" | "elevated" | "high" | "severe" | "unknown";
|
|
58
|
+
readonly title?: string;
|
|
59
|
+
}
|
|
60
|
+
/** A `<dt>`/`<dd>` pair. Must be rendered inside {@link SummaryList}. */
|
|
61
|
+
export declare function SummaryRow(props: SummaryRowProps): JSX.Element;
|
|
62
|
+
/** A definition list wrapper for {@link SummaryRow}s. */
|
|
63
|
+
export declare function SummaryList(props: {
|
|
64
|
+
readonly children: ReactNode;
|
|
65
|
+
}): JSX.Element;
|
|
66
|
+
/** Props for {@link StatusRegion}. */
|
|
67
|
+
export interface StatusRegionProps {
|
|
68
|
+
readonly message: string;
|
|
69
|
+
readonly tone?: "neutral" | "error" | "success";
|
|
70
|
+
/** `assertive` for errors that need to interrupt; `polite` otherwise. */
|
|
71
|
+
readonly assertive?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The widget's single live region.
|
|
75
|
+
*
|
|
76
|
+
* Quote refreshes and transaction transitions are announced here rather than by
|
|
77
|
+
* moving focus, so a keyboard user is never yanked out of the amount field
|
|
78
|
+
* mid-typing by a background re-quote.
|
|
79
|
+
*/
|
|
80
|
+
export declare function StatusRegion(props: StatusRegionProps): JSX.Element;
|
|
81
|
+
/** Props for {@link ActionButton}. */
|
|
82
|
+
export interface ActionButtonProps {
|
|
83
|
+
readonly children: ReactNode;
|
|
84
|
+
readonly onClick?: () => void;
|
|
85
|
+
readonly disabled?: boolean;
|
|
86
|
+
readonly busy?: boolean;
|
|
87
|
+
readonly type?: "button" | "submit";
|
|
88
|
+
readonly variant?: "primary" | "secondary" | "danger";
|
|
89
|
+
/**
|
|
90
|
+
* True while the widget is waiting for a wallet. The button then becomes
|
|
91
|
+
* the connect call to action: enabled and calling `onConnectRequest` when
|
|
92
|
+
* the host gave one, otherwise the disabled label it always was. `type`,
|
|
93
|
+
* `disabled` and `onClick` are ignored in that state.
|
|
94
|
+
*/
|
|
95
|
+
readonly needsConnect?: boolean;
|
|
96
|
+
/** See {@link connectCtaProps}. */
|
|
97
|
+
readonly onConnectRequest?: () => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The attributes of a primary button while no wallet is connected.
|
|
101
|
+
*
|
|
102
|
+
* With a handler the button is a real button that asks the host to open its
|
|
103
|
+
* connect flow; without one it is disabled, so a host that renders its own
|
|
104
|
+
* connect control somewhere else keeps exactly the behaviour it had. Never a
|
|
105
|
+
* submit: pressing it must not run the form's swap/add/buy handler.
|
|
106
|
+
*/
|
|
107
|
+
export declare function connectCtaProps(onConnectRequest: (() => void) | undefined): {
|
|
108
|
+
readonly type: "button";
|
|
109
|
+
readonly disabled: boolean;
|
|
110
|
+
readonly onClick: (() => void) | undefined;
|
|
111
|
+
};
|
|
112
|
+
/** The widget's primary call to action. */
|
|
113
|
+
export declare function ActionButton(props: ActionButtonProps): JSX.Element;
|
|
114
|
+
/** A labelled progress bar backed by a real `progressbar` role. */
|
|
115
|
+
export declare function ProgressBar(props: {
|
|
116
|
+
readonly label: string;
|
|
117
|
+
readonly percent: number;
|
|
118
|
+
}): JSX.Element;
|
|
119
|
+
/** A radio-style segmented control. */
|
|
120
|
+
export declare function SegmentedControl<T extends string>(props: {
|
|
121
|
+
readonly label: string;
|
|
122
|
+
readonly value: T;
|
|
123
|
+
readonly options: readonly {
|
|
124
|
+
readonly value: T;
|
|
125
|
+
readonly label: string;
|
|
126
|
+
}[];
|
|
127
|
+
readonly onChange: (value: T) => void;
|
|
128
|
+
}): JSX.Element;
|
|
129
|
+
/** Renders a route as a chain of token chips. */
|
|
130
|
+
export declare function RouteSummary(props: {
|
|
131
|
+
readonly tokens: readonly string[];
|
|
132
|
+
readonly detail?: string;
|
|
133
|
+
}): JSX.Element;
|
|
134
|
+
/** An error panel with `role="alert"`. */
|
|
135
|
+
export declare function ErrorPanel(props: {
|
|
136
|
+
readonly error: Error | null;
|
|
137
|
+
readonly context?: "quote" | "swap" | "liquidity" | "transaction";
|
|
138
|
+
}): JSX.Element | null;
|
|
139
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/components/primitives.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMzD,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;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G,MAAM,GAAG,WAAW,GAAG,aAAa,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CASzJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swap settings in a Radix Popover: slippage tolerance (auto, presets, custom)
|
|
3
|
+
* and the high-impact acknowledgement. Nothing here is hidden from the
|
|
4
|
+
* summary: the chosen tolerance is always printed in the details.
|
|
5
|
+
*/
|
|
6
|
+
export interface SwapSettingsProps {
|
|
7
|
+
readonly slippageBps: number;
|
|
8
|
+
readonly defaultSlippageBps: number;
|
|
9
|
+
readonly onSlippageChange: (bps: number) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function SwapSettings(props: SwapSettingsProps): JSX.Element;
|
|
12
|
+
//# sourceMappingURL=SwapSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapSettings.d.ts","sourceRoot":"","sources":["../../../src/components/swap/SwapSettings.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AAUH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAsElE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token selector: a Radix Dialog with search, common tokens, balances for
|
|
3
|
+
* the connected account and paste-an-address lookup through the adapter.
|
|
4
|
+
*
|
|
5
|
+
* Tokens carry their provenance. An entry that came from a token list
|
|
6
|
+
* (`SwapWidget`'s `tokenLists`) is grouped under that list's name and says
|
|
7
|
+
* which other lists also carry it; the adapter's own tokens - the tokens of the
|
|
8
|
+
* pools this site routes through - come first, ungrouped. A tokenised stock
|
|
9
|
+
* (`extensions.stock`) gets an issuer badge, and a REBASING one a warning,
|
|
10
|
+
* because the issuer's control over the token is the thing a trader has to
|
|
11
|
+
* know before choosing it. A pasted address that is in no list is looked up on
|
|
12
|
+
* chain and labelled as unlisted; it is never silently promoted.
|
|
13
|
+
*
|
|
14
|
+
* Portals render INTO the widget root (see `PortalContainer`) rather than
|
|
15
|
+
* `document.body`, so the same component works inside the shadow-root web
|
|
16
|
+
* component, where body-level portals would render unstyled.
|
|
17
|
+
*/
|
|
18
|
+
import type { TokenInfo } from "../../adapters/protocol.js";
|
|
19
|
+
/**
|
|
20
|
+
* A token's logo, or a monogram of its symbol. `https://` loads directly;
|
|
21
|
+
* `ipfs://` resolves through the SDK's first allow-listed gateway; a URL that
|
|
22
|
+
* fails to load falls back to the monogram rather than a broken image.
|
|
23
|
+
*/
|
|
24
|
+
export declare function TokenLogo(props: {
|
|
25
|
+
readonly token: TokenInfo | null;
|
|
26
|
+
readonly size?: number;
|
|
27
|
+
}): JSX.Element;
|
|
28
|
+
/** A stable hue per token (0-359), so a token without a logo is still recognisable at a glance. */
|
|
29
|
+
export declare function hueOf(key: string): number;
|
|
30
|
+
/** The badges a row carries: the issuer of a stock, a rebasing warning, a test-token mark. */
|
|
31
|
+
export declare function TokenBadges(props: {
|
|
32
|
+
readonly token: TokenInfo;
|
|
33
|
+
}): JSX.Element | null;
|
|
34
|
+
/**
|
|
35
|
+
* The read-only form of the selector, for a pinned pair (`SwapWidget`'s
|
|
36
|
+
* `lockPair`): the same chip, the token it shows, no chevron and no dialog.
|
|
37
|
+
* A `<span>`, not a disabled button, so it is not announced as a control that
|
|
38
|
+
* happens to be off; the label says the pair is fixed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function TokenChip(props: {
|
|
41
|
+
readonly value: TokenInfo | null;
|
|
42
|
+
readonly label: string;
|
|
43
|
+
}): JSX.Element;
|
|
44
|
+
export interface TokenSelectProps {
|
|
45
|
+
readonly value: TokenInfo | null;
|
|
46
|
+
readonly tokens: readonly TokenInfo[];
|
|
47
|
+
readonly onChange: (token: TokenInfo) => void;
|
|
48
|
+
/** The other side of the pair, greyed out in the list. */
|
|
49
|
+
readonly exclude?: TokenInfo | null;
|
|
50
|
+
readonly label: string;
|
|
51
|
+
/** Lists that were asked for and did not load, shown as a note so an empty group is explained. */
|
|
52
|
+
readonly listFailures?: readonly {
|
|
53
|
+
readonly url: string;
|
|
54
|
+
readonly message: string;
|
|
55
|
+
}[];
|
|
56
|
+
/** `true` while lists are still loading. */
|
|
57
|
+
readonly listsLoading?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** The trigger button plus its dialog. */
|
|
60
|
+
export declare function TokenSelect(props: TokenSelectProps): JSX.Element;
|
|
61
|
+
//# sourceMappingURL=TokenSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenSelect.d.ts","sourceRoot":"","sources":["../../../src/components/swap/TokenSelect.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAS5D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAkB1G;AAED,mGAAmG;AACnG,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKzC;AAWD,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmBpF;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,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