@unifold/ui-react 0.1.46 → 0.1.48

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
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { AutoSwapResponse, ChainType, Wallet, FiatCurrency, ExecutionStatus, FeaturedToken, PaymentNetwork, DestinationToken, DestinationTokenChain, PaymentIntent, DepositQuote, SupportedDestinationTokensResponse, VerifyAddressResponse } from '@unifold/core';
2
+ import { AutoSwapResponse, ChainType, DepositEvent, Wallet, FiatCurrency, ExecutionStatus, FeaturedToken, PaymentNetwork, DestinationToken, DestinationTokenChain, PaymentIntent, DepositQuote, SupportedDestinationTokensResponse, VerifyAddressResponse } from '@unifold/core';
3
3
  export { ChainType } from '@unifold/core';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
@@ -192,6 +192,7 @@ interface DepositModalProps {
192
192
  transaction?: unknown;
193
193
  executionId?: string;
194
194
  }) => void;
195
+ onEvent?: (event: DepositEvent) => void;
195
196
  onDepositError?: (error: {
196
197
  message: string;
197
198
  error?: unknown;
@@ -203,7 +204,7 @@ interface DepositModalProps {
203
204
  /** First screen when the modal opens. Default `main` (deposit menu). */
204
205
  initialScreen?: DepositModalInitialScreen;
205
206
  }
206
- declare function DepositModal({ open, onOpenChange, userId, publishableKey, modalTitle, destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, hideDepositTracker, showBalanceHeader, transferInputVariant, depositConfirmationMode, enableConnectWallet, browserWalletAmountQuickSelect, enablePayWithExchange, hideDepositFlowInfo, hideDisplayDescription, onDepositSuccess, onDepositError, theme, hideOverlay, initialScreen, transferCryptoTitle, depositWithCardTitle, payWithExchangeTitle, depositTrackerTitle, depositTrackerSubTitle, }: DepositModalProps): react_jsx_runtime.JSX.Element;
207
+ declare function DepositModal({ open, onOpenChange, userId, publishableKey, modalTitle, destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, hideDepositTracker, showBalanceHeader, transferInputVariant, depositConfirmationMode, enableConnectWallet, browserWalletAmountQuickSelect, enablePayWithExchange, hideDepositFlowInfo, hideDisplayDescription, onDepositSuccess, onDepositError, onEvent, theme, hideOverlay, initialScreen, transferCryptoTitle, depositWithCardTitle, payWithExchangeTitle, depositTrackerTitle, depositTrackerSubTitle, }: DepositModalProps): react_jsx_runtime.JSX.Element;
207
208
 
208
209
  interface DepositHeaderProps {
209
210
  title: string;
@@ -324,6 +325,7 @@ interface BuyWithCardProps {
324
325
  transaction?: unknown;
325
326
  executionId?: string;
326
327
  }) => void;
328
+ onEvent?: (event: DepositEvent) => void;
327
329
  onDepositError?: (error: {
328
330
  message: string;
329
331
  error?: unknown;
@@ -338,7 +340,7 @@ interface BuyWithCardProps {
338
340
  hideDisplayDescription?: boolean;
339
341
  }
340
342
  declare function BuyWithCard({ userId, publishableKey, view: externalView, onViewChange, maxAmountUsd, accentColor, // Keep prop for backward compatibility but don't use default
341
- destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, onDepositSuccess, onDepositError, themeClass, wallets: externalWallets, assetCdnUrl, hideDepositFlowInfo, hideDisplayDescription, }: BuyWithCardProps): react_jsx_runtime.JSX.Element;
343
+ destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, onDepositSuccess, onDepositError, onEvent, themeClass, wallets: externalWallets, assetCdnUrl, hideDepositFlowInfo, hideDisplayDescription, }: BuyWithCardProps): react_jsx_runtime.JSX.Element;
342
344
 
343
345
  interface CurrencyModalProps {
344
346
  open: boolean;
@@ -465,6 +467,18 @@ interface CheckoutModalProps {
465
467
  modalTitle?: string;
466
468
  /** Enable browser wallet connection option. Defaults to false */
467
469
  enableConnectWallet?: boolean;
470
+ /**
471
+ * Pre-select source token/chain in the Transfer Crypto view.
472
+ * All four props are optional. To match, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
473
+ * If omitted or no match is found in `/supported_deposit_tokens`, the first available token and chain are used.
474
+ */
475
+ defaultSourceChainType?: ChainType;
476
+ /** Source chain ID (e.g. `"mainnet"`, `"137"`). Must be paired with `defaultSourceChainType` + symbol or token address. */
477
+ defaultSourceChainId?: string;
478
+ /** Source token contract address. Must be paired with `defaultSourceChainType` + `defaultSourceChainId`. */
479
+ defaultSourceTokenAddress?: string;
480
+ /** Source token symbol (e.g. `"USDC"`). Must be paired with `defaultSourceChainType` + `defaultSourceChainId`. */
481
+ defaultSourceSymbol?: string;
468
482
  theme?: "light" | "dark" | "auto";
469
483
  onCheckoutSuccess?: (data: {
470
484
  paymentIntentId: string;
@@ -476,7 +490,7 @@ interface CheckoutModalProps {
476
490
  code?: string;
477
491
  }) => void;
478
492
  }
479
- declare function CheckoutModal({ open, onOpenChange, clientSecret, publishableKey, modalTitle, enableConnectWallet, theme, onCheckoutSuccess, onCheckoutError, }: CheckoutModalProps): react_jsx_runtime.JSX.Element;
493
+ declare function CheckoutModal({ open, onOpenChange, clientSecret, publishableKey, modalTitle, enableConnectWallet, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, theme, onCheckoutSuccess, onCheckoutError, }: CheckoutModalProps): react_jsx_runtime.JSX.Element;
480
494
 
481
495
  interface WithdrawTransactionInfo {
482
496
  /** Source (sending) chain type */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { AutoSwapResponse, ChainType, Wallet, FiatCurrency, ExecutionStatus, FeaturedToken, PaymentNetwork, DestinationToken, DestinationTokenChain, PaymentIntent, DepositQuote, SupportedDestinationTokensResponse, VerifyAddressResponse } from '@unifold/core';
2
+ import { AutoSwapResponse, ChainType, DepositEvent, Wallet, FiatCurrency, ExecutionStatus, FeaturedToken, PaymentNetwork, DestinationToken, DestinationTokenChain, PaymentIntent, DepositQuote, SupportedDestinationTokensResponse, VerifyAddressResponse } from '@unifold/core';
3
3
  export { ChainType } from '@unifold/core';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
@@ -192,6 +192,7 @@ interface DepositModalProps {
192
192
  transaction?: unknown;
193
193
  executionId?: string;
194
194
  }) => void;
195
+ onEvent?: (event: DepositEvent) => void;
195
196
  onDepositError?: (error: {
196
197
  message: string;
197
198
  error?: unknown;
@@ -203,7 +204,7 @@ interface DepositModalProps {
203
204
  /** First screen when the modal opens. Default `main` (deposit menu). */
204
205
  initialScreen?: DepositModalInitialScreen;
205
206
  }
206
- declare function DepositModal({ open, onOpenChange, userId, publishableKey, modalTitle, destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, hideDepositTracker, showBalanceHeader, transferInputVariant, depositConfirmationMode, enableConnectWallet, browserWalletAmountQuickSelect, enablePayWithExchange, hideDepositFlowInfo, hideDisplayDescription, onDepositSuccess, onDepositError, theme, hideOverlay, initialScreen, transferCryptoTitle, depositWithCardTitle, payWithExchangeTitle, depositTrackerTitle, depositTrackerSubTitle, }: DepositModalProps): react_jsx_runtime.JSX.Element;
207
+ declare function DepositModal({ open, onOpenChange, userId, publishableKey, modalTitle, destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, hideDepositTracker, showBalanceHeader, transferInputVariant, depositConfirmationMode, enableConnectWallet, browserWalletAmountQuickSelect, enablePayWithExchange, hideDepositFlowInfo, hideDisplayDescription, onDepositSuccess, onDepositError, onEvent, theme, hideOverlay, initialScreen, transferCryptoTitle, depositWithCardTitle, payWithExchangeTitle, depositTrackerTitle, depositTrackerSubTitle, }: DepositModalProps): react_jsx_runtime.JSX.Element;
207
208
 
208
209
  interface DepositHeaderProps {
209
210
  title: string;
@@ -324,6 +325,7 @@ interface BuyWithCardProps {
324
325
  transaction?: unknown;
325
326
  executionId?: string;
326
327
  }) => void;
328
+ onEvent?: (event: DepositEvent) => void;
327
329
  onDepositError?: (error: {
328
330
  message: string;
329
331
  error?: unknown;
@@ -338,7 +340,7 @@ interface BuyWithCardProps {
338
340
  hideDisplayDescription?: boolean;
339
341
  }
340
342
  declare function BuyWithCard({ userId, publishableKey, view: externalView, onViewChange, maxAmountUsd, accentColor, // Keep prop for backward compatibility but don't use default
341
- destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, onDepositSuccess, onDepositError, themeClass, wallets: externalWallets, assetCdnUrl, hideDepositFlowInfo, hideDisplayDescription, }: BuyWithCardProps): react_jsx_runtime.JSX.Element;
343
+ destinationTokenSymbol, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, onDepositSuccess, onDepositError, onEvent, themeClass, wallets: externalWallets, assetCdnUrl, hideDepositFlowInfo, hideDisplayDescription, }: BuyWithCardProps): react_jsx_runtime.JSX.Element;
342
344
 
343
345
  interface CurrencyModalProps {
344
346
  open: boolean;
@@ -465,6 +467,18 @@ interface CheckoutModalProps {
465
467
  modalTitle?: string;
466
468
  /** Enable browser wallet connection option. Defaults to false */
467
469
  enableConnectWallet?: boolean;
470
+ /**
471
+ * Pre-select source token/chain in the Transfer Crypto view.
472
+ * All four props are optional. To match, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
473
+ * If omitted or no match is found in `/supported_deposit_tokens`, the first available token and chain are used.
474
+ */
475
+ defaultSourceChainType?: ChainType;
476
+ /** Source chain ID (e.g. `"mainnet"`, `"137"`). Must be paired with `defaultSourceChainType` + symbol or token address. */
477
+ defaultSourceChainId?: string;
478
+ /** Source token contract address. Must be paired with `defaultSourceChainType` + `defaultSourceChainId`. */
479
+ defaultSourceTokenAddress?: string;
480
+ /** Source token symbol (e.g. `"USDC"`). Must be paired with `defaultSourceChainType` + `defaultSourceChainId`. */
481
+ defaultSourceSymbol?: string;
468
482
  theme?: "light" | "dark" | "auto";
469
483
  onCheckoutSuccess?: (data: {
470
484
  paymentIntentId: string;
@@ -476,7 +490,7 @@ interface CheckoutModalProps {
476
490
  code?: string;
477
491
  }) => void;
478
492
  }
479
- declare function CheckoutModal({ open, onOpenChange, clientSecret, publishableKey, modalTitle, enableConnectWallet, theme, onCheckoutSuccess, onCheckoutError, }: CheckoutModalProps): react_jsx_runtime.JSX.Element;
493
+ declare function CheckoutModal({ open, onOpenChange, clientSecret, publishableKey, modalTitle, enableConnectWallet, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol, theme, onCheckoutSuccess, onCheckoutError, }: CheckoutModalProps): react_jsx_runtime.JSX.Element;
480
494
 
481
495
  interface WithdrawTransactionInfo {
482
496
  /** Source (sending) chain type */
package/dist/index.js CHANGED
@@ -2496,6 +2496,7 @@ function BuyWithCard({
2496
2496
  destinationTokenAddress,
2497
2497
  onDepositSuccess,
2498
2498
  onDepositError,
2499
+ onEvent,
2499
2500
  themeClass = "",
2500
2501
  wallets: externalWallets,
2501
2502
  assetCdnUrl,
@@ -2849,6 +2850,7 @@ function BuyWithCard({
2849
2850
  setQuotesError("Wallet address not available");
2850
2851
  return;
2851
2852
  }
2853
+ const externalId = (0, import_core9.generatePrefixedKSUID)("orsext");
2852
2854
  const sessionRequest = {
2853
2855
  service_provider: selectedProvider.service_provider,
2854
2856
  country_code: selectedProvider.country_code.toUpperCase() || "US",
@@ -2857,7 +2859,8 @@ function BuyWithCard({
2857
2859
  destination_currency: selectedProvider.destination_currency,
2858
2860
  destination_network: selectedProvider.destination_network,
2859
2861
  wallet_address: wallet.address,
2860
- subdivision_code: userIpInfo?.state || void 0
2862
+ subdivision_code: userIpInfo?.state || void 0,
2863
+ external_id: externalId
2861
2864
  };
2862
2865
  const sessionStartUrl = (0, import_core9.getOnrampSessionStartUrl)(
2863
2866
  sessionRequest,
@@ -2867,7 +2870,14 @@ function BuyWithCard({
2867
2870
  provider: selectedProvider,
2868
2871
  sourceCurrency: currency,
2869
2872
  sourceAmount: amount,
2870
- sessionUrl: sessionStartUrl
2873
+ sessionUrl: sessionStartUrl,
2874
+ externalId
2875
+ });
2876
+ onEvent?.({
2877
+ id: (0, import_core9.generatePrefixedKSUID)("sevt"),
2878
+ type: import_core9.DepositEventType.ONRAMP_SESSION_CREATED,
2879
+ created: Math.floor(Date.now() / 1e3),
2880
+ data: { object: { externalId } }
2871
2881
  });
2872
2882
  window.open(sessionStartUrl, "_blank");
2873
2883
  handleViewChange("onramp");
@@ -11888,6 +11898,7 @@ function DepositModal({
11888
11898
  hideDisplayDescription = false,
11889
11899
  onDepositSuccess,
11890
11900
  onDepositError,
11901
+ onEvent,
11891
11902
  theme = "dark",
11892
11903
  hideOverlay = false,
11893
11904
  initialScreen = "main",
@@ -12402,6 +12413,7 @@ function DepositModal({
12402
12413
  destinationTokenAddress,
12403
12414
  onDepositSuccess,
12404
12415
  onDepositError,
12416
+ onEvent,
12405
12417
  themeClass,
12406
12418
  wallets,
12407
12419
  assetCdnUrl: projectConfig?.asset_cdn_url,
@@ -12600,6 +12612,10 @@ function CheckoutModal({
12600
12612
  publishableKey,
12601
12613
  modalTitle,
12602
12614
  enableConnectWallet = false,
12615
+ defaultSourceChainType,
12616
+ defaultSourceChainId,
12617
+ defaultSourceTokenAddress,
12618
+ defaultSourceSymbol,
12603
12619
  theme = "dark",
12604
12620
  onCheckoutSuccess,
12605
12621
  onCheckoutError
@@ -13097,6 +13113,10 @@ function CheckoutModal({
13097
13113
  destinationChainType: paymentIntent.destination_chain_type,
13098
13114
  destinationChainId: paymentIntent.destination_chain_id,
13099
13115
  destinationTokenAddress: paymentIntent.destination_token_address,
13116
+ defaultSourceChainType,
13117
+ defaultSourceChainId,
13118
+ defaultSourceTokenAddress,
13119
+ defaultSourceSymbol,
13100
13120
  depositConfirmationMode: "auto_ui",
13101
13121
  wallets,
13102
13122
  onSourceTokenChange: setSelectedSource,
package/dist/index.mjs CHANGED
@@ -605,7 +605,9 @@ import {
605
605
  getTokenMetadata,
606
606
  getIconUrlWithCdn,
607
607
  getPreferredIconUrl as getPreferredIconUrl2,
608
- getDefaultOnrampToken
608
+ getDefaultOnrampToken,
609
+ generatePrefixedKSUID,
610
+ DepositEventType
609
611
  } from "@unifold/core";
610
612
 
611
613
  // src/hooks/use-deposit-address.ts
@@ -2418,6 +2420,7 @@ function BuyWithCard({
2418
2420
  destinationTokenAddress,
2419
2421
  onDepositSuccess,
2420
2422
  onDepositError,
2423
+ onEvent,
2421
2424
  themeClass = "",
2422
2425
  wallets: externalWallets,
2423
2426
  assetCdnUrl,
@@ -2771,6 +2774,7 @@ function BuyWithCard({
2771
2774
  setQuotesError("Wallet address not available");
2772
2775
  return;
2773
2776
  }
2777
+ const externalId = generatePrefixedKSUID("orsext");
2774
2778
  const sessionRequest = {
2775
2779
  service_provider: selectedProvider.service_provider,
2776
2780
  country_code: selectedProvider.country_code.toUpperCase() || "US",
@@ -2779,7 +2783,8 @@ function BuyWithCard({
2779
2783
  destination_currency: selectedProvider.destination_currency,
2780
2784
  destination_network: selectedProvider.destination_network,
2781
2785
  wallet_address: wallet.address,
2782
- subdivision_code: userIpInfo?.state || void 0
2786
+ subdivision_code: userIpInfo?.state || void 0,
2787
+ external_id: externalId
2783
2788
  };
2784
2789
  const sessionStartUrl = getOnrampSessionStartUrl(
2785
2790
  sessionRequest,
@@ -2789,7 +2794,14 @@ function BuyWithCard({
2789
2794
  provider: selectedProvider,
2790
2795
  sourceCurrency: currency,
2791
2796
  sourceAmount: amount,
2792
- sessionUrl: sessionStartUrl
2797
+ sessionUrl: sessionStartUrl,
2798
+ externalId
2799
+ });
2800
+ onEvent?.({
2801
+ id: generatePrefixedKSUID("sevt"),
2802
+ type: DepositEventType.ONRAMP_SESSION_CREATED,
2803
+ created: Math.floor(Date.now() / 1e3),
2804
+ data: { object: { externalId } }
2793
2805
  });
2794
2806
  window.open(sessionStartUrl, "_blank");
2795
2807
  handleViewChange("onramp");
@@ -11858,6 +11870,7 @@ function DepositModal({
11858
11870
  hideDisplayDescription = false,
11859
11871
  onDepositSuccess,
11860
11872
  onDepositError,
11873
+ onEvent,
11861
11874
  theme = "dark",
11862
11875
  hideOverlay = false,
11863
11876
  initialScreen = "main",
@@ -12372,6 +12385,7 @@ function DepositModal({
12372
12385
  destinationTokenAddress,
12373
12386
  onDepositSuccess,
12374
12387
  onDepositError,
12388
+ onEvent,
12375
12389
  themeClass,
12376
12390
  wallets,
12377
12391
  assetCdnUrl: projectConfig?.asset_cdn_url,
@@ -12579,6 +12593,10 @@ function CheckoutModal({
12579
12593
  publishableKey,
12580
12594
  modalTitle,
12581
12595
  enableConnectWallet = false,
12596
+ defaultSourceChainType,
12597
+ defaultSourceChainId,
12598
+ defaultSourceTokenAddress,
12599
+ defaultSourceSymbol,
12582
12600
  theme = "dark",
12583
12601
  onCheckoutSuccess,
12584
12602
  onCheckoutError
@@ -13076,6 +13094,10 @@ function CheckoutModal({
13076
13094
  destinationChainType: paymentIntent.destination_chain_type,
13077
13095
  destinationChainId: paymentIntent.destination_chain_id,
13078
13096
  destinationTokenAddress: paymentIntent.destination_token_address,
13097
+ defaultSourceChainType,
13098
+ defaultSourceChainId,
13099
+ defaultSourceTokenAddress,
13100
+ defaultSourceSymbol,
13079
13101
  depositConfirmationMode: "auto_ui",
13080
13102
  wallets,
13081
13103
  onSourceTokenChange: setSelectedSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-react",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "description": "Unifold UI React - Deposit and onramp components for React applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -21,16 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "react": "^18.2.0 || ^19.0.0",
23
23
  "react-dom": "^18.2.0 || ^19.0.0",
24
- "@solana/web3.js": "^1.87.0",
25
- "@solana/spl-token": "^0.3.8"
26
- },
27
- "peerDependenciesMeta": {
28
- "@solana/web3.js": {
29
- "optional": true
30
- },
31
- "@solana/spl-token": {
32
- "optional": true
33
- }
24
+ "@solana/web3.js": "^1.87.0"
34
25
  },
35
26
  "dependencies": {
36
27
  "@radix-ui/react-dialog": "^1.0.5",
@@ -43,10 +34,9 @@
43
34
  "lucide-react": "^0.454.0",
44
35
  "qr-code-styling": "^1.6.0-rc.1",
45
36
  "tailwind-merge": "^2.0.0",
46
- "@unifold/core": "0.1.46"
37
+ "@unifold/core": "0.1.48"
47
38
  },
48
39
  "devDependencies": {
49
- "@solana/spl-token": "^0.3.8",
50
40
  "@solana/web3.js": "^1.87.0",
51
41
  "@types/react": "^19.0.0",
52
42
  "@types/react-dom": "^19.0.0",