@rhinestone/deposit-modal 0.1.65 → 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-GAHX5RAT.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";
@@ -2586,6 +2590,7 @@ function DepositFlow({
2586
2590
  allowedRoutes,
2587
2591
  onStepChange,
2588
2592
  onTotalBalanceChange,
2593
+ onSmartAccountChange,
2589
2594
  onClose,
2590
2595
  onConnected,
2591
2596
  onDepositSubmitted,
@@ -2597,6 +2602,7 @@ function DepositFlow({
2597
2602
  }) {
2598
2603
  const onStepChangeRef = useLatestRef(onStepChange);
2599
2604
  const onTotalBalanceChangeRef = useLatestRef(onTotalBalanceChange);
2605
+ const onSmartAccountChangeRef = useLatestRef(onSmartAccountChange);
2600
2606
  const onEventRef = useLatestRef(onEvent);
2601
2607
  const hasInitialReownSession = Boolean(
2602
2608
  enableSolana ? reownWallet?.isConnected || reownWallet?.address : reownWallet?.address
@@ -3001,12 +3007,13 @@ function DepositFlow({
3001
3007
  setStep({ type: "setup" });
3002
3008
  }, []);
3003
3009
  const handleNewDeposit = useCallback3(() => {
3010
+ onSmartAccountChangeRef.current?.(null);
3004
3011
  setFlowMode(null);
3005
3012
  setStep({ type: "setup" });
3006
3013
  setIsConnectSelectionConfirmed(false);
3007
3014
  setSelectedWalletId(null);
3008
3015
  hasNavigatedBackRef.current = false;
3009
- }, []);
3016
+ }, [onSmartAccountChangeRef]);
3010
3017
  const handleSetupComplete = useCallback3(
3011
3018
  (smartAccount, solanaDepositAddress) => {
3012
3019
  logFlow("setup:complete", {
@@ -3014,6 +3021,7 @@ function DepositFlow({
3014
3021
  hasSolanaDepositAddress: Boolean(solanaDepositAddress),
3015
3022
  flowMode: isDepositAddressMode ? "deposit-address" : isSolanaWalletMode ? "solana-wallet" : "wallet"
3016
3023
  });
3024
+ onSmartAccountChangeRef.current?.(smartAccount);
3017
3025
  if (isDepositAddressMode) {
3018
3026
  setStep({
3019
3027
  type: "deposit-address",
@@ -3037,7 +3045,7 @@ function DepositFlow({
3037
3045
  setStep({ type: "select-asset", smartAccount });
3038
3046
  }
3039
3047
  },
3040
- [isDepositAddressMode, isSolanaWalletMode, logFlow]
3048
+ [isDepositAddressMode, isSolanaWalletMode, logFlow, onSmartAccountChangeRef]
3041
3049
  );
3042
3050
  const handleDepositAddressDetected = useCallback3(
3043
3051
  (txHash, chainId, amount, token, sourceSymbol, sourceDecimals) => {
@@ -3664,10 +3672,251 @@ function DepositFlow({
3664
3672
  ] });
3665
3673
  }
3666
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
+
3667
3916
  // src/DepositModal.tsx
3668
- import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
3917
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
3669
3918
  var ReownDepositInner = lazy(
3670
- () => import("./DepositModalReown-Y4M3RA73.mjs").then((m) => ({ default: m.DepositModalReown }))
3919
+ () => import("./DepositModalReown-RXIVPSEE.mjs").then((m) => ({ default: m.DepositModalReown }))
3671
3920
  );
3672
3921
  function DepositModal(props) {
3673
3922
  const needsReown = !!props.reownAppId;
@@ -3676,7 +3925,7 @@ function DepositModal(props) {
3676
3925
  "dappWalletClient"
3677
3926
  );
3678
3927
  if (needsReown) {
3679
- return /* @__PURE__ */ jsx11(Suspense, { fallback: null, children: /* @__PURE__ */ jsx11(
3928
+ return /* @__PURE__ */ jsx12(Suspense, { fallback: null, children: /* @__PURE__ */ jsx12(
3680
3929
  ReownDepositInner,
3681
3930
  {
3682
3931
  ...props,
@@ -3684,7 +3933,7 @@ function DepositModal(props) {
3684
3933
  }
3685
3934
  ) });
3686
3935
  }
3687
- return /* @__PURE__ */ jsx11(
3936
+ return /* @__PURE__ */ jsx12(
3688
3937
  DepositModalInner,
3689
3938
  {
3690
3939
  ...props,
@@ -3740,6 +3989,16 @@ function DepositModalInner({
3740
3989
  const [currentStepIndex, setCurrentStepIndex] = useState11(0);
3741
3990
  const [totalBalanceUsd, setTotalBalanceUsd] = useState11(null);
3742
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);
3743
4002
  const targetChain = getChainId(targetChainProp);
3744
4003
  const sourceChain = sourceChainProp ? getChainId(sourceChainProp) : void 0;
3745
4004
  const service = useMemo8(
@@ -3769,19 +4028,121 @@ function DepositModalInner({
3769
4028
  setCurrentStepIndex(0);
3770
4029
  }
3771
4030
  }, [isOpen]);
3772
- const handleStepChange = useCallback4(
4031
+ const handleStepChange = useCallback5(
3773
4032
  (stepIndex, onBack) => {
3774
4033
  setCurrentStepIndex(stepIndex);
3775
4034
  backHandlerRef.current = onBack;
3776
4035
  },
3777
4036
  []
3778
4037
  );
3779
- const handleTotalBalanceChange = useCallback4((balance2) => {
4038
+ const handleTotalBalanceChange = useCallback5((balance2) => {
3780
4039
  setTotalBalanceUsd(balance2);
3781
4040
  }, []);
3782
- const handleBack = useCallback4(() => {
4041
+ const handleBack = useCallback5(() => {
3783
4042
  backHandlerRef.current?.();
3784
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]);
3785
4146
  const showLogo = uiConfig?.showLogo ?? false;
3786
4147
  const showStepper = uiConfig?.showStepper ?? false;
3787
4148
  const showBackButton = uiConfig?.showBackButton ?? true;
@@ -3789,7 +4150,7 @@ function DepositModalInner({
3789
4150
  const logoUrl = branding?.logoUrl ?? "https://github.com/rhinestonewtf.png";
3790
4151
  const title = branding?.title ?? "Deposit";
3791
4152
  const canGoBack = currentStepIndex > 0 && currentStepIndex < 4 && backHandlerRef.current !== void 0;
3792
- return /* @__PURE__ */ jsx11(
4153
+ return /* @__PURE__ */ jsx12(
3793
4154
  Modal,
3794
4155
  {
3795
4156
  isOpen,
@@ -3797,23 +4158,23 @@ function DepositModalInner({
3797
4158
  className,
3798
4159
  inline,
3799
4160
  closeOnOverlayClick,
3800
- children: /* @__PURE__ */ jsxs11("div", { ref: modalRef, className: "rs-modal", children: [
3801
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header--redesigned", children: [
3802
- /* @__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(
3803
4164
  "button",
3804
4165
  {
3805
4166
  type: "button",
3806
4167
  className: "rs-modal-header-back",
3807
4168
  "aria-label": "Go back",
3808
4169
  onClick: handleBack,
3809
- children: /* @__PURE__ */ jsx11(
4170
+ children: /* @__PURE__ */ jsx12(
3810
4171
  "svg",
3811
4172
  {
3812
4173
  viewBox: "0 0 24 24",
3813
4174
  fill: "none",
3814
4175
  stroke: "currentColor",
3815
4176
  strokeWidth: "2",
3816
- children: /* @__PURE__ */ jsx11(
4177
+ children: /* @__PURE__ */ jsx12(
3817
4178
  "path",
3818
4179
  {
3819
4180
  strokeLinecap: "round",
@@ -3825,9 +4186,9 @@ function DepositModalInner({
3825
4186
  )
3826
4187
  }
3827
4188
  ) }),
3828
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-nav-center", children: [
3829
- /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-title-row", children: [
3830
- 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(
3831
4192
  "img",
3832
4193
  {
3833
4194
  src: logoUrl,
@@ -3838,20 +4199,20 @@ function DepositModalInner({
3838
4199
  }
3839
4200
  }
3840
4201
  ),
3841
- /* @__PURE__ */ jsx11("span", { className: "rs-modal-header-title", children: title }),
3842
- showStepper && currentStepIndex >= 2 && /* @__PURE__ */ jsxs11("div", { className: "rs-step-indicator", style: { marginLeft: 8 }, children: [
3843
- /* @__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(
3844
4205
  "div",
3845
4206
  {
3846
4207
  className: `rs-step-indicator-node ${currentStepIndex >= 4 ? "rs-step-indicator-node--complete" : "rs-step-indicator-node--active"}`,
3847
- children: currentStepIndex >= 4 ? /* @__PURE__ */ jsx11(
4208
+ children: currentStepIndex >= 4 ? /* @__PURE__ */ jsx12(
3848
4209
  "svg",
3849
4210
  {
3850
4211
  viewBox: "0 0 24 24",
3851
4212
  fill: "none",
3852
4213
  stroke: "currentColor",
3853
4214
  strokeWidth: "3",
3854
- children: /* @__PURE__ */ jsx11(
4215
+ children: /* @__PURE__ */ jsx12(
3855
4216
  "path",
3856
4217
  {
3857
4218
  strokeLinecap: "round",
@@ -3863,13 +4224,13 @@ function DepositModalInner({
3863
4224
  ) : "1"
3864
4225
  }
3865
4226
  ),
3866
- /* @__PURE__ */ jsx11(
4227
+ /* @__PURE__ */ jsx12(
3867
4228
  "div",
3868
4229
  {
3869
4230
  className: `rs-step-indicator-line ${currentStepIndex >= 4 ? "rs-step-indicator-line--active" : ""}`
3870
4231
  }
3871
4232
  ),
3872
- /* @__PURE__ */ jsx11(
4233
+ /* @__PURE__ */ jsx12(
3873
4234
  "div",
3874
4235
  {
3875
4236
  className: `rs-step-indicator-node ${currentStepIndex >= 4 ? "rs-step-indicator-node--active" : "rs-step-indicator-node--inactive"}`,
@@ -3878,42 +4239,71 @@ function DepositModalInner({
3878
4239
  )
3879
4240
  ] })
3880
4241
  ] }),
3881
- balance && /* @__PURE__ */ jsxs11("div", { className: "rs-modal-header-balance", children: [
3882
- /* @__PURE__ */ jsxs11("span", { children: [
4242
+ balance && /* @__PURE__ */ jsxs12("div", { className: "rs-modal-header-balance", children: [
4243
+ /* @__PURE__ */ jsxs12("span", { children: [
3883
4244
  balance.title,
3884
4245
  ":"
3885
4246
  ] }),
3886
- /* @__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) })
3887
4248
  ] })
3888
4249
  ] }),
3889
- /* @__PURE__ */ jsx11("div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ jsx11(
3890
- "button",
3891
- {
3892
- type: "button",
3893
- onClick: onClose,
3894
- className: "rs-modal-close",
3895
- "aria-label": "Close",
3896
- children: /* @__PURE__ */ jsx11(
3897
- "svg",
3898
- {
3899
- viewBox: "0 0 24 24",
3900
- fill: "none",
3901
- stroke: "currentColor",
3902
- strokeWidth: "2",
3903
- children: /* @__PURE__ */ jsx11(
3904
- "path",
3905
- {
3906
- strokeLinecap: "round",
3907
- strokeLinejoin: "round",
3908
- d: "M6 18L18 6M6 6l12 12"
3909
- }
3910
- )
3911
- }
3912
- )
3913
- }
3914
- ) })
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
+ ] })
3915
4305
  ] }),
3916
- /* @__PURE__ */ jsx11(
4306
+ /* @__PURE__ */ jsx12(
3917
4307
  DepositFlow,
3918
4308
  {
3919
4309
  dappWalletClient,
@@ -3942,15 +4332,28 @@ function DepositModalInner({
3942
4332
  allowedRoutes,
3943
4333
  onStepChange: handleStepChange,
3944
4334
  onTotalBalanceChange: handleTotalBalanceChange,
4335
+ onSmartAccountChange: showHistoryButton ? handleSmartAccountChange : void 0,
3945
4336
  onClose,
3946
4337
  onConnected,
3947
- onDepositSubmitted,
3948
- onDepositComplete,
3949
- onDepositFailed,
4338
+ onDepositSubmitted: showHistoryButton ? handleDepositSubmitted : onDepositSubmitted,
4339
+ onDepositComplete: showHistoryButton ? handleDepositComplete : onDepositComplete,
4340
+ onDepositFailed: showHistoryButton ? handleDepositFailed : onDepositFailed,
3950
4341
  onEvent,
3951
4342
  onError,
3952
4343
  debug
3953
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
+ }
3954
4357
  )
3955
4358
  ] })
3956
4359
  }