@tokenflight/swap 0.3.0-rc.0 → 0.3.0-rc.1
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/dist/ReceiveComponent-Cyn4ECRG.js +1 -0
- package/dist/ReceiveComponent.module-BGpemTAX.js +1 -0
- package/dist/SwapComponent-BwfaI3D9.js +1 -0
- package/dist/bridge-Bq0QUltI.js +1 -0
- package/dist/bridge.d.ts +17 -1
- package/dist/bridge.js +1 -1
- package/dist/custom-elements.d.ts +1 -27
- package/dist/defaults-loader-DfcaO9j5.js +1 -0
- package/dist/en-US-CU2aSy93.js +1 -0
- package/dist/errors-Nd9setTj.js +3 -0
- package/dist/iframe-entry.d.ts +21 -0
- package/dist/iframe-entry.js +29 -0
- package/dist/iframe-receiver-PfhKUIZW.js +1 -0
- package/dist/iframe.d.ts +78 -10
- package/dist/iframe.js +45 -1
- package/dist/ja-JP-BoipV6-j.js +1 -0
- package/dist/ko-KR-DyFXZJsF.js +1 -0
- package/dist/protocol-CDxgudrl.js +1 -0
- package/dist/rank-offers-CR-1NeiW.js +1 -0
- package/dist/register-defaults-C_q7CG7x.js +1 -0
- package/dist/register-widget-DOzDJD94.js +1 -0
- package/dist/shared.module-C-kWMzqW.js +1 -0
- package/dist/solid-iWr5Czxc.js +1 -0
- package/dist/swap.css +1 -1
- package/dist/theme-C9tsVWlo.js +2 -0
- package/dist/tokenflight-swap.d.ts +88 -250
- package/dist/tokenflight-swap.js +1 -2
- package/dist/tokenflight-swap.umd.cjs +5 -6
- package/dist/widget-BadYytj9.js +2 -0
- package/dist/widget.d.ts +307 -25
- package/dist/widget.js +1 -1
- package/dist/zh-CN-epCUm9Io.js +1 -0
- package/dist/zh-TW-DSEboEJV.js +1 -0
- package/package.json +6 -2
- package/dist/bridge-C9uFKAdS.js +0 -1
- package/dist/en-US-ChmhdVUe.js +0 -1
- package/dist/ja-JP-BAX9fLqV.js +0 -1
- package/dist/ko-KR-jwhmhUqJ.js +0 -1
- package/dist/register-defaults-lIJMUU-P.js +0 -1
- package/dist/register-widget-DQAzucnZ.js +0 -5
- package/dist/zh-CN-fKcRI4Y8.js +0 -1
- package/dist/zh-TW-gFEUAIR6.js +0 -1
- /package/dist/{active-bridge-DTyKObda.js → active-bridge-V8lTJ2Js.js} +0 -0
|
@@ -42,9 +42,24 @@ declare type BooleanAttribute = boolean | "true" | "false" | "1" | "0" | "yes" |
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function buildOffersForRanking(routes: readonly QuoteRoute[], tradeType: TradeType | null): OfferForRanking[];
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Callback interfaces for widget events.
|
|
47
|
+
*
|
|
48
|
+
* **Crypto outcome routing** (mutually exclusive — pick the channel that matches
|
|
49
|
+
* the active flow):
|
|
50
|
+
* - `EXACT_INPUT` (`<tokenflight-widget trade-type="EXACT_INPUT">` / default,
|
|
51
|
+
* "spend exactly N of X") → fires `onSwapSuccess` / `onSwapError`
|
|
52
|
+
* - `EXACT_OUTPUT` (`<tokenflight-widget trade-type="EXACT_OUTPUT">`,
|
|
53
|
+
* "receive exactly N of Y") → fires `onDepositSuccess` / `onDepositError`
|
|
54
|
+
*
|
|
55
|
+
* **Fiat (card) outcomes** route through the same `onSwap*` / `onDeposit*`
|
|
56
|
+
* channels for errors (matched to the host flow) and through
|
|
57
|
+
* `onFiatOrderCreated` / `onFiatOrderCompleted` for fiat-specific lifecycle.
|
|
58
|
+
*/
|
|
46
59
|
export declare interface Callbacks {
|
|
60
|
+
/** EXACT_INPUT crypto success. */
|
|
47
61
|
onSwapSuccess?(data: SwapSuccessData): void;
|
|
62
|
+
/** EXACT_INPUT errors (crypto execution + card flow when in EXACT_INPUT mode). */
|
|
48
63
|
onSwapError?(data: SwapErrorData): void;
|
|
49
64
|
onWalletConnected?(data: WalletConnectedData): void;
|
|
50
65
|
onQuoteReceived?(data: QuoteResponse): void;
|
|
@@ -64,9 +79,9 @@ export declare interface Callbacks {
|
|
|
64
79
|
status: string;
|
|
65
80
|
txHash?: string;
|
|
66
81
|
}): void;
|
|
67
|
-
/**
|
|
82
|
+
/** EXACT_OUTPUT crypto success. */
|
|
68
83
|
onDepositSuccess?(data: SwapSuccessData): void;
|
|
69
|
-
/**
|
|
84
|
+
/** EXACT_OUTPUT errors (crypto execution + card flow when in EXACT_OUTPUT mode). */
|
|
70
85
|
onDepositError?(data: SwapErrorData): void;
|
|
71
86
|
}
|
|
72
87
|
|
|
@@ -107,25 +122,6 @@ export declare type DepositApproval = HyperstreamApi.Approval;
|
|
|
107
122
|
|
|
108
123
|
export declare type DepositBuildResponse = HyperstreamApi.Deposit;
|
|
109
124
|
|
|
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
125
|
export declare type EIP1193RequestApproval = HyperstreamApi.EIP1193RequestApproval;
|
|
130
126
|
|
|
131
127
|
/**
|
|
@@ -220,16 +216,6 @@ export declare function getBestOverallRouteId(routes: readonly QuoteRoute[], tra
|
|
|
220
216
|
/** Get chain type from chainId */
|
|
221
217
|
export declare function getChainType(chainId: number): "evm" | "solana";
|
|
222
218
|
|
|
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
219
|
declare interface ImperativeWidgetOptions<TConfig> {
|
|
234
220
|
container: string | HTMLElement;
|
|
235
221
|
config: TConfig;
|
|
@@ -321,6 +307,9 @@ export declare type OrderTimestamps = HyperstreamApi.OrderTimestamps;
|
|
|
321
307
|
|
|
322
308
|
export declare type OrderTransactions = HyperstreamApi.OrderTransactions;
|
|
323
309
|
|
|
310
|
+
/** Quote detail card display mode. */
|
|
311
|
+
export declare type QuoteCardVisibility = "hidden" | "visible";
|
|
312
|
+
|
|
324
313
|
export declare type QuoteRequest = HyperstreamApi.QuoteRequest;
|
|
325
314
|
|
|
326
315
|
export declare type QuoteResponse = HyperstreamApi.GetQuotesResponse;
|
|
@@ -339,7 +328,8 @@ export declare function rankOffers(offers: readonly OfferForRanking[]): string[]
|
|
|
339
328
|
export declare type ReceiveMode = "crypto" | "fiat" | "all";
|
|
340
329
|
|
|
341
330
|
/**
|
|
342
|
-
* Non-derivable state for
|
|
331
|
+
* Non-derivable state for the Receive (EXACT_OUTPUT) flow inside
|
|
332
|
+
* `<tokenflight-widget>`.
|
|
343
333
|
*
|
|
344
334
|
* Derivable values (phase, selectedQuote, paymentTokens) are computed in
|
|
345
335
|
* ReceiveComponent from payTokenQuotes + loadingQuotes + these signals.
|
|
@@ -359,8 +349,6 @@ export declare interface ReceiveState {
|
|
|
359
349
|
errorCode: string | null;
|
|
360
350
|
}
|
|
361
351
|
|
|
362
|
-
export declare function registerDepositElement(options?: RegisterElementsOptions): void;
|
|
363
|
-
|
|
364
352
|
export declare function registerElements(options?: RegisterElementsOptions): void;
|
|
365
353
|
|
|
366
354
|
export declare interface RegisterElementsOptions {
|
|
@@ -383,6 +371,8 @@ export declare interface RegisterElementsOptions {
|
|
|
383
371
|
hideTitle?: boolean;
|
|
384
372
|
/** Default hide-powered-by flag. */
|
|
385
373
|
hidePoweredBy?: boolean;
|
|
374
|
+
/** Default hide-provider flag (hides "via {provider}" badge on the tracking page). */
|
|
375
|
+
hideProvider?: boolean;
|
|
386
376
|
/** Default no-background flag. */
|
|
387
377
|
noBackground?: boolean;
|
|
388
378
|
/** Default no-border flag. */
|
|
@@ -393,10 +383,12 @@ export declare interface RegisterElementsOptions {
|
|
|
393
383
|
rpcOverrides?: Record<string, string>;
|
|
394
384
|
/** Default supported chain id allowlist. */
|
|
395
385
|
supportedChainIds?: number[];
|
|
386
|
+
/** Referrer address that receives the fee. Passed through to quote API. */
|
|
387
|
+
referrer?: string;
|
|
388
|
+
/** Referrer fee in basis points (e.g. 30 = 0.3%). Passed through to quote API. */
|
|
389
|
+
referrerFeeBps?: number;
|
|
396
390
|
}
|
|
397
391
|
|
|
398
|
-
export declare function registerSwapElement(options?: RegisterElementsOptions): void;
|
|
399
|
-
|
|
400
392
|
export declare function registerWidgetElement(options?: RegisterElementsOptions): void;
|
|
401
393
|
|
|
402
394
|
/** Resolved token with full metadata for local display state */
|
|
@@ -468,9 +460,6 @@ export declare interface SwapSuccessData {
|
|
|
468
460
|
txHash: string;
|
|
469
461
|
}
|
|
470
462
|
|
|
471
|
-
/** @deprecated Use `SwapPayMethod` instead. */
|
|
472
|
-
declare type SwapV2PayMethod = SwapPayMethod;
|
|
473
|
-
|
|
474
463
|
export { TERMINAL_FIAT_STATUSES }
|
|
475
464
|
|
|
476
465
|
export { TERMINAL_ORDER_STATUSES }
|
|
@@ -490,6 +479,38 @@ export declare interface TextOverrides {
|
|
|
490
479
|
youPay?: string;
|
|
491
480
|
/** Label above the destination/to token panel. Default: "You receive" */
|
|
492
481
|
youReceive?: string;
|
|
482
|
+
/** Step 1 title (pending). Default: "Sign in wallet" */
|
|
483
|
+
trackingSignTitle?: string;
|
|
484
|
+
/** Step 1 title (done). Default: "Signed in wallet" */
|
|
485
|
+
trackingSignedTitle?: string;
|
|
486
|
+
/** Step 1 subtitle (pending). Default: "Confirm in your wallet..." */
|
|
487
|
+
trackingSignSubtitle?: string;
|
|
488
|
+
/** Step 1 subtitle (done). Default: "Signature submitted" */
|
|
489
|
+
trackingSignedSubtitle?: string;
|
|
490
|
+
/** Step 2 title. Default: "Deposit on {chain}" */
|
|
491
|
+
trackingDepositTitle?: string;
|
|
492
|
+
/** Step 2 subtitle (pending). Default: "Waiting for confirmation..." */
|
|
493
|
+
trackingDepositSubtitle?: string;
|
|
494
|
+
/** Step 2 subtitle (done). Default: "Confirmed on-chain" */
|
|
495
|
+
trackingDepositConfirmedSubtitle?: string;
|
|
496
|
+
/** Step 3 title. Default: "Provider filling your order" */
|
|
497
|
+
trackingFillTitle?: string;
|
|
498
|
+
/** Step 3 subtitle. Default: "Via {provider}" */
|
|
499
|
+
trackingFillSubtitle?: string;
|
|
500
|
+
/** Step 4 title. Default: "Filled on {chain}" */
|
|
501
|
+
trackingCompleteTitle?: string;
|
|
502
|
+
/** Step 4 subtitle. Default: "Tokens delivered" */
|
|
503
|
+
trackingCompleteSubtitle?: string;
|
|
504
|
+
/** Fiat step 1 title. Default: "Awaiting payment" */
|
|
505
|
+
trackingPaymentTitle?: string;
|
|
506
|
+
/** Fiat step 1 subtitle (done). Default: "Payment confirmed" */
|
|
507
|
+
trackingPaymentConfirmedSubtitle?: string;
|
|
508
|
+
/** Fiat swap step title (jump strategy). Default: "Swapping tokens" */
|
|
509
|
+
trackingSwapTitle?: string;
|
|
510
|
+
/** Fiat final step title. Default: "Purchase complete" */
|
|
511
|
+
trackingPurchaseTitle?: string;
|
|
512
|
+
/** Fiat final step subtitle (done). Default: "Tokens delivered to your wallet" */
|
|
513
|
+
trackingDeliverySubtitle?: string;
|
|
493
514
|
}
|
|
494
515
|
|
|
495
516
|
/** All first-party CSS custom properties exposed for theming. */
|
|
@@ -534,6 +555,10 @@ export declare interface TokenFlightConfigBase {
|
|
|
534
555
|
hideTitle?: boolean;
|
|
535
556
|
/** Hide "Powered by TokenFlight" footer */
|
|
536
557
|
hidePoweredBy?: boolean;
|
|
558
|
+
/** Hide the "via {provider}" badge on the order tracking page */
|
|
559
|
+
hideProvider?: boolean;
|
|
560
|
+
/** Quote card display mode. EXACT_INPUT Swap defaults to "hidden". */
|
|
561
|
+
quoteCard?: QuoteCardVisibility;
|
|
537
562
|
/** Remove container background (transparent) */
|
|
538
563
|
noBackground?: boolean;
|
|
539
564
|
/** Remove container border and shadow */
|
|
@@ -544,52 +569,10 @@ export declare interface TokenFlightConfigBase {
|
|
|
544
569
|
* are decimal chain IDs as strings.
|
|
545
570
|
*/
|
|
546
571
|
rpcOverrides?: Record<string, string>;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
|
|
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;
|
|
572
|
+
/** Referrer address that receives the fee. Passed through to the quote API. */
|
|
573
|
+
referrer?: string;
|
|
574
|
+
/** Referrer fee in basis points (e.g. 30 = 0.3%). Passed through to the quote API. */
|
|
575
|
+
referrerFeeBps?: number;
|
|
593
576
|
}
|
|
594
577
|
|
|
595
578
|
export { TokenFlightError }
|
|
@@ -608,167 +591,11 @@ export declare interface TokenFlightFiatAttributes {
|
|
|
608
591
|
icon?: string;
|
|
609
592
|
"hide-title"?: BooleanAttribute;
|
|
610
593
|
"hide-powered-by"?: BooleanAttribute;
|
|
594
|
+
"hide-provider"?: BooleanAttribute;
|
|
611
595
|
"no-background"?: BooleanAttribute;
|
|
612
596
|
"no-border"?: BooleanAttribute;
|
|
613
597
|
}
|
|
614
598
|
|
|
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
599
|
export declare const TokenFlightWidget: {
|
|
773
600
|
new (options: ImperativeWidgetOptions<TokenFlightWidgetConfig>): {
|
|
774
601
|
#dispose: (() => void) | null;
|
|
@@ -814,8 +641,12 @@ export declare interface TokenFlightWidgetAttributes {
|
|
|
814
641
|
"csp-nonce"?: string;
|
|
815
642
|
"hide-title"?: BooleanAttribute;
|
|
816
643
|
"hide-powered-by"?: BooleanAttribute;
|
|
644
|
+
"hide-provider"?: BooleanAttribute;
|
|
645
|
+
"quote-card"?: "hidden" | "visible";
|
|
817
646
|
"no-background"?: BooleanAttribute;
|
|
818
647
|
"no-border"?: BooleanAttribute;
|
|
648
|
+
"referrer"?: string;
|
|
649
|
+
"referrer-fee-bps"?: string | number;
|
|
819
650
|
}
|
|
820
651
|
|
|
821
652
|
/** Configuration for Widget component (auto-selects Swap or Deposit UX based on config) */
|
|
@@ -838,9 +669,9 @@ export declare interface TokenFlightWidgetConfig extends TokenFlightConfigBase {
|
|
|
838
669
|
/** Address the filler should refund to if the fill fails (sent as `refundTo` on quote requests). */
|
|
839
670
|
refundTo?: string;
|
|
840
671
|
/** Payment methods to offer (default: ["crypto"]) */
|
|
841
|
-
methods?:
|
|
672
|
+
methods?: SwapPayMethod[];
|
|
842
673
|
/** Default active pay method tab (default: "crypto") */
|
|
843
|
-
defaultPayMethod?:
|
|
674
|
+
defaultPayMethod?: SwapPayMethod;
|
|
844
675
|
/** Fiat currency code for card payments (default: "USD") */
|
|
845
676
|
fiatCurrency?: string;
|
|
846
677
|
/** Whitelist of allowed source tokens (CAIP-10) */
|
|
@@ -934,6 +765,7 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
934
765
|
readonly customColors: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
935
766
|
readonly hideTitle: v.BooleanSchema<undefined>;
|
|
936
767
|
readonly hidePoweredBy: v.BooleanSchema<undefined>;
|
|
768
|
+
readonly hideProvider: v.BooleanSchema<undefined>;
|
|
937
769
|
readonly noBackground: v.BooleanSchema<undefined>;
|
|
938
770
|
readonly noBorder: v.BooleanSchema<undefined>;
|
|
939
771
|
readonly methods: v.ArraySchema<v.PicklistSchema<["crypto", "card"], undefined>, undefined>;
|
|
@@ -949,6 +781,7 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
949
781
|
readonly customColors: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
|
|
950
782
|
readonly hideTitle: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
951
783
|
readonly hidePoweredBy: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
784
|
+
readonly hideProvider: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
952
785
|
readonly noBackground: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
953
786
|
readonly noBorder: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
954
787
|
readonly methods: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["crypto", "card"], undefined>, undefined>, undefined>;
|
|
@@ -966,9 +799,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
966
799
|
} | undefined;
|
|
967
800
|
hideTitle?: boolean | undefined;
|
|
968
801
|
hidePoweredBy?: boolean | undefined;
|
|
802
|
+
hideProvider?: boolean | undefined;
|
|
969
803
|
noBackground?: boolean | undefined;
|
|
970
804
|
noBorder?: boolean | undefined;
|
|
971
|
-
methods?: ("
|
|
805
|
+
methods?: ("crypto" | "card")[] | undefined;
|
|
972
806
|
supportedChainIds?: number[] | undefined;
|
|
973
807
|
rpcOverrides?: {
|
|
974
808
|
[x: string]: string;
|
|
@@ -984,9 +818,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
984
818
|
} | undefined;
|
|
985
819
|
hideTitle?: boolean | undefined;
|
|
986
820
|
hidePoweredBy?: boolean | undefined;
|
|
821
|
+
hideProvider?: boolean | undefined;
|
|
987
822
|
noBackground?: boolean | undefined;
|
|
988
823
|
noBorder?: boolean | undefined;
|
|
989
|
-
methods?: ("
|
|
824
|
+
methods?: ("crypto" | "card")[] | undefined;
|
|
990
825
|
supportedChainIds?: number[] | undefined;
|
|
991
826
|
rpcOverrides?: {
|
|
992
827
|
[x: string]: string;
|
|
@@ -1003,9 +838,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
1003
838
|
} | undefined;
|
|
1004
839
|
hideTitle?: boolean | undefined;
|
|
1005
840
|
hidePoweredBy?: boolean | undefined;
|
|
841
|
+
hideProvider?: boolean | undefined;
|
|
1006
842
|
noBackground?: boolean | undefined;
|
|
1007
843
|
noBorder?: boolean | undefined;
|
|
1008
|
-
methods?: ("
|
|
844
|
+
methods?: ("crypto" | "card")[] | undefined;
|
|
1009
845
|
supportedChainIds?: number[] | undefined;
|
|
1010
846
|
rpcOverrides?: {
|
|
1011
847
|
[x: string]: string;
|
|
@@ -1023,9 +859,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
1023
859
|
} | undefined;
|
|
1024
860
|
hideTitle?: boolean | undefined;
|
|
1025
861
|
hidePoweredBy?: boolean | undefined;
|
|
862
|
+
hideProvider?: boolean | undefined;
|
|
1026
863
|
noBackground?: boolean | undefined;
|
|
1027
864
|
noBorder?: boolean | undefined;
|
|
1028
|
-
methods?: ("
|
|
865
|
+
methods?: ("crypto" | "card")[] | undefined;
|
|
1029
866
|
supportedChainIds?: number[] | undefined;
|
|
1030
867
|
rpcOverrides?: {
|
|
1031
868
|
[x: string]: string;
|
|
@@ -1042,9 +879,10 @@ declare const WidgetDefaultsSchema: Omit<v.ObjectSchema<{
|
|
|
1042
879
|
} | undefined;
|
|
1043
880
|
hideTitle?: boolean | undefined;
|
|
1044
881
|
hidePoweredBy?: boolean | undefined;
|
|
882
|
+
hideProvider?: boolean | undefined;
|
|
1045
883
|
noBackground?: boolean | undefined;
|
|
1046
884
|
noBorder?: boolean | undefined;
|
|
1047
|
-
methods?: ("
|
|
885
|
+
methods?: ("crypto" | "card")[] | undefined;
|
|
1048
886
|
supportedChainIds?: number[] | undefined;
|
|
1049
887
|
rpcOverrides?: {
|
|
1050
888
|
[x: string]: string;
|
package/dist/tokenflight-swap.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
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-Nd9setTj.js";import"./shared.module-C-kWMzqW.js";import{n as s,t as c}from"./register-widget-DOzDJD94.js";import"./widget-BadYytj9.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-CR-1NeiW.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};
|