@rhinestone/deposit-modal 0.3.0-alpha.7 → 0.3.0-alpha.9

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.
@@ -11,7 +11,7 @@ import {
11
11
  getTokenDecimalsByAddress,
12
12
  getTokenIcon,
13
13
  getTokenSymbol
14
- } from "./chunk-UCZXBHLH.mjs";
14
+ } from "./chunk-SZIYS42B.mjs";
15
15
 
16
16
  // src/components/ui/Modal.tsx
17
17
  import {
@@ -1073,6 +1073,78 @@ function extractNumericString(data, key) {
1073
1073
  return Number.isFinite(parsed) ? parsed : null;
1074
1074
  }
1075
1075
 
1076
+ // src/core/formatters.ts
1077
+ var currencyFormatter = new Intl.NumberFormat("en-US", {
1078
+ style: "currency",
1079
+ currency: "USD",
1080
+ maximumFractionDigits: 2
1081
+ });
1082
+ var tokenFormatter = new Intl.NumberFormat("en-US", {
1083
+ minimumFractionDigits: 2,
1084
+ maximumFractionDigits: 5
1085
+ });
1086
+ function isUnsupportedChainSwitchError(error) {
1087
+ if (!error) return false;
1088
+ const name = error instanceof Error ? error.name : "";
1089
+ const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
1090
+ return name === "SwitchChainNotSupportedError" || message.includes("does not support programmatic chain switching") || message.includes("switch chain not supported") || message.includes("method not found") || message.includes("does not exist") || message.includes("is not available");
1091
+ }
1092
+ function formatUserError(raw) {
1093
+ const lower = raw.toLowerCase();
1094
+ if (lower.includes("user rejected") || lower.includes("user denied")) {
1095
+ return "Transaction cancelled";
1096
+ }
1097
+ if (lower.includes("insufficient funds")) {
1098
+ return "Insufficient funds for this transaction";
1099
+ }
1100
+ if (lower.includes("nonce too low") || lower.includes("nonce too high")) {
1101
+ return "Transaction conflict \u2014 please try again";
1102
+ }
1103
+ if (lower.includes("execution reverted")) {
1104
+ return "Transaction would fail on-chain";
1105
+ }
1106
+ if (lower.includes("timed out") || lower.includes("took too long")) {
1107
+ return "Request timed out \u2014 please try again";
1108
+ }
1109
+ if (lower.includes("econnrefused") || lower.includes("econnreset") || lower.includes("enotfound") || lower.includes("fetch failed")) {
1110
+ return "Service unavailable \u2014 please try again";
1111
+ }
1112
+ if (lower.includes("recent blockhash") || lower.includes("latest blockhash")) {
1113
+ return "Solana RPC unavailable \u2014 please retry";
1114
+ }
1115
+ if (lower.includes("network") || lower.includes("disconnected")) {
1116
+ return "Network error \u2014 check your connection";
1117
+ }
1118
+ if (lower.includes("rate limit") || lower.includes("429")) {
1119
+ return "Rate limited \u2014 please try again shortly";
1120
+ }
1121
+ let cleaned = raw;
1122
+ const stripMarkers = [
1123
+ "\n\nRequest Arguments:",
1124
+ "\nRaw Call Arguments:",
1125
+ "\nRequest body:",
1126
+ "\nContract Call:",
1127
+ "\nDocs:",
1128
+ "\nDetails:",
1129
+ "\nVersion:",
1130
+ "\nURL:"
1131
+ ];
1132
+ for (const marker of stripMarkers) {
1133
+ const idx = cleaned.indexOf(marker);
1134
+ if (idx !== -1) {
1135
+ cleaned = cleaned.slice(0, idx).trim();
1136
+ }
1137
+ }
1138
+ cleaned = cleaned.replace(/https?:\/\/\S+/g, "").trim();
1139
+ if (cleaned.length === 0) {
1140
+ return "An unexpected error occurred";
1141
+ }
1142
+ if (cleaned.length > 120) {
1143
+ return cleaned.slice(0, 120) + "...";
1144
+ }
1145
+ return cleaned;
1146
+ }
1147
+
1076
1148
  // src/core/useLatestRef.ts
1077
1149
  import { useEffect as useEffect2, useRef as useRef2 } from "react";
1078
1150
  function useLatestRef(value) {
@@ -1714,7 +1786,7 @@ function ConnectStep({
1714
1786
  const hasReownWallet = rows.some(
1715
1787
  (row) => row.kind === "external" || row.kind === "solana"
1716
1788
  );
1717
- const showDappImports = hasReownWallet && (dappImports?.length ?? 0) > 0;
1789
+ const showDappImports = (dappImports?.length ?? 0) > 0;
1718
1790
  const extraChainCount = Math.max(0, getSupportedChainIds().length - 3);
1719
1791
  const chainBadge2 = /* @__PURE__ */ jsxs6(Fragment2, { children: [
1720
1792
  /* @__PURE__ */ jsx8(ChainBadgeIcons, {}),
@@ -1747,7 +1819,6 @@ function ConnectStep({
1747
1819
  rows.map((row) => {
1748
1820
  const collapseToExternal = Boolean(onSelectTransferCrypto) && row.kind !== "solana";
1749
1821
  const subtitleText = row.state === "loading" ? "Preparing\u2026" : row.state === "error" ? row.errorReason ?? "Couldn't prepare wallet \u2014 tap to retry" : shorten(row.address);
1750
- const showInlineDisconnect = Boolean(onSelectTransferCrypto) && Boolean(onDisconnect) && row.state !== "loading";
1751
1822
  return /* @__PURE__ */ jsx8(
1752
1823
  ListRow,
1753
1824
  {
@@ -1756,8 +1827,7 @@ function ConnectStep({
1756
1827
  subtitle: subtitleText,
1757
1828
  onClick: () => onConfirmWallet?.(row.id),
1758
1829
  disabled: row.state === "loading",
1759
- trailing: renderRowTrailing(row.state),
1760
- action: showInlineDisconnect && onDisconnect ? { label: "Disconnect", onClick: onDisconnect } : void 0
1830
+ trailing: renderRowTrailing(row.state)
1761
1831
  },
1762
1832
  row.id
1763
1833
  );
@@ -1776,7 +1846,20 @@ function ConnectStep({
1776
1846
  }
1777
1847
  ),
1778
1848
  showDappImports && dappImports?.map((row) => {
1779
- if (row.status === "loading") {
1849
+ if (!hasReownWallet) {
1850
+ return /* @__PURE__ */ jsx8(
1851
+ ListRow,
1852
+ {
1853
+ leading: row.icon,
1854
+ title: row.label,
1855
+ subtitle: "Connect wallet to view balance",
1856
+ onClick: handleConnect,
1857
+ disabled: !handleConnect
1858
+ },
1859
+ row.id
1860
+ );
1861
+ }
1862
+ if (row.status === "loading" || row.status === "needs-connect") {
1780
1863
  return /* @__PURE__ */ jsx8(
1781
1864
  ListRow,
1782
1865
  {
@@ -1826,77 +1909,20 @@ function ConnectStep({
1826
1909
  })
1827
1910
  ] })
1828
1911
  ] }),
1912
+ onDisconnect && hasReownWallet && /* @__PURE__ */ jsx8("div", { className: "rs-screen-tight-row", children: /* @__PURE__ */ jsx8(
1913
+ "button",
1914
+ {
1915
+ type: "button",
1916
+ className: "rs-connect-wallet-manage",
1917
+ onClick: onDisconnect,
1918
+ children: "Disconnect wallet"
1919
+ }
1920
+ ) }),
1829
1921
  /* @__PURE__ */ jsx8(PoweredBy, {})
1830
1922
  ] });
1831
1923
  }
1832
1924
  ConnectStep.displayName = "ConnectStep";
1833
1925
 
1834
- // src/core/formatters.ts
1835
- var currencyFormatter = new Intl.NumberFormat("en-US", {
1836
- style: "currency",
1837
- currency: "USD",
1838
- maximumFractionDigits: 2
1839
- });
1840
- var tokenFormatter = new Intl.NumberFormat("en-US", {
1841
- minimumFractionDigits: 2,
1842
- maximumFractionDigits: 5
1843
- });
1844
- function formatUserError(raw) {
1845
- const lower = raw.toLowerCase();
1846
- if (lower.includes("user rejected") || lower.includes("user denied")) {
1847
- return "Transaction cancelled";
1848
- }
1849
- if (lower.includes("insufficient funds")) {
1850
- return "Insufficient funds for this transaction";
1851
- }
1852
- if (lower.includes("nonce too low") || lower.includes("nonce too high")) {
1853
- return "Transaction conflict \u2014 please try again";
1854
- }
1855
- if (lower.includes("execution reverted")) {
1856
- return "Transaction would fail on-chain";
1857
- }
1858
- if (lower.includes("timed out") || lower.includes("took too long")) {
1859
- return "Request timed out \u2014 please try again";
1860
- }
1861
- if (lower.includes("econnrefused") || lower.includes("econnreset") || lower.includes("enotfound") || lower.includes("fetch failed")) {
1862
- return "Service unavailable \u2014 please try again";
1863
- }
1864
- if (lower.includes("recent blockhash") || lower.includes("latest blockhash")) {
1865
- return "Solana RPC unavailable \u2014 please retry";
1866
- }
1867
- if (lower.includes("network") || lower.includes("disconnected")) {
1868
- return "Network error \u2014 check your connection";
1869
- }
1870
- if (lower.includes("rate limit") || lower.includes("429")) {
1871
- return "Rate limited \u2014 please try again shortly";
1872
- }
1873
- let cleaned = raw;
1874
- const stripMarkers = [
1875
- "\n\nRequest Arguments:",
1876
- "\nRaw Call Arguments:",
1877
- "\nRequest body:",
1878
- "\nContract Call:",
1879
- "\nDocs:",
1880
- "\nDetails:",
1881
- "\nVersion:",
1882
- "\nURL:"
1883
- ];
1884
- for (const marker of stripMarkers) {
1885
- const idx = cleaned.indexOf(marker);
1886
- if (idx !== -1) {
1887
- cleaned = cleaned.slice(0, idx).trim();
1888
- }
1889
- }
1890
- cleaned = cleaned.replace(/https?:\/\/\S+/g, "").trim();
1891
- if (cleaned.length === 0) {
1892
- return "An unexpected error occurred";
1893
- }
1894
- if (cleaned.length > 120) {
1895
- return cleaned.slice(0, 120) + "...";
1896
- }
1897
- return cleaned;
1898
- }
1899
-
1900
1926
  // src/components/steps/ProcessingStep.tsx
1901
1927
  import { useEffect as useEffect4, useRef as useRef4, useState as useState2 } from "react";
1902
1928
  import { formatUnits } from "viem";
@@ -3210,6 +3236,7 @@ export {
3210
3236
  createDepositService,
3211
3237
  currencyFormatter,
3212
3238
  tokenFormatter,
3239
+ isUnsupportedChainSwitchError,
3213
3240
  formatUserError,
3214
3241
  Tooltip,
3215
3242
  getEventTxHash,