@rhinestone/deposit-modal 0.1.16 → 0.1.18

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.
package/dist/index.cjs CHANGED
@@ -1476,6 +1476,33 @@ var init_deposit_service = __esm({
1476
1476
  });
1477
1477
 
1478
1478
  // src/core/formatters.ts
1479
+ function formatUserError(raw) {
1480
+ const lower = raw.toLowerCase();
1481
+ if (lower.includes("user rejected") || lower.includes("user denied")) {
1482
+ return "Transaction cancelled";
1483
+ }
1484
+ if (lower.includes("insufficient funds")) {
1485
+ return "Insufficient funds for this transaction";
1486
+ }
1487
+ if (lower.includes("nonce too low") || lower.includes("nonce too high")) {
1488
+ return "Transaction conflict \u2014 please try again";
1489
+ }
1490
+ if (lower.includes("execution reverted")) {
1491
+ return "Transaction would fail on-chain";
1492
+ }
1493
+ if (lower.includes("network") || lower.includes("disconnected")) {
1494
+ return "Network error \u2014 check your connection";
1495
+ }
1496
+ const detailsCut = raw.indexOf("\n\nRequest Arguments:");
1497
+ if (detailsCut !== -1) {
1498
+ const short = raw.slice(0, detailsCut).trim();
1499
+ return short.length > 80 ? short.slice(0, 80) + "..." : short;
1500
+ }
1501
+ if (raw.length > 80) {
1502
+ return raw.slice(0, 80) + "...";
1503
+ }
1504
+ return raw;
1505
+ }
1479
1506
  var currencyFormatter, tokenFormatter;
1480
1507
  var init_formatters = __esm({
1481
1508
  "src/core/formatters.ts"() {
@@ -2294,7 +2321,8 @@ function ConfirmStep({
2294
2321
  onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
2295
2322
  onConfirm(hash, asset.chainId, amountUnits.toString(), asset.token);
2296
2323
  } catch (err) {
2297
- const message = err instanceof Error ? err.message : "Transfer failed";
2324
+ const raw = err instanceof Error ? err.message : "Transfer failed";
2325
+ const message = formatUserError(raw);
2298
2326
  setError(message);
2299
2327
  onError?.(message, "TRANSFER_ERROR");
2300
2328
  } finally {
@@ -2307,8 +2335,8 @@ function ConfirmStep({
2307
2335
  try {
2308
2336
  await switchChain(asset.chainId);
2309
2337
  } catch (err) {
2310
- const message = err instanceof Error ? err.message : "Failed to switch chain";
2311
- setError(message);
2338
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
2339
+ setError(formatUserError(raw));
2312
2340
  } finally {
2313
2341
  setIsSwitching(false);
2314
2342
  }
@@ -2452,19 +2480,7 @@ function ConfirmStep({
2452
2480
  )
2453
2481
  }
2454
2482
  ),
2455
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2456
- "span",
2457
- {
2458
- className: "rs-alert-text",
2459
- style: {
2460
- overflow: "hidden",
2461
- textOverflow: "ellipsis",
2462
- whiteSpace: "nowrap",
2463
- display: "block"
2464
- },
2465
- children: error.includes("User rejected") || error.includes("User denied") ? "Transaction rejected by user" : error.length > 60 ? error.slice(0, 60) + "..." : error
2466
- }
2467
- )
2483
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "rs-alert-text", children: error })
2468
2484
  ] })
2469
2485
  ] }),
2470
2486
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rs-step-footer", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -4032,8 +4048,11 @@ function applyTheme(element, theme) {
4032
4048
  if (theme?.ctaColor) {
4033
4049
  element.style.setProperty("--rs-primary", theme.ctaColor);
4034
4050
  element.style.setProperty("--rs-border-accent", theme.ctaColor);
4035
- }
4036
- if (theme?.ctaHoverColor) {
4051
+ element.style.setProperty(
4052
+ "--rs-primary-hover",
4053
+ theme.ctaHoverColor ?? theme.ctaColor
4054
+ );
4055
+ } else if (theme?.ctaHoverColor) {
4037
4056
  element.style.setProperty("--rs-primary-hover", theme.ctaHoverColor);
4038
4057
  }
4039
4058
  if (theme?.borderColor) {
@@ -4474,8 +4493,8 @@ function WithdrawFormStep({
4474
4493
  hasAttemptedSwitch.current = true;
4475
4494
  setIsSwitching(true);
4476
4495
  switchChain(asset.chainId).catch((err) => {
4477
- const message = err instanceof Error ? err.message : "Failed to switch chain";
4478
- setError(message);
4496
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
4497
+ setError(formatUserError(raw));
4479
4498
  }).finally(() => {
4480
4499
  setIsSwitching(false);
4481
4500
  });
@@ -4593,8 +4612,8 @@ function WithdrawFormStep({
4593
4612
  try {
4594
4613
  await onSubmit(recipient, amount);
4595
4614
  } catch (err) {
4596
- const message = err instanceof Error ? err.message : "Withdrawal failed";
4597
- setError(message);
4615
+ const raw = err instanceof Error ? err.message : "Withdrawal failed";
4616
+ setError(formatUserError(raw));
4598
4617
  } finally {
4599
4618
  setIsSubmitting(false);
4600
4619
  }
@@ -4605,8 +4624,8 @@ function WithdrawFormStep({
4605
4624
  try {
4606
4625
  await switchChain(asset.chainId);
4607
4626
  } catch (err) {
4608
- const message = err instanceof Error ? err.message : "Failed to switch chain";
4609
- setError(message);
4627
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
4628
+ setError(formatUserError(raw));
4610
4629
  } finally {
4611
4630
  setIsSwitching(false);
4612
4631
  }
@@ -5421,8 +5440,8 @@ function WithdrawFlow({
5421
5440
  amount: amountUnits.toString()
5422
5441
  });
5423
5442
  } catch (err) {
5424
- const message = err instanceof Error ? err.message : "Withdraw failed";
5425
- handleError(message, "WITHDRAW_FLOW_ERROR");
5443
+ const raw = err instanceof Error ? err.message : "Withdraw failed";
5444
+ handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
5426
5445
  throw err;
5427
5446
  } finally {
5428
5447
  setIsSubmitting(false);
@@ -5598,6 +5617,7 @@ var init_WithdrawFlow = __esm({
5598
5617
  init_session_owner();
5599
5618
  init_safe();
5600
5619
  import_viem10 = require("viem");
5620
+ init_formatters();
5601
5621
  import_jsx_runtime19 = require("react/jsx-runtime");
5602
5622
  }
5603
5623
  });
package/dist/index.mjs CHANGED
@@ -1462,6 +1462,33 @@ var init_deposit_service = __esm({
1462
1462
  });
1463
1463
 
1464
1464
  // src/core/formatters.ts
1465
+ function formatUserError(raw) {
1466
+ const lower = raw.toLowerCase();
1467
+ if (lower.includes("user rejected") || lower.includes("user denied")) {
1468
+ return "Transaction cancelled";
1469
+ }
1470
+ if (lower.includes("insufficient funds")) {
1471
+ return "Insufficient funds for this transaction";
1472
+ }
1473
+ if (lower.includes("nonce too low") || lower.includes("nonce too high")) {
1474
+ return "Transaction conflict \u2014 please try again";
1475
+ }
1476
+ if (lower.includes("execution reverted")) {
1477
+ return "Transaction would fail on-chain";
1478
+ }
1479
+ if (lower.includes("network") || lower.includes("disconnected")) {
1480
+ return "Network error \u2014 check your connection";
1481
+ }
1482
+ const detailsCut = raw.indexOf("\n\nRequest Arguments:");
1483
+ if (detailsCut !== -1) {
1484
+ const short = raw.slice(0, detailsCut).trim();
1485
+ return short.length > 80 ? short.slice(0, 80) + "..." : short;
1486
+ }
1487
+ if (raw.length > 80) {
1488
+ return raw.slice(0, 80) + "...";
1489
+ }
1490
+ return raw;
1491
+ }
1465
1492
  var currencyFormatter, tokenFormatter;
1466
1493
  var init_formatters = __esm({
1467
1494
  "src/core/formatters.ts"() {
@@ -2281,7 +2308,8 @@ function ConfirmStep({
2281
2308
  onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
2282
2309
  onConfirm(hash, asset.chainId, amountUnits.toString(), asset.token);
2283
2310
  } catch (err) {
2284
- const message = err instanceof Error ? err.message : "Transfer failed";
2311
+ const raw = err instanceof Error ? err.message : "Transfer failed";
2312
+ const message = formatUserError(raw);
2285
2313
  setError(message);
2286
2314
  onError?.(message, "TRANSFER_ERROR");
2287
2315
  } finally {
@@ -2294,8 +2322,8 @@ function ConfirmStep({
2294
2322
  try {
2295
2323
  await switchChain(asset.chainId);
2296
2324
  } catch (err) {
2297
- const message = err instanceof Error ? err.message : "Failed to switch chain";
2298
- setError(message);
2325
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
2326
+ setError(formatUserError(raw));
2299
2327
  } finally {
2300
2328
  setIsSwitching(false);
2301
2329
  }
@@ -2439,19 +2467,7 @@ function ConfirmStep({
2439
2467
  )
2440
2468
  }
2441
2469
  ),
2442
- /* @__PURE__ */ jsx10(
2443
- "span",
2444
- {
2445
- className: "rs-alert-text",
2446
- style: {
2447
- overflow: "hidden",
2448
- textOverflow: "ellipsis",
2449
- whiteSpace: "nowrap",
2450
- display: "block"
2451
- },
2452
- children: error.includes("User rejected") || error.includes("User denied") ? "Transaction rejected by user" : error.length > 60 ? error.slice(0, 60) + "..." : error
2453
- }
2454
- )
2470
+ /* @__PURE__ */ jsx10("span", { className: "rs-alert-text", children: error })
2455
2471
  ] })
2456
2472
  ] }),
2457
2473
  /* @__PURE__ */ jsx10("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx10(
@@ -4014,8 +4030,11 @@ function applyTheme(element, theme) {
4014
4030
  if (theme?.ctaColor) {
4015
4031
  element.style.setProperty("--rs-primary", theme.ctaColor);
4016
4032
  element.style.setProperty("--rs-border-accent", theme.ctaColor);
4017
- }
4018
- if (theme?.ctaHoverColor) {
4033
+ element.style.setProperty(
4034
+ "--rs-primary-hover",
4035
+ theme.ctaHoverColor ?? theme.ctaColor
4036
+ );
4037
+ } else if (theme?.ctaHoverColor) {
4019
4038
  element.style.setProperty("--rs-primary-hover", theme.ctaHoverColor);
4020
4039
  }
4021
4040
  if (theme?.borderColor) {
@@ -4473,8 +4492,8 @@ function WithdrawFormStep({
4473
4492
  hasAttemptedSwitch.current = true;
4474
4493
  setIsSwitching(true);
4475
4494
  switchChain(asset.chainId).catch((err) => {
4476
- const message = err instanceof Error ? err.message : "Failed to switch chain";
4477
- setError(message);
4495
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
4496
+ setError(formatUserError(raw));
4478
4497
  }).finally(() => {
4479
4498
  setIsSwitching(false);
4480
4499
  });
@@ -4592,8 +4611,8 @@ function WithdrawFormStep({
4592
4611
  try {
4593
4612
  await onSubmit(recipient, amount);
4594
4613
  } catch (err) {
4595
- const message = err instanceof Error ? err.message : "Withdrawal failed";
4596
- setError(message);
4614
+ const raw = err instanceof Error ? err.message : "Withdrawal failed";
4615
+ setError(formatUserError(raw));
4597
4616
  } finally {
4598
4617
  setIsSubmitting(false);
4599
4618
  }
@@ -4604,8 +4623,8 @@ function WithdrawFormStep({
4604
4623
  try {
4605
4624
  await switchChain(asset.chainId);
4606
4625
  } catch (err) {
4607
- const message = err instanceof Error ? err.message : "Failed to switch chain";
4608
- setError(message);
4626
+ const raw = err instanceof Error ? err.message : "Failed to switch chain";
4627
+ setError(formatUserError(raw));
4609
4628
  } finally {
4610
4629
  setIsSwitching(false);
4611
4630
  }
@@ -5428,8 +5447,8 @@ function WithdrawFlow({
5428
5447
  amount: amountUnits.toString()
5429
5448
  });
5430
5449
  } catch (err) {
5431
- const message = err instanceof Error ? err.message : "Withdraw failed";
5432
- handleError(message, "WITHDRAW_FLOW_ERROR");
5450
+ const raw = err instanceof Error ? err.message : "Withdraw failed";
5451
+ handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
5433
5452
  throw err;
5434
5453
  } finally {
5435
5454
  setIsSubmitting(false);
@@ -5601,6 +5620,7 @@ var init_WithdrawFlow = __esm({
5601
5620
  init_account();
5602
5621
  init_session_owner();
5603
5622
  init_safe();
5623
+ init_formatters();
5604
5624
  }
5605
5625
  });
5606
5626
 
package/dist/styles.css CHANGED
@@ -20,13 +20,19 @@
20
20
  --color-gray11: #646464;
21
21
  --color-gray12: #202020;
22
22
 
23
- /* Blue accent (primary action) */
23
+ /* Blue (info) */
24
24
  --color-blue3: #e6f4fe;
25
25
  --color-blue4: #d5efff;
26
26
  --color-blue9: #0090ff;
27
27
  --color-blue10: #0588f0;
28
28
  --color-blue11: #0d74ce;
29
29
 
30
+ /* Neutral accent (primary action) */
31
+ --color-neutral3: #f4f4f5;
32
+ --color-neutral4: #e4e4e7;
33
+ --color-neutral9: #18181b;
34
+ --color-neutral10: #27272a;
35
+
30
36
  /* Green (success) */
31
37
  --color-green3: #e6f6eb;
32
38
  --color-green4: #d6f1df;
@@ -48,9 +54,9 @@
48
54
  --rs-background-secondary: var(--color-gray2);
49
55
  --rs-surface: var(--color-gray3);
50
56
  --rs-surface-hover: var(--color-gray4);
51
- --rs-primary: var(--color-blue9);
52
- --rs-primary-hover: var(--color-blue10);
53
- --rs-primary-tint: var(--color-blue3);
57
+ --rs-primary: var(--color-neutral9);
58
+ --rs-primary-hover: var(--color-neutral10);
59
+ --rs-primary-tint: var(--color-neutral3);
54
60
  --rs-primary-foreground: #ffffff;
55
61
  --rs-success: var(--color-green9);
56
62
  --rs-success-tint: var(--color-green3);
@@ -65,7 +71,7 @@
65
71
 
66
72
  --rs-border: var(--color-gray5);
67
73
  --rs-border-surface: var(--color-gray4);
68
- --rs-border-accent: var(--color-blue9);
74
+ --rs-border-accent: var(--color-neutral9);
69
75
 
70
76
  --rs-secondary: var(--color-gray3);
71
77
  --rs-secondary-hover: var(--color-gray4);
@@ -103,30 +109,37 @@
103
109
  ============================================================================= */
104
110
 
105
111
  .rs-modal[data-theme="dark"] {
106
- --color-gray1: #050505;
107
- --color-gray2: #0a0a0a;
108
- --color-gray3: #131313;
109
- --color-gray4: #1a1a1a;
110
- --color-gray5: #232323;
111
- --color-gray6: #2c2c2c;
112
- --color-gray7: #3b3b3b;
113
- --color-gray8: #525252;
114
- --color-gray9: #6e6e6e;
115
- --color-gray10: #9a9a9a;
116
- --color-gray11: #b0b0b0;
117
- --color-gray12: #ededed;
112
+ --color-gray1: #141414;
113
+ --color-gray2: #1a1a1a;
114
+ --color-gray3: #212121;
115
+ --color-gray4: #282828;
116
+ --color-gray5: #303030;
117
+ --color-gray6: #393939;
118
+ --color-gray7: #474747;
119
+ --color-gray8: #5e5e5e;
120
+ --color-gray9: #7a7a7a;
121
+ --color-gray10: #a0a0a0;
122
+ --color-gray11: #b8b8b8;
123
+ --color-gray12: #eeeeee;
118
124
 
119
125
  /* Dark mode tints: translucent overlays instead of light pastels */
120
- --color-blue3: rgba(0, 144, 255, 0.10);
126
+ --color-blue3: rgba(0, 144, 255, 0.1);
121
127
  --color-blue4: rgba(0, 144, 255, 0.16);
122
128
  --color-blue10: #3b9eff;
123
- --color-green3: rgba(48, 164, 108, 0.10);
129
+ --color-green3: rgba(48, 164, 108, 0.1);
124
130
  --color-green4: rgba(48, 164, 108, 0.16);
125
131
  --color-green10: #3cb179;
126
- --color-red3: rgba(229, 72, 77, 0.10);
132
+ --color-red3: rgba(229, 72, 77, 0.1);
127
133
  --color-red4: rgba(229, 72, 77, 0.16);
128
134
  --color-red10: #f16a6e;
129
- --color-amber3: rgba(226, 163, 54, 0.10);
135
+ --color-amber3: rgba(226, 163, 54, 0.1);
136
+
137
+ --color-neutral3: rgba(244, 244, 245, 0.08);
138
+ --color-neutral4: rgba(244, 244, 245, 0.14);
139
+ --color-neutral9: #f4f4f5;
140
+ --color-neutral10: #e4e4e7;
141
+
142
+ --rs-primary-foreground: #18181b;
130
143
 
131
144
  --rs-shadow-dropdown:
132
145
  0 4px 20px rgba(0, 0, 0, 0.6), 0 1px 4px rgba(0, 0, 0, 0.4);
@@ -608,6 +621,7 @@
608
621
 
609
622
  .rs-step-footer--connect-empty {
610
623
  padding-bottom: 14px;
624
+ margin-top: auto;
611
625
  }
612
626
 
613
627
  .rs-step-footer-buttons {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/deposit-modal",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "React modal component for Rhinestone cross-chain deposits",
5
5
  "author": "Rhinestone <dev@rhinestone.wtf>",
6
6
  "bugs": {