@tokenflight/swap 0.3.0-rc.0 → 0.3.0-rc.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.
Files changed (43) hide show
  1. package/dist/ReceiveComponent-DIJ4BGPQ.js +1 -0
  2. package/dist/ReceiveComponent.module-DpNu0IXq.js +1 -0
  3. package/dist/SwapComponent-BUaJEHfz.js +1 -0
  4. package/dist/bridge-Bq0QUltI.js +1 -0
  5. package/dist/bridge.d.ts +66 -1
  6. package/dist/bridge.js +1 -1
  7. package/dist/custom-elements.d.ts +1 -27
  8. package/dist/defaults-loader-DfcaO9j5.js +1 -0
  9. package/dist/en-US-CU2aSy93.js +1 -0
  10. package/dist/errors-BZKSEUy5.js +3 -0
  11. package/dist/iframe-entry.d.ts +21 -0
  12. package/dist/iframe-entry.js +29 -0
  13. package/dist/iframe-receiver-PfhKUIZW.js +1 -0
  14. package/dist/iframe.d.ts +127 -10
  15. package/dist/iframe.js +45 -1
  16. package/dist/ja-JP-BoipV6-j.js +1 -0
  17. package/dist/ko-KR-DyFXZJsF.js +1 -0
  18. package/dist/protocol-CDxgudrl.js +1 -0
  19. package/dist/rank-offers-Dt1Mvbrr.js +1 -0
  20. package/dist/register-defaults-C_q7CG7x.js +1 -0
  21. package/dist/register-widget-BrN4UxSU.js +1 -0
  22. package/dist/shared.module-C-kWMzqW.js +1 -0
  23. package/dist/solid-iWr5Czxc.js +1 -0
  24. package/dist/swap.css +1 -1
  25. package/dist/theme-C9tsVWlo.js +2 -0
  26. package/dist/tokenflight-swap.d.ts +137 -250
  27. package/dist/tokenflight-swap.js +1 -2
  28. package/dist/tokenflight-swap.umd.cjs +5 -6
  29. package/dist/widget-DQLVNkNn.js +2 -0
  30. package/dist/widget.d.ts +356 -25
  31. package/dist/widget.js +1 -1
  32. package/dist/zh-CN-epCUm9Io.js +1 -0
  33. package/dist/zh-TW-DSEboEJV.js +1 -0
  34. package/package.json +6 -2
  35. package/dist/bridge-C9uFKAdS.js +0 -1
  36. package/dist/en-US-ChmhdVUe.js +0 -1
  37. package/dist/ja-JP-BAX9fLqV.js +0 -1
  38. package/dist/ko-KR-jwhmhUqJ.js +0 -1
  39. package/dist/register-defaults-lIJMUU-P.js +0 -1
  40. package/dist/register-widget-DQAzucnZ.js +0 -5
  41. package/dist/zh-CN-fKcRI4Y8.js +0 -1
  42. package/dist/zh-TW-gFEUAIR6.js +0 -1
  43. /package/dist/{active-bridge-DTyKObda.js → active-bridge-V8lTJ2Js.js} +0 -0
@@ -18,6 +18,25 @@ import { TERMINAL_ORDER_STATUSES } from '@tokenflight/api';
18
18
  import { TokenFlightError } from '@tokenflight/api';
19
19
  import * as v from 'valibot';
20
20
 
21
+ /**
22
+ * Parameters for the EIP-3085 `wallet_addEthereumChain` request. Returned by
23
+ * adapters that know the chain's RPC/native-currency metadata so the widget
24
+ * can recover from Coinbase Wallet's "Unrecognized chain" failure by adding
25
+ * the chain before retrying the switch.
26
+ */
27
+ export declare interface AddEthereumChainParameters {
28
+ chainId: string;
29
+ chainName: string;
30
+ nativeCurrency: {
31
+ name: string;
32
+ symbol: string;
33
+ decimals: number;
34
+ };
35
+ rpcUrls: string[];
36
+ blockExplorerUrls?: string[];
37
+ iconUrls?: string[];
38
+ }
39
+
21
40
  /**
22
41
  * Add thousands separators (commas) to the integer part of a numeric string.
23
42
  * e.g., "3200" → "3,200", "1234567.89" → "1,234,567.89", "0.5" → "0.5"
@@ -42,9 +61,24 @@ declare type BooleanAttribute = boolean | "true" | "false" | "1" | "0" | "yes" |
42
61
  */
43
62
  export declare function buildOffersForRanking(routes: readonly QuoteRoute[], tradeType: TradeType | null): OfferForRanking[];
44
63
 
45
- /** Callback interfaces for widget events */
64
+ /**
65
+ * Callback interfaces for widget events.
66
+ *
67
+ * **Crypto outcome routing** (mutually exclusive — pick the channel that matches
68
+ * the active flow):
69
+ * - `EXACT_INPUT` (`<tokenflight-widget trade-type="EXACT_INPUT">` / default,
70
+ * "spend exactly N of X") → fires `onSwapSuccess` / `onSwapError`
71
+ * - `EXACT_OUTPUT` (`<tokenflight-widget trade-type="EXACT_OUTPUT">`,
72
+ * "receive exactly N of Y") → fires `onDepositSuccess` / `onDepositError`
73
+ *
74
+ * **Fiat (card) outcomes** route through the same `onSwap*` / `onDeposit*`
75
+ * channels for errors (matched to the host flow) and through
76
+ * `onFiatOrderCreated` / `onFiatOrderCompleted` for fiat-specific lifecycle.
77
+ */
46
78
  export declare interface Callbacks {
79
+ /** EXACT_INPUT crypto success. */
47
80
  onSwapSuccess?(data: SwapSuccessData): void;
81
+ /** EXACT_INPUT errors (crypto execution + card flow when in EXACT_INPUT mode). */
48
82
  onSwapError?(data: SwapErrorData): void;
49
83
  onWalletConnected?(data: WalletConnectedData): void;
50
84
  onQuoteReceived?(data: QuoteResponse): void;
@@ -64,9 +98,9 @@ export declare interface Callbacks {
64
98
  status: string;
65
99
  txHash?: string;
66
100
  }): void;
67
- /** Called when a deposit completes successfully */
101
+ /** EXACT_OUTPUT crypto success. */
68
102
  onDepositSuccess?(data: SwapSuccessData): void;
69
- /** Called when a deposit fails */
103
+ /** EXACT_OUTPUT errors (crypto execution + card flow when in EXACT_OUTPUT mode). */
70
104
  onDepositError?(data: SwapErrorData): void;
71
105
  }
72
106
 
@@ -107,25 +141,6 @@ export declare type DepositApproval = HyperstreamApi.Approval;
107
141
 
108
142
  export declare type DepositBuildResponse = HyperstreamApi.Deposit;
109
143
 
110
- /** Payment methods available in `<tokenflight-deposit>` */
111
- export declare type DepositMethod = "wallet" | "card";
112
-
113
- /** Non-derivable state for `<tokenflight-deposit>`. */
114
- export declare interface DepositState {
115
- targetToken: ResolvedToken | null;
116
- targetAmount: string;
117
- fromToken: ResolvedToken | null;
118
- recipient: string | null;
119
- walletAddress: string | null;
120
- execPhase: ExecPhase | null;
121
- order: OrderResponse | null;
122
- error: string | null;
123
- errorCode: string | null;
124
- }
125
-
126
- /** @deprecated Deposit now uses a flat layout; overlays are boolean signals. Kept for public API compatibility. */
127
- export declare type DepositView = "entry" | "fixed" | "select-target" | "wallet-pay-with";
128
-
129
144
  export declare type EIP1193RequestApproval = HyperstreamApi.EIP1193RequestApproval;
130
145
 
131
146
  /**
@@ -220,16 +235,6 @@ export declare function getBestOverallRouteId(routes: readonly QuoteRoute[], tra
220
235
  /** Get chain type from chainId */
221
236
  export declare function getChainType(chainId: number): "evm" | "solana";
222
237
 
223
- /**
224
- * Fetch and parse the shared `defaults.json` payload. Memoized — subsequent
225
- * calls return the same in-flight or resolved promise.
226
- *
227
- * Silently resolves to `null` on any failure (network error, non-2xx status,
228
- * parse error, schema mismatch, timeout). Host code is expected to fall back
229
- * to hardcoded defaults when `null` is returned.
230
- */
231
- export declare function getDefaults(): Promise<WidgetDefaults | null>;
232
-
233
238
  declare interface ImperativeWidgetOptions<TConfig> {
234
239
  container: string | HTMLElement;
235
240
  config: TConfig;
@@ -270,6 +275,22 @@ export declare interface IWalletAdapter {
270
275
  signMessage?(message: string, chainType?: ChainType): Promise<string>;
271
276
  /** Optional: open the wallet's native account/connected modal */
272
277
  openAccountModal?(): Promise<void>;
278
+ /**
279
+ * Optional: return `wallet_addEthereumChain` parameters for the given
280
+ * chain, or `undefined` if unknown. Used by the switch-chain fallback to
281
+ * recover from Coinbase Wallet's `-32603` "Unrecognized chain" response
282
+ * (see coinbase/coinbase-wallet-sdk#915) by adding the chain before
283
+ * retrying the switch.
284
+ */
285
+ getAddEthereumChainParams?(chainId: number): AddEthereumChainParameters | undefined;
286
+ /**
287
+ * Optional: read-only, side-effect-free probe for the wallet's current
288
+ * chain ID. MUST NOT trigger a chain switch or any user-facing prompt.
289
+ * Returns `null` if the current chain cannot be determined (e.g. not
290
+ * connected). Used by `safeSwitchChain` to skip no-op switches without
291
+ * opening a wallet prompt first.
292
+ */
293
+ getCurrentChainId?(): Promise<bigint | null>;
273
294
  /** Optional: clean up internal subscriptions and watchers */
274
295
  destroy?(): void;
275
296
  /** Subscribe to wallet events */
@@ -321,6 +342,9 @@ export declare type OrderTimestamps = HyperstreamApi.OrderTimestamps;
321
342
 
322
343
  export declare type OrderTransactions = HyperstreamApi.OrderTransactions;
323
344
 
345
+ /** Quote detail card display mode. */
346
+ export declare type QuoteCardVisibility = "hidden" | "visible";
347
+
324
348
  export declare type QuoteRequest = HyperstreamApi.QuoteRequest;
325
349
 
326
350
  export declare type QuoteResponse = HyperstreamApi.GetQuotesResponse;
@@ -339,7 +363,8 @@ export declare function rankOffers(offers: readonly OfferForRanking[]): string[]
339
363
  export declare type ReceiveMode = "crypto" | "fiat" | "all";
340
364
 
341
365
  /**
342
- * Non-derivable state for `<tokenflight-receive>`.
366
+ * Non-derivable state for the Receive (EXACT_OUTPUT) flow inside
367
+ * `<tokenflight-widget>`.
343
368
  *
344
369
  * Derivable values (phase, selectedQuote, paymentTokens) are computed in
345
370
  * ReceiveComponent from payTokenQuotes + loadingQuotes + these signals.
@@ -359,8 +384,6 @@ export declare interface ReceiveState {
359
384
  errorCode: string | null;
360
385
  }
361
386
 
362
- export declare function registerDepositElement(options?: RegisterElementsOptions): void;
363
-
364
387
  export declare function registerElements(options?: RegisterElementsOptions): void;
365
388
 
366
389
  export declare interface RegisterElementsOptions {
@@ -383,6 +406,8 @@ export declare interface RegisterElementsOptions {
383
406
  hideTitle?: boolean;
384
407
  /** Default hide-powered-by flag. */
385
408
  hidePoweredBy?: boolean;
409
+ /** Default hide-provider flag (hides "via {provider}" badge on the tracking page). */
410
+ hideProvider?: boolean;
386
411
  /** Default no-background flag. */
387
412
  noBackground?: boolean;
388
413
  /** Default no-border flag. */
@@ -393,10 +418,12 @@ export declare interface RegisterElementsOptions {
393
418
  rpcOverrides?: Record<string, string>;
394
419
  /** Default supported chain id allowlist. */
395
420
  supportedChainIds?: number[];
421
+ /** Referrer address that receives the fee. Passed through to quote API. */
422
+ referrer?: string;
423
+ /** Referrer fee in basis points (e.g. 30 = 0.3%). Passed through to quote API. */
424
+ referrerFeeBps?: number;
396
425
  }
397
426
 
398
- export declare function registerSwapElement(options?: RegisterElementsOptions): void;
399
-
400
427
  export declare function registerWidgetElement(options?: RegisterElementsOptions): void;
401
428
 
402
429
  /** Resolved token with full metadata for local display state */
@@ -468,9 +495,6 @@ export declare interface SwapSuccessData {
468
495
  txHash: string;
469
496
  }
470
497
 
471
- /** @deprecated Use `SwapPayMethod` instead. */
472
- declare type SwapV2PayMethod = SwapPayMethod;
473
-
474
498
  export { TERMINAL_FIAT_STATUSES }
475
499
 
476
500
  export { TERMINAL_ORDER_STATUSES }
@@ -490,6 +514,38 @@ export declare interface TextOverrides {
490
514
  youPay?: string;
491
515
  /** Label above the destination/to token panel. Default: "You receive" */
492
516
  youReceive?: string;
517
+ /** Step 1 title (pending). Default: "Sign in wallet" */
518
+ trackingSignTitle?: string;
519
+ /** Step 1 title (done). Default: "Signed in wallet" */
520
+ trackingSignedTitle?: string;
521
+ /** Step 1 subtitle (pending). Default: "Confirm in your wallet..." */
522
+ trackingSignSubtitle?: string;
523
+ /** Step 1 subtitle (done). Default: "Signature submitted" */
524
+ trackingSignedSubtitle?: string;
525
+ /** Step 2 title. Default: "Deposit on {chain}" */
526
+ trackingDepositTitle?: string;
527
+ /** Step 2 subtitle (pending). Default: "Waiting for confirmation..." */
528
+ trackingDepositSubtitle?: string;
529
+ /** Step 2 subtitle (done). Default: "Confirmed on-chain" */
530
+ trackingDepositConfirmedSubtitle?: string;
531
+ /** Step 3 title. Default: "Provider filling your order" */
532
+ trackingFillTitle?: string;
533
+ /** Step 3 subtitle. Default: "Via {provider}" */
534
+ trackingFillSubtitle?: string;
535
+ /** Step 4 title. Default: "Filled on {chain}" */
536
+ trackingCompleteTitle?: string;
537
+ /** Step 4 subtitle. Default: "Tokens delivered" */
538
+ trackingCompleteSubtitle?: string;
539
+ /** Fiat step 1 title. Default: "Awaiting payment" */
540
+ trackingPaymentTitle?: string;
541
+ /** Fiat step 1 subtitle (done). Default: "Payment confirmed" */
542
+ trackingPaymentConfirmedSubtitle?: string;
543
+ /** Fiat swap step title (jump strategy). Default: "Swapping tokens" */
544
+ trackingSwapTitle?: string;
545
+ /** Fiat final step title. Default: "Purchase complete" */
546
+ trackingPurchaseTitle?: string;
547
+ /** Fiat final step subtitle (done). Default: "Tokens delivered to your wallet" */
548
+ trackingDeliverySubtitle?: string;
493
549
  }
494
550
 
495
551
  /** All first-party CSS custom properties exposed for theming. */
@@ -534,6 +590,10 @@ export declare interface TokenFlightConfigBase {
534
590
  hideTitle?: boolean;
535
591
  /** Hide "Powered by TokenFlight" footer */
536
592
  hidePoweredBy?: boolean;
593
+ /** Hide the "via {provider}" badge on the order tracking page */
594
+ hideProvider?: boolean;
595
+ /** Quote card display mode. EXACT_INPUT Swap defaults to "hidden". */
596
+ quoteCard?: QuoteCardVisibility;
537
597
  /** Remove container background (transparent) */
538
598
  noBackground?: boolean;
539
599
  /** Remove container border and shadow */
@@ -544,52 +604,10 @@ export declare interface TokenFlightConfigBase {
544
604
  * are decimal chain IDs as strings.
545
605
  */
546
606
  rpcOverrides?: Record<string, string>;
547
- }
548
-
549
- /** Attributes accepted by `<tokenflight-deposit>`. */
550
- export declare interface TokenFlightDepositAttributes {
551
- "api-endpoint"?: string;
552
- target?: string;
553
- amount?: string;
554
- "from-token"?: string;
555
- recipient?: string;
556
- methods?: string;
557
- "target-icon"?: string;
558
- "fiat-currency"?: string;
559
- "title-text"?: string;
560
- "title-image"?: string;
561
- theme?: Theme;
562
- locale?: SupportedLocale;
563
- "csp-nonce"?: string;
564
- "hide-title"?: BooleanAttribute;
565
- "hide-powered-by"?: BooleanAttribute;
566
- "no-background"?: BooleanAttribute;
567
- "no-border"?: BooleanAttribute;
568
- }
569
-
570
- /** Configuration for `<tokenflight-deposit>` */
571
- export declare interface TokenFlightDepositConfig extends TokenFlightConfigBase {
572
- /** Target token(s) to deposit into. When omitted, user selects via TokenSelector. */
573
- target?: TokenIdentifier | TokenIdentifier[];
574
- /** Optional: fixed amount for the target token */
575
- amount?: string;
576
- /** Optional: recipient address */
577
- recipient?: string;
578
- /** Payment methods to offer (default: ["wallet"]) */
579
- methods?: DepositMethod[];
580
- /** Optional source token to pay with */
581
- fromToken?: TokenIdentifier;
582
- /** Optional icon URL for the target token */
583
- targetIcon?: string;
584
- /** Fiat currency code for card payments (default: "USD") */
585
- fiatCurrency?: string;
586
- }
587
-
588
- export declare interface TokenFlightDepositOptions {
589
- container: string | HTMLElement;
590
- config: TokenFlightDepositConfig;
591
- walletAdapter?: IWalletAdapter;
592
- callbacks?: Callbacks;
607
+ /** Referrer address that receives the fee. Passed through to the quote API. */
608
+ referrer?: string;
609
+ /** Referrer fee in basis points (e.g. 30 = 0.3%). Passed through to the quote API. */
610
+ referrerFeeBps?: number;
593
611
  }
594
612
 
595
613
  export { TokenFlightError }
@@ -608,167 +626,11 @@ export declare interface TokenFlightFiatAttributes {
608
626
  icon?: string;
609
627
  "hide-title"?: BooleanAttribute;
610
628
  "hide-powered-by"?: BooleanAttribute;
629
+ "hide-provider"?: BooleanAttribute;
611
630
  "no-background"?: BooleanAttribute;
612
631
  "no-border"?: BooleanAttribute;
613
632
  }
614
633
 
615
- /**
616
- * @deprecated Use `TokenFlightDepositConfig` instead.
617
- *
618
- * Configuration for `<tokenflight-fiat>`
619
- */
620
- export declare interface TokenFlightFiatConfig extends TokenFlightConfigBase {
621
- /** Optional: target token to purchase (user can select via TokenSelector if omitted) */
622
- target?: TokenIdentifier;
623
- /** Optional recipient address (if not using connected wallet) */
624
- recipient?: string;
625
- /** Fiat currency code (default: "USD") */
626
- fiatCurrency?: string;
627
- /** Optional icon URL for the target token */
628
- icon?: string;
629
- }
630
-
631
- export declare interface TokenFlightFiatOptions {
632
- container: string | HTMLElement;
633
- config: TokenFlightFiatConfig;
634
- walletAdapter?: IWalletAdapter;
635
- callbacks?: Callbacks;
636
- }
637
-
638
- /** Attributes accepted by `<tokenflight-receive>`. */
639
- export declare interface TokenFlightReceiveAttributes {
640
- "api-endpoint"?: string;
641
- target?: string;
642
- amount?: string;
643
- "from-token"?: string;
644
- recipient?: string;
645
- "title-text"?: string;
646
- "title-image"?: string;
647
- theme?: Theme;
648
- locale?: SupportedLocale;
649
- "csp-nonce"?: string;
650
- icon?: string;
651
- "hide-title"?: BooleanAttribute;
652
- "hide-powered-by"?: BooleanAttribute;
653
- "no-background"?: BooleanAttribute;
654
- "no-border"?: BooleanAttribute;
655
- }
656
-
657
- /** Configuration for the Receive component (EXACT_OUTPUT UX) */
658
- export declare interface TokenFlightReceiveConfig extends TokenFlightConfigBase {
659
- /** Target token to receive (optional — user can select via TokenSelector if omitted) */
660
- target?: TokenIdentifier;
661
- /** Amount to receive (optional when amountEditable is true) */
662
- amount?: string;
663
- /** Optional source token to pay with */
664
- fromToken?: TokenIdentifier;
665
- /** Optional recipient address (for cross-chain swaps to a different address) */
666
- recipient?: string;
667
- /**
668
- * When true, the recipient badge stays editable even if `recipient` is preset.
669
- * Default: false — presetting `recipient` locks the badge.
670
- */
671
- recipientEditable?: boolean;
672
- /** Address the filler should refund to if the fill fails (sent as `refundTo` on quote requests). */
673
- refundTo?: string;
674
- /** Optional icon URL for the target token */
675
- icon?: string;
676
- /** Payment methods to offer (default: ["crypto"]) */
677
- methods?: ("crypto" | "card")[];
678
- /** Fiat currency code for card payments (default: "USD") */
679
- fiatCurrency?: string;
680
- /** Allow user to edit the receive amount */
681
- amountEditable?: boolean;
682
- /** Whitelist of allowed source tokens (CAIP-10) */
683
- fromTokens?: TokenIdentifier[];
684
- /** Whitelist of allowed destination tokens (CAIP-10) */
685
- toTokens?: TokenIdentifier[];
686
- }
687
-
688
- export declare interface TokenFlightReceiveOptions {
689
- container: string | HTMLElement;
690
- config: TokenFlightReceiveConfig;
691
- walletAdapter?: IWalletAdapter;
692
- callbacks?: Callbacks;
693
- }
694
-
695
- export declare const TokenFlightSwap: {
696
- new (options: ImperativeWidgetOptions<TokenFlightSwapConfig>): {
697
- #dispose: (() => void) | null;
698
- #unwatchTheme: (() => void) | null;
699
- #container: HTMLElement;
700
- #shadowRoot: ShadowRoot | null;
701
- #config: TokenFlightSwapConfig;
702
- #walletAdapter?: IWalletAdapter;
703
- #callbacks?: Callbacks;
704
- initialize(): void;
705
- destroy(): void;
706
- setTheme(theme: Theme): void;
707
- setCustomColors(colors: CustomColors): void;
708
- #applyThemeStyles(style: HTMLStyleElement, theme: string): void;
709
- #setupAutoThemeWatch(style: HTMLStyleElement): void;
710
- };
711
- };
712
-
713
- /** Attributes accepted by `<tokenflight-swap>`. */
714
- export declare interface TokenFlightSwapAttributes {
715
- "api-endpoint"?: string;
716
- "from-token"?: string;
717
- "to-token"?: string;
718
- recipient?: string;
719
- "title-text"?: string;
720
- "title-image"?: string;
721
- theme?: Theme;
722
- locale?: SupportedLocale;
723
- "csp-nonce"?: string;
724
- "hide-title"?: BooleanAttribute;
725
- "hide-powered-by"?: BooleanAttribute;
726
- "no-background"?: BooleanAttribute;
727
- "no-border"?: BooleanAttribute;
728
- }
729
-
730
- /** Configuration for `<tokenflight-swap>` and `<tokenflight-widget>` swap mode */
731
- export declare interface TokenFlightSwapConfig extends TokenFlightConfigBase {
732
- /** Optional source token (crypto tab) */
733
- fromToken?: TokenIdentifier;
734
- /** Optional destination token */
735
- toToken?: TokenIdentifier;
736
- /** Optional recipient address */
737
- recipient?: string;
738
- /**
739
- * When true, the recipient badge stays editable even if `recipient` is preset.
740
- * Default: false — presetting `recipient` locks the badge.
741
- */
742
- recipientEditable?: boolean;
743
- /** Address the filler should refund to if the fill fails (sent as `refundTo` on quote requests). */
744
- refundTo?: string;
745
- /** Trade direction: "EXACT_INPUT" (default) = amount is input, "EXACT_OUTPUT" = amount is output */
746
- tradeType?: "EXACT_INPUT" | "EXACT_OUTPUT";
747
- /** Amount value — interpreted as input or output based on tradeType */
748
- amount?: string;
749
- /** Payment methods to offer (default: ["crypto"]) */
750
- methods?: SwapPayMethod[];
751
- /** Default active pay method tab (default: "crypto") */
752
- defaultPayMethod?: SwapPayMethod;
753
- /** Fiat currency code for card payments (default: "USD") */
754
- fiatCurrency?: string;
755
- /** Whitelist of allowed source tokens (CAIP-10) */
756
- fromTokens?: TokenIdentifier[];
757
- /** Whitelist of allowed destination tokens (CAIP-10) */
758
- toTokens?: TokenIdentifier[];
759
- /** Lock the from-token selector (disable changing) */
760
- lockFromToken?: boolean;
761
- /** Lock the to-token selector (disable changing) */
762
- lockToToken?: boolean;
763
- }
764
-
765
- export declare interface TokenFlightSwapOptions {
766
- container: string | HTMLElement;
767
- config: TokenFlightSwapConfig;
768
- walletAdapter?: IWalletAdapter;
769
- callbacks?: Callbacks;
770
- }
771
-
772
634
  export declare const TokenFlightWidget: {
773
635
  new (options: ImperativeWidgetOptions<TokenFlightWidgetConfig>): {
774
636
  #dispose: (() => void) | null;
@@ -814,8 +676,12 @@ export declare interface TokenFlightWidgetAttributes {
814
676
  "csp-nonce"?: string;
815
677
  "hide-title"?: BooleanAttribute;
816
678
  "hide-powered-by"?: BooleanAttribute;
679
+ "hide-provider"?: BooleanAttribute;
680
+ "quote-card"?: "hidden" | "visible";
817
681
  "no-background"?: BooleanAttribute;
818
682
  "no-border"?: BooleanAttribute;
683
+ "referrer"?: string;
684
+ "referrer-fee-bps"?: string | number;
819
685
  }
820
686
 
821
687
  /** Configuration for Widget component (auto-selects Swap or Deposit UX based on config) */
@@ -838,9 +704,9 @@ export declare interface TokenFlightWidgetConfig extends TokenFlightConfigBase {
838
704
  /** Address the filler should refund to if the fill fails (sent as `refundTo` on quote requests). */
839
705
  refundTo?: string;
840
706
  /** Payment methods to offer (default: ["crypto"]) */
841
- methods?: SwapV2PayMethod[];
707
+ methods?: SwapPayMethod[];
842
708
  /** Default active pay method tab (default: "crypto") */
843
- defaultPayMethod?: SwapV2PayMethod;
709
+ defaultPayMethod?: SwapPayMethod;
844
710
  /** Fiat currency code for card payments (default: "USD") */
845
711
  fiatCurrency?: string;
846
712
  /** Whitelist of allowed source tokens (CAIP-10) */
@@ -894,6 +760,20 @@ export declare interface WalletActionResult {
894
760
  success: boolean;
895
761
  data?: unknown;
896
762
  error?: string;
763
+ /**
764
+ * Optional: JSON-RPC / EIP-1193 provider error code (e.g. `-32603`,
765
+ * `4001`). Populated by adapters when the underlying error object
766
+ * exposes a numeric `.code` so downstream callers (notably the
767
+ * Coinbase `-32603` fallback in `safeSwitchChain`) can reliably
768
+ * detect provider signatures without relying on stringified messages.
769
+ */
770
+ errorCode?: number;
771
+ /**
772
+ * Optional: the provider's structured error data (e.g. `data.cause`),
773
+ * preserved from the thrown error for detectors that inspect nested
774
+ * fields. Adapters may pass through whatever shape the provider gave.
775
+ */
776
+ errorData?: unknown;
897
777
  txHash?: string;
898
778
  }
899
779
 
@@ -934,6 +814,7 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
934
814
  readonly customColors: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
935
815
  readonly hideTitle: v.BooleanSchema<undefined>;
936
816
  readonly hidePoweredBy: v.BooleanSchema<undefined>;
817
+ readonly hideProvider: v.BooleanSchema<undefined>;
937
818
  readonly noBackground: v.BooleanSchema<undefined>;
938
819
  readonly noBorder: v.BooleanSchema<undefined>;
939
820
  readonly methods: v.ArraySchema<v.PicklistSchema<["crypto", "card"], undefined>, undefined>;
@@ -949,6 +830,7 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
949
830
  readonly customColors: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
950
831
  readonly hideTitle: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
951
832
  readonly hidePoweredBy: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
833
+ readonly hideProvider: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
952
834
  readonly noBackground: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
953
835
  readonly noBorder: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
954
836
  readonly methods: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["crypto", "card"], undefined>, undefined>, undefined>;
@@ -966,9 +848,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
966
848
  } | undefined;
967
849
  hideTitle?: boolean | undefined;
968
850
  hidePoweredBy?: boolean | undefined;
851
+ hideProvider?: boolean | undefined;
969
852
  noBackground?: boolean | undefined;
970
853
  noBorder?: boolean | undefined;
971
- methods?: ("card" | "crypto")[] | undefined;
854
+ methods?: ("crypto" | "card")[] | undefined;
972
855
  supportedChainIds?: number[] | undefined;
973
856
  rpcOverrides?: {
974
857
  [x: string]: string;
@@ -984,9 +867,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
984
867
  } | undefined;
985
868
  hideTitle?: boolean | undefined;
986
869
  hidePoweredBy?: boolean | undefined;
870
+ hideProvider?: boolean | undefined;
987
871
  noBackground?: boolean | undefined;
988
872
  noBorder?: boolean | undefined;
989
- methods?: ("card" | "crypto")[] | undefined;
873
+ methods?: ("crypto" | "card")[] | undefined;
990
874
  supportedChainIds?: number[] | undefined;
991
875
  rpcOverrides?: {
992
876
  [x: string]: string;
@@ -1003,9 +887,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
1003
887
  } | undefined;
1004
888
  hideTitle?: boolean | undefined;
1005
889
  hidePoweredBy?: boolean | undefined;
890
+ hideProvider?: boolean | undefined;
1006
891
  noBackground?: boolean | undefined;
1007
892
  noBorder?: boolean | undefined;
1008
- methods?: ("card" | "crypto")[] | undefined;
893
+ methods?: ("crypto" | "card")[] | undefined;
1009
894
  supportedChainIds?: number[] | undefined;
1010
895
  rpcOverrides?: {
1011
896
  [x: string]: string;
@@ -1023,9 +908,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
1023
908
  } | undefined;
1024
909
  hideTitle?: boolean | undefined;
1025
910
  hidePoweredBy?: boolean | undefined;
911
+ hideProvider?: boolean | undefined;
1026
912
  noBackground?: boolean | undefined;
1027
913
  noBorder?: boolean | undefined;
1028
- methods?: ("card" | "crypto")[] | undefined;
914
+ methods?: ("crypto" | "card")[] | undefined;
1029
915
  supportedChainIds?: number[] | undefined;
1030
916
  rpcOverrides?: {
1031
917
  [x: string]: string;
@@ -1042,9 +928,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
1042
928
  } | undefined;
1043
929
  hideTitle?: boolean | undefined;
1044
930
  hidePoweredBy?: boolean | undefined;
931
+ hideProvider?: boolean | undefined;
1045
932
  noBackground?: boolean | undefined;
1046
933
  noBorder?: boolean | undefined;
1047
- methods?: ("card" | "crypto")[] | undefined;
934
+ methods?: ("crypto" | "card")[] | undefined;
1048
935
  supportedChainIds?: number[] | undefined;
1049
936
  rpcOverrides?: {
1050
937
  [x: string]: string;
@@ -1,2 +1 @@
1
- import{D as e,F as t,_ as n,c as r,g as i,h as a,i as o,j as s,m as c,n as l,r as u,t as d,v as f,z as p}from"./register-defaults-lIJMUU-P.js";import{$ as m,A as h,B as g,C as _,D as v,E as y,F as b,G as x,H as S,I as C,J as w,K as T,L as ee,M as te,N as ne,O as re,P as ie,Q as ae,R as oe,S as se,T as E,U as D,V as O,W as k,X as ce,Y as A,Z as j,_ as M,a as N,b as P,c as F,d as I,et as L,f as R,g as z,h as B,i as V,j as H,k as U,l as W,m as G,n as K,o as le,p as ue,q,r as de,s as fe,t as J,u as pe,v as me,w as he,x as ge,y as _e,z as Y}from"./register-widget-DQAzucnZ.js";var X=[he,_,se,ge,P,_e,me,M,z,B,G,ue,R,I,pe,W,F,fe,le].join(`
2
- `),ve=g((t,n,r)=>e(E,{config:t,walletAdapter:n,callbacks:r}),()=>X),ye=class{constructor(){this.name=`Mock Wallet`,this.icon=void 0,this.supportedActionTypes=[`eip1193_request`,`solana_signAndSendTransaction`],this.connected=!1,this.address=`0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045`,this.listeners=new Map}async connect(e){this.connected=!0,this.emit(`connect`,{address:this.address})}async disconnect(){this.connected=!1,this.emit(`disconnect`)}isConnected(e){return this.connected}async getAddress(e){return this.connected?this.address:null}async executeWalletAction(e){return await new Promise(e=>setTimeout(e,1e3)),{success:!0,txHash:`0x`+`a`.repeat(64)}}async signMessage(e){return`0x`+`b`.repeat(130)}async openAccountModal(){}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r({type:e,data:t})}},be=A(`<style>`);function Z(n){n&&d(n),!(typeof customElements>`u`)&&(customElements.get(`tokenflight-swap`)||K(`tokenflight-swap`,{"api-endpoint":``,"from-token":``,"to-token":``,recipient:``,"title-text":``,"title-image":``,theme:``,locale:``,"csp-nonce":``,"hide-title":!1,"hide-powered-by":!1,"no-background":!1,"no-border":!1},(n,{element:d})=>{let f={apiEndpoint:n[`api-endpoint`]||l()||void 0,fromToken:n[`from-token`]||void 0,toToken:n[`to-token`]||void 0,recipient:n.recipient||void 0,titleText:n[`title-text`]||void 0,titleImageUrl:n[`title-image`]||void 0,theme:n.theme||c()||`light`,locale:n.locale||r()||`en-US`,hideTitle:i(n[`hide-title`]),hidePoweredBy:i(n[`hide-powered-by`]),noBackground:i(n[`no-background`]),noBorder:i(n[`no-border`])},m=n[`csp-nonce`]||void 0,[h,g]=t(typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches===!0);p(x(e=>{g(e===D)}));let _=d.__customColors,v=s(()=>{let e=n.theme||c()||`light`,t=(e===`auto`?h():e===`dark`)?D:k,r=o();return`${X}\n:host { ${S(r||_?{...t,...r,..._}:t)} }`}),y=d.__walletAdapter,b=d.__callbacks;return[(()=>{var e=be();return w(e,`nonce`,m),q(e,v),e})(),e(T,{client:O,get children(){return e(E,{config:f,get walletAdapter(){return y??a()},get callbacks(){return b?{...u(),...b}:u()}})}})]}))}var xe=A(`<style>`);function Se(e){if(!e)return``;let t=e.trim();if(t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return t}function Ce(e){if(e)try{let t=JSON.parse(e.trim());if(Array.isArray(t))return t}catch{}}function we(e){if(e)return e.map(e=>e===`wallet`?`crypto`:`card`)}function Q(n){n&&d(n),!(typeof customElements>`u`)&&(customElements.get(`tokenflight-deposit`)||K(`tokenflight-deposit`,{"api-endpoint":``,target:``,amount:``,"from-token":``,recipient:``,methods:``,"target-icon":``,"fiat-currency":``,"title-text":``,"title-image":``,theme:``,locale:``,"csp-nonce":``,"hide-title":!1,"hide-powered-by":!1,"no-background":!1,"no-border":!1},(n,{element:d})=>{let f=Ce(n.methods),m={apiEndpoint:n[`api-endpoint`]||l()||void 0,toToken:Se(n.target),fromToken:n[`from-token`]||void 0,tradeType:n.amount?`EXACT_OUTPUT`:`EXACT_INPUT`,amount:n.amount||void 0,recipient:n.recipient||void 0,methods:we(f),icon:n[`target-icon`]||void 0,fiatCurrency:n[`fiat-currency`]||void 0,titleText:n[`title-text`]||void 0,titleImageUrl:n[`title-image`]||void 0,theme:n.theme||c()||`light`,locale:n.locale||r()||`en-US`,hideTitle:i(n[`hide-title`]),hidePoweredBy:i(n[`hide-powered-by`]),noBackground:i(n[`no-background`]),noBorder:i(n[`no-border`])},h=n[`csp-nonce`]||void 0,[g,_]=t(typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches===!0);p(x(e=>{_(e===D)}));let v=d.__customColors,y=s(()=>{let e=n.theme||c()||`light`,t=(e===`auto`?g():e===`dark`)?D:k,r=o();return`${V}\n:host { ${S(r||v?{...t,...r,...v}:t)} }`}),b=d.__walletAdapter,C=d.__callbacks;return[(()=>{var e=xe();return w(e,`nonce`,h),q(e,y),e})(),e(T,{client:O,get children(){return e(N,{config:m,get walletAdapter(){return b??a()},get callbacks(){return C?{...u(),...C}:u()}})}})]}))}function $(e={}){d(e),Z(),Q(),J()}typeof window<`u`&&$();export{L as DEFAULT_API_ENDPOINT,ce as ErrorCode,ye as MockWalletAdapter,h as SOLANA_CHAIN_ID,j as TERMINAL_FIAT_STATUSES,ae as TERMINAL_ORDER_STATUSES,m as TokenFlightError,ve as TokenFlightSwap,de as TokenFlightWidget,b as addThousandsSeparator,y as buildOffersForRanking,U as clearTokenCache,C as computeExchangeRate,ee as formatDisplayAmount,v as getBestOverallRouteId,H as getChainType,f as getDefaults,te as isCrossChainSwap,ne as isEvmChain,ie as isSolanaChain,re as rankOffers,Q as registerDepositElement,$ as registerElements,Z as registerSwapElement,J as registerWidgetElement,n as setTextOverrides,oe as toBaseUnits,Y as toDisplayAmount};
1
+ import{t as e,x as t}from"./register-defaults-C_q7CG7x.js";import{a as n,c as r,l as i,r as a,t as o}from"./errors-BZKSEUy5.js";import"./shared.module-C-kWMzqW.js";import{n as s,t as c}from"./register-widget-BrN4UxSU.js";import"./widget-DQLVNkNn.js";import{_ as l,a as u,d,f,g as p,h as m,i as h,m as g,n as _,p as v,s as y,t as b,u as x,v as S}from"./rank-offers-Dt1Mvbrr.js";function C(){return typeof window>`u`?null:window.__tfMockWallet?.queuedActions?.shift()??null}var w=class{constructor(){this.name=`Mock Wallet`,this.icon=void 0,this.supportedActionTypes=[`eip1193_request`,`solana_signAndSendTransaction`],this.connected=!1,this.address=`0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045`,this.listeners=new Map}async connect(e){this.connected=!0,this.emit(`connect`,{address:this.address})}async disconnect(){this.connected=!1,this.emit(`disconnect`)}isConnected(e){return this.connected}async getAddress(e){return this.connected?this.address:null}async executeWalletAction(e){let t=C(),n=Number(t?.delayMs??1e3);return await new Promise(e=>setTimeout(e,Number.isFinite(n)&&n>0?n:0)),t?.success===!1?{success:!1,error:t.error??`User denied transaction signature.`}:{success:!0,txHash:t?.txHash??`0x`+`a`.repeat(64)}}async signMessage(e){return`0x`+`b`.repeat(130)}async openAccountModal(){}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,t){let n=this.listeners.get(e);if(n)for(let r of n)r({type:e,data:t})}};function T(t={}){e(t),c()}typeof window<`u`&&T();export{i as DEFAULT_API_ENDPOINT,o as ErrorCode,w as MockWalletAdapter,u as SOLANA_CHAIN_ID,a as TERMINAL_FIAT_STATUSES,n as TERMINAL_ORDER_STATUSES,r as TokenFlightError,s as TokenFlightWidget,v as addThousandsSeparator,b as buildOffersForRanking,S as clearTokenCache,g as computeExchangeRate,m as formatDisplayAmount,_ as getBestOverallRouteId,y as getChainType,x as isCrossChainSwap,d as isEvmChain,f as isSolanaChain,h as rankOffers,T as registerElements,c as registerWidgetElement,t as setTextOverrides,p as toBaseUnits,l as toDisplayAmount};