@rhinestone/deposit-modal 0.0.0-dev-20260611141108 → 0.0.0-dev-20260612113238

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.
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-NWCRGZG3.mjs";
3
+ } from "./chunk-GG2M5CRZ.mjs";
4
4
  import "./chunk-BAEB5AFZ.mjs";
5
5
  import {
6
6
  ReownWalletProvider,
7
7
  useReownWallet
8
- } from "./chunk-KAYBLYUS.mjs";
9
- import "./chunk-E25DOT37.mjs";
8
+ } from "./chunk-ZQL3RTYF.mjs";
9
+ import "./chunk-PWQZ5P6R.mjs";
10
10
  import "./chunk-TQ2AYMWS.mjs";
11
11
  import "./chunk-6YRDD462.mjs";
12
12
 
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkMMPRPDLScjs = require('./chunk-MMPRPDLS.cjs');
3
+ var _chunkVDAUVW57cjs = require('./chunk-VDAUVW57.cjs');
4
4
  require('./chunk-R5CPOBCF.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunk7KHWMSIDcjs = require('./chunk-7KHWMSID.cjs');
9
- require('./chunk-GQCEQZGF.cjs');
8
+ var _chunkROE4VOGOcjs = require('./chunk-ROE4VOGO.cjs');
9
+ require('./chunk-LYVRC3RK.cjs');
10
10
  require('./chunk-AJHFNHG3.cjs');
11
11
  require('./chunk-MILJQWPT.cjs');
12
12
 
@@ -16,7 +16,7 @@ var _react3 = require('@reown/appkit/react');
16
16
  var _react5 = require('@reown/appkit-adapter-solana/react');
17
17
  var _jsxruntime = require('react/jsx-runtime');
18
18
  function DepositModalWithReown(props) {
19
- const reown = _chunk7KHWMSIDcjs.useReownWallet.call(void 0, );
19
+ const reown = _chunkROE4VOGOcjs.useReownWallet.call(void 0, );
20
20
  const enableSolana = _nullishCoalesce(props.enableSolana, () => ( true));
21
21
  const { walletProvider: solanaWalletProvider } = _react3.useAppKitProvider.call(void 0,
22
22
  enableSolana ? "solana" : "eip155"
@@ -37,7 +37,7 @@ function DepositModalWithReown(props) {
37
37
  reown.disconnect();
38
38
  }, [reown.disconnect]);
39
39
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
40
- _chunkMMPRPDLScjs.DepositModalInner,
40
+ _chunkVDAUVW57cjs.DepositModalInner,
41
41
  {
42
42
  ...props,
43
43
  reownWallet: reownWithSolana,
@@ -48,7 +48,7 @@ function DepositModalWithReown(props) {
48
48
  }
49
49
  function DepositModalReown(props) {
50
50
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
51
- _chunk7KHWMSIDcjs.ReownWalletProvider,
51
+ _chunkROE4VOGOcjs.ReownWalletProvider,
52
52
  {
53
53
  projectId: props.reownAppId,
54
54
  theme: props.theme,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  WithdrawModalInner
3
- } from "./chunk-RVBLNCWE.mjs";
3
+ } from "./chunk-IIWW4GG4.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
- } from "./chunk-KAYBLYUS.mjs";
8
- import "./chunk-E25DOT37.mjs";
7
+ } from "./chunk-ZQL3RTYF.mjs";
8
+ import "./chunk-PWQZ5P6R.mjs";
9
9
  import "./chunk-TQ2AYMWS.mjs";
10
10
  import "./chunk-6YRDD462.mjs";
11
11
 
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk7AADPL52cjs = require('./chunk-7AADPL52.cjs');
3
+ var _chunkYR2ZP47Acjs = require('./chunk-YR2ZP47A.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunk7KHWMSIDcjs = require('./chunk-7KHWMSID.cjs');
8
- require('./chunk-GQCEQZGF.cjs');
7
+ var _chunkROE4VOGOcjs = require('./chunk-ROE4VOGO.cjs');
8
+ require('./chunk-LYVRC3RK.cjs');
9
9
  require('./chunk-AJHFNHG3.cjs');
10
10
  require('./chunk-MILJQWPT.cjs');
11
11
 
@@ -13,7 +13,7 @@ require('./chunk-MILJQWPT.cjs');
13
13
  var _react = require('react');
14
14
  var _jsxruntime = require('react/jsx-runtime');
15
15
  function WithdrawModalWithReown(props) {
16
- const reown = _chunk7KHWMSIDcjs.useReownWallet.call(void 0, );
16
+ const reown = _chunkROE4VOGOcjs.useReownWallet.call(void 0, );
17
17
  const handleConnect = _react.useCallback.call(void 0, () => {
18
18
  reown.openConnect();
19
19
  }, [reown.openConnect]);
@@ -21,7 +21,7 @@ function WithdrawModalWithReown(props) {
21
21
  reown.disconnect();
22
22
  }, [reown.disconnect]);
23
23
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
24
- _chunk7AADPL52cjs.WithdrawModalInner,
24
+ _chunkYR2ZP47Acjs.WithdrawModalInner,
25
25
  {
26
26
  ...props,
27
27
  reownWallet: reown,
@@ -31,7 +31,7 @@ function WithdrawModalWithReown(props) {
31
31
  );
32
32
  }
33
33
  function WithdrawModalReown(props) {
34
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk7KHWMSIDcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
34
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkROE4VOGOcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
35
35
  }
36
36
 
37
37
 
@@ -45,6 +45,8 @@ import {
45
45
  debugError,
46
46
  debugLog,
47
47
  failureMessageForEvent,
48
+ formatReceiveEstimate,
49
+ formatTokenAmount,
48
50
  formatUserError,
49
51
  getAssetId,
50
52
  getEventSourceDetails,
@@ -60,7 +62,7 @@ import {
60
62
  tokenFormatter,
61
63
  txRefsMatch,
62
64
  useLatestRef
63
- } from "./chunk-E25DOT37.mjs";
65
+ } from "./chunk-PWQZ5P6R.mjs";
64
66
  import {
65
67
  SAFE_ABI
66
68
  } from "./chunk-TQ2AYMWS.mjs";
@@ -876,25 +878,21 @@ function ConfirmStep({
876
878
  const targetChainIcon = getChainIcon(targetChain);
877
879
  const sourceTokenIcon = getTokenIcon(asset.symbol);
878
880
  const targetTokenIcon = getTokenIcon(targetSymbol);
879
- const formattedSendAmount = amount && !Number.isNaN(Number(amount)) ? Number(amount).toLocaleString("en-US", {
880
- minimumFractionDigits: 2,
881
- maximumFractionDigits: 6
882
- }) : "0";
883
- const formattedReceiveAmount = (() => {
884
- if (sameRoute) return formattedSendAmount;
885
- const dollarValue = Number(targetAmount);
886
- if (!Number.isFinite(dollarValue) || dollarValue <= 0)
887
- return formattedSendAmount;
888
- if (targetTokenPriceUsd !== null && targetTokenPriceUsd > 0) {
889
- const tokenAmount = dollarValue / targetTokenPriceUsd;
890
- return tokenAmount.toLocaleString("en-US", {
891
- minimumFractionDigits: 2,
892
- maximumFractionDigits: 6
893
- });
894
- }
895
- return formattedSendAmount;
881
+ const formattedSendAmount = amount && Number.isFinite(Number(amount)) ? formatTokenAmount(Number(amount), asset.symbol) ?? "0" : "0";
882
+ const receiveDisplay = (() => {
883
+ if (sameRoute) return `${formattedSendAmount} ${asset.symbol}`;
884
+ const usdValue = Number(targetAmount);
885
+ const sourceAmountUsd = Number.isFinite(usdValue) && usdValue > 0 ? usdValue : void 0;
886
+ const estimate = formatReceiveEstimate({
887
+ sourceAmount: Number.isFinite(Number(amount)) ? Number(amount) : void 0,
888
+ sourceSymbol: asset.symbol,
889
+ targetSymbol,
890
+ sourceAmountUsd,
891
+ prices: targetTokenPriceUsd !== null && targetTokenPriceUsd > 0 ? { [targetSymbol.toUpperCase()]: targetTokenPriceUsd } : {}
892
+ });
893
+ if (estimate !== void 0) return estimate;
894
+ return sourceAmountUsd !== void 0 ? `~$${sourceAmountUsd.toFixed(2)}` : `${formattedSendAmount} ${asset.symbol}`;
896
895
  })();
897
- const receiveAmount = sameRoute ? formattedReceiveAmount : `~${formattedReceiveAmount}`;
898
896
  const feeSponsored = uiConfig?.feeSponsored ?? false;
899
897
  const feeTooltip = uiConfig?.feeTooltip ?? (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.");
900
898
  const feeDisplay = quote ? `$${quote.fees.totalUsd.toFixed(2)}` : null;
@@ -1048,11 +1046,7 @@ function ConfirmStep({
1048
1046
  /* @__PURE__ */ jsxs4("div", { className: "rs-review-detail-row", children: [
1049
1047
  /* @__PURE__ */ jsx4("span", { children: "Receive" }),
1050
1048
  /* @__PURE__ */ jsxs4("span", { className: "rs-review-detail-value", children: [
1051
- /* @__PURE__ */ jsxs4("span", { children: [
1052
- receiveAmount,
1053
- " ",
1054
- targetSymbol
1055
- ] }),
1049
+ /* @__PURE__ */ jsx4("span", { children: receiveDisplay }),
1056
1050
  targetTokenIcon && /* @__PURE__ */ jsx4("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx4("img", { src: targetTokenIcon, alt: "" }) })
1057
1051
  ] })
1058
1052
  ] }),
@@ -3579,7 +3573,6 @@ function SolanaConfirmStep({
3579
3573
  const [isSubmitting, setIsSubmitting] = useState10(false);
3580
3574
  const [error, setError] = useState10(null);
3581
3575
  const targetSymbol = getTargetTokenSymbol(targetToken, targetChain);
3582
- const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
3583
3576
  const sourceChainName = getChainName("solana");
3584
3577
  const targetChainName = getChainName(targetChain);
3585
3578
  const sourceChainIcon = getChainIcon("solana");
@@ -3588,25 +3581,20 @@ function SolanaConfirmStep({
3588
3581
  const targetTokenIcon = getTokenIcon(targetSymbol);
3589
3582
  const feeSponsored = uiConfig?.feeSponsored ?? false;
3590
3583
  const feeTooltip = uiConfig?.feeTooltip ?? (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.");
3591
- const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", {
3592
- minimumFractionDigits: 2,
3593
- maximumFractionDigits: 6
3594
- }) : "0";
3595
- const formattedReceiveAmount = (() => {
3596
- if (isSameToken) return formattedAmount;
3597
- const dollarValue = Number(targetAmount);
3598
- if (!Number.isFinite(dollarValue) || dollarValue <= 0)
3599
- return formattedAmount;
3600
- if (targetTokenPriceUsd !== null && targetTokenPriceUsd > 0) {
3601
- const tokenAmount = dollarValue / targetTokenPriceUsd;
3602
- return tokenAmount.toLocaleString("en-US", {
3603
- minimumFractionDigits: 2,
3604
- maximumFractionDigits: 6
3605
- });
3606
- }
3607
- return formattedAmount;
3584
+ const formattedAmount = sourceAmount && Number.isFinite(Number(sourceAmount)) ? formatTokenAmount(Number(sourceAmount), token.symbol) ?? "0" : "0";
3585
+ const receiveDisplay = (() => {
3586
+ const usdValue = Number(targetAmount);
3587
+ const sourceAmountUsd = Number.isFinite(usdValue) && usdValue > 0 ? usdValue : void 0;
3588
+ const estimate = formatReceiveEstimate({
3589
+ sourceAmount: Number.isFinite(Number(sourceAmount)) ? Number(sourceAmount) : void 0,
3590
+ sourceSymbol: token.symbol,
3591
+ targetSymbol,
3592
+ sourceAmountUsd,
3593
+ prices: targetTokenPriceUsd !== null && targetTokenPriceUsd > 0 ? { [targetSymbol.toUpperCase()]: targetTokenPriceUsd } : {}
3594
+ });
3595
+ if (estimate !== void 0) return estimate;
3596
+ return sourceAmountUsd !== void 0 ? `~$${sourceAmountUsd.toFixed(2)}` : `${formattedAmount} ${token.symbol}`;
3608
3597
  })();
3609
- const receiveAmount = isSameToken ? formattedReceiveAmount : `~${formattedReceiveAmount}`;
3610
3598
  const handleConfirm = async () => {
3611
3599
  if (!solanaProvider) {
3612
3600
  debugLog(debug, "solana-confirm", "submit:blocked", {
@@ -3732,11 +3720,7 @@ function SolanaConfirmStep({
3732
3720
  /* @__PURE__ */ jsxs15("div", { className: "rs-review-detail-row", children: [
3733
3721
  /* @__PURE__ */ jsx17("span", { children: "Receive" }),
3734
3722
  /* @__PURE__ */ jsxs15("span", { className: "rs-review-detail-value", children: [
3735
- /* @__PURE__ */ jsxs15("span", { children: [
3736
- receiveAmount,
3737
- " ",
3738
- targetSymbol
3739
- ] }),
3723
+ /* @__PURE__ */ jsx17("span", { children: receiveDisplay }),
3740
3724
  targetTokenIcon && /* @__PURE__ */ jsx17("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx17("img", { src: targetTokenIcon, alt: "" }) })
3741
3725
  ] })
3742
3726
  ] }),
@@ -7519,7 +7503,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
7519
7503
  // src/DepositModal.tsx
7520
7504
  import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
7521
7505
  var ReownDepositInner = lazy2(
7522
- () => import("./DepositModalReown-O4VWVJYG.mjs").then((m) => ({ default: m.DepositModalReown }))
7506
+ () => import("./DepositModalReown-2CSLOVXS.mjs").then((m) => ({ default: m.DepositModalReown }))
7523
7507
  );
7524
7508
  function sortByCreatedAtDesc(items) {
7525
7509
  return [...items].sort((a, b) => {
@@ -20,14 +20,17 @@ import {
20
20
  currencyFormatter,
21
21
  debugError,
22
22
  debugLog,
23
+ formatReceiveEstimate,
24
+ formatTokenAmount,
23
25
  formatUserError,
24
26
  getAssetId,
25
27
  getPublicClient,
26
28
  isNativeAsset,
27
29
  loadSessionOwnerFromStorage,
28
30
  saveSessionOwnerToStorage,
29
- useLatestRef
30
- } from "./chunk-E25DOT37.mjs";
31
+ useLatestRef,
32
+ useTokenPrices
33
+ } from "./chunk-PWQZ5P6R.mjs";
31
34
  import {
32
35
  buildSafeTransaction,
33
36
  executeSafeErc20Transfer,
@@ -668,6 +671,7 @@ function WithdrawReviewStep({
668
671
  estimatedTime = "< 1 min",
669
672
  registrationPending = false,
670
673
  registrationError = null,
674
+ service,
671
675
  onConfirm,
672
676
  onError
673
677
  }) {
@@ -680,6 +684,16 @@ function WithdrawReviewStep({
680
684
  const targetChainIcon = getChainIcon(targetChain);
681
685
  const sourceTokenIcon = getTokenIcon(sourceSymbol);
682
686
  const targetTokenIcon = getTokenIcon(targetSymbol);
687
+ const amountNumber = Number(amount);
688
+ const formattedSendAmount = formatTokenAmount(amountNumber, sourceSymbol) ?? amount;
689
+ const prices = useTokenPrices(service, [sourceSymbol, targetSymbol]);
690
+ const receiveDisplay = formatReceiveEstimate({
691
+ sourceAmount: Number.isFinite(amountNumber) ? amountNumber : void 0,
692
+ sourceSymbol,
693
+ targetSymbol,
694
+ prices
695
+ }) ?? // No price for the target token — an honest dash beats a wrong number.
696
+ "\u2014";
683
697
  const handleConfirm = async () => {
684
698
  setError(null);
685
699
  setIsSubmitting(true);
@@ -709,7 +723,7 @@ function WithdrawReviewStep({
709
723
  /* @__PURE__ */ jsx2("span", { children: "You send" }),
710
724
  /* @__PURE__ */ jsxs2("span", { className: "rs-review-detail-value", children: [
711
725
  /* @__PURE__ */ jsxs2("span", { children: [
712
- amount,
726
+ formattedSendAmount,
713
727
  " ",
714
728
  sourceSymbol
715
729
  ] }),
@@ -730,11 +744,7 @@ function WithdrawReviewStep({
730
744
  /* @__PURE__ */ jsxs2("div", { className: "rs-review-detail-row", children: [
731
745
  /* @__PURE__ */ jsx2("span", { children: "Receive" }),
732
746
  /* @__PURE__ */ jsxs2("span", { className: "rs-review-detail-value", children: [
733
- /* @__PURE__ */ jsxs2("span", { children: [
734
- amount,
735
- " ",
736
- targetSymbol
737
- ] }),
747
+ /* @__PURE__ */ jsx2("span", { children: receiveDisplay }),
738
748
  targetTokenIcon && /* @__PURE__ */ jsx2("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: targetTokenIcon, alt: "" }) })
739
749
  ] })
740
750
  ] }),
@@ -1456,6 +1466,7 @@ function WithdrawFlow({
1456
1466
  targetToken,
1457
1467
  amount: storeApi.getState().amount ?? "0",
1458
1468
  recipient: storeApi.getState().recipient ?? recipientForRegistration ?? "0x0",
1469
+ service,
1459
1470
  registrationPending: registration.kind === "pending" || registration.kind === "stale",
1460
1471
  registrationError: registration.kind === "failed" ? registration.error : null,
1461
1472
  onConfirm: handleReviewConfirm,
@@ -1471,7 +1482,9 @@ function WithdrawFlow({
1471
1482
  sourceToken,
1472
1483
  targetChain,
1473
1484
  targetToken,
1474
- amount: storeApi.getState().amount ?? "0",
1485
+ amount: toBaseUnits(storeApi.getState().amount ?? "0", asset.decimals),
1486
+ sourceSymbol: asset.symbol,
1487
+ sourceDecimals: asset.decimals,
1475
1488
  directTransfer: isSameRoute,
1476
1489
  service,
1477
1490
  flowLabel: "withdraw",
@@ -1485,6 +1498,13 @@ function WithdrawFlow({
1485
1498
  )
1486
1499
  ] });
1487
1500
  }
1501
+ function toBaseUnits(amount, decimals) {
1502
+ try {
1503
+ return parseUnits2(amount, decimals).toString();
1504
+ } catch {
1505
+ return "0";
1506
+ }
1507
+ }
1488
1508
  function deriveStepView(step, _registration) {
1489
1509
  if (step === "review") return "review";
1490
1510
  if (step === "processing" || step === "complete" || step === "failed") {
@@ -1496,7 +1516,7 @@ function deriveStepView(step, _registration) {
1496
1516
  // src/WithdrawModal.tsx
1497
1517
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1498
1518
  var ReownWithdrawInner = lazy(
1499
- () => import("./WithdrawModalReown-GLOHYSUG.mjs").then((m) => ({
1519
+ () => import("./WithdrawModalReown-AZVFB573.mjs").then((m) => ({
1500
1520
  default: m.WithdrawModalReown
1501
1521
  }))
1502
1522
  );