@unifold/ui-react 0.1.45 → 0.1.47

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 */
@@ -514,7 +528,7 @@ interface WithdrawModalProps {
514
528
  sourceTokenSymbol?: string;
515
529
  recipientAddress?: string;
516
530
  senderAddress: string;
517
- onWithdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
531
+ onWithdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
518
532
  onWithdrawSuccess?: (data: {
519
533
  message: string;
520
534
  transaction?: unknown;
@@ -584,7 +598,8 @@ interface WithdrawFormProps {
584
598
  senderAddress: string;
585
599
  sourceChainId: string;
586
600
  sourceTokenAddress: string;
587
- onWithdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
601
+ /** Called when the user confirms the withdrawal. The host app signs and submits the transaction. */
602
+ onWithdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
588
603
  onWithdrawError?: (error: {
589
604
  message: string;
590
605
  error?: unknown;
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 */
@@ -514,7 +528,7 @@ interface WithdrawModalProps {
514
528
  sourceTokenSymbol?: string;
515
529
  recipientAddress?: string;
516
530
  senderAddress: string;
517
- onWithdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
531
+ onWithdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
518
532
  onWithdrawSuccess?: (data: {
519
533
  message: string;
520
534
  transaction?: unknown;
@@ -584,7 +598,8 @@ interface WithdrawFormProps {
584
598
  senderAddress: string;
585
599
  sourceChainId: string;
586
600
  sourceTokenAddress: string;
587
- onWithdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
601
+ /** Called when the user confirms the withdrawal. The host app signs and submits the transaction. */
602
+ onWithdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
588
603
  onWithdrawError?: (error: {
589
604
  message: string;
590
605
  error?: unknown;
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");
@@ -10588,10 +10598,11 @@ function BrowserWalletModal({
10588
10598
  const chainType = depositWallet.chain_type;
10589
10599
  const recipientAddress = depositWallet.address;
10590
10600
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
10591
- const { executions: depositExecutions, isPolling } = useDepositPolling({
10601
+ const { executions: depositExecutions, isPolling, handleIveDeposited } = useDepositPolling({
10592
10602
  userId,
10593
10603
  publishableKey,
10594
10604
  clientSecret,
10605
+ depositWalletId: depositWallet.id,
10595
10606
  enabled: open && hasSignedTransaction,
10596
10607
  onDepositSuccess,
10597
10608
  onDepositError
@@ -10842,6 +10853,7 @@ function BrowserWalletModal({
10842
10853
  }
10843
10854
  setReceivedUsdAtSubmission(checkoutReceivedUsd ?? "0");
10844
10855
  setHasSignedTransaction(true);
10856
+ handleIveDeposited();
10845
10857
  setIsConfirming(false);
10846
10858
  setStep("confirming");
10847
10859
  onSuccess?.(txHash);
@@ -11886,6 +11898,7 @@ function DepositModal({
11886
11898
  hideDisplayDescription = false,
11887
11899
  onDepositSuccess,
11888
11900
  onDepositError,
11901
+ onEvent,
11889
11902
  theme = "dark",
11890
11903
  hideOverlay = false,
11891
11904
  initialScreen = "main",
@@ -12400,6 +12413,7 @@ function DepositModal({
12400
12413
  destinationTokenAddress,
12401
12414
  onDepositSuccess,
12402
12415
  onDepositError,
12416
+ onEvent,
12403
12417
  themeClass,
12404
12418
  wallets,
12405
12419
  assetCdnUrl: projectConfig?.asset_cdn_url,
@@ -12598,6 +12612,10 @@ function CheckoutModal({
12598
12612
  publishableKey,
12599
12613
  modalTitle,
12600
12614
  enableConnectWallet = false,
12615
+ defaultSourceChainType,
12616
+ defaultSourceChainId,
12617
+ defaultSourceTokenAddress,
12618
+ defaultSourceSymbol,
12601
12619
  theme = "dark",
12602
12620
  onCheckoutSuccess,
12603
12621
  onCheckoutError
@@ -13095,6 +13113,10 @@ function CheckoutModal({
13095
13113
  destinationChainType: paymentIntent.destination_chain_type,
13096
13114
  destinationChainId: paymentIntent.destination_chain_id,
13097
13115
  destinationTokenAddress: paymentIntent.destination_token_address,
13116
+ defaultSourceChainType,
13117
+ defaultSourceChainId,
13118
+ defaultSourceTokenAddress,
13119
+ defaultSourceSymbol,
13098
13120
  depositConfirmationMode: "auto_ui",
13099
13121
  wallets,
13100
13122
  onSourceTokenChange: setSelectedSource,
@@ -14051,6 +14073,9 @@ function WithdrawForm({
14051
14073
  setIsSubmitting(true);
14052
14074
  setSubmitError(null);
14053
14075
  try {
14076
+ if (!onWithdraw) {
14077
+ throw new Error("No withdrawal method available. Please provide an onWithdraw handler.");
14078
+ }
14054
14079
  const depositWallet = await onDepositWalletCreation({
14055
14080
  destinationChainType: selectedChain.chain_type,
14056
14081
  destinationChainId: selectedChain.chain_id,
@@ -14108,63 +14133,16 @@ function WithdrawForm({
14108
14133
  withdrawIntentAddress: depositWallet.address,
14109
14134
  recipientAddress: trimmedAddress
14110
14135
  };
14111
- const wallet = await detectBrowserWallet(sourceChainType, senderAddress);
14112
- console.log("browser wallet", wallet);
14113
- if (wallet) {
14114
- try {
14115
- if (wallet.chainFamily === "evm" && isHypercoreChain(sourceChainId)) {
14116
- await sendHypercoreWithdraw({
14117
- provider: wallet.provider,
14118
- fromAddress: wallet.address,
14119
- depositWalletAddress: depositWallet.address,
14120
- sourceTokenAddress,
14121
- amount: humanAmount,
14122
- tokenSymbol,
14123
- publishableKey
14124
- });
14125
- } else if (wallet.chainFamily === "evm") {
14126
- await sendEvmWithdraw({
14127
- provider: wallet.provider,
14128
- fromAddress: wallet.address,
14129
- depositWalletAddress: depositWallet.address,
14130
- sourceTokenAddress,
14131
- sourceChainId,
14132
- amountBaseUnit
14133
- });
14134
- } else if (wallet.chainFamily === "solana") {
14135
- await sendSolanaWithdraw({
14136
- provider: wallet.provider,
14137
- fromAddress: wallet.address,
14138
- depositWalletAddress: depositWallet.address,
14139
- sourceTokenAddress,
14140
- amountBaseUnit,
14141
- publishableKey
14142
- });
14143
- }
14144
- } catch (walletErr) {
14145
- console.error("[Unifold] Browser wallet send failed:", walletErr, {
14146
- wallet: `${wallet.name} (${wallet.chainFamily})`,
14147
- sourceChainId,
14148
- amount: humanAmount,
14149
- amountBaseUnit,
14150
- depositWallet: depositWallet.address
14151
- });
14152
- throw walletErr;
14153
- }
14154
- } else if (onWithdraw) {
14155
- try {
14156
- await onWithdraw(txInfo);
14157
- } catch (callbackErr) {
14158
- console.error("[Unifold] onWithdraw callback failed:", callbackErr, {
14159
- sourceChainId,
14160
- amount: humanAmount,
14161
- amountBaseUnit,
14162
- depositWallet: depositWallet.address
14163
- });
14164
- throw callbackErr;
14165
- }
14166
- } else {
14167
- throw new Error("No withdrawal method available. Please connect a wallet.");
14136
+ try {
14137
+ await onWithdraw(txInfo);
14138
+ } catch (callbackErr) {
14139
+ console.error("[Unifold] onWithdraw callback failed:", callbackErr, {
14140
+ sourceChainId,
14141
+ amount: humanAmount,
14142
+ amountBaseUnit,
14143
+ depositWallet: depositWallet.address
14144
+ });
14145
+ throw callbackErr;
14168
14146
  }
14169
14147
  onWithdrawSubmitted?.(txInfo);
14170
14148
  } catch (err) {
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");
@@ -10558,10 +10570,11 @@ function BrowserWalletModal({
10558
10570
  const chainType = depositWallet.chain_type;
10559
10571
  const recipientAddress = depositWallet.address;
10560
10572
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
10561
- const { executions: depositExecutions, isPolling } = useDepositPolling({
10573
+ const { executions: depositExecutions, isPolling, handleIveDeposited } = useDepositPolling({
10562
10574
  userId,
10563
10575
  publishableKey,
10564
10576
  clientSecret,
10577
+ depositWalletId: depositWallet.id,
10565
10578
  enabled: open && hasSignedTransaction,
10566
10579
  onDepositSuccess,
10567
10580
  onDepositError
@@ -10812,6 +10825,7 @@ function BrowserWalletModal({
10812
10825
  }
10813
10826
  setReceivedUsdAtSubmission(checkoutReceivedUsd ?? "0");
10814
10827
  setHasSignedTransaction(true);
10828
+ handleIveDeposited();
10815
10829
  setIsConfirming(false);
10816
10830
  setStep("confirming");
10817
10831
  onSuccess?.(txHash);
@@ -11856,6 +11870,7 @@ function DepositModal({
11856
11870
  hideDisplayDescription = false,
11857
11871
  onDepositSuccess,
11858
11872
  onDepositError,
11873
+ onEvent,
11859
11874
  theme = "dark",
11860
11875
  hideOverlay = false,
11861
11876
  initialScreen = "main",
@@ -12370,6 +12385,7 @@ function DepositModal({
12370
12385
  destinationTokenAddress,
12371
12386
  onDepositSuccess,
12372
12387
  onDepositError,
12388
+ onEvent,
12373
12389
  themeClass,
12374
12390
  wallets,
12375
12391
  assetCdnUrl: projectConfig?.asset_cdn_url,
@@ -12577,6 +12593,10 @@ function CheckoutModal({
12577
12593
  publishableKey,
12578
12594
  modalTitle,
12579
12595
  enableConnectWallet = false,
12596
+ defaultSourceChainType,
12597
+ defaultSourceChainId,
12598
+ defaultSourceTokenAddress,
12599
+ defaultSourceSymbol,
12580
12600
  theme = "dark",
12581
12601
  onCheckoutSuccess,
12582
12602
  onCheckoutError
@@ -13074,6 +13094,10 @@ function CheckoutModal({
13074
13094
  destinationChainType: paymentIntent.destination_chain_type,
13075
13095
  destinationChainId: paymentIntent.destination_chain_id,
13076
13096
  destinationTokenAddress: paymentIntent.destination_token_address,
13097
+ defaultSourceChainType,
13098
+ defaultSourceChainId,
13099
+ defaultSourceTokenAddress,
13100
+ defaultSourceSymbol,
13077
13101
  depositConfirmationMode: "auto_ui",
13078
13102
  wallets,
13079
13103
  onSourceTokenChange: setSelectedSource,
@@ -14061,6 +14085,9 @@ function WithdrawForm({
14061
14085
  setIsSubmitting(true);
14062
14086
  setSubmitError(null);
14063
14087
  try {
14088
+ if (!onWithdraw) {
14089
+ throw new Error("No withdrawal method available. Please provide an onWithdraw handler.");
14090
+ }
14064
14091
  const depositWallet = await onDepositWalletCreation({
14065
14092
  destinationChainType: selectedChain.chain_type,
14066
14093
  destinationChainId: selectedChain.chain_id,
@@ -14118,63 +14145,16 @@ function WithdrawForm({
14118
14145
  withdrawIntentAddress: depositWallet.address,
14119
14146
  recipientAddress: trimmedAddress
14120
14147
  };
14121
- const wallet = await detectBrowserWallet(sourceChainType, senderAddress);
14122
- console.log("browser wallet", wallet);
14123
- if (wallet) {
14124
- try {
14125
- if (wallet.chainFamily === "evm" && isHypercoreChain(sourceChainId)) {
14126
- await sendHypercoreWithdraw({
14127
- provider: wallet.provider,
14128
- fromAddress: wallet.address,
14129
- depositWalletAddress: depositWallet.address,
14130
- sourceTokenAddress,
14131
- amount: humanAmount,
14132
- tokenSymbol,
14133
- publishableKey
14134
- });
14135
- } else if (wallet.chainFamily === "evm") {
14136
- await sendEvmWithdraw({
14137
- provider: wallet.provider,
14138
- fromAddress: wallet.address,
14139
- depositWalletAddress: depositWallet.address,
14140
- sourceTokenAddress,
14141
- sourceChainId,
14142
- amountBaseUnit
14143
- });
14144
- } else if (wallet.chainFamily === "solana") {
14145
- await sendSolanaWithdraw({
14146
- provider: wallet.provider,
14147
- fromAddress: wallet.address,
14148
- depositWalletAddress: depositWallet.address,
14149
- sourceTokenAddress,
14150
- amountBaseUnit,
14151
- publishableKey
14152
- });
14153
- }
14154
- } catch (walletErr) {
14155
- console.error("[Unifold] Browser wallet send failed:", walletErr, {
14156
- wallet: `${wallet.name} (${wallet.chainFamily})`,
14157
- sourceChainId,
14158
- amount: humanAmount,
14159
- amountBaseUnit,
14160
- depositWallet: depositWallet.address
14161
- });
14162
- throw walletErr;
14163
- }
14164
- } else if (onWithdraw) {
14165
- try {
14166
- await onWithdraw(txInfo);
14167
- } catch (callbackErr) {
14168
- console.error("[Unifold] onWithdraw callback failed:", callbackErr, {
14169
- sourceChainId,
14170
- amount: humanAmount,
14171
- amountBaseUnit,
14172
- depositWallet: depositWallet.address
14173
- });
14174
- throw callbackErr;
14175
- }
14176
- } else {
14177
- throw new Error("No withdrawal method available. Please connect a wallet.");
14148
+ try {
14149
+ await onWithdraw(txInfo);
14150
+ } catch (callbackErr) {
14151
+ console.error("[Unifold] onWithdraw callback failed:", callbackErr, {
14152
+ sourceChainId,
14153
+ amount: humanAmount,
14154
+ amountBaseUnit,
14155
+ depositWallet: depositWallet.address
14156
+ });
14157
+ throw callbackErr;
14178
14158
  }
14179
14159
  onWithdrawSubmitted?.(txInfo);
14180
14160
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-react",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
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",
@@ -43,7 +43,7 @@
43
43
  "lucide-react": "^0.454.0",
44
44
  "qr-code-styling": "^1.6.0-rc.1",
45
45
  "tailwind-merge": "^2.0.0",
46
- "@unifold/core": "0.1.45"
46
+ "@unifold/core": "0.1.47"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@solana/spl-token": "^0.3.8",