@rhinestone/deposit-modal 0.1.16 → 0.1.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.
- package/dist/index.cjs +41 -24
- package/dist/index.mjs +41 -24
- package/dist/styles.css +17 -16
- package/package.json +1 -1
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
|
|
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
|
|
2311
|
-
setError(
|
|
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)(
|
|
@@ -4474,8 +4490,8 @@ function WithdrawFormStep({
|
|
|
4474
4490
|
hasAttemptedSwitch.current = true;
|
|
4475
4491
|
setIsSwitching(true);
|
|
4476
4492
|
switchChain(asset.chainId).catch((err) => {
|
|
4477
|
-
const
|
|
4478
|
-
setError(
|
|
4493
|
+
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
4494
|
+
setError(formatUserError(raw));
|
|
4479
4495
|
}).finally(() => {
|
|
4480
4496
|
setIsSwitching(false);
|
|
4481
4497
|
});
|
|
@@ -4593,8 +4609,8 @@ function WithdrawFormStep({
|
|
|
4593
4609
|
try {
|
|
4594
4610
|
await onSubmit(recipient, amount);
|
|
4595
4611
|
} catch (err) {
|
|
4596
|
-
const
|
|
4597
|
-
setError(
|
|
4612
|
+
const raw = err instanceof Error ? err.message : "Withdrawal failed";
|
|
4613
|
+
setError(formatUserError(raw));
|
|
4598
4614
|
} finally {
|
|
4599
4615
|
setIsSubmitting(false);
|
|
4600
4616
|
}
|
|
@@ -4605,8 +4621,8 @@ function WithdrawFormStep({
|
|
|
4605
4621
|
try {
|
|
4606
4622
|
await switchChain(asset.chainId);
|
|
4607
4623
|
} catch (err) {
|
|
4608
|
-
const
|
|
4609
|
-
setError(
|
|
4624
|
+
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
4625
|
+
setError(formatUserError(raw));
|
|
4610
4626
|
} finally {
|
|
4611
4627
|
setIsSwitching(false);
|
|
4612
4628
|
}
|
|
@@ -5421,8 +5437,8 @@ function WithdrawFlow({
|
|
|
5421
5437
|
amount: amountUnits.toString()
|
|
5422
5438
|
});
|
|
5423
5439
|
} catch (err) {
|
|
5424
|
-
const
|
|
5425
|
-
handleError(
|
|
5440
|
+
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
5441
|
+
handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
|
|
5426
5442
|
throw err;
|
|
5427
5443
|
} finally {
|
|
5428
5444
|
setIsSubmitting(false);
|
|
@@ -5598,6 +5614,7 @@ var init_WithdrawFlow = __esm({
|
|
|
5598
5614
|
init_session_owner();
|
|
5599
5615
|
init_safe();
|
|
5600
5616
|
import_viem10 = require("viem");
|
|
5617
|
+
init_formatters();
|
|
5601
5618
|
import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5602
5619
|
}
|
|
5603
5620
|
});
|
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
|
|
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
|
|
2298
|
-
setError(
|
|
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(
|
|
@@ -4473,8 +4489,8 @@ function WithdrawFormStep({
|
|
|
4473
4489
|
hasAttemptedSwitch.current = true;
|
|
4474
4490
|
setIsSwitching(true);
|
|
4475
4491
|
switchChain(asset.chainId).catch((err) => {
|
|
4476
|
-
const
|
|
4477
|
-
setError(
|
|
4492
|
+
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
4493
|
+
setError(formatUserError(raw));
|
|
4478
4494
|
}).finally(() => {
|
|
4479
4495
|
setIsSwitching(false);
|
|
4480
4496
|
});
|
|
@@ -4592,8 +4608,8 @@ function WithdrawFormStep({
|
|
|
4592
4608
|
try {
|
|
4593
4609
|
await onSubmit(recipient, amount);
|
|
4594
4610
|
} catch (err) {
|
|
4595
|
-
const
|
|
4596
|
-
setError(
|
|
4611
|
+
const raw = err instanceof Error ? err.message : "Withdrawal failed";
|
|
4612
|
+
setError(formatUserError(raw));
|
|
4597
4613
|
} finally {
|
|
4598
4614
|
setIsSubmitting(false);
|
|
4599
4615
|
}
|
|
@@ -4604,8 +4620,8 @@ function WithdrawFormStep({
|
|
|
4604
4620
|
try {
|
|
4605
4621
|
await switchChain(asset.chainId);
|
|
4606
4622
|
} catch (err) {
|
|
4607
|
-
const
|
|
4608
|
-
setError(
|
|
4623
|
+
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
4624
|
+
setError(formatUserError(raw));
|
|
4609
4625
|
} finally {
|
|
4610
4626
|
setIsSwitching(false);
|
|
4611
4627
|
}
|
|
@@ -5428,8 +5444,8 @@ function WithdrawFlow({
|
|
|
5428
5444
|
amount: amountUnits.toString()
|
|
5429
5445
|
});
|
|
5430
5446
|
} catch (err) {
|
|
5431
|
-
const
|
|
5432
|
-
handleError(
|
|
5447
|
+
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
5448
|
+
handleError(formatUserError(raw), "WITHDRAW_FLOW_ERROR");
|
|
5433
5449
|
throw err;
|
|
5434
5450
|
} finally {
|
|
5435
5451
|
setIsSubmitting(false);
|
|
@@ -5601,6 +5617,7 @@ var init_WithdrawFlow = __esm({
|
|
|
5601
5617
|
init_account();
|
|
5602
5618
|
init_session_owner();
|
|
5603
5619
|
init_safe();
|
|
5620
|
+
init_formatters();
|
|
5604
5621
|
}
|
|
5605
5622
|
});
|
|
5606
5623
|
|
package/dist/styles.css
CHANGED
|
@@ -103,30 +103,30 @@
|
|
|
103
103
|
============================================================================= */
|
|
104
104
|
|
|
105
105
|
.rs-modal[data-theme="dark"] {
|
|
106
|
-
--color-gray1: #
|
|
107
|
-
--color-gray2: #
|
|
108
|
-
--color-gray3: #
|
|
109
|
-
--color-gray4: #
|
|
110
|
-
--color-gray5: #
|
|
111
|
-
--color-gray6: #
|
|
112
|
-
--color-gray7: #
|
|
113
|
-
--color-gray8: #
|
|
114
|
-
--color-gray9: #
|
|
115
|
-
--color-gray10: #
|
|
116
|
-
--color-gray11: #
|
|
117
|
-
--color-gray12: #
|
|
106
|
+
--color-gray1: #141414;
|
|
107
|
+
--color-gray2: #1a1a1a;
|
|
108
|
+
--color-gray3: #212121;
|
|
109
|
+
--color-gray4: #282828;
|
|
110
|
+
--color-gray5: #303030;
|
|
111
|
+
--color-gray6: #393939;
|
|
112
|
+
--color-gray7: #474747;
|
|
113
|
+
--color-gray8: #5e5e5e;
|
|
114
|
+
--color-gray9: #7a7a7a;
|
|
115
|
+
--color-gray10: #a0a0a0;
|
|
116
|
+
--color-gray11: #b8b8b8;
|
|
117
|
+
--color-gray12: #eeeeee;
|
|
118
118
|
|
|
119
119
|
/* Dark mode tints: translucent overlays instead of light pastels */
|
|
120
|
-
--color-blue3: rgba(0, 144, 255, 0.
|
|
120
|
+
--color-blue3: rgba(0, 144, 255, 0.1);
|
|
121
121
|
--color-blue4: rgba(0, 144, 255, 0.16);
|
|
122
122
|
--color-blue10: #3b9eff;
|
|
123
|
-
--color-green3: rgba(48, 164, 108, 0.
|
|
123
|
+
--color-green3: rgba(48, 164, 108, 0.1);
|
|
124
124
|
--color-green4: rgba(48, 164, 108, 0.16);
|
|
125
125
|
--color-green10: #3cb179;
|
|
126
|
-
--color-red3: rgba(229, 72, 77, 0.
|
|
126
|
+
--color-red3: rgba(229, 72, 77, 0.1);
|
|
127
127
|
--color-red4: rgba(229, 72, 77, 0.16);
|
|
128
128
|
--color-red10: #f16a6e;
|
|
129
|
-
--color-amber3: rgba(226, 163, 54, 0.
|
|
129
|
+
--color-amber3: rgba(226, 163, 54, 0.1);
|
|
130
130
|
|
|
131
131
|
--rs-shadow-dropdown:
|
|
132
132
|
0 4px 20px rgba(0, 0, 0, 0.6), 0 1px 4px rgba(0, 0, 0, 0.4);
|
|
@@ -608,6 +608,7 @@
|
|
|
608
608
|
|
|
609
609
|
.rs-step-footer--connect-empty {
|
|
610
610
|
padding-bottom: 14px;
|
|
611
|
+
margin-top: auto;
|
|
611
612
|
}
|
|
612
613
|
|
|
613
614
|
.rs-step-footer-buttons {
|