@rhinestone/deposit-modal 0.18.0 → 0.19.0
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/README.md +49 -8
- package/dist/{DepositModalReown-TVO3ZQQK.cjs → DepositModalReown-UITYXJ6W.cjs} +16 -16
- package/dist/{DepositModalReown-VCY65DJX.mjs → DepositModalReown-XBNY6QCI.mjs} +3 -3
- package/dist/{WithdrawModal-RMCYJJ4S.mjs → WithdrawModal-DY6A55OA.mjs} +3 -3
- package/dist/WithdrawModal-V42OK7L3.cjs +11 -0
- package/dist/{chunk-AIZKGFVA.mjs → chunk-5NWLS5BQ.mjs} +69 -19
- package/dist/{chunk-R2B6VD4E.mjs → chunk-BIL4ENC3.mjs} +1 -1
- package/dist/{chunk-34JVJZEZ.cjs → chunk-EG4H7OMC.cjs} +71 -71
- package/dist/{chunk-N3AAT6BS.cjs → chunk-HMUGY66O.cjs} +226 -176
- package/dist/{chunk-O4JZKKCZ.cjs → chunk-ISLVD5HQ.cjs} +2 -2
- package/dist/{chunk-EKC2IRQG.mjs → chunk-NITKDXHR.mjs} +211 -31
- package/dist/{chunk-JV5OGG53.cjs → chunk-OCWSMLOP.cjs} +724 -544
- package/dist/{chunk-N6JJG57R.cjs → chunk-PYOC6K24.cjs} +1 -1
- package/dist/{chunk-3TEVMP76.mjs → chunk-X6N2XPTO.mjs} +1 -1
- package/dist/{chunk-X4EUXBHJ.mjs → chunk-ZGHVJ2XM.mjs} +1 -1
- package/dist/compliance.cjs +4 -4
- package/dist/compliance.mjs +2 -2
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +4 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +3 -3
- package/dist/embed.cjs +14 -14
- package/dist/embed.d.cts +1 -1
- package/dist/embed.d.ts +1 -1
- package/dist/embed.mjs +4 -4
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/offramp.cjs +9 -9
- package/dist/offramp.mjs +7 -7
- package/dist/onramp.cjs +24 -11
- package/dist/onramp.d.cts +24 -6
- package/dist/onramp.d.ts +24 -6
- package/dist/onramp.mjs +22 -9
- package/dist/styles.css +25 -0
- package/dist/{types-CZYypODQ.d.ts → types-BOxa1DE-.d.ts} +37 -2
- package/dist/{types-CbUs4boj.d.cts → types-BShYNpvO.d.cts} +37 -2
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +5 -5
- package/dist/WithdrawModal-GR3HLYXU.cjs +0 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkPYOC6K24cjs = require('./chunk-PYOC6K24.cjs');
|
|
4
4
|
|
|
5
5
|
// src/core/bearer-transport.ts
|
|
6
6
|
var ScopedRequestError = class extends Error {
|
|
@@ -22,7 +22,7 @@ function createBearerTransport(options) {
|
|
|
22
22
|
const response = await fetch(`${base}${path}`, {
|
|
23
23
|
method: body === void 0 ? "GET" : "POST",
|
|
24
24
|
headers: {
|
|
25
|
-
...
|
|
25
|
+
..._chunkPYOC6K24cjs.serviceHeaders.call(void 0, ),
|
|
26
26
|
Authorization: `Bearer ${session.token}`
|
|
27
27
|
},
|
|
28
28
|
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
useRpcUrls,
|
|
106
106
|
useStableRpcUrls,
|
|
107
107
|
warnRemovedProps
|
|
108
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-5NWLS5BQ.mjs";
|
|
109
109
|
import {
|
|
110
110
|
HYPERCORE_CHAIN_ID,
|
|
111
111
|
HYPERCORE_MIN_DEPOSIT_USD,
|
|
@@ -1083,6 +1083,16 @@ function AnimatedAmountInput({
|
|
|
1083
1083
|
|
|
1084
1084
|
// src/components/steps/AmountStep.tsx
|
|
1085
1085
|
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1086
|
+
function requiredSourceAmount(quote, decimals) {
|
|
1087
|
+
const raw = quote?.input?.amount;
|
|
1088
|
+
if (raw === void 0) return null;
|
|
1089
|
+
try {
|
|
1090
|
+
return formatUnits2(BigInt(raw), decimals);
|
|
1091
|
+
} catch {
|
|
1092
|
+
return null;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
var PAYMENT_QUOTE_REFRESH_MS = 3e4;
|
|
1086
1096
|
var PRESETS = [
|
|
1087
1097
|
{ value: 25, label: "25%" },
|
|
1088
1098
|
{ value: 50, label: "50%" },
|
|
@@ -1113,6 +1123,8 @@ function AmountStep({
|
|
|
1113
1123
|
sourcePriceUnavailable = false,
|
|
1114
1124
|
appBalanceUsd,
|
|
1115
1125
|
title = "Wallet deposit",
|
|
1126
|
+
payment,
|
|
1127
|
+
account,
|
|
1116
1128
|
onContinue,
|
|
1117
1129
|
onCtaClick,
|
|
1118
1130
|
service
|
|
@@ -1120,6 +1132,7 @@ function AmountStep({
|
|
|
1120
1132
|
const [amount, setAmount] = useState3("");
|
|
1121
1133
|
const [balance, setBalance] = useState3(null);
|
|
1122
1134
|
const [error, setError] = useState3(null);
|
|
1135
|
+
const [paymentQuote, setPaymentQuote] = useState3("loading");
|
|
1123
1136
|
const hasAttemptedSwitch = useRef2(false);
|
|
1124
1137
|
const hasAppliedDefaultRef = useRef2(false);
|
|
1125
1138
|
const isMaxDefault = defaultAmount?.trim().toLowerCase() === "max";
|
|
@@ -1241,7 +1254,15 @@ function AmountStep({
|
|
|
1241
1254
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
1242
1255
|
}, [amount]);
|
|
1243
1256
|
const amountUsd = numericAmount;
|
|
1257
|
+
const lockedAmount = payment && typeof paymentQuote !== "string" ? requiredSourceAmount(paymentQuote, asset.decimals) : null;
|
|
1244
1258
|
const sourceAmountUnits = useMemo2(() => {
|
|
1259
|
+
if (lockedAmount !== null) {
|
|
1260
|
+
try {
|
|
1261
|
+
return parseUnits(lockedAmount, asset.decimals);
|
|
1262
|
+
} catch {
|
|
1263
|
+
return null;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1245
1266
|
if (numericAmount <= 0) return null;
|
|
1246
1267
|
const raw = isSourceStablecoin || !hasPricing ? numericAmount : numericAmount / (tokenPriceUsd ?? 1);
|
|
1247
1268
|
try {
|
|
@@ -1249,7 +1270,14 @@ function AmountStep({
|
|
|
1249
1270
|
} catch {
|
|
1250
1271
|
return null;
|
|
1251
1272
|
}
|
|
1252
|
-
}, [
|
|
1273
|
+
}, [
|
|
1274
|
+
lockedAmount,
|
|
1275
|
+
numericAmount,
|
|
1276
|
+
isSourceStablecoin,
|
|
1277
|
+
hasPricing,
|
|
1278
|
+
tokenPriceUsd,
|
|
1279
|
+
asset.decimals
|
|
1280
|
+
]);
|
|
1253
1281
|
const minDepositUsd = isHyperCoreDestination(targetChain) ? Math.max(HYPERCORE_MIN_DEPOSIT_USD, uiConfig?.minDepositUsd ?? 0) : uiConfig?.minDepositUsd ?? null;
|
|
1254
1282
|
const maxDepositUsd = uiConfig?.maxDepositUsd ?? null;
|
|
1255
1283
|
const isBelowMin = minDepositUsd !== null && numericAmount > 0 && amountUsd < minDepositUsd;
|
|
@@ -1263,6 +1291,36 @@ function AmountStep({
|
|
|
1263
1291
|
sourceAmountUnits
|
|
1264
1292
|
);
|
|
1265
1293
|
const balanceAfterUsd = appBalanceUsd !== void 0 ? appBalanceUsd + numericAmount : null;
|
|
1294
|
+
useEffect3(() => {
|
|
1295
|
+
if (!payment || !account) return;
|
|
1296
|
+
let active = true;
|
|
1297
|
+
setPaymentQuote("loading");
|
|
1298
|
+
const load = async () => {
|
|
1299
|
+
const result = await service.getQuotePreview({
|
|
1300
|
+
account,
|
|
1301
|
+
sourceChainId: asset.chainId,
|
|
1302
|
+
sourceToken: asset.token,
|
|
1303
|
+
direction: "exactOut",
|
|
1304
|
+
amountOut: payment.amount
|
|
1305
|
+
});
|
|
1306
|
+
if (!active) return;
|
|
1307
|
+
setPaymentQuote(
|
|
1308
|
+
result && "output" in result && result.input ? result : "unavailable"
|
|
1309
|
+
);
|
|
1310
|
+
};
|
|
1311
|
+
void load();
|
|
1312
|
+
const timer = setInterval(load, PAYMENT_QUOTE_REFRESH_MS);
|
|
1313
|
+
return () => {
|
|
1314
|
+
active = false;
|
|
1315
|
+
clearInterval(timer);
|
|
1316
|
+
};
|
|
1317
|
+
}, [
|
|
1318
|
+
payment,
|
|
1319
|
+
account,
|
|
1320
|
+
asset.chainId,
|
|
1321
|
+
asset.token,
|
|
1322
|
+
service
|
|
1323
|
+
]);
|
|
1266
1324
|
const handlePresetClick = (percentage) => {
|
|
1267
1325
|
if (balance === null) return;
|
|
1268
1326
|
onCtaClick?.(percentage === 100 ? "Max" : `${percentage}%`);
|
|
@@ -1286,6 +1344,19 @@ function AmountStep({
|
|
|
1286
1344
|
};
|
|
1287
1345
|
const handleContinue = async () => {
|
|
1288
1346
|
if (chainMismatch || boundViolation) return;
|
|
1347
|
+
if (payment) {
|
|
1348
|
+
if (!lockedAmount) return;
|
|
1349
|
+
if (balance !== null && parseUnits(lockedAmount, asset.decimals) > balance) {
|
|
1350
|
+
setError("Insufficient balance");
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
setError(null);
|
|
1354
|
+
onCtaClick?.("continue");
|
|
1355
|
+
const lockedUnits = Number(lockedAmount);
|
|
1356
|
+
const usd = isSourceStablecoin || !hasPricing ? lockedUnits : lockedUnits * (tokenPriceUsd ?? 1);
|
|
1357
|
+
onContinue(lockedAmount, usd.toString(), balance ?? void 0);
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1289
1360
|
let effectiveAmount = numericAmount;
|
|
1290
1361
|
if (isBelowMin && minDepositUsd !== null) {
|
|
1291
1362
|
effectiveAmount = minDepositUsd;
|
|
@@ -1323,7 +1394,13 @@ function AmountStep({
|
|
|
1323
1394
|
const knowsBalance = address !== void 0;
|
|
1324
1395
|
const needsPricing = !knowsBalance && !isSourceStablecoin;
|
|
1325
1396
|
const blockedOnPricing = needsPricing && !hasPricing;
|
|
1326
|
-
const continueDisabled =
|
|
1397
|
+
const continueDisabled = payment ? (
|
|
1398
|
+
// No input to validate — only whether the quote resolved and whether the
|
|
1399
|
+
// payer can cover it. Bounds still apply: they are the project's ingest
|
|
1400
|
+
// limits, so an invoice under a chain's minimum genuinely cannot be paid
|
|
1401
|
+
// that way and the payer has to be told, not left on a dead button.
|
|
1402
|
+
chainMismatch || lockedAmount === null || exceedsBalance || boundViolation !== null || knowsBalance && balance === null
|
|
1403
|
+
) : chainMismatch || exceedsBalance || boundViolation !== null || blockedOnPricing || numericAmount === 0 && !isBelowMin || knowsBalance && balance === null;
|
|
1327
1404
|
const chainName = useChainName();
|
|
1328
1405
|
const sourceChainName = chainName(asset.chainId);
|
|
1329
1406
|
const targetChainName = chainName(targetChainId);
|
|
@@ -1332,7 +1409,7 @@ function AmountStep({
|
|
|
1332
1409
|
/* @__PURE__ */ jsx8(BodyHeader, { icon: /* @__PURE__ */ jsx8(WalletIcon, {}), title }),
|
|
1333
1410
|
/* @__PURE__ */ jsxs6("div", { className: "rs-amount-section", children: [
|
|
1334
1411
|
/* @__PURE__ */ jsxs6("div", { className: "rs-amount-display", children: [
|
|
1335
|
-
/* @__PURE__ */ jsx8(
|
|
1412
|
+
payment ? /* @__PURE__ */ jsx8("div", { className: "rs-amount-fixed", "aria-label": "Amount to pay", children: lockedAmount ? `${tokenFormatter.format(Number(lockedAmount))} ${asset.symbol}` : "\u2014" }) : /* @__PURE__ */ jsx8(
|
|
1336
1413
|
AnimatedAmountInput,
|
|
1337
1414
|
{
|
|
1338
1415
|
value: amount,
|
|
@@ -1359,7 +1436,7 @@ function AmountStep({
|
|
|
1359
1436
|
] })
|
|
1360
1437
|
] })
|
|
1361
1438
|
] }),
|
|
1362
|
-
knowsBalance && /* @__PURE__ */ jsx8("div", { className: "rs-amount-presets", children: PRESETS.map((preset) => /* @__PURE__ */ jsx8(
|
|
1439
|
+
knowsBalance && !payment && /* @__PURE__ */ jsx8("div", { className: "rs-amount-presets", children: PRESETS.map((preset) => /* @__PURE__ */ jsx8(
|
|
1363
1440
|
"button",
|
|
1364
1441
|
{
|
|
1365
1442
|
type: "button",
|
|
@@ -1399,6 +1476,14 @@ function AmountStep({
|
|
|
1399
1476
|
/* @__PURE__ */ jsx8("span", { className: "rs-amount-detail-value", children: currencyFormatter.format(balanceAfterUsd) })
|
|
1400
1477
|
] })
|
|
1401
1478
|
] }),
|
|
1479
|
+
payment && paymentQuote === "unavailable" && /* @__PURE__ */ jsxs6(Callout, { variant: "error", children: [
|
|
1480
|
+
"This payment can't be priced from ",
|
|
1481
|
+
asset.symbol,
|
|
1482
|
+
" on",
|
|
1483
|
+
" ",
|
|
1484
|
+
sourceChainName,
|
|
1485
|
+
" right now. Try another asset."
|
|
1486
|
+
] }),
|
|
1402
1487
|
blockedOnPricing && sourcePriceUnavailable && /* @__PURE__ */ jsxs6(Callout, { variant: "error", children: [
|
|
1403
1488
|
asset.symbol,
|
|
1404
1489
|
" can't be priced right now, so this deposit can't be estimated. You can still send any amount to the deposit address."
|
|
@@ -1656,7 +1741,9 @@ function ConfirmStep({
|
|
|
1656
1741
|
onError,
|
|
1657
1742
|
onDepositSubmitted,
|
|
1658
1743
|
onSubmittingChange,
|
|
1659
|
-
executeTransfer
|
|
1744
|
+
executeTransfer,
|
|
1745
|
+
title = "Review deposit",
|
|
1746
|
+
routeThroughAccount = false
|
|
1660
1747
|
}) {
|
|
1661
1748
|
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
1662
1749
|
const [error, setError] = useState4(null);
|
|
@@ -1712,7 +1799,7 @@ function ConfirmStep({
|
|
|
1712
1799
|
const { display: feeDisplay, struck: feesFullySponsored } = quoteFeeRow(
|
|
1713
1800
|
quote?.fees
|
|
1714
1801
|
);
|
|
1715
|
-
const directTransfer = sameRoute && !mustHaveQuote && !executeTransfer;
|
|
1802
|
+
const directTransfer = sameRoute && !mustHaveQuote && !executeTransfer && !routeThroughAccount;
|
|
1716
1803
|
const permitEligible = enableGaslessDeposit && !isNativeAsset(asset) && !isDappImportAsset(asset) && !executeTransfer && !directTransfer && asset.chainId !== HYPERCORE_CHAIN_ID;
|
|
1717
1804
|
const permitRequestKey = JSON.stringify([
|
|
1718
1805
|
smartAccount.toLowerCase(),
|
|
@@ -2045,7 +2132,7 @@ function ConfirmStep({
|
|
|
2045
2132
|
};
|
|
2046
2133
|
return /* @__PURE__ */ jsxs8("div", { className: "rs-screen", children: [
|
|
2047
2134
|
/* @__PURE__ */ jsxs8("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
2048
|
-
/* @__PURE__ */ jsx10(BodyHeader, { icon: /* @__PURE__ */ jsx10(WalletIcon, {}), title
|
|
2135
|
+
/* @__PURE__ */ jsx10(BodyHeader, { icon: /* @__PURE__ */ jsx10(WalletIcon, {}), title }),
|
|
2049
2136
|
/* @__PURE__ */ jsx10(
|
|
2050
2137
|
ReviewDetails,
|
|
2051
2138
|
{
|
|
@@ -2214,6 +2301,7 @@ import {
|
|
|
2214
2301
|
lazy,
|
|
2215
2302
|
Suspense
|
|
2216
2303
|
} from "react";
|
|
2304
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
2217
2305
|
|
|
2218
2306
|
// src/components/steps/DepositAddressSkeleton.tsx
|
|
2219
2307
|
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
@@ -2411,7 +2499,7 @@ function DepositNotification({
|
|
|
2411
2499
|
const onCompleteRef = useLatestRef(onComplete);
|
|
2412
2500
|
const onFailedRef = useLatestRef(onFailed);
|
|
2413
2501
|
const handleComplete = useCallback(
|
|
2414
|
-
(destTxHash) => {
|
|
2502
|
+
(destTxHash, destAmount) => {
|
|
2415
2503
|
if (completedRef.current) return;
|
|
2416
2504
|
completedRef.current = true;
|
|
2417
2505
|
setDestinationTxHash(destTxHash ?? null);
|
|
@@ -2424,7 +2512,8 @@ function DepositNotification({
|
|
|
2424
2512
|
sourceToken: context.sourceToken,
|
|
2425
2513
|
sourceDecimals: context.sourceDecimals,
|
|
2426
2514
|
targetChain: context.targetChain,
|
|
2427
|
-
targetToken: context.targetToken
|
|
2515
|
+
targetToken: context.targetToken,
|
|
2516
|
+
destinationAmount: destAmount
|
|
2428
2517
|
});
|
|
2429
2518
|
},
|
|
2430
2519
|
[depositContextRef, onCompleteRef, txHash]
|
|
@@ -2453,8 +2542,11 @@ function DepositNotification({
|
|
|
2453
2542
|
const lastEvent = data.lastEvent;
|
|
2454
2543
|
const eventForTx = isEventForTx(lastEvent, txHash) ? lastEvent : void 0;
|
|
2455
2544
|
if (eventForTx?.type === "bridge-complete") {
|
|
2456
|
-
const
|
|
2457
|
-
handleComplete(
|
|
2545
|
+
const destination = eventForTx.data?.destination;
|
|
2546
|
+
handleComplete(
|
|
2547
|
+
destination?.transactionHash,
|
|
2548
|
+
typeof destination?.amount === "string" ? destination.amount : void 0
|
|
2549
|
+
);
|
|
2458
2550
|
return;
|
|
2459
2551
|
}
|
|
2460
2552
|
if (eventForTx?.type === "bridge-failed") {
|
|
@@ -2622,6 +2714,15 @@ function DepositNotification({
|
|
|
2622
2714
|
);
|
|
2623
2715
|
}
|
|
2624
2716
|
|
|
2717
|
+
// src/core/payment-uri.ts
|
|
2718
|
+
function paymentRequestUri(input) {
|
|
2719
|
+
const { to, chainId, token, amount } = input;
|
|
2720
|
+
if (token.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase() || token.toLowerCase() === "0x0") {
|
|
2721
|
+
return `ethereum:${to}@${chainId}?value=${amount}`;
|
|
2722
|
+
}
|
|
2723
|
+
return `ethereum:${token}@${chainId}/transfer?address=${to}&uint256=${amount}`;
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2625
2726
|
// src/core/deposit-source-identity.ts
|
|
2626
2727
|
var SOLANA_NATIVE_MINT = "11111111111111111111111111111111";
|
|
2627
2728
|
var EVM_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -2643,6 +2744,7 @@ function resolveSourceTokenIdentity(input) {
|
|
|
2643
2744
|
const isNative = raw.toLowerCase() === "native" || raw.toLowerCase() === EVM_ZERO_ADDRESS;
|
|
2644
2745
|
return isNative ? SOLANA_NATIVE_MINT : raw;
|
|
2645
2746
|
}
|
|
2747
|
+
if (raw.toLowerCase() === "0x0") return EVM_ZERO_ADDRESS;
|
|
2646
2748
|
return raw.toLowerCase();
|
|
2647
2749
|
}
|
|
2648
2750
|
|
|
@@ -2652,6 +2754,7 @@ var QRCode = lazy(
|
|
|
2652
2754
|
() => import("./QRCode-5RGIZZHL.mjs").then((m) => ({ default: m.QRCode }))
|
|
2653
2755
|
);
|
|
2654
2756
|
var POLL_INTERVAL_MS = 4e3;
|
|
2757
|
+
var PAYMENT_QUOTE_REFRESH_MS2 = 3e4;
|
|
2655
2758
|
function isRecord(value) {
|
|
2656
2759
|
return typeof value === "object" && value !== null;
|
|
2657
2760
|
}
|
|
@@ -2779,6 +2882,7 @@ function DepositAddressStep({
|
|
|
2779
2882
|
onDepositComplete,
|
|
2780
2883
|
onDepositFailed,
|
|
2781
2884
|
onAddressShown,
|
|
2885
|
+
payment,
|
|
2782
2886
|
onCopyAddress,
|
|
2783
2887
|
onReviewDeposit,
|
|
2784
2888
|
onError
|
|
@@ -2864,6 +2968,7 @@ function DepositAddressStep({
|
|
|
2864
2968
|
const baselineTxHashRef = useRef5(void 0);
|
|
2865
2969
|
const notificationIdRef = useRef5(0);
|
|
2866
2970
|
const displayAddress = isSolana && solanaDepositAddress ? solanaDepositAddress : smartAccount;
|
|
2971
|
+
const [paymentUnits, setPaymentUnits] = useState7("loading");
|
|
2867
2972
|
const sourceTokenIdentity = useMemo3(
|
|
2868
2973
|
() => resolveSourceTokenIdentity({
|
|
2869
2974
|
chain: sourceChainId,
|
|
@@ -2873,6 +2978,44 @@ function DepositAddressStep({
|
|
|
2873
2978
|
}),
|
|
2874
2979
|
[sourceChainId, sourceTokenSymbol, shortlist, offer.restricted, catalogFor]
|
|
2875
2980
|
);
|
|
2981
|
+
useEffect7(() => {
|
|
2982
|
+
if (!payment) return;
|
|
2983
|
+
if (typeof sourceChainId !== "number" || !sourceTokenIdentity) {
|
|
2984
|
+
setPaymentUnits("unavailable");
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
setPaymentUnits("loading");
|
|
2988
|
+
let active = true;
|
|
2989
|
+
const load = async () => {
|
|
2990
|
+
const quote = await service.getQuotePreview({
|
|
2991
|
+
account: smartAccount,
|
|
2992
|
+
sourceChainId,
|
|
2993
|
+
sourceToken: sourceTokenIdentity,
|
|
2994
|
+
direction: "exactOut",
|
|
2995
|
+
amountOut: payment.amount
|
|
2996
|
+
});
|
|
2997
|
+
if (!active) return;
|
|
2998
|
+
const answered = quote && "output" in quote ? quote.input?.amount : void 0;
|
|
2999
|
+
setPaymentUnits(answered ?? "unavailable");
|
|
3000
|
+
};
|
|
3001
|
+
void load();
|
|
3002
|
+
const timer = setInterval(load, PAYMENT_QUOTE_REFRESH_MS2);
|
|
3003
|
+
return () => {
|
|
3004
|
+
active = false;
|
|
3005
|
+
clearInterval(timer);
|
|
3006
|
+
};
|
|
3007
|
+
}, [payment, sourceChainId, sourceTokenIdentity, smartAccount, service]);
|
|
3008
|
+
const paymentDecimals = typeof sourceChainId === "number" && sourceTokenIdentity ? findTokenDecimals(sourceTokenIdentity, sourceChainId) : void 0;
|
|
3009
|
+
const paymentAmountUnits = payment && paymentUnits !== "loading" && paymentUnits !== "unavailable" ? paymentUnits : null;
|
|
3010
|
+
const paymentDisplay = paymentAmountUnits !== null && paymentDecimals !== void 0 ? formatUnits3(BigInt(paymentAmountUnits), paymentDecimals) : null;
|
|
3011
|
+
const qrValue = paymentAmountUnits !== null && typeof sourceChainId === "number" && sourceTokenIdentity ? paymentRequestUri({
|
|
3012
|
+
to: displayAddress,
|
|
3013
|
+
chainId: sourceChainId,
|
|
3014
|
+
token: sourceTokenIdentity,
|
|
3015
|
+
amount: paymentAmountUnits
|
|
3016
|
+
}) : displayAddress;
|
|
3017
|
+
const withholdPaymentQr = Boolean(payment) && paymentAmountUnits === null;
|
|
3018
|
+
const paymentUnquotable = Boolean(payment) && paymentUnits === "unavailable";
|
|
2876
3019
|
const pendingChain = pendingChainRef.current;
|
|
2877
3020
|
const sourceSelectionSettled = !catalogLoading && offer.status === "ready" && chainOptions.length > 0 && (pendingChain === void 0 || pendingChain === sourceChainId) && (chainChosenByUser.current ? chainOptions.includes(sourceChainId) : sourceChainId === preferredChainId(chainOptions));
|
|
2878
3021
|
useEffect7(() => {
|
|
@@ -3201,14 +3344,34 @@ function DepositAddressStep({
|
|
|
3201
3344
|
style: { display: "flex", flexDirection: "column", gap: 4, width: "100%" },
|
|
3202
3345
|
children: [
|
|
3203
3346
|
/* @__PURE__ */ jsxs12("div", { className: "rs-deposit-address-well", children: [
|
|
3204
|
-
/* @__PURE__ */ jsx14("div", { className: "rs-deposit-address-qr", children: /* @__PURE__ */ jsx14(
|
|
3347
|
+
/* @__PURE__ */ jsx14("div", { className: "rs-deposit-address-qr", children: withholdPaymentQr ? /* @__PURE__ */ jsx14("div", { className: "rs-skeleton rs-skeleton-qr", "aria-hidden": "true" }) : /* @__PURE__ */ jsx14(
|
|
3205
3348
|
Suspense,
|
|
3206
3349
|
{
|
|
3207
|
-
fallback: /* @__PURE__ */ jsx14(
|
|
3208
|
-
|
|
3350
|
+
fallback: /* @__PURE__ */ jsx14(
|
|
3351
|
+
"div",
|
|
3352
|
+
{
|
|
3353
|
+
className: "rs-skeleton rs-skeleton-qr",
|
|
3354
|
+
"aria-hidden": "true"
|
|
3355
|
+
}
|
|
3356
|
+
),
|
|
3357
|
+
children: /* @__PURE__ */ jsx14(QRCode, { value: qrValue, size: 190, iconSrc: qrIconSrc })
|
|
3209
3358
|
}
|
|
3210
3359
|
) }),
|
|
3211
|
-
/* @__PURE__ */
|
|
3360
|
+
payment && paymentDisplay && /* @__PURE__ */ jsxs12("div", { className: "rs-deposit-address-amount", children: [
|
|
3361
|
+
"Send exactly ",
|
|
3362
|
+
paymentDisplay,
|
|
3363
|
+
" ",
|
|
3364
|
+
sourceTokenSymbol
|
|
3365
|
+
] }),
|
|
3366
|
+
!withholdPaymentQr && /* @__PURE__ */ jsx14("div", { className: "rs-deposit-address-value", children: displayAddress })
|
|
3367
|
+
] }),
|
|
3368
|
+
paymentUnquotable && /* @__PURE__ */ jsxs12(Callout, { variant: "error", children: [
|
|
3369
|
+
"This payment can't be priced from ",
|
|
3370
|
+
sourceTokenSymbol,
|
|
3371
|
+
" on",
|
|
3372
|
+
" ",
|
|
3373
|
+
chainLabel(sourceChainId, catalogFor(sourceChainId)),
|
|
3374
|
+
" right now. Pick another chain or token."
|
|
3212
3375
|
] }),
|
|
3213
3376
|
/* @__PURE__ */ jsxs12("div", { className: "rs-deposit-address-actions", children: [
|
|
3214
3377
|
/* @__PURE__ */ jsxs12(
|
|
@@ -3217,6 +3380,7 @@ function DepositAddressStep({
|
|
|
3217
3380
|
type: "button",
|
|
3218
3381
|
className: "rs-deposit-address-copy",
|
|
3219
3382
|
onClick: handleCopy,
|
|
3383
|
+
disabled: withholdPaymentQr,
|
|
3220
3384
|
children: [
|
|
3221
3385
|
copied ? /* @__PURE__ */ jsx14(CheckIcon, {}) : /* @__PURE__ */ jsx14(CopyIcon, {}),
|
|
3222
3386
|
copied ? "Copied!" : "Copy address"
|
|
@@ -4282,7 +4446,7 @@ ExchangeSelectStep.displayName = "ExchangeSelectStep";
|
|
|
4282
4446
|
|
|
4283
4447
|
// src/components/steps/SolanaTokenSelectStep.tsx
|
|
4284
4448
|
import { useState as useState10, useEffect as useEffect10, useMemo as useMemo5 } from "react";
|
|
4285
|
-
import { formatUnits as
|
|
4449
|
+
import { formatUnits as formatUnits4 } from "viem";
|
|
4286
4450
|
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4287
4451
|
function SolanaTokenSelectStep({
|
|
4288
4452
|
solanaAddress,
|
|
@@ -4379,7 +4543,7 @@ function SolanaTokenSelectStep({
|
|
|
4379
4543
|
const selectedEntry = selectedSymbol ? rows.find((r) => r.token.symbol === selectedSymbol) : null;
|
|
4380
4544
|
const formatBalance = (entry) => {
|
|
4381
4545
|
try {
|
|
4382
|
-
const raw =
|
|
4546
|
+
const raw = formatUnits4(entry.balance, entry.token.decimals);
|
|
4383
4547
|
const numeric = Number(raw);
|
|
4384
4548
|
if (!Number.isFinite(numeric)) return raw;
|
|
4385
4549
|
return tokenFormatter.format(numeric);
|
|
@@ -4485,7 +4649,7 @@ function SolanaTokenSelectStep({
|
|
|
4485
4649
|
|
|
4486
4650
|
// src/components/steps/SolanaAmountStep.tsx
|
|
4487
4651
|
import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo6, useRef as useRef7, useState as useState11 } from "react";
|
|
4488
|
-
import { formatUnits as
|
|
4652
|
+
import { formatUnits as formatUnits5, parseUnits as parseUnits4 } from "viem";
|
|
4489
4653
|
import { Fragment as Fragment5, jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4490
4654
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
4491
4655
|
var PRESETS2 = [
|
|
@@ -4515,7 +4679,7 @@ function SolanaAmountStep({
|
|
|
4515
4679
|
const tokenPriceUsd = useMemo6(() => {
|
|
4516
4680
|
if (isSourceStablecoin) return 1;
|
|
4517
4681
|
try {
|
|
4518
|
-
const balanceUnits = Number(
|
|
4682
|
+
const balanceUnits = Number(formatUnits5(balance, token.decimals));
|
|
4519
4683
|
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0 || balanceUsd <= 0) {
|
|
4520
4684
|
return null;
|
|
4521
4685
|
}
|
|
@@ -4528,7 +4692,7 @@ function SolanaAmountStep({
|
|
|
4528
4692
|
const hasPricing = tokenPriceUsd !== null;
|
|
4529
4693
|
const formattedBalance = useMemo6(() => {
|
|
4530
4694
|
try {
|
|
4531
|
-
const raw =
|
|
4695
|
+
const raw = formatUnits5(balance, token.decimals);
|
|
4532
4696
|
const numeric = Number(raw);
|
|
4533
4697
|
if (!Number.isFinite(numeric)) return raw;
|
|
4534
4698
|
return tokenFormatter.format(numeric);
|
|
@@ -4538,7 +4702,7 @@ function SolanaAmountStep({
|
|
|
4538
4702
|
}, [balance, token.decimals]);
|
|
4539
4703
|
const computedBalanceUsd = useMemo6(() => {
|
|
4540
4704
|
try {
|
|
4541
|
-
const balanceUnits = Number(
|
|
4705
|
+
const balanceUnits = Number(formatUnits5(balance, token.decimals));
|
|
4542
4706
|
if (!Number.isFinite(balanceUnits) || balanceUnits < 0) return null;
|
|
4543
4707
|
if (tokenPriceUsd !== null) return balanceUnits * tokenPriceUsd;
|
|
4544
4708
|
if (Number.isFinite(balanceUsd) && balanceUsd > 0) return balanceUsd;
|
|
@@ -4553,7 +4717,7 @@ function SolanaAmountStep({
|
|
|
4553
4717
|
}, [balance, token]);
|
|
4554
4718
|
const spendableBalanceUsd = useMemo6(() => {
|
|
4555
4719
|
try {
|
|
4556
|
-
const spendableUnits = Number(
|
|
4720
|
+
const spendableUnits = Number(formatUnits5(spendableBalance, token.decimals));
|
|
4557
4721
|
if (!Number.isFinite(spendableUnits) || spendableUnits < 0) return null;
|
|
4558
4722
|
if (tokenPriceUsd !== null) return spendableUnits * tokenPriceUsd;
|
|
4559
4723
|
return null;
|
|
@@ -4565,7 +4729,7 @@ function SolanaAmountStep({
|
|
|
4565
4729
|
(percentage) => {
|
|
4566
4730
|
try {
|
|
4567
4731
|
const spendableUnits = Number(
|
|
4568
|
-
|
|
4732
|
+
formatUnits5(spendableBalance, token.decimals)
|
|
4569
4733
|
);
|
|
4570
4734
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return "";
|
|
4571
4735
|
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (spendableBalanceUsd ?? 0) * percentage / 100;
|
|
@@ -5530,7 +5694,7 @@ function withdrawableUsd(position) {
|
|
|
5530
5694
|
}
|
|
5531
5695
|
|
|
5532
5696
|
// src/core/dapp-imports/polymarket/index.ts
|
|
5533
|
-
import { formatUnits as
|
|
5697
|
+
import { formatUnits as formatUnits6 } from "viem";
|
|
5534
5698
|
|
|
5535
5699
|
// src/core/dapp-imports/polymarket/deposit-wallet.ts
|
|
5536
5700
|
import {
|
|
@@ -5789,7 +5953,7 @@ function buildAsset2(params) {
|
|
|
5789
5953
|
const isPusd = tokenKind === "pusd";
|
|
5790
5954
|
const tokenAddress = isPusd ? POLYMARKET_PUSD_ADDRESS : POLYMARKET_USDCE_ADDRESS;
|
|
5791
5955
|
const symbol = isPusd ? "pUSD" : "USDC.e";
|
|
5792
|
-
const balanceUsd = Number(
|
|
5956
|
+
const balanceUsd = Number(formatUnits6(balance, 6));
|
|
5793
5957
|
const metadata = { proxyWallet, tokenKind, walletKind };
|
|
5794
5958
|
return {
|
|
5795
5959
|
id: `polymarket:${tokenKind}`,
|
|
@@ -7496,6 +7660,7 @@ function DepositFlow({
|
|
|
7496
7660
|
sourceToken: defaultSourceToken,
|
|
7497
7661
|
amount: defaultAmount,
|
|
7498
7662
|
recipient,
|
|
7663
|
+
payment,
|
|
7499
7664
|
appBalanceUsd,
|
|
7500
7665
|
outputTokenRules,
|
|
7501
7666
|
rejectUnmapped,
|
|
@@ -8648,7 +8813,8 @@ function DepositFlow({
|
|
|
8648
8813
|
recipient,
|
|
8649
8814
|
outputTokenRules,
|
|
8650
8815
|
rejectUnmapped,
|
|
8651
|
-
forceRegister
|
|
8816
|
+
forceRegister,
|
|
8817
|
+
...payment ? { salt: payment.salt } : {}
|
|
8652
8818
|
}),
|
|
8653
8819
|
[
|
|
8654
8820
|
targetChain,
|
|
@@ -8656,7 +8822,8 @@ function DepositFlow({
|
|
|
8656
8822
|
recipient,
|
|
8657
8823
|
outputTokenRules,
|
|
8658
8824
|
rejectUnmapped,
|
|
8659
|
-
forceRegister
|
|
8825
|
+
forceRegister,
|
|
8826
|
+
payment
|
|
8660
8827
|
]
|
|
8661
8828
|
);
|
|
8662
8829
|
const desiredSetupRequestKey = computeRequestKey(setupInput);
|
|
@@ -9137,6 +9304,7 @@ function DepositFlow({
|
|
|
9137
9304
|
return /* @__PURE__ */ jsx28("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx28(
|
|
9138
9305
|
ConnectStep,
|
|
9139
9306
|
{
|
|
9307
|
+
title: payment ? "Pay" : void 0,
|
|
9140
9308
|
walletRows,
|
|
9141
9309
|
defaultMethodTab: flowSlice.methodTab,
|
|
9142
9310
|
onMethodTabChange: (tab) => storeApi.dispatch({ type: "connect/method-tab-changed", tab }),
|
|
@@ -9206,6 +9374,7 @@ function DepositFlow({
|
|
|
9206
9374
|
effectiveStep.type === "deposit-address" && /* @__PURE__ */ jsx28(
|
|
9207
9375
|
DepositAddressStep,
|
|
9208
9376
|
{
|
|
9377
|
+
payment,
|
|
9209
9378
|
smartAccount: effectiveStep.smartAccount,
|
|
9210
9379
|
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
9211
9380
|
service,
|
|
@@ -9320,6 +9489,7 @@ function DepositFlow({
|
|
|
9320
9489
|
step.type === "processing" && /* @__PURE__ */ jsx28(
|
|
9321
9490
|
ProcessingStep,
|
|
9322
9491
|
{
|
|
9492
|
+
flowLabel: payment ? "payment" : void 0,
|
|
9323
9493
|
smartAccount: step.smartAccount,
|
|
9324
9494
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
9325
9495
|
txHash: step.txHash,
|
|
@@ -9400,6 +9570,7 @@ function DepositFlow({
|
|
|
9400
9570
|
step.type === "processing" && /* @__PURE__ */ jsx28(
|
|
9401
9571
|
ProcessingStep,
|
|
9402
9572
|
{
|
|
9573
|
+
flowLabel: payment ? "payment" : void 0,
|
|
9403
9574
|
smartAccount: step.smartAccount,
|
|
9404
9575
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
9405
9576
|
txHash: step.txHash,
|
|
@@ -9529,6 +9700,7 @@ function DepositFlow({
|
|
|
9529
9700
|
effectiveStep.type === "processing" && /* @__PURE__ */ jsx28(
|
|
9530
9701
|
ProcessingStep,
|
|
9531
9702
|
{
|
|
9703
|
+
flowLabel: payment ? "payment" : void 0,
|
|
9532
9704
|
smartAccount: effectiveStep.smartAccount,
|
|
9533
9705
|
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
9534
9706
|
txHash: effectiveStep.txHash,
|
|
@@ -9663,6 +9835,9 @@ function DepositFlow({
|
|
|
9663
9835
|
uiConfig,
|
|
9664
9836
|
appBalanceUsd,
|
|
9665
9837
|
service,
|
|
9838
|
+
payment,
|
|
9839
|
+
account: effectiveStep.smartAccount,
|
|
9840
|
+
title: payment ? "Amount to pay" : void 0,
|
|
9666
9841
|
onContinue: handleAmountContinue,
|
|
9667
9842
|
onCtaClick: (ctaName) => {
|
|
9668
9843
|
if (ctaName === "continue") analytics.completeStep();
|
|
@@ -9678,6 +9853,8 @@ function DepositFlow({
|
|
|
9678
9853
|
recipient,
|
|
9679
9854
|
asset: effectiveStep.asset,
|
|
9680
9855
|
amount: effectiveStep.amount,
|
|
9856
|
+
title: payment ? "Review payment" : void 0,
|
|
9857
|
+
routeThroughAccount: Boolean(payment),
|
|
9681
9858
|
targetAmount: effectiveStep.targetAmount,
|
|
9682
9859
|
targetTokenPriceUsd: effectiveStep.targetTokenPriceUsd,
|
|
9683
9860
|
balance: effectiveStep.balance,
|
|
@@ -9721,6 +9898,7 @@ function DepositFlow({
|
|
|
9721
9898
|
effectiveStep.type === "processing" && /* @__PURE__ */ jsx28(
|
|
9722
9899
|
ProcessingStep,
|
|
9723
9900
|
{
|
|
9901
|
+
flowLabel: payment ? "payment" : void 0,
|
|
9724
9902
|
smartAccount: effectiveStep.smartAccount,
|
|
9725
9903
|
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
9726
9904
|
txHash: effectiveStep.txHash,
|
|
@@ -9759,7 +9937,7 @@ function DepositFlow({
|
|
|
9759
9937
|
import { jsx as jsx29, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
9760
9938
|
var ReownDepositInner = lazy2(async () => {
|
|
9761
9939
|
await loadReownDependencies();
|
|
9762
|
-
const module = await import("./DepositModalReown-
|
|
9940
|
+
const module = await import("./DepositModalReown-XBNY6QCI.mjs");
|
|
9763
9941
|
return { default: module.DepositModalReown };
|
|
9764
9942
|
});
|
|
9765
9943
|
function buildDepositAnalyticsSessionProperties({
|
|
@@ -9852,6 +10030,7 @@ function DepositModalInner({
|
|
|
9852
10030
|
sourceToken,
|
|
9853
10031
|
defaultAmount,
|
|
9854
10032
|
recipient,
|
|
10033
|
+
payment,
|
|
9855
10034
|
appBalanceUsd,
|
|
9856
10035
|
backendUrl,
|
|
9857
10036
|
rpcUrls: rpcUrlsProp,
|
|
@@ -9898,7 +10077,7 @@ function DepositModalInner({
|
|
|
9898
10077
|
void 0
|
|
9899
10078
|
);
|
|
9900
10079
|
const [processingSettled, setProcessingSettled] = useState14(false);
|
|
9901
|
-
const historyButtonVisible = isHistoryEntryVisible({
|
|
10080
|
+
const historyButtonVisible = !payment && isHistoryEntryVisible({
|
|
9902
10081
|
screen: currentScreen,
|
|
9903
10082
|
submitting,
|
|
9904
10083
|
settled: processingSettled
|
|
@@ -9922,7 +10101,7 @@ function DepositModalInner({
|
|
|
9922
10101
|
[]
|
|
9923
10102
|
);
|
|
9924
10103
|
const history = useHistoryPanel({
|
|
9925
|
-
isOpen,
|
|
10104
|
+
isOpen: isOpen && !payment,
|
|
9926
10105
|
recipient,
|
|
9927
10106
|
service,
|
|
9928
10107
|
canRecover: Boolean(signRecovery),
|
|
@@ -10135,6 +10314,7 @@ function DepositModalInner({
|
|
|
10135
10314
|
sourceToken,
|
|
10136
10315
|
amount: defaultAmount,
|
|
10137
10316
|
recipient,
|
|
10317
|
+
payment,
|
|
10138
10318
|
appBalanceUsd,
|
|
10139
10319
|
outputTokenRules,
|
|
10140
10320
|
rejectUnmapped,
|