@rhinestone/deposit-modal 0.3.0-alpha.16 → 0.3.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsupportedChainSwitchError
3
- } from "./chunk-Z7OJPEV2.mjs";
3
+ } from "./chunk-H2FI4RN7.mjs";
4
4
  import {
5
5
  SUPPORTED_CHAINS,
6
6
  getChainName
@@ -968,6 +968,44 @@ function createDepositService(baseUrl, options) {
968
968
  });
969
969
  return result;
970
970
  },
971
+ async getQuotePreview(params) {
972
+ const url = apiUrl("/quotes/preview");
973
+ const body = {
974
+ account: params.account,
975
+ sourceChainId: `eip155:${params.sourceChainId}`,
976
+ sourceToken: params.sourceToken,
977
+ amount: params.amount
978
+ };
979
+ debugLog(debug, scope, "getQuotePreview:request", {
980
+ url,
981
+ sourceChainId: body.sourceChainId,
982
+ sourceToken: params.sourceToken,
983
+ amount: params.amount
984
+ });
985
+ try {
986
+ const response = await fetch(url, {
987
+ method: "POST",
988
+ headers: { "Content-Type": "application/json" },
989
+ body: JSON.stringify(body),
990
+ cache: "no-store"
991
+ });
992
+ if (!response.ok) {
993
+ debugLog(debug, scope, "getQuotePreview:unavailable", {
994
+ status: response.status
995
+ });
996
+ return null;
997
+ }
998
+ const quote = await response.json();
999
+ debugLog(debug, scope, "getQuotePreview:success", {
1000
+ settlementLayer: quote.settlementLayer,
1001
+ totalUsd: quote.fees?.totalUsd
1002
+ });
1003
+ return quote;
1004
+ } catch (error) {
1005
+ debugError(debug, scope, "getQuotePreview:error", error);
1006
+ return null;
1007
+ }
1008
+ },
971
1009
  async fetchPrices(symbols) {
972
1010
  const list = symbols.filter((s) => s.length > 0);
973
1011
  if (list.length === 0) return {};
@@ -968,6 +968,44 @@ function createDepositService(baseUrl, options) {
968
968
  });
969
969
  return result;
970
970
  },
971
+ async getQuotePreview(params) {
972
+ const url = apiUrl("/quotes/preview");
973
+ const body = {
974
+ account: params.account,
975
+ sourceChainId: `eip155:${params.sourceChainId}`,
976
+ sourceToken: params.sourceToken,
977
+ amount: params.amount
978
+ };
979
+ debugLog(debug, scope, "getQuotePreview:request", {
980
+ url,
981
+ sourceChainId: body.sourceChainId,
982
+ sourceToken: params.sourceToken,
983
+ amount: params.amount
984
+ });
985
+ try {
986
+ const response = await fetch(url, {
987
+ method: "POST",
988
+ headers: { "Content-Type": "application/json" },
989
+ body: JSON.stringify(body),
990
+ cache: "no-store"
991
+ });
992
+ if (!response.ok) {
993
+ debugLog(debug, scope, "getQuotePreview:unavailable", {
994
+ status: response.status
995
+ });
996
+ return null;
997
+ }
998
+ const quote = await response.json();
999
+ debugLog(debug, scope, "getQuotePreview:success", {
1000
+ settlementLayer: quote.settlementLayer,
1001
+ totalUsd: _optionalChain([quote, 'access', _24 => _24.fees, 'optionalAccess', _25 => _25.totalUsd])
1002
+ });
1003
+ return quote;
1004
+ } catch (error) {
1005
+ debugError(debug, scope, "getQuotePreview:error", error);
1006
+ return null;
1007
+ }
1008
+ },
971
1009
  async fetchPrices(symbols) {
972
1010
  const list = symbols.filter((s) => s.length > 0);
973
1011
  if (list.length === 0) return {};
@@ -1146,16 +1184,16 @@ function createDepositService(baseUrl, options) {
1146
1184
  }
1147
1185
  function normalizeDirectPortfolio(data) {
1148
1186
  const rawTokens = _nullishCoalesce(_nullishCoalesce(extractArray(data, "tokens"), () => ( extractArray(
1149
- _optionalChain([data, 'optionalAccess', _24 => _24.data]),
1187
+ _optionalChain([data, 'optionalAccess', _26 => _26.data]),
1150
1188
  "tokens"
1151
1189
  ))), () => ( []));
1152
- const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _25 => _25.data]), "totalUsd"))), () => ( 0));
1190
+ const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _27 => _27.data]), "totalUsd"))), () => ( 0));
1153
1191
  const tokens = rawTokens.map((token) => normalizeDirectToken(token)).filter((token) => Boolean(token));
1154
1192
  return { tokens, totalUsd };
1155
1193
  }
1156
1194
  function extractOrchestratorPortfolio(data) {
1157
1195
  const portfolio = _nullishCoalesce(extractArray(data, "portfolio"), () => ( extractArray(
1158
- _optionalChain([data, 'optionalAccess', _26 => _26.data]),
1196
+ _optionalChain([data, 'optionalAccess', _28 => _28.data]),
1159
1197
  "portfolio"
1160
1198
  )));
1161
1199
  if (!portfolio || !Array.isArray(portfolio)) return null;
@@ -1166,7 +1204,7 @@ function normalizeOrchestratorPortfolio(data) {
1166
1204
  for (const tokenData of data.portfolio || []) {
1167
1205
  const chainBalances = _nullishCoalesce(_nullishCoalesce(tokenData.tokenChainBalance, () => ( tokenData.chainBalances)), () => ( []));
1168
1206
  for (const chainBalance of chainBalances) {
1169
- const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _27 => _27.balance, 'optionalAccess', _28 => _28.unlocked]), () => ( "0"));
1207
+ const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _29 => _29.balance, 'optionalAccess', _30 => _30.unlocked]), () => ( "0"));
1170
1208
  const normalizedName = tokenData.tokenName.trim();
1171
1209
  const isNativeSymbol = normalizedName.toUpperCase() === "ETH" || normalizedName.toUpperCase() === "ETHER";
1172
1210
  const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkMILJQWPTcjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
@@ -1200,7 +1238,7 @@ function normalizeDirectToken(token) {
1200
1238
  if (chainId === null) return null;
1201
1239
  const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "symbol"), () => ( extractString(token, "tokenSymbol"))), () => ( extractString(token, "tokenName"))), () => ( extractString(token, "name")));
1202
1240
  if (!symbol) return null;
1203
- const balanceValue = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "balance"), () => ( extractString(token, "amount"))), () => ( extractString(token, "value"))), () => ( extractString(token, "rawBalance"))), () => ( _optionalChain([extractNumber, 'call', _29 => _29(token, "balance"), 'optionalAccess', _30 => _30.toString, 'call', _31 => _31()]))), () => ( _optionalChain([extractNumber, 'call', _32 => _32(token, "amount"), 'optionalAccess', _33 => _33.toString, 'call', _34 => _34()]))), () => ( _optionalChain([extractNumber, 'call', _35 => _35(token, "value"), 'optionalAccess', _36 => _36.toString, 'call', _37 => _37()]))), () => ( _optionalChain([extractNumber, 'call', _38 => _38(token, "rawBalance"), 'optionalAccess', _39 => _39.toString, 'call', _40 => _40()])));
1241
+ 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()])));
1204
1242
  if (!balanceValue) return null;
1205
1243
  const address = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "address"), () => ( extractString(token, "tokenAddress"))), () => ( extractString(
1206
1244
  token.token,
@@ -1225,7 +1263,7 @@ function normalizeDirectToken(token) {
1225
1263
  }
1226
1264
  function extractTokenAddress(tokenData, chainId) {
1227
1265
  const token = tokenData;
1228
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _41 => _41.addresses, 'optionalAccess', _42 => _42[chainId]]))), () => ( _optionalChain([token, 'access', _43 => _43.token, 'optionalAccess', _44 => _44.address]))), () => ( _optionalChain([token, 'access', _45 => _45.token, 'optionalAccess', _46 => _46.addresses, 'optionalAccess', _47 => _47[chainId]])));
1266
+ 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]])));
1229
1267
  }
1230
1268
  function extractArray(data, key) {
1231
1269
  if (!data || typeof data !== "object") return null;
@@ -1453,19 +1491,19 @@ var CUSTOM_PRIMARY_VARS = [
1453
1491
  function applyTheme(element, theme) {
1454
1492
  if (!element) return;
1455
1493
  const parent = element.parentElement;
1456
- const targets = _optionalChain([parent, 'optionalAccess', _48 => _48.classList, 'access', _49 => _49.contains, 'call', _50 => _50("rs-modal-content")]) ? [element, parent] : [element];
1457
- if (_optionalChain([theme, 'optionalAccess', _51 => _51.mode])) {
1494
+ const targets = _optionalChain([parent, 'optionalAccess', _50 => _50.classList, 'access', _51 => _51.contains, 'call', _52 => _52("rs-modal-content")]) ? [element, parent] : [element];
1495
+ if (_optionalChain([theme, 'optionalAccess', _53 => _53.mode])) {
1458
1496
  for (const t of targets) t.setAttribute("data-theme", theme.mode);
1459
1497
  } else {
1460
1498
  for (const t of targets) t.removeAttribute("data-theme");
1461
1499
  }
1462
- if (_optionalChain([theme, 'optionalAccess', _52 => _52.fontColor])) {
1500
+ if (_optionalChain([theme, 'optionalAccess', _54 => _54.fontColor])) {
1463
1501
  setVar(targets, "--rs-foreground", theme.fontColor);
1464
1502
  }
1465
- if (_optionalChain([theme, 'optionalAccess', _53 => _53.iconColor])) {
1503
+ if (_optionalChain([theme, 'optionalAccess', _55 => _55.iconColor])) {
1466
1504
  setVar(targets, "--rs-icon", theme.iconColor);
1467
1505
  }
1468
- if (_optionalChain([theme, 'optionalAccess', _54 => _54.ctaColor])) {
1506
+ if (_optionalChain([theme, 'optionalAccess', _56 => _56.ctaColor])) {
1469
1507
  const derived = deriveCustomPrimary(theme.ctaColor);
1470
1508
  if (derived) {
1471
1509
  setVar(targets, "--rs-primary", derived.base);
@@ -1490,18 +1528,18 @@ function applyTheme(element, theme) {
1490
1528
  }
1491
1529
  } else {
1492
1530
  for (const v of CUSTOM_PRIMARY_VARS) clearVar(targets, v);
1493
- if (_optionalChain([theme, 'optionalAccess', _55 => _55.ctaHoverColor])) {
1531
+ if (_optionalChain([theme, 'optionalAccess', _57 => _57.ctaHoverColor])) {
1494
1532
  setVar(targets, "--rs-primary-hover", theme.ctaHoverColor);
1495
1533
  }
1496
1534
  }
1497
- if (_optionalChain([theme, 'optionalAccess', _56 => _56.borderColor])) {
1535
+ if (_optionalChain([theme, 'optionalAccess', _58 => _58.borderColor])) {
1498
1536
  setVar(targets, "--rs-border", theme.borderColor);
1499
1537
  setVar(targets, "--rs-border-surface", theme.borderColor);
1500
1538
  }
1501
- if (_optionalChain([theme, 'optionalAccess', _57 => _57.backgroundColor])) {
1539
+ if (_optionalChain([theme, 'optionalAccess', _59 => _59.backgroundColor])) {
1502
1540
  setVar(targets, "--rs-background", theme.backgroundColor);
1503
1541
  }
1504
- if (_optionalChain([theme, 'optionalAccess', _58 => _58.radius])) {
1542
+ if (_optionalChain([theme, 'optionalAccess', _60 => _60.radius])) {
1505
1543
  const scale = RADIUS_SCALE[theme.radius];
1506
1544
  setVar(targets, "--rs-radius-sm", scale.sm);
1507
1545
  setVar(targets, "--rs-radius-md", scale.md);
@@ -1677,7 +1715,7 @@ function ListRow({
1677
1715
  if (disabled) return;
1678
1716
  if (e.key === "Enter" || e.key === " ") {
1679
1717
  e.preventDefault();
1680
- _optionalChain([onClick, 'optionalCall', _59 => _59(e)]);
1718
+ _optionalChain([onClick, 'optionalCall', _61 => _61(e)]);
1681
1719
  }
1682
1720
  };
1683
1721
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1687,7 +1725,7 @@ function ListRow({
1687
1725
  role: "button",
1688
1726
  tabIndex: disabled ? -1 : 0,
1689
1727
  "aria-disabled": disabled || void 0,
1690
- onClick: disabled ? void 0 : (e) => _optionalChain([onClick, 'optionalCall', _60 => _60(e)]),
1728
+ onClick: disabled ? void 0 : (e) => _optionalChain([onClick, 'optionalCall', _62 => _62(e)]),
1691
1729
  onKeyDown: handleKey,
1692
1730
  children: inner
1693
1731
  }
@@ -2091,7 +2129,7 @@ function ConnectStep({
2091
2129
  const hasReownWallet = rows.some(
2092
2130
  (row) => row.kind === "external" || row.kind === "solana"
2093
2131
  );
2094
- const showDappImports = (_nullishCoalesce(_optionalChain([dappImports, 'optionalAccess', _61 => _61.length]), () => ( 0))) > 0;
2132
+ const showDappImports = (_nullishCoalesce(_optionalChain([dappImports, 'optionalAccess', _63 => _63.length]), () => ( 0))) > 0;
2095
2133
  const defaultSubtitle = onSelectTransferCrypto ? "Add money to your balance" : "Choose a wallet to continue";
2096
2134
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen", children: [
2097
2135
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
@@ -2150,7 +2188,7 @@ function ConnectStep({
2150
2188
  leading: renderWalletLeading(row),
2151
2189
  title: collapseToExternal ? "External wallet" : row.label,
2152
2190
  subtitle: subtitleText,
2153
- onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _62 => _62(row.id)]),
2191
+ onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _64 => _64(row.id)]),
2154
2192
  disabled: row.state === "loading",
2155
2193
  trailing: renderRowTrailing(row.state)
2156
2194
  },
@@ -2167,7 +2205,7 @@ function ConnectStep({
2167
2205
  onClick: handleConnect
2168
2206
  }
2169
2207
  ),
2170
- showDappImports && _optionalChain([dappImports, 'optionalAccess', _63 => _63.map, 'call', _64 => _64((row) => {
2208
+ showDappImports && _optionalChain([dappImports, 'optionalAccess', _65 => _65.map, 'call', _66 => _66((row) => {
2171
2209
  if (!hasReownWallet) {
2172
2210
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2173
2211
  ListRow,
@@ -2201,7 +2239,7 @@ function ConnectStep({
2201
2239
  leading: row.icon,
2202
2240
  title: row.label,
2203
2241
  subtitle: formatBalanceUsd(row.status.balanceUsd),
2204
- onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _65 => _65(row.id)])
2242
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _67 => _67(row.id)])
2205
2243
  },
2206
2244
  row.id
2207
2245
  );
@@ -2213,7 +2251,7 @@ function ConnectStep({
2213
2251
  leading: row.icon,
2214
2252
  title: row.label,
2215
2253
  subtitle: row.status.reason,
2216
- onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _66 => _66(row.id)])
2254
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _68 => _68(row.id)])
2217
2255
  },
2218
2256
  row.id
2219
2257
  );
@@ -2318,8 +2356,8 @@ function Tooltip({ content, children, className }) {
2318
2356
  function handleOutside(event) {
2319
2357
  const target = event.target;
2320
2358
  if (!target) return;
2321
- if (_optionalChain([triggerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.contains, 'call', _69 => _69(target)])) return;
2322
- if (_optionalChain([bubbleRef, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.contains, 'call', _72 => _72(target)])) return;
2359
+ if (_optionalChain([triggerRef, 'access', _69 => _69.current, 'optionalAccess', _70 => _70.contains, 'call', _71 => _71(target)])) return;
2360
+ if (_optionalChain([bubbleRef, 'access', _72 => _72.current, 'optionalAccess', _73 => _73.contains, 'call', _74 => _74(target)])) return;
2323
2361
  setOpen(false);
2324
2362
  }
2325
2363
  function handleKey(event) {
@@ -2399,7 +2437,7 @@ function asNumber(value) {
2399
2437
  const trimmed = value.trim();
2400
2438
  if (!trimmed) return void 0;
2401
2439
  const caipMatch = trimmed.match(/^eip155:(\d+)$/);
2402
- if (_optionalChain([caipMatch, 'optionalAccess', _73 => _73[1]])) {
2440
+ if (_optionalChain([caipMatch, 'optionalAccess', _75 => _75[1]])) {
2403
2441
  const parsed2 = Number(caipMatch[1]);
2404
2442
  return Number.isFinite(parsed2) ? parsed2 : void 0;
2405
2443
  }
@@ -2418,28 +2456,28 @@ function asAddress(value) {
2418
2456
  return /^0x[a-fA-F0-9]{40}$/.test(value) ? value : void 0;
2419
2457
  }
2420
2458
  function getEventTxHash(event) {
2421
- if (!_optionalChain([event, 'optionalAccess', _74 => _74.type])) return void 0;
2459
+ if (!_optionalChain([event, 'optionalAccess', _76 => _76.type])) return void 0;
2422
2460
  if (event.type === "deposit-received") {
2423
- return asString(_optionalChain([event, 'access', _75 => _75.data, 'optionalAccess', _76 => _76.transactionHash]));
2461
+ return asString(_optionalChain([event, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.transactionHash]));
2424
2462
  }
2425
2463
  if (event.type === "bridge-started" || event.type === "bridge-complete") {
2426
- const deposit = isRecord(_optionalChain([event, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.deposit])) ? event.data.deposit : void 0;
2427
- const source = isRecord(_optionalChain([event, 'access', _79 => _79.data, 'optionalAccess', _80 => _80.source])) ? event.data.source : void 0;
2428
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _81 => _81.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _82 => _82.transactionHash]))));
2464
+ const deposit = isRecord(_optionalChain([event, 'access', _79 => _79.data, 'optionalAccess', _80 => _80.deposit])) ? event.data.deposit : void 0;
2465
+ const source = isRecord(_optionalChain([event, 'access', _81 => _81.data, 'optionalAccess', _82 => _82.source])) ? event.data.source : void 0;
2466
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _83 => _83.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _84 => _84.transactionHash]))));
2429
2467
  }
2430
2468
  if (event.type === "bridge-failed" || event.type === "error") {
2431
- const deposit = isRecord(_optionalChain([event, 'access', _83 => _83.data, 'optionalAccess', _84 => _84.deposit])) ? event.data.deposit : void 0;
2432
- const source = isRecord(_optionalChain([event, 'access', _85 => _85.data, 'optionalAccess', _86 => _86.source])) ? event.data.source : void 0;
2433
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _87 => _87.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _88 => _88.transactionHash]))));
2469
+ const deposit = isRecord(_optionalChain([event, 'access', _85 => _85.data, 'optionalAccess', _86 => _86.deposit])) ? event.data.deposit : void 0;
2470
+ const source = isRecord(_optionalChain([event, 'access', _87 => _87.data, 'optionalAccess', _88 => _88.source])) ? event.data.source : void 0;
2471
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _89 => _89.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _90 => _90.transactionHash]))));
2434
2472
  }
2435
2473
  if (event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
2436
- const deposit = isRecord(_optionalChain([event, 'access', _89 => _89.data, 'optionalAccess', _90 => _90.deposit])) ? event.data.deposit : void 0;
2437
- return asString(_optionalChain([deposit, 'optionalAccess', _91 => _91.transactionHash]));
2474
+ const deposit = isRecord(_optionalChain([event, 'access', _91 => _91.data, 'optionalAccess', _92 => _92.deposit])) ? event.data.deposit : void 0;
2475
+ return asString(_optionalChain([deposit, 'optionalAccess', _93 => _93.transactionHash]));
2438
2476
  }
2439
2477
  return void 0;
2440
2478
  }
2441
2479
  function getEventSourceDetails(event) {
2442
- if (!_optionalChain([event, 'optionalAccess', _92 => _92.type]) || !isRecord(event.data)) return {};
2480
+ if (!_optionalChain([event, 'optionalAccess', _94 => _94.type]) || !isRecord(event.data)) return {};
2443
2481
  if (event.type === "deposit-received") {
2444
2482
  return {
2445
2483
  chainId: asNumber(event.data.chain),
@@ -2451,18 +2489,18 @@ function getEventSourceDetails(event) {
2451
2489
  const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
2452
2490
  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") {
2453
2491
  return {
2454
- chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _93 => _93.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _94 => _94.chain])))),
2455
- amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _95 => _95.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _96 => _96.amount])))),
2456
- token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _97 => _97.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _98 => _98.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _99 => _99.token]))))
2492
+ chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _95 => _95.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _96 => _96.chain])))),
2493
+ amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _97 => _97.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _98 => _98.amount])))),
2494
+ token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _99 => _99.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _100 => _100.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _101 => _101.token]))))
2457
2495
  };
2458
2496
  }
2459
2497
  return {};
2460
2498
  }
2461
2499
  function isDepositEvent(event) {
2462
- return _optionalChain([event, 'optionalAccess', _100 => _100.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _101 => _101.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _102 => _102.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _103 => _103.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _104 => _104.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _105 => _105.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _106 => _106.type]) === "error";
2500
+ return _optionalChain([event, 'optionalAccess', _102 => _102.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _103 => _103.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _104 => _104.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _105 => _105.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _106 => _106.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _107 => _107.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _108 => _108.type]) === "error";
2463
2501
  }
2464
2502
  function isFailedEvent(event) {
2465
- return _optionalChain([event, 'optionalAccess', _107 => _107.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _108 => _108.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _109 => _109.type]) === "error";
2503
+ return _optionalChain([event, 'optionalAccess', _109 => _109.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _110 => _110.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _111 => _111.type]) === "error";
2466
2504
  }
2467
2505
  function isHexString(value) {
2468
2506
  return value.startsWith("0x") || value.startsWith("0X");
@@ -2474,7 +2512,7 @@ function txRefsMatch(a, b) {
2474
2512
  return a === b;
2475
2513
  }
2476
2514
  function formatBridgeFailedMessage(event) {
2477
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _110 => _110.data]), () => ( {}));
2515
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _112 => _112.data]), () => ( {}));
2478
2516
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
2479
2517
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
2480
2518
  function toUserFacingFailure(raw) {
@@ -2502,7 +2540,7 @@ function formatBridgeFailedMessage(event) {
2502
2540
  return { message: "Bridge failed" };
2503
2541
  }
2504
2542
  function failureMessageForEvent(event) {
2505
- if (_optionalChain([event, 'optionalAccess', _111 => _111.type]) === "error") {
2543
+ if (_optionalChain([event, 'optionalAccess', _113 => _113.type]) === "error") {
2506
2544
  const message = isRecord(event.data) ? asString(event.data.message) : void 0;
2507
2545
  return _nullishCoalesce(message, () => ( "Unknown error"));
2508
2546
  }
@@ -2648,12 +2686,12 @@ function isEventForTx(event, txHash) {
2648
2686
  return txRefsMatch(eventTxHash, txHash);
2649
2687
  }
2650
2688
  function parseWebhookTimestamp(event) {
2651
- if (typeof _optionalChain([event, 'optionalAccess', _112 => _112.time]) !== "string") return void 0;
2689
+ if (typeof _optionalChain([event, 'optionalAccess', _114 => _114.time]) !== "string") return void 0;
2652
2690
  const timestamp = Date.parse(event.time);
2653
2691
  return Number.isFinite(timestamp) ? timestamp : void 0;
2654
2692
  }
2655
2693
  function syncPhaseTimings(previous, event) {
2656
- if (!_optionalChain([event, 'optionalAccess', _113 => _113.type])) return previous;
2694
+ if (!_optionalChain([event, 'optionalAccess', _115 => _115.type])) return previous;
2657
2695
  const timestamp = _nullishCoalesce(parseWebhookTimestamp(event), () => ( Date.now()));
2658
2696
  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;
2659
2697
  const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.bridgingAt === void 0;
@@ -2715,9 +2753,9 @@ function getCurrentPhaseId(state, phaseTimings) {
2715
2753
  if (state.type === "complete") {
2716
2754
  return void 0;
2717
2755
  }
2718
- if (_optionalChain([state, 'access', _114 => _114.lastEvent, 'optionalAccess', _115 => _115.type]) === "bridge-started" || _optionalChain([state, 'access', _116 => _116.lastEvent, 'optionalAccess', _117 => _117.type]) === "bridge-complete")
2756
+ if (_optionalChain([state, 'access', _116 => _116.lastEvent, 'optionalAccess', _117 => _117.type]) === "bridge-started" || _optionalChain([state, 'access', _118 => _118.lastEvent, 'optionalAccess', _119 => _119.type]) === "bridge-complete")
2719
2757
  return "bridging";
2720
- if (_optionalChain([state, 'access', _118 => _118.lastEvent, 'optionalAccess', _119 => _119.type]) === "deposit-received") return "received";
2758
+ if (_optionalChain([state, 'access', _120 => _120.lastEvent, 'optionalAccess', _121 => _121.type]) === "deposit-received") return "received";
2721
2759
  return "confirming";
2722
2760
  }
2723
2761
  function ProcessingStep({
@@ -2802,7 +2840,7 @@ function ProcessingStep({
2802
2840
  flowLabel
2803
2841
  });
2804
2842
  const context = processingContextRef.current;
2805
- _optionalChain([onDepositCompleteRef, 'access', _120 => _120.current, 'optionalCall', _121 => _121(txHash, void 0, {
2843
+ _optionalChain([onDepositCompleteRef, 'access', _122 => _122.current, 'optionalCall', _123 => _123(txHash, void 0, {
2806
2844
  amount: context.amount,
2807
2845
  sourceChain: context.sourceChain,
2808
2846
  sourceToken: context.sourceToken,
@@ -2844,7 +2882,7 @@ function ProcessingStep({
2844
2882
  updatePhaseTimings(
2845
2883
  (previous) => syncPhaseTimings(previous, state.lastEvent)
2846
2884
  );
2847
- }, [_optionalChain([state, 'access', _122 => _122.lastEvent, 'optionalAccess', _123 => _123.time]), _optionalChain([state, 'access', _124 => _124.lastEvent, 'optionalAccess', _125 => _125.type]), updatePhaseTimings]);
2885
+ }, [_optionalChain([state, 'access', _124 => _124.lastEvent, 'optionalAccess', _125 => _125.time]), _optionalChain([state, 'access', _126 => _126.lastEvent, 'optionalAccess', _127 => _127.type]), updatePhaseTimings]);
2848
2886
  const [swappedFiatContext, setSwappedFiatContext] = _react.useState.call(void 0, null);
2849
2887
  _react.useEffect.call(void 0, () => {
2850
2888
  let cancelled = false;
@@ -2891,21 +2929,21 @@ function ProcessingStep({
2891
2929
  debugLog(debug, "processing", "poll:event", {
2892
2930
  type: lastEvent2.type,
2893
2931
  matchesTx: eventMatchesTx,
2894
- intentId: _optionalChain([eventData, 'optionalAccess', _126 => _126.intentId])
2932
+ intentId: _optionalChain([eventData, 'optionalAccess', _128 => _128.intentId])
2895
2933
  });
2896
2934
  }
2897
2935
  if (!isMounted) return;
2898
2936
  const awaitingPostBridgeSwap = processingContextRef.current.hasPostBridgeActions;
2899
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _127 => _127.type]) === "post-bridge-swap-complete") {
2937
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _129 => _129.type]) === "post-bridge-swap-complete") {
2900
2938
  setState({ type: "complete", lastEvent: eventForCurrentTx });
2901
- const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _128 => _128.data, 'optionalAccess', _129 => _129.swap, 'optionalAccess', _130 => _130.transactionHash]);
2939
+ const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _130 => _130.data, 'optionalAccess', _131 => _131.swap, 'optionalAccess', _132 => _132.transactionHash]);
2902
2940
  debugLog(debug, "processing", "state:complete", {
2903
2941
  txHash,
2904
2942
  destinationTxHash: swapTxHash,
2905
2943
  event: eventForCurrentTx.type
2906
2944
  });
2907
2945
  const context = processingContextRef.current;
2908
- _optionalChain([onDepositCompleteRef, 'access', _131 => _131.current, 'optionalCall', _132 => _132(txHash, swapTxHash, {
2946
+ _optionalChain([onDepositCompleteRef, 'access', _133 => _133.current, 'optionalCall', _134 => _134(txHash, swapTxHash, {
2909
2947
  amount: context.amount,
2910
2948
  sourceChain: context.sourceChain,
2911
2949
  sourceToken: context.sourceToken,
@@ -2916,7 +2954,7 @@ function ProcessingStep({
2916
2954
  })]);
2917
2955
  return;
2918
2956
  }
2919
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _133 => _133.type]) === "post-bridge-swap-failed") {
2957
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _135 => _135.type]) === "post-bridge-swap-failed") {
2920
2958
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
2921
2959
  setState({
2922
2960
  type: "failed",
@@ -2928,19 +2966,19 @@ function ProcessingStep({
2928
2966
  message: formatted.message,
2929
2967
  code: formatted.code
2930
2968
  });
2931
- _optionalChain([onDepositFailedRef, 'access', _134 => _134.current, 'optionalCall', _135 => _135(txHash, formatted.message)]);
2969
+ _optionalChain([onDepositFailedRef, 'access', _136 => _136.current, 'optionalCall', _137 => _137(txHash, formatted.message)]);
2932
2970
  return;
2933
2971
  }
2934
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _136 => _136.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
2972
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _138 => _138.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
2935
2973
  setState({ type: "complete", lastEvent: eventForCurrentTx });
2936
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _137 => _137.data, 'optionalAccess', _138 => _138.destination, 'optionalAccess', _139 => _139.transactionHash]);
2974
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _139 => _139.data, 'optionalAccess', _140 => _140.destination, 'optionalAccess', _141 => _141.transactionHash]);
2937
2975
  debugLog(debug, "processing", "state:complete", {
2938
2976
  txHash,
2939
2977
  destinationTxHash: destinationTxHash2,
2940
2978
  event: eventForCurrentTx.type
2941
2979
  });
2942
2980
  const context = processingContextRef.current;
2943
- _optionalChain([onDepositCompleteRef, 'access', _140 => _140.current, 'optionalCall', _141 => _141(txHash, destinationTxHash2, {
2981
+ _optionalChain([onDepositCompleteRef, 'access', _142 => _142.current, 'optionalCall', _143 => _143(txHash, destinationTxHash2, {
2944
2982
  amount: context.amount,
2945
2983
  sourceChain: context.sourceChain,
2946
2984
  sourceToken: context.sourceToken,
@@ -2951,7 +2989,7 @@ function ProcessingStep({
2951
2989
  })]);
2952
2990
  return;
2953
2991
  }
2954
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _142 => _142.type]) === "bridge-failed") {
2992
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _144 => _144.type]) === "bridge-failed") {
2955
2993
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
2956
2994
  setState({
2957
2995
  type: "failed",
@@ -2963,11 +3001,11 @@ function ProcessingStep({
2963
3001
  message: formatted.message,
2964
3002
  code: formatted.code
2965
3003
  });
2966
- _optionalChain([onDepositFailedRef, 'access', _143 => _143.current, 'optionalCall', _144 => _144(txHash, formatted.message)]);
3004
+ _optionalChain([onDepositFailedRef, 'access', _145 => _145.current, 'optionalCall', _146 => _146(txHash, formatted.message)]);
2967
3005
  return;
2968
3006
  }
2969
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _145 => _145.type]) === "error") {
2970
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _146 => _146.data, 'optionalAccess', _147 => _147.message]), () => ( "Unknown error"));
3007
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _147 => _147.type]) === "error") {
3008
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _148 => _148.data, 'optionalAccess', _149 => _149.message]), () => ( "Unknown error"));
2971
3009
  setState({
2972
3010
  type: "failed",
2973
3011
  message: errorMessage,
@@ -2977,7 +3015,7 @@ function ProcessingStep({
2977
3015
  txHash,
2978
3016
  message: errorMessage
2979
3017
  });
2980
- _optionalChain([onDepositFailedRef, 'access', _148 => _148.current, 'optionalCall', _149 => _149(txHash, errorMessage)]);
3018
+ _optionalChain([onDepositFailedRef, 'access', _150 => _150.current, 'optionalCall', _151 => _151(txHash, errorMessage)]);
2981
3019
  return;
2982
3020
  }
2983
3021
  setState((previous) => ({
@@ -3038,7 +3076,7 @@ function ProcessingStep({
3038
3076
  txHash,
3039
3077
  timeoutMs: ESCALATED_DELAY_MS
3040
3078
  });
3041
- _optionalChain([onErrorRef, 'access', _150 => _150.current, 'optionalCall', _151 => _151(message, "PROCESS_TIMEOUT")]);
3079
+ _optionalChain([onErrorRef, 'access', _152 => _152.current, 'optionalCall', _153 => _153(message, "PROCESS_TIMEOUT")]);
3042
3080
  }, ESCALATED_DELAY_MS);
3043
3081
  return () => clearTimeout(timeoutId);
3044
3082
  }, [debug, directTransfer, onErrorRef, state.type, txHash]);
@@ -3050,8 +3088,8 @@ function ProcessingStep({
3050
3088
  const timelineNowMs = _nullishCoalesce(phaseTimings.endedAt, () => ( Date.now()));
3051
3089
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
3052
3090
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
3053
- const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _152 => _152.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _153 => _153.type]) === "post-bridge-swap-failed";
3054
- const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _154 => _154.data, 'optionalAccess', _155 => _155.swap, 'optionalAccess', _156 => _156.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _157 => _157.data, 'optionalAccess', _158 => _158.destination, 'optionalAccess', _159 => _159.transactionHash]) || null;
3091
+ const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _154 => _154.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _155 => _155.type]) === "post-bridge-swap-failed";
3092
+ const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _156 => _156.data, 'optionalAccess', _157 => _157.swap, 'optionalAccess', _158 => _158.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _159 => _159.data, 'optionalAccess', _160 => _160.destination, 'optionalAccess', _161 => _161.transactionHash]) || null;
3055
3093
  const sourceDetails = getEventSourceDetails(lastEvent);
3056
3094
  const displaySourceChain = _nullishCoalesce(sourceDetails.chainId, () => ( sourceChain));
3057
3095
  const displaySourceToken = _nullishCoalesce(sourceDetails.token, () => ( sourceToken));
@@ -3082,7 +3120,7 @@ function ProcessingStep({
3082
3120
  }
3083
3121
  })();
3084
3122
  const destinationAmountRaw = (() => {
3085
- const dest = _optionalChain([lastEvent, 'optionalAccess', _160 => _160.data, 'optionalAccess', _161 => _161.destination]);
3123
+ const dest = _optionalChain([lastEvent, 'optionalAccess', _162 => _162.data, 'optionalAccess', _163 => _163.destination]);
3086
3124
  if (!dest || dest.amount === void 0) return void 0;
3087
3125
  try {
3088
3126
  return BigInt(dest.amount);
@@ -3141,8 +3179,8 @@ function ProcessingStep({
3141
3179
  const sourceChainName = _chunkMILJQWPTcjs.getChainName.call(void 0, displaySourceChain);
3142
3180
  const targetChainName = _chunkMILJQWPTcjs.getChainName.call(void 0, targetChain);
3143
3181
  const timerText = formatTimer(elapsedSeconds);
3144
- const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _162 => _162.feeSponsored]), () => ( false));
3145
- const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _163 => _163.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
3182
+ const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _164 => _164.feeSponsored]), () => ( false));
3183
+ const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _165 => _165.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
3146
3184
  const stateTitle = isComplete ? `${flowCapitalized} successful` : isFailed ? `${flowCapitalized} failed` : "Processing...";
3147
3185
  const handleRetry = _nullishCoalesce(onRetry, () => ( onNewDeposit));
3148
3186
  const headerContent = isComplete ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-body-header", children: [
@@ -3196,7 +3234,7 @@ function ProcessingStep({
3196
3234
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: isProcessing ? "Time elapsed" : "Total time" }),
3197
3235
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-review-detail-value", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Ticker, { value: timerText }) })
3198
3236
  ] }),
3199
- _optionalChain([swappedFiatContext, 'optionalAccess', _164 => _164.paidAmountUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3237
+ _optionalChain([swappedFiatContext, 'optionalAccess', _166 => _166.paidAmountUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3200
3238
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "You pay" }),
3201
3239
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-review-detail-value", children: [
3202
3240
  "$",
@@ -3207,7 +3245,7 @@ function ProcessingStep({
3207
3245
  ] })
3208
3246
  ] })
3209
3247
  ] }),
3210
- _optionalChain([swappedFiatContext, 'optionalAccess', _165 => _165.onrampFeeUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3248
+ _optionalChain([swappedFiatContext, 'optionalAccess', _167 => _167.onrampFeeUsd]) != null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-review-detail-row", children: [
3211
3249
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "On-ramp fee" }),
3212
3250
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-review-detail-value", children: [
3213
3251
  "$",