@unifold/ui-web 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,5 +1,5 @@
1
1
  import { UnifoldConnectProviderConfig, DepositConfig, DepositResult, WithdrawConfig, WithdrawResult } from '@unifold/connect-react';
2
- export { DepositConfig, DepositError, DepositInitialScreen, DepositResult, UnifoldConnectProviderConfig, WithdrawConfig, WithdrawError, WithdrawResult, WithdrawTransactionInfo } from '@unifold/connect-react';
2
+ export { DepositConfig, DepositError, DepositInitialScreen, DepositMethod, DepositResult, UnifoldConnectProviderConfig, WithdrawConfig, WithdrawError, WithdrawResult, WithdrawTransactionInfo } from '@unifold/connect-react';
3
3
 
4
4
  type UnifoldConfig = UnifoldConnectProviderConfig["config"];
5
5
  interface UnifoldHandle {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { UnifoldConnectProviderConfig, DepositConfig, DepositResult, WithdrawConfig, WithdrawResult } from '@unifold/connect-react';
2
- export { DepositConfig, DepositError, DepositInitialScreen, DepositResult, UnifoldConnectProviderConfig, WithdrawConfig, WithdrawError, WithdrawResult, WithdrawTransactionInfo } from '@unifold/connect-react';
2
+ export { DepositConfig, DepositError, DepositInitialScreen, DepositMethod, DepositResult, UnifoldConnectProviderConfig, WithdrawConfig, WithdrawError, WithdrawResult, WithdrawTransactionInfo } from '@unifold/connect-react';
3
3
 
4
4
  type UnifoldConfig = UnifoldConnectProviderConfig["config"];
5
5
  interface UnifoldHandle {
package/dist/index.js CHANGED
@@ -44108,8 +44108,13 @@ async function sendHypercoreTransaction(request, publishableKey) {
44108
44108
  }
44109
44109
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
44110
44110
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
44111
+ DepositEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
44111
44112
  return DepositEventType2;
44112
44113
  })(DepositEventType || {});
44114
+ var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
44115
+ WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
44116
+ return WithdrawEventType2;
44117
+ })(WithdrawEventType || {});
44113
44118
  var import_qr_code_styling = __toESM2(require_qr_code_styling(), 1);
44114
44119
  var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
44115
44120
  var use = React25[" use ".trim().toString()];
@@ -51741,6 +51746,31 @@ function useDepositPolling({
51741
51746
  onDepositSuccess,
51742
51747
  onDepositError
51743
51748
  }) {
51749
+ const createExecutionSuccessEvent = (execution) => ({
51750
+ id: generatePrefixedKSUID("sevt"),
51751
+ type: DepositEventType.DIRECT_EXECUTION_SUCCEEDED,
51752
+ 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),
51753
+ data: { object: mapToDirectExecution(execution) }
51754
+ });
51755
+ const mapToDirectExecution = (execution) => ({
51756
+ id: execution.id,
51757
+ transactionHash: execution.transaction_hash,
51758
+ recipientAddress: execution.recipient_address,
51759
+ depositAddress: execution.deposit_wallet?.address,
51760
+ sourceChainType: execution.source_chain_type,
51761
+ sourceChainId: execution.source_chain_id,
51762
+ sourceTokenAddress: execution.source_token_address,
51763
+ destinationChainType: execution.destination_chain_type,
51764
+ destinationChainId: execution.destination_chain_id,
51765
+ destinationTokenAddress: execution.destination_token_address,
51766
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
51767
+ sourceAmountUsd: execution.source_amount_usd,
51768
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
51769
+ destinationAmountUsd: execution.destination_amount_usd,
51770
+ destinationTransactionHashes: execution.destination_transaction_hashes,
51771
+ status: execution.status,
51772
+ failureReason: execution.failure_reason
51773
+ });
51744
51774
  const [executions, setExecutions] = (0, import_react10.useState)([]);
51745
51775
  const [isPolling, setIsPolling] = (0, import_react10.useState)(false);
51746
51776
  const [pollingEnabled, setPollingEnabled] = (0, import_react10.useState)(false);
@@ -51854,7 +51884,9 @@ function useDepositPolling({
51854
51884
  onDepositSuccessRef.current?.({
51855
51885
  message: "Deposit completed successfully",
51856
51886
  executionId: execution.id,
51857
- transaction: execution
51887
+ // Backward compatibility: keep transaction in API response shape.
51888
+ transaction: execution,
51889
+ execution: createExecutionSuccessEvent(execution)
51858
51890
  });
51859
51891
  } else if (execution.status === ExecutionStatus.FAILED && previousStatus !== ExecutionStatus.FAILED) {
51860
51892
  onDepositErrorRef.current?.({
@@ -58035,6 +58067,8 @@ function CoinbaseConnect({
58035
58067
  destinationChainId,
58036
58068
  destinationChainType,
58037
58069
  onTransferSuccess,
58070
+ onDepositSuccess,
58071
+ onDepositError,
58038
58072
  onTransferError,
58039
58073
  onClose,
58040
58074
  onBack: parentOnBack,
@@ -58182,10 +58216,14 @@ function CoinbaseConnect({
58182
58216
  depositWalletId: transferDepositWalletId,
58183
58217
  enabled: view === "success" && !!transferDepositWalletId,
58184
58218
  immediateDirectPolling: true,
58185
- onDepositSuccess: onTransferSuccess ? () => {
58186
- if (confirmResult) onTransferSuccess(confirmResult);
58219
+ onDepositSuccess: onDepositSuccess || onTransferSuccess ? (data) => {
58220
+ onDepositSuccess?.(data);
58221
+ if (onTransferSuccess && confirmResult) onTransferSuccess(confirmResult);
58187
58222
  } : void 0,
58188
- onDepositError: onTransferError
58223
+ onDepositError: onDepositError || onTransferError ? (error) => {
58224
+ onDepositError?.(error);
58225
+ onTransferError?.({ message: error.message });
58226
+ } : void 0
58189
58227
  });
58190
58228
  (0, import_react18.useEffect)(() => {
58191
58229
  onExecutionsChange?.(depositExecutions);
@@ -64636,6 +64674,23 @@ function DepositModal({
64636
64674
  depositTrackerSubTitle = t7.depositTracker.subtitle
64637
64675
  }) {
64638
64676
  const { colors: colors2, fonts, components } = useTheme();
64677
+ const onDepositSuccessFor = (0, import_react3.useCallback)(
64678
+ (method) => onDepositSuccess || onEvent ? (data) => {
64679
+ const payload = { ...data, method };
64680
+ onDepositSuccess?.(payload);
64681
+ if (payload.execution) {
64682
+ onEvent?.({
64683
+ ...payload.execution,
64684
+ method
64685
+ });
64686
+ }
64687
+ } : void 0,
64688
+ [onDepositSuccess, onEvent]
64689
+ );
64690
+ const onDepositErrorFor = (0, import_react3.useCallback)(
64691
+ (method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
64692
+ [onDepositError]
64693
+ );
64639
64694
  const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
64640
64695
  const s = initialScreen ?? "main";
64641
64696
  if (s === "tracker" && hideDepositTracker === true) return "main";
@@ -65320,8 +65375,8 @@ function DepositModal({
65320
65375
  defaultSourceSymbol,
65321
65376
  depositConfirmationMode,
65322
65377
  onExecutionsChange: setDepositExecutions,
65323
- onDepositSuccess,
65324
- onDepositError,
65378
+ onDepositSuccess: onDepositSuccessFor("transfer"),
65379
+ onDepositError: onDepositErrorFor("transfer"),
65325
65380
  wallets
65326
65381
  }
65327
65382
  ) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
@@ -65339,8 +65394,8 @@ function DepositModal({
65339
65394
  defaultSourceSymbol,
65340
65395
  depositConfirmationMode,
65341
65396
  onExecutionsChange: setDepositExecutions,
65342
- onDepositSuccess,
65343
- onDepositError,
65397
+ onDepositSuccess: onDepositSuccessFor("transfer"),
65398
+ onDepositError: onDepositErrorFor("transfer"),
65344
65399
  wallets
65345
65400
  }
65346
65401
  ),
@@ -65405,8 +65460,8 @@ function DepositModal({
65405
65460
  destinationChainType,
65406
65461
  destinationChainId,
65407
65462
  destinationTokenAddress,
65408
- onDepositSuccess,
65409
- onDepositError,
65463
+ onDepositSuccess: onDepositSuccessFor("card"),
65464
+ onDepositError: onDepositErrorFor("card"),
65410
65465
  onEvent,
65411
65466
  themeClass,
65412
65467
  wallets,
@@ -65441,8 +65496,8 @@ function DepositModal({
65441
65496
  destinationChainType,
65442
65497
  destinationChainId,
65443
65498
  destinationTokenAddress,
65444
- onDepositSuccess,
65445
- onDepositError,
65499
+ onDepositSuccess: onDepositSuccessFor("pay_with_exchange"),
65500
+ onDepositError: onDepositErrorFor("pay_with_exchange"),
65446
65501
  wallets,
65447
65502
  defaultToken: defaultToken ?? null
65448
65503
  }
@@ -65460,14 +65515,10 @@ function DepositModal({
65460
65515
  destinationTokenAddress: destinationTokenAddress ?? "",
65461
65516
  destinationChainId: destinationChainId ?? "",
65462
65517
  destinationChainType: destinationChainType ?? "",
65463
- onTransferSuccess: (result) => {
65464
- onDepositSuccess?.({
65465
- message: "Transfer completed via Coinbase Connect",
65466
- transaction: result
65467
- });
65468
- },
65518
+ onDepositSuccess: onDepositSuccessFor("exchange_connect"),
65519
+ onDepositError: onDepositErrorFor("exchange_connect"),
65469
65520
  onTransferError: (error) => {
65470
- onDepositError?.({
65521
+ onDepositErrorFor("exchange_connect")?.({
65471
65522
  message: error.message,
65472
65523
  error
65473
65524
  });
@@ -65496,20 +65547,14 @@ function DepositModal({
65496
65547
  publishableKey,
65497
65548
  assetCdnUrl: projectConfig?.asset_cdn_url,
65498
65549
  projectName: projectConfig?.project_name,
65499
- onSuccess: (txHash) => {
65500
- onDepositSuccess?.({
65501
- message: "Transaction sent successfully",
65502
- transaction: { txHash }
65503
- });
65504
- },
65505
65550
  onError: (error) => {
65506
- onDepositError?.({
65551
+ onDepositErrorFor("wallet_connect")?.({
65507
65552
  message: error.message,
65508
65553
  error
65509
65554
  });
65510
65555
  },
65511
- onDepositSuccess,
65512
- onDepositError,
65556
+ onDepositSuccess: onDepositSuccessFor("wallet_connect"),
65557
+ onDepositError: onDepositErrorFor("wallet_connect"),
65513
65558
  amountQuickSelect: browserWalletAmountQuickSelect,
65514
65559
  onWalletDisconnect: handleWalletDisconnect,
65515
65560
  onWalletConnected: (info, dw) => {
@@ -65553,8 +65598,8 @@ function DepositModal({
65553
65598
  onViewChange: setCashAppView,
65554
65599
  onAmountChange: setCashAppAmount,
65555
65600
  onEvent,
65556
- onDepositSuccess,
65557
- onDepositError
65601
+ onDepositSuccess: onDepositSuccessFor("cashapp"),
65602
+ onDepositError: onDepositErrorFor("cashapp")
65558
65603
  }
65559
65604
  ),
65560
65605
  depositPoweredByFooter
@@ -66392,6 +66437,31 @@ function useWithdrawPolling({
66392
66437
  onWithdrawSuccess,
66393
66438
  onWithdrawError
66394
66439
  }) {
66440
+ const createExecutionSuccessEvent = (execution) => ({
66441
+ id: generatePrefixedKSUID("sevt"),
66442
+ type: WithdrawEventType.DIRECT_EXECUTION_SUCCEEDED,
66443
+ 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),
66444
+ data: { object: mapToDirectExecution(execution) }
66445
+ });
66446
+ const mapToDirectExecution = (execution) => ({
66447
+ id: execution.id,
66448
+ transactionHash: execution.transaction_hash,
66449
+ recipientAddress: execution.recipient_address,
66450
+ depositAddress: execution.deposit_wallet?.address,
66451
+ sourceChainType: execution.source_chain_type,
66452
+ sourceChainId: execution.source_chain_id,
66453
+ sourceTokenAddress: execution.source_token_address,
66454
+ destinationChainType: execution.destination_chain_type,
66455
+ destinationChainId: execution.destination_chain_id,
66456
+ destinationTokenAddress: execution.destination_token_address,
66457
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
66458
+ sourceAmountUsd: execution.source_amount_usd,
66459
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
66460
+ destinationAmountUsd: execution.destination_amount_usd,
66461
+ destinationTransactionHashes: execution.destination_transaction_hashes,
66462
+ status: execution.status,
66463
+ failureReason: execution.failure_reason
66464
+ });
66395
66465
  const [executions, setExecutions] = (0, import_react31.useState)([]);
66396
66466
  const [isPolling, setIsPolling] = (0, import_react31.useState)(false);
66397
66467
  const enabledAtRef = (0, import_react31.useRef)(/* @__PURE__ */ new Date());
@@ -66459,7 +66529,13 @@ function useWithdrawPolling({
66459
66529
  return [...list, ex];
66460
66530
  });
66461
66531
  if (ex.status === ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
66462
- onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
66532
+ onSuccessRef.current?.({
66533
+ message: "Withdrawal completed successfully",
66534
+ executionId: ex.id,
66535
+ // Backward compatibility: keep transaction in API response shape.
66536
+ transaction: ex,
66537
+ execution: createExecutionSuccessEvent(ex)
66538
+ });
66463
66539
  } else if (ex.status === ExecutionStatus.FAILED && prev !== ExecutionStatus.FAILED) {
66464
66540
  onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
66465
66541
  }
@@ -67661,9 +67737,19 @@ function WithdrawModal({
67661
67737
  onWithdraw,
67662
67738
  onWithdrawSuccess,
67663
67739
  onWithdrawError,
67740
+ onEvent,
67664
67741
  theme = "dark",
67665
67742
  hideOverlay = false
67666
67743
  }) {
67744
+ const onWithdrawSuccessFor = (0, import_react30.useCallback)(
67745
+ (data) => {
67746
+ onWithdrawSuccess?.(data);
67747
+ if (data.execution) {
67748
+ onEvent?.(data.execution);
67749
+ }
67750
+ },
67751
+ [onWithdrawSuccess, onEvent]
67752
+ );
67667
67753
  const { colors: colors2, fonts, components } = useTheme();
67668
67754
  const [containerEl, setContainerEl] = (0, import_react30.useState)(null);
67669
67755
  const containerCallbackRef = (0, import_react30.useCallback)((el) => {
@@ -67725,7 +67811,7 @@ function WithdrawModal({
67725
67811
  publishableKey,
67726
67812
  depositWalletId: withdrawDepositWalletId,
67727
67813
  enabled: !!withdrawDepositWalletId && open,
67728
- onWithdrawSuccess: onWithdrawSuccess ? (d) => onWithdrawSuccess({ message: d.message, transaction: d.transaction }) : void 0,
67814
+ onWithdrawSuccess: onWithdrawSuccess || onEvent ? onWithdrawSuccessFor : void 0,
67729
67815
  onWithdrawError
67730
67816
  });
67731
67817
  const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
@@ -68222,6 +68308,7 @@ function UnifoldProvider2({
68222
68308
  onWithdraw: withdrawConfig.withdraw,
68223
68309
  onWithdrawSuccess: handleWithdrawSuccess,
68224
68310
  onWithdrawError: handleWithdrawError,
68311
+ onEvent: withdrawConfig.onEvent,
68225
68312
  theme: resolvedTheme
68226
68313
  }
68227
68314
  ),
package/dist/index.mjs CHANGED
@@ -44095,8 +44095,13 @@ async function sendHypercoreTransaction(request, publishableKey) {
44095
44095
  }
44096
44096
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
44097
44097
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
44098
+ DepositEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
44098
44099
  return DepositEventType2;
44099
44100
  })(DepositEventType || {});
44101
+ var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
44102
+ WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
44103
+ return WithdrawEventType2;
44104
+ })(WithdrawEventType || {});
44100
44105
  var import_qr_code_styling = __toESM2(require_qr_code_styling(), 1);
44101
44106
  var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
44102
44107
  var use = React25[" use ".trim().toString()];
@@ -51728,6 +51733,31 @@ function useDepositPolling({
51728
51733
  onDepositSuccess,
51729
51734
  onDepositError
51730
51735
  }) {
51736
+ const createExecutionSuccessEvent = (execution) => ({
51737
+ id: generatePrefixedKSUID("sevt"),
51738
+ type: DepositEventType.DIRECT_EXECUTION_SUCCEEDED,
51739
+ 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),
51740
+ data: { object: mapToDirectExecution(execution) }
51741
+ });
51742
+ const mapToDirectExecution = (execution) => ({
51743
+ id: execution.id,
51744
+ transactionHash: execution.transaction_hash,
51745
+ recipientAddress: execution.recipient_address,
51746
+ depositAddress: execution.deposit_wallet?.address,
51747
+ sourceChainType: execution.source_chain_type,
51748
+ sourceChainId: execution.source_chain_id,
51749
+ sourceTokenAddress: execution.source_token_address,
51750
+ destinationChainType: execution.destination_chain_type,
51751
+ destinationChainId: execution.destination_chain_id,
51752
+ destinationTokenAddress: execution.destination_token_address,
51753
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
51754
+ sourceAmountUsd: execution.source_amount_usd,
51755
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
51756
+ destinationAmountUsd: execution.destination_amount_usd,
51757
+ destinationTransactionHashes: execution.destination_transaction_hashes,
51758
+ status: execution.status,
51759
+ failureReason: execution.failure_reason
51760
+ });
51731
51761
  const [executions, setExecutions] = (0, import_react10.useState)([]);
51732
51762
  const [isPolling, setIsPolling] = (0, import_react10.useState)(false);
51733
51763
  const [pollingEnabled, setPollingEnabled] = (0, import_react10.useState)(false);
@@ -51841,7 +51871,9 @@ function useDepositPolling({
51841
51871
  onDepositSuccessRef.current?.({
51842
51872
  message: "Deposit completed successfully",
51843
51873
  executionId: execution.id,
51844
- transaction: execution
51874
+ // Backward compatibility: keep transaction in API response shape.
51875
+ transaction: execution,
51876
+ execution: createExecutionSuccessEvent(execution)
51845
51877
  });
51846
51878
  } else if (execution.status === ExecutionStatus.FAILED && previousStatus !== ExecutionStatus.FAILED) {
51847
51879
  onDepositErrorRef.current?.({
@@ -58022,6 +58054,8 @@ function CoinbaseConnect({
58022
58054
  destinationChainId,
58023
58055
  destinationChainType,
58024
58056
  onTransferSuccess,
58057
+ onDepositSuccess,
58058
+ onDepositError,
58025
58059
  onTransferError,
58026
58060
  onClose,
58027
58061
  onBack: parentOnBack,
@@ -58169,10 +58203,14 @@ function CoinbaseConnect({
58169
58203
  depositWalletId: transferDepositWalletId,
58170
58204
  enabled: view === "success" && !!transferDepositWalletId,
58171
58205
  immediateDirectPolling: true,
58172
- onDepositSuccess: onTransferSuccess ? () => {
58173
- if (confirmResult) onTransferSuccess(confirmResult);
58206
+ onDepositSuccess: onDepositSuccess || onTransferSuccess ? (data) => {
58207
+ onDepositSuccess?.(data);
58208
+ if (onTransferSuccess && confirmResult) onTransferSuccess(confirmResult);
58174
58209
  } : void 0,
58175
- onDepositError: onTransferError
58210
+ onDepositError: onDepositError || onTransferError ? (error) => {
58211
+ onDepositError?.(error);
58212
+ onTransferError?.({ message: error.message });
58213
+ } : void 0
58176
58214
  });
58177
58215
  (0, import_react18.useEffect)(() => {
58178
58216
  onExecutionsChange?.(depositExecutions);
@@ -64623,6 +64661,23 @@ function DepositModal({
64623
64661
  depositTrackerSubTitle = t7.depositTracker.subtitle
64624
64662
  }) {
64625
64663
  const { colors: colors2, fonts, components } = useTheme();
64664
+ const onDepositSuccessFor = (0, import_react3.useCallback)(
64665
+ (method) => onDepositSuccess || onEvent ? (data) => {
64666
+ const payload = { ...data, method };
64667
+ onDepositSuccess?.(payload);
64668
+ if (payload.execution) {
64669
+ onEvent?.({
64670
+ ...payload.execution,
64671
+ method
64672
+ });
64673
+ }
64674
+ } : void 0,
64675
+ [onDepositSuccess, onEvent]
64676
+ );
64677
+ const onDepositErrorFor = (0, import_react3.useCallback)(
64678
+ (method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
64679
+ [onDepositError]
64680
+ );
64626
64681
  const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
64627
64682
  const s = initialScreen ?? "main";
64628
64683
  if (s === "tracker" && hideDepositTracker === true) return "main";
@@ -65307,8 +65362,8 @@ function DepositModal({
65307
65362
  defaultSourceSymbol,
65308
65363
  depositConfirmationMode,
65309
65364
  onExecutionsChange: setDepositExecutions,
65310
- onDepositSuccess,
65311
- onDepositError,
65365
+ onDepositSuccess: onDepositSuccessFor("transfer"),
65366
+ onDepositError: onDepositErrorFor("transfer"),
65312
65367
  wallets
65313
65368
  }
65314
65369
  ) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
@@ -65326,8 +65381,8 @@ function DepositModal({
65326
65381
  defaultSourceSymbol,
65327
65382
  depositConfirmationMode,
65328
65383
  onExecutionsChange: setDepositExecutions,
65329
- onDepositSuccess,
65330
- onDepositError,
65384
+ onDepositSuccess: onDepositSuccessFor("transfer"),
65385
+ onDepositError: onDepositErrorFor("transfer"),
65331
65386
  wallets
65332
65387
  }
65333
65388
  ),
@@ -65392,8 +65447,8 @@ function DepositModal({
65392
65447
  destinationChainType,
65393
65448
  destinationChainId,
65394
65449
  destinationTokenAddress,
65395
- onDepositSuccess,
65396
- onDepositError,
65450
+ onDepositSuccess: onDepositSuccessFor("card"),
65451
+ onDepositError: onDepositErrorFor("card"),
65397
65452
  onEvent,
65398
65453
  themeClass,
65399
65454
  wallets,
@@ -65428,8 +65483,8 @@ function DepositModal({
65428
65483
  destinationChainType,
65429
65484
  destinationChainId,
65430
65485
  destinationTokenAddress,
65431
- onDepositSuccess,
65432
- onDepositError,
65486
+ onDepositSuccess: onDepositSuccessFor("pay_with_exchange"),
65487
+ onDepositError: onDepositErrorFor("pay_with_exchange"),
65433
65488
  wallets,
65434
65489
  defaultToken: defaultToken ?? null
65435
65490
  }
@@ -65447,14 +65502,10 @@ function DepositModal({
65447
65502
  destinationTokenAddress: destinationTokenAddress ?? "",
65448
65503
  destinationChainId: destinationChainId ?? "",
65449
65504
  destinationChainType: destinationChainType ?? "",
65450
- onTransferSuccess: (result) => {
65451
- onDepositSuccess?.({
65452
- message: "Transfer completed via Coinbase Connect",
65453
- transaction: result
65454
- });
65455
- },
65505
+ onDepositSuccess: onDepositSuccessFor("exchange_connect"),
65506
+ onDepositError: onDepositErrorFor("exchange_connect"),
65456
65507
  onTransferError: (error) => {
65457
- onDepositError?.({
65508
+ onDepositErrorFor("exchange_connect")?.({
65458
65509
  message: error.message,
65459
65510
  error
65460
65511
  });
@@ -65483,20 +65534,14 @@ function DepositModal({
65483
65534
  publishableKey,
65484
65535
  assetCdnUrl: projectConfig?.asset_cdn_url,
65485
65536
  projectName: projectConfig?.project_name,
65486
- onSuccess: (txHash) => {
65487
- onDepositSuccess?.({
65488
- message: "Transaction sent successfully",
65489
- transaction: { txHash }
65490
- });
65491
- },
65492
65537
  onError: (error) => {
65493
- onDepositError?.({
65538
+ onDepositErrorFor("wallet_connect")?.({
65494
65539
  message: error.message,
65495
65540
  error
65496
65541
  });
65497
65542
  },
65498
- onDepositSuccess,
65499
- onDepositError,
65543
+ onDepositSuccess: onDepositSuccessFor("wallet_connect"),
65544
+ onDepositError: onDepositErrorFor("wallet_connect"),
65500
65545
  amountQuickSelect: browserWalletAmountQuickSelect,
65501
65546
  onWalletDisconnect: handleWalletDisconnect,
65502
65547
  onWalletConnected: (info, dw) => {
@@ -65540,8 +65585,8 @@ function DepositModal({
65540
65585
  onViewChange: setCashAppView,
65541
65586
  onAmountChange: setCashAppAmount,
65542
65587
  onEvent,
65543
- onDepositSuccess,
65544
- onDepositError
65588
+ onDepositSuccess: onDepositSuccessFor("cashapp"),
65589
+ onDepositError: onDepositErrorFor("cashapp")
65545
65590
  }
65546
65591
  ),
65547
65592
  depositPoweredByFooter
@@ -66379,6 +66424,31 @@ function useWithdrawPolling({
66379
66424
  onWithdrawSuccess,
66380
66425
  onWithdrawError
66381
66426
  }) {
66427
+ const createExecutionSuccessEvent = (execution) => ({
66428
+ id: generatePrefixedKSUID("sevt"),
66429
+ type: WithdrawEventType.DIRECT_EXECUTION_SUCCEEDED,
66430
+ 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),
66431
+ data: { object: mapToDirectExecution(execution) }
66432
+ });
66433
+ const mapToDirectExecution = (execution) => ({
66434
+ id: execution.id,
66435
+ transactionHash: execution.transaction_hash,
66436
+ recipientAddress: execution.recipient_address,
66437
+ depositAddress: execution.deposit_wallet?.address,
66438
+ sourceChainType: execution.source_chain_type,
66439
+ sourceChainId: execution.source_chain_id,
66440
+ sourceTokenAddress: execution.source_token_address,
66441
+ destinationChainType: execution.destination_chain_type,
66442
+ destinationChainId: execution.destination_chain_id,
66443
+ destinationTokenAddress: execution.destination_token_address,
66444
+ sourceAmountBaseUnit: execution.source_amount_base_unit,
66445
+ sourceAmountUsd: execution.source_amount_usd,
66446
+ destinationAmountBaseUnit: execution.destination_amount_base_unit,
66447
+ destinationAmountUsd: execution.destination_amount_usd,
66448
+ destinationTransactionHashes: execution.destination_transaction_hashes,
66449
+ status: execution.status,
66450
+ failureReason: execution.failure_reason
66451
+ });
66382
66452
  const [executions, setExecutions] = (0, import_react31.useState)([]);
66383
66453
  const [isPolling, setIsPolling] = (0, import_react31.useState)(false);
66384
66454
  const enabledAtRef = (0, import_react31.useRef)(/* @__PURE__ */ new Date());
@@ -66446,7 +66516,13 @@ function useWithdrawPolling({
66446
66516
  return [...list, ex];
66447
66517
  });
66448
66518
  if (ex.status === ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
66449
- onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
66519
+ onSuccessRef.current?.({
66520
+ message: "Withdrawal completed successfully",
66521
+ executionId: ex.id,
66522
+ // Backward compatibility: keep transaction in API response shape.
66523
+ transaction: ex,
66524
+ execution: createExecutionSuccessEvent(ex)
66525
+ });
66450
66526
  } else if (ex.status === ExecutionStatus.FAILED && prev !== ExecutionStatus.FAILED) {
66451
66527
  onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
66452
66528
  }
@@ -67648,9 +67724,19 @@ function WithdrawModal({
67648
67724
  onWithdraw,
67649
67725
  onWithdrawSuccess,
67650
67726
  onWithdrawError,
67727
+ onEvent,
67651
67728
  theme = "dark",
67652
67729
  hideOverlay = false
67653
67730
  }) {
67731
+ const onWithdrawSuccessFor = (0, import_react30.useCallback)(
67732
+ (data) => {
67733
+ onWithdrawSuccess?.(data);
67734
+ if (data.execution) {
67735
+ onEvent?.(data.execution);
67736
+ }
67737
+ },
67738
+ [onWithdrawSuccess, onEvent]
67739
+ );
67654
67740
  const { colors: colors2, fonts, components } = useTheme();
67655
67741
  const [containerEl, setContainerEl] = (0, import_react30.useState)(null);
67656
67742
  const containerCallbackRef = (0, import_react30.useCallback)((el) => {
@@ -67712,7 +67798,7 @@ function WithdrawModal({
67712
67798
  publishableKey,
67713
67799
  depositWalletId: withdrawDepositWalletId,
67714
67800
  enabled: !!withdrawDepositWalletId && open,
67715
- onWithdrawSuccess: onWithdrawSuccess ? (d) => onWithdrawSuccess({ message: d.message, transaction: d.transaction }) : void 0,
67801
+ onWithdrawSuccess: onWithdrawSuccess || onEvent ? onWithdrawSuccessFor : void 0,
67716
67802
  onWithdrawError
67717
67803
  });
67718
67804
  const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
@@ -68209,6 +68295,7 @@ function UnifoldProvider2({
68209
68295
  onWithdraw: withdrawConfig.withdraw,
68210
68296
  onWithdrawSuccess: handleWithdrawSuccess,
68211
68297
  onWithdrawError: handleWithdrawError,
68298
+ onEvent: withdrawConfig.onEvent,
68212
68299
  theme: resolvedTheme
68213
68300
  }
68214
68301
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-web",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "description": "Unifold UI Web - Framework-agnostic deposit widget",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -30,10 +30,10 @@
30
30
  "@types/react-dom": "^19.0.0",
31
31
  "tsup": "^8.0.0",
32
32
  "typescript": "^5.0.0",
33
- "@unifold/core": "0.1.66",
34
- "@unifold/react-provider": "0.1.66",
35
- "@unifold/ui-react": "0.1.66",
36
- "@unifold/connect-react": "0.1.66"
33
+ "@unifold/connect-react": "0.1.67",
34
+ "@unifold/react-provider": "0.1.67",
35
+ "@unifold/ui-react": "0.1.67",
36
+ "@unifold/core": "0.1.67"
37
37
  },
38
38
  "keywords": [
39
39
  "unifold",