@rhinestone/deposit-modal 0.4.1 → 0.4.2

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.
@@ -3059,6 +3059,23 @@ function estimateReceiveAmount(params) {
3059
3059
  if (targetPrice === void 0) return void 0;
3060
3060
  return usdValue / targetPrice;
3061
3061
  }
3062
+ function formatQuotedReceive(output, fallbackSymbol) {
3063
+ if (output.decimals === null) return void 0;
3064
+ let raw;
3065
+ try {
3066
+ raw = BigInt(output.amount);
3067
+ } catch {
3068
+ return void 0;
3069
+ }
3070
+ if (raw <= 0n) return void 0;
3071
+ const symbol = output.symbol ?? fallbackSymbol;
3072
+ const formatted = formatRawTokenAmount(raw, {
3073
+ symbol,
3074
+ decimals: output.decimals
3075
+ });
3076
+ if (formatted === void 0) return void 0;
3077
+ return `~${formatted} ${symbol}`;
3078
+ }
3062
3079
  function formatReceiveEstimate(params) {
3063
3080
  const estimate = estimateReceiveAmount(params);
3064
3081
  if (estimate === void 0) return void 0;
@@ -4014,6 +4031,7 @@ export {
4014
4031
  formatUserError,
4015
4032
  Tooltip,
4016
4033
  formatTokenAmount,
4034
+ formatQuotedReceive,
4017
4035
  formatReceiveEstimate,
4018
4036
  getEventTxHash,
4019
4037
  getEventSourceDetails,
@@ -30,7 +30,7 @@ import {
30
30
  saveSessionOwnerToStorage,
31
31
  useLatestRef,
32
32
  useTokenPrices
33
- } from "./chunk-A33QFRKD.mjs";
33
+ } from "./chunk-7EQQD7B4.mjs";
34
34
  import {
35
35
  buildSafeTransaction,
36
36
  executeSafeErc20Transfer,
@@ -1564,7 +1564,7 @@ function deriveStepView(step, _registration) {
1564
1564
  // src/WithdrawModal.tsx
1565
1565
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1566
1566
  var ReownWithdrawInner = lazy(
1567
- () => import("./WithdrawModalReown-G7EM6HXO.mjs").then((m) => ({
1567
+ () => import("./WithdrawModalReown-L4SWLONE.mjs").then((m) => ({
1568
1568
  default: m.WithdrawModalReown
1569
1569
  }))
1570
1570
  );
@@ -45,6 +45,7 @@ import {
45
45
  debugError,
46
46
  debugLog,
47
47
  failureMessageForEvent,
48
+ formatQuotedReceive,
48
49
  formatReceiveEstimate,
49
50
  formatTokenAmount,
50
51
  formatUserError,
@@ -63,7 +64,7 @@ import {
63
64
  tokenFormatter,
64
65
  txRefsMatch,
65
66
  useLatestRef
66
- } from "./chunk-A33QFRKD.mjs";
67
+ } from "./chunk-7EQQD7B4.mjs";
67
68
  import {
68
69
  SAFE_ABI
69
70
  } from "./chunk-F7P4MV72.mjs";
@@ -119,7 +120,6 @@ import {
119
120
  useLayoutEffect as useLayoutEffect2,
120
121
  useRef as useRef8
121
122
  } from "react";
122
- import { formatUnits as formatUnits7 } from "viem";
123
123
 
124
124
  // src/components/steps/AssetSelectStep.tsx
125
125
  import { useEffect, useMemo, useState } from "react";
@@ -134,7 +134,6 @@ function AssetSelectStep({
134
134
  service,
135
135
  onContinue,
136
136
  onTotalBalanceComputed,
137
- onAssetsLoaded,
138
137
  onDisconnect
139
138
  }) {
140
139
  const [assets, setAssets] = useState([]);
@@ -149,7 +148,6 @@ function AssetSelectStep({
149
148
  });
150
149
  }, [defaultSourceChain, defaultSourceToken]);
151
150
  const onTotalBalanceComputedRef = useLatestRef(onTotalBalanceComputed);
152
- const onAssetsLoadedRef = useLatestRef(onAssetsLoaded);
153
151
  useEffect(() => {
154
152
  let active = true;
155
153
  function emitAssetsUpdate(currentAssets) {
@@ -158,7 +156,6 @@ function AssetSelectStep({
158
156
  0
159
157
  );
160
158
  onTotalBalanceComputedRef.current?.(total);
161
- if (currentAssets.length > 0) onAssetsLoadedRef.current?.(currentAssets);
162
159
  }
163
160
  async function loadPortfolio() {
164
161
  if (!address) {
@@ -202,7 +199,7 @@ function AssetSelectStep({
202
199
  return () => {
203
200
  active = false;
204
201
  };
205
- }, [address, publicClient, service, onTotalBalanceComputedRef, onAssetsLoadedRef]);
202
+ }, [address, publicClient, service, onTotalBalanceComputedRef]);
206
203
  useEffect(() => {
207
204
  if (!defaultAssetId || selectedAssetId) return;
208
205
  if (assets.some((asset) => asset.id === defaultAssetId)) {
@@ -706,32 +703,34 @@ function AmountStep({
706
703
  }
707
704
  setError(null);
708
705
  onCtaClick?.("continue");
709
- setIsCheckingLiquidity(true);
710
706
  let liquidityWarning;
711
- try {
712
- const liquidity = await service.checkLiquidity({
713
- sourceChainId: liquiditySource?.chainId ?? asset.chainId,
714
- sourceToken: liquiditySource?.token ?? asset.token,
715
- destinationChainId: targetChain,
716
- destinationToken: targetToken,
717
- amount: amountInUnits.toString()
718
- });
719
- if (liquidity.unlimited || liquidity.hasLiquidity) {
720
- liquidityWarning = void 0;
721
- } else if (liquidity.maxAmount !== null) {
722
- liquidityWarning = {
723
- kind: "low",
724
- maxAmount: liquidity.maxAmount,
725
- decimals: liquidity.decimals,
726
- symbol: liquidity.symbol
727
- };
728
- } else {
729
- liquidityWarning = { kind: "unavailable" };
707
+ if (uiConfig?.checkLiquidity) {
708
+ setIsCheckingLiquidity(true);
709
+ try {
710
+ const liquidity = await service.checkLiquidity({
711
+ sourceChainId: liquiditySource?.chainId ?? asset.chainId,
712
+ sourceToken: liquiditySource?.token ?? asset.token,
713
+ destinationChainId: targetChain,
714
+ destinationToken: targetToken,
715
+ amount: amountInUnits.toString()
716
+ });
717
+ if (liquidity.unlimited || liquidity.hasLiquidity) {
718
+ liquidityWarning = void 0;
719
+ } else if (liquidity.maxAmount !== null) {
720
+ liquidityWarning = {
721
+ kind: "low",
722
+ maxAmount: liquidity.maxAmount,
723
+ decimals: liquidity.decimals,
724
+ symbol: liquidity.symbol
725
+ };
726
+ } else {
727
+ liquidityWarning = { kind: "unavailable" };
728
+ }
729
+ } catch {
730
+ liquidityWarning = { kind: "check-failed" };
731
+ } finally {
732
+ setIsCheckingLiquidity(false);
730
733
  }
731
- } catch {
732
- liquidityWarning = { kind: "check-failed" };
733
- } finally {
734
- setIsCheckingLiquidity(false);
735
734
  }
736
735
  onContinue(
737
736
  sourceAmount.toString(),
@@ -882,6 +881,10 @@ function ConfirmStep({
882
881
  const formattedSendAmount = amount && Number.isFinite(Number(amount)) ? formatTokenAmount(Number(amount), asset.symbol) ?? "0" : "0";
883
882
  const receiveDisplay = (() => {
884
883
  if (sameRoute) return `${formattedSendAmount} ${asset.symbol}`;
884
+ if (quote) {
885
+ const quoted = formatQuotedReceive(quote.output, targetSymbol);
886
+ if (quoted !== void 0) return quoted;
887
+ }
885
888
  const usdValue = Number(targetAmount);
886
889
  const sourceAmountUsd = Number.isFinite(usdValue) && usdValue > 0 ? usdValue : void 0;
887
890
  const estimate = formatReceiveEstimate({
@@ -892,7 +895,7 @@ function ConfirmStep({
892
895
  prices: targetTokenPriceUsd !== null && targetTokenPriceUsd > 0 ? { [targetSymbol.toUpperCase()]: targetTokenPriceUsd } : {}
893
896
  });
894
897
  if (estimate !== void 0) return estimate;
895
- return sourceAmountUsd !== void 0 ? `~$${sourceAmountUsd.toFixed(2)}` : `${formattedSendAmount} ${asset.symbol}`;
898
+ return targetSymbol;
896
899
  })();
897
900
  const feeSponsored = uiConfig?.feeSponsored ?? false;
898
901
  const feeTooltip = uiConfig?.feeTooltip ?? (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.");
@@ -3480,7 +3483,7 @@ function SolanaConfirmStep({
3480
3483
  prices: targetTokenPriceUsd !== null && targetTokenPriceUsd > 0 ? { [targetSymbol.toUpperCase()]: targetTokenPriceUsd } : {}
3481
3484
  });
3482
3485
  if (estimate !== void 0) return estimate;
3483
- return sourceAmountUsd !== void 0 ? `~$${sourceAmountUsd.toFixed(2)}` : `${formattedAmount} ${token.symbol}`;
3486
+ return targetSymbol;
3484
3487
  })();
3485
3488
  const handleConfirm = async () => {
3486
3489
  if (!solanaProvider) {
@@ -5370,7 +5373,6 @@ function DepositFlow({
5370
5373
  const isConnectSelectionConfirmed = flowSlice.isConnectSelectionConfirmed;
5371
5374
  const selectedWalletId = useDepositStore(selectedWalletIdSelector);
5372
5375
  const [totalBalanceUsd, setTotalBalanceUsd] = useState11(0);
5373
- const portfolioAssetsRef = useRef8([]);
5374
5376
  const stableWalletSignerRef = useRef8(null);
5375
5377
  const stableWalletSelectionKeyRef = useRef8(null);
5376
5378
  const logFlow = useCallback7(
@@ -5385,24 +5387,6 @@ function DepositFlow({
5385
5387
  },
5386
5388
  [debug]
5387
5389
  );
5388
- const handleAssetsLoaded = useCallback7((assets) => {
5389
- portfolioAssetsRef.current = assets;
5390
- }, []);
5391
- const getTokenPriceUsd = useCallback7((symbol) => {
5392
- const sym = symbol.toLowerCase();
5393
- for (const asset of portfolioAssetsRef.current) {
5394
- if (asset.symbol.toLowerCase() === sym && asset.balanceUsd && asset.balance) {
5395
- try {
5396
- const balanceUnits = Number(
5397
- formatUnits7(BigInt(asset.balance), asset.decimals)
5398
- );
5399
- if (balanceUnits > 0) return asset.balanceUsd / balanceUnits;
5400
- } catch {
5401
- }
5402
- }
5403
- }
5404
- return null;
5405
- }, []);
5406
5390
  const dappSwitchChain = useMemo7(() => {
5407
5391
  if (!dappWalletClient?.switchChain) return void 0;
5408
5392
  return async (chainId) => {
@@ -5714,14 +5698,10 @@ function DepositFlow({
5714
5698
  );
5715
5699
  const step = effectiveStep;
5716
5700
  const handleBack = useCallback7(() => {
5717
- const stepBeforeBack = storeApi.getState().flow.step;
5718
5701
  storeApi.dispatch({
5719
5702
  type: "back/requested",
5720
5703
  hasWalletOptions: hasWalletOptions || Boolean(reownWallet)
5721
5704
  });
5722
- if (stepBeforeBack === "deposit-address" || stepBeforeBack === "select-asset" || stepBeforeBack === "solana-token-select") {
5723
- portfolioAssetsRef.current = [];
5724
- }
5725
5705
  }, [storeApi, hasWalletOptions, reownWallet]);
5726
5706
  const canGoBackFromHere = effectiveStep.type === "deposit-address" || effectiveStep.type === "solana-token-select" || effectiveStep.type === "solana-amount" || effectiveStep.type === "solana-confirm" || effectiveStep.type === "amount" || effectiveStep.type === "confirm" || // Escape hatch from a slow or stuck pre-routed resolve. Mode-gated so
5727
5707
  // the chevron doesn't linger if a disconnect cleared the mode out from
@@ -6120,7 +6100,6 @@ function DepositFlow({
6120
6100
  solana: null
6121
6101
  });
6122
6102
  storeApi.dispatch({ type: "flow/reset" });
6123
- portfolioAssetsRef.current = [];
6124
6103
  stableWalletSignerRef.current = null;
6125
6104
  stableWalletSelectionKeyRef.current = null;
6126
6105
  }, [onLifecycleRef, storeApi]);
@@ -6294,7 +6273,7 @@ function DepositFlow({
6294
6273
  (token, sourceAmount, inputAmountUsd) => {
6295
6274
  const targetSym = getTargetTokenSymbol(targetToken, targetChain);
6296
6275
  const isTargetStable = isStablecoinSymbol(targetSym);
6297
- const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym) ?? targetMarketPriceRef.current;
6276
+ const targetTokenPriceUsd = isTargetStable ? 1 : targetMarketPriceRef.current;
6298
6277
  logFlow("solana:amount:continue", {
6299
6278
  token: token.symbol,
6300
6279
  sourceAmount,
@@ -6310,7 +6289,7 @@ function DepositFlow({
6310
6289
  targetTokenPriceUsd
6311
6290
  });
6312
6291
  },
6313
- [targetToken, targetChain, getTokenPriceUsd, logFlow, storeApi]
6292
+ [targetToken, targetChain, logFlow, storeApi]
6314
6293
  );
6315
6294
  const handleSolanaConfirmed = useCallback7(
6316
6295
  (txHash, amountUnits) => {
@@ -6371,7 +6350,7 @@ function DepositFlow({
6371
6350
  if (entry.status !== "ready") return;
6372
6351
  const targetSym = getTargetTokenSymbol(targetToken, targetChain);
6373
6352
  const isTargetStable = isStablecoinSymbol(targetSym);
6374
- const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym) ?? targetMarketPriceRef.current;
6353
+ const targetTokenPriceUsd = isTargetStable ? 1 : targetMarketPriceRef.current;
6375
6354
  storeApi.dispatch({
6376
6355
  type: "amount/entered",
6377
6356
  amount,
@@ -6381,7 +6360,7 @@ function DepositFlow({
6381
6360
  liquidityWarning
6382
6361
  });
6383
6362
  },
6384
- [targetToken, targetChain, getTokenPriceUsd, storeApi, activeOwner]
6363
+ [targetToken, targetChain, storeApi, activeOwner]
6385
6364
  );
6386
6365
  const handleDepositSubmitted = useCallback7(
6387
6366
  (txHash, chainId, amount, token) => {
@@ -6942,7 +6921,6 @@ function DepositFlow({
6942
6921
  service,
6943
6922
  onContinue: handleAssetContinue,
6944
6923
  onTotalBalanceComputed: handleTotalBalanceComputed,
6945
- onAssetsLoaded: handleAssetsLoaded,
6946
6924
  onDisconnect: onDisconnect ? () => {
6947
6925
  onDisconnect();
6948
6926
  handleBack();
@@ -7347,7 +7325,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
7347
7325
  // src/DepositModal.tsx
7348
7326
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
7349
7327
  var ReownDepositInner = lazy2(
7350
- () => import("./DepositModalReown-EXI7MW65.mjs").then((m) => ({ default: m.DepositModalReown }))
7328
+ () => import("./DepositModalReown-ORSBSEMO.mjs").then((m) => ({ default: m.DepositModalReown }))
7351
7329
  );
7352
7330
  function sortByCreatedAtDesc(items) {
7353
7331
  return [...items].sort((a, b) => {
@@ -3059,6 +3059,23 @@ function estimateReceiveAmount(params) {
3059
3059
  if (targetPrice === void 0) return void 0;
3060
3060
  return usdValue / targetPrice;
3061
3061
  }
3062
+ function formatQuotedReceive(output, fallbackSymbol) {
3063
+ if (output.decimals === null) return void 0;
3064
+ let raw;
3065
+ try {
3066
+ raw = BigInt(output.amount);
3067
+ } catch (e5) {
3068
+ return void 0;
3069
+ }
3070
+ if (raw <= 0n) return void 0;
3071
+ const symbol = _nullishCoalesce(output.symbol, () => ( fallbackSymbol));
3072
+ const formatted = formatRawTokenAmount(raw, {
3073
+ symbol,
3074
+ decimals: output.decimals
3075
+ });
3076
+ if (formatted === void 0) return void 0;
3077
+ return `~${formatted} ${symbol}`;
3078
+ }
3062
3079
  function formatReceiveEstimate(params) {
3063
3080
  const estimate = estimateReceiveAmount(params);
3064
3081
  if (estimate === void 0) return void 0;
@@ -3196,7 +3213,7 @@ function loadPhaseTimings(txHash) {
3196
3213
  const parsed = JSON.parse(raw);
3197
3214
  if (typeof parsed.startedAt !== "number") return null;
3198
3215
  return parsed;
3199
- } catch (e5) {
3216
+ } catch (e6) {
3200
3217
  return null;
3201
3218
  }
3202
3219
  }
@@ -3207,7 +3224,7 @@ function savePhaseTimings(txHash, timings) {
3207
3224
  `${PHASE_TIMINGS_PREFIX}:${txHash}`,
3208
3225
  JSON.stringify(timings)
3209
3226
  );
3210
- } catch (e6) {
3227
+ } catch (e7) {
3211
3228
  }
3212
3229
  }
3213
3230
  function isEventForTx(event, txHash) {
@@ -3945,7 +3962,7 @@ function loadSessionOwnerFromStorage(eoaAddress) {
3945
3962
  privateKey: parsed.privateKey,
3946
3963
  address: account.address
3947
3964
  };
3948
- } catch (e7) {
3965
+ } catch (e8) {
3949
3966
  return null;
3950
3967
  }
3951
3968
  }
@@ -4030,4 +4047,5 @@ function accountFromPrivateKey(privateKey) {
4030
4047
 
4031
4048
 
4032
4049
 
4033
- exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.TransferCryptoIcon = TransferCryptoIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.HandCoinsIcon = HandCoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowUpRightIcon = ArrowUpRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.PercentIcon = PercentIcon; exports.ClockIcon = ClockIcon; exports.PlusCircleIcon = PlusCircleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.BankIcon = BankIcon; exports.UnplugIcon = UnplugIcon; exports.Callout = Callout; exports.BodyHeader = BodyHeader; exports.PoweredBy = PoweredBy; exports.Spinner = Spinner; exports.getExchangeLogo = getExchangeLogo; exports.ConnectStep = ConnectStep; exports.useLatestRef = useLatestRef; exports.Button = Button; exports.debugLog = debugLog; exports.debugError = debugError; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.isUnsupportedChainSwitchError = isUnsupportedChainSwitchError; exports.formatUserError = formatUserError; exports.Tooltip = Tooltip; exports.formatTokenAmount = formatTokenAmount; exports.formatReceiveEstimate = formatReceiveEstimate; exports.getEventTxHash = getEventTxHash; exports.getEventSourceDetails = getEventSourceDetails; exports.isDepositEvent = isDepositEvent; exports.isFailedEvent = isFailedEvent; exports.txRefsMatch = txRefsMatch; exports.failureMessageForEvent = failureMessageForEvent; exports.useTokenPrices = useTokenPrices; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.getHyperEvmReadClient = getHyperEvmReadClient; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.applyTheme = applyTheme;
4050
+
4051
+ exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.TransferCryptoIcon = TransferCryptoIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.HandCoinsIcon = HandCoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowUpRightIcon = ArrowUpRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.PercentIcon = PercentIcon; exports.ClockIcon = ClockIcon; exports.PlusCircleIcon = PlusCircleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.BankIcon = BankIcon; exports.UnplugIcon = UnplugIcon; exports.Callout = Callout; exports.BodyHeader = BodyHeader; exports.PoweredBy = PoweredBy; exports.Spinner = Spinner; exports.getExchangeLogo = getExchangeLogo; exports.ConnectStep = ConnectStep; exports.useLatestRef = useLatestRef; exports.Button = Button; exports.debugLog = debugLog; exports.debugError = debugError; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.isUnsupportedChainSwitchError = isUnsupportedChainSwitchError; exports.formatUserError = formatUserError; exports.Tooltip = Tooltip; exports.formatTokenAmount = formatTokenAmount; exports.formatQuotedReceive = formatQuotedReceive; exports.formatReceiveEstimate = formatReceiveEstimate; exports.getEventTxHash = getEventTxHash; exports.getEventSourceDetails = getEventSourceDetails; exports.isDepositEvent = isDepositEvent; exports.isFailedEvent = isFailedEvent; exports.txRefsMatch = txRefsMatch; exports.failureMessageForEvent = failureMessageForEvent; exports.useTokenPrices = useTokenPrices; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.getHyperEvmReadClient = getHyperEvmReadClient; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.applyTheme = applyTheme;