@unifold/connect-react 0.1.66 → 0.1.67

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,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { ChainType, DepositConfirmationMode, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
5
- export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
6
- import { EvmContractCall, DepositEvent } from '@unifold/core';
7
- export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
4
+ import { ChainType, DepositConfirmationMode, DepositMethod, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
5
+ export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, DepositMethod, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
6
+ import { EvmContractCall, DirectExecutionSucceededEvent, DepositEvent, WithdrawDirectExecutionSucceededEvent, WithdrawEvent } from '@unifold/core';
7
+ export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, DirectExecution, DirectExecutionResponse, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, WithdrawDirectExecutionSucceededEvent, WithdrawEvent, WithdrawEventType, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
8
8
 
9
9
  interface UnifoldConnectProviderConfig {
10
10
  publishableKey: string;
@@ -79,11 +79,14 @@ interface DepositResult {
79
79
  message: string;
80
80
  transaction?: unknown;
81
81
  executionId?: string;
82
+ execution?: DirectExecutionSucceededEvent;
83
+ method?: DepositMethod;
82
84
  }
83
85
  interface DepositError {
84
86
  message: string;
85
87
  error?: unknown;
86
88
  code?: string;
89
+ method?: DepositMethod;
87
90
  }
88
91
  interface DepositConfig {
89
92
  externalUserId: string;
@@ -144,6 +147,8 @@ interface CheckoutError {
144
147
  interface WithdrawResult {
145
148
  message: string;
146
149
  transaction?: unknown;
150
+ executionId?: string;
151
+ execution?: WithdrawDirectExecutionSucceededEvent;
147
152
  }
148
153
  interface WithdrawError {
149
154
  message: string;
@@ -210,6 +215,8 @@ interface WithdrawConfig {
210
215
  withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
211
216
  onSuccess?: (data: WithdrawResult) => void;
212
217
  onError?: (error: WithdrawError) => void;
218
+ /** Called when withdraw lifecycle events occur. */
219
+ onEvent?: (event: WithdrawEvent) => void;
213
220
  onClose?: () => void;
214
221
  }
215
222
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { ChainType, DepositConfirmationMode, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
5
- export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
6
- import { EvmContractCall, DepositEvent } from '@unifold/core';
7
- export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
4
+ import { ChainType, DepositConfirmationMode, DepositMethod, DepositModalInitialScreen, ThemeMode, ThemeConfig, FontConfig, ComponentConfig, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
5
+ export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, DepositMethod, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
6
+ import { EvmContractCall, DirectExecutionSucceededEvent, DepositEvent, WithdrawDirectExecutionSucceededEvent, WithdrawEvent } from '@unifold/core';
7
+ export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, DirectExecution, DirectExecutionResponse, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, WithdrawDirectExecutionSucceededEvent, WithdrawEvent, WithdrawEventType, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
8
8
 
9
9
  interface UnifoldConnectProviderConfig {
10
10
  publishableKey: string;
@@ -79,11 +79,14 @@ interface DepositResult {
79
79
  message: string;
80
80
  transaction?: unknown;
81
81
  executionId?: string;
82
+ execution?: DirectExecutionSucceededEvent;
83
+ method?: DepositMethod;
82
84
  }
83
85
  interface DepositError {
84
86
  message: string;
85
87
  error?: unknown;
86
88
  code?: string;
89
+ method?: DepositMethod;
87
90
  }
88
91
  interface DepositConfig {
89
92
  externalUserId: string;
@@ -144,6 +147,8 @@ interface CheckoutError {
144
147
  interface WithdrawResult {
145
148
  message: string;
146
149
  transaction?: unknown;
150
+ executionId?: string;
151
+ execution?: WithdrawDirectExecutionSucceededEvent;
147
152
  }
148
153
  interface WithdrawError {
149
154
  message: string;
@@ -210,6 +215,8 @@ interface WithdrawConfig {
210
215
  withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
211
216
  onSuccess?: (data: WithdrawResult) => void;
212
217
  onError?: (error: WithdrawError) => void;
218
+ /** Called when withdraw lifecycle events occur. */
219
+ onEvent?: (event: WithdrawEvent) => void;
213
220
  onClose?: () => void;
214
221
  }
215
222
 
package/dist/index.js CHANGED
@@ -1159,6 +1159,7 @@ __export(index_exports, {
1159
1159
  ExecutionStatus: () => ExecutionStatus,
1160
1160
  SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
1161
1161
  UnifoldProvider: () => UnifoldProvider2,
1162
+ WithdrawEventType: () => WithdrawEventType,
1162
1163
  createDepositAddress: () => createDepositAddress,
1163
1164
  createOnrampSession: () => createOnrampSession,
1164
1165
  generatePrefixedKSUID: () => generatePrefixedKSUID,
@@ -7155,8 +7156,13 @@ async function sendHypercoreTransaction(request, publishableKey) {
7155
7156
  }
7156
7157
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
7157
7158
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
7159
+ DepositEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
7158
7160
  return DepositEventType2;
7159
7161
  })(DepositEventType || {});
7162
+ var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
7163
+ WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
7164
+ return WithdrawEventType2;
7165
+ })(WithdrawEventType || {});
7160
7166
  function useUserIp() {
7161
7167
  const {
7162
7168
  data: userIpInfo,
@@ -15126,6 +15132,31 @@ function useDepositPolling({
15126
15132
  onDepositSuccess,
15127
15133
  onDepositError
15128
15134
  }) {
15135
+ const createExecutionSuccessEvent = (execution) => ({
15136
+ id: generatePrefixedKSUID("sevt"),
15137
+ type: DepositEventType.DIRECT_EXECUTION_SUCCEEDED,
15138
+ created: execution.updated_at ? Math.floor(new Date(execution.updated_at).getTime() / 1e3) : execution.created_at ? Math.floor(new Date(execution.created_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3),
15139
+ data: { object: mapToDirectExecution(execution) }
15140
+ });
15141
+ const mapToDirectExecution = (execution) => ({
15142
+ id: execution.id,
15143
+ transactionHash: execution.transaction_hash,
15144
+ recipientAddress: execution.recipient_address,
15145
+ depositAddress: execution.deposit_wallet?.address,
15146
+ sourceChainType: execution.source_chain_type,
15147
+ sourceChainId: execution.source_chain_id,
15148
+ sourceTokenAddress: execution.source_token_address,
15149
+ destinationChainType: execution.destination_chain_type,
15150
+ destinationChainId: execution.destination_chain_id,
15151
+ destinationTokenAddress: execution.destination_token_address,
15152
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
15153
+ sourceAmountUsd: execution.source_amount_usd,
15154
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
15155
+ destinationAmountUsd: execution.destination_amount_usd,
15156
+ destinationTransactionHashes: execution.destination_transaction_hashes,
15157
+ status: execution.status,
15158
+ failureReason: execution.failure_reason
15159
+ });
15129
15160
  const [executions, setExecutions] = (0, import_react12.useState)([]);
15130
15161
  const [isPolling, setIsPolling] = (0, import_react12.useState)(false);
15131
15162
  const [pollingEnabled, setPollingEnabled] = (0, import_react12.useState)(false);
@@ -15239,7 +15270,9 @@ function useDepositPolling({
15239
15270
  onDepositSuccessRef.current?.({
15240
15271
  message: "Deposit completed successfully",
15241
15272
  executionId: execution.id,
15242
- transaction: execution
15273
+ // Backward compatibility: keep transaction in API response shape.
15274
+ transaction: execution,
15275
+ execution: createExecutionSuccessEvent(execution)
15243
15276
  });
15244
15277
  } else if (execution.status === ExecutionStatus.FAILED && previousStatus !== ExecutionStatus.FAILED) {
15245
15278
  onDepositErrorRef.current?.({
@@ -21420,6 +21453,8 @@ function CoinbaseConnect({
21420
21453
  destinationChainId,
21421
21454
  destinationChainType,
21422
21455
  onTransferSuccess,
21456
+ onDepositSuccess,
21457
+ onDepositError,
21423
21458
  onTransferError,
21424
21459
  onClose,
21425
21460
  onBack: parentOnBack,
@@ -21567,10 +21602,14 @@ function CoinbaseConnect({
21567
21602
  depositWalletId: transferDepositWalletId,
21568
21603
  enabled: view === "success" && !!transferDepositWalletId,
21569
21604
  immediateDirectPolling: true,
21570
- onDepositSuccess: onTransferSuccess ? () => {
21571
- if (confirmResult) onTransferSuccess(confirmResult);
21605
+ onDepositSuccess: onDepositSuccess || onTransferSuccess ? (data) => {
21606
+ onDepositSuccess?.(data);
21607
+ if (onTransferSuccess && confirmResult) onTransferSuccess(confirmResult);
21572
21608
  } : void 0,
21573
- onDepositError: onTransferError
21609
+ onDepositError: onDepositError || onTransferError ? (error) => {
21610
+ onDepositError?.(error);
21611
+ onTransferError?.({ message: error.message });
21612
+ } : void 0
21574
21613
  });
21575
21614
  (0, import_react20.useEffect)(() => {
21576
21615
  onExecutionsChange?.(depositExecutions);
@@ -28021,6 +28060,23 @@ function DepositModal({
28021
28060
  depositTrackerSubTitle = t7.depositTracker.subtitle
28022
28061
  }) {
28023
28062
  const { colors: colors2, fonts, components } = useTheme();
28063
+ const onDepositSuccessFor = (0, import_react8.useCallback)(
28064
+ (method) => onDepositSuccess || onEvent ? (data) => {
28065
+ const payload = { ...data, method };
28066
+ onDepositSuccess?.(payload);
28067
+ if (payload.execution) {
28068
+ onEvent?.({
28069
+ ...payload.execution,
28070
+ method
28071
+ });
28072
+ }
28073
+ } : void 0,
28074
+ [onDepositSuccess, onEvent]
28075
+ );
28076
+ const onDepositErrorFor = (0, import_react8.useCallback)(
28077
+ (method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
28078
+ [onDepositError]
28079
+ );
28024
28080
  const effectiveInitialScreen = (0, import_react8.useMemo)(() => {
28025
28081
  const s = initialScreen ?? "main";
28026
28082
  if (s === "tracker" && hideDepositTracker === true) return "main";
@@ -28705,8 +28761,8 @@ function DepositModal({
28705
28761
  defaultSourceSymbol,
28706
28762
  depositConfirmationMode,
28707
28763
  onExecutionsChange: setDepositExecutions,
28708
- onDepositSuccess,
28709
- onDepositError,
28764
+ onDepositSuccess: onDepositSuccessFor("transfer"),
28765
+ onDepositError: onDepositErrorFor("transfer"),
28710
28766
  wallets
28711
28767
  }
28712
28768
  ) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
@@ -28724,8 +28780,8 @@ function DepositModal({
28724
28780
  defaultSourceSymbol,
28725
28781
  depositConfirmationMode,
28726
28782
  onExecutionsChange: setDepositExecutions,
28727
- onDepositSuccess,
28728
- onDepositError,
28783
+ onDepositSuccess: onDepositSuccessFor("transfer"),
28784
+ onDepositError: onDepositErrorFor("transfer"),
28729
28785
  wallets
28730
28786
  }
28731
28787
  ),
@@ -28790,8 +28846,8 @@ function DepositModal({
28790
28846
  destinationChainType,
28791
28847
  destinationChainId,
28792
28848
  destinationTokenAddress,
28793
- onDepositSuccess,
28794
- onDepositError,
28849
+ onDepositSuccess: onDepositSuccessFor("card"),
28850
+ onDepositError: onDepositErrorFor("card"),
28795
28851
  onEvent,
28796
28852
  themeClass,
28797
28853
  wallets,
@@ -28826,8 +28882,8 @@ function DepositModal({
28826
28882
  destinationChainType,
28827
28883
  destinationChainId,
28828
28884
  destinationTokenAddress,
28829
- onDepositSuccess,
28830
- onDepositError,
28885
+ onDepositSuccess: onDepositSuccessFor("pay_with_exchange"),
28886
+ onDepositError: onDepositErrorFor("pay_with_exchange"),
28831
28887
  wallets,
28832
28888
  defaultToken: defaultToken ?? null
28833
28889
  }
@@ -28845,14 +28901,10 @@ function DepositModal({
28845
28901
  destinationTokenAddress: destinationTokenAddress ?? "",
28846
28902
  destinationChainId: destinationChainId ?? "",
28847
28903
  destinationChainType: destinationChainType ?? "",
28848
- onTransferSuccess: (result) => {
28849
- onDepositSuccess?.({
28850
- message: "Transfer completed via Coinbase Connect",
28851
- transaction: result
28852
- });
28853
- },
28904
+ onDepositSuccess: onDepositSuccessFor("exchange_connect"),
28905
+ onDepositError: onDepositErrorFor("exchange_connect"),
28854
28906
  onTransferError: (error) => {
28855
- onDepositError?.({
28907
+ onDepositErrorFor("exchange_connect")?.({
28856
28908
  message: error.message,
28857
28909
  error
28858
28910
  });
@@ -28881,20 +28933,14 @@ function DepositModal({
28881
28933
  publishableKey,
28882
28934
  assetCdnUrl: projectConfig?.asset_cdn_url,
28883
28935
  projectName: projectConfig?.project_name,
28884
- onSuccess: (txHash) => {
28885
- onDepositSuccess?.({
28886
- message: "Transaction sent successfully",
28887
- transaction: { txHash }
28888
- });
28889
- },
28890
28936
  onError: (error) => {
28891
- onDepositError?.({
28937
+ onDepositErrorFor("wallet_connect")?.({
28892
28938
  message: error.message,
28893
28939
  error
28894
28940
  });
28895
28941
  },
28896
- onDepositSuccess,
28897
- onDepositError,
28942
+ onDepositSuccess: onDepositSuccessFor("wallet_connect"),
28943
+ onDepositError: onDepositErrorFor("wallet_connect"),
28898
28944
  amountQuickSelect: browserWalletAmountQuickSelect,
28899
28945
  onWalletDisconnect: handleWalletDisconnect,
28900
28946
  onWalletConnected: (info, dw) => {
@@ -28938,8 +28984,8 @@ function DepositModal({
28938
28984
  onViewChange: setCashAppView,
28939
28985
  onAmountChange: setCashAppAmount,
28940
28986
  onEvent,
28941
- onDepositSuccess,
28942
- onDepositError
28987
+ onDepositSuccess: onDepositSuccessFor("cashapp"),
28988
+ onDepositError: onDepositErrorFor("cashapp")
28943
28989
  }
28944
28990
  ),
28945
28991
  depositPoweredByFooter
@@ -29777,6 +29823,31 @@ function useWithdrawPolling({
29777
29823
  onWithdrawSuccess,
29778
29824
  onWithdrawError
29779
29825
  }) {
29826
+ const createExecutionSuccessEvent = (execution) => ({
29827
+ id: generatePrefixedKSUID("sevt"),
29828
+ type: WithdrawEventType.DIRECT_EXECUTION_SUCCEEDED,
29829
+ created: execution.updated_at ? Math.floor(new Date(execution.updated_at).getTime() / 1e3) : execution.created_at ? Math.floor(new Date(execution.created_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3),
29830
+ data: { object: mapToDirectExecution(execution) }
29831
+ });
29832
+ const mapToDirectExecution = (execution) => ({
29833
+ id: execution.id,
29834
+ transactionHash: execution.transaction_hash,
29835
+ recipientAddress: execution.recipient_address,
29836
+ depositAddress: execution.deposit_wallet?.address,
29837
+ sourceChainType: execution.source_chain_type,
29838
+ sourceChainId: execution.source_chain_id,
29839
+ sourceTokenAddress: execution.source_token_address,
29840
+ destinationChainType: execution.destination_chain_type,
29841
+ destinationChainId: execution.destination_chain_id,
29842
+ destinationTokenAddress: execution.destination_token_address,
29843
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
29844
+ sourceAmountUsd: execution.source_amount_usd,
29845
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
29846
+ destinationAmountUsd: execution.destination_amount_usd,
29847
+ destinationTransactionHashes: execution.destination_transaction_hashes,
29848
+ status: execution.status,
29849
+ failureReason: execution.failure_reason
29850
+ });
29780
29851
  const [executions, setExecutions] = (0, import_react30.useState)([]);
29781
29852
  const [isPolling, setIsPolling] = (0, import_react30.useState)(false);
29782
29853
  const enabledAtRef = (0, import_react30.useRef)(/* @__PURE__ */ new Date());
@@ -29844,7 +29915,13 @@ function useWithdrawPolling({
29844
29915
  return [...list, ex];
29845
29916
  });
29846
29917
  if (ex.status === ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
29847
- onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
29918
+ onSuccessRef.current?.({
29919
+ message: "Withdrawal completed successfully",
29920
+ executionId: ex.id,
29921
+ // Backward compatibility: keep transaction in API response shape.
29922
+ transaction: ex,
29923
+ execution: createExecutionSuccessEvent(ex)
29924
+ });
29848
29925
  } else if (ex.status === ExecutionStatus.FAILED && prev !== ExecutionStatus.FAILED) {
29849
29926
  onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
29850
29927
  }
@@ -31046,9 +31123,19 @@ function WithdrawModal({
31046
31123
  onWithdraw,
31047
31124
  onWithdrawSuccess,
31048
31125
  onWithdrawError,
31126
+ onEvent,
31049
31127
  theme = "dark",
31050
31128
  hideOverlay = false
31051
31129
  }) {
31130
+ const onWithdrawSuccessFor = (0, import_react29.useCallback)(
31131
+ (data) => {
31132
+ onWithdrawSuccess?.(data);
31133
+ if (data.execution) {
31134
+ onEvent?.(data.execution);
31135
+ }
31136
+ },
31137
+ [onWithdrawSuccess, onEvent]
31138
+ );
31052
31139
  const { colors: colors2, fonts, components } = useTheme();
31053
31140
  const [containerEl, setContainerEl] = (0, import_react29.useState)(null);
31054
31141
  const containerCallbackRef = (0, import_react29.useCallback)((el) => {
@@ -31110,7 +31197,7 @@ function WithdrawModal({
31110
31197
  publishableKey,
31111
31198
  depositWalletId: withdrawDepositWalletId,
31112
31199
  enabled: !!withdrawDepositWalletId && open,
31113
- onWithdrawSuccess: onWithdrawSuccess ? (d) => onWithdrawSuccess({ message: d.message, transaction: d.transaction }) : void 0,
31200
+ onWithdrawSuccess: onWithdrawSuccess || onEvent ? onWithdrawSuccessFor : void 0,
31114
31201
  onWithdrawError
31115
31202
  });
31116
31203
  const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
@@ -31610,6 +31697,7 @@ function UnifoldProvider2({
31610
31697
  onWithdraw: withdrawConfig.withdraw,
31611
31698
  onWithdrawSuccess: handleWithdrawSuccess,
31612
31699
  onWithdrawError: handleWithdrawError,
31700
+ onEvent: withdrawConfig.onEvent,
31613
31701
  theme: resolvedTheme
31614
31702
  }
31615
31703
  ),
@@ -31705,6 +31793,7 @@ function useAllowedCountry2() {
31705
31793
  ExecutionStatus,
31706
31794
  SOLANA_USDC_ADDRESS,
31707
31795
  UnifoldProvider,
31796
+ WithdrawEventType,
31708
31797
  createDepositAddress,
31709
31798
  createOnrampSession,
31710
31799
  generatePrefixedKSUID,
package/dist/index.mjs CHANGED
@@ -7128,8 +7128,13 @@ async function sendHypercoreTransaction(request, publishableKey) {
7128
7128
  }
7129
7129
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
7130
7130
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
7131
+ DepositEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
7131
7132
  return DepositEventType2;
7132
7133
  })(DepositEventType || {});
7134
+ var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
7135
+ WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
7136
+ return WithdrawEventType2;
7137
+ })(WithdrawEventType || {});
7133
7138
  function useUserIp() {
7134
7139
  const {
7135
7140
  data: userIpInfo,
@@ -15112,6 +15117,31 @@ function useDepositPolling({
15112
15117
  onDepositSuccess,
15113
15118
  onDepositError
15114
15119
  }) {
15120
+ const createExecutionSuccessEvent = (execution) => ({
15121
+ id: generatePrefixedKSUID("sevt"),
15122
+ type: DepositEventType.DIRECT_EXECUTION_SUCCEEDED,
15123
+ created: execution.updated_at ? Math.floor(new Date(execution.updated_at).getTime() / 1e3) : execution.created_at ? Math.floor(new Date(execution.created_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3),
15124
+ data: { object: mapToDirectExecution(execution) }
15125
+ });
15126
+ const mapToDirectExecution = (execution) => ({
15127
+ id: execution.id,
15128
+ transactionHash: execution.transaction_hash,
15129
+ recipientAddress: execution.recipient_address,
15130
+ depositAddress: execution.deposit_wallet?.address,
15131
+ sourceChainType: execution.source_chain_type,
15132
+ sourceChainId: execution.source_chain_id,
15133
+ sourceTokenAddress: execution.source_token_address,
15134
+ destinationChainType: execution.destination_chain_type,
15135
+ destinationChainId: execution.destination_chain_id,
15136
+ destinationTokenAddress: execution.destination_token_address,
15137
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
15138
+ sourceAmountUsd: execution.source_amount_usd,
15139
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
15140
+ destinationAmountUsd: execution.destination_amount_usd,
15141
+ destinationTransactionHashes: execution.destination_transaction_hashes,
15142
+ status: execution.status,
15143
+ failureReason: execution.failure_reason
15144
+ });
15115
15145
  const [executions, setExecutions] = useState52([]);
15116
15146
  const [isPolling, setIsPolling] = useState52(false);
15117
15147
  const [pollingEnabled, setPollingEnabled] = useState52(false);
@@ -15225,7 +15255,9 @@ function useDepositPolling({
15225
15255
  onDepositSuccessRef.current?.({
15226
15256
  message: "Deposit completed successfully",
15227
15257
  executionId: execution.id,
15228
- transaction: execution
15258
+ // Backward compatibility: keep transaction in API response shape.
15259
+ transaction: execution,
15260
+ execution: createExecutionSuccessEvent(execution)
15229
15261
  });
15230
15262
  } else if (execution.status === ExecutionStatus.FAILED && previousStatus !== ExecutionStatus.FAILED) {
15231
15263
  onDepositErrorRef.current?.({
@@ -21406,6 +21438,8 @@ function CoinbaseConnect({
21406
21438
  destinationChainId,
21407
21439
  destinationChainType,
21408
21440
  onTransferSuccess,
21441
+ onDepositSuccess,
21442
+ onDepositError,
21409
21443
  onTransferError,
21410
21444
  onClose,
21411
21445
  onBack: parentOnBack,
@@ -21553,10 +21587,14 @@ function CoinbaseConnect({
21553
21587
  depositWalletId: transferDepositWalletId,
21554
21588
  enabled: view === "success" && !!transferDepositWalletId,
21555
21589
  immediateDirectPolling: true,
21556
- onDepositSuccess: onTransferSuccess ? () => {
21557
- if (confirmResult) onTransferSuccess(confirmResult);
21590
+ onDepositSuccess: onDepositSuccess || onTransferSuccess ? (data) => {
21591
+ onDepositSuccess?.(data);
21592
+ if (onTransferSuccess && confirmResult) onTransferSuccess(confirmResult);
21558
21593
  } : void 0,
21559
- onDepositError: onTransferError
21594
+ onDepositError: onDepositError || onTransferError ? (error) => {
21595
+ onDepositError?.(error);
21596
+ onTransferError?.({ message: error.message });
21597
+ } : void 0
21560
21598
  });
21561
21599
  useEffect172(() => {
21562
21600
  onExecutionsChange?.(depositExecutions);
@@ -28007,6 +28045,23 @@ function DepositModal({
28007
28045
  depositTrackerSubTitle = t7.depositTracker.subtitle
28008
28046
  }) {
28009
28047
  const { colors: colors2, fonts, components } = useTheme();
28048
+ const onDepositSuccessFor = useCallback52(
28049
+ (method) => onDepositSuccess || onEvent ? (data) => {
28050
+ const payload = { ...data, method };
28051
+ onDepositSuccess?.(payload);
28052
+ if (payload.execution) {
28053
+ onEvent?.({
28054
+ ...payload.execution,
28055
+ method
28056
+ });
28057
+ }
28058
+ } : void 0,
28059
+ [onDepositSuccess, onEvent]
28060
+ );
28061
+ const onDepositErrorFor = useCallback52(
28062
+ (method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
28063
+ [onDepositError]
28064
+ );
28010
28065
  const effectiveInitialScreen = useMemo10(() => {
28011
28066
  const s = initialScreen ?? "main";
28012
28067
  if (s === "tracker" && hideDepositTracker === true) return "main";
@@ -28691,8 +28746,8 @@ function DepositModal({
28691
28746
  defaultSourceSymbol,
28692
28747
  depositConfirmationMode,
28693
28748
  onExecutionsChange: setDepositExecutions,
28694
- onDepositSuccess,
28695
- onDepositError,
28749
+ onDepositSuccess: onDepositSuccessFor("transfer"),
28750
+ onDepositError: onDepositErrorFor("transfer"),
28696
28751
  wallets
28697
28752
  }
28698
28753
  ) : /* @__PURE__ */ jsx55(
@@ -28710,8 +28765,8 @@ function DepositModal({
28710
28765
  defaultSourceSymbol,
28711
28766
  depositConfirmationMode,
28712
28767
  onExecutionsChange: setDepositExecutions,
28713
- onDepositSuccess,
28714
- onDepositError,
28768
+ onDepositSuccess: onDepositSuccessFor("transfer"),
28769
+ onDepositError: onDepositErrorFor("transfer"),
28715
28770
  wallets
28716
28771
  }
28717
28772
  ),
@@ -28776,8 +28831,8 @@ function DepositModal({
28776
28831
  destinationChainType,
28777
28832
  destinationChainId,
28778
28833
  destinationTokenAddress,
28779
- onDepositSuccess,
28780
- onDepositError,
28834
+ onDepositSuccess: onDepositSuccessFor("card"),
28835
+ onDepositError: onDepositErrorFor("card"),
28781
28836
  onEvent,
28782
28837
  themeClass,
28783
28838
  wallets,
@@ -28812,8 +28867,8 @@ function DepositModal({
28812
28867
  destinationChainType,
28813
28868
  destinationChainId,
28814
28869
  destinationTokenAddress,
28815
- onDepositSuccess,
28816
- onDepositError,
28870
+ onDepositSuccess: onDepositSuccessFor("pay_with_exchange"),
28871
+ onDepositError: onDepositErrorFor("pay_with_exchange"),
28817
28872
  wallets,
28818
28873
  defaultToken: defaultToken ?? null
28819
28874
  }
@@ -28831,14 +28886,10 @@ function DepositModal({
28831
28886
  destinationTokenAddress: destinationTokenAddress ?? "",
28832
28887
  destinationChainId: destinationChainId ?? "",
28833
28888
  destinationChainType: destinationChainType ?? "",
28834
- onTransferSuccess: (result) => {
28835
- onDepositSuccess?.({
28836
- message: "Transfer completed via Coinbase Connect",
28837
- transaction: result
28838
- });
28839
- },
28889
+ onDepositSuccess: onDepositSuccessFor("exchange_connect"),
28890
+ onDepositError: onDepositErrorFor("exchange_connect"),
28840
28891
  onTransferError: (error) => {
28841
- onDepositError?.({
28892
+ onDepositErrorFor("exchange_connect")?.({
28842
28893
  message: error.message,
28843
28894
  error
28844
28895
  });
@@ -28867,20 +28918,14 @@ function DepositModal({
28867
28918
  publishableKey,
28868
28919
  assetCdnUrl: projectConfig?.asset_cdn_url,
28869
28920
  projectName: projectConfig?.project_name,
28870
- onSuccess: (txHash) => {
28871
- onDepositSuccess?.({
28872
- message: "Transaction sent successfully",
28873
- transaction: { txHash }
28874
- });
28875
- },
28876
28921
  onError: (error) => {
28877
- onDepositError?.({
28922
+ onDepositErrorFor("wallet_connect")?.({
28878
28923
  message: error.message,
28879
28924
  error
28880
28925
  });
28881
28926
  },
28882
- onDepositSuccess,
28883
- onDepositError,
28927
+ onDepositSuccess: onDepositSuccessFor("wallet_connect"),
28928
+ onDepositError: onDepositErrorFor("wallet_connect"),
28884
28929
  amountQuickSelect: browserWalletAmountQuickSelect,
28885
28930
  onWalletDisconnect: handleWalletDisconnect,
28886
28931
  onWalletConnected: (info, dw) => {
@@ -28924,8 +28969,8 @@ function DepositModal({
28924
28969
  onViewChange: setCashAppView,
28925
28970
  onAmountChange: setCashAppAmount,
28926
28971
  onEvent,
28927
- onDepositSuccess,
28928
- onDepositError
28972
+ onDepositSuccess: onDepositSuccessFor("cashapp"),
28973
+ onDepositError: onDepositErrorFor("cashapp")
28929
28974
  }
28930
28975
  ),
28931
28976
  depositPoweredByFooter
@@ -29763,6 +29808,31 @@ function useWithdrawPolling({
29763
29808
  onWithdrawSuccess,
29764
29809
  onWithdrawError
29765
29810
  }) {
29811
+ const createExecutionSuccessEvent = (execution) => ({
29812
+ id: generatePrefixedKSUID("sevt"),
29813
+ type: WithdrawEventType.DIRECT_EXECUTION_SUCCEEDED,
29814
+ created: execution.updated_at ? Math.floor(new Date(execution.updated_at).getTime() / 1e3) : execution.created_at ? Math.floor(new Date(execution.created_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3),
29815
+ data: { object: mapToDirectExecution(execution) }
29816
+ });
29817
+ const mapToDirectExecution = (execution) => ({
29818
+ id: execution.id,
29819
+ transactionHash: execution.transaction_hash,
29820
+ recipientAddress: execution.recipient_address,
29821
+ depositAddress: execution.deposit_wallet?.address,
29822
+ sourceChainType: execution.source_chain_type,
29823
+ sourceChainId: execution.source_chain_id,
29824
+ sourceTokenAddress: execution.source_token_address,
29825
+ destinationChainType: execution.destination_chain_type,
29826
+ destinationChainId: execution.destination_chain_id,
29827
+ destinationTokenAddress: execution.destination_token_address,
29828
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
29829
+ sourceAmountUsd: execution.source_amount_usd,
29830
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
29831
+ destinationAmountUsd: execution.destination_amount_usd,
29832
+ destinationTransactionHashes: execution.destination_transaction_hashes,
29833
+ status: execution.status,
29834
+ failureReason: execution.failure_reason
29835
+ });
29766
29836
  const [executions, setExecutions] = useState34([]);
29767
29837
  const [isPolling, setIsPolling] = useState34(false);
29768
29838
  const enabledAtRef = useRef112(/* @__PURE__ */ new Date());
@@ -29830,7 +29900,13 @@ function useWithdrawPolling({
29830
29900
  return [...list, ex];
29831
29901
  });
29832
29902
  if (ex.status === ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
29833
- onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
29903
+ onSuccessRef.current?.({
29904
+ message: "Withdrawal completed successfully",
29905
+ executionId: ex.id,
29906
+ // Backward compatibility: keep transaction in API response shape.
29907
+ transaction: ex,
29908
+ execution: createExecutionSuccessEvent(ex)
29909
+ });
29834
29910
  } else if (ex.status === ExecutionStatus.FAILED && prev !== ExecutionStatus.FAILED) {
29835
29911
  onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
29836
29912
  }
@@ -31032,9 +31108,19 @@ function WithdrawModal({
31032
31108
  onWithdraw,
31033
31109
  onWithdrawSuccess,
31034
31110
  onWithdrawError,
31111
+ onEvent,
31035
31112
  theme = "dark",
31036
31113
  hideOverlay = false
31037
31114
  }) {
31115
+ const onWithdrawSuccessFor = useCallback82(
31116
+ (data) => {
31117
+ onWithdrawSuccess?.(data);
31118
+ if (data.execution) {
31119
+ onEvent?.(data.execution);
31120
+ }
31121
+ },
31122
+ [onWithdrawSuccess, onEvent]
31123
+ );
31038
31124
  const { colors: colors2, fonts, components } = useTheme();
31039
31125
  const [containerEl, setContainerEl] = useState37(null);
31040
31126
  const containerCallbackRef = useCallback82((el) => {
@@ -31096,7 +31182,7 @@ function WithdrawModal({
31096
31182
  publishableKey,
31097
31183
  depositWalletId: withdrawDepositWalletId,
31098
31184
  enabled: !!withdrawDepositWalletId && open,
31099
- onWithdrawSuccess: onWithdrawSuccess ? (d) => onWithdrawSuccess({ message: d.message, transaction: d.transaction }) : void 0,
31185
+ onWithdrawSuccess: onWithdrawSuccess || onEvent ? onWithdrawSuccessFor : void 0,
31100
31186
  onWithdrawError
31101
31187
  });
31102
31188
  const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
@@ -31596,6 +31682,7 @@ function UnifoldProvider2({
31596
31682
  onWithdraw: withdrawConfig.withdraw,
31597
31683
  onWithdrawSuccess: handleWithdrawSuccess,
31598
31684
  onWithdrawError: handleWithdrawError,
31685
+ onEvent: withdrawConfig.onEvent,
31599
31686
  theme: resolvedTheme
31600
31687
  }
31601
31688
  ),
@@ -31690,6 +31777,7 @@ export {
31690
31777
  ExecutionStatus,
31691
31778
  SOLANA_USDC_ADDRESS,
31692
31779
  UnifoldProvider2 as UnifoldProvider,
31780
+ WithdrawEventType,
31693
31781
  createDepositAddress,
31694
31782
  createOnrampSession,
31695
31783
  generatePrefixedKSUID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/connect-react",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "description": "Unifold Connect React - Complete React SDK with UI components for crypto deposits",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -26,9 +26,9 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@tanstack/react-query": "^5.90.11",
29
- "@unifold/core": "0.1.66",
30
- "@unifold/ui-react": "0.1.66",
31
- "@unifold/react-provider": "0.1.66"
29
+ "@unifold/core": "0.1.67",
30
+ "@unifold/react-provider": "0.1.67",
31
+ "@unifold/ui-react": "0.1.67"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/react": "^19.0.0",