@rhinestone/deposit-modal 0.6.0 → 0.7.0

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.
Files changed (30) hide show
  1. package/dist/{DepositModalReown-J3KYAOD3.cjs → DepositModalReown-CHVDFNEX.cjs} +9 -9
  2. package/dist/{DepositModalReown-YD7TLEAA.mjs → DepositModalReown-T4RRW5FM.mjs} +6 -6
  3. package/dist/{WithdrawModalReown-ZPDMX47Z.mjs → WithdrawModalReown-Q6MUMZTX.mjs} +5 -5
  4. package/dist/{WithdrawModalReown-QSQUV6HX.cjs → WithdrawModalReown-YZMZTN6E.cjs} +8 -8
  5. package/dist/{chunk-FJWLC4AM.mjs → chunk-4JLYWRQA.mjs} +1 -1
  6. package/dist/{chunk-YYIE5U5K.cjs → chunk-6P3WNDED.cjs} +10 -8
  7. package/dist/{chunk-3JVGI7FC.mjs → chunk-CLUR2J72.mjs} +4 -4
  8. package/dist/{chunk-WJX3TJFK.mjs → chunk-CPMHRMPH.mjs} +36 -7
  9. package/dist/{chunk-ABVRVW3P.cjs → chunk-HH46H6ZI.cjs} +37 -8
  10. package/dist/{chunk-DXGM6YET.mjs → chunk-J52W34Y7.mjs} +6 -4
  11. package/dist/{chunk-F7P4MV72.mjs → chunk-K6J3RDDK.mjs} +1 -1
  12. package/dist/{chunk-DASS33PJ.cjs → chunk-KUURQOTT.cjs} +100 -100
  13. package/dist/{chunk-GQDVHMOT.mjs → chunk-OYPFPEIT.mjs} +333 -54
  14. package/dist/{chunk-7LVI3VAL.cjs → chunk-QSMPJQTX.cjs} +698 -529
  15. package/dist/{chunk-UEKPBRBY.cjs → chunk-RLMXWLF4.cjs} +3 -3
  16. package/dist/{chunk-ZDYV536Q.cjs → chunk-UN6MEOOA.cjs} +382 -103
  17. package/dist/{chunk-NSAODZSS.mjs → chunk-UZENNYHS.mjs} +242 -73
  18. package/dist/{chunk-NRNJAQUA.cjs → chunk-XOBLFIGV.cjs} +4 -4
  19. package/dist/constants.cjs +2 -2
  20. package/dist/constants.mjs +1 -1
  21. package/dist/deposit.cjs +6 -6
  22. package/dist/deposit.mjs +5 -5
  23. package/dist/index.cjs +7 -7
  24. package/dist/index.mjs +6 -6
  25. package/dist/polymarket.cjs +6 -6
  26. package/dist/polymarket.mjs +3 -3
  27. package/dist/styles.css +103 -31
  28. package/dist/withdraw.cjs +5 -5
  29. package/dist/withdraw.mjs +4 -4
  30. package/package.json +1 -1
@@ -7,7 +7,7 @@ import {
7
7
  executePolymarketSafeTransfer,
8
8
  fetchPolymarketProxyWallet,
9
9
  readPolymarketBalances
10
- } from "./chunk-FJWLC4AM.mjs";
10
+ } from "./chunk-4JLYWRQA.mjs";
11
11
  import {
12
12
  AlertTriangleIcon,
13
13
  ArrowUpRightIcon,
@@ -68,10 +68,10 @@ import {
68
68
  useLatestRef,
69
69
  useRpcUrls,
70
70
  useStableRpcUrls
71
- } from "./chunk-GQDVHMOT.mjs";
71
+ } from "./chunk-OYPFPEIT.mjs";
72
72
  import {
73
73
  SAFE_ABI
74
- } from "./chunk-F7P4MV72.mjs";
74
+ } from "./chunk-K6J3RDDK.mjs";
75
75
  import {
76
76
  DEFAULT_BACKEND_URL,
77
77
  DEFAULT_SIGNER_ADDRESS,
@@ -87,6 +87,7 @@ import {
87
87
  getChainName,
88
88
  getExplorerTxUrl,
89
89
  getExplorerUrl,
90
+ getNativeSymbol,
90
91
  getSupportedChainIds,
91
92
  getTargetTokenSymbol,
92
93
  getTargetTokenSymbolsForChain,
@@ -98,10 +99,11 @@ import {
98
99
  isNativeSol,
99
100
  isSolanaCaip2,
100
101
  isStablecoinSymbol,
102
+ isSupportedTokenAddressForChain,
101
103
  isVirtualDestination,
102
104
  parseEvmChainId,
103
105
  targetChainToCaip2
104
- } from "./chunk-WJX3TJFK.mjs";
106
+ } from "./chunk-CPMHRMPH.mjs";
105
107
 
106
108
  // src/DepositModal.tsx
107
109
  import {
@@ -204,12 +206,6 @@ function AssetSelectStep({
204
206
  active = false;
205
207
  };
206
208
  }, [address, publicClient, service, onTotalBalanceComputedRef]);
207
- useEffect(() => {
208
- if (!defaultAssetId || selectedAssetId) return;
209
- if (assets.some((asset) => asset.id === defaultAssetId)) {
210
- setSelectedAssetId(defaultAssetId);
211
- }
212
- }, [assets, defaultAssetId, selectedAssetId]);
213
209
  const allowedChainSet = useMemo(
214
210
  () => allowedRoutes?.sourceChains ? new Set(allowedRoutes.sourceChains) : null,
215
211
  [allowedRoutes?.sourceChains]
@@ -226,7 +222,12 @@ function AssetSelectStep({
226
222
  return false;
227
223
  }
228
224
  if (allowedChainSet && !allowedChainSet.has(a.chainId)) return false;
229
- if (allowedTokenSet && !allowedTokenSet.has(a.symbol.toUpperCase()))
225
+ if (allowedTokenSet) {
226
+ if (!allowedTokenSet.has(a.symbol.toUpperCase())) return false;
227
+ if (!isSupportedTokenAddressForChain(a.token, a.chainId)) return false;
228
+ }
229
+ const isNativeToken = a.token.toLowerCase() === NATIVE_TOKEN_ADDRESS;
230
+ if (!isNativeToken && !(typeof a.balanceUsd === "number" && a.balanceUsd >= 0.01))
230
231
  return false;
231
232
  return true;
232
233
  }).sort((a, b) => {
@@ -240,7 +241,13 @@ function AssetSelectStep({
240
241
  return 0;
241
242
  });
242
243
  }, [assets, allowedChainSet, allowedTokenSet]);
243
- const selectedAsset = selectedAssetId && assets.find((asset) => asset.id === selectedAssetId);
244
+ useEffect(() => {
245
+ if (!defaultAssetId || selectedAssetId) return;
246
+ if (rows.some((asset) => asset.id === defaultAssetId)) {
247
+ setSelectedAssetId(defaultAssetId);
248
+ }
249
+ }, [rows, defaultAssetId, selectedAssetId]);
250
+ const selectedAsset = selectedAssetId && rows.find((asset) => asset.id === selectedAssetId);
244
251
  const formatBalance = (asset) => {
245
252
  if (!asset.balance) return "--";
246
253
  try {
@@ -366,13 +373,14 @@ async function fetchNativeAssets(address, publicClient, existing) {
366
373
  if (existingIds.has(id)) return [];
367
374
  try {
368
375
  const balance = await publicClient.getBalance({ address });
376
+ const nativeSymbol = getNativeSymbol(connectedChainId);
369
377
  return [
370
378
  {
371
379
  id,
372
380
  chainId: connectedChainId,
373
381
  token: NATIVE_TOKEN_ADDRESS,
374
- symbol: "ETH",
375
- name: "Ethereum",
382
+ symbol: nativeSymbol,
383
+ name: nativeSymbol,
376
384
  decimals: 18,
377
385
  balance: balance.toString()
378
386
  }
@@ -1008,7 +1016,13 @@ function ConfirmStep({
1008
1016
  });
1009
1017
  }
1010
1018
  onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
1011
- onConfirm(hash, asset.chainId, amountUnits.toString(), resolvedSourceToken);
1019
+ onConfirm(
1020
+ hash,
1021
+ asset.chainId,
1022
+ amountUnits.toString(),
1023
+ resolvedSourceToken,
1024
+ quote?.fees?.breakdown
1025
+ );
1012
1026
  } catch (err) {
1013
1027
  const raw = err instanceof Error ? err.message : "Transfer failed";
1014
1028
  const message = formatUserError(raw);
@@ -1502,14 +1516,26 @@ function getDepositEventDetails(event) {
1502
1516
  function isSameRoute(sourceChain, sourceToken, targetChain, targetToken) {
1503
1517
  return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
1504
1518
  }
1505
- function computeTokensForChain(chainId, allowedTokenSet) {
1506
- const all = chainId === "solana" ? SOLANA_TOKENS.map((t) => t.symbol) : getTargetTokenSymbolsForChain(chainId);
1519
+ function chainLabel(chainId) {
1520
+ return getChainName(chainId).replace(/\s+(One|Mainnet|Smart Chain)$/i, "");
1521
+ }
1522
+ function computeTokensForChain(chainId, allowedTokenSet, topTokens) {
1523
+ const fromBackend = topTokens?.[String(chainId)]?.map((t) => t.symbol);
1524
+ const all = fromBackend ?? (chainId === "solana" ? SOLANA_TOKENS.map((t) => t.symbol) : getTargetTokenSymbolsForChain(chainId));
1507
1525
  return allowedTokenSet ? all.filter((s) => allowedTokenSet.has(s.toUpperCase())) : all;
1508
1526
  }
1527
+ function resolveSourceTokenAddress(symbol, chainId, topTokens) {
1528
+ const top = topTokens?.[String(chainId)]?.find((t) => t.symbol === symbol);
1529
+ return top?.address ?? getTokenAddress(symbol, chainId);
1530
+ }
1531
+ function TokenGlyph({ symbol }) {
1532
+ const icon = getTokenIcon(symbol);
1533
+ return icon ? /* @__PURE__ */ jsx6("img", { src: icon, alt: "", className: "rs-deposit-address-dropdown-icon" }) : /* @__PURE__ */ jsx6("span", { className: "rs-deposit-address-dropdown-icon rs-deposit-address-dropdown-icon--fallback", children: symbol.slice(0, 3) });
1534
+ }
1509
1535
  function pickFallbackToken(tokens, current) {
1510
1536
  if (tokens.includes(current)) return current;
1511
1537
  if (tokens.includes("USDC")) return "USDC";
1512
- return tokens[0] ?? "USDC";
1538
+ return tokens[0] ?? "";
1513
1539
  }
1514
1540
  function DepositAddressStep({
1515
1541
  smartAccount,
@@ -1545,15 +1571,33 @@ function DepositAddressStep({
1545
1571
  return options;
1546
1572
  }, [evmChainIds, hasSolana]);
1547
1573
  const BASE_CHAIN_ID2 = 8453;
1548
- const defaultChainId = evmChainIds.includes(BASE_CHAIN_ID2) ? BASE_CHAIN_ID2 : evmChainIds[0];
1574
+ const chainHasAllowedToken = (id) => !allowedTokenSet || getTargetTokenSymbolsForChain(id).some(
1575
+ (s) => allowedTokenSet.has(s.toUpperCase())
1576
+ );
1577
+ const defaultChainId = evmChainIds.includes(BASE_CHAIN_ID2) && chainHasAllowedToken(BASE_CHAIN_ID2) ? BASE_CHAIN_ID2 : evmChainIds.find(chainHasAllowedToken) ?? evmChainIds[0];
1549
1578
  const [sourceChainId, setSourceChainId] = useState5(defaultChainId);
1550
1579
  const isSolana = sourceChainId === "solana";
1580
+ const [topTokens, setTopTokens] = useState5(null);
1581
+ useEffect5(() => {
1582
+ let active = true;
1583
+ service.getTopTokens().then((t) => {
1584
+ if (active) setTopTokens(t);
1585
+ });
1586
+ return () => {
1587
+ active = false;
1588
+ };
1589
+ }, [service]);
1551
1590
  const tokensForChain = useMemo3(
1552
- () => computeTokensForChain(sourceChainId, allowedTokenSet),
1553
- [sourceChainId, allowedTokenSet]
1591
+ () => computeTokensForChain(sourceChainId, allowedTokenSet, topTokens),
1592
+ [sourceChainId, allowedTokenSet, topTokens]
1554
1593
  );
1555
1594
  const defaultToken = pickFallbackToken(tokensForChain, "USDC");
1556
1595
  const [sourceTokenSymbol, setSourceTokenSymbol] = useState5(defaultToken);
1596
+ useEffect5(() => {
1597
+ if (!tokensForChain.includes(sourceTokenSymbol)) {
1598
+ setSourceTokenSymbol(pickFallbackToken(tokensForChain, sourceTokenSymbol));
1599
+ }
1600
+ }, [tokensForChain, sourceTokenSymbol]);
1557
1601
  const [copied, setCopied] = useState5(false);
1558
1602
  const [pollingError, setPollingError] = useState5(null);
1559
1603
  const [chainDropdownOpen, setChainDropdownOpen] = useState5(false);
@@ -1573,9 +1617,10 @@ function DepositAddressStep({
1573
1617
  setLiquidityHelper({ kind: "idle" });
1574
1618
  return;
1575
1619
  }
1576
- const sourceTokenAddress = getTokenAddress(
1620
+ const sourceTokenAddress = resolveSourceTokenAddress(
1577
1621
  sourceTokenSymbol,
1578
- sourceChainId
1622
+ sourceChainId,
1623
+ topTokens
1579
1624
  );
1580
1625
  if (!sourceTokenAddress) {
1581
1626
  setLiquidityHelper({ kind: "idle" });
@@ -1616,7 +1661,8 @@ function DepositAddressStep({
1616
1661
  sourceTokenSymbol,
1617
1662
  targetChain,
1618
1663
  targetToken,
1619
- service
1664
+ service,
1665
+ topTokens
1620
1666
  ]);
1621
1667
  const displayAddress = isSolana && solanaDepositAddress ? solanaDepositAddress : smartAccount;
1622
1668
  useEffect5(() => {
@@ -1658,14 +1704,18 @@ function DepositAddressStep({
1658
1704
  }, [displayAddress, onCopyAddress]);
1659
1705
  const handleSelectChain = useCallback2(
1660
1706
  (nextChain) => {
1661
- const nextTokens = computeTokensForChain(nextChain, allowedTokenSet);
1707
+ const nextTokens = computeTokensForChain(
1708
+ nextChain,
1709
+ allowedTokenSet,
1710
+ topTokens
1711
+ );
1662
1712
  setSourceChainId(nextChain);
1663
1713
  setSourceTokenSymbol(pickFallbackToken(nextTokens, sourceTokenSymbol));
1664
1714
  setChainDropdownOpen(false);
1665
1715
  setTokenDropdownOpen(false);
1666
1716
  setCopied(false);
1667
1717
  },
1668
- [allowedTokenSet, sourceTokenSymbol]
1718
+ [allowedTokenSet, sourceTokenSymbol, topTokens]
1669
1719
  );
1670
1720
  const onDepositSubmittedRef = useRef5(onDepositSubmitted);
1671
1721
  onDepositSubmittedRef.current = onDepositSubmitted;
@@ -1820,7 +1870,7 @@ function DepositAddressStep({
1820
1870
  className: "rs-deposit-address-dropdown-icon"
1821
1871
  }
1822
1872
  ),
1823
- /* @__PURE__ */ jsx6("span", { children: getChainName(sourceChainId) }),
1873
+ /* @__PURE__ */ jsx6("span", { children: chainLabel(sourceChainId) }),
1824
1874
  /* @__PURE__ */ jsx6(ChevronDownIcon, { className: "rs-deposit-address-dropdown-chevron" })
1825
1875
  ]
1826
1876
  }
@@ -1840,7 +1890,7 @@ function DepositAddressStep({
1840
1890
  className: "rs-deposit-address-dropdown-icon"
1841
1891
  }
1842
1892
  ),
1843
- /* @__PURE__ */ jsx6("span", { children: getChainName(chainId) })
1893
+ /* @__PURE__ */ jsx6("span", { children: chainLabel(chainId) })
1844
1894
  ]
1845
1895
  },
1846
1896
  String(chainId)
@@ -1872,14 +1922,7 @@ function DepositAddressStep({
1872
1922
  setChainDropdownOpen(false);
1873
1923
  },
1874
1924
  children: [
1875
- getTokenIcon(sourceTokenSymbol) && /* @__PURE__ */ jsx6(
1876
- "img",
1877
- {
1878
- src: getTokenIcon(sourceTokenSymbol),
1879
- alt: "",
1880
- className: "rs-deposit-address-dropdown-icon"
1881
- }
1882
- ),
1925
+ /* @__PURE__ */ jsx6(TokenGlyph, { symbol: sourceTokenSymbol }),
1883
1926
  /* @__PURE__ */ jsx6("span", { children: sourceTokenSymbol }),
1884
1927
  /* @__PURE__ */ jsx6(ChevronDownIcon, { className: "rs-deposit-address-dropdown-chevron" })
1885
1928
  ]
@@ -1895,14 +1938,7 @@ function DepositAddressStep({
1895
1938
  setTokenDropdownOpen(false);
1896
1939
  },
1897
1940
  children: [
1898
- getTokenIcon(symbol) && /* @__PURE__ */ jsx6(
1899
- "img",
1900
- {
1901
- src: getTokenIcon(symbol),
1902
- alt: "",
1903
- className: "rs-deposit-address-dropdown-icon"
1904
- }
1905
- ),
1941
+ /* @__PURE__ */ jsx6(TokenGlyph, { symbol }),
1906
1942
  /* @__PURE__ */ jsx6("span", { children: symbol })
1907
1943
  ]
1908
1944
  },
@@ -2176,6 +2212,7 @@ var DEPOSIT_POLL_INTERVAL_MS = 2e3;
2176
2212
  var DEPOSIT_POLL_FAST_INITIAL_DELAY_MS = 1e3;
2177
2213
  var DEPOSIT_POLL_FAST_INTERVAL_MS = 500;
2178
2214
  var IFRAME_LOAD_TIMEOUT_MS = 15e3;
2215
+ var SWAPPED_SUCCESS_HANDOFF_DELAY_MS = 1400;
2179
2216
  var SWAPPED_IFRAME_ORIGINS = new Set(SWAPPED_ORIGINS);
2180
2217
  var SWAPPED_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
2181
2218
  "order_completed",
@@ -2244,7 +2281,8 @@ function SwappedIframeStep({
2244
2281
  onSwappedFailed,
2245
2282
  onClose,
2246
2283
  onGoBack,
2247
- onError
2284
+ onError,
2285
+ onImmersiveChange
2248
2286
  }) {
2249
2287
  const [widgetUrl, setWidgetUrl] = useState6(null);
2250
2288
  const [loadError, setLoadError] = useState6(null);
@@ -2256,6 +2294,7 @@ function SwappedIframeStep({
2256
2294
  const iframeRef = useRef6(null);
2257
2295
  const completeFiredRef = useRef6(false);
2258
2296
  const failedFiredRef = useRef6(false);
2297
+ const completeTimeoutRef = useRef6(null);
2259
2298
  const expectedOrderUuidRef = useRef6(null);
2260
2299
  const expectedExternalCustomerIdRef = useRef6(null);
2261
2300
  const baselineDepositTxHashRef = useRef6(void 0);
@@ -2272,6 +2311,8 @@ function SwappedIframeStep({
2272
2311
  onErrorRef.current = onError;
2273
2312
  const onGoBackRef = useRef6(onGoBack);
2274
2313
  onGoBackRef.current = onGoBack;
2314
+ const onImmersiveChangeRef = useRef6(onImmersiveChange);
2315
+ onImmersiveChangeRef.current = onImmersiveChange;
2275
2316
  const loadUrlRef = useRef6(loadUrl);
2276
2317
  loadUrlRef.current = loadUrl;
2277
2318
  useEffect6(() => {
@@ -2282,6 +2323,10 @@ function SwappedIframeStep({
2282
2323
  setOrderState(null);
2283
2324
  setLatestEvent(null);
2284
2325
  setPhase("iframe");
2326
+ if (completeTimeoutRef.current !== null) {
2327
+ clearTimeout(completeTimeoutRef.current);
2328
+ completeTimeoutRef.current = null;
2329
+ }
2285
2330
  expectedOrderUuidRef.current = null;
2286
2331
  expectedExternalCustomerIdRef.current = null;
2287
2332
  completeFiredRef.current = false;
@@ -2303,6 +2348,10 @@ function SwappedIframeStep({
2303
2348
  });
2304
2349
  return () => {
2305
2350
  cancelled = true;
2351
+ if (completeTimeoutRef.current !== null) {
2352
+ clearTimeout(completeTimeoutRef.current);
2353
+ completeTimeoutRef.current = null;
2354
+ }
2306
2355
  };
2307
2356
  }, [service, smartAccount, retryToken, loadErrorCode, loadErrorFallback]);
2308
2357
  useEffect6(() => {
@@ -2412,10 +2461,11 @@ function SwappedIframeStep({
2412
2461
  return () => window.removeEventListener("message", onMessage);
2413
2462
  }, []);
2414
2463
  useEffect6(() => {
2415
- if (phase === "iframe" && orderState !== null) {
2464
+ const swappedProvesLive = orderState !== null && !(variant === "fiat" && orderState.status === "payment_pending");
2465
+ if (phase === "iframe" && (swappedProvesLive || latestEvent !== null)) {
2416
2466
  setPhase("tracker");
2417
2467
  }
2418
- }, [phase, orderState]);
2468
+ }, [phase, orderState, latestEvent, variant]);
2419
2469
  const stepStates = useMemo4(
2420
2470
  () => deriveStepStates(orderState?.status ?? null, latestEvent),
2421
2471
  [orderState, latestEvent]
@@ -2441,14 +2491,21 @@ function SwappedIframeStep({
2441
2491
  const txHash = currentDepositTxHashRef.current;
2442
2492
  if (!txHash) return;
2443
2493
  completeFiredRef.current = true;
2444
- onSwappedCompleteRef.current({
2494
+ const info = {
2495
+ smartAccount,
2445
2496
  txHash,
2446
2497
  orderCrypto: orderState?.orderCrypto ?? null,
2447
2498
  // Base-unit source amount from the deposit row/event, consistent with the
2448
2499
  // wallet/QR path. ProcessingStep + onLifecycle expect base units.
2449
- amount: getEventSourceDetails(latestEvent ?? void 0).amount ?? null
2450
- });
2451
- }, [latestEvent, orderState]);
2500
+ amount: getEventSourceDetails(latestEvent ?? void 0).amount ?? null,
2501
+ expectedOrderUuid: expectedOrderUuidRef.current,
2502
+ initialEvent: latestEvent ?? void 0
2503
+ };
2504
+ completeTimeoutRef.current = setTimeout(() => {
2505
+ completeTimeoutRef.current = null;
2506
+ onSwappedCompleteRef.current(info);
2507
+ }, SWAPPED_SUCCESS_HANDOFF_DELAY_MS);
2508
+ }, [latestEvent, orderState, smartAccount]);
2452
2509
  useEffect6(() => {
2453
2510
  if (failedFiredRef.current || completeFiredRef.current) return;
2454
2511
  if (!isFailedEvent(latestEvent ?? void 0)) return;
@@ -2461,6 +2518,11 @@ function SwappedIframeStep({
2461
2518
  failureMessageForEvent(latestEvent ?? void 0)
2462
2519
  );
2463
2520
  }, [latestEvent]);
2521
+ const immersive = variant === "fiat" && phase === "iframe" && !loadError;
2522
+ useEffect6(() => {
2523
+ onImmersiveChangeRef.current?.(immersive);
2524
+ }, [immersive]);
2525
+ useEffect6(() => () => onImmersiveChangeRef.current?.(false), []);
2464
2526
  if (phase === "tracker") {
2465
2527
  const paymentReceived = stepStates[0] === "complete";
2466
2528
  if (variant === "connect" && !terminalState && paymentReceived) {
@@ -2507,7 +2569,7 @@ function SwappedIframeStep({
2507
2569
  retryToken
2508
2570
  )
2509
2571
  ] }) }),
2510
- /* @__PURE__ */ jsx9(PoweredBy, {})
2572
+ loadError && /* @__PURE__ */ jsx9(PoweredBy, {})
2511
2573
  ] });
2512
2574
  }
2513
2575
  function deriveStepStates(swappedStatus, latestEvent) {
@@ -2518,10 +2580,10 @@ function deriveStepStates(swappedStatus, latestEvent) {
2518
2580
  return ["failed", "pending", "pending", "pending"];
2519
2581
  }
2520
2582
  const step1Complete = swappedStatus === "order_completed" || swappedStatus === "order_broadcasted";
2521
- const step2Complete = latestEvent !== null;
2583
+ const step2Complete = latestEvent !== null || swappedStatus === "order_broadcasted";
2522
2584
  const step3Complete = latestEvent?.type === "bridge-complete";
2523
2585
  if (step3Complete) {
2524
- return ["complete", "complete", "complete", "pending"];
2586
+ return ["complete", "complete", "complete", "complete"];
2525
2587
  }
2526
2588
  if (step2Complete) {
2527
2589
  return ["complete", "complete", "active", "pending"];
@@ -2570,7 +2632,8 @@ function FiatOnrampStep({
2570
2632
  onSwappedFailed,
2571
2633
  onClose,
2572
2634
  onGoBack,
2573
- onError
2635
+ onError,
2636
+ onImmersiveChange
2574
2637
  }) {
2575
2638
  const loadUrl = useCallback3(async () => {
2576
2639
  const prefetched = consumePrefetchedUrl?.(smartAccount, paymentMethod);
@@ -2601,7 +2664,8 @@ function FiatOnrampStep({
2601
2664
  onSwappedFailed,
2602
2665
  onClose,
2603
2666
  onGoBack,
2604
- onError
2667
+ onError,
2668
+ onImmersiveChange
2605
2669
  }
2606
2670
  );
2607
2671
  }
@@ -2647,7 +2711,8 @@ function ExchangeConnectStep({
2647
2711
  onSwappedFailed,
2648
2712
  onClose,
2649
2713
  onGoBack,
2650
- onError
2714
+ onError,
2715
+ onImmersiveChange
2651
2716
  }) {
2652
2717
  const loadUrl = useCallback4(async () => {
2653
2718
  const res = await service.getSwappedConnectUrl({
@@ -2671,7 +2736,8 @@ function ExchangeConnectStep({
2671
2736
  onSwappedFailed,
2672
2737
  onClose,
2673
2738
  onGoBack,
2674
- onError
2739
+ onError,
2740
+ onImmersiveChange
2675
2741
  }
2676
2742
  );
2677
2743
  }
@@ -4180,7 +4246,9 @@ function createInitialState(overrides) {
4180
4246
  processing: {
4181
4247
  txHash: null,
4182
4248
  directTransfer: false,
4183
- swappedContext: null
4249
+ swappedContext: null,
4250
+ initialEvent: null,
4251
+ quoteFeeBreakdown: null
4184
4252
  },
4185
4253
  dappImport: {
4186
4254
  activeProviderId: null,
@@ -4789,10 +4857,23 @@ function applyAction(state, action) {
4789
4857
  ...state.processing,
4790
4858
  txHash: action.txHash,
4791
4859
  directTransfer: action.directTransfer ?? false,
4792
- swappedContext: action.swappedContext ?? null
4860
+ swappedContext: action.swappedContext ?? null,
4861
+ initialEvent: action.initialEvent ?? null,
4862
+ quoteFeeBreakdown: action.quoteFeeBreakdown ?? null
4793
4863
  },
4794
4864
  flow: { ...state.flow, step: "processing" }
4795
4865
  };
4866
+ case "processing/quote-fee-breakdown-loaded":
4867
+ if (state.flow.step !== "processing" || state.processing.txHash?.toLowerCase() !== action.txHash.toLowerCase()) {
4868
+ return state;
4869
+ }
4870
+ return {
4871
+ ...state,
4872
+ processing: {
4873
+ ...state.processing,
4874
+ quoteFeeBreakdown: action.quoteFeeBreakdown
4875
+ }
4876
+ };
4796
4877
  case "dapp-import/availability-loading":
4797
4878
  return {
4798
4879
  ...state,
@@ -4959,7 +5040,9 @@ function applyAction(state, action) {
4959
5040
  processing: {
4960
5041
  txHash: null,
4961
5042
  directTransfer: false,
4962
- swappedContext: null
5043
+ swappedContext: null,
5044
+ initialEvent: null,
5045
+ quoteFeeBreakdown: null
4963
5046
  },
4964
5047
  // Drop fetched availability wholesale. The fetch effect refetches
4965
5048
  // unconditionally on remount (so keeping the map saves nothing),
@@ -5316,6 +5399,33 @@ function isSameRoute2(sourceChain, sourceToken, targetChain, targetToken) {
5316
5399
  var SWAPPED_SOURCE_CHAIN = 8453;
5317
5400
  var SWAPPED_SOURCE_TOKEN = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
5318
5401
  var SWAPPED_SOURCE_DECIMALS = 6;
5402
+ var SWAPPED_QUOTE_FEE_TIMEOUT_MS = 2500;
5403
+ async function fetchQuoteFeeBreakdown(params) {
5404
+ try {
5405
+ if (BigInt(params.amount) <= 0n) return void 0;
5406
+ } catch {
5407
+ return void 0;
5408
+ }
5409
+ let timeoutId;
5410
+ try {
5411
+ const quote = await Promise.race([
5412
+ params.service.getQuotePreview({
5413
+ account: params.account,
5414
+ sourceChainId: params.sourceChainId,
5415
+ sourceToken: params.sourceToken,
5416
+ amount: params.amount
5417
+ }),
5418
+ new Promise((resolve) => {
5419
+ timeoutId = setTimeout(resolve, SWAPPED_QUOTE_FEE_TIMEOUT_MS, null);
5420
+ })
5421
+ ]);
5422
+ return quote?.fees?.breakdown;
5423
+ } catch {
5424
+ return void 0;
5425
+ } finally {
5426
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
5427
+ }
5428
+ }
5319
5429
  var DEFAULT_FIAT_ONRAMP_METHODS = [
5320
5430
  {
5321
5431
  method: "creditcard",
@@ -5455,7 +5565,9 @@ function deriveStep(flow, d, p, activeEntry, fiat, exchange) {
5455
5565
  sourceDecimals: d.sourceDecimals ?? void 0,
5456
5566
  inputAmountUsd: d.inputAmountUsd ?? void 0,
5457
5567
  directTransfer: p.directTransfer,
5458
- swappedContext: p.swappedContext ?? void 0
5568
+ swappedContext: p.swappedContext ?? void 0,
5569
+ initialEvent: p.initialEvent ?? void 0,
5570
+ quoteFeeBreakdown: p.quoteFeeBreakdown ?? void 0
5459
5571
  };
5460
5572
  }
5461
5573
  }
@@ -5506,6 +5618,7 @@ function DepositFlow({
5506
5618
  uiConfig,
5507
5619
  allowedRoutes,
5508
5620
  onStepChange,
5621
+ onSwappedImmersiveChange,
5509
5622
  onClose,
5510
5623
  onLifecycle,
5511
5624
  onEvent,
@@ -6631,7 +6744,7 @@ function DepositFlow({
6631
6744
  [targetToken, targetChain, storeApi, activeOwner]
6632
6745
  );
6633
6746
  const handleDepositSubmitted = useCallback7(
6634
- (txHash, chainId, amount, token) => {
6747
+ (txHash, chainId, amount, token, quoteFeeBreakdown) => {
6635
6748
  logFlow("evm:submitted", {
6636
6749
  txHash,
6637
6750
  sourceChain: chainId,
@@ -6650,7 +6763,8 @@ function DepositFlow({
6650
6763
  sourceSymbol: asset?.symbol,
6651
6764
  sourceDecimals: asset?.decimals,
6652
6765
  inputAmountUsd: depositAtSubmit.inputAmountUsd ?? void 0,
6653
- directTransfer: !dappImport && isSameRoute2(chainId, token, targetChain, targetToken)
6766
+ directTransfer: !dappImport && isSameRoute2(chainId, token, targetChain, targetToken),
6767
+ quoteFeeBreakdown
6654
6768
  });
6655
6769
  },
6656
6770
  [logFlow, storeApi, targetChain, targetToken]
@@ -6665,10 +6779,12 @@ function DepositFlow({
6665
6779
  const stateAtComplete = storeApi.getState();
6666
6780
  const swappedContext = stateAtComplete.flow.mode === "exchange-connect" ? {
6667
6781
  variant: "connect",
6668
- method: stateAtComplete.exchange.selectedConnection
6782
+ method: stateAtComplete.exchange.selectedConnection,
6783
+ expectedOrderUuid: info.expectedOrderUuid
6669
6784
  } : stateAtComplete.flow.mode === "fiat-onramp" ? {
6670
6785
  variant: "fiat",
6671
- method: stateAtComplete.fiat.selectedMethod
6786
+ method: stateAtComplete.fiat.selectedMethod,
6787
+ expectedOrderUuid: info.expectedOrderUuid
6672
6788
  } : void 0;
6673
6789
  storeApi.dispatch({
6674
6790
  type: "deposit/submitted",
@@ -6678,7 +6794,8 @@ function DepositFlow({
6678
6794
  amount,
6679
6795
  sourceSymbol: info.orderCrypto ?? "USDC",
6680
6796
  sourceDecimals: SWAPPED_SOURCE_DECIMALS,
6681
- swappedContext
6797
+ swappedContext,
6798
+ initialEvent: info.initialEvent
6682
6799
  });
6683
6800
  onLifecycleRef.current?.({
6684
6801
  type: "submitted",
@@ -6687,8 +6804,23 @@ function DepositFlow({
6687
6804
  amount,
6688
6805
  sourceDecimals: SWAPPED_SOURCE_DECIMALS
6689
6806
  });
6807
+ void (async () => {
6808
+ const quoteFeeBreakdown = await fetchQuoteFeeBreakdown({
6809
+ service,
6810
+ account: info.smartAccount,
6811
+ sourceChainId: SWAPPED_SOURCE_CHAIN,
6812
+ sourceToken: SWAPPED_SOURCE_TOKEN,
6813
+ amount
6814
+ });
6815
+ if (!quoteFeeBreakdown) return;
6816
+ storeApi.dispatch({
6817
+ type: "processing/quote-fee-breakdown-loaded",
6818
+ txHash: info.txHash,
6819
+ quoteFeeBreakdown
6820
+ });
6821
+ })();
6690
6822
  },
6691
- [logFlow, storeApi, onLifecycleRef]
6823
+ [logFlow, onLifecycleRef, service, storeApi]
6692
6824
  );
6693
6825
  const handleDepositSubmittedCallback = useCallback7(
6694
6826
  (txHash, sourceChain, amount) => {
@@ -6930,7 +7062,8 @@ function DepositFlow({
6930
7062
  onClose: onClose ?? (() => {
6931
7063
  }),
6932
7064
  onGoBack: handleBack,
6933
- onError: handleError
7065
+ onError: handleError,
7066
+ onImmersiveChange: onSwappedImmersiveChange
6934
7067
  }
6935
7068
  ),
6936
7069
  step.type === "processing" && /* @__PURE__ */ jsx19(
@@ -6948,9 +7081,12 @@ function DepositFlow({
6948
7081
  sourceDecimals: step.sourceDecimals,
6949
7082
  amountUsd: step.inputAmountUsd,
6950
7083
  swappedContext: step.swappedContext,
7084
+ quoteFeeBreakdown: step.quoteFeeBreakdown,
6951
7085
  service,
6952
7086
  directTransfer: step.directTransfer,
7087
+ initialEvent: step.initialEvent,
6953
7088
  isSwappedOrder: true,
7089
+ uiConfig,
6954
7090
  onClose,
6955
7091
  onNewDeposit: handleNewDeposit,
6956
7092
  onDepositComplete: handleDepositComplete,
@@ -6998,7 +7134,8 @@ function DepositFlow({
6998
7134
  onClose: onClose ?? (() => {
6999
7135
  }),
7000
7136
  onGoBack: handleBack,
7001
- onError: handleError
7137
+ onError: handleError,
7138
+ onImmersiveChange: onSwappedImmersiveChange
7002
7139
  }
7003
7140
  ),
7004
7141
  step.type === "processing" && /* @__PURE__ */ jsx19(
@@ -7016,9 +7153,12 @@ function DepositFlow({
7016
7153
  sourceDecimals: step.sourceDecimals,
7017
7154
  amountUsd: step.inputAmountUsd,
7018
7155
  swappedContext: step.swappedContext,
7156
+ quoteFeeBreakdown: step.quoteFeeBreakdown,
7019
7157
  service,
7020
7158
  directTransfer: step.directTransfer,
7159
+ initialEvent: step.initialEvent,
7021
7160
  isSwappedOrder: true,
7161
+ uiConfig,
7022
7162
  onClose,
7023
7163
  onNewDeposit: handleNewDeposit,
7024
7164
  onDepositComplete: handleDepositComplete,
@@ -7147,6 +7287,8 @@ function DepositFlow({
7147
7287
  amountUsd: effectiveStep.inputAmountUsd,
7148
7288
  service,
7149
7289
  directTransfer: effectiveStep.directTransfer,
7290
+ initialEvent: effectiveStep.initialEvent,
7291
+ quoteFeeBreakdown: effectiveStep.quoteFeeBreakdown,
7150
7292
  onClose,
7151
7293
  onNewDeposit: handleNewDeposit,
7152
7294
  onDepositComplete: handleDepositComplete,
@@ -7308,6 +7450,8 @@ function DepositFlow({
7308
7450
  amountUsd: effectiveStep.inputAmountUsd,
7309
7451
  service,
7310
7452
  directTransfer: effectiveStep.directTransfer,
7453
+ initialEvent: effectiveStep.initialEvent,
7454
+ quoteFeeBreakdown: effectiveStep.quoteFeeBreakdown,
7311
7455
  uiConfig,
7312
7456
  onClose,
7313
7457
  onNewDeposit: handleNewDeposit,
@@ -7608,7 +7752,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
7608
7752
  // src/DepositModal.tsx
7609
7753
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
7610
7754
  var ReownDepositInner = lazy2(
7611
- () => import("./DepositModalReown-YD7TLEAA.mjs").then((m) => ({ default: m.DepositModalReown }))
7755
+ () => import("./DepositModalReown-T4RRW5FM.mjs").then((m) => ({ default: m.DepositModalReown }))
7612
7756
  );
7613
7757
  function sortByCreatedAtDesc(items) {
7614
7758
  return [...items].sort((a, b) => {
@@ -7688,6 +7832,7 @@ function DepositModalInner({
7688
7832
  const modalRef = useRef9(null);
7689
7833
  const onReadyRef = useLatestRef(onReady);
7690
7834
  const [currentScreen, setCurrentScreen] = useState13("connect");
7835
+ const [swappedImmersive, setSwappedImmersive] = useState13(false);
7691
7836
  const [backHandler, setBackHandler] = useState13(
7692
7837
  void 0
7693
7838
  );
@@ -7737,6 +7882,24 @@ function DepositModalInner({
7737
7882
  }),
7738
7883
  [backendUrl, debug]
7739
7884
  );
7885
+ const [clientSetup, setClientSetup] = useState13(
7886
+ null
7887
+ );
7888
+ useEffect11(() => {
7889
+ if (!isOpen) return;
7890
+ let active = true;
7891
+ service.getSetup().then((config) => {
7892
+ if (active) setClientSetup(config);
7893
+ });
7894
+ return () => {
7895
+ active = false;
7896
+ };
7897
+ }, [isOpen, service]);
7898
+ useEffect11(() => {
7899
+ if (debug && clientSetup) {
7900
+ console.debug("[deposit] client setup config (not shown yet)", clientSetup);
7901
+ }
7902
+ }, [debug, clientSetup]);
7740
7903
  const store = useMemo9(
7741
7904
  () => createDepositStore({ targetChain, targetToken }),
7742
7905
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -7850,6 +8013,9 @@ function DepositModalInner({
7850
8013
  cursorRef.current = null;
7851
8014
  historyStaleRef.current = false;
7852
8015
  historyLoadedRef.current = false;
8016
+ setCurrentScreen("connect");
8017
+ setBackHandler(void 0);
8018
+ setSwappedImmersive(false);
7853
8019
  }
7854
8020
  }, [isOpen]);
7855
8021
  useEffect11(() => {
@@ -7859,6 +8025,8 @@ function DepositModalInner({
7859
8025
  }, [isOpen, store]);
7860
8026
  const showBackButton = uiConfig?.showBackButton ?? true;
7861
8027
  const canGoBack = backHandler !== void 0;
8028
+ const hideHeaderChrome = swappedImmersive;
8029
+ const modalClassName = `rs-modal${hideHeaderChrome ? " rs-modal--swapped-iframe" : ""}`;
7862
8030
  return /* @__PURE__ */ jsx21(RpcUrlsProvider, { value: rpcUrls, children: /* @__PURE__ */ jsx21(DepositStoreProvider, { store, children: /* @__PURE__ */ jsx21(
7863
8031
  Modal,
7864
8032
  {
@@ -7867,8 +8035,8 @@ function DepositModalInner({
7867
8035
  className,
7868
8036
  inline,
7869
8037
  closeOnOverlayClick,
7870
- children: /* @__PURE__ */ jsxs19("div", { ref: modalRef, className: "rs-modal", children: [
7871
- /* @__PURE__ */ jsxs19("div", { className: "rs-modal-header--redesigned", children: [
8038
+ children: /* @__PURE__ */ jsxs19("div", { ref: modalRef, className: modalClassName, children: [
8039
+ !hideHeaderChrome && /* @__PURE__ */ jsxs19("div", { className: "rs-modal-header--redesigned", children: [
7872
8040
  /* @__PURE__ */ jsx21("div", { className: "rs-modal-header-nav-left", children: showBackButton && canGoBack && backHandler && /* @__PURE__ */ jsx21(
7873
8041
  "button",
7874
8042
  {
@@ -7937,6 +8105,7 @@ function DepositModalInner({
7937
8105
  uiConfig,
7938
8106
  allowedRoutes,
7939
8107
  onStepChange: handleStepChange,
8108
+ onSwappedImmersiveChange: setSwappedImmersive,
7940
8109
  onClose,
7941
8110
  onLifecycle: handleLifecycle,
7942
8111
  onEvent,