@tokenflight/swap 0.0.4 → 0.1.2

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.
@@ -0,0 +1,829 @@
1
+ import { ChainInfo } from '@tokenflight/api';
2
+ import { ContractCallDeposit } from '@tokenflight/api';
3
+ import { DEFAULT_API_ENDPOINT } from '@tokenflight/api';
4
+ import { DepositApproval } from '@tokenflight/api';
5
+ import { DepositBuildResponse } from '@tokenflight/api';
6
+ import { EIP1193RequestApproval } from '@tokenflight/api';
7
+ import { ErrorCode } from '@tokenflight/api';
8
+ import { ExactOutMethod } from '@tokenflight/api';
9
+ import { FiatJumpRoute } from '@tokenflight/api';
10
+ import { FiatOrderRequest } from '@tokenflight/api';
11
+ import { FiatOrderResponse } from '@tokenflight/api';
12
+ import { FiatOrderStatus } from '@tokenflight/api';
13
+ import { FiatPaymentMethod } from '@tokenflight/api';
14
+ import { FiatProviderInfo } from '@tokenflight/api';
15
+ import { FiatProvidersResponse } from '@tokenflight/api';
16
+ import { FiatQuoteItem } from '@tokenflight/api';
17
+ import { FiatQuoteRequest } from '@tokenflight/api';
18
+ import { FiatQuoteResponse } from '@tokenflight/api';
19
+ import { FiatQuotesResponse } from '@tokenflight/api';
20
+ import { FiatStatusResponse } from '@tokenflight/api';
21
+ import { OnChainTx } from '@tokenflight/api';
22
+ import { OrderListResponse } from '@tokenflight/api';
23
+ import { OrderResponse } from '@tokenflight/api';
24
+ import { OrderStatus } from '@tokenflight/api';
25
+ import { OrderTimestamps } from '@tokenflight/api';
26
+ import { OrderTransactions } from '@tokenflight/api';
27
+ import { QuoteRequest } from '@tokenflight/api';
28
+ import { QuoteResponse } from '@tokenflight/api';
29
+ import { QuoteRoute } from '@tokenflight/api';
30
+ import { ResolvedToken } from '@tokenflight/api';
31
+ import { RouteQuote } from '@tokenflight/api';
32
+ import { RouteTag } from '@tokenflight/api';
33
+ import { SolanaApproval } from '@tokenflight/api';
34
+ import { SubmitDepositResponse } from '@tokenflight/api';
35
+ import { SwapStrategy } from '@tokenflight/api';
36
+ import { TERMINAL_FIAT_STATUSES } from '@tokenflight/api';
37
+ import { TERMINAL_ORDER_STATUSES } from '@tokenflight/api';
38
+ import { TokenExtensions } from '@tokenflight/api';
39
+ import { TokenFlightError } from '@tokenflight/api';
40
+ import { TokenInfo } from '@tokenflight/api';
41
+ import { TokenListResponse } from '@tokenflight/api';
42
+ import { TokenMeta } from '@tokenflight/api';
43
+ import { TokenSearchResponse } from '@tokenflight/api';
44
+ import { TradeType } from '@tokenflight/api';
45
+
46
+ /**
47
+ * Add thousands separators (commas) to the integer part of a numeric string.
48
+ * e.g., "3200" → "3,200", "1234567.89" → "1,234,567.89", "0.5" → "0.5"
49
+ */
50
+ export declare function addThousandsSeparator(value: string): string;
51
+
52
+ /** Amount change data */
53
+ export declare interface AmountChangedData {
54
+ amount: string;
55
+ direction: "from" | "to";
56
+ }
57
+
58
+ /**
59
+ * Boolean HTML attribute — accepts both native booleans and the
60
+ * string equivalents that `parseBooleanProp()` understands.
61
+ */
62
+ declare type BooleanAttribute = boolean | "true" | "false" | "1" | "0" | "yes" | "no" | "";
63
+
64
+ /**
65
+ * Build offers for ranking from API routes (EXACT_OUTPUT mode).
66
+ * Routes with unparseable amountIn are excluded from ranking.
67
+ */
68
+ export declare function buildOffersForRanking(routes: readonly QuoteRoute[], tradeType: TradeType | null): OfferForRanking[];
69
+
70
+ /** Callback interfaces for widget events */
71
+ export declare interface Callbacks {
72
+ onSwapSuccess?(data: SwapSuccessData): void;
73
+ onSwapError?(data: SwapErrorData): void;
74
+ onWalletConnected?(data: WalletConnectedData): void;
75
+ onQuoteReceived?(data: QuoteResponse): void;
76
+ onAmountChanged?(data: AmountChangedData): void;
77
+ /** Called when user clicks Connect Wallet and no walletAdapter is provided */
78
+ onConnectWallet?(): void;
79
+ /** Called when user clicks the connected wallet address (for custom account modal handling) */
80
+ onAccountModal?(): void;
81
+ /** Called when a fiat order is created and the payment widget URL is available */
82
+ onFiatOrderCreated?(data: {
83
+ orderId: string;
84
+ widgetUrl: string;
85
+ }): void;
86
+ /** Called when a fiat order reaches a terminal status */
87
+ onFiatOrderCompleted?(data: {
88
+ orderId: string;
89
+ status: string;
90
+ txHash?: string;
91
+ }): void;
92
+ /** Called when a deposit completes successfully */
93
+ onDepositSuccess?(data: SwapSuccessData): void;
94
+ /** Called when a deposit fails */
95
+ onDepositError?(data: SwapErrorData): void;
96
+ }
97
+
98
+ export { ChainInfo }
99
+
100
+ /** Chain type for multi-chain support */
101
+ export declare type ChainType = "evm" | "solana";
102
+
103
+ /** Clear all TokenFlight token cache entries */
104
+ export declare function clearTokenCache(): void;
105
+
106
+ /**
107
+ * Compute exchange rate as a display string.
108
+ * Returns how many toToken units you get per 1 fromToken.
109
+ */
110
+ export declare function computeExchangeRate(amountIn: string, decimalsIn: number, amountOut: string, decimalsOut: number): string;
111
+
112
+ export { ContractCallDeposit }
113
+
114
+ /**
115
+ * Custom color overrides — keys are CSS variable names.
116
+ * Typed keys provide autocomplete; arbitrary `--tf-*` strings are also accepted.
117
+ *
118
+ * ```ts
119
+ * customColors: {
120
+ * "--tf-primary": "#FF6B00",
121
+ * "--tf-bg": "#1A1A2E",
122
+ * "--tf-button-radius": "4px",
123
+ * "--tf-widget-max-width": "480px",
124
+ * }
125
+ * ```
126
+ */
127
+ export declare type CustomColors = Partial<Record<TfCssVar, string>> & Record<string, string>;
128
+
129
+ export { DEFAULT_API_ENDPOINT }
130
+
131
+ export { DepositApproval }
132
+
133
+ export { DepositBuildResponse }
134
+
135
+ /** Payment methods available in `<tokenflight-deposit>` */
136
+ export declare type DepositMethod = "wallet" | "card";
137
+
138
+ /** Non-derivable state for `<tokenflight-deposit>`. */
139
+ export declare interface DepositState {
140
+ targetToken: ResolvedToken | null;
141
+ targetAmount: string;
142
+ fromToken: ResolvedToken | null;
143
+ recipient: string | null;
144
+ walletAddress: string | null;
145
+ execPhase: ExecPhase | null;
146
+ order: OrderResponse | null;
147
+ error: string | null;
148
+ errorCode: string | null;
149
+ }
150
+
151
+ /** @deprecated Deposit now uses a flat layout; overlays are boolean signals. Kept for public API compatibility. */
152
+ export declare type DepositView = "entry" | "fixed" | "select-target" | "wallet-pay-with";
153
+
154
+ export { EIP1193RequestApproval }
155
+
156
+ export { ErrorCode }
157
+
158
+ /** EVM wallet action via EIP-1193 */
159
+ export declare interface EvmWalletAction {
160
+ type: "eip1193_request";
161
+ chainId: number;
162
+ method: string;
163
+ params: unknown[];
164
+ }
165
+
166
+ export { ExactOutMethod }
167
+
168
+ /** Execution-only phases for the async build→wallet→submit→track→success flow */
169
+ export declare type ExecPhase = "building" | "awaiting-wallet" | "submitting" | "tracking" | "success";
170
+
171
+ /** Execution-only phases for the fiat flow */
172
+ export declare type FiatExecPhase = "creating-order" | "awaiting-payment" | "tracking" | "success";
173
+
174
+ export { FiatJumpRoute }
175
+
176
+ export { FiatOrderRequest }
177
+
178
+ export { FiatOrderResponse }
179
+
180
+ export { FiatOrderStatus }
181
+
182
+ export { FiatPaymentMethod }
183
+
184
+ /** How the fiat payment provider UI is opened. */
185
+ export declare type FiatPaymentMode = "overlay" | "popup";
186
+
187
+ /** UI phases for the fiat flow (derived from signals + queries) */
188
+ export declare type FiatPhase = "idle" | "quoting" | "quoted" | "creating-order" | "awaiting-payment" | "tracking" | "success" | "error";
189
+
190
+ export { FiatProviderInfo }
191
+
192
+ export { FiatProvidersResponse }
193
+
194
+ export { FiatQuoteItem }
195
+
196
+ export { FiatQuoteRequest }
197
+
198
+ export { FiatQuoteResponse }
199
+
200
+ export { FiatQuotesResponse }
201
+
202
+ export { FiatStatusResponse }
203
+
204
+ /**
205
+ * Format a display amount to a fixed number of significant decimals.
206
+ * Avoids showing excessive precision in the UI.
207
+ *
208
+ * When the integer part is "0", ensures at least `maxDecimals` significant
209
+ * digits are shown (e.g., "0.00472" → "0.0047" with maxDecimals=2).
210
+ */
211
+ export declare function formatDisplayAmount(amount: string, maxDecimals?: number): string;
212
+
213
+ /** Get the best overall route ID for exact output. */
214
+ export declare function getBestOverallRouteId(routes: readonly QuoteRoute[], tradeType: TradeType | null): string | null;
215
+
216
+ /** Get chain type from chainId */
217
+ export declare function getChainType(chainId: number): "evm" | "solana";
218
+
219
+ declare interface ImperativeWidgetOptions<TConfig> {
220
+ container: string | HTMLElement;
221
+ config: TConfig;
222
+ walletAdapter?: IWalletAdapter;
223
+ callbacks?: Callbacks;
224
+ }
225
+
226
+ /** Check if two chains are of different types (cross-chain swap) */
227
+ export declare function isCrossChainSwap(fromChainId: number, toChainId: number): boolean;
228
+
229
+ /** Check if a chainId is EVM */
230
+ export declare function isEvmChain(chainId: number): boolean;
231
+
232
+ /** Check if a chainId is Solana */
233
+ export declare function isSolanaChain(chainId: number): boolean;
234
+
235
+ /** Wallet adapter interface that all adapters must implement */
236
+ export declare interface IWalletAdapter {
237
+ /** Human-readable name */
238
+ readonly name: string;
239
+ /** Icon URL */
240
+ readonly icon?: string;
241
+ /** Supported action types */
242
+ readonly supportedActionTypes: WalletActionType[];
243
+ /** Optional: supported chain IDs — when set, the widget only shows tokens on these chains */
244
+ readonly supportedChainIds?: number[];
245
+ /** Connect the wallet */
246
+ connect(chainType?: ChainType): Promise<void>;
247
+ /** Disconnect the wallet */
248
+ disconnect(): Promise<void>;
249
+ /** Check if connected */
250
+ isConnected(chainType?: ChainType): boolean;
251
+ /** Get the current address */
252
+ getAddress(chainType?: ChainType): Promise<string | null>;
253
+ /** Execute a wallet action */
254
+ executeWalletAction(action: WalletAction): Promise<WalletActionResult>;
255
+ /** Optional: sign a message */
256
+ signMessage?(message: string, chainType?: ChainType): Promise<string>;
257
+ /** Optional: open the wallet's native account/connected modal */
258
+ openAccountModal?(): Promise<void>;
259
+ /** Optional: clean up internal subscriptions and watchers */
260
+ destroy?(): void;
261
+ /** Subscribe to wallet events */
262
+ on(event: WalletEventType, handler: (event: WalletEvent) => void): void;
263
+ /** Unsubscribe from wallet events */
264
+ off(event: WalletEventType, handler: (event: WalletEvent) => void): void;
265
+ }
266
+
267
+ export declare class MockWalletAdapter implements IWalletAdapter {
268
+ readonly name = "Mock Wallet";
269
+ readonly icon: undefined;
270
+ readonly supportedActionTypes: WalletActionType[];
271
+ private connected;
272
+ private address;
273
+ private listeners;
274
+ connect(_chainType?: ChainType): Promise<void>;
275
+ disconnect(): Promise<void>;
276
+ isConnected(_chainType?: ChainType): boolean;
277
+ getAddress(_chainType?: ChainType): Promise<string | null>;
278
+ executeWalletAction(_action: WalletAction): Promise<WalletActionResult>;
279
+ signMessage(_message: string): Promise<string>;
280
+ openAccountModal(): Promise<void>;
281
+ on(event: WalletEventType, handler: (event: WalletEvent) => void): void;
282
+ off(event: WalletEventType, handler: (event: WalletEvent) => void): void;
283
+ private emit;
284
+ }
285
+
286
+ /**
287
+ * Minimal offer data needed for ranking offers.
288
+ * For offers (EXACT_OUTPUT): lower amountIn is better.
289
+ */
290
+ declare interface OfferForRanking {
291
+ routeId: string;
292
+ amountIn: bigint;
293
+ etaSeconds: number;
294
+ isGuaranteedOutput: boolean;
295
+ isOneClick: boolean;
296
+ }
297
+
298
+ export { OnChainTx }
299
+
300
+ export { OrderListResponse }
301
+
302
+ export { OrderResponse }
303
+
304
+ export { OrderStatus }
305
+
306
+ export { OrderTimestamps }
307
+
308
+ export { OrderTransactions }
309
+
310
+ export { QuoteRequest }
311
+
312
+ export { QuoteResponse }
313
+
314
+ export { QuoteRoute }
315
+
316
+ /**
317
+ * Rank offers where lower input amount is better (EXACT_OUTPUT).
318
+ *
319
+ * Same algorithm as rankSwapOffers but inverted:
320
+ * best price = lowest amountIn, threshold = lowestAmountIn * 1.001
321
+ */
322
+ export declare function rankOffers(offers: readonly OfferForRanking[]): string[];
323
+
324
+ /** Receive component mode: crypto-only, fiat-only, or both */
325
+ export declare type ReceiveMode = "crypto" | "fiat" | "all";
326
+
327
+ /**
328
+ * Non-derivable state for `<tokenflight-receive>`.
329
+ *
330
+ * Derivable values (phase, selectedQuote, paymentTokens) are computed in
331
+ * ReceiveComponent from payTokenQuotes + loadingQuotes + these signals.
332
+ */
333
+ export declare interface ReceiveState {
334
+ targetToken: ResolvedToken | null;
335
+ targetAmount: string;
336
+ /** Set before execution starts for TransactionComplete display */
337
+ fromToken: ResolvedToken | null;
338
+ /** Recipient address for cross-chain swaps */
339
+ recipient: string | null;
340
+ walletAddress: string | null;
341
+ /** Current execution phase, or null when idle/quoting/quoted */
342
+ execPhase: ExecPhase | null;
343
+ order: OrderResponse | null;
344
+ error: string | null;
345
+ errorCode: string | null;
346
+ }
347
+
348
+ declare function registerDepositElement(options?: RegisterElementsOptions): void;
349
+ export { registerDepositElement }
350
+ export { registerDepositElement as registerFiatElement }
351
+ export { registerDepositElement as registerReceiveElement }
352
+
353
+ export declare function registerElements(options?: RegisterElementsOptions): void;
354
+
355
+ export declare interface RegisterElementsOptions {
356
+ walletAdapter?: IWalletAdapter;
357
+ callbacks?: Callbacks;
358
+ /** Custom CSS variable overrides merged on top of the active theme.
359
+ * Keys are CSS variable names, e.g. `"--tf-primary"`, `"--tf-font-family"`. */
360
+ customColors?: CustomColors;
361
+ /** Default API endpoint for all widget instances. */
362
+ apiEndpoint?: string;
363
+ /** Default theme for all widget instances. */
364
+ theme?: Theme;
365
+ /** Default locale for all widget instances. */
366
+ locale?: SupportedLocale;
367
+ }
368
+
369
+ export declare function registerSwapElement(options?: RegisterElementsOptions): void;
370
+
371
+ export declare function registerWidgetElement(options?: RegisterElementsOptions): void;
372
+
373
+ export { ResolvedToken }
374
+
375
+ export { RouteQuote }
376
+
377
+ export { RouteTag }
378
+
379
+ /** Chain ID for Solana mainnet in the API */
380
+ export declare const SOLANA_CHAIN_ID = 20011000000;
381
+
382
+ export { SolanaApproval }
383
+
384
+ /** Solana sign and send transaction action */
385
+ export declare interface SolanaSignAndSendAction {
386
+ type: "solana_signAndSendTransaction";
387
+ transaction: string;
388
+ }
389
+
390
+ /** Solana sign transaction action */
391
+ export declare interface SolanaSignTransactionAction {
392
+ type: "solana_signTransaction";
393
+ transaction: string;
394
+ }
395
+
396
+ export { SubmitDepositResponse }
397
+
398
+ /** Supported locale identifiers. Accepts any string for forward-compat; known values get bundled translations. */
399
+ export declare type SupportedLocale = "en-US" | "zh-CN" | "zh-TW" | "ja-JP" | "ko-KR" | (string & {});
400
+
401
+ /** Data emitted on swap error */
402
+ export declare interface SwapErrorData {
403
+ code: string;
404
+ message: string;
405
+ details?: unknown;
406
+ }
407
+
408
+ /** Swap flow phases */
409
+ export declare type SwapPhase = "idle" | "quoting" | "quoted" | "building" | "awaiting-wallet" | "submitting" | "tracking" | "success" | "error";
410
+
411
+ export { SwapStrategy }
412
+
413
+ /** Data emitted on swap success */
414
+ export declare interface SwapSuccessData {
415
+ orderId: string;
416
+ fromToken: string;
417
+ toToken: string;
418
+ fromAmount: string;
419
+ toAmount: string;
420
+ txHash: string;
421
+ }
422
+
423
+ export { TERMINAL_FIAT_STATUSES }
424
+
425
+ export { TERMINAL_ORDER_STATUSES }
426
+
427
+ /** All first-party CSS custom properties exposed for theming. */
428
+ declare type TfCssVar = "--tf-bg" | "--tf-bg-secondary" | "--tf-bg-elevated" | "--tf-surface" | "--tf-surface-hover" | "--tf-input-bg" | "--tf-glass" | "--tf-text" | "--tf-text-secondary" | "--tf-text-tertiary" | "--tf-text-on-primary" | "--tf-border" | "--tf-border-light" | "--tf-primary" | "--tf-primary-alpha" | "--tf-primary-light" | "--tf-primary-glow" | "--tf-success" | "--tf-success-bg" | "--tf-error" | "--tf-error-bg" | "--tf-error-alpha" | "--tf-warning" | "--tf-warning-bg" | "--tf-shadow" | "--tf-shadow-lg" | "--tf-skeleton" | "--tf-radius-xs" | "--tf-radius-sm" | "--tf-radius" | "--tf-radius-lg" | "--tf-radius-xl" | "--tf-button-radius" | "--tf-widget-max-width" | "--tf-font-family" | "--tf-font-family-mono";
429
+
430
+ /** Visual theme mode. */
431
+ export declare type Theme = "light" | "dark" | "auto";
432
+
433
+ /**
434
+ * Convert display amount to base units (bigint string) using token decimals.
435
+ * e.g., toBaseUnits("1", 6) → "1000000"
436
+ * toBaseUnits("1.5", 6) → "1500000"
437
+ */
438
+ export declare function toBaseUnits(displayAmount: string, decimals: number): string;
439
+
440
+ /**
441
+ * Convert base units (bigint string) to display amount using token decimals.
442
+ * e.g., toDisplayAmount("1000000", 6) → "1"
443
+ * toDisplayAmount("1500000", 6) → "1.5"
444
+ */
445
+ export declare function toDisplayAmount(baseUnits: string, decimals: number): string;
446
+
447
+ export { TokenExtensions }
448
+
449
+ /** Shared configuration fields for both widgets */
450
+ export declare interface TokenFlightConfigBase {
451
+ /** HyperStream API endpoint */
452
+ apiEndpoint?: string;
453
+ /** Fiat on-ramp API endpoint (default: https://fiat-preview.hyperstream.dev) */
454
+ fiatApiEndpoint?: string;
455
+ /** Visual theme */
456
+ theme?: Theme;
457
+ /** Locale for i18n */
458
+ locale?: SupportedLocale;
459
+ /** Custom CSS color overrides */
460
+ customColors?: CustomColors;
461
+ /** Optional custom widget title text */
462
+ titleText?: string;
463
+ /** Optional custom widget title image URL */
464
+ titleImageUrl?: string;
465
+ /** Hide top title/header area */
466
+ hideTitle?: boolean;
467
+ /** Hide "Powered by TokenFlight" footer */
468
+ hidePoweredBy?: boolean;
469
+ /** Remove container background (transparent) */
470
+ noBackground?: boolean;
471
+ /** Remove container border and shadow */
472
+ noBorder?: boolean;
473
+ }
474
+
475
+ declare const TokenFlightDeposit: {
476
+ new (options: ImperativeWidgetOptions<TokenFlightDepositConfig>): {
477
+ #dispose: (() => void) | null;
478
+ #unwatchTheme: (() => void) | null;
479
+ #container: HTMLElement;
480
+ #shadowRoot: ShadowRoot | null;
481
+ #config: TokenFlightDepositConfig;
482
+ #walletAdapter?: IWalletAdapter;
483
+ #callbacks?: Callbacks;
484
+ initialize(): void;
485
+ destroy(): void;
486
+ setTheme(theme: Theme): void;
487
+ setCustomColors(colors: CustomColors): void;
488
+ #applyThemeStyles(style: HTMLStyleElement, theme: string): void;
489
+ #setupAutoThemeWatch(style: HTMLStyleElement): void;
490
+ };
491
+ };
492
+ export { TokenFlightDeposit }
493
+ export { TokenFlightDeposit as TokenFlightFiat }
494
+ export { TokenFlightDeposit as TokenFlightReceive }
495
+
496
+ /** Attributes accepted by `<tokenflight-deposit>`. */
497
+ export declare interface TokenFlightDepositAttributes {
498
+ "api-endpoint"?: string;
499
+ target?: string;
500
+ amount?: string;
501
+ "from-token"?: string;
502
+ recipient?: string;
503
+ methods?: string;
504
+ "target-icon"?: string;
505
+ "fiat-currency"?: string;
506
+ "fiat-payment-mode"?: string;
507
+ "title-text"?: string;
508
+ "title-image"?: string;
509
+ theme?: Theme;
510
+ locale?: SupportedLocale;
511
+ "csp-nonce"?: string;
512
+ "hide-title"?: BooleanAttribute;
513
+ "hide-powered-by"?: BooleanAttribute;
514
+ "no-background"?: BooleanAttribute;
515
+ "no-border"?: BooleanAttribute;
516
+ }
517
+
518
+ /** Configuration for `<tokenflight-deposit>` */
519
+ export declare interface TokenFlightDepositConfig extends TokenFlightConfigBase {
520
+ /** Target token(s) to deposit into. When omitted, user selects via TokenSelector. */
521
+ target?: TokenIdentifier | TokenIdentifier[];
522
+ /** Optional: fixed amount for the target token */
523
+ amount?: string;
524
+ /** Optional: recipient address */
525
+ recipient?: string;
526
+ /** Payment methods to offer (default: ["wallet"]) */
527
+ methods?: DepositMethod[];
528
+ /** Optional source token to pay with */
529
+ fromToken?: TokenIdentifier;
530
+ /** Optional icon URL for the target token */
531
+ targetIcon?: string;
532
+ /** Fiat currency code for card payments (default: "USD") */
533
+ fiatCurrency?: string;
534
+ /** How to open the fiat payment provider (default: "overlay") */
535
+ fiatPaymentMode?: FiatPaymentMode;
536
+ }
537
+
538
+ export declare interface TokenFlightDepositOptions {
539
+ container: string | HTMLElement;
540
+ config: TokenFlightDepositConfig;
541
+ walletAdapter?: IWalletAdapter;
542
+ callbacks?: Callbacks;
543
+ }
544
+
545
+ export { TokenFlightError }
546
+
547
+ /** Attributes accepted by `<tokenflight-fiat>`. */
548
+ export declare interface TokenFlightFiatAttributes {
549
+ "api-endpoint"?: string;
550
+ target?: string;
551
+ recipient?: string;
552
+ "fiat-currency"?: string;
553
+ "title-text"?: string;
554
+ "title-image"?: string;
555
+ theme?: Theme;
556
+ locale?: SupportedLocale;
557
+ "csp-nonce"?: string;
558
+ icon?: string;
559
+ "hide-title"?: BooleanAttribute;
560
+ "hide-powered-by"?: BooleanAttribute;
561
+ "no-background"?: BooleanAttribute;
562
+ "no-border"?: BooleanAttribute;
563
+ }
564
+
565
+ /**
566
+ * @deprecated Use `TokenFlightDepositConfig` instead.
567
+ *
568
+ * Configuration for `<tokenflight-fiat>`
569
+ */
570
+ export declare interface TokenFlightFiatConfig extends TokenFlightConfigBase {
571
+ /** Optional: target token to purchase (user can select via TokenSelector if omitted) */
572
+ target?: TokenIdentifier;
573
+ /** Optional recipient address (if not using connected wallet) */
574
+ recipient?: string;
575
+ /** Fiat currency code (default: "USD") */
576
+ fiatCurrency?: string;
577
+ /** Optional icon URL for the target token */
578
+ icon?: string;
579
+ /** How to open the payment provider: "overlay" (iframe modal, default) or "popup" (new window). */
580
+ paymentMode?: FiatPaymentMode;
581
+ }
582
+
583
+ export declare interface TokenFlightFiatOptions {
584
+ container: string | HTMLElement;
585
+ config: TokenFlightFiatConfig;
586
+ walletAdapter?: IWalletAdapter;
587
+ callbacks?: Callbacks;
588
+ }
589
+
590
+ /** Attributes accepted by `<tokenflight-receive>`. */
591
+ export declare interface TokenFlightReceiveAttributes {
592
+ "api-endpoint"?: string;
593
+ target?: string;
594
+ amount?: string;
595
+ "from-token"?: string;
596
+ recipient?: string;
597
+ "title-text"?: string;
598
+ "title-image"?: string;
599
+ theme?: Theme;
600
+ locale?: SupportedLocale;
601
+ "csp-nonce"?: string;
602
+ icon?: string;
603
+ "hide-title"?: BooleanAttribute;
604
+ "hide-powered-by"?: BooleanAttribute;
605
+ "no-background"?: BooleanAttribute;
606
+ "no-border"?: BooleanAttribute;
607
+ }
608
+
609
+ /** Configuration for the Receive component (EXACT_OUTPUT UX) */
610
+ export declare interface TokenFlightReceiveConfig extends TokenFlightConfigBase {
611
+ /** Target token to receive (optional — user can select via TokenSelector if omitted) */
612
+ target?: TokenIdentifier;
613
+ /** Amount to receive (optional when amountEditable is true) */
614
+ amount?: string;
615
+ /** Optional source token to pay with */
616
+ fromToken?: TokenIdentifier;
617
+ /** Optional recipient address (for cross-chain swaps to a different address) */
618
+ recipient?: string;
619
+ /** Optional icon URL for the target token */
620
+ icon?: string;
621
+ /** Payment methods to offer (default: ["crypto"]) */
622
+ methods?: ("crypto" | "card")[];
623
+ /** Fiat currency code for card payments (default: "USD") */
624
+ fiatCurrency?: string;
625
+ /** How to open the fiat payment provider (default: "overlay") */
626
+ fiatPaymentMode?: FiatPaymentMode;
627
+ /** Allow user to edit the receive amount */
628
+ amountEditable?: boolean;
629
+ /** Whitelist of allowed source tokens (CAIP-10) */
630
+ fromTokens?: TokenIdentifier[];
631
+ /** Whitelist of allowed destination tokens (CAIP-10) */
632
+ toTokens?: TokenIdentifier[];
633
+ }
634
+
635
+ export declare interface TokenFlightReceiveOptions {
636
+ container: string | HTMLElement;
637
+ config: TokenFlightReceiveConfig;
638
+ walletAdapter?: IWalletAdapter;
639
+ callbacks?: Callbacks;
640
+ }
641
+
642
+ export declare const TokenFlightSwap: {
643
+ new (options: ImperativeWidgetOptions<TokenFlightSwapConfig>): {
644
+ #dispose: (() => void) | null;
645
+ #unwatchTheme: (() => void) | null;
646
+ #container: HTMLElement;
647
+ #shadowRoot: ShadowRoot | null;
648
+ #config: TokenFlightSwapConfig;
649
+ #walletAdapter?: IWalletAdapter;
650
+ #callbacks?: Callbacks;
651
+ initialize(): void;
652
+ destroy(): void;
653
+ setTheme(theme: Theme): void;
654
+ setCustomColors(colors: CustomColors): void;
655
+ #applyThemeStyles(style: HTMLStyleElement, theme: string): void;
656
+ #setupAutoThemeWatch(style: HTMLStyleElement): void;
657
+ };
658
+ };
659
+
660
+ /** Attributes accepted by `<tokenflight-swap>`. */
661
+ export declare interface TokenFlightSwapAttributes {
662
+ "api-endpoint"?: string;
663
+ "from-token"?: string;
664
+ "to-token"?: string;
665
+ recipient?: string;
666
+ "title-text"?: string;
667
+ "title-image"?: string;
668
+ theme?: Theme;
669
+ locale?: SupportedLocale;
670
+ "csp-nonce"?: string;
671
+ "hide-title"?: BooleanAttribute;
672
+ "hide-powered-by"?: BooleanAttribute;
673
+ "no-background"?: BooleanAttribute;
674
+ "no-border"?: BooleanAttribute;
675
+ }
676
+
677
+ /** Configuration for `<tokenflight-swap>` */
678
+ export declare interface TokenFlightSwapConfig extends TokenFlightConfigBase {
679
+ /** Optional source token */
680
+ fromToken?: TokenIdentifier;
681
+ /** Optional destination token */
682
+ toToken?: TokenIdentifier;
683
+ /** Optional recipient address (for cross-chain swaps to a different address) */
684
+ recipient?: string;
685
+ }
686
+
687
+ export declare interface TokenFlightSwapOptions {
688
+ container: string | HTMLElement;
689
+ config: TokenFlightSwapConfig;
690
+ walletAdapter?: IWalletAdapter;
691
+ callbacks?: Callbacks;
692
+ }
693
+
694
+ export declare const TokenFlightWidget: {
695
+ new (options: ImperativeWidgetOptions<TokenFlightWidgetConfig>): {
696
+ #dispose: (() => void) | null;
697
+ #unwatchTheme: (() => void) | null;
698
+ #container: HTMLElement;
699
+ #shadowRoot: ShadowRoot | null;
700
+ #config: TokenFlightWidgetConfig;
701
+ #walletAdapter?: IWalletAdapter;
702
+ #callbacks?: Callbacks;
703
+ initialize(): void;
704
+ destroy(): void;
705
+ setTheme(theme: Theme): void;
706
+ setCustomColors(colors: CustomColors): void;
707
+ #applyThemeStyles(style: HTMLStyleElement, theme: string): void;
708
+ #setupAutoThemeWatch(style: HTMLStyleElement): void;
709
+ };
710
+ };
711
+
712
+ /** Attributes accepted by `<tokenflight-widget>`. */
713
+ export declare interface TokenFlightWidgetAttributes {
714
+ "api-endpoint"?: string;
715
+ "fiat-api-endpoint"?: string;
716
+ "to-token"?: string;
717
+ "from-token"?: string;
718
+ "trade-type"?: string;
719
+ amount?: string;
720
+ recipient?: string;
721
+ icon?: string;
722
+ "lock-from-token"?: BooleanAttribute;
723
+ "lock-to-token"?: BooleanAttribute;
724
+ "fiat-currency"?: string;
725
+ "fiat-payment-mode"?: string;
726
+ methods?: string;
727
+ "default-pay-method"?: "crypto" | "card";
728
+ "from-tokens"?: string;
729
+ "to-tokens"?: string;
730
+ "title-text"?: string;
731
+ "title-image"?: string;
732
+ theme?: Theme;
733
+ locale?: SupportedLocale;
734
+ "csp-nonce"?: string;
735
+ "hide-title"?: BooleanAttribute;
736
+ "hide-powered-by"?: BooleanAttribute;
737
+ "no-background"?: BooleanAttribute;
738
+ "no-border"?: BooleanAttribute;
739
+ }
740
+
741
+ /** Configuration for Widget component (auto-selects SwapV2 or Deposit UX based on config) */
742
+ export declare interface TokenFlightWidgetConfig extends TokenFlightConfigBase {
743
+ /** Optional source token (crypto tab) */
744
+ fromToken?: TokenIdentifier;
745
+ /** Destination token(s) — array for launchpad multi-select */
746
+ toToken?: TokenIdentifier | TokenIdentifier[];
747
+ /** Trade direction: "EXACT_INPUT" (default) or "EXACT_OUTPUT" */
748
+ tradeType?: "EXACT_INPUT" | "EXACT_OUTPUT";
749
+ /** Amount value — interpreted as input or output based on tradeType */
750
+ amount?: string;
751
+ /** Optional recipient address */
752
+ recipient?: string;
753
+ /** Fiat currency code for card payments (default: "USD") */
754
+ fiatCurrency?: string;
755
+ /** How to open the fiat payment provider (default: "overlay") */
756
+ fiatPaymentMode?: FiatPaymentMode;
757
+ /** Whitelist of allowed source tokens (CAIP-10) */
758
+ fromTokens?: TokenIdentifier[];
759
+ /** Whitelist of allowed destination tokens (CAIP-10) */
760
+ toTokens?: TokenIdentifier[];
761
+ /** Optional icon URL for target token */
762
+ icon?: string;
763
+ /** Lock the from-token selector (disable changing) */
764
+ lockFromToken?: boolean;
765
+ /** Lock the to-token selector (disable changing) */
766
+ lockToToken?: boolean;
767
+ }
768
+
769
+ export declare interface TokenFlightWidgetOptions {
770
+ container: string | HTMLElement;
771
+ config: TokenFlightWidgetConfig;
772
+ walletAdapter?: IWalletAdapter;
773
+ callbacks?: Callbacks;
774
+ }
775
+
776
+ /**
777
+ * Flexible token identifier supporting:
778
+ * - Direct object: { chainId: 1, address: "0x..." }
779
+ * - CAIP-10 string: "eip155:1:0x..."
780
+ * - JSON string: '{"chainId":1,"address":"0x..."}'
781
+ */
782
+ export declare type TokenIdentifier = string | TokenTarget;
783
+
784
+ export { TokenInfo }
785
+
786
+ export { TokenListResponse }
787
+
788
+ export { TokenMeta }
789
+
790
+ export { TokenSearchResponse }
791
+
792
+ /** Token target as chain + address pair */
793
+ export declare interface TokenTarget {
794
+ chainId: number;
795
+ address: string;
796
+ }
797
+
798
+ export { TradeType }
799
+
800
+ /** Union of all wallet action types */
801
+ export declare type WalletAction = EvmWalletAction | SolanaSignTransactionAction | SolanaSignAndSendAction;
802
+
803
+ /** Result of executing a wallet action */
804
+ export declare interface WalletActionResult {
805
+ success: boolean;
806
+ data?: unknown;
807
+ error?: string;
808
+ txHash?: string;
809
+ }
810
+
811
+ /** Wallet action types */
812
+ export declare type WalletActionType = "eip1193_request" | "solana_signTransaction" | "solana_signAndSendTransaction";
813
+
814
+ /** Data emitted when wallet is connected */
815
+ export declare interface WalletConnectedData {
816
+ address: string;
817
+ chainType: string;
818
+ }
819
+
820
+ /** Wallet event payload */
821
+ export declare interface WalletEvent {
822
+ type: WalletEventType;
823
+ data?: unknown;
824
+ }
825
+
826
+ /** Wallet event types */
827
+ export declare type WalletEventType = "connect" | "disconnect" | "chainChanged" | "accountsChanged";
828
+
829
+ export { }