@rhinestone/deposit-modal 0.1.64 → 0.1.66

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.
@@ -19,14 +19,16 @@ import {
19
19
  getPublicClient,
20
20
  isDepositEvent,
21
21
  isNativeAsset,
22
+ isSolanaCaip2,
22
23
  loadSessionOwnerFromStorage,
24
+ parseEvmChainId,
23
25
  portfolioToAssets,
24
26
  saveSessionOwnerToStorage,
25
27
  toEvmCaip2,
26
28
  tokenFormatter,
27
29
  txRefsMatch,
28
30
  useLatestRef
29
- } from "./chunk-TDTBAZNO.mjs";
31
+ } from "./chunk-FWGLRTWF.mjs";
30
32
  import {
31
33
  DEFAULT_BACKEND_URL,
32
34
  DEFAULT_SIGNER_ADDRESS,
@@ -36,9 +38,11 @@ import {
36
38
  getChainIcon,
37
39
  getChainId,
38
40
  getChainName,
41
+ getExplorerUrl,
39
42
  getSupportedChainIds,
40
43
  getTargetTokenSymbolsForChain,
41
44
  getTokenAddress,
45
+ getTokenDecimalsByAddress,
42
46
  getTokenIcon,
43
47
  getTokenSymbol,
44
48
  isStablecoinSymbol
@@ -50,7 +54,7 @@ import {
50
54
  useEffect as useEffect10,
51
55
  useRef as useRef6,
52
56
  useState as useState11,
53
- useCallback as useCallback4,
57
+ useCallback as useCallback5,
54
58
  lazy,
55
59
  Suspense
56
60
  } from "react";
@@ -109,6 +113,8 @@ function SetupStep({
109
113
  sessionOwnerAddress: sessionOwner.address,
110
114
  targetChain: toEvmCaip2(targetChain),
111
115
  targetToken,
116
+ recipient,
117
+ postBridgeActions,
112
118
  signerAddress,
113
119
  sessionChainIds,
114
120
  forceRegister
@@ -2584,6 +2590,7 @@ function DepositFlow({
2584
2590
  allowedRoutes,
2585
2591
  onStepChange,
2586
2592
  onTotalBalanceChange,
2593
+ onSmartAccountChange,
2587
2594
  onClose,
2588
2595
  onConnected,
2589
2596
  onDepositSubmitted,
@@ -2595,6 +2602,7 @@ function DepositFlow({
2595
2602
  }) {
2596
2603
  const onStepChangeRef = useLatestRef(onStepChange);
2597
2604
  const onTotalBalanceChangeRef = useLatestRef(onTotalBalanceChange);
2605
+ const onSmartAccountChangeRef = useLatestRef(onSmartAccountChange);
2598
2606
  const onEventRef = useLatestRef(onEvent);
2599
2607
  const hasInitialReownSession = Boolean(
2600
2608
  enableSolana ? reownWallet?.isConnected || reownWallet?.address : reownWallet?.address
@@ -2999,12 +3007,13 @@ function DepositFlow({
2999
3007
  setStep({ type: "setup" });
3000
3008
  }, []);
3001
3009
  const handleNewDeposit = useCallback3(() => {
3010
+ onSmartAccountChangeRef.current?.(null);
3002
3011
  setFlowMode(null);
3003
3012
  setStep({ type: "setup" });
3004
3013
  setIsConnectSelectionConfirmed(false);
3005
3014
  setSelectedWalletId(null);
3006
3015
  hasNavigatedBackRef.current = false;
3007
- }, []);
3016
+ }, [onSmartAccountChangeRef]);
3008
3017
  const handleSetupComplete = useCallback3(
3009
3018
  (smartAccount, solanaDepositAddress) => {
3010
3019
  logFlow("setup:complete", {
@@ -3012,6 +3021,7 @@ function DepositFlow({
3012
3021
  hasSolanaDepositAddress: Boolean(solanaDepositAddress),
3013
3022
  flowMode: isDepositAddressMode ? "deposit-address" : isSolanaWalletMode ? "solana-wallet" : "wallet"
3014
3023
  });
3024
+ onSmartAccountChangeRef.current?.(smartAccount);
3015
3025
  if (isDepositAddressMode) {
3016
3026
  setStep({
3017
3027
  type: "deposit-address",
@@ -3035,7 +3045,7 @@ function DepositFlow({
3035
3045
  setStep({ type: "select-asset", smartAccount });
3036
3046
  }
3037
3047
  },
3038
- [isDepositAddressMode, isSolanaWalletMode, logFlow]
3048
+ [isDepositAddressMode, isSolanaWalletMode, logFlow, onSmartAccountChangeRef]
3039
3049
  );
3040
3050
  const handleDepositAddressDetected = useCallback3(
3041
3051
  (txHash, chainId, amount, token, sourceSymbol, sourceDecimals) => {
@@ -3662,10 +3672,251 @@ function DepositFlow({
3662
3672
  ] });
3663
3673
  }
3664
3674
 
3675
+ // src/components/history/DepositHistoryPanel.tsx
3676
+ import { useCallback as useCallback4 } from "react";
3677
+ import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
3678
+ function shortenHash(hash) {
3679
+ if (hash.length <= 14) return hash;
3680
+ return `${hash.slice(0, 6)}\u2026${hash.slice(-4)}`;
3681
+ }
3682
+ function formatTimestamp(iso) {
3683
+ try {
3684
+ const date = new Date(iso);
3685
+ if (Number.isNaN(date.getTime())) return iso;
3686
+ const now = /* @__PURE__ */ new Date();
3687
+ const diffMs = now.getTime() - date.getTime();
3688
+ const diffMin = Math.floor(diffMs / 6e4);
3689
+ if (diffMin < 1) return "Just now";
3690
+ if (diffMin < 60) return `${diffMin}m ago`;
3691
+ const diffHr = Math.floor(diffMin / 60);
3692
+ if (diffHr < 24) return `${diffHr}h ago`;
3693
+ const diffDay = Math.floor(diffHr / 24);
3694
+ if (diffDay < 7) return `${diffDay}d ago`;
3695
+ return date.toLocaleDateString("en-US", {
3696
+ month: "short",
3697
+ day: "numeric"
3698
+ });
3699
+ } catch {
3700
+ return iso;
3701
+ }
3702
+ }
3703
+ function resolveChainId(value) {
3704
+ if (value === void 0 || value === null) return null;
3705
+ if (typeof value === "number") return value;
3706
+ if (isSolanaCaip2(value) || value === "solana") return "solana";
3707
+ const parsed = parseEvmChainId(value);
3708
+ if (parsed !== null) return parsed;
3709
+ const num = Number(value);
3710
+ return Number.isFinite(num) ? num : null;
3711
+ }
3712
+ function resolveTokenSymbol(token, chainId) {
3713
+ if (!token) return "";
3714
+ if (chainId !== null && chainId !== void 0 && chainId !== "solana" && /^0x[a-fA-F0-9]{40}$/.test(token)) {
3715
+ const sym = getTokenSymbol(token, chainId);
3716
+ if (sym !== "Token") return sym;
3717
+ }
3718
+ return shortenHash(token);
3719
+ }
3720
+ function formatAmount(rawAmount, token, chainId) {
3721
+ if (!rawAmount) return "";
3722
+ let decimals = 18;
3723
+ if (token && chainId !== null && chainId !== void 0 && chainId !== "solana" && /^0x[a-fA-F0-9]{40}$/.test(token)) {
3724
+ decimals = getTokenDecimalsByAddress(token, chainId);
3725
+ }
3726
+ try {
3727
+ const raw = BigInt(rawAmount);
3728
+ const divisor = BigInt(10 ** decimals);
3729
+ const whole = raw / divisor;
3730
+ const remainder = raw % divisor;
3731
+ if (remainder === 0n) return whole.toString();
3732
+ const fracStr = remainder.toString().padStart(decimals, "0");
3733
+ const trimmed = fracStr.slice(0, 6).replace(/0+$/, "");
3734
+ if (!trimmed) return whole.toString();
3735
+ return `${whole}.${trimmed}`;
3736
+ } catch {
3737
+ return rawAmount;
3738
+ }
3739
+ }
3740
+ function getTxExplorerUrl(txHash, chainId) {
3741
+ if (!chainId) return null;
3742
+ const base = getExplorerUrl(chainId);
3743
+ if (!base) return null;
3744
+ return `${base}/tx/${txHash}`;
3745
+ }
3746
+ function normalizeStatus(raw) {
3747
+ const lower = raw.toLowerCase();
3748
+ if (lower === "completed" || lower === "complete" || lower === "bridge-complete" || lower === "processed") return "completed";
3749
+ if (lower === "failed" || lower === "error" || lower === "bridge-failed") return "failed";
3750
+ if (lower === "processing" || lower === "submitted" || lower === "bridging") return "processing";
3751
+ return "pending";
3752
+ }
3753
+ var STATUS_LABEL = {
3754
+ pending: "Pending",
3755
+ processing: "Processing",
3756
+ completed: "Completed",
3757
+ failed: "Failed"
3758
+ };
3759
+ function ExternalLinkIcon() {
3760
+ return /* @__PURE__ */ jsx11("svg", { className: "rs-history-ext-icon", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ jsx11("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 1.5H2.25A.75.75 0 0 0 1.5 2.25v7.5c0 .414.336.75.75.75h7.5a.75.75 0 0 0 .75-.75V7.5m-3-6h3m0 0v3m0-3L6 6" }) });
3761
+ }
3762
+ function DepositHistoryPanel({
3763
+ deposits,
3764
+ isLoading,
3765
+ error,
3766
+ hasMore,
3767
+ isLoadingMore,
3768
+ onLoadMore,
3769
+ onClose
3770
+ }) {
3771
+ const handleKeyDown = useCallback4(
3772
+ (e) => {
3773
+ if (e.key === "Escape") {
3774
+ e.stopPropagation();
3775
+ onClose();
3776
+ }
3777
+ },
3778
+ [onClose]
3779
+ );
3780
+ return /* @__PURE__ */ jsxs11(
3781
+ "div",
3782
+ {
3783
+ className: "rs-history-panel",
3784
+ role: "dialog",
3785
+ "aria-label": "Deposit history",
3786
+ onKeyDown: handleKeyDown,
3787
+ children: [
3788
+ /* @__PURE__ */ jsxs11("div", { className: "rs-history-header", children: [
3789
+ /* @__PURE__ */ jsx11(
3790
+ "button",
3791
+ {
3792
+ type: "button",
3793
+ className: "rs-history-back",
3794
+ "aria-label": "Close history",
3795
+ onClick: onClose,
3796
+ children: /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx11("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 19.5L8.25 12l7.5-7.5" }) })
3797
+ }
3798
+ ),
3799
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-header-title", children: "History" }),
3800
+ /* @__PURE__ */ jsx11("div", { className: "rs-history-header-spacer" })
3801
+ ] }),
3802
+ /* @__PURE__ */ jsxs11("div", { className: "rs-history-body", children: [
3803
+ isLoading && deposits.length === 0 && /* @__PURE__ */ jsxs11("div", { className: "rs-history-state", children: [
3804
+ /* @__PURE__ */ jsx11("div", { className: "rs-history-spinner", children: /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx11("path", { d: "M12 2v4m0 12v4m-7.07-3.93l2.83-2.83m8.48-8.48l2.83-2.83M2 12h4m12 0h4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83", strokeLinecap: "round" }) }) }),
3805
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-state-text", children: "Loading history..." })
3806
+ ] }),
3807
+ error && !isLoading && /* @__PURE__ */ jsxs11("div", { className: "rs-history-state", children: [
3808
+ /* @__PURE__ */ jsx11("div", { className: "rs-history-state-icon rs-history-state-icon--error", children: /* @__PURE__ */ jsxs11("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
3809
+ /* @__PURE__ */ jsx11("circle", { cx: "12", cy: "12", r: "10" }),
3810
+ /* @__PURE__ */ jsx11("path", { strokeLinecap: "round", d: "M12 8v4m0 4h.01" })
3811
+ ] }) }),
3812
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-state-text", children: error })
3813
+ ] }),
3814
+ !isLoading && !error && deposits.length === 0 && /* @__PURE__ */ jsxs11("div", { className: "rs-history-state", children: [
3815
+ /* @__PURE__ */ jsx11("div", { className: "rs-history-state-icon", children: /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ jsx11("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" }) }) }),
3816
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-state-text", children: "No deposits yet" }),
3817
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-state-hint", children: "Your deposit history will appear here" })
3818
+ ] }),
3819
+ deposits.length > 0 && /* @__PURE__ */ jsxs11("div", { className: "rs-history-list", children: [
3820
+ deposits.map((deposit, i) => /* @__PURE__ */ jsx11(HistoryRow, { deposit }, deposit.txHash || i)),
3821
+ hasMore && /* @__PURE__ */ jsx11(
3822
+ "button",
3823
+ {
3824
+ type: "button",
3825
+ className: "rs-history-load-more",
3826
+ onClick: onLoadMore,
3827
+ disabled: isLoadingMore,
3828
+ children: isLoadingMore ? "Loading..." : "Load more"
3829
+ }
3830
+ )
3831
+ ] })
3832
+ ] })
3833
+ ]
3834
+ }
3835
+ );
3836
+ }
3837
+ function HistoryRow({ deposit }) {
3838
+ const status = normalizeStatus(deposit.status);
3839
+ const sourceChainId = resolveChainId(deposit.chain);
3840
+ const targetChainId = resolveChainId(deposit.targetChain);
3841
+ const sourceChainName = sourceChainId ? getChainName(sourceChainId) : null;
3842
+ const targetChainName = targetChainId ? getChainName(targetChainId) : null;
3843
+ const sourceChainIcon = sourceChainId ? getChainIcon(sourceChainId) : void 0;
3844
+ const targetChainIcon = targetChainId ? getChainIcon(targetChainId) : void 0;
3845
+ const sourceSymbol = resolveTokenSymbol(deposit.token, sourceChainId);
3846
+ const targetSymbol = resolveTokenSymbol(deposit.targetToken, targetChainId);
3847
+ const rawAmount = deposit.sourceAmount ?? deposit.amount;
3848
+ const formattedAmount = rawAmount ? formatAmount(rawAmount, deposit.token, sourceChainId) : null;
3849
+ const timestamp = deposit.createdAt ? formatTimestamp(deposit.createdAt) : null;
3850
+ const srcTxUrl = deposit.sourceTxHash ? getTxExplorerUrl(deposit.sourceTxHash, sourceChainId) : null;
3851
+ const dstTxUrl = deposit.destinationTxHash ? getTxExplorerUrl(deposit.destinationTxHash, targetChainId) : null;
3852
+ return /* @__PURE__ */ jsxs11("div", { className: "rs-history-row", children: [
3853
+ /* @__PURE__ */ jsxs11("div", { className: "rs-history-row-primary", children: [
3854
+ /* @__PURE__ */ jsxs11("div", { className: "rs-history-route", children: [
3855
+ /* @__PURE__ */ jsxs11("span", { className: "rs-history-chain", children: [
3856
+ sourceChainIcon && /* @__PURE__ */ jsx11("img", { src: sourceChainIcon, alt: "", className: "rs-history-chain-icon" }),
3857
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-chain-name", children: sourceChainName ?? "Unknown" })
3858
+ ] }),
3859
+ /* @__PURE__ */ jsx11("svg", { className: "rs-history-route-arrow", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: /* @__PURE__ */ jsx11("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M2.5 6h7m0 0L7 3.5M9.5 6 7 8.5" }) }),
3860
+ /* @__PURE__ */ jsxs11("span", { className: "rs-history-chain", children: [
3861
+ targetChainIcon && /* @__PURE__ */ jsx11("img", { src: targetChainIcon, alt: "", className: "rs-history-chain-icon" }),
3862
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-chain-name", children: targetChainName ?? "Unknown" })
3863
+ ] })
3864
+ ] }),
3865
+ /* @__PURE__ */ jsxs11("span", { className: `rs-history-status rs-history-status--${status}`, children: [
3866
+ /* @__PURE__ */ jsx11("span", { className: `rs-history-dot rs-history-dot--${status}` }),
3867
+ STATUS_LABEL[status]
3868
+ ] })
3869
+ ] }),
3870
+ /* @__PURE__ */ jsxs11("div", { className: "rs-history-row-secondary", children: [
3871
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-amount", children: formattedAmount ? /* @__PURE__ */ jsxs11(Fragment3, { children: [
3872
+ formattedAmount,
3873
+ " ",
3874
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-token", children: sourceSymbol }),
3875
+ targetSymbol && sourceSymbol !== targetSymbol && /* @__PURE__ */ jsxs11("span", { className: "rs-history-token-target", children: [
3876
+ " \u2192 ",
3877
+ targetSymbol
3878
+ ] })
3879
+ ] }) : /* @__PURE__ */ jsx11("span", { className: "rs-history-no-amount", children: "\u2014" }) }),
3880
+ timestamp && /* @__PURE__ */ jsx11("span", { className: "rs-history-time", children: timestamp })
3881
+ ] }),
3882
+ (srcTxUrl || dstTxUrl) && /* @__PURE__ */ jsxs11("div", { className: "rs-history-row-links", children: [
3883
+ srcTxUrl && deposit.sourceTxHash && /* @__PURE__ */ jsxs11(
3884
+ "a",
3885
+ {
3886
+ href: srcTxUrl,
3887
+ target: "_blank",
3888
+ rel: "noopener noreferrer",
3889
+ className: "rs-history-tx-link",
3890
+ title: deposit.sourceTxHash,
3891
+ children: [
3892
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-tx-hash", children: shortenHash(deposit.sourceTxHash) }),
3893
+ /* @__PURE__ */ jsx11(ExternalLinkIcon, {})
3894
+ ]
3895
+ }
3896
+ ),
3897
+ dstTxUrl && deposit.destinationTxHash && /* @__PURE__ */ jsxs11(
3898
+ "a",
3899
+ {
3900
+ href: dstTxUrl,
3901
+ target: "_blank",
3902
+ rel: "noopener noreferrer",
3903
+ className: "rs-history-tx-link",
3904
+ title: deposit.destinationTxHash,
3905
+ children: [
3906
+ /* @__PURE__ */ jsx11("span", { className: "rs-history-tx-hash", children: shortenHash(deposit.destinationTxHash) }),
3907
+ /* @__PURE__ */ jsx11(ExternalLinkIcon, {})
3908
+ ]
3909
+ }
3910
+ )
3911
+ ] })
3912
+ ] });
3913
+ }
3914
+ DepositHistoryPanel.displayName = "DepositHistoryPanel";
3915
+
3665
3916
  // src/DepositModal.tsx
3666
- import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
3917
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
3667
3918
  var ReownDepositInner = lazy(
3668
- () => import("./DepositModalReown-XOLZ62BQ.mjs").then((m) => ({ default: m.DepositModalReown }))
3919
+ () => import("./DepositModalReown-RXIVPSEE.mjs").then((m) => ({ default: m.DepositModalReown }))
3669
3920
  );
3670
3921
  function DepositModal(props) {
3671
3922
  const needsReown = !!props.reownAppId;
@@ -3674,7 +3925,7 @@ function DepositModal(props) {
3674
3925
  "dappWalletClient"
3675
3926
  );
3676
3927
  if (needsReown) {
3677
- return /* @__PURE__ */ jsx11(Suspense, { fallback: null, children: /* @__PURE__ */ jsx11(
3928
+ return /* @__PURE__ */ jsx12(Suspense, { fallback: null, children: /* @__PURE__ */ jsx12(
3678
3929
  ReownDepositInner,
3679
3930
  {
3680
3931
  ...props,
@@ -3682,7 +3933,7 @@ function DepositModal(props) {
3682
3933
  }
3683
3934
  ) });
3684
3935
  }
3685
- return /* @__PURE__ */ jsx11(
3936
+ return /* @__PURE__ */ jsx12(
3686
3937
  DepositModalInner,
3687
3938
  {
3688
3939
  ...props,
@@ -3738,6 +3989,16 @@ function DepositModalInner({
3738
3989
  const [currentStepIndex, setCurrentStepIndex] = useState11(0);
3739
3990
  const [totalBalanceUsd, setTotalBalanceUsd] = useState11(null);
3740
3991
  const backHandlerRef = useRef6(void 0);
3992
+ const showHistoryButton = uiConfig?.showHistoryButton ?? false;
3993
+ const [activeSmartAccount, setActiveSmartAccount] = useState11(null);
3994
+ const [historyOpen, setHistoryOpen] = useState11(false);
3995
+ const [historyDeposits, setHistoryDeposits] = useState11([]);
3996
+ const [historyNextCursor, setHistoryNextCursor] = useState11(null);
3997
+ const [historyLoading, setHistoryLoading] = useState11(false);
3998
+ const [historyLoadingMore, setHistoryLoadingMore] = useState11(false);
3999
+ const [historyError, setHistoryError] = useState11(null);
4000
+ const historyStaleRef = useRef6(false);
4001
+ const historyLoadedRef = useRef6(false);
3741
4002
  const targetChain = getChainId(targetChainProp);
3742
4003
  const sourceChain = sourceChainProp ? getChainId(sourceChainProp) : void 0;
3743
4004
  const service = useMemo8(
@@ -3767,19 +4028,121 @@ function DepositModalInner({
3767
4028
  setCurrentStepIndex(0);
3768
4029
  }
3769
4030
  }, [isOpen]);
3770
- const handleStepChange = useCallback4(
4031
+ const handleStepChange = useCallback5(
3771
4032
  (stepIndex, onBack) => {
3772
4033
  setCurrentStepIndex(stepIndex);
3773
4034
  backHandlerRef.current = onBack;
3774
4035
  },
3775
4036
  []
3776
4037
  );
3777
- const handleTotalBalanceChange = useCallback4((balance2) => {
4038
+ const handleTotalBalanceChange = useCallback5((balance2) => {
3778
4039
  setTotalBalanceUsd(balance2);
3779
4040
  }, []);
3780
- const handleBack = useCallback4(() => {
4041
+ const handleBack = useCallback5(() => {
3781
4042
  backHandlerRef.current?.();
3782
4043
  }, []);
4044
+ const handleSmartAccountChange = useCallback5(
4045
+ (account) => {
4046
+ setActiveSmartAccount(account);
4047
+ if (!account) {
4048
+ historyStaleRef.current = true;
4049
+ }
4050
+ },
4051
+ []
4052
+ );
4053
+ const fetchHistory = useCallback5(
4054
+ async (cursor) => {
4055
+ if (!activeSmartAccount) return;
4056
+ const isInitial = !cursor;
4057
+ if (isInitial) {
4058
+ setHistoryLoading(true);
4059
+ } else {
4060
+ setHistoryLoadingMore(true);
4061
+ }
4062
+ setHistoryError(null);
4063
+ try {
4064
+ const result = await service.fetchDepositHistory({
4065
+ account: activeSmartAccount,
4066
+ limit: 20,
4067
+ cursor
4068
+ });
4069
+ if (isInitial) {
4070
+ setHistoryDeposits(result.deposits);
4071
+ } else {
4072
+ setHistoryDeposits((prev) => [...prev, ...result.deposits]);
4073
+ }
4074
+ setHistoryNextCursor(result.nextCursor ?? null);
4075
+ historyStaleRef.current = false;
4076
+ historyLoadedRef.current = true;
4077
+ } catch (err) {
4078
+ setHistoryError(
4079
+ err instanceof Error ? err.message : "Failed to load history"
4080
+ );
4081
+ } finally {
4082
+ if (isInitial) {
4083
+ setHistoryLoading(false);
4084
+ } else {
4085
+ setHistoryLoadingMore(false);
4086
+ }
4087
+ }
4088
+ },
4089
+ [activeSmartAccount, service]
4090
+ );
4091
+ const handleHistoryOpen = useCallback5(() => {
4092
+ setHistoryOpen(true);
4093
+ if (!historyLoadedRef.current || historyStaleRef.current) {
4094
+ fetchHistory();
4095
+ }
4096
+ }, [fetchHistory]);
4097
+ const handleHistoryClose = useCallback5(() => {
4098
+ setHistoryOpen(false);
4099
+ }, []);
4100
+ const handleHistoryLoadMore = useCallback5(() => {
4101
+ if (historyNextCursor) {
4102
+ fetchHistory(historyNextCursor);
4103
+ }
4104
+ }, [fetchHistory, historyNextCursor]);
4105
+ const markHistoryStale = useCallback5(() => {
4106
+ historyStaleRef.current = true;
4107
+ if (historyOpen) {
4108
+ fetchHistory();
4109
+ }
4110
+ }, [historyOpen, fetchHistory]);
4111
+ const onDepositSubmittedRef = useLatestRef(onDepositSubmitted);
4112
+ const onDepositCompleteRef = useLatestRef(onDepositComplete);
4113
+ const onDepositFailedRef = useLatestRef(onDepositFailed);
4114
+ const handleDepositSubmitted = useCallback5(
4115
+ (data) => {
4116
+ onDepositSubmittedRef.current?.(data);
4117
+ if (showHistoryButton) markHistoryStale();
4118
+ },
4119
+ [onDepositSubmittedRef, showHistoryButton, markHistoryStale]
4120
+ );
4121
+ const handleDepositComplete = useCallback5(
4122
+ (data) => {
4123
+ onDepositCompleteRef.current?.(data);
4124
+ if (showHistoryButton) markHistoryStale();
4125
+ },
4126
+ [onDepositCompleteRef, showHistoryButton, markHistoryStale]
4127
+ );
4128
+ const handleDepositFailed = useCallback5(
4129
+ (data) => {
4130
+ onDepositFailedRef.current?.(data);
4131
+ if (showHistoryButton) markHistoryStale();
4132
+ },
4133
+ [onDepositFailedRef, showHistoryButton, markHistoryStale]
4134
+ );
4135
+ useEffect10(() => {
4136
+ if (!isOpen) {
4137
+ setHistoryOpen(false);
4138
+ setHistoryDeposits([]);
4139
+ setHistoryNextCursor(null);
4140
+ setHistoryError(null);
4141
+ setActiveSmartAccount(null);
4142
+ historyStaleRef.current = false;
4143
+ historyLoadedRef.current = false;
4144
+ }
4145
+ }, [isOpen]);
3783
4146
  const showLogo = uiConfig?.showLogo ?? false;
3784
4147
  const showStepper = uiConfig?.showStepper ?? false;
3785
4148
  const showBackButton = uiConfig?.showBackButton ?? true;
@@ -3787,7 +4150,7 @@ function DepositModalInner({
3787
4150
  const logoUrl = branding?.logoUrl ?? "https://github.com/rhinestonewtf.png";
3788
4151
  const title = branding?.title ?? "Deposit";
3789
4152
  const canGoBack = currentStepIndex > 0 && currentStepIndex < 4 && backHandlerRef.current !== void 0;
3790
- return /* @__PURE__ */ jsx11(
4153
+ return /* @__PURE__ */ jsx12(
3791
4154
  Modal,
3792
4155
  {
3793
4156
  isOpen,
@@ -3795,23 +4158,23 @@ function DepositModalInner({
3795
4158
  className,
3796
4159
  inline,
3797
4160
  closeOnOverlayClick,
3798
- children: /* @__PURE__ */ jsxs11("div", { ref: modalRef, className: "rs-modal", children: [
3799
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header--redesigned", children: [
3800
- /* @__PURE__ */ jsx11("div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && /* @__PURE__ */ jsx11(
4161
+ children: /* @__PURE__ */ jsxs12("div", { ref: modalRef, className: "rs-modal", children: [
4162
+ /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header--redesigned", children: [
4163
+ /* @__PURE__ */ jsx12("div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && /* @__PURE__ */ jsx12(
3801
4164
  "button",
3802
4165
  {
3803
4166
  type: "button",
3804
4167
  className: "rs-modal-header-back",
3805
4168
  "aria-label": "Go back",
3806
4169
  onClick: handleBack,
3807
- children: /* @__PURE__ */ jsx11(
4170
+ children: /* @__PURE__ */ jsx12(
3808
4171
  "svg",
3809
4172
  {
3810
4173
  viewBox: "0 0 24 24",
3811
4174
  fill: "none",
3812
4175
  stroke: "currentColor",
3813
4176
  strokeWidth: "2",
3814
- children: /* @__PURE__ */ jsx11(
4177
+ children: /* @__PURE__ */ jsx12(
3815
4178
  "path",
3816
4179
  {
3817
4180
  strokeLinecap: "round",
@@ -3823,9 +4186,9 @@ function DepositModalInner({
3823
4186
  )
3824
4187
  }
3825
4188
  ) }),
3826
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-nav-center", children: [
3827
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-title-row", children: [
3828
- showLogo && logoUrl && /* @__PURE__ */ jsx11(
4189
+ /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header-nav-center", children: [
4190
+ /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header-title-row", children: [
4191
+ showLogo && logoUrl && /* @__PURE__ */ jsx12(
3829
4192
  "img",
3830
4193
  {
3831
4194
  src: logoUrl,
@@ -3836,20 +4199,20 @@ function DepositModalInner({
3836
4199
  }
3837
4200
  }
3838
4201
  ),
3839
- /* @__PURE__ */ jsx11("span", { className: "rs-modal-header-title", children: title }),
3840
- showStepper && currentStepIndex >= 2 && /* @__PURE__ */ jsxs11("div", { className: "rs-step-indicator", style: { marginLeft: 8 }, children: [
3841
- /* @__PURE__ */ jsx11(
4202
+ /* @__PURE__ */ jsx12("span", { className: "rs-modal-header-title", children: title }),
4203
+ showStepper && currentStepIndex >= 2 && /* @__PURE__ */ jsxs12("div", { className: "rs-step-indicator", style: { marginLeft: 8 }, children: [
4204
+ /* @__PURE__ */ jsx12(
3842
4205
  "div",
3843
4206
  {
3844
4207
  className: `rs-step-indicator-node ${currentStepIndex >= 4 ? "rs-step-indicator-node--complete" : "rs-step-indicator-node--active"}`,
3845
- children: currentStepIndex >= 4 ? /* @__PURE__ */ jsx11(
4208
+ children: currentStepIndex >= 4 ? /* @__PURE__ */ jsx12(
3846
4209
  "svg",
3847
4210
  {
3848
4211
  viewBox: "0 0 24 24",
3849
4212
  fill: "none",
3850
4213
  stroke: "currentColor",
3851
4214
  strokeWidth: "3",
3852
- children: /* @__PURE__ */ jsx11(
4215
+ children: /* @__PURE__ */ jsx12(
3853
4216
  "path",
3854
4217
  {
3855
4218
  strokeLinecap: "round",
@@ -3861,13 +4224,13 @@ function DepositModalInner({
3861
4224
  ) : "1"
3862
4225
  }
3863
4226
  ),
3864
- /* @__PURE__ */ jsx11(
4227
+ /* @__PURE__ */ jsx12(
3865
4228
  "div",
3866
4229
  {
3867
4230
  className: `rs-step-indicator-line ${currentStepIndex >= 4 ? "rs-step-indicator-line--active" : ""}`
3868
4231
  }
3869
4232
  ),
3870
- /* @__PURE__ */ jsx11(
4233
+ /* @__PURE__ */ jsx12(
3871
4234
  "div",
3872
4235
  {
3873
4236
  className: `rs-step-indicator-node ${currentStepIndex >= 4 ? "rs-step-indicator-node--active" : "rs-step-indicator-node--inactive"}`,
@@ -3876,42 +4239,71 @@ function DepositModalInner({
3876
4239
  )
3877
4240
  ] })
3878
4241
  ] }),
3879
- balance && /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-balance", children: [
3880
- /* @__PURE__ */ jsxs11("span", { children: [
4242
+ balance && /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header-balance", children: [
4243
+ /* @__PURE__ */ jsxs12("span", { children: [
3881
4244
  balance.title,
3882
4245
  ":"
3883
4246
  ] }),
3884
- /* @__PURE__ */ jsx11("span", { className: "rs-modal-header-balance-value", children: balance.amount ?? (totalBalanceUsd !== null ? currencyFormatter.format(totalBalanceUsd) : null) })
4247
+ /* @__PURE__ */ jsx12("span", { className: "rs-modal-header-balance-value", children: balance.amount ?? (totalBalanceUsd !== null ? currencyFormatter.format(totalBalanceUsd) : null) })
3885
4248
  ] })
3886
4249
  ] }),
3887
- /* @__PURE__ */ jsx11("div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ jsx11(
3888
- "button",
3889
- {
3890
- type: "button",
3891
- onClick: onClose,
3892
- className: "rs-modal-close",
3893
- "aria-label": "Close",
3894
- children: /* @__PURE__ */ jsx11(
3895
- "svg",
3896
- {
3897
- viewBox: "0 0 24 24",
3898
- fill: "none",
3899
- stroke: "currentColor",
3900
- strokeWidth: "2",
3901
- children: /* @__PURE__ */ jsx11(
3902
- "path",
3903
- {
3904
- strokeLinecap: "round",
3905
- strokeLinejoin: "round",
3906
- d: "M6 18L18 6M6 6l12 12"
3907
- }
3908
- )
3909
- }
3910
- )
3911
- }
3912
- ) })
4250
+ /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header-nav-right", children: [
4251
+ showHistoryButton && /* @__PURE__ */ jsx12(
4252
+ "button",
4253
+ {
4254
+ type: "button",
4255
+ className: "rs-modal-header-history",
4256
+ "aria-label": "Deposit history",
4257
+ onClick: handleHistoryOpen,
4258
+ disabled: !activeSmartAccount,
4259
+ children: /* @__PURE__ */ jsx12(
4260
+ "svg",
4261
+ {
4262
+ viewBox: "0 0 24 24",
4263
+ fill: "none",
4264
+ stroke: "currentColor",
4265
+ strokeWidth: "1.75",
4266
+ children: /* @__PURE__ */ jsx12(
4267
+ "path",
4268
+ {
4269
+ strokeLinecap: "round",
4270
+ strokeLinejoin: "round",
4271
+ d: "M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
4272
+ }
4273
+ )
4274
+ }
4275
+ )
4276
+ }
4277
+ ),
4278
+ /* @__PURE__ */ jsx12(
4279
+ "button",
4280
+ {
4281
+ type: "button",
4282
+ onClick: onClose,
4283
+ className: "rs-modal-close",
4284
+ "aria-label": "Close",
4285
+ children: /* @__PURE__ */ jsx12(
4286
+ "svg",
4287
+ {
4288
+ viewBox: "0 0 24 24",
4289
+ fill: "none",
4290
+ stroke: "currentColor",
4291
+ strokeWidth: "2",
4292
+ children: /* @__PURE__ */ jsx12(
4293
+ "path",
4294
+ {
4295
+ strokeLinecap: "round",
4296
+ strokeLinejoin: "round",
4297
+ d: "M6 18L18 6M6 6l12 12"
4298
+ }
4299
+ )
4300
+ }
4301
+ )
4302
+ }
4303
+ )
4304
+ ] })
3913
4305
  ] }),
3914
- /* @__PURE__ */ jsx11(
4306
+ /* @__PURE__ */ jsx12(
3915
4307
  DepositFlow,
3916
4308
  {
3917
4309
  dappWalletClient,
@@ -3940,15 +4332,28 @@ function DepositModalInner({
3940
4332
  allowedRoutes,
3941
4333
  onStepChange: handleStepChange,
3942
4334
  onTotalBalanceChange: handleTotalBalanceChange,
4335
+ onSmartAccountChange: showHistoryButton ? handleSmartAccountChange : void 0,
3943
4336
  onClose,
3944
4337
  onConnected,
3945
- onDepositSubmitted,
3946
- onDepositComplete,
3947
- onDepositFailed,
4338
+ onDepositSubmitted: showHistoryButton ? handleDepositSubmitted : onDepositSubmitted,
4339
+ onDepositComplete: showHistoryButton ? handleDepositComplete : onDepositComplete,
4340
+ onDepositFailed: showHistoryButton ? handleDepositFailed : onDepositFailed,
3948
4341
  onEvent,
3949
4342
  onError,
3950
4343
  debug
3951
4344
  }
4345
+ ),
4346
+ showHistoryButton && historyOpen && /* @__PURE__ */ jsx12(
4347
+ DepositHistoryPanel,
4348
+ {
4349
+ deposits: historyDeposits,
4350
+ isLoading: historyLoading,
4351
+ error: historyError,
4352
+ hasMore: Boolean(historyNextCursor),
4353
+ isLoadingMore: historyLoadingMore,
4354
+ onLoadMore: handleHistoryLoadMore,
4355
+ onClose: handleHistoryClose
4356
+ }
3952
4357
  )
3953
4358
  ] })
3954
4359
  }