@rhinestone/deposit-modal 0.3.0-alpha.2 → 0.3.0-alpha.4

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.
@@ -1227,6 +1227,36 @@ function PoweredBy() {
1227
1227
  }
1228
1228
  PoweredBy.displayName = "PoweredBy";
1229
1229
 
1230
+ // src/components/ui/Spinner.tsx
1231
+
1232
+ function Spinner({ className }) {
1233
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1234
+ "svg",
1235
+ {
1236
+ className: `rs-spinner ${className || ""}`,
1237
+ fill: "none",
1238
+ viewBox: "0 0 20 21",
1239
+ children: [
1240
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1241
+ "path",
1242
+ {
1243
+ d: "M10 0.5C8.02219 0.5 6.08879 1.08649 4.4443 2.1853C2.79981 3.28412 1.51809 4.8459 0.761209 6.67316C0.00433288 8.50043 -0.1937 10.5111 0.192152 12.4509C0.578004 14.3907 1.53041 16.1725 2.92894 17.5711C4.32746 18.9696 6.10929 19.922 8.0491 20.3078C9.98891 20.6937 11.9996 20.4957 13.8268 19.7388C15.6541 18.9819 17.2159 17.7002 18.3147 16.0557C19.4135 14.4112 20 12.4778 20 10.5C20 7.84783 18.9464 5.3043 17.0711 3.42893C15.1957 1.55357 12.6522 0.5 10 0.5ZM10 17.7727C8.56159 17.7727 7.15549 17.3462 5.95949 16.547C4.7635 15.7479 3.83134 14.6121 3.28088 13.2831C2.73042 11.9542 2.5864 10.4919 2.86702 9.08116C3.14764 7.67039 3.8403 6.37451 4.85741 5.3574C5.87452 4.3403 7.17039 3.64764 8.58116 3.36702C9.99193 3.0864 11.4542 3.23042 12.7832 3.78088C14.1121 4.33133 15.2479 5.26349 16.0471 6.45949C16.8462 7.65548 17.2727 9.06159 17.2727 10.5C17.2727 12.4288 16.5065 14.2787 15.1426 15.6426C13.7787 17.0065 11.9288 17.7727 10 17.7727Z",
1244
+ fill: "currentColor",
1245
+ opacity: 0.3
1246
+ }
1247
+ ),
1248
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1249
+ "path",
1250
+ {
1251
+ d: "M10 3.22767C11.7423 3.22846 13.4276 3.8412 14.7556 4.95667C16.0837 6.07214 16.9681 7.61784 17.2512 9.31825C17.3012 9.64364 17.4662 9.94096 17.7169 10.1573C17.9677 10.3737 18.2878 10.4951 18.6205 10.5C18.8211 10.5001 19.0193 10.457 19.2012 10.3735C19.3832 10.2901 19.5445 10.1684 19.674 10.017C19.8036 9.86549 19.8981 9.68789 19.9511 9.49656C20.004 9.30523 20.0141 9.10478 19.9807 8.90918C19.5986 6.56305 18.3843 4.42821 16.5554 2.88726C14.7265 1.34631 12.4025 0.5 10 0.5C7.59751 0.5 5.27354 1.34631 3.44461 2.88726C1.61569 4.42821 0.401366 6.56305 0.0192815 8.90918C-0.0141442 9.10478 -0.00402016 9.30523 0.0489472 9.49656C0.101914 9.68789 0.196449 9.86549 0.325956 10.017C0.455463 10.1684 0.616823 10.2901 0.798778 10.3735C0.980732 10.457 1.1789 10.5001 1.37945 10.5C1.71216 10.4951 2.03235 10.3737 2.28307 10.1573C2.5338 9.94096 2.69883 9.64364 2.74882 9.31825C3.03193 7.61784 3.91633 6.07214 5.24436 4.95667C6.57239 3.8412 8.25775 3.22846 10 3.22767Z",
1252
+ fill: "currentColor"
1253
+ }
1254
+ )
1255
+ ]
1256
+ }
1257
+ );
1258
+ }
1259
+
1230
1260
  // src/components/ui/ListRow.tsx
1231
1261
 
1232
1262
  function ListRow({
@@ -1491,15 +1521,19 @@ ChainBadgeIcons.displayName = "ChainBadgeIcons";
1491
1521
 
1492
1522
  // src/components/steps/ConnectStep.tsx
1493
1523
 
1524
+ function formatBalanceUsd(value) {
1525
+ if (!Number.isFinite(value) || value <= 0) return "$0.00";
1526
+ return `$${value.toFixed(2)}`;
1527
+ }
1494
1528
  function shorten(addr) {
1495
1529
  return addr.length > 12 ? `${addr.slice(0, 6)}...${addr.slice(-4)}` : addr;
1496
1530
  }
1497
- function renderWalletLeading(option) {
1498
- if (option.icon) {
1531
+ function renderWalletLeading(row) {
1532
+ if (row.icon) {
1499
1533
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1500
1534
  "img",
1501
1535
  {
1502
- src: option.icon,
1536
+ src: row.icon,
1503
1537
  alt: "",
1504
1538
  style: { width: 24, height: 24, borderRadius: 6 }
1505
1539
  }
@@ -1507,21 +1541,32 @@ function renderWalletLeading(option) {
1507
1541
  }
1508
1542
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WalletIcon, {});
1509
1543
  }
1544
+ function renderRowTrailing(state) {
1545
+ if (state === "loading") {
1546
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" });
1547
+ }
1548
+ return void 0;
1549
+ }
1510
1550
  function ConnectStep({
1511
- walletOptions,
1551
+ walletRows,
1512
1552
  onConfirmWallet,
1513
1553
  onSelectTransferCrypto,
1554
+ transferCryptoState,
1555
+ transferCryptoErrorReason,
1514
1556
  onRequestConnect,
1515
1557
  onConnect,
1516
1558
  onDisconnect,
1559
+ dappImports,
1560
+ onSelectDappImport,
1517
1561
  title = "Deposit",
1518
1562
  subtitle
1519
1563
  }) {
1520
- const options = _nullishCoalesce(walletOptions, () => ( []));
1564
+ const rows = _nullishCoalesce(walletRows, () => ( []));
1521
1565
  const handleConnect = _nullishCoalesce(onConnect, () => ( onRequestConnect));
1522
- const hasReownWallet = options.some(
1523
- (option) => option.kind === "external" || option.kind === "solana"
1566
+ const hasReownWallet = rows.some(
1567
+ (row) => row.kind === "external" || row.kind === "solana"
1524
1568
  );
1569
+ const showDappImports = hasReownWallet && (_nullishCoalesce(_optionalChain([dappImports, 'optionalAccess', _56 => _56.length]), () => ( 0))) > 0;
1525
1570
  const extraChainCount = Math.max(0, _chunkIVTXEYB2cjs.getSupportedChainIds.call(void 0, ).length - 3);
1526
1571
  const chainBadge2 = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1527
1572
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChainBadgeIcons, {}),
@@ -1544,22 +1589,27 @@ function ConnectStep({
1544
1589
  {
1545
1590
  leading: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CoinsIcon, {}),
1546
1591
  title: "Transfer crypto",
1547
- subtitle: "Instant - No limit",
1592
+ subtitle: transferCryptoState === "loading" ? "Preparing\u2026" : transferCryptoState === "error" ? _nullishCoalesce(transferCryptoErrorReason, () => ( "Couldn't prepare account \u2014 tap to retry")) : "Instant - No limit",
1548
1593
  meta: chainBadge2,
1549
- onClick: onSelectTransferCrypto
1594
+ onClick: onSelectTransferCrypto,
1595
+ disabled: transferCryptoState === "loading",
1596
+ trailing: transferCryptoState === "loading" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" }) : void 0
1550
1597
  }
1551
1598
  ),
1552
- options.map((option) => {
1553
- const rawAddress = _nullishCoalesce(_nullishCoalesce(option.address, () => ( option.solanaAddress)), () => ( option.id));
1599
+ rows.map((row) => {
1600
+ const collapseToExternal = Boolean(onSelectTransferCrypto) && row.kind !== "solana";
1601
+ const subtitleText = row.state === "loading" ? "Preparing\u2026" : row.state === "error" ? _nullishCoalesce(row.errorReason, () => ( "Couldn't prepare wallet \u2014 tap to retry")) : shorten(row.address);
1554
1602
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1555
1603
  ListRow,
1556
1604
  {
1557
- leading: renderWalletLeading(option),
1558
- title: onSelectTransferCrypto ? "External wallet" : option.label,
1559
- subtitle: shorten(rawAddress),
1560
- onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _56 => _56(option.id)])
1605
+ leading: renderWalletLeading(row),
1606
+ title: collapseToExternal ? "External wallet" : row.label,
1607
+ subtitle: subtitleText,
1608
+ onClick: () => _optionalChain([onConfirmWallet, 'optionalCall', _57 => _57(row.id)]),
1609
+ disabled: row.state === "loading",
1610
+ trailing: renderRowTrailing(row.state)
1561
1611
  },
1562
- option.id
1612
+ row.id
1563
1613
  );
1564
1614
  }),
1565
1615
  !hasReownWallet && handleConnect && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1574,7 +1624,56 @@ function ConnectStep({
1574
1624
  ] }),
1575
1625
  onClick: handleConnect
1576
1626
  }
1577
- )
1627
+ ),
1628
+ showDappImports && _optionalChain([dappImports, 'optionalAccess', _58 => _58.map, 'call', _59 => _59((row) => {
1629
+ if (row.status === "loading") {
1630
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1631
+ ListRow,
1632
+ {
1633
+ leading: row.icon,
1634
+ title: row.label,
1635
+ subtitle: "Checking balance\u2026",
1636
+ disabled: true,
1637
+ trailing: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" })
1638
+ },
1639
+ row.id
1640
+ );
1641
+ }
1642
+ if (row.status.enabled) {
1643
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1644
+ ListRow,
1645
+ {
1646
+ leading: row.icon,
1647
+ title: row.label,
1648
+ subtitle: formatBalanceUsd(row.status.balanceUsd),
1649
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _60 => _60(row.id)])
1650
+ },
1651
+ row.id
1652
+ );
1653
+ }
1654
+ if (row.status.retryable) {
1655
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1656
+ ListRow,
1657
+ {
1658
+ leading: row.icon,
1659
+ title: row.label,
1660
+ subtitle: row.status.reason,
1661
+ onClick: () => _optionalChain([onSelectDappImport, 'optionalCall', _61 => _61(row.id)])
1662
+ },
1663
+ row.id
1664
+ );
1665
+ }
1666
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1667
+ ListRow,
1668
+ {
1669
+ leading: row.icon,
1670
+ title: row.label,
1671
+ subtitle: row.status.reason,
1672
+ disabled: true
1673
+ },
1674
+ row.id
1675
+ );
1676
+ })])
1578
1677
  ] })
1579
1678
  ] }),
1580
1679
  onDisconnect && hasReownWallet && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-screen-tight-row", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1591,85 +1690,6 @@ function ConnectStep({
1591
1690
  }
1592
1691
  ConnectStep.displayName = "ConnectStep";
1593
1692
 
1594
- // src/components/ui/Spinner.tsx
1595
-
1596
- function Spinner({ className }) {
1597
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1598
- "svg",
1599
- {
1600
- className: `rs-spinner ${className || ""}`,
1601
- fill: "none",
1602
- viewBox: "0 0 20 21",
1603
- children: [
1604
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1605
- "path",
1606
- {
1607
- d: "M10 0.5C8.02219 0.5 6.08879 1.08649 4.4443 2.1853C2.79981 3.28412 1.51809 4.8459 0.761209 6.67316C0.00433288 8.50043 -0.1937 10.5111 0.192152 12.4509C0.578004 14.3907 1.53041 16.1725 2.92894 17.5711C4.32746 18.9696 6.10929 19.922 8.0491 20.3078C9.98891 20.6937 11.9996 20.4957 13.8268 19.7388C15.6541 18.9819 17.2159 17.7002 18.3147 16.0557C19.4135 14.4112 20 12.4778 20 10.5C20 7.84783 18.9464 5.3043 17.0711 3.42893C15.1957 1.55357 12.6522 0.5 10 0.5ZM10 17.7727C8.56159 17.7727 7.15549 17.3462 5.95949 16.547C4.7635 15.7479 3.83134 14.6121 3.28088 13.2831C2.73042 11.9542 2.5864 10.4919 2.86702 9.08116C3.14764 7.67039 3.8403 6.37451 4.85741 5.3574C5.87452 4.3403 7.17039 3.64764 8.58116 3.36702C9.99193 3.0864 11.4542 3.23042 12.7832 3.78088C14.1121 4.33133 15.2479 5.26349 16.0471 6.45949C16.8462 7.65548 17.2727 9.06159 17.2727 10.5C17.2727 12.4288 16.5065 14.2787 15.1426 15.6426C13.7787 17.0065 11.9288 17.7727 10 17.7727Z",
1608
- fill: "currentColor",
1609
- opacity: 0.3
1610
- }
1611
- ),
1612
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1613
- "path",
1614
- {
1615
- d: "M10 3.22767C11.7423 3.22846 13.4276 3.8412 14.7556 4.95667C16.0837 6.07214 16.9681 7.61784 17.2512 9.31825C17.3012 9.64364 17.4662 9.94096 17.7169 10.1573C17.9677 10.3737 18.2878 10.4951 18.6205 10.5C18.8211 10.5001 19.0193 10.457 19.2012 10.3735C19.3832 10.2901 19.5445 10.1684 19.674 10.017C19.8036 9.86549 19.8981 9.68789 19.9511 9.49656C20.004 9.30523 20.0141 9.10478 19.9807 8.90918C19.5986 6.56305 18.3843 4.42821 16.5554 2.88726C14.7265 1.34631 12.4025 0.5 10 0.5C7.59751 0.5 5.27354 1.34631 3.44461 2.88726C1.61569 4.42821 0.401366 6.56305 0.0192815 8.90918C-0.0141442 9.10478 -0.00402016 9.30523 0.0489472 9.49656C0.101914 9.68789 0.196449 9.86549 0.325956 10.017C0.455463 10.1684 0.616823 10.2901 0.798778 10.3735C0.980732 10.457 1.1789 10.5001 1.37945 10.5C1.71216 10.4951 2.03235 10.3737 2.28307 10.1573C2.5338 9.94096 2.69883 9.64364 2.74882 9.31825C3.03193 7.61784 3.91633 6.07214 5.24436 4.95667C6.57239 3.8412 8.25775 3.22846 10 3.22767Z",
1616
- fill: "currentColor"
1617
- }
1618
- )
1619
- ]
1620
- }
1621
- );
1622
- }
1623
-
1624
- // src/core/session-owner.ts
1625
- var _viem = require('viem');
1626
-
1627
-
1628
-
1629
- var _accounts = require('viem/accounts');
1630
- var STORAGE_PREFIX = "rhinestone:session-owner";
1631
- function storageKey(eoaAddress) {
1632
- return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
1633
- }
1634
- function loadSessionOwnerFromStorage(eoaAddress) {
1635
- if (typeof window === "undefined") return null;
1636
- const raw = window.localStorage.getItem(storageKey(eoaAddress));
1637
- if (!raw) return null;
1638
- try {
1639
- const parsed = JSON.parse(raw);
1640
- if (!parsed.privateKey) return null;
1641
- const account = _accounts.privateKeyToAccount.call(void 0, parsed.privateKey);
1642
- return {
1643
- privateKey: parsed.privateKey,
1644
- address: account.address
1645
- };
1646
- } catch (e2) {
1647
- return null;
1648
- }
1649
- }
1650
- function saveSessionOwnerToStorage(eoaAddress, privateKey, address) {
1651
- if (typeof window === "undefined") return;
1652
- if (!_viem.isAddress.call(void 0, address)) return;
1653
- const payload = {
1654
- privateKey,
1655
- address,
1656
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
1657
- };
1658
- window.localStorage.setItem(storageKey(eoaAddress), JSON.stringify(payload));
1659
- }
1660
- function createSessionOwnerKey() {
1661
- const privateKey = _accounts.generatePrivateKey.call(void 0, );
1662
- const account = _accounts.privateKeyToAccount.call(void 0, privateKey);
1663
- return {
1664
- privateKey,
1665
- account,
1666
- address: account.address
1667
- };
1668
- }
1669
- function accountFromPrivateKey(privateKey) {
1670
- return _accounts.privateKeyToAccount.call(void 0, privateKey);
1671
- }
1672
-
1673
1693
  // src/core/formatters.ts
1674
1694
  var currencyFormatter = new Intl.NumberFormat("en-US", {
1675
1695
  style: "currency",
@@ -1737,7 +1757,7 @@ function formatUserError(raw) {
1737
1757
 
1738
1758
  // src/components/steps/ProcessingStep.tsx
1739
1759
 
1740
-
1760
+ var _viem = require('viem');
1741
1761
 
1742
1762
  // src/components/ui/Button.tsx
1743
1763
 
@@ -1808,8 +1828,8 @@ function Tooltip({ content, children, className }) {
1808
1828
  function handleOutside(event) {
1809
1829
  const target = event.target;
1810
1830
  if (!target) return;
1811
- if (_optionalChain([triggerRef, 'access', _57 => _57.current, 'optionalAccess', _58 => _58.contains, 'call', _59 => _59(target)])) return;
1812
- if (_optionalChain([bubbleRef, 'access', _60 => _60.current, 'optionalAccess', _61 => _61.contains, 'call', _62 => _62(target)])) return;
1831
+ if (_optionalChain([triggerRef, 'access', _62 => _62.current, 'optionalAccess', _63 => _63.contains, 'call', _64 => _64(target)])) return;
1832
+ if (_optionalChain([bubbleRef, 'access', _65 => _65.current, 'optionalAccess', _66 => _66.contains, 'call', _67 => _67(target)])) return;
1813
1833
  setOpen(false);
1814
1834
  }
1815
1835
  function handleKey(event) {
@@ -1889,7 +1909,7 @@ function asNumber(value) {
1889
1909
  const trimmed = value.trim();
1890
1910
  if (!trimmed) return void 0;
1891
1911
  const caipMatch = trimmed.match(/^eip155:(\d+)$/);
1892
- if (_optionalChain([caipMatch, 'optionalAccess', _63 => _63[1]])) {
1912
+ if (_optionalChain([caipMatch, 'optionalAccess', _68 => _68[1]])) {
1893
1913
  const parsed2 = Number(caipMatch[1]);
1894
1914
  return Number.isFinite(parsed2) ? parsed2 : void 0;
1895
1915
  }
@@ -1908,28 +1928,28 @@ function asAddress(value) {
1908
1928
  return /^0x[a-fA-F0-9]{40}$/.test(value) ? value : void 0;
1909
1929
  }
1910
1930
  function getEventTxHash(event) {
1911
- if (!_optionalChain([event, 'optionalAccess', _64 => _64.type])) return void 0;
1931
+ if (!_optionalChain([event, 'optionalAccess', _69 => _69.type])) return void 0;
1912
1932
  if (event.type === "deposit-received") {
1913
- return asString(_optionalChain([event, 'access', _65 => _65.data, 'optionalAccess', _66 => _66.transactionHash]));
1933
+ return asString(_optionalChain([event, 'access', _70 => _70.data, 'optionalAccess', _71 => _71.transactionHash]));
1914
1934
  }
1915
1935
  if (event.type === "bridge-started" || event.type === "bridge-complete") {
1916
- const deposit = isRecord(_optionalChain([event, 'access', _67 => _67.data, 'optionalAccess', _68 => _68.deposit])) ? event.data.deposit : void 0;
1917
- const source = isRecord(_optionalChain([event, 'access', _69 => _69.data, 'optionalAccess', _70 => _70.source])) ? event.data.source : void 0;
1918
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _71 => _71.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _72 => _72.transactionHash]))));
1936
+ const deposit = isRecord(_optionalChain([event, 'access', _72 => _72.data, 'optionalAccess', _73 => _73.deposit])) ? event.data.deposit : void 0;
1937
+ const source = isRecord(_optionalChain([event, 'access', _74 => _74.data, 'optionalAccess', _75 => _75.source])) ? event.data.source : void 0;
1938
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _76 => _76.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _77 => _77.transactionHash]))));
1919
1939
  }
1920
1940
  if (event.type === "bridge-failed" || event.type === "error") {
1921
- const deposit = isRecord(_optionalChain([event, 'access', _73 => _73.data, 'optionalAccess', _74 => _74.deposit])) ? event.data.deposit : void 0;
1922
- const source = isRecord(_optionalChain([event, 'access', _75 => _75.data, 'optionalAccess', _76 => _76.source])) ? event.data.source : void 0;
1923
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _77 => _77.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _78 => _78.transactionHash]))));
1941
+ const deposit = isRecord(_optionalChain([event, 'access', _78 => _78.data, 'optionalAccess', _79 => _79.deposit])) ? event.data.deposit : void 0;
1942
+ const source = isRecord(_optionalChain([event, 'access', _80 => _80.data, 'optionalAccess', _81 => _81.source])) ? event.data.source : void 0;
1943
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _82 => _82.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _83 => _83.transactionHash]))));
1924
1944
  }
1925
1945
  if (event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
1926
- const deposit = isRecord(_optionalChain([event, 'access', _79 => _79.data, 'optionalAccess', _80 => _80.deposit])) ? event.data.deposit : void 0;
1927
- return asString(_optionalChain([deposit, 'optionalAccess', _81 => _81.transactionHash]));
1946
+ const deposit = isRecord(_optionalChain([event, 'access', _84 => _84.data, 'optionalAccess', _85 => _85.deposit])) ? event.data.deposit : void 0;
1947
+ return asString(_optionalChain([deposit, 'optionalAccess', _86 => _86.transactionHash]));
1928
1948
  }
1929
1949
  return void 0;
1930
1950
  }
1931
1951
  function getEventSourceDetails(event) {
1932
- if (!_optionalChain([event, 'optionalAccess', _82 => _82.type]) || !isRecord(event.data)) return {};
1952
+ if (!_optionalChain([event, 'optionalAccess', _87 => _87.type]) || !isRecord(event.data)) return {};
1933
1953
  if (event.type === "deposit-received") {
1934
1954
  return {
1935
1955
  chainId: asNumber(event.data.chain),
@@ -1941,15 +1961,15 @@ function getEventSourceDetails(event) {
1941
1961
  const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
1942
1962
  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") {
1943
1963
  return {
1944
- chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _83 => _83.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _84 => _84.chain])))),
1945
- amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _85 => _85.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _86 => _86.amount])))),
1946
- token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _87 => _87.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _88 => _88.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _89 => _89.token]))))
1964
+ chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _88 => _88.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _89 => _89.chain])))),
1965
+ amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _90 => _90.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _91 => _91.amount])))),
1966
+ token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _92 => _92.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _93 => _93.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _94 => _94.token]))))
1947
1967
  };
1948
1968
  }
1949
1969
  return {};
1950
1970
  }
1951
1971
  function isDepositEvent(event) {
1952
- return _optionalChain([event, 'optionalAccess', _90 => _90.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _91 => _91.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _92 => _92.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _93 => _93.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _94 => _94.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _95 => _95.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _96 => _96.type]) === "error";
1972
+ return _optionalChain([event, 'optionalAccess', _95 => _95.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _96 => _96.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _97 => _97.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _98 => _98.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _99 => _99.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _100 => _100.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _101 => _101.type]) === "error";
1953
1973
  }
1954
1974
  function isHexString(value) {
1955
1975
  return value.startsWith("0x") || value.startsWith("0X");
@@ -1981,7 +2001,7 @@ function loadPhaseTimings(txHash) {
1981
2001
  const parsed = JSON.parse(raw);
1982
2002
  if (typeof parsed.startedAt !== "number") return null;
1983
2003
  return parsed;
1984
- } catch (e3) {
2004
+ } catch (e2) {
1985
2005
  return null;
1986
2006
  }
1987
2007
  }
@@ -1992,7 +2012,7 @@ function savePhaseTimings(txHash, timings) {
1992
2012
  `${PHASE_TIMINGS_PREFIX}:${txHash}`,
1993
2013
  JSON.stringify(timings)
1994
2014
  );
1995
- } catch (e4) {
2015
+ } catch (e3) {
1996
2016
  }
1997
2017
  }
1998
2018
  function isEventForTx(event, txHash) {
@@ -2001,7 +2021,7 @@ function isEventForTx(event, txHash) {
2001
2021
  return txRefsMatch(eventTxHash, txHash);
2002
2022
  }
2003
2023
  function formatBridgeFailedMessage(event) {
2004
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _97 => _97.data]), () => ( {}));
2024
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _102 => _102.data]), () => ( {}));
2005
2025
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
2006
2026
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
2007
2027
  function toUserFacingFailure(raw) {
@@ -2033,12 +2053,12 @@ function formatBridgeFailedMessage(event) {
2033
2053
  return { message: "Bridge failed" };
2034
2054
  }
2035
2055
  function parseWebhookTimestamp(event) {
2036
- if (typeof _optionalChain([event, 'optionalAccess', _98 => _98.time]) !== "string") return void 0;
2056
+ if (typeof _optionalChain([event, 'optionalAccess', _103 => _103.time]) !== "string") return void 0;
2037
2057
  const timestamp = Date.parse(event.time);
2038
2058
  return Number.isFinite(timestamp) ? timestamp : void 0;
2039
2059
  }
2040
2060
  function syncPhaseTimings(previous, event) {
2041
- if (!_optionalChain([event, 'optionalAccess', _99 => _99.type])) return previous;
2061
+ if (!_optionalChain([event, 'optionalAccess', _104 => _104.type])) return previous;
2042
2062
  const timestamp = _nullishCoalesce(parseWebhookTimestamp(event), () => ( Date.now()));
2043
2063
  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;
2044
2064
  const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.bridgingAt === void 0;
@@ -2079,9 +2099,9 @@ function getCurrentPhaseId(state, phaseTimings, isEarlyComplete) {
2079
2099
  if (state.type === "complete") {
2080
2100
  return void 0;
2081
2101
  }
2082
- if (_optionalChain([state, 'access', _100 => _100.lastEvent, 'optionalAccess', _101 => _101.type]) === "bridge-started" || _optionalChain([state, 'access', _102 => _102.lastEvent, 'optionalAccess', _103 => _103.type]) === "bridge-complete")
2102
+ if (_optionalChain([state, 'access', _105 => _105.lastEvent, 'optionalAccess', _106 => _106.type]) === "bridge-started" || _optionalChain([state, 'access', _107 => _107.lastEvent, 'optionalAccess', _108 => _108.type]) === "bridge-complete")
2083
2103
  return "bridging";
2084
- if (_optionalChain([state, 'access', _104 => _104.lastEvent, 'optionalAccess', _105 => _105.type]) === "deposit-received") return "received";
2104
+ if (_optionalChain([state, 'access', _109 => _109.lastEvent, 'optionalAccess', _110 => _110.type]) === "deposit-received") return "received";
2085
2105
  return "confirming";
2086
2106
  }
2087
2107
  function ProcessingStep({
@@ -2155,7 +2175,7 @@ function ProcessingStep({
2155
2175
  flowLabel
2156
2176
  });
2157
2177
  const context = processingContextRef.current;
2158
- _optionalChain([onDepositCompleteRef, 'access', _106 => _106.current, 'optionalCall', _107 => _107(txHash, void 0, {
2178
+ _optionalChain([onDepositCompleteRef, 'access', _111 => _111.current, 'optionalCall', _112 => _112(txHash, void 0, {
2159
2179
  amount: context.amount,
2160
2180
  sourceChain: context.sourceChain,
2161
2181
  sourceToken: context.sourceToken,
@@ -2192,7 +2212,7 @@ function ProcessingStep({
2192
2212
  _react.useEffect.call(void 0, () => {
2193
2213
  if (!state.lastEvent) return;
2194
2214
  setPhaseTimings((previous) => syncPhaseTimings(previous, state.lastEvent));
2195
- }, [_optionalChain([state, 'access', _108 => _108.lastEvent, 'optionalAccess', _109 => _109.time]), _optionalChain([state, 'access', _110 => _110.lastEvent, 'optionalAccess', _111 => _111.type])]);
2215
+ }, [_optionalChain([state, 'access', _113 => _113.lastEvent, 'optionalAccess', _114 => _114.time]), _optionalChain([state, 'access', _115 => _115.lastEvent, 'optionalAccess', _116 => _116.type])]);
2196
2216
  _react.useEffect.call(void 0, () => {
2197
2217
  savePhaseTimings(txHash, phaseTimings);
2198
2218
  }, [txHash, phaseTimings]);
@@ -2220,21 +2240,21 @@ function ProcessingStep({
2220
2240
  debugLog(debug, "processing", "poll:event", {
2221
2241
  type: lastEvent2.type,
2222
2242
  matchesTx: eventMatchesTx,
2223
- intentId: _optionalChain([eventData, 'optionalAccess', _112 => _112.intentId])
2243
+ intentId: _optionalChain([eventData, 'optionalAccess', _117 => _117.intentId])
2224
2244
  });
2225
2245
  }
2226
2246
  if (!isMounted) return;
2227
2247
  const awaitingPostBridgeSwap = processingContextRef.current.waitForFinalTx && processingContextRef.current.hasPostBridgeActions;
2228
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _113 => _113.type]) === "post-bridge-swap-complete") {
2248
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _118 => _118.type]) === "post-bridge-swap-complete") {
2229
2249
  setState({ type: "complete", lastEvent: eventForCurrentTx });
2230
- const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _114 => _114.data, 'optionalAccess', _115 => _115.swap, 'optionalAccess', _116 => _116.transactionHash]);
2250
+ const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _119 => _119.data, 'optionalAccess', _120 => _120.swap, 'optionalAccess', _121 => _121.transactionHash]);
2231
2251
  debugLog(debug, "processing", "state:complete", {
2232
2252
  txHash,
2233
2253
  destinationTxHash: swapTxHash,
2234
2254
  event: eventForCurrentTx.type
2235
2255
  });
2236
2256
  const context = processingContextRef.current;
2237
- _optionalChain([onDepositCompleteRef, 'access', _117 => _117.current, 'optionalCall', _118 => _118(txHash, swapTxHash, {
2257
+ _optionalChain([onDepositCompleteRef, 'access', _122 => _122.current, 'optionalCall', _123 => _123(txHash, swapTxHash, {
2238
2258
  amount: context.amount,
2239
2259
  sourceChain: context.sourceChain,
2240
2260
  sourceToken: context.sourceToken,
@@ -2243,7 +2263,7 @@ function ProcessingStep({
2243
2263
  })]);
2244
2264
  return;
2245
2265
  }
2246
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _119 => _119.type]) === "post-bridge-swap-failed") {
2266
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _124 => _124.type]) === "post-bridge-swap-failed") {
2247
2267
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
2248
2268
  setState({
2249
2269
  type: "failed",
@@ -2255,19 +2275,19 @@ function ProcessingStep({
2255
2275
  message: formatted.message,
2256
2276
  code: formatted.code
2257
2277
  });
2258
- _optionalChain([onDepositFailedRef, 'access', _120 => _120.current, 'optionalCall', _121 => _121(txHash, formatted.message)]);
2278
+ _optionalChain([onDepositFailedRef, 'access', _125 => _125.current, 'optionalCall', _126 => _126(txHash, formatted.message)]);
2259
2279
  return;
2260
2280
  }
2261
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _122 => _122.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
2281
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _127 => _127.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
2262
2282
  setState({ type: "complete", lastEvent: eventForCurrentTx });
2263
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _123 => _123.data, 'optionalAccess', _124 => _124.destination, 'optionalAccess', _125 => _125.transactionHash]);
2283
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _128 => _128.data, 'optionalAccess', _129 => _129.destination, 'optionalAccess', _130 => _130.transactionHash]);
2264
2284
  debugLog(debug, "processing", "state:complete", {
2265
2285
  txHash,
2266
2286
  destinationTxHash: destinationTxHash2,
2267
2287
  event: eventForCurrentTx.type
2268
2288
  });
2269
2289
  const context = processingContextRef.current;
2270
- _optionalChain([onDepositCompleteRef, 'access', _126 => _126.current, 'optionalCall', _127 => _127(txHash, destinationTxHash2, {
2290
+ _optionalChain([onDepositCompleteRef, 'access', _131 => _131.current, 'optionalCall', _132 => _132(txHash, destinationTxHash2, {
2271
2291
  amount: context.amount,
2272
2292
  sourceChain: context.sourceChain,
2273
2293
  sourceToken: context.sourceToken,
@@ -2276,14 +2296,14 @@ function ProcessingStep({
2276
2296
  })]);
2277
2297
  return;
2278
2298
  }
2279
- if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _128 => _128.type]) === "bridge-started") {
2299
+ if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _133 => _133.type]) === "bridge-started") {
2280
2300
  setState({ type: "complete", lastEvent: eventForCurrentTx });
2281
2301
  debugLog(debug, "processing", "state:early-complete", {
2282
2302
  txHash,
2283
2303
  event: eventForCurrentTx.type
2284
2304
  });
2285
2305
  const context = processingContextRef.current;
2286
- _optionalChain([onDepositCompleteRef, 'access', _129 => _129.current, 'optionalCall', _130 => _130(txHash, void 0, {
2306
+ _optionalChain([onDepositCompleteRef, 'access', _134 => _134.current, 'optionalCall', _135 => _135(txHash, void 0, {
2287
2307
  amount: context.amount,
2288
2308
  sourceChain: context.sourceChain,
2289
2309
  sourceToken: context.sourceToken,
@@ -2292,7 +2312,7 @@ function ProcessingStep({
2292
2312
  })]);
2293
2313
  return;
2294
2314
  }
2295
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _131 => _131.type]) === "bridge-failed") {
2315
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _136 => _136.type]) === "bridge-failed") {
2296
2316
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
2297
2317
  setState({
2298
2318
  type: "failed",
@@ -2304,11 +2324,11 @@ function ProcessingStep({
2304
2324
  message: formatted.message,
2305
2325
  code: formatted.code
2306
2326
  });
2307
- _optionalChain([onDepositFailedRef, 'access', _132 => _132.current, 'optionalCall', _133 => _133(txHash, formatted.message)]);
2327
+ _optionalChain([onDepositFailedRef, 'access', _137 => _137.current, 'optionalCall', _138 => _138(txHash, formatted.message)]);
2308
2328
  return;
2309
2329
  }
2310
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _134 => _134.type]) === "error") {
2311
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _135 => _135.data, 'optionalAccess', _136 => _136.message]), () => ( "Unknown error"));
2330
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _139 => _139.type]) === "error") {
2331
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _140 => _140.data, 'optionalAccess', _141 => _141.message]), () => ( "Unknown error"));
2312
2332
  setState({
2313
2333
  type: "failed",
2314
2334
  message: errorMessage,
@@ -2318,7 +2338,7 @@ function ProcessingStep({
2318
2338
  txHash,
2319
2339
  message: errorMessage
2320
2340
  });
2321
- _optionalChain([onDepositFailedRef, 'access', _137 => _137.current, 'optionalCall', _138 => _138(txHash, errorMessage)]);
2341
+ _optionalChain([onDepositFailedRef, 'access', _142 => _142.current, 'optionalCall', _143 => _143(txHash, errorMessage)]);
2322
2342
  return;
2323
2343
  }
2324
2344
  setState((previous) => ({
@@ -2379,7 +2399,7 @@ function ProcessingStep({
2379
2399
  txHash,
2380
2400
  timeoutMs: ESCALATED_DELAY_MS
2381
2401
  });
2382
- _optionalChain([onErrorRef, 'access', _139 => _139.current, 'optionalCall', _140 => _140(message, "PROCESS_TIMEOUT")]);
2402
+ _optionalChain([onErrorRef, 'access', _144 => _144.current, 'optionalCall', _145 => _145(message, "PROCESS_TIMEOUT")]);
2383
2403
  }, ESCALATED_DELAY_MS);
2384
2404
  return () => clearTimeout(timeoutId);
2385
2405
  }, [debug, directTransfer, onErrorRef, state.type, txHash]);
@@ -2388,12 +2408,12 @@ function ProcessingStep({
2388
2408
  const isProcessing = state.type === "processing";
2389
2409
  const lastEvent = state.lastEvent;
2390
2410
  const failureMessage = state.type === "failed" ? state.message : void 0;
2391
- const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _141 => _141.type]) === "bridge-started";
2411
+ const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _146 => _146.type]) === "bridge-started";
2392
2412
  const timelineNowMs = _nullishCoalesce(phaseTimings.endedAt, () => ( Date.now()));
2393
2413
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
2394
2414
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
2395
- const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _142 => _142.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _143 => _143.type]) === "post-bridge-swap-failed";
2396
- const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _144 => _144.data, 'optionalAccess', _145 => _145.swap, 'optionalAccess', _146 => _146.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _147 => _147.data, 'optionalAccess', _148 => _148.destination, 'optionalAccess', _149 => _149.transactionHash]) || null;
2415
+ const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _147 => _147.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _148 => _148.type]) === "post-bridge-swap-failed";
2416
+ const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _149 => _149.data, 'optionalAccess', _150 => _150.swap, 'optionalAccess', _151 => _151.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _152 => _152.data, 'optionalAccess', _153 => _153.destination, 'optionalAccess', _154 => _154.transactionHash]) || null;
2397
2417
  const sourceDetails = getEventSourceDetails(lastEvent);
2398
2418
  const displaySourceChain = _nullishCoalesce(sourceDetails.chainId, () => ( sourceChain));
2399
2419
  const displaySourceToken = _nullishCoalesce(sourceDetails.token, () => ( sourceToken));
@@ -2412,7 +2432,7 @@ function ProcessingStep({
2412
2432
  const numeric = Number(raw);
2413
2433
  if (!Number.isFinite(numeric)) return raw;
2414
2434
  return numeric.toLocaleString("en-US", { maximumFractionDigits: 6 });
2415
- } catch (e5) {
2435
+ } catch (e4) {
2416
2436
  return Number(displayAmount).toLocaleString("en-US", {
2417
2437
  maximumFractionDigits: 6
2418
2438
  });
@@ -2437,9 +2457,8 @@ function ProcessingStep({
2437
2457
  const sourceChainName = _chunkIVTXEYB2cjs.getChainName.call(void 0, displaySourceChain);
2438
2458
  const targetChainName = _chunkIVTXEYB2cjs.getChainName.call(void 0, targetChain);
2439
2459
  const totalTimeText = formatElapsedTime(elapsedSeconds);
2440
- const feeSymbol = _nullishCoalesce(quotedFeeSymbol, () => ( sourceSymbol));
2441
- const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _150 => _150.feeSponsored]), () => ( false));
2442
- const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _151 => _151.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
2460
+ const feeSponsored = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _155 => _155.feeSponsored]), () => ( false));
2461
+ const feeTooltip = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _156 => _156.feeTooltip]), () => ( (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.")));
2443
2462
  const stateTitle = isComplete ? `${flowCapitalized} successful` : isFailed ? `${flowCapitalized} failed` : "Processing...";
2444
2463
  const stateVariant = isComplete ? "success" : isFailed ? "error" : "default";
2445
2464
  const stateIcon = isComplete ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckIcon, {}) : isFailed ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CloseIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WalletIcon, {});
@@ -2528,15 +2547,11 @@ function ProcessingStep({
2528
2547
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-detail-row", children: [
2529
2548
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Fees" }),
2530
2549
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-detail-value", children: [
2531
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2550
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2532
2551
  "span",
2533
2552
  {
2534
2553
  style: feeSponsored ? { textDecoration: "line-through" } : void 0,
2535
- children: [
2536
- quotedFeeAmount,
2537
- " ",
2538
- feeSymbol
2539
- ]
2554
+ children: "$0.05"
2540
2555
  }
2541
2556
  ),
2542
2557
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tooltip, { content: feeTooltip, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-detail-info", "aria-label": "Fee info", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoIcon, {}) }) })
@@ -2564,6 +2579,291 @@ function ProcessingStep({
2564
2579
  ] });
2565
2580
  }
2566
2581
 
2582
+ // src/core/safe.ts
2583
+
2584
+
2585
+
2586
+
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+ var SAFE_ABI = [
2594
+ {
2595
+ type: "function",
2596
+ name: "isOwner",
2597
+ stateMutability: "view",
2598
+ inputs: [{ name: "owner", type: "address" }],
2599
+ outputs: [{ name: "", type: "bool" }]
2600
+ },
2601
+ {
2602
+ type: "function",
2603
+ name: "nonce",
2604
+ stateMutability: "view",
2605
+ inputs: [],
2606
+ outputs: [{ type: "uint256" }]
2607
+ },
2608
+ {
2609
+ type: "function",
2610
+ name: "execTransaction",
2611
+ stateMutability: "payable",
2612
+ inputs: [
2613
+ { name: "to", type: "address" },
2614
+ { name: "value", type: "uint256" },
2615
+ { name: "data", type: "bytes" },
2616
+ { name: "operation", type: "uint8" },
2617
+ { name: "safeTxGas", type: "uint256" },
2618
+ { name: "baseGas", type: "uint256" },
2619
+ { name: "gasPrice", type: "uint256" },
2620
+ { name: "gasToken", type: "address" },
2621
+ { name: "refundReceiver", type: "address" },
2622
+ { name: "signatures", type: "bytes" }
2623
+ ],
2624
+ outputs: [{ name: "success", type: "bool" }]
2625
+ },
2626
+ {
2627
+ type: "event",
2628
+ name: "ExecutionSuccess",
2629
+ inputs: [
2630
+ { name: "txHash", type: "bytes32", indexed: true },
2631
+ { name: "payment", type: "uint256", indexed: false }
2632
+ ],
2633
+ anonymous: false
2634
+ },
2635
+ {
2636
+ type: "event",
2637
+ name: "ExecutionFailure",
2638
+ inputs: [
2639
+ { name: "txHash", type: "bytes32", indexed: true },
2640
+ { name: "payment", type: "uint256", indexed: false }
2641
+ ],
2642
+ anonymous: false
2643
+ }
2644
+ ];
2645
+ async function executeSafeEthTransfer(params) {
2646
+ const {
2647
+ walletClient,
2648
+ publicClient,
2649
+ safeAddress,
2650
+ recipient,
2651
+ amount,
2652
+ chainId
2653
+ } = params;
2654
+ const account = walletClient.account;
2655
+ const chain = walletClient.chain;
2656
+ if (!account || !chain) {
2657
+ throw new Error("Wallet not connected");
2658
+ }
2659
+ if (chain.id !== chainId) {
2660
+ throw new Error(`Switch to ${_chunkIVTXEYB2cjs.getChainName.call(void 0, chainId)} to sign`);
2661
+ }
2662
+ const isOwner = await publicClient.readContract({
2663
+ address: safeAddress,
2664
+ abi: SAFE_ABI,
2665
+ functionName: "isOwner",
2666
+ args: [account.address]
2667
+ });
2668
+ if (!isOwner) {
2669
+ throw new Error("Connected wallet is not a Safe owner");
2670
+ }
2671
+ const safeTx = {
2672
+ to: recipient,
2673
+ value: amount,
2674
+ data: "0x",
2675
+ operation: 0,
2676
+ safeTxGas: 0n,
2677
+ baseGas: 0n,
2678
+ gasPrice: 0n,
2679
+ gasToken: _viem.zeroAddress,
2680
+ refundReceiver: _viem.zeroAddress
2681
+ };
2682
+ const signature = _viem.concat.call(void 0, [
2683
+ _viem.pad.call(void 0, account.address, { size: 32 }),
2684
+ _viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
2685
+ _viem.toHex.call(void 0, 1, { size: 1 })
2686
+ ]);
2687
+ const txHash = await walletClient.writeContract({
2688
+ account,
2689
+ chain,
2690
+ address: safeAddress,
2691
+ abi: SAFE_ABI,
2692
+ functionName: "execTransaction",
2693
+ args: [
2694
+ safeTx.to,
2695
+ safeTx.value,
2696
+ safeTx.data,
2697
+ safeTx.operation,
2698
+ safeTx.safeTxGas,
2699
+ safeTx.baseGas,
2700
+ safeTx.gasPrice,
2701
+ safeTx.gasToken,
2702
+ safeTx.refundReceiver,
2703
+ signature
2704
+ ]
2705
+ });
2706
+ const receipt = await publicClient.waitForTransactionReceipt({
2707
+ hash: txHash
2708
+ });
2709
+ const safeLogs = receipt.logs.filter(
2710
+ (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
2711
+ );
2712
+ const parsed = _viem.parseEventLogs.call(void 0, {
2713
+ abi: SAFE_ABI,
2714
+ logs: safeLogs,
2715
+ strict: false
2716
+ });
2717
+ const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
2718
+ if (failed) {
2719
+ throw new Error("Safe transaction failed");
2720
+ }
2721
+ const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
2722
+ if (!succeeded) {
2723
+ throw new Error("Safe transaction status unavailable");
2724
+ }
2725
+ return { txHash };
2726
+ }
2727
+ async function executeSafeErc20Transfer(params) {
2728
+ const {
2729
+ walletClient,
2730
+ publicClient,
2731
+ safeAddress,
2732
+ tokenAddress,
2733
+ recipient,
2734
+ amount,
2735
+ chainId
2736
+ } = params;
2737
+ const account = walletClient.account;
2738
+ const chain = walletClient.chain;
2739
+ if (!account || !chain) {
2740
+ throw new Error("Wallet not connected");
2741
+ }
2742
+ if (chain.id !== chainId) {
2743
+ throw new Error(`Switch to ${_chunkIVTXEYB2cjs.getChainName.call(void 0, chainId)} to sign`);
2744
+ }
2745
+ const isOwner = await publicClient.readContract({
2746
+ address: safeAddress,
2747
+ abi: SAFE_ABI,
2748
+ functionName: "isOwner",
2749
+ args: [account.address]
2750
+ });
2751
+ if (!isOwner) {
2752
+ throw new Error("Connected wallet is not a Safe owner");
2753
+ }
2754
+ const data = _viem.encodeFunctionData.call(void 0, {
2755
+ abi: _viem.erc20Abi,
2756
+ functionName: "transfer",
2757
+ args: [recipient, amount]
2758
+ });
2759
+ const safeTx = {
2760
+ to: tokenAddress,
2761
+ value: 0n,
2762
+ data,
2763
+ operation: 0,
2764
+ safeTxGas: 0n,
2765
+ baseGas: 0n,
2766
+ gasPrice: 0n,
2767
+ gasToken: _viem.zeroAddress,
2768
+ refundReceiver: _viem.zeroAddress
2769
+ };
2770
+ const signature = _viem.concat.call(void 0, [
2771
+ _viem.pad.call(void 0, account.address, { size: 32 }),
2772
+ _viem.pad.call(void 0, _viem.toHex.call(void 0, 0), { size: 32 }),
2773
+ _viem.toHex.call(void 0, 1, { size: 1 })
2774
+ ]);
2775
+ const txHash = await walletClient.writeContract({
2776
+ account,
2777
+ chain,
2778
+ address: safeAddress,
2779
+ abi: SAFE_ABI,
2780
+ functionName: "execTransaction",
2781
+ args: [
2782
+ safeTx.to,
2783
+ safeTx.value,
2784
+ safeTx.data,
2785
+ safeTx.operation,
2786
+ safeTx.safeTxGas,
2787
+ safeTx.baseGas,
2788
+ safeTx.gasPrice,
2789
+ safeTx.gasToken,
2790
+ safeTx.refundReceiver,
2791
+ signature
2792
+ ]
2793
+ });
2794
+ const receipt = await publicClient.waitForTransactionReceipt({
2795
+ hash: txHash
2796
+ });
2797
+ const safeLogs = receipt.logs.filter(
2798
+ (log) => log.address.toLowerCase() === safeAddress.toLowerCase()
2799
+ );
2800
+ const parsed = _viem.parseEventLogs.call(void 0, {
2801
+ abi: SAFE_ABI,
2802
+ logs: safeLogs,
2803
+ strict: false
2804
+ });
2805
+ const failed = parsed.find((log) => log.eventName === "ExecutionFailure");
2806
+ if (failed) {
2807
+ throw new Error("Safe transaction failed");
2808
+ }
2809
+ const succeeded = parsed.find((log) => log.eventName === "ExecutionSuccess");
2810
+ if (!succeeded) {
2811
+ throw new Error("Safe transaction status unavailable");
2812
+ }
2813
+ return { txHash };
2814
+ }
2815
+ var SAFE_TX_TYPES = {
2816
+ SafeTx: [
2817
+ { name: "to", type: "address" },
2818
+ { name: "value", type: "uint256" },
2819
+ { name: "data", type: "bytes" },
2820
+ { name: "operation", type: "uint8" },
2821
+ { name: "safeTxGas", type: "uint256" },
2822
+ { name: "baseGas", type: "uint256" },
2823
+ { name: "gasPrice", type: "uint256" },
2824
+ { name: "gasToken", type: "address" },
2825
+ { name: "refundReceiver", type: "address" },
2826
+ { name: "nonce", type: "uint256" }
2827
+ ]
2828
+ };
2829
+ async function buildSafeTransaction(params) {
2830
+ const { publicClient, safeAddress, to, value, data, chainId } = params;
2831
+ const nonce = await publicClient.readContract({
2832
+ address: safeAddress,
2833
+ abi: SAFE_ABI,
2834
+ functionName: "nonce"
2835
+ });
2836
+ const message = {
2837
+ to,
2838
+ value,
2839
+ data,
2840
+ operation: 0,
2841
+ safeTxGas: 0n,
2842
+ baseGas: 0n,
2843
+ gasPrice: 0n,
2844
+ gasToken: _viem.zeroAddress,
2845
+ refundReceiver: _viem.zeroAddress,
2846
+ nonce
2847
+ };
2848
+ const safeTxHash = _viem.hashTypedData.call(void 0, {
2849
+ domain: { chainId, verifyingContract: safeAddress },
2850
+ types: SAFE_TX_TYPES,
2851
+ primaryType: "SafeTx",
2852
+ message
2853
+ });
2854
+ return {
2855
+ chainId,
2856
+ safeAddress,
2857
+ safeTxHash,
2858
+ typedData: {
2859
+ domain: { chainId, verifyingContract: safeAddress },
2860
+ types: SAFE_TX_TYPES,
2861
+ primaryType: "SafeTx",
2862
+ message
2863
+ }
2864
+ };
2865
+ }
2866
+
2567
2867
  // src/core/public-client.ts
2568
2868
 
2569
2869
  var clientCache = /* @__PURE__ */ new Map();
@@ -2580,6 +2880,61 @@ function getPublicClient(chainId) {
2580
2880
  return client;
2581
2881
  }
2582
2882
 
2883
+ // src/core/session-owner.ts
2884
+
2885
+
2886
+
2887
+
2888
+ var _accounts = require('viem/accounts');
2889
+ var STORAGE_PREFIX = "rhinestone:session-owner";
2890
+ function storageKey(eoaAddress) {
2891
+ return `${STORAGE_PREFIX}:${eoaAddress.toLowerCase()}`;
2892
+ }
2893
+ function loadSessionOwnerFromStorage(eoaAddress) {
2894
+ if (typeof window === "undefined") return null;
2895
+ const raw = window.localStorage.getItem(storageKey(eoaAddress));
2896
+ if (!raw) return null;
2897
+ try {
2898
+ const parsed = JSON.parse(raw);
2899
+ if (!parsed.privateKey) return null;
2900
+ const account = _accounts.privateKeyToAccount.call(void 0, parsed.privateKey);
2901
+ return {
2902
+ privateKey: parsed.privateKey,
2903
+ address: account.address
2904
+ };
2905
+ } catch (e5) {
2906
+ return null;
2907
+ }
2908
+ }
2909
+ function saveSessionOwnerToStorage(eoaAddress, privateKey, address) {
2910
+ if (typeof window === "undefined") return;
2911
+ if (!_viem.isAddress.call(void 0, address)) return;
2912
+ const payload = {
2913
+ privateKey,
2914
+ address,
2915
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
2916
+ };
2917
+ window.localStorage.setItem(storageKey(eoaAddress), JSON.stringify(payload));
2918
+ }
2919
+ function createSessionOwnerKey() {
2920
+ const privateKey = _accounts.generatePrivateKey.call(void 0, );
2921
+ const account = _accounts.privateKeyToAccount.call(void 0, privateKey);
2922
+ return {
2923
+ privateKey,
2924
+ account,
2925
+ address: account.address
2926
+ };
2927
+ }
2928
+ function accountFromPrivateKey(privateKey) {
2929
+ return _accounts.privateKeyToAccount.call(void 0, privateKey);
2930
+ }
2931
+
2932
+
2933
+
2934
+
2935
+
2936
+
2937
+
2583
2938
 
2584
2939
 
2585
2940
 
@@ -2628,4 +2983,4 @@ function getPublicClient(chainId) {
2628
2983
 
2629
2984
 
2630
2985
 
2631
- exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.CoinsIcon = CoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowRightIcon = ArrowRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.PercentIcon = PercentIcon; exports.ClockIcon = ClockIcon; exports.PlusCircleIcon = PlusCircleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.BodyHeader = BodyHeader; exports.PoweredBy = PoweredBy; exports.ConnectStep = ConnectStep; exports.Spinner = Spinner; exports.Button = Button; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.parseEvmChainId = parseEvmChainId; exports.isSolanaCaip2 = isSolanaCaip2; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.Tooltip = Tooltip; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.useLatestRef = useLatestRef; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
2986
+ exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.HandCoinsIcon = HandCoinsIcon; exports.CoinsIcon = CoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowRightIcon = ArrowRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.PercentIcon = PercentIcon; exports.ClockIcon = ClockIcon; exports.PlusCircleIcon = PlusCircleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.BodyHeader = BodyHeader; exports.ListRow = ListRow; exports.PoweredBy = PoweredBy; exports.Spinner = Spinner; exports.ConnectStep = ConnectStep; exports.Button = Button; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.parseEvmChainId = parseEvmChainId; exports.isSolanaCaip2 = isSolanaCaip2; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.Tooltip = Tooltip; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.useLatestRef = useLatestRef; exports.ProcessingStep = ProcessingStep; exports.SAFE_ABI = SAFE_ABI; exports.executeSafeEthTransfer = executeSafeEthTransfer; exports.executeSafeErc20Transfer = executeSafeErc20Transfer; exports.buildSafeTransaction = buildSafeTransaction; exports.getPublicClient = getPublicClient; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.applyTheme = applyTheme;