@wheelx-widget/widget 0.1.19 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -72,6 +72,8 @@ interface WidgetConfig {
72
72
  evmDifferentAddress?: string;
73
73
  /** Solana链固定收款异地址(base58格式)。配置后,to网络为Solana链时优先使用此地址 */
74
74
  solanaDifferentAddress?: string;
75
+ /** Tron链固定收款异地址(T地址格式,以T开头)。配置后,to网络为Tron链时优先使用此地址 */
76
+ tronDifferentAddress?: string;
75
77
  /**
76
78
  * 返佣ID(affiliation code)。
77
79
  * 配置后在 quote 请求中优先使用此值;为空时回退到从 URL path 中提取。
@@ -85,7 +87,7 @@ interface WheelXProviderProps {
85
87
  }
86
88
  declare const WheelXProvider: React.FC<WheelXProviderProps>;
87
89
 
88
- interface routesItem {
90
+ interface routesItem$1 {
89
91
  name: string;
90
92
  logo: string;
91
93
  }
@@ -106,7 +108,11 @@ interface TxInfoProps {
106
108
  amountOut: string;
107
109
  fromTokenInUsd?: Fraction;
108
110
  router_type: string | null | undefined;
109
- routes?: routesItem[] | undefined;
111
+ routes?: routesItem$1[] | undefined;
112
+ onToggleAiRouter?: () => void;
113
+ hasMultipleQuotes?: boolean;
114
+ /** Current quote request_id — TxInfo re-expands whenever it changes */
115
+ quoteRequestId?: string | null;
110
116
  }
111
117
 
112
118
  interface RefetchQuoteParams {
@@ -123,8 +129,53 @@ interface QuoteRequest {
123
129
  to_address: string;
124
130
  amount: string;
125
131
  slippage?: number;
132
+ /** Whether the user is in auto (recommended) slippage mode — recorded by
133
+ * the backend. false = manual preset/custom value. */
134
+ is_auto_slippage?: boolean;
126
135
  to_platform_id: number;
127
136
  sponsor_gas?: boolean;
137
+ btc_transfer_mode?: 'psbt' | 'deposit';
138
+ }
139
+ interface routesItem {
140
+ name: string;
141
+ logo: string;
142
+ }
143
+ interface QuoteItem {
144
+ request_id: string;
145
+ router: string;
146
+ amount_out: string;
147
+ tx: {
148
+ chainId: number;
149
+ data: `0x${string}`;
150
+ to: `0x${string}`;
151
+ value: string;
152
+ gas?: bigint | null;
153
+ maxFeePerGas?: bigint | undefined;
154
+ maxPriorityFeePerGas?: bigint | undefined;
155
+ message?: string;
156
+ sender?: string;
157
+ tx?: string;
158
+ psbt?: string;
159
+ encoding?: string;
160
+ /** JSON-serialized TronTxInfo for Tron approve transactions */
161
+ approveTx?: string;
162
+ };
163
+ routes: routesItem[];
164
+ gas_fee?: string | null;
165
+ /** Provider fee (USD) — legacy fallback: `fee_usd` */
166
+ fee_usd?: string | null;
167
+ /** Network cost (USD) */
168
+ native_fee_usd?: string | null;
169
+ /** Per-route approve payload (ERC-20 / TRC-20) */
170
+ approve?: {
171
+ token: string;
172
+ spender: string;
173
+ amount: bigint;
174
+ } | null;
175
+ /** Deposit address for deposit-address flows (Tron / Bitcoin) */
176
+ deposit_address?: string | null;
177
+ /** Per-route estimated completion time (seconds) */
178
+ estimated_time?: number;
128
179
  }
129
180
  type QuoteErrorType = 'business_error' | 'http_error' | 'network_error' | 'timeout' | 'unknown_error';
130
181
  interface QuoteMutationError extends Error {
@@ -152,6 +203,8 @@ interface TokenInfo {
152
203
  platform_id?: number;
153
204
  platform_type?: string[];
154
205
  isSolana?: boolean;
206
+ isTron?: boolean;
207
+ isBitcoin?: boolean;
155
208
  fee_level?: FeeLevel;
156
209
  }
157
210
  interface TokenInfoWithBalance extends TokenInfo {
@@ -200,6 +253,32 @@ declare function getChainsAndTokens(): Promise<ChainsAndTokens>;
200
253
  declare const useChainsAndTokens: (enabled?: boolean) => _tanstack_react_query.UseQueryResult<ChainsAndTokens, Error>;
201
254
  declare function mergeTokensWithCompositeKey(arr1: TokenInfoWithBalance[], arr2: TokenInfoWithBalance[]): TokenInfoWithBalance[];
202
255
 
256
+ /**
257
+ * Parameter section of a Tron transaction from the backend.
258
+ *
259
+ * Two shapes come back from the quote API:
260
+ * - TriggerSmartContract (TRC-20 swap / approve): contract_address + data
261
+ * - TransferContract (native TRX, deposit-address bridges): to_address + amount
262
+ * and NO calldata at all
263
+ */
264
+ interface TronTxParameter {
265
+ owner_address: string;
266
+ contract_address?: string;
267
+ data?: string;
268
+ call_value?: number;
269
+ /** Native TransferContract only. */
270
+ to_address?: string;
271
+ /** Native TransferContract only. */
272
+ amount?: number;
273
+ }
274
+ /** Tron transaction data returned by the quote API (tron→X swaps) */
275
+ interface TronTxInfo {
276
+ parameter: TronTxParameter;
277
+ type: string;
278
+ gas: null | number;
279
+ chainId: number;
280
+ }
281
+
203
282
  type WheelXWidgetProps = {
204
283
  config?: WidgetConfig;
205
284
  };
@@ -219,9 +298,20 @@ interface QuoteInfo {
219
298
  tx_value?: string | null;
220
299
  points?: number | 0 | string;
221
300
  quote_message?: string | null;
222
- routes?: routesItem[];
301
+ routes?: routesItem$1[];
302
+ quotes?: QuoteItem[];
223
303
  solanaTxMessage?: string;
224
304
  solanaTxSender?: string;
305
+ tronTx?: TronTxInfo | null;
306
+ tronApproveTx?: TronTxInfo | null;
307
+ tronDepositAddress?: string | null;
308
+ bitcoinPsbt?: string;
309
+ bitcoinDepositAddress?: string | null;
310
+ approve?: {
311
+ token: string;
312
+ spender: string;
313
+ amount: bigint;
314
+ } | null;
225
315
  }
226
316
  interface QuoteRequestWithToTokenDecimals extends QuoteRequest {
227
317
  toTokenDecimals: number;
@@ -255,6 +345,10 @@ interface SwapState {
255
345
  shortLink?: string;
256
346
  transactionType?: string;
257
347
  autoSlippage?: number | undefined;
348
+ /** Session-level slippage mode: true = auto (recommended), false = manual.
349
+ * Synced from the per-address localStorage preference by SlippageSettings
350
+ * and used by the quote request funnel (getState read, always fresh). */
351
+ isAutoSlippage: boolean;
258
352
  tradeType?: string | null;
259
353
  }
260
354
  interface SwapAndBridgeContextStore extends SwapState {
@@ -273,6 +367,7 @@ interface SwapAndBridgeContextStore extends SwapState {
273
367
  setShortLink: (value: string) => void;
274
368
  setTransactionType: (value: string) => void;
275
369
  setAutoSlippage: (value: number | undefined) => void;
370
+ setIsAutoSlippage: (value: boolean) => void;
276
371
  }
277
372
  declare const useSwapAndBridgeContextStore: zustand.UseBoundStore<zustand.StoreApi<SwapAndBridgeContextStore>>;
278
373
  declare const useInitSwapAndBridgeState: (config?: WidgetConfig) => void;
@@ -296,6 +391,14 @@ interface TxStateContextStore {
296
391
  setSolanaFromTxHash: (hash: string | null) => void;
297
392
  isSolanaTransaction: boolean;
298
393
  setIsSolanaTransaction: (isSolana: boolean) => void;
394
+ tronFromTxHash: string | null;
395
+ setTronFromTxHash: (hash: string | null) => void;
396
+ isTronTransaction: boolean;
397
+ setIsTronTransaction: (isTronTransaction: boolean) => void;
398
+ bitcoinFromTxHash: string | null;
399
+ setBitcoinFromTxHash: (hash: string | null) => void;
400
+ isBitcoinTransaction: boolean;
401
+ setIsBitcoinTransaction: (isBitcoinTransaction: boolean) => void;
299
402
  }
300
403
  declare const useTxStateContextStore: zustand.UseBoundStore<zustand.StoreApi<TxStateContextStore>>;
301
404
 
@@ -312,7 +415,7 @@ declare const useRefreshLoading: () => {
312
415
  interface Props {
313
416
  chainId: number;
314
417
  tokenAddress?: `0x${string}`;
315
- connectAddress?: `0x${string}`;
418
+ connectAddress?: string;
316
419
  }
317
420
  interface BalanceResult {
318
421
  decimals: number;
@@ -352,6 +455,27 @@ declare const useEvmAddress: () => `0x${string}` | undefined;
352
455
  * Used to detect and intercept deep links when the widget runs inside
353
456
  * a WebView (e.g., React Native, Android WebView, WKWebView).
354
457
  */
458
+ declare global {
459
+ interface Window {
460
+ ReactNativeWebView?: {
461
+ postMessage?: (msg: string) => void;
462
+ };
463
+ __wheelx_wallet_callback_url__?: string;
464
+ __walletx_callback_params__?: Record<string, string>;
465
+ __wheelx_trigger_url_update__?: () => void;
466
+ __wheelx_callback_listener_installed?: boolean;
467
+ __wheelx_pending_callback__?: string;
468
+ DynamicLabs?: {
469
+ utils?: {
470
+ PlatformService?: unknown;
471
+ };
472
+ };
473
+ __DYNAMIC_LABS__?: {
474
+ PlatformService?: unknown;
475
+ };
476
+ PlatformService?: unknown;
477
+ }
478
+ }
355
479
  /** Check if running inside a React Native WebView */
356
480
  declare const isReactNativeWebView: () => boolean;
357
481
  /** Check if running in any WebView (Android/iOS) */
@@ -399,11 +523,19 @@ interface WalletStore {
399
523
  setIsEthWalletConnected: (isEthWalletConnected: boolean) => void;
400
524
  isSolanaWalletConnected: boolean;
401
525
  setIsSolanaWalletConnected: (isSolanaWalletConnected: boolean) => void;
526
+ isTronWalletConnected: boolean;
527
+ setIsTronWalletConnected: (isTronWalletConnected: boolean) => void;
528
+ isBitcoinWalletConnected: boolean;
529
+ setIsBitcoinWalletConnected: (isBitcoinWalletConnected: boolean) => void;
402
530
  totalConnectedWallets: number;
403
531
  setTotalConnectedWallets: () => void;
404
532
  totalWallets: number;
405
533
  solanaWalletAddress: string | null;
406
534
  setSolanaWalletAddress: (address: string | null) => void;
535
+ tronWalletAddress: string | null;
536
+ setTronWalletAddress: (address: string | null) => void;
537
+ bitcoinWalletAddress: string | null;
538
+ setBitcoinWalletAddress: (address: string | null) => void;
407
539
  evmWalletAddress: string | null;
408
540
  evmWalletConnectorId: string | null;
409
541
  setEvmWalletInfo: (address: string | null, connectorId: string | null) => void;
package/dist/index.d.ts CHANGED
@@ -72,6 +72,8 @@ interface WidgetConfig {
72
72
  evmDifferentAddress?: string;
73
73
  /** Solana链固定收款异地址(base58格式)。配置后,to网络为Solana链时优先使用此地址 */
74
74
  solanaDifferentAddress?: string;
75
+ /** Tron链固定收款异地址(T地址格式,以T开头)。配置后,to网络为Tron链时优先使用此地址 */
76
+ tronDifferentAddress?: string;
75
77
  /**
76
78
  * 返佣ID(affiliation code)。
77
79
  * 配置后在 quote 请求中优先使用此值;为空时回退到从 URL path 中提取。
@@ -85,7 +87,7 @@ interface WheelXProviderProps {
85
87
  }
86
88
  declare const WheelXProvider: React.FC<WheelXProviderProps>;
87
89
 
88
- interface routesItem {
90
+ interface routesItem$1 {
89
91
  name: string;
90
92
  logo: string;
91
93
  }
@@ -106,7 +108,11 @@ interface TxInfoProps {
106
108
  amountOut: string;
107
109
  fromTokenInUsd?: Fraction;
108
110
  router_type: string | null | undefined;
109
- routes?: routesItem[] | undefined;
111
+ routes?: routesItem$1[] | undefined;
112
+ onToggleAiRouter?: () => void;
113
+ hasMultipleQuotes?: boolean;
114
+ /** Current quote request_id — TxInfo re-expands whenever it changes */
115
+ quoteRequestId?: string | null;
110
116
  }
111
117
 
112
118
  interface RefetchQuoteParams {
@@ -123,8 +129,53 @@ interface QuoteRequest {
123
129
  to_address: string;
124
130
  amount: string;
125
131
  slippage?: number;
132
+ /** Whether the user is in auto (recommended) slippage mode — recorded by
133
+ * the backend. false = manual preset/custom value. */
134
+ is_auto_slippage?: boolean;
126
135
  to_platform_id: number;
127
136
  sponsor_gas?: boolean;
137
+ btc_transfer_mode?: 'psbt' | 'deposit';
138
+ }
139
+ interface routesItem {
140
+ name: string;
141
+ logo: string;
142
+ }
143
+ interface QuoteItem {
144
+ request_id: string;
145
+ router: string;
146
+ amount_out: string;
147
+ tx: {
148
+ chainId: number;
149
+ data: `0x${string}`;
150
+ to: `0x${string}`;
151
+ value: string;
152
+ gas?: bigint | null;
153
+ maxFeePerGas?: bigint | undefined;
154
+ maxPriorityFeePerGas?: bigint | undefined;
155
+ message?: string;
156
+ sender?: string;
157
+ tx?: string;
158
+ psbt?: string;
159
+ encoding?: string;
160
+ /** JSON-serialized TronTxInfo for Tron approve transactions */
161
+ approveTx?: string;
162
+ };
163
+ routes: routesItem[];
164
+ gas_fee?: string | null;
165
+ /** Provider fee (USD) — legacy fallback: `fee_usd` */
166
+ fee_usd?: string | null;
167
+ /** Network cost (USD) */
168
+ native_fee_usd?: string | null;
169
+ /** Per-route approve payload (ERC-20 / TRC-20) */
170
+ approve?: {
171
+ token: string;
172
+ spender: string;
173
+ amount: bigint;
174
+ } | null;
175
+ /** Deposit address for deposit-address flows (Tron / Bitcoin) */
176
+ deposit_address?: string | null;
177
+ /** Per-route estimated completion time (seconds) */
178
+ estimated_time?: number;
128
179
  }
129
180
  type QuoteErrorType = 'business_error' | 'http_error' | 'network_error' | 'timeout' | 'unknown_error';
130
181
  interface QuoteMutationError extends Error {
@@ -152,6 +203,8 @@ interface TokenInfo {
152
203
  platform_id?: number;
153
204
  platform_type?: string[];
154
205
  isSolana?: boolean;
206
+ isTron?: boolean;
207
+ isBitcoin?: boolean;
155
208
  fee_level?: FeeLevel;
156
209
  }
157
210
  interface TokenInfoWithBalance extends TokenInfo {
@@ -200,6 +253,32 @@ declare function getChainsAndTokens(): Promise<ChainsAndTokens>;
200
253
  declare const useChainsAndTokens: (enabled?: boolean) => _tanstack_react_query.UseQueryResult<ChainsAndTokens, Error>;
201
254
  declare function mergeTokensWithCompositeKey(arr1: TokenInfoWithBalance[], arr2: TokenInfoWithBalance[]): TokenInfoWithBalance[];
202
255
 
256
+ /**
257
+ * Parameter section of a Tron transaction from the backend.
258
+ *
259
+ * Two shapes come back from the quote API:
260
+ * - TriggerSmartContract (TRC-20 swap / approve): contract_address + data
261
+ * - TransferContract (native TRX, deposit-address bridges): to_address + amount
262
+ * and NO calldata at all
263
+ */
264
+ interface TronTxParameter {
265
+ owner_address: string;
266
+ contract_address?: string;
267
+ data?: string;
268
+ call_value?: number;
269
+ /** Native TransferContract only. */
270
+ to_address?: string;
271
+ /** Native TransferContract only. */
272
+ amount?: number;
273
+ }
274
+ /** Tron transaction data returned by the quote API (tron→X swaps) */
275
+ interface TronTxInfo {
276
+ parameter: TronTxParameter;
277
+ type: string;
278
+ gas: null | number;
279
+ chainId: number;
280
+ }
281
+
203
282
  type WheelXWidgetProps = {
204
283
  config?: WidgetConfig;
205
284
  };
@@ -219,9 +298,20 @@ interface QuoteInfo {
219
298
  tx_value?: string | null;
220
299
  points?: number | 0 | string;
221
300
  quote_message?: string | null;
222
- routes?: routesItem[];
301
+ routes?: routesItem$1[];
302
+ quotes?: QuoteItem[];
223
303
  solanaTxMessage?: string;
224
304
  solanaTxSender?: string;
305
+ tronTx?: TronTxInfo | null;
306
+ tronApproveTx?: TronTxInfo | null;
307
+ tronDepositAddress?: string | null;
308
+ bitcoinPsbt?: string;
309
+ bitcoinDepositAddress?: string | null;
310
+ approve?: {
311
+ token: string;
312
+ spender: string;
313
+ amount: bigint;
314
+ } | null;
225
315
  }
226
316
  interface QuoteRequestWithToTokenDecimals extends QuoteRequest {
227
317
  toTokenDecimals: number;
@@ -255,6 +345,10 @@ interface SwapState {
255
345
  shortLink?: string;
256
346
  transactionType?: string;
257
347
  autoSlippage?: number | undefined;
348
+ /** Session-level slippage mode: true = auto (recommended), false = manual.
349
+ * Synced from the per-address localStorage preference by SlippageSettings
350
+ * and used by the quote request funnel (getState read, always fresh). */
351
+ isAutoSlippage: boolean;
258
352
  tradeType?: string | null;
259
353
  }
260
354
  interface SwapAndBridgeContextStore extends SwapState {
@@ -273,6 +367,7 @@ interface SwapAndBridgeContextStore extends SwapState {
273
367
  setShortLink: (value: string) => void;
274
368
  setTransactionType: (value: string) => void;
275
369
  setAutoSlippage: (value: number | undefined) => void;
370
+ setIsAutoSlippage: (value: boolean) => void;
276
371
  }
277
372
  declare const useSwapAndBridgeContextStore: zustand.UseBoundStore<zustand.StoreApi<SwapAndBridgeContextStore>>;
278
373
  declare const useInitSwapAndBridgeState: (config?: WidgetConfig) => void;
@@ -296,6 +391,14 @@ interface TxStateContextStore {
296
391
  setSolanaFromTxHash: (hash: string | null) => void;
297
392
  isSolanaTransaction: boolean;
298
393
  setIsSolanaTransaction: (isSolana: boolean) => void;
394
+ tronFromTxHash: string | null;
395
+ setTronFromTxHash: (hash: string | null) => void;
396
+ isTronTransaction: boolean;
397
+ setIsTronTransaction: (isTronTransaction: boolean) => void;
398
+ bitcoinFromTxHash: string | null;
399
+ setBitcoinFromTxHash: (hash: string | null) => void;
400
+ isBitcoinTransaction: boolean;
401
+ setIsBitcoinTransaction: (isBitcoinTransaction: boolean) => void;
299
402
  }
300
403
  declare const useTxStateContextStore: zustand.UseBoundStore<zustand.StoreApi<TxStateContextStore>>;
301
404
 
@@ -312,7 +415,7 @@ declare const useRefreshLoading: () => {
312
415
  interface Props {
313
416
  chainId: number;
314
417
  tokenAddress?: `0x${string}`;
315
- connectAddress?: `0x${string}`;
418
+ connectAddress?: string;
316
419
  }
317
420
  interface BalanceResult {
318
421
  decimals: number;
@@ -352,6 +455,27 @@ declare const useEvmAddress: () => `0x${string}` | undefined;
352
455
  * Used to detect and intercept deep links when the widget runs inside
353
456
  * a WebView (e.g., React Native, Android WebView, WKWebView).
354
457
  */
458
+ declare global {
459
+ interface Window {
460
+ ReactNativeWebView?: {
461
+ postMessage?: (msg: string) => void;
462
+ };
463
+ __wheelx_wallet_callback_url__?: string;
464
+ __walletx_callback_params__?: Record<string, string>;
465
+ __wheelx_trigger_url_update__?: () => void;
466
+ __wheelx_callback_listener_installed?: boolean;
467
+ __wheelx_pending_callback__?: string;
468
+ DynamicLabs?: {
469
+ utils?: {
470
+ PlatformService?: unknown;
471
+ };
472
+ };
473
+ __DYNAMIC_LABS__?: {
474
+ PlatformService?: unknown;
475
+ };
476
+ PlatformService?: unknown;
477
+ }
478
+ }
355
479
  /** Check if running inside a React Native WebView */
356
480
  declare const isReactNativeWebView: () => boolean;
357
481
  /** Check if running in any WebView (Android/iOS) */
@@ -399,11 +523,19 @@ interface WalletStore {
399
523
  setIsEthWalletConnected: (isEthWalletConnected: boolean) => void;
400
524
  isSolanaWalletConnected: boolean;
401
525
  setIsSolanaWalletConnected: (isSolanaWalletConnected: boolean) => void;
526
+ isTronWalletConnected: boolean;
527
+ setIsTronWalletConnected: (isTronWalletConnected: boolean) => void;
528
+ isBitcoinWalletConnected: boolean;
529
+ setIsBitcoinWalletConnected: (isBitcoinWalletConnected: boolean) => void;
402
530
  totalConnectedWallets: number;
403
531
  setTotalConnectedWallets: () => void;
404
532
  totalWallets: number;
405
533
  solanaWalletAddress: string | null;
406
534
  setSolanaWalletAddress: (address: string | null) => void;
535
+ tronWalletAddress: string | null;
536
+ setTronWalletAddress: (address: string | null) => void;
537
+ bitcoinWalletAddress: string | null;
538
+ setBitcoinWalletAddress: (address: string | null) => void;
407
539
  evmWalletAddress: string | null;
408
540
  evmWalletConnectorId: string | null;
409
541
  setEvmWalletInfo: (address: string | null, connectorId: string | null) => void;