@rhinestone/deposit-modal 0.2.1 → 0.2.3

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.
@@ -28,7 +28,7 @@ import {
28
28
  tokenFormatter,
29
29
  txRefsMatch,
30
30
  useLatestRef
31
- } from "./chunk-3CRG5NPG.mjs";
31
+ } from "./chunk-JRNGXHWQ.mjs";
32
32
  import {
33
33
  DEFAULT_BACKEND_URL,
34
34
  DEFAULT_SIGNER_ADDRESS,
@@ -1451,6 +1451,7 @@ var txLinkIcon = /* @__PURE__ */ jsx7(
1451
1451
  function DepositNotification({
1452
1452
  deposit,
1453
1453
  smartAccount,
1454
+ solanaDepositAddress,
1454
1455
  targetChain,
1455
1456
  targetToken,
1456
1457
  waitForFinalTx,
@@ -1521,7 +1522,8 @@ function DepositNotification({
1521
1522
  let isMounted = true;
1522
1523
  async function pollStatus() {
1523
1524
  try {
1524
- const data = await service.fetchStatus(smartAccount, txHash);
1525
+ const account = sourceChain === "solana" && solanaDepositAddress ? solanaDepositAddress : smartAccount;
1526
+ const data = await service.fetchStatus(account, txHash);
1525
1527
  if (!isMounted) return;
1526
1528
  const lastEvent = data.lastEvent;
1527
1529
  const eventForTx = isEventForTx(lastEvent, txHash) ? lastEvent : void 0;
@@ -1582,6 +1584,8 @@ function DepositNotification({
1582
1584
  handleFailed,
1583
1585
  service,
1584
1586
  smartAccount,
1587
+ solanaDepositAddress,
1588
+ sourceChain,
1585
1589
  status,
1586
1590
  txHash
1587
1591
  ]);
@@ -2377,9 +2381,29 @@ function DepositAddressStep({
2377
2381
  /* @__PURE__ */ jsx8("div", { className: "rs-deposit-address-qr", children: /* @__PURE__ */ jsx8(QRCode, { value: displayAddress, size: 150, iconSrc: qrIconSrc }) }),
2378
2382
  /* @__PURE__ */ jsxs7("div", { className: "rs-deposit-address-info", children: [
2379
2383
  /* @__PURE__ */ jsxs7("div", { className: "rs-deposit-address-label", children: [
2380
- "Your ",
2381
- isSolana ? "Solana" : "EVM",
2382
- " deposit address"
2384
+ /* @__PURE__ */ jsx8("span", { children: "Your deposit address" }),
2385
+ /* @__PURE__ */ jsx8(Tooltip, { content: "Send any accepted token to this address and it will auto swap to your account.", children: /* @__PURE__ */ jsxs7(
2386
+ "svg",
2387
+ {
2388
+ className: "rs-deposit-address-label-icon",
2389
+ viewBox: "0 0 24 24",
2390
+ fill: "none",
2391
+ stroke: "currentColor",
2392
+ strokeWidth: "2",
2393
+ "aria-hidden": "true",
2394
+ children: [
2395
+ /* @__PURE__ */ jsx8("circle", { cx: "12", cy: "12", r: "9" }),
2396
+ /* @__PURE__ */ jsx8(
2397
+ "path",
2398
+ {
2399
+ strokeLinecap: "round",
2400
+ strokeLinejoin: "round",
2401
+ d: "M12 8h.01M11 12h1v4h1"
2402
+ }
2403
+ )
2404
+ ]
2405
+ }
2406
+ ) })
2383
2407
  ] }),
2384
2408
  /* @__PURE__ */ jsx8("div", { className: "rs-deposit-address-value", children: displayAddress }),
2385
2409
  /* @__PURE__ */ jsxs7(
@@ -2544,6 +2568,7 @@ function DepositAddressStep({
2544
2568
  {
2545
2569
  deposit,
2546
2570
  smartAccount,
2571
+ solanaDepositAddress,
2547
2572
  targetChain,
2548
2573
  targetToken,
2549
2574
  waitForFinalTx,
@@ -3755,7 +3780,7 @@ function DepositFlow({
3755
3780
  setStep({ type: "setup" });
3756
3781
  }, []);
3757
3782
  const handleNewDeposit = useCallback5(() => {
3758
- onSmartAccountChangeRef.current?.(null);
3783
+ onSmartAccountChangeRef.current?.({ evm: null, solana: null });
3759
3784
  setFlowMode(null);
3760
3785
  setStep({ type: "setup" });
3761
3786
  setIsConnectSelectionConfirmed(false);
@@ -3769,7 +3794,10 @@ function DepositFlow({
3769
3794
  hasSolanaDepositAddress: Boolean(solanaDepositAddress),
3770
3795
  flowMode: isDepositAddressMode ? "deposit-address" : isSolanaWalletMode ? "solana-wallet" : "wallet"
3771
3796
  });
3772
- onSmartAccountChangeRef.current?.(smartAccount);
3797
+ onSmartAccountChangeRef.current?.({
3798
+ evm: smartAccount,
3799
+ solana: solanaDepositAddress ?? null
3800
+ });
3773
3801
  if (isDepositAddressMode) {
3774
3802
  setStep({
3775
3803
  type: "deposit-address",
@@ -3866,6 +3894,7 @@ function DepositFlow({
3866
3894
  return {
3867
3895
  type: "processing",
3868
3896
  smartAccount: prev.smartAccount,
3897
+ solanaDepositAddress: prev.solanaDepositAddress,
3869
3898
  txHash,
3870
3899
  sourceChain: "solana",
3871
3900
  sourceToken: prev.token.mint,
@@ -4253,6 +4282,7 @@ function DepositFlow({
4253
4282
  ProcessingStep,
4254
4283
  {
4255
4284
  smartAccount: step.smartAccount,
4285
+ solanaDepositAddress: step.solanaDepositAddress,
4256
4286
  txHash: step.txHash,
4257
4287
  sourceChain: step.sourceChain,
4258
4288
  sourceToken: step.sourceToken,
@@ -4377,6 +4407,7 @@ function DepositFlow({
4377
4407
  ProcessingStep,
4378
4408
  {
4379
4409
  smartAccount: step.smartAccount,
4410
+ solanaDepositAddress: step.solanaDepositAddress,
4380
4411
  txHash: step.txHash,
4381
4412
  sourceChain: step.sourceChain,
4382
4413
  sourceToken: step.sourceToken,
@@ -4669,8 +4700,15 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
4669
4700
  // src/DepositModal.tsx
4670
4701
  import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
4671
4702
  var ReownDepositInner = lazy(
4672
- () => import("./DepositModalReown-IIEXOTKU.mjs").then((m) => ({ default: m.DepositModalReown }))
4703
+ () => import("./DepositModalReown-SJHEU6RQ.mjs").then((m) => ({ default: m.DepositModalReown }))
4673
4704
  );
4705
+ function sortByCreatedAtDesc(items) {
4706
+ return [...items].sort((a, b) => {
4707
+ const at = a.createdAt ? Date.parse(a.createdAt) : 0;
4708
+ const bt = b.createdAt ? Date.parse(b.createdAt) : 0;
4709
+ return bt - at;
4710
+ });
4711
+ }
4674
4712
  function DepositModal(props) {
4675
4713
  const needsReown = !!props.reownAppId;
4676
4714
  const hasDappWalletClientProp = Object.prototype.hasOwnProperty.call(
@@ -4745,13 +4783,18 @@ function DepositModalInner({
4745
4783
  const [totalBalanceUsd, setTotalBalanceUsd] = useState12(null);
4746
4784
  const backHandlerRef = useRef8(void 0);
4747
4785
  const showHistoryButton = uiConfig?.showHistoryButton ?? false;
4748
- const [activeSmartAccount, setActiveSmartAccount] = useState12(null);
4786
+ const [activeEvmAccount, setActiveEvmAccount] = useState12(null);
4787
+ const [activeSolanaAccount, setActiveSolanaAccount] = useState12(
4788
+ null
4789
+ );
4749
4790
  const [historyOpen, setHistoryOpen] = useState12(false);
4750
4791
  const [historyDeposits, setHistoryDeposits] = useState12([]);
4751
- const [historyNextCursor, setHistoryNextCursor] = useState12(null);
4792
+ const [hasMoreHistory, setHasMoreHistory] = useState12(false);
4752
4793
  const [historyLoading, setHistoryLoading] = useState12(false);
4753
4794
  const [historyLoadingMore, setHistoryLoadingMore] = useState12(false);
4754
4795
  const [historyError, setHistoryError] = useState12(null);
4796
+ const evmCursorRef = useRef8(null);
4797
+ const solanaCursorRef = useRef8(null);
4755
4798
  const historyStaleRef = useRef8(false);
4756
4799
  const historyLoadedRef = useRef8(false);
4757
4800
  const targetChain = getChainId(targetChainProp);
@@ -4795,18 +4838,19 @@ function DepositModalInner({
4795
4838
  backHandlerRef.current?.();
4796
4839
  }, []);
4797
4840
  const handleSmartAccountChange = useCallback7(
4798
- (account) => {
4799
- setActiveSmartAccount(account);
4800
- if (!account) {
4841
+ ({ evm, solana }) => {
4842
+ setActiveEvmAccount(evm);
4843
+ setActiveSolanaAccount(solana);
4844
+ if (!evm && !solana) {
4801
4845
  historyStaleRef.current = true;
4802
4846
  }
4803
4847
  },
4804
4848
  []
4805
4849
  );
4806
4850
  const fetchHistory = useCallback7(
4807
- async (cursor) => {
4808
- if (!activeSmartAccount) return;
4809
- const isInitial = !cursor;
4851
+ async (mode = "initial") => {
4852
+ if (!activeEvmAccount && !activeSolanaAccount) return;
4853
+ const isInitial = mode === "initial";
4810
4854
  if (isInitial) {
4811
4855
  setHistoryLoading(true);
4812
4856
  } else {
@@ -4814,17 +4858,54 @@ function DepositModalInner({
4814
4858
  }
4815
4859
  setHistoryError(null);
4816
4860
  try {
4817
- const result = await service.fetchDepositHistory({
4818
- account: activeSmartAccount,
4819
- limit: 20,
4820
- cursor
4821
- });
4861
+ const evmCursor = isInitial ? null : evmCursorRef.current;
4862
+ const solanaCursor = isInitial ? null : solanaCursorRef.current;
4863
+ const requests = [];
4864
+ if (activeEvmAccount && (isInitial || evmCursor)) {
4865
+ requests.push(
4866
+ service.fetchDepositHistory({
4867
+ account: activeEvmAccount,
4868
+ limit: 20,
4869
+ cursor: evmCursor ?? void 0
4870
+ }).then((r) => ({
4871
+ deposits: r.deposits,
4872
+ nextCursor: r.nextCursor ?? null,
4873
+ source: "evm"
4874
+ }))
4875
+ );
4876
+ }
4877
+ if (activeSolanaAccount && (isInitial || solanaCursor)) {
4878
+ requests.push(
4879
+ service.fetchDepositHistory({
4880
+ account: activeSolanaAccount,
4881
+ limit: 20,
4882
+ cursor: solanaCursor ?? void 0
4883
+ }).then((r) => ({
4884
+ deposits: r.deposits,
4885
+ nextCursor: r.nextCursor ?? null,
4886
+ source: "solana"
4887
+ }))
4888
+ );
4889
+ }
4890
+ const results = await Promise.all(requests);
4891
+ let nextEvm = isInitial ? null : evmCursor;
4892
+ let nextSolana = isInitial ? null : solanaCursor;
4893
+ const incoming = [];
4894
+ for (const r of results) {
4895
+ incoming.push(...r.deposits);
4896
+ if (r.source === "evm") nextEvm = r.nextCursor;
4897
+ else nextSolana = r.nextCursor;
4898
+ }
4822
4899
  if (isInitial) {
4823
- setHistoryDeposits(result.deposits);
4900
+ setHistoryDeposits(sortByCreatedAtDesc(incoming));
4824
4901
  } else {
4825
- setHistoryDeposits((prev) => [...prev, ...result.deposits]);
4902
+ setHistoryDeposits(
4903
+ (prev) => sortByCreatedAtDesc([...prev, ...incoming])
4904
+ );
4826
4905
  }
4827
- setHistoryNextCursor(result.nextCursor ?? null);
4906
+ evmCursorRef.current = nextEvm;
4907
+ solanaCursorRef.current = nextSolana;
4908
+ setHasMoreHistory(Boolean(nextEvm || nextSolana));
4828
4909
  historyStaleRef.current = false;
4829
4910
  historyLoadedRef.current = true;
4830
4911
  } catch (err) {
@@ -4839,26 +4920,24 @@ function DepositModalInner({
4839
4920
  }
4840
4921
  }
4841
4922
  },
4842
- [activeSmartAccount, service]
4923
+ [activeEvmAccount, activeSolanaAccount, service]
4843
4924
  );
4844
4925
  const handleHistoryOpen = useCallback7(() => {
4845
4926
  setHistoryOpen(true);
4846
4927
  if (!historyLoadedRef.current || historyStaleRef.current) {
4847
- fetchHistory();
4928
+ fetchHistory("initial");
4848
4929
  }
4849
4930
  }, [fetchHistory]);
4850
4931
  const handleHistoryClose = useCallback7(() => {
4851
4932
  setHistoryOpen(false);
4852
4933
  }, []);
4853
4934
  const handleHistoryLoadMore = useCallback7(() => {
4854
- if (historyNextCursor) {
4855
- fetchHistory(historyNextCursor);
4856
- }
4857
- }, [fetchHistory, historyNextCursor]);
4935
+ fetchHistory("more");
4936
+ }, [fetchHistory]);
4858
4937
  const markHistoryStale = useCallback7(() => {
4859
4938
  historyStaleRef.current = true;
4860
4939
  if (historyOpen) {
4861
- fetchHistory();
4940
+ fetchHistory("initial");
4862
4941
  }
4863
4942
  }, [historyOpen, fetchHistory]);
4864
4943
  const onDepositSubmittedRef = useLatestRef(onDepositSubmitted);
@@ -4889,9 +4968,12 @@ function DepositModalInner({
4889
4968
  if (!isOpen) {
4890
4969
  setHistoryOpen(false);
4891
4970
  setHistoryDeposits([]);
4892
- setHistoryNextCursor(null);
4971
+ setHasMoreHistory(false);
4893
4972
  setHistoryError(null);
4894
- setActiveSmartAccount(null);
4973
+ setActiveEvmAccount(null);
4974
+ setActiveSolanaAccount(null);
4975
+ evmCursorRef.current = null;
4976
+ solanaCursorRef.current = null;
4895
4977
  historyStaleRef.current = false;
4896
4978
  historyLoadedRef.current = false;
4897
4979
  }
@@ -5008,7 +5090,7 @@ function DepositModalInner({
5008
5090
  className: "rs-modal-header-history",
5009
5091
  "aria-label": "Deposit history",
5010
5092
  onClick: handleHistoryOpen,
5011
- disabled: !activeSmartAccount,
5093
+ disabled: !activeEvmAccount && !activeSolanaAccount,
5012
5094
  children: /* @__PURE__ */ jsx14(
5013
5095
  "svg",
5014
5096
  {
@@ -5104,7 +5186,7 @@ function DepositModalInner({
5104
5186
  deposits: historyDeposits,
5105
5187
  isLoading: historyLoading,
5106
5188
  error: historyError,
5107
- hasMore: Boolean(historyNextCursor),
5189
+ hasMore: hasMoreHistory,
5108
5190
  isLoadingMore: historyLoadingMore,
5109
5191
  onLoadMore: handleHistoryLoadMore,
5110
5192
  onClose: handleHistoryClose
@@ -1680,6 +1680,7 @@ function getCurrentPhaseId(state, phaseTimings, isEarlyComplete) {
1680
1680
  }
1681
1681
  function ProcessingStep({
1682
1682
  smartAccount,
1683
+ solanaDepositAddress,
1683
1684
  txHash,
1684
1685
  sourceChain,
1685
1686
  sourceToken,
@@ -1792,12 +1793,13 @@ function ProcessingStep({
1792
1793
  let isMounted = true;
1793
1794
  async function pollStatus() {
1794
1795
  try {
1796
+ const account = sourceChain === "solana" && solanaDepositAddress ? solanaDepositAddress : smartAccount;
1795
1797
  debugLog(debug, "processing", "poll:request", {
1796
- smartAccount,
1798
+ account,
1797
1799
  txHash,
1798
1800
  intervalMs: pollIntervalRef.current
1799
1801
  });
1800
- const data = await service.fetchStatus(smartAccount, txHash);
1802
+ const data = await service.fetchStatus(account, txHash);
1801
1803
  const lastEvent2 = data.lastEvent;
1802
1804
  const eventMatchesTx = isEventForTx(lastEvent2, txHash);
1803
1805
  const eventForCurrentTx = eventMatchesTx ? lastEvent2 : void 0;
@@ -1949,6 +1951,8 @@ function ProcessingStep({
1949
1951
  processingContextRef,
1950
1952
  service,
1951
1953
  smartAccount,
1954
+ solanaDepositAddress,
1955
+ sourceChain,
1952
1956
  state.type,
1953
1957
  txHash
1954
1958
  ]);
@@ -21,7 +21,7 @@ import {
21
21
  saveSessionOwnerToStorage,
22
22
  toEvmCaip2,
23
23
  useLatestRef
24
- } from "./chunk-3CRG5NPG.mjs";
24
+ } from "./chunk-JRNGXHWQ.mjs";
25
25
  import {
26
26
  DEFAULT_BACKEND_URL,
27
27
  DEFAULT_SIGNER_ADDRESS,
@@ -1485,7 +1485,7 @@ function WithdrawFlow({
1485
1485
  // src/WithdrawModal.tsx
1486
1486
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1487
1487
  var ReownWithdrawInner = lazy(
1488
- () => import("./WithdrawModalReown-URF6AERQ.mjs").then((m) => ({
1488
+ () => import("./WithdrawModalReown-RUJZCQ4C.mjs").then((m) => ({
1489
1489
  default: m.WithdrawModalReown
1490
1490
  }))
1491
1491
  );
@@ -1680,6 +1680,7 @@ function getCurrentPhaseId(state, phaseTimings, isEarlyComplete) {
1680
1680
  }
1681
1681
  function ProcessingStep({
1682
1682
  smartAccount,
1683
+ solanaDepositAddress,
1683
1684
  txHash,
1684
1685
  sourceChain,
1685
1686
  sourceToken,
@@ -1792,12 +1793,13 @@ function ProcessingStep({
1792
1793
  let isMounted = true;
1793
1794
  async function pollStatus() {
1794
1795
  try {
1796
+ const account = sourceChain === "solana" && solanaDepositAddress ? solanaDepositAddress : smartAccount;
1795
1797
  debugLog(debug, "processing", "poll:request", {
1796
- smartAccount,
1798
+ account,
1797
1799
  txHash,
1798
1800
  intervalMs: pollIntervalRef.current
1799
1801
  });
1800
- const data = await service.fetchStatus(smartAccount, txHash);
1802
+ const data = await service.fetchStatus(account, txHash);
1801
1803
  const lastEvent2 = data.lastEvent;
1802
1804
  const eventMatchesTx = isEventForTx(lastEvent2, txHash);
1803
1805
  const eventForCurrentTx = eventMatchesTx ? lastEvent2 : void 0;
@@ -1949,6 +1951,8 @@ function ProcessingStep({
1949
1951
  processingContextRef,
1950
1952
  service,
1951
1953
  smartAccount,
1954
+ solanaDepositAddress,
1955
+ sourceChain,
1952
1956
  state.type,
1953
1957
  txHash
1954
1958
  ]);