@rhinestone/deposit-modal 0.5.1 → 0.6.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.
@@ -414,15 +414,12 @@ function depositRowToEvent(row) {
414
414
  const time = _nullishCoalesce(_nullishCoalesce(row.completedAt, () => ( row.createdAt)), () => ( void 0));
415
415
  if (status === "completed") {
416
416
  return {
417
- type: "post-bridge-swap-complete",
417
+ type: "bridge-complete",
418
418
  time: _nullishCoalesce(time, () => ( void 0)),
419
419
  data: {
420
420
  deposit,
421
421
  source,
422
- ...destination && { destination },
423
- ...destination && {
424
- swap: { transactionHash: destination.transactionHash }
425
- }
422
+ ...destination && { destination }
426
423
  }
427
424
  };
428
425
  }
@@ -541,15 +538,18 @@ function createDepositService(baseUrl, options) {
541
538
  }
542
539
  const PORTFOLIO_CACHE_TTL_MS = 3e4;
543
540
  const portfolioCache = /* @__PURE__ */ new Map();
544
- function cachedPortfolio(key, fetcher) {
541
+ function cachedPortfolio(key, fetcher, forceRefresh = false) {
545
542
  const now = Date.now();
546
543
  const entry = portfolioCache.get(key);
547
- if (entry && entry.expiresAt > now) {
544
+ if (!forceRefresh && entry && entry.expiresAt > now) {
548
545
  debugLog(debug, scope, "portfolio:cache-hit", { key });
549
546
  return entry.promise;
550
547
  }
551
- const promise = fetcher().catch((err) => {
552
- portfolioCache.delete(key);
548
+ let promise;
549
+ promise = fetcher().catch((err) => {
550
+ if (_optionalChain([portfolioCache, 'access', _3 => _3.get, 'call', _4 => _4(key), 'optionalAccess', _5 => _5.promise]) === promise) {
551
+ portfolioCache.delete(key);
552
+ }
553
553
  throw err;
554
554
  });
555
555
  portfolioCache.set(key, {
@@ -567,7 +567,6 @@ function createDepositService(baseUrl, options) {
567
567
  targetChain: params.targetChain,
568
568
  targetToken: params.targetToken,
569
569
  recipient: params.recipient ? shortRef(params.recipient) : void 0,
570
- postBridgeActionCount: _nullishCoalesce(_optionalChain([params, 'access', _3 => _3.postBridgeActions, 'optionalAccess', _4 => _4.length]), () => ( 0)),
571
570
  forceRegister: params.forceRegister
572
571
  });
573
572
  const response = await fetch(url, {
@@ -584,7 +583,7 @@ function createDepositService(baseUrl, options) {
584
583
  error,
585
584
  { status: response.status, ownerAddress: params.ownerAddress }
586
585
  );
587
- const detail = Array.isArray(error.details) ? error.details.map((d) => _optionalChain([d, 'optionalAccess', _5 => _5.message])).filter(Boolean).join("; ") : void 0;
586
+ const detail = Array.isArray(error.details) ? error.details.map((d) => _optionalChain([d, 'optionalAccess', _6 => _6.message])).filter(Boolean).join("; ") : void 0;
588
587
  const base = error.error || `Setup account failed: ${response.status}`;
589
588
  throw new Error(detail ? `${base}: ${detail}` : base);
590
589
  }
@@ -636,12 +635,12 @@ function createDepositService(baseUrl, options) {
636
635
  const result = await response.json();
637
636
  debugLog(debug, scope, "registerAccount:success", {
638
637
  address: params.address,
639
- evmDepositAddress: _optionalChain([result, 'optionalAccess', _6 => _6.evmDepositAddress]),
640
- hasSolanaDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _7 => _7.solanaDepositAddress]))
638
+ evmDepositAddress: _optionalChain([result, 'optionalAccess', _7 => _7.evmDepositAddress]),
639
+ hasSolanaDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _8 => _8.solanaDepositAddress]))
641
640
  });
642
641
  return result;
643
642
  },
644
- async fetchPortfolio(address) {
643
+ async fetchPortfolio(address, options2) {
645
644
  return cachedPortfolio(`evm:${address.toLowerCase()}`, async () => {
646
645
  const url = apiUrl(`/portfolio/${address}`);
647
646
  debugLog(debug, scope, "fetchPortfolio:request", { url, address });
@@ -686,9 +685,9 @@ function createDepositService(baseUrl, options) {
686
685
  }
687
686
  debugLog(debug, scope, "fetchPortfolio:empty", { address });
688
687
  return { tokens: [], totalUsd: 0 };
689
- });
688
+ }, _optionalChain([options2, 'optionalAccess', _9 => _9.forceRefresh]));
690
689
  },
691
- async fetchSolanaPortfolio(address) {
690
+ async fetchSolanaPortfolio(address, options2) {
692
691
  return cachedPortfolio(`sol:${address}`, async () => {
693
692
  const url = apiUrl(`/portfolio/solana/${address}`);
694
693
  debugLog(debug, scope, "fetchSolanaPortfolio:request", { url, address });
@@ -717,7 +716,7 @@ function createDepositService(baseUrl, options) {
717
716
  totalUsd: normalized.totalUsd
718
717
  });
719
718
  return normalized;
720
- });
719
+ }, _optionalChain([options2, 'optionalAccess', _10 => _10.forceRefresh]));
721
720
  },
722
721
  async checkAccount(address) {
723
722
  const url = apiUrl(`/check/${address}`);
@@ -739,9 +738,9 @@ function createDepositService(baseUrl, options) {
739
738
  }
740
739
  const data = await response.json();
741
740
  const result = {
742
- isRegistered: _optionalChain([data, 'optionalAccess', _8 => _8.isRegistered]) === true,
743
- targetChain: _optionalChain([data, 'optionalAccess', _9 => _9.targetChain]),
744
- targetToken: _optionalChain([data, 'optionalAccess', _10 => _10.targetToken])
741
+ isRegistered: _optionalChain([data, 'optionalAccess', _11 => _11.isRegistered]) === true,
742
+ targetChain: _optionalChain([data, 'optionalAccess', _12 => _12.targetChain]),
743
+ targetToken: _optionalChain([data, 'optionalAccess', _13 => _13.targetToken])
745
744
  };
746
745
  debugLog(debug, scope, "checkAccount:success", {
747
746
  address,
@@ -771,12 +770,12 @@ function createDepositService(baseUrl, options) {
771
770
  return { lastEvent: void 0 };
772
771
  }
773
772
  const body = await response.json();
774
- const row = _optionalChain([body, 'access', _11 => _11.deposits, 'optionalAccess', _12 => _12[0]]);
773
+ const row = _optionalChain([body, 'access', _14 => _14.deposits, 'optionalAccess', _15 => _15[0]]);
775
774
  const lastEvent = row ? depositRowToEvent(row) : void 0;
776
775
  debugLog(debug, scope, "fetchStatus:success", {
777
776
  address,
778
777
  txHash: shortRef(normalized),
779
- eventType: _optionalChain([lastEvent, 'optionalAccess', _13 => _13.type])
778
+ eventType: _optionalChain([lastEvent, 'optionalAccess', _16 => _16.type])
780
779
  });
781
780
  return { lastEvent };
782
781
  },
@@ -797,11 +796,11 @@ function createDepositService(baseUrl, options) {
797
796
  return { lastEvent: void 0 };
798
797
  }
799
798
  const body = await response.json();
800
- const row = _optionalChain([body, 'access', _14 => _14.deposits, 'optionalAccess', _15 => _15[0]]);
799
+ const row = _optionalChain([body, 'access', _17 => _17.deposits, 'optionalAccess', _18 => _18[0]]);
801
800
  const lastEvent = row ? depositRowToEvent(row) : void 0;
802
801
  debugLog(debug, scope, "fetchLatestStatus:success", {
803
802
  address,
804
- eventType: _optionalChain([lastEvent, 'optionalAccess', _16 => _16.type])
803
+ eventType: _optionalChain([lastEvent, 'optionalAccess', _19 => _19.type])
805
804
  });
806
805
  return { lastEvent };
807
806
  },
@@ -863,7 +862,7 @@ function createDepositService(baseUrl, options) {
863
862
  smartAccount,
864
863
  chainId,
865
864
  safeAddress,
866
- txHash: _optionalChain([result, 'optionalAccess', _17 => _17.txHash]) ? shortRef(result.txHash) : void 0
865
+ txHash: _optionalChain([result, 'optionalAccess', _20 => _20.txHash]) ? shortRef(result.txHash) : void 0
867
866
  });
868
867
  return result;
869
868
  },
@@ -903,7 +902,7 @@ function createDepositService(baseUrl, options) {
903
902
  const result = await response.json();
904
903
  debugLog(debug, scope, "submitPolymarketWithdraw:success", {
905
904
  depositWallet,
906
- txHash: _optionalChain([result, 'optionalAccess', _18 => _18.txHash]) ? shortRef(result.txHash) : void 0
905
+ txHash: _optionalChain([result, 'optionalAccess', _21 => _21.txHash]) ? shortRef(result.txHash) : void 0
907
906
  });
908
907
  return result;
909
908
  },
@@ -938,8 +937,8 @@ function createDepositService(baseUrl, options) {
938
937
  );
939
938
  }
940
939
  const data = await response.json();
941
- const deposits = Array.isArray(_optionalChain([data, 'optionalAccess', _19 => _19.deposits])) ? data.deposits : [];
942
- const nextCursor = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _20 => _20.nextCursor]), () => ( _optionalChain([data, 'optionalAccess', _21 => _21.next_cursor]))), () => ( null));
940
+ const deposits = Array.isArray(_optionalChain([data, 'optionalAccess', _22 => _22.deposits])) ? data.deposits : [];
941
+ const nextCursor = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _23 => _23.nextCursor]), () => ( _optionalChain([data, 'optionalAccess', _24 => _24.next_cursor]))), () => ( null));
943
942
  debugLog(debug, scope, "fetchDepositHistory:success", {
944
943
  recipient: shortRef(params.recipient),
945
944
  count: deposits.length,
@@ -952,8 +951,8 @@ function createDepositService(baseUrl, options) {
952
951
  const token = _chunkABVRVW3Pcjs.getSolanaTokenByMint.call(void 0, params.destinationToken);
953
952
  return {
954
953
  hasLiquidity: true,
955
- symbol: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _22 => _22.symbol]), () => ( "Token")),
956
- decimals: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _23 => _23.decimals]), () => ( 9)),
954
+ symbol: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _25 => _25.symbol]), () => ( "Token")),
955
+ decimals: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _26 => _26.decimals]), () => ( 9)),
957
956
  unlimited: true,
958
957
  maxAmount: null
959
958
  };
@@ -1031,7 +1030,7 @@ function createDepositService(baseUrl, options) {
1031
1030
  const quote = await response.json();
1032
1031
  debugLog(debug, scope, "getQuotePreview:success", {
1033
1032
  settlementLayer: quote.settlementLayer,
1034
- totalUsd: _optionalChain([quote, 'access', _24 => _24.fees, 'optionalAccess', _25 => _25.totalUsd])
1033
+ totalUsd: _optionalChain([quote, 'access', _27 => _27.fees, 'optionalAccess', _28 => _28.totalUsd])
1035
1034
  });
1036
1035
  return quote;
1037
1036
  } catch (error) {
@@ -1217,16 +1216,16 @@ function createDepositService(baseUrl, options) {
1217
1216
  }
1218
1217
  function normalizeDirectPortfolio(data) {
1219
1218
  const rawTokens = _nullishCoalesce(_nullishCoalesce(extractArray(data, "tokens"), () => ( extractArray(
1220
- _optionalChain([data, 'optionalAccess', _26 => _26.data]),
1219
+ _optionalChain([data, 'optionalAccess', _29 => _29.data]),
1221
1220
  "tokens"
1222
1221
  ))), () => ( []));
1223
- const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _27 => _27.data]), "totalUsd"))), () => ( 0));
1222
+ const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _30 => _30.data]), "totalUsd"))), () => ( 0));
1224
1223
  const tokens = rawTokens.map((token) => normalizeDirectToken(token)).filter((token) => Boolean(token));
1225
1224
  return { tokens, totalUsd };
1226
1225
  }
1227
1226
  function extractOrchestratorPortfolio(data) {
1228
1227
  const portfolio = _nullishCoalesce(extractArray(data, "portfolio"), () => ( extractArray(
1229
- _optionalChain([data, 'optionalAccess', _28 => _28.data]),
1228
+ _optionalChain([data, 'optionalAccess', _31 => _31.data]),
1230
1229
  "portfolio"
1231
1230
  )));
1232
1231
  if (!portfolio || !Array.isArray(portfolio)) return null;
@@ -1237,7 +1236,7 @@ function normalizeOrchestratorPortfolio(data) {
1237
1236
  for (const tokenData of data.portfolio || []) {
1238
1237
  const chainBalances = _nullishCoalesce(_nullishCoalesce(tokenData.tokenChainBalance, () => ( tokenData.chainBalances)), () => ( []));
1239
1238
  for (const chainBalance of chainBalances) {
1240
- const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _29 => _29.balance, 'optionalAccess', _30 => _30.unlocked]), () => ( "0"));
1239
+ const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _32 => _32.balance, 'optionalAccess', _33 => _33.unlocked]), () => ( "0"));
1241
1240
  const normalizedName = tokenData.tokenName.trim();
1242
1241
  const isNativeSymbol = normalizedName.toUpperCase() === "ETH" || normalizedName.toUpperCase() === "ETHER";
1243
1242
  const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkABVRVW3Pcjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
@@ -1271,7 +1270,7 @@ function normalizeDirectToken(token) {
1271
1270
  if (chainId === null) return null;
1272
1271
  const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "symbol"), () => ( extractString(token, "tokenSymbol"))), () => ( extractString(token, "tokenName"))), () => ( extractString(token, "name")));
1273
1272
  if (!symbol) return null;
1274
- const balanceValue = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "balance"), () => ( extractString(token, "amount"))), () => ( extractString(token, "value"))), () => ( extractString(token, "rawBalance"))), () => ( _optionalChain([extractNumber, 'call', _31 => _31(token, "balance"), 'optionalAccess', _32 => _32.toString, 'call', _33 => _33()]))), () => ( _optionalChain([extractNumber, 'call', _34 => _34(token, "amount"), 'optionalAccess', _35 => _35.toString, 'call', _36 => _36()]))), () => ( _optionalChain([extractNumber, 'call', _37 => _37(token, "value"), 'optionalAccess', _38 => _38.toString, 'call', _39 => _39()]))), () => ( _optionalChain([extractNumber, 'call', _40 => _40(token, "rawBalance"), 'optionalAccess', _41 => _41.toString, 'call', _42 => _42()])));
1273
+ const balanceValue = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "balance"), () => ( extractString(token, "amount"))), () => ( extractString(token, "value"))), () => ( extractString(token, "rawBalance"))), () => ( _optionalChain([extractNumber, 'call', _34 => _34(token, "balance"), 'optionalAccess', _35 => _35.toString, 'call', _36 => _36()]))), () => ( _optionalChain([extractNumber, 'call', _37 => _37(token, "amount"), 'optionalAccess', _38 => _38.toString, 'call', _39 => _39()]))), () => ( _optionalChain([extractNumber, 'call', _40 => _40(token, "value"), 'optionalAccess', _41 => _41.toString, 'call', _42 => _42()]))), () => ( _optionalChain([extractNumber, 'call', _43 => _43(token, "rawBalance"), 'optionalAccess', _44 => _44.toString, 'call', _45 => _45()])));
1275
1274
  if (!balanceValue) return null;
1276
1275
  const address = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "address"), () => ( extractString(token, "tokenAddress"))), () => ( extractString(
1277
1276
  token.token,
@@ -1296,7 +1295,7 @@ function normalizeDirectToken(token) {
1296
1295
  }
1297
1296
  function extractTokenAddress(tokenData, chainId) {
1298
1297
  const token = tokenData;
1299
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _43 => _43.addresses, 'optionalAccess', _44 => _44[chainId]]))), () => ( _optionalChain([token, 'access', _45 => _45.token, 'optionalAccess', _46 => _46.address]))), () => ( _optionalChain([token, 'access', _47 => _47.token, 'optionalAccess', _48 => _48.addresses, 'optionalAccess', _49 => _49[chainId]])));
1298
+ return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _46 => _46.addresses, 'optionalAccess', _47 => _47[chainId]]))), () => ( _optionalChain([token, 'access', _48 => _48.token, 'optionalAccess', _49 => _49.address]))), () => ( _optionalChain([token, 'access', _50 => _50.token, 'optionalAccess', _51 => _51.addresses, 'optionalAccess', _52 => _52[chainId]])));
1300
1299
  }
1301
1300
  function extractArray(data, key) {
1302
1301
  if (!data || typeof data !== "object") return null;
@@ -1398,7 +1397,7 @@ function formatUserError(raw) {
1398
1397
  // src/core/rpc.ts
1399
1398
 
1400
1399
  function rpcUrlFor(rpcUrls, chain) {
1401
- const url = _optionalChain([rpcUrls, 'optionalAccess', _50 => _50[chain], 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()]);
1400
+ const url = _optionalChain([rpcUrls, 'optionalAccess', _53 => _53[chain], 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()]);
1402
1401
  return url ? url : void 0;
1403
1402
  }
1404
1403
  var RpcUrlsContext = _react.createContext.call(void 0, void 0);
@@ -1408,7 +1407,7 @@ function useRpcUrls() {
1408
1407
  }
1409
1408
  function rpcUrlsKey(rpcUrls) {
1410
1409
  if (!rpcUrls) return "";
1411
- return Object.entries(rpcUrls).map(([chain, url]) => [chain, _nullishCoalesce(_optionalChain([url, 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()]), () => ( ""))]).filter(([, url]) => url !== "").map(([chain, url]) => `${chain}=${url}`).sort().join("|");
1410
+ return Object.entries(rpcUrls).map(([chain, url]) => [chain, _nullishCoalesce(_optionalChain([url, 'optionalAccess', _56 => _56.trim, 'call', _57 => _57()]), () => ( ""))]).filter(([, url]) => url !== "").map(([chain, url]) => `${chain}=${url}`).sort().join("|");
1412
1411
  }
1413
1412
  function useStableRpcUrls(rpcUrls) {
1414
1413
  const key = rpcUrlsKey(rpcUrls);
@@ -1550,19 +1549,19 @@ var CUSTOM_PRIMARY_VARS = [
1550
1549
  function applyTheme(element, theme) {
1551
1550
  if (!element) return;
1552
1551
  const parent = element.parentElement;
1553
- const targets = _optionalChain([parent, 'optionalAccess', _55 => _55.classList, 'access', _56 => _56.contains, 'call', _57 => _57("rs-modal-content")]) ? [element, parent] : [element];
1554
- if (_optionalChain([theme, 'optionalAccess', _58 => _58.mode])) {
1552
+ const targets = _optionalChain([parent, 'optionalAccess', _58 => _58.classList, 'access', _59 => _59.contains, 'call', _60 => _60("rs-modal-content")]) ? [element, parent] : [element];
1553
+ if (_optionalChain([theme, 'optionalAccess', _61 => _61.mode])) {
1555
1554
  for (const t of targets) t.setAttribute("data-theme", theme.mode);
1556
1555
  } else {
1557
1556
  for (const t of targets) t.removeAttribute("data-theme");
1558
1557
  }
1559
- if (_optionalChain([theme, 'optionalAccess', _59 => _59.fontColor])) {
1558
+ if (_optionalChain([theme, 'optionalAccess', _62 => _62.fontColor])) {
1560
1559
  setVar(targets, "--rs-foreground", theme.fontColor);
1561
1560
  }
1562
- if (_optionalChain([theme, 'optionalAccess', _60 => _60.iconColor])) {
1561
+ if (_optionalChain([theme, 'optionalAccess', _63 => _63.iconColor])) {
1563
1562
  setVar(targets, "--rs-icon", theme.iconColor);
1564
1563
  }
1565
- if (_optionalChain([theme, 'optionalAccess', _61 => _61.ctaColor])) {
1564
+ if (_optionalChain([theme, 'optionalAccess', _64 => _64.ctaColor])) {
1566
1565
  const derived = deriveCustomPrimary(theme.ctaColor);
1567
1566
  if (derived) {
1568
1567
  setVar(targets, "--rs-primary", derived.base);
@@ -1587,18 +1586,18 @@ function applyTheme(element, theme) {
1587
1586
  }
1588
1587
  } else {
1589
1588
  for (const v of CUSTOM_PRIMARY_VARS) clearVar(targets, v);
1590
- if (_optionalChain([theme, 'optionalAccess', _62 => _62.ctaHoverColor])) {
1589
+ if (_optionalChain([theme, 'optionalAccess', _65 => _65.ctaHoverColor])) {
1591
1590
  setVar(targets, "--rs-primary-hover", theme.ctaHoverColor);
1592
1591
  }
1593
1592
  }
1594
- if (_optionalChain([theme, 'optionalAccess', _63 => _63.borderColor])) {
1593
+ if (_optionalChain([theme, 'optionalAccess', _66 => _66.borderColor])) {
1595
1594
  setVar(targets, "--rs-border", theme.borderColor);
1596
1595
  setVar(targets, "--rs-border-surface", theme.borderColor);
1597
1596
  }
1598
- if (_optionalChain([theme, 'optionalAccess', _64 => _64.backgroundColor])) {
1597
+ if (_optionalChain([theme, 'optionalAccess', _67 => _67.backgroundColor])) {
1599
1598
  setVar(targets, "--rs-background", theme.backgroundColor);
1600
1599
  }
1601
- if (_optionalChain([theme, 'optionalAccess', _65 => _65.radius])) {
1600
+ if (_optionalChain([theme, 'optionalAccess', _68 => _68.radius])) {
1602
1601
  const scale = RADIUS_SCALE[theme.radius];
1603
1602
  setVar(targets, "--rs-radius-sm", scale.sm);
1604
1603
  setVar(targets, "--rs-radius-md", scale.md);
@@ -1781,7 +1780,7 @@ function ListRow({
1781
1780
  if (disabled) return;
1782
1781
  if (e.key === "Enter" || e.key === " ") {
1783
1782
  e.preventDefault();
1784
- _optionalChain([onClick, 'optionalCall', _66 => _66(e)]);
1783
+ _optionalChain([onClick, 'optionalCall', _69 => _69(e)]);
1785
1784
  }
1786
1785
  };
1787
1786
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1791,7 +1790,7 @@ function ListRow({
1791
1790
  role: "button",
1792
1791
  tabIndex: disabled ? -1 : 0,
1793
1792
  "aria-disabled": disabled || void 0,
1794
- onClick: disabled ? void 0 : (e) => _optionalChain([onClick, 'optionalCall', _67 => _67(e)]),
1793
+ onClick: disabled ? void 0 : (e) => _optionalChain([onClick, 'optionalCall', _70 => _70(e)]),
1795
1794
  onKeyDown: handleKey,
1796
1795
  children: inner
1797
1796
  }
@@ -2340,6 +2339,24 @@ function formatBalanceUsd(value) {
2340
2339
  if (!Number.isFinite(value) || value <= 0) return "$0.00";
2341
2340
  return `$${value.toFixed(2)}`;
2342
2341
  }
2342
+ function rankUsd(value) {
2343
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
2344
+ }
2345
+ function rankCryptoRows(descriptors) {
2346
+ return descriptors.map((descriptor, index) => ({ descriptor, index })).sort((a, b) => {
2347
+ const first = a.descriptor;
2348
+ const second = b.descriptor;
2349
+ if (first.isBalanceSource !== second.isBalanceSource) {
2350
+ return first.isBalanceSource ? -1 : 1;
2351
+ }
2352
+ if (!first.isBalanceSource) return a.index - b.index;
2353
+ if (first.resolved !== second.resolved) return first.resolved ? -1 : 1;
2354
+ if (first.resolved && first.balanceUsd !== second.balanceUsd) {
2355
+ return second.balanceUsd - first.balanceUsd;
2356
+ }
2357
+ return a.index - b.index;
2358
+ }).map(({ descriptor }) => descriptor.node);
2359
+ }
2343
2360
  function fiatIcon(name) {
2344
2361
  if (name === "apple") return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AppleIcon, {});
2345
2362
  if (name === "bank") return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BankIcon, {});
@@ -2397,6 +2414,7 @@ function ConnectStep({
2397
2414
  onSelectPayWithCard,
2398
2415
  fiatPaymentMethods,
2399
2416
  onSelectFiatMethod,
2417
+ onPrefetchFiatMethod,
2400
2418
  onSelectFundFromExchange,
2401
2419
  onRequestConnect,
2402
2420
  onConnect,
@@ -2412,11 +2430,23 @@ function ConnectStep({
2412
2430
  const hasReownWallet = rows.some(
2413
2431
  (row) => row.kind === "external" || row.kind === "solana"
2414
2432
  );
2415
- const showDappImports = (_nullishCoalesce(_optionalChain([dappImports, 'optionalAccess', _68 => _68.length]), () => ( 0))) > 0;
2433
+ const showDappImports = (_nullishCoalesce(_optionalChain([dappImports, 'optionalAccess', _71 => _71.length]), () => ( 0))) > 0;
2416
2434
  const defaultSubtitle = onSelectTransferCrypto ? "Add money to your balance" : "Choose a wallet to continue";
2417
- const cryptoRows = [];
2435
+ const cryptoDescriptors = [];
2436
+ const pushAction = (node) => cryptoDescriptors.push({
2437
+ node,
2438
+ isBalanceSource: false,
2439
+ resolved: false,
2440
+ balanceUsd: 0
2441
+ });
2442
+ const pushBalanceSource = (node, resolved, balanceUsd) => cryptoDescriptors.push({
2443
+ node,
2444
+ isBalanceSource: true,
2445
+ resolved,
2446
+ balanceUsd: rankUsd(balanceUsd)
2447
+ });
2418
2448
  if (onSelectTransferCrypto) {
2419
- cryptoRows.push(
2449
+ pushAction(
2420
2450
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2421
2451
  ListRow,
2422
2452
  {
@@ -2432,24 +2462,26 @@ function ConnectStep({
2432
2462
  }
2433
2463
  for (const row of rows) {
2434
2464
  const collapseToExternal = Boolean(onSelectTransferCrypto) && row.kind !== "solana";
2435
- const subtitleText = row.state === "loading" ? "Preparing\u2026" : row.state === "error" ? _nullishCoalesce(row.errorReason, () => ( "Couldn't prepare wallet \u2014 tap to retry")) : shorten(row.address);
2436
- cryptoRows.push(
2465
+ const subtitleText = row.state === "loading" ? "Preparing\u2026" : row.state === "error" ? _nullishCoalesce(row.errorReason, () => ( "Couldn't prepare wallet \u2014 tap to retry")) : row.balanceStatus === "ready" && row.balanceUsd != null ? formatBalanceUsd(row.balanceUsd) : row.balanceStatus === "loading" ? "Checking balance\u2026" : shorten(row.address);
2466
+ pushBalanceSource(
2437
2467
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2438
2468
  ListRow,
2439
2469
  {
2440
2470
  leading: renderWalletLeading(row),
2441
2471
  title: collapseToExternal ? "External wallet" : row.label,
2442
2472
  subtitle: subtitleText,
2443
- onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _69 => _69(row.id)]),
2473
+ onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _72 => _72(row.id)]),
2444
2474
  disabled: row.state === "loading",
2445
2475
  trailing: renderRowTrailing(row.state)
2446
2476
  },
2447
2477
  row.id
2448
- )
2478
+ ),
2479
+ row.balanceStatus === "ready",
2480
+ _nullishCoalesce(row.balanceUsd, () => ( 0))
2449
2481
  );
2450
2482
  }
2451
2483
  if (!hasReownWallet && handleConnect) {
2452
- cryptoRows.push(
2484
+ pushAction(
2453
2485
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2454
2486
  ListRow,
2455
2487
  {
@@ -2464,7 +2496,7 @@ function ConnectStep({
2464
2496
  );
2465
2497
  }
2466
2498
  if (onSelectFundFromExchange) {
2467
- cryptoRows.push(
2499
+ pushAction(
2468
2500
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2469
2501
  ListRow,
2470
2502
  {
@@ -2481,7 +2513,7 @@ function ConnectStep({
2481
2513
  if (showDappImports) {
2482
2514
  for (const row of _nullishCoalesce(dappImports, () => ( []))) {
2483
2515
  if (!hasReownWallet) {
2484
- cryptoRows.push(
2516
+ pushBalanceSource(
2485
2517
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2486
2518
  ListRow,
2487
2519
  {
@@ -2492,12 +2524,14 @@ function ConnectStep({
2492
2524
  disabled: !handleConnect
2493
2525
  },
2494
2526
  row.id
2495
- )
2527
+ ),
2528
+ false,
2529
+ 0
2496
2530
  );
2497
2531
  continue;
2498
2532
  }
2499
2533
  if (row.status === "loading" || row.status === "needs-connect") {
2500
- cryptoRows.push(
2534
+ pushBalanceSource(
2501
2535
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2502
2536
  ListRow,
2503
2537
  {
@@ -2508,41 +2542,47 @@ function ConnectStep({
2508
2542
  trailing: SMALL_SPINNER
2509
2543
  },
2510
2544
  row.id
2511
- )
2545
+ ),
2546
+ false,
2547
+ 0
2512
2548
  );
2513
2549
  continue;
2514
2550
  }
2515
2551
  if (row.status.enabled) {
2516
- cryptoRows.push(
2552
+ pushBalanceSource(
2517
2553
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2518
2554
  ListRow,
2519
2555
  {
2520
2556
  leading: row.icon,
2521
2557
  title: row.label,
2522
2558
  subtitle: formatBalanceUsd(row.status.balanceUsd),
2523
- onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _70 => _70(row.id)])
2559
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _73 => _73(row.id)])
2524
2560
  },
2525
2561
  row.id
2526
- )
2562
+ ),
2563
+ true,
2564
+ row.status.balanceUsd
2527
2565
  );
2528
2566
  continue;
2529
2567
  }
2530
2568
  if (row.status.retryable) {
2531
- cryptoRows.push(
2569
+ pushBalanceSource(
2532
2570
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2533
2571
  ListRow,
2534
2572
  {
2535
2573
  leading: row.icon,
2536
2574
  title: row.label,
2537
2575
  subtitle: row.status.reason,
2538
- onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _71 => _71(row.id)])
2576
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _74 => _74(row.id)])
2539
2577
  },
2540
2578
  row.id
2541
- )
2579
+ ),
2580
+ false,
2581
+ 0
2542
2582
  );
2543
2583
  continue;
2544
2584
  }
2545
- cryptoRows.push(
2585
+ pushBalanceSource(
2546
2586
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2547
2587
  ListRow,
2548
2588
  {
@@ -2552,10 +2592,13 @@ function ConnectStep({
2552
2592
  disabled: true
2553
2593
  },
2554
2594
  row.id
2555
- )
2595
+ ),
2596
+ false,
2597
+ 0
2556
2598
  );
2557
2599
  }
2558
2600
  }
2601
+ const cryptoRows = rankCryptoRows(cryptoDescriptors);
2559
2602
  const cashRows = [];
2560
2603
  if (fiatPaymentMethods && fiatPaymentMethods.length > 0 && onSelectFiatMethod) {
2561
2604
  for (const opt of fiatPaymentMethods) {
@@ -2594,6 +2637,14 @@ function ConnectStep({
2594
2637
  const [tab, setTab] = _react.useState.call(void 0, defaultMethodTab);
2595
2638
  const activeTab = showToggle ? tab : hasCash && !hasCrypto ? "cash" : "crypto";
2596
2639
  const activeRows = activeTab === "cash" ? cashRows : cryptoRows;
2640
+ _react.useEffect.call(void 0, () => {
2641
+ if (activeTab !== "cash" || !onPrefetchFiatMethod || !fiatPaymentMethods) {
2642
+ return;
2643
+ }
2644
+ for (const opt of fiatPaymentMethods) {
2645
+ onPrefetchFiatMethod(opt.method);
2646
+ }
2647
+ }, [activeTab, onPrefetchFiatMethod, fiatPaymentMethods]);
2597
2648
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
2598
2649
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
2599
2650
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -2704,8 +2755,8 @@ function Tooltip({ content, children, className }) {
2704
2755
  function handleOutside(event) {
2705
2756
  const target = event.target;
2706
2757
  if (!target) return;
2707
- if (_optionalChain([triggerRef, 'access', _72 => _72.current, 'optionalAccess', _73 => _73.contains, 'call', _74 => _74(target)])) return;
2708
- if (_optionalChain([bubbleRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.contains, 'call', _77 => _77(target)])) return;
2758
+ if (_optionalChain([triggerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.contains, 'call', _77 => _77(target)])) return;
2759
+ if (_optionalChain([bubbleRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.contains, 'call', _80 => _80(target)])) return;
2709
2760
  setOpen(false);
2710
2761
  }
2711
2762
  function handleKey(event) {
@@ -2872,7 +2923,7 @@ function asNumber(value) {
2872
2923
  const trimmed = value.trim();
2873
2924
  if (!trimmed) return void 0;
2874
2925
  const caipMatch = trimmed.match(/^eip155:(\d+)$/);
2875
- if (_optionalChain([caipMatch, 'optionalAccess', _78 => _78[1]])) {
2926
+ if (_optionalChain([caipMatch, 'optionalAccess', _81 => _81[1]])) {
2876
2927
  const parsed2 = Number(caipMatch[1]);
2877
2928
  return Number.isFinite(parsed2) ? parsed2 : void 0;
2878
2929
  }
@@ -2891,23 +2942,19 @@ function asAddress(value) {
2891
2942
  return /^0x[a-fA-F0-9]{40}$/.test(value) ? value : void 0;
2892
2943
  }
2893
2944
  function getEventTxHash(event) {
2894
- if (!_optionalChain([event, 'optionalAccess', _79 => _79.type])) return void 0;
2945
+ if (!_optionalChain([event, 'optionalAccess', _82 => _82.type])) return void 0;
2895
2946
  if (event.type === "deposit-received") {
2896
- return asString(_optionalChain([event, 'access', _80 => _80.data, 'optionalAccess', _81 => _81.transactionHash]));
2947
+ return asString(_optionalChain([event, 'access', _83 => _83.data, 'optionalAccess', _84 => _84.transactionHash]));
2897
2948
  }
2898
2949
  if (event.type === "bridge-started" || event.type === "bridge-complete") {
2899
- const deposit = isRecord(_optionalChain([event, 'access', _82 => _82.data, 'optionalAccess', _83 => _83.deposit])) ? event.data.deposit : void 0;
2900
- const source = isRecord(_optionalChain([event, 'access', _84 => _84.data, 'optionalAccess', _85 => _85.source])) ? event.data.source : void 0;
2901
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _86 => _86.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _87 => _87.transactionHash]))));
2950
+ const deposit = isRecord(_optionalChain([event, 'access', _85 => _85.data, 'optionalAccess', _86 => _86.deposit])) ? event.data.deposit : void 0;
2951
+ const source = isRecord(_optionalChain([event, 'access', _87 => _87.data, 'optionalAccess', _88 => _88.source])) ? event.data.source : void 0;
2952
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _89 => _89.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _90 => _90.transactionHash]))));
2902
2953
  }
2903
2954
  if (event.type === "bridge-failed" || event.type === "error") {
2904
- const deposit = isRecord(_optionalChain([event, 'access', _88 => _88.data, 'optionalAccess', _89 => _89.deposit])) ? event.data.deposit : void 0;
2905
- const source = isRecord(_optionalChain([event, 'access', _90 => _90.data, 'optionalAccess', _91 => _91.source])) ? event.data.source : void 0;
2906
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _92 => _92.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _93 => _93.transactionHash]))));
2907
- }
2908
- if (event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
2909
- const deposit = isRecord(_optionalChain([event, 'access', _94 => _94.data, 'optionalAccess', _95 => _95.deposit])) ? event.data.deposit : void 0;
2910
- return asString(_optionalChain([deposit, 'optionalAccess', _96 => _96.transactionHash]));
2955
+ const deposit = isRecord(_optionalChain([event, 'access', _91 => _91.data, 'optionalAccess', _92 => _92.deposit])) ? event.data.deposit : void 0;
2956
+ const source = isRecord(_optionalChain([event, 'access', _93 => _93.data, 'optionalAccess', _94 => _94.source])) ? event.data.source : void 0;
2957
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _95 => _95.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _96 => _96.transactionHash]))));
2911
2958
  }
2912
2959
  return void 0;
2913
2960
  }
@@ -2922,7 +2969,7 @@ function getEventSourceDetails(event) {
2922
2969
  }
2923
2970
  const source = isRecord(event.data.source) ? event.data.source : void 0;
2924
2971
  const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
2925
- if (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error" || event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
2972
+ if (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error") {
2926
2973
  return {
2927
2974
  chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _98 => _98.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _99 => _99.chain])))),
2928
2975
  amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _100 => _100.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _101 => _101.amount])))),
@@ -2939,7 +2986,7 @@ function asChain(value) {
2939
2986
  }
2940
2987
  function getEventDestinationDetails(event) {
2941
2988
  if (!_optionalChain([event, 'optionalAccess', _105 => _105.type]) || !isRecord(event.data)) return {};
2942
- if (event.type !== "bridge-started" && event.type !== "bridge-complete" && event.type !== "post-bridge-swap-complete") {
2989
+ if (event.type !== "bridge-started" && event.type !== "bridge-complete") {
2943
2990
  return {};
2944
2991
  }
2945
2992
  const destination = isRecord(event.data.destination) ? event.data.destination : void 0;
@@ -2952,10 +2999,10 @@ function getEventDestinationDetails(event) {
2952
2999
  };
2953
3000
  }
2954
3001
  function isDepositEvent(event) {
2955
- return _optionalChain([event, 'optionalAccess', _108 => _108.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _109 => _109.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _110 => _110.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _111 => _111.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _112 => _112.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _113 => _113.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _114 => _114.type]) === "error";
3002
+ return _optionalChain([event, 'optionalAccess', _108 => _108.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _109 => _109.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _110 => _110.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _111 => _111.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _112 => _112.type]) === "error";
2956
3003
  }
2957
3004
  function isFailedEvent(event) {
2958
- return _optionalChain([event, 'optionalAccess', _115 => _115.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _116 => _116.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _117 => _117.type]) === "error";
3005
+ return _optionalChain([event, 'optionalAccess', _113 => _113.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _114 => _114.type]) === "error";
2959
3006
  }
2960
3007
  function isHexString(value) {
2961
3008
  return value.startsWith("0x") || value.startsWith("0X");
@@ -2967,7 +3014,7 @@ function txRefsMatch(a, b) {
2967
3014
  return a === b;
2968
3015
  }
2969
3016
  function formatBridgeFailedMessage(event) {
2970
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _118 => _118.data]), () => ( {}));
3017
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _115 => _115.data]), () => ( {}));
2971
3018
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
2972
3019
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
2973
3020
  function toUserFacingFailure(raw) {
@@ -2995,7 +3042,7 @@ function formatBridgeFailedMessage(event) {
2995
3042
  return { message: "Bridge failed" };
2996
3043
  }
2997
3044
  function failureMessageForEvent(event) {
2998
- if (_optionalChain([event, 'optionalAccess', _119 => _119.type]) === "error") {
3045
+ if (_optionalChain([event, 'optionalAccess', _116 => _116.type]) === "error") {
2999
3046
  const message = isRecord(event.data) ? asString(event.data.message) : void 0;
3000
3047
  return _nullishCoalesce(message, () => ( "Unknown error"));
3001
3048
  }
@@ -3032,15 +3079,15 @@ function resolveTokenDisplay(token, chain, fallback) {
3032
3079
  const decimals = _chunkABVRVW3Pcjs.findTokenDecimals.call(void 0, token, chain);
3033
3080
  if (symbol !== "Token" || decimals !== void 0) {
3034
3081
  return {
3035
- symbol: symbol !== "Token" ? symbol : _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _120 => _120.symbol]), () => ( symbol)),
3036
- decimals: _nullishCoalesce(decimals, () => ( _optionalChain([fallback, 'optionalAccess', _121 => _121.decimals])))
3082
+ symbol: symbol !== "Token" ? symbol : _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _117 => _117.symbol]), () => ( symbol)),
3083
+ decimals: _nullishCoalesce(decimals, () => ( _optionalChain([fallback, 'optionalAccess', _118 => _118.decimals])))
3037
3084
  };
3038
3085
  }
3039
3086
  }
3040
3087
  }
3041
3088
  return {
3042
- symbol: _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _122 => _122.symbol]), () => ( "Token")),
3043
- decimals: _optionalChain([fallback, 'optionalAccess', _123 => _123.decimals])
3089
+ symbol: _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _119 => _119.symbol]), () => ( "Token")),
3090
+ decimals: _optionalChain([fallback, 'optionalAccess', _120 => _120.decimals])
3044
3091
  };
3045
3092
  }
3046
3093
  function maxFractionDigitsFor(symbol) {
@@ -3263,16 +3310,16 @@ function isEventForTx(event, txHash) {
3263
3310
  return txRefsMatch(eventTxHash, txHash);
3264
3311
  }
3265
3312
  function parseWebhookTimestamp(event) {
3266
- if (typeof _optionalChain([event, 'optionalAccess', _124 => _124.time]) !== "string") return void 0;
3313
+ if (typeof _optionalChain([event, 'optionalAccess', _121 => _121.time]) !== "string") return void 0;
3267
3314
  const timestamp = Date.parse(event.time);
3268
3315
  return Number.isFinite(timestamp) ? timestamp : void 0;
3269
3316
  }
3270
3317
  function syncPhaseTimings(previous, event) {
3271
- if (!_optionalChain([event, 'optionalAccess', _125 => _125.type])) return previous;
3318
+ if (!_optionalChain([event, 'optionalAccess', _122 => _122.type])) return previous;
3272
3319
  const timestamp = _nullishCoalesce(parseWebhookTimestamp(event), () => ( Date.now()));
3273
- const setReceived = (event.type === "deposit-received" || event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed" || event.type === "error") && previous.receivedAt === void 0;
3274
- const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.bridgingAt === void 0;
3275
- const setCompleted = (event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.completedAt === void 0;
3320
+ const setReceived = (event.type === "deposit-received" || event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error") && previous.receivedAt === void 0;
3321
+ const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete") && previous.bridgingAt === void 0;
3322
+ const setCompleted = event.type === "bridge-complete" && previous.completedAt === void 0;
3276
3323
  if (!setReceived && !setBridging && !setCompleted) return previous;
3277
3324
  return {
3278
3325
  ...previous,
@@ -3330,9 +3377,9 @@ function getCurrentPhaseId(state, phaseTimings) {
3330
3377
  if (state.type === "complete") {
3331
3378
  return void 0;
3332
3379
  }
3333
- if (_optionalChain([state, 'access', _126 => _126.lastEvent, 'optionalAccess', _127 => _127.type]) === "bridge-started" || _optionalChain([state, 'access', _128 => _128.lastEvent, 'optionalAccess', _129 => _129.type]) === "bridge-complete")
3380
+ if (_optionalChain([state, 'access', _123 => _123.lastEvent, 'optionalAccess', _124 => _124.type]) === "bridge-started" || _optionalChain([state, 'access', _125 => _125.lastEvent, 'optionalAccess', _126 => _126.type]) === "bridge-complete")
3334
3381
  return "bridging";
3335
- if (_optionalChain([state, 'access', _130 => _130.lastEvent, 'optionalAccess', _131 => _131.type]) === "deposit-received") return "received";
3382
+ if (_optionalChain([state, 'access', _127 => _127.lastEvent, 'optionalAccess', _128 => _128.type]) === "deposit-received") return "received";
3336
3383
  return "confirming";
3337
3384
  }
3338
3385
  function ProcessingStep({
@@ -3346,7 +3393,6 @@ function ProcessingStep({
3346
3393
  sourceSymbol: providedSourceSymbol,
3347
3394
  sourceDecimals: providedSourceDecimals,
3348
3395
  amountUsd,
3349
- hasPostBridgeActions,
3350
3396
  service,
3351
3397
  directTransfer,
3352
3398
  flowLabel = "deposit",
@@ -3376,8 +3422,7 @@ function ProcessingStep({
3376
3422
  sourceDecimals: providedSourceDecimals,
3377
3423
  amountUsd,
3378
3424
  targetChain,
3379
- targetToken,
3380
- hasPostBridgeActions
3425
+ targetToken
3381
3426
  });
3382
3427
  const onDepositCompleteRef = useLatestRef(onDepositComplete);
3383
3428
  const onDepositFailedRef = useLatestRef(onDepositFailed);
@@ -3418,7 +3463,7 @@ function ProcessingStep({
3418
3463
  flowLabel
3419
3464
  });
3420
3465
  const context = processingContextRef.current;
3421
- _optionalChain([onDepositCompleteRef, 'access', _132 => _132.current, 'optionalCall', _133 => _133(txHash, void 0, {
3466
+ _optionalChain([onDepositCompleteRef, 'access', _129 => _129.current, 'optionalCall', _130 => _130(txHash, void 0, {
3422
3467
  amount: context.amount,
3423
3468
  sourceChain: context.sourceChain,
3424
3469
  sourceToken: context.sourceToken,
@@ -3460,7 +3505,7 @@ function ProcessingStep({
3460
3505
  updatePhaseTimings(
3461
3506
  (previous) => syncPhaseTimings(previous, state.lastEvent)
3462
3507
  );
3463
- }, [_optionalChain([state, 'access', _134 => _134.lastEvent, 'optionalAccess', _135 => _135.time]), _optionalChain([state, 'access', _136 => _136.lastEvent, 'optionalAccess', _137 => _137.type]), updatePhaseTimings]);
3508
+ }, [_optionalChain([state, 'access', _131 => _131.lastEvent, 'optionalAccess', _132 => _132.time]), _optionalChain([state, 'access', _133 => _133.lastEvent, 'optionalAccess', _134 => _134.type]), updatePhaseTimings]);
3464
3509
  const [swappedFiatContext, setSwappedFiatContext] = _react.useState.call(void 0, null);
3465
3510
  _react.useEffect.call(void 0, () => {
3466
3511
  let cancelled = false;
@@ -3468,7 +3513,7 @@ function ProcessingStep({
3468
3513
  if (cancelled || !res) return;
3469
3514
  if (res.transactionId != null) {
3470
3515
  if (res.transactionId.toLowerCase() !== txHash.toLowerCase()) return;
3471
- } else if (!isSwappedOrder || _optionalChain([swappedContext, 'optionalAccess', _138 => _138.variant]) === "connect") {
3516
+ } else if (!isSwappedOrder || _optionalChain([swappedContext, 'optionalAccess', _135 => _135.variant]) === "connect") {
3472
3517
  return;
3473
3518
  }
3474
3519
  setSwappedFiatContext({
@@ -3484,7 +3529,7 @@ function ProcessingStep({
3484
3529
  return () => {
3485
3530
  cancelled = true;
3486
3531
  };
3487
- }, [service, smartAccount, txHash, isSwappedOrder, _optionalChain([swappedContext, 'optionalAccess', _139 => _139.variant])]);
3532
+ }, [service, smartAccount, txHash, isSwappedOrder, _optionalChain([swappedContext, 'optionalAccess', _136 => _136.variant])]);
3488
3533
  _react.useEffect.call(void 0, () => {
3489
3534
  if (directTransfer) return;
3490
3535
  if (state.type !== "processing") {
@@ -3509,56 +3554,20 @@ function ProcessingStep({
3509
3554
  debugLog(debug, "processing", "poll:event", {
3510
3555
  type: lastEvent2.type,
3511
3556
  matchesTx: eventMatchesTx,
3512
- intentId: _optionalChain([eventData, 'optionalAccess', _140 => _140.intentId])
3557
+ intentId: _optionalChain([eventData, 'optionalAccess', _137 => _137.intentId])
3513
3558
  });
3514
3559
  }
3515
3560
  if (!isMounted) return;
3516
- const awaitingPostBridgeSwap = processingContextRef.current.hasPostBridgeActions;
3517
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _141 => _141.type]) === "post-bridge-swap-complete") {
3518
- setState({ type: "complete", lastEvent: eventForCurrentTx });
3519
- const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _142 => _142.data, 'optionalAccess', _143 => _143.swap, 'optionalAccess', _144 => _144.transactionHash]);
3520
- debugLog(debug, "processing", "state:complete", {
3521
- txHash,
3522
- destinationTxHash: swapTxHash,
3523
- event: eventForCurrentTx.type
3524
- });
3525
- const context = processingContextRef.current;
3526
- _optionalChain([onDepositCompleteRef, 'access', _145 => _145.current, 'optionalCall', _146 => _146(txHash, swapTxHash, {
3527
- amount: context.amount,
3528
- sourceChain: context.sourceChain,
3529
- sourceToken: context.sourceToken,
3530
- sourceDecimals: context.sourceDecimals,
3531
- amountUsd: context.amountUsd,
3532
- targetChain: context.targetChain,
3533
- targetToken: context.targetToken
3534
- })]);
3535
- return;
3536
- }
3537
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _147 => _147.type]) === "post-bridge-swap-failed") {
3538
- const formatted = formatBridgeFailedMessage(eventForCurrentTx);
3539
- setState({
3540
- type: "failed",
3541
- message: formatted.message,
3542
- lastEvent: eventForCurrentTx
3543
- });
3544
- debugLog(debug, "processing", "state:failed", {
3545
- txHash,
3546
- message: formatted.message,
3547
- code: formatted.code
3548
- });
3549
- _optionalChain([onDepositFailedRef, 'access', _148 => _148.current, 'optionalCall', _149 => _149(txHash, formatted.message)]);
3550
- return;
3551
- }
3552
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _150 => _150.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
3561
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _138 => _138.type]) === "bridge-complete") {
3553
3562
  setState({ type: "complete", lastEvent: eventForCurrentTx });
3554
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _151 => _151.data, 'optionalAccess', _152 => _152.destination, 'optionalAccess', _153 => _153.transactionHash]);
3563
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _139 => _139.data, 'optionalAccess', _140 => _140.destination, 'optionalAccess', _141 => _141.transactionHash]);
3555
3564
  debugLog(debug, "processing", "state:complete", {
3556
3565
  txHash,
3557
3566
  destinationTxHash: destinationTxHash2,
3558
3567
  event: eventForCurrentTx.type
3559
3568
  });
3560
3569
  const context = processingContextRef.current;
3561
- _optionalChain([onDepositCompleteRef, 'access', _154 => _154.current, 'optionalCall', _155 => _155(txHash, destinationTxHash2, {
3570
+ _optionalChain([onDepositCompleteRef, 'access', _142 => _142.current, 'optionalCall', _143 => _143(txHash, destinationTxHash2, {
3562
3571
  amount: context.amount,
3563
3572
  sourceChain: context.sourceChain,
3564
3573
  sourceToken: context.sourceToken,
@@ -3569,7 +3578,7 @@ function ProcessingStep({
3569
3578
  })]);
3570
3579
  return;
3571
3580
  }
3572
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _156 => _156.type]) === "bridge-failed") {
3581
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _144 => _144.type]) === "bridge-failed") {
3573
3582
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
3574
3583
  setState({
3575
3584
  type: "failed",
@@ -3581,11 +3590,11 @@ function ProcessingStep({
3581
3590
  message: formatted.message,
3582
3591
  code: formatted.code
3583
3592
  });
3584
- _optionalChain([onDepositFailedRef, 'access', _157 => _157.current, 'optionalCall', _158 => _158(txHash, formatted.message)]);
3593
+ _optionalChain([onDepositFailedRef, 'access', _145 => _145.current, 'optionalCall', _146 => _146(txHash, formatted.message)]);
3585
3594
  return;
3586
3595
  }
3587
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _159 => _159.type]) === "error") {
3588
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _160 => _160.data, 'optionalAccess', _161 => _161.message]), () => ( "Unknown error"));
3596
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _147 => _147.type]) === "error") {
3597
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _148 => _148.data, 'optionalAccess', _149 => _149.message]), () => ( "Unknown error"));
3589
3598
  setState({
3590
3599
  type: "failed",
3591
3600
  message: errorMessage,
@@ -3595,7 +3604,7 @@ function ProcessingStep({
3595
3604
  txHash,
3596
3605
  message: errorMessage
3597
3606
  });
3598
- _optionalChain([onDepositFailedRef, 'access', _162 => _162.current, 'optionalCall', _163 => _163(txHash, errorMessage)]);
3607
+ _optionalChain([onDepositFailedRef, 'access', _150 => _150.current, 'optionalCall', _151 => _151(txHash, errorMessage)]);
3599
3608
  return;
3600
3609
  }
3601
3610
  setState((previous) => ({
@@ -3656,7 +3665,7 @@ function ProcessingStep({
3656
3665
  txHash,
3657
3666
  timeoutMs: ESCALATED_DELAY_MS
3658
3667
  });
3659
- _optionalChain([onErrorRef, 'access', _164 => _164.current, 'optionalCall', _165 => _165(message, "PROCESS_TIMEOUT")]);
3668
+ _optionalChain([onErrorRef, 'access', _152 => _152.current, 'optionalCall', _153 => _153(message, "PROCESS_TIMEOUT")]);
3660
3669
  }, ESCALATED_DELAY_MS);
3661
3670
  return () => clearTimeout(timeoutId);
3662
3671
  }, [debug, directTransfer, onErrorRef, state.type, txHash]);
@@ -3668,8 +3677,7 @@ function ProcessingStep({
3668
3677
  const timelineNowMs = _nullishCoalesce(phaseTimings.endedAt, () => ( Date.now()));
3669
3678
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
3670
3679
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
3671
- const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _166 => _166.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _167 => _167.type]) === "post-bridge-swap-failed";
3672
- const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _168 => _168.data, 'optionalAccess', _169 => _169.swap, 'optionalAccess', _170 => _170.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _171 => _171.data, 'optionalAccess', _172 => _172.destination, 'optionalAccess', _173 => _173.transactionHash]) || null;
3680
+ const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _154 => _154.data, 'optionalAccess', _155 => _155.destination, 'optionalAccess', _156 => _156.transactionHash]) || null;
3673
3681
  const sourceDetails = getEventSourceDetails(lastEvent);
3674
3682
  const displaySourceChain = _nullishCoalesce(sourceDetails.chainId, () => ( sourceChain));
3675
3683
  const displaySourceToken = _nullishCoalesce(sourceDetails.token, () => ( sourceToken));
@@ -3689,8 +3697,7 @@ function ProcessingStep({
3689
3697
  const sourceSymbol = sourceDisplay.symbol;
3690
3698
  const formattedSentAmount = _nullishCoalesce(_nullishCoalesce(formatRawTokenAmount(displayAmount, sourceDisplay), () => ( // Not raw base units (e.g. a decimal string) — render the number as-is.
3691
3699
  formatTokenAmount(Number(displayAmount), sourceDisplay.symbol))), () => ( displayAmount));
3692
- const isBridgeHopDestination = hasPostBridgeActions && (_optionalChain([lastEvent, 'optionalAccess', _174 => _174.type]) === "bridge-started" || _optionalChain([lastEvent, 'optionalAccess', _175 => _175.type]) === "bridge-complete");
3693
- const eventDestination = isBridgeHopDestination ? {} : getEventDestinationDetails(lastEvent);
3700
+ const eventDestination = getEventDestinationDetails(lastEvent);
3694
3701
  const targetDisplay = resolveTokenDisplay(
3695
3702
  _nullishCoalesce(eventDestination.token, () => ( targetToken)),
3696
3703
  _nullishCoalesce(eventDestination.chainId, () => ( targetChain)),
@@ -3748,8 +3755,8 @@ function ProcessingStep({
3748
3755
  const sourceChainName = _chunkABVRVW3Pcjs.getChainName.call(void 0, displaySourceChain);
3749
3756
  const targetChainName = _chunkABVRVW3Pcjs.getChainName.call(void 0, targetChain);
3750
3757
  const timerText = formatTimer(elapsedSeconds);
3751
- const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _176 => _176.feeSponsored]), () => ( false));
3752
- const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _177 => _177.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
3758
+ const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _157 => _157.feeSponsored]), () => ( false));
3759
+ const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _158 => _158.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
3753
3760
  const stateTitle = isComplete ? `${flowCapitalized} successful` : isFailed ? `${flowCapitalized} failed` : "Processing...";
3754
3761
  const handleRetry = _nullishCoalesce(onRetry, () => ( onNewDeposit));
3755
3762
  const headerContent = isComplete ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-body-header", children: [
@@ -3760,16 +3767,16 @@ function ProcessingStep({
3760
3767
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-body-header-text", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "rs-body-header-title", children: stateTitle }) })
3761
3768
  ] }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BodyHeader, { icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WalletIcon, {}), title: stateTitle });
3762
3769
  if (isComplete && isSwappedOrder) {
3763
- const effectivePaymentMethod = _nullishCoalesce(_nullishCoalesce(_optionalChain([swappedContext, 'optionalAccess', _178 => _178.method]), () => ( _optionalChain([swappedFiatContext, 'optionalAccess', _179 => _179.paymentMethod]))), () => ( null));
3770
+ const effectivePaymentMethod = _nullishCoalesce(_nullishCoalesce(_optionalChain([swappedContext, 'optionalAccess', _159 => _159.method]), () => ( _optionalChain([swappedFiatContext, 'optionalAccess', _160 => _160.paymentMethod]))), () => ( null));
3764
3771
  const onrampMethod = effectivePaymentMethod ? formatPaymentMethod(effectivePaymentMethod) : null;
3765
- const onrampMethodIcon = _optionalChain([swappedContext, 'optionalAccess', _180 => _180.variant]) === "connect" && effectivePaymentMethod ? getExchangeLogoSrc(
3772
+ const onrampMethodIcon = _optionalChain([swappedContext, 'optionalAccess', _161 => _161.variant]) === "connect" && effectivePaymentMethod ? getExchangeLogoSrc(
3766
3773
  _nullishCoalesce(onrampMethod, () => ( effectivePaymentMethod)),
3767
3774
  effectivePaymentMethod
3768
3775
  ) : null;
3769
- const connectPaidAmount = _optionalChain([swappedContext, 'optionalAccess', _181 => _181.variant]) === "connect" ? `${formattedSentAmount} ${sourceSymbol}` : null;
3770
- const amountPaid = _nullishCoalesce(connectPaidAmount, () => ( (_optionalChain([swappedFiatContext, 'optionalAccess', _182 => _182.paidAmountUsd]) != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null)));
3776
+ const connectPaidAmount = _optionalChain([swappedContext, 'optionalAccess', _162 => _162.variant]) === "connect" ? `${formattedSentAmount} ${sourceSymbol}` : null;
3777
+ const amountPaid = _nullishCoalesce(connectPaidAmount, () => ( (_optionalChain([swappedFiatContext, 'optionalAccess', _163 => _163.paidAmountUsd]) != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null)));
3771
3778
  const depositedAmount = receiveDisplay;
3772
- const onrampFeeUsd = _nullishCoalesce(_optionalChain([swappedFiatContext, 'optionalAccess', _183 => _183.onrampFeeUsd]), () => ( null));
3779
+ const onrampFeeUsd = _nullishCoalesce(_optionalChain([swappedFiatContext, 'optionalAccess', _164 => _164.onrampFeeUsd]), () => ( null));
3773
3780
  const networkFeeUsd = quotedFeeAmount !== void 0 && Number.isFinite(Number(quotedFeeAmount)) ? Number(quotedFeeAmount) : null;
3774
3781
  const feeRows = [];
3775
3782
  if (onrampFeeUsd != null) {
@@ -3846,7 +3853,7 @@ function ProcessingStep({
3846
3853
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-review-detail-value", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Ticker, { value: timerText }) })
3847
3854
  ] }),
3848
3855
  isSwappedOrder ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3849
- _optionalChain([swappedFiatContext, 'optionalAccess', _184 => _184.paidAmountUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3856
+ _optionalChain([swappedFiatContext, 'optionalAccess', _165 => _165.paidAmountUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3850
3857
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "You pay" }),
3851
3858
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-review-detail-value", children: [
3852
3859
  "$",
@@ -3858,7 +3865,7 @@ function ProcessingStep({
3858
3865
  ] })
3859
3866
  ] })
3860
3867
  ] }),
3861
- _optionalChain([swappedFiatContext, 'optionalAccess', _185 => _185.onrampFeeUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3868
+ _optionalChain([swappedFiatContext, 'optionalAccess', _166 => _166.onrampFeeUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3862
3869
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "On-ramp fee" }),
3863
3870
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-review-detail-value", children: [
3864
3871
  "$",