@unifold/ui-web 0.1.42 → 0.1.43
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.js +1514 -290
- package/dist/index.mjs +1514 -290
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -34394,7 +34394,7 @@ var require_jsx_runtime = __commonJS({
|
|
|
34394
34394
|
});
|
|
34395
34395
|
|
|
34396
34396
|
// src/unifold.tsx
|
|
34397
|
-
var
|
|
34397
|
+
var import_react33 = __toESM(require_react());
|
|
34398
34398
|
var import_client = __toESM(require_client());
|
|
34399
34399
|
|
|
34400
34400
|
// ../connect-react/dist/index.mjs
|
|
@@ -37214,17 +37214,19 @@ var React272 = __toESM(require_react(), 1);
|
|
|
37214
37214
|
var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
|
|
37215
37215
|
var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
|
|
37216
37216
|
var import_react27 = __toESM(require_react(), 1);
|
|
37217
|
-
var import_react28 = __toESM(require_react(), 1);
|
|
37218
37217
|
var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
|
|
37218
|
+
var import_react28 = __toESM(require_react(), 1);
|
|
37219
37219
|
var import_react29 = __toESM(require_react(), 1);
|
|
37220
37220
|
var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
|
|
37221
|
-
var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
|
|
37222
37221
|
var import_react30 = __toESM(require_react(), 1);
|
|
37222
|
+
var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
|
|
37223
37223
|
var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
|
|
37224
|
-
var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
|
|
37225
37224
|
var import_react31 = __toESM(require_react(), 1);
|
|
37225
|
+
var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
|
|
37226
37226
|
var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
|
|
37227
|
+
var import_react32 = __toESM(require_react(), 1);
|
|
37227
37228
|
var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
|
|
37229
|
+
var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
|
|
37228
37230
|
var __create2 = Object.create;
|
|
37229
37231
|
var __defProp2 = Object.defineProperty;
|
|
37230
37232
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -38488,6 +38490,10 @@ var ArrowLeft = createLucideIcon("ArrowLeft", [
|
|
|
38488
38490
|
["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
|
|
38489
38491
|
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
38490
38492
|
]);
|
|
38493
|
+
var ArrowRight = createLucideIcon("ArrowRight", [
|
|
38494
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
38495
|
+
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
38496
|
+
]);
|
|
38491
38497
|
var ArrowUpDown = createLucideIcon("ArrowUpDown", [
|
|
38492
38498
|
["path", { d: "m21 16-4 4-4-4", key: "f6ql7i" }],
|
|
38493
38499
|
["path", { d: "M17 20V4", key: "1ejh1v" }],
|
|
@@ -43566,6 +43572,119 @@ async function sendSolanaTransaction(request, publishableKey) {
|
|
|
43566
43572
|
}
|
|
43567
43573
|
return response.json();
|
|
43568
43574
|
}
|
|
43575
|
+
async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
43576
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43577
|
+
validatePublishableKey(pk);
|
|
43578
|
+
const response = await fetch(
|
|
43579
|
+
`${API_BASE_URL}/v1/public/payment_intents/retrieve`,
|
|
43580
|
+
{
|
|
43581
|
+
method: "POST",
|
|
43582
|
+
headers: {
|
|
43583
|
+
accept: "application/json",
|
|
43584
|
+
"x-publishable-key": pk,
|
|
43585
|
+
"Content-Type": "application/json"
|
|
43586
|
+
},
|
|
43587
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
43588
|
+
}
|
|
43589
|
+
);
|
|
43590
|
+
if (!response.ok) {
|
|
43591
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
43592
|
+
throw new Error(
|
|
43593
|
+
`Failed to retrieve payment intent: ${error.message || response.statusText}`
|
|
43594
|
+
);
|
|
43595
|
+
}
|
|
43596
|
+
return response.json();
|
|
43597
|
+
}
|
|
43598
|
+
async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
43599
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43600
|
+
validatePublishableKey(pk);
|
|
43601
|
+
const response = await fetch(
|
|
43602
|
+
`${API_BASE_URL}/v1/public/payment_intents/executions`,
|
|
43603
|
+
{
|
|
43604
|
+
method: "POST",
|
|
43605
|
+
headers: {
|
|
43606
|
+
accept: "application/json",
|
|
43607
|
+
"x-publishable-key": pk,
|
|
43608
|
+
"Content-Type": "application/json"
|
|
43609
|
+
},
|
|
43610
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
43611
|
+
}
|
|
43612
|
+
);
|
|
43613
|
+
if (!response.ok) {
|
|
43614
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
43615
|
+
throw new Error(
|
|
43616
|
+
`Failed to list payment intent executions: ${error.message || response.statusText}`
|
|
43617
|
+
);
|
|
43618
|
+
}
|
|
43619
|
+
return response.json();
|
|
43620
|
+
}
|
|
43621
|
+
async function getDepositQuote(request, publishableKey) {
|
|
43622
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43623
|
+
validatePublishableKey(pk);
|
|
43624
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/quotes`, {
|
|
43625
|
+
method: "POST",
|
|
43626
|
+
headers: {
|
|
43627
|
+
accept: "application/json",
|
|
43628
|
+
"x-publishable-key": pk,
|
|
43629
|
+
"Content-Type": "application/json"
|
|
43630
|
+
},
|
|
43631
|
+
body: JSON.stringify(request)
|
|
43632
|
+
});
|
|
43633
|
+
if (!response.ok) {
|
|
43634
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
43635
|
+
throw new Error(
|
|
43636
|
+
`Failed to get deposit quote: ${error.message || response.statusText}`
|
|
43637
|
+
);
|
|
43638
|
+
}
|
|
43639
|
+
const json = await response.json();
|
|
43640
|
+
return json.data;
|
|
43641
|
+
}
|
|
43642
|
+
async function buildHypercoreTransaction(request, publishableKey) {
|
|
43643
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43644
|
+
validatePublishableKey(pk);
|
|
43645
|
+
const response = await fetch(
|
|
43646
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/build`,
|
|
43647
|
+
{
|
|
43648
|
+
method: "POST",
|
|
43649
|
+
headers: {
|
|
43650
|
+
accept: "application/json",
|
|
43651
|
+
"x-publishable-key": pk,
|
|
43652
|
+
"Content-Type": "application/json"
|
|
43653
|
+
},
|
|
43654
|
+
body: JSON.stringify(request)
|
|
43655
|
+
}
|
|
43656
|
+
);
|
|
43657
|
+
if (!response.ok) {
|
|
43658
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
43659
|
+
throw new Error(
|
|
43660
|
+
`Failed to build HyperCore transaction: ${error.message || response.statusText}`
|
|
43661
|
+
);
|
|
43662
|
+
}
|
|
43663
|
+
return response.json();
|
|
43664
|
+
}
|
|
43665
|
+
async function sendHypercoreTransaction(request, publishableKey) {
|
|
43666
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
43667
|
+
validatePublishableKey(pk);
|
|
43668
|
+
const response = await fetch(
|
|
43669
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/send`,
|
|
43670
|
+
{
|
|
43671
|
+
method: "POST",
|
|
43672
|
+
headers: {
|
|
43673
|
+
accept: "application/json",
|
|
43674
|
+
"x-publishable-key": pk,
|
|
43675
|
+
"Content-Type": "application/json"
|
|
43676
|
+
},
|
|
43677
|
+
body: JSON.stringify(request)
|
|
43678
|
+
}
|
|
43679
|
+
);
|
|
43680
|
+
if (!response.ok) {
|
|
43681
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
43682
|
+
throw new Error(
|
|
43683
|
+
`Failed to send HyperCore transaction: ${error.message || response.statusText}`
|
|
43684
|
+
);
|
|
43685
|
+
}
|
|
43686
|
+
return response.json();
|
|
43687
|
+
}
|
|
43569
43688
|
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
43570
43689
|
var use = React25[" use ".trim().toString()];
|
|
43571
43690
|
function isPromiseLike(value) {
|
|
@@ -48922,6 +49041,7 @@ var CUTOFF_BUFFER_MS = 6e4;
|
|
|
48922
49041
|
function useDepositPolling({
|
|
48923
49042
|
userId,
|
|
48924
49043
|
publishableKey,
|
|
49044
|
+
clientSecret,
|
|
48925
49045
|
depositConfirmationMode = "auto_ui",
|
|
48926
49046
|
depositWalletId,
|
|
48927
49047
|
enabled = true,
|
|
@@ -48979,11 +49099,12 @@ function useDepositPolling({
|
|
|
48979
49099
|
depositWalletId
|
|
48980
49100
|
]);
|
|
48981
49101
|
(0, import_react10.useEffect)(() => {
|
|
48982
|
-
if (!
|
|
49102
|
+
if (!enabled) return;
|
|
49103
|
+
if (!clientSecret && !userId) return;
|
|
48983
49104
|
const modalOpenedAt = modalOpenedAtRef.current;
|
|
48984
49105
|
const poll = async () => {
|
|
48985
49106
|
try {
|
|
48986
|
-
const response = await queryExecutions(userId, publishableKey, ActionType.Deposit);
|
|
49107
|
+
const response = clientSecret ? await listPaymentIntentExecutions(clientSecret, publishableKey) : await queryExecutions(userId, publishableKey, ActionType.Deposit);
|
|
48987
49108
|
const cutoff = new Date(modalOpenedAt.getTime() - CUTOFF_BUFFER_MS);
|
|
48988
49109
|
const sortedExecutions = [...response.data].sort((a, b) => {
|
|
48989
49110
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
@@ -49067,7 +49188,7 @@ function useDepositPolling({
|
|
|
49067
49188
|
clearInterval(pollInterval);
|
|
49068
49189
|
setIsPolling(false);
|
|
49069
49190
|
};
|
|
49070
|
-
}, [userId, publishableKey, enabled]);
|
|
49191
|
+
}, [userId, publishableKey, clientSecret, enabled]);
|
|
49071
49192
|
(0, import_react10.useEffect)(() => {
|
|
49072
49193
|
if (!pollingEnabled || !depositWalletId) return;
|
|
49073
49194
|
const triggerPoll = async () => {
|
|
@@ -55576,6 +55697,7 @@ var parseChainKey = (chainKey) => {
|
|
|
55576
55697
|
function TransferCryptoSingleInput({
|
|
55577
55698
|
userId,
|
|
55578
55699
|
publishableKey,
|
|
55700
|
+
clientSecret,
|
|
55579
55701
|
recipientAddress,
|
|
55580
55702
|
destinationChainType,
|
|
55581
55703
|
destinationChainId,
|
|
@@ -55588,7 +55710,9 @@ function TransferCryptoSingleInput({
|
|
|
55588
55710
|
onExecutionsChange,
|
|
55589
55711
|
onDepositSuccess,
|
|
55590
55712
|
onDepositError,
|
|
55591
|
-
wallets: externalWallets
|
|
55713
|
+
wallets: externalWallets,
|
|
55714
|
+
onSourceTokenChange,
|
|
55715
|
+
checkoutQuote
|
|
55592
55716
|
}) {
|
|
55593
55717
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
55594
55718
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
@@ -55655,12 +55779,28 @@ function TransferCryptoSingleInput({
|
|
|
55655
55779
|
} = useDepositPolling({
|
|
55656
55780
|
userId,
|
|
55657
55781
|
publishableKey,
|
|
55782
|
+
clientSecret,
|
|
55658
55783
|
depositConfirmationMode,
|
|
55659
55784
|
depositWalletId: currentWallet?.id,
|
|
55660
55785
|
enabled: true,
|
|
55661
55786
|
onDepositSuccess,
|
|
55662
55787
|
onDepositError
|
|
55663
55788
|
});
|
|
55789
|
+
(0, import_react16.useEffect)(() => {
|
|
55790
|
+
if (!onSourceTokenChange || !token || !chain || !initialSelectionDone) return;
|
|
55791
|
+
const { chainType, chainId } = parseChainKey(chain);
|
|
55792
|
+
const matchedToken = supportedTokens.find((t11) => t11.symbol === token);
|
|
55793
|
+
const matchedChain = matchedToken?.chains.find(
|
|
55794
|
+
(c) => c.chain_type === chainType && c.chain_id === chainId
|
|
55795
|
+
);
|
|
55796
|
+
onSourceTokenChange({
|
|
55797
|
+
symbol: token,
|
|
55798
|
+
chainType,
|
|
55799
|
+
chainId,
|
|
55800
|
+
tokenAddress: matchedChain?.token_address ?? "",
|
|
55801
|
+
minimumDepositAmountUsd: matchedChain?.minimum_deposit_amount_usd ?? 0
|
|
55802
|
+
});
|
|
55803
|
+
}, [token, chain, initialSelectionDone, onSourceTokenChange, supportedTokens]);
|
|
55664
55804
|
(0, import_react16.useEffect)(() => {
|
|
55665
55805
|
if (onExecutionsChange) {
|
|
55666
55806
|
onExecutionsChange(depositExecutions);
|
|
@@ -55807,6 +55947,53 @@ function TransferCryptoSingleInput({
|
|
|
55807
55947
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
|
|
55808
55948
|
] })
|
|
55809
55949
|
] }),
|
|
55950
|
+
checkoutQuote && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
55951
|
+
"div",
|
|
55952
|
+
{
|
|
55953
|
+
className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
|
|
55954
|
+
style: {
|
|
55955
|
+
backgroundColor: components.card.backgroundColor,
|
|
55956
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
|
|
55957
|
+
borderRadius: components.card.borderRadius
|
|
55958
|
+
},
|
|
55959
|
+
children: [
|
|
55960
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
55961
|
+
"span",
|
|
55962
|
+
{
|
|
55963
|
+
className: "uf-text-xs",
|
|
55964
|
+
style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
|
|
55965
|
+
children: "You send"
|
|
55966
|
+
}
|
|
55967
|
+
),
|
|
55968
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
55969
|
+
"span",
|
|
55970
|
+
{
|
|
55971
|
+
className: "uf-text-sm uf-font-semibold",
|
|
55972
|
+
style: { color: components.card.titleColor, fontFamily: fonts.semibold },
|
|
55973
|
+
children: [
|
|
55974
|
+
(Number(checkoutQuote.sourceAmount) / 10 ** checkoutQuote.sourceTokenDecimals).toFixed(
|
|
55975
|
+
Math.min(checkoutQuote.sourceTokenDecimals, 6)
|
|
55976
|
+
),
|
|
55977
|
+
" ",
|
|
55978
|
+
checkoutQuote.sourceTokenSymbol,
|
|
55979
|
+
checkoutQuote.sourceAmountUsd && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
55980
|
+
"span",
|
|
55981
|
+
{
|
|
55982
|
+
className: "uf-text-xs uf-font-normal uf-ml-1.5",
|
|
55983
|
+
style: { color: components.card.subtitleColor },
|
|
55984
|
+
children: [
|
|
55985
|
+
"($",
|
|
55986
|
+
checkoutQuote.sourceAmountUsd,
|
|
55987
|
+
")"
|
|
55988
|
+
]
|
|
55989
|
+
}
|
|
55990
|
+
)
|
|
55991
|
+
]
|
|
55992
|
+
}
|
|
55993
|
+
)
|
|
55994
|
+
]
|
|
55995
|
+
}
|
|
55996
|
+
),
|
|
55810
55997
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pt-2", children: [
|
|
55811
55998
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-text-xs uf-mb-2 uf-flex uf-items-center uf-gap-1", style: { color: components.card.labelColor }, children: "Intent address" }),
|
|
55812
55999
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "uf-shadow-lg", style: { borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: loading || tokensLoading || !initialSelectionDone ? (
|
|
@@ -56628,9 +56815,16 @@ function SelectTokenView({
|
|
|
56628
56815
|
onBack,
|
|
56629
56816
|
onClose,
|
|
56630
56817
|
onDisconnectWallet,
|
|
56631
|
-
isDisconnectingWallet = false
|
|
56818
|
+
isDisconnectingWallet = false,
|
|
56819
|
+
checkoutAmountUsd,
|
|
56820
|
+
checkoutReceivedUsd
|
|
56632
56821
|
}) {
|
|
56633
56822
|
const { colors: colors2, fonts, components } = useTheme();
|
|
56823
|
+
const isCheckout = !!checkoutAmountUsd;
|
|
56824
|
+
const headerSubtitle = isCheckout ? parseFloat(checkoutReceivedUsd || "0") > 0 ? `$${checkoutReceivedUsd} / $${checkoutAmountUsd} received` : `Amount due: $${checkoutAmountUsd}` : formatBalanceDisplay(
|
|
56825
|
+
`$${totalBalanceUsd || "0.00"}`,
|
|
56826
|
+
projectName
|
|
56827
|
+
);
|
|
56634
56828
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
56635
56829
|
"div",
|
|
56636
56830
|
{
|
|
@@ -56639,11 +56833,8 @@ function SelectTokenView({
|
|
|
56639
56833
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
56640
56834
|
DepositHeader,
|
|
56641
56835
|
{
|
|
56642
|
-
title: "Select Token",
|
|
56643
|
-
subtitle:
|
|
56644
|
-
`$${totalBalanceUsd || "0.00"}`,
|
|
56645
|
-
projectName
|
|
56646
|
-
),
|
|
56836
|
+
title: isCheckout ? "Select Token" : "Select Token",
|
|
56837
|
+
subtitle: headerSubtitle,
|
|
56647
56838
|
showBack: true,
|
|
56648
56839
|
onBack,
|
|
56649
56840
|
onClose
|
|
@@ -56871,10 +57062,19 @@ function EnterAmountView({
|
|
|
56871
57062
|
onReview,
|
|
56872
57063
|
onBack,
|
|
56873
57064
|
onClose,
|
|
56874
|
-
quickSelectMode
|
|
57065
|
+
quickSelectMode,
|
|
57066
|
+
checkoutAmountUsd,
|
|
57067
|
+
checkoutReceivedUsd
|
|
56875
57068
|
}) {
|
|
56876
57069
|
const { colors: colors2, fonts, components } = useTheme();
|
|
57070
|
+
const isCheckout = !!checkoutAmountUsd;
|
|
56877
57071
|
const balanceSubtitle = selectedBalance?.amount_usd ? `Balance: $${parseFloat(selectedBalance.amount_usd).toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} (${formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol)} ${selectedToken.symbol})` : `Balance: ${formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol)} ${selectedToken.symbol}`;
|
|
57072
|
+
const checkoutRemainingUsd = isCheckout ? Math.max(
|
|
57073
|
+
parseFloat(checkoutAmountUsd) - parseFloat(checkoutReceivedUsd || "0"),
|
|
57074
|
+
0
|
|
57075
|
+
).toFixed(2) : null;
|
|
57076
|
+
const headerTitle = isCheckout ? `Pay $${checkoutRemainingUsd}` : "Enter Amount";
|
|
57077
|
+
const headerSubtitle = isCheckout ? parseFloat(checkoutReceivedUsd || "0") > 0 ? `$${checkoutReceivedUsd} / $${checkoutAmountUsd} received` : null : balanceSubtitle;
|
|
56878
57078
|
const usePercentageChips = quickSelectMode === "percentage" && maxUsdAmount > 0;
|
|
56879
57079
|
const chipButtonClass = "uf-flex-1 uf-min-w-0 uf-basis-0 uf-py-2 uf-px-1 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-colors hover:uf-opacity-80 uf-whitespace-nowrap";
|
|
56880
57080
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
@@ -56888,14 +57088,27 @@ function EnterAmountView({
|
|
|
56888
57088
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
56889
57089
|
DepositHeader,
|
|
56890
57090
|
{
|
|
56891
|
-
title:
|
|
56892
|
-
subtitle:
|
|
57091
|
+
title: headerTitle,
|
|
57092
|
+
subtitle: headerSubtitle ?? void 0,
|
|
56893
57093
|
showBack: true,
|
|
56894
57094
|
onBack,
|
|
56895
57095
|
onClose
|
|
56896
57096
|
}
|
|
56897
57097
|
),
|
|
56898
|
-
walletInfoProp ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "uf-flex uf-w-full uf-justify-center uf-mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime65.
|
|
57098
|
+
walletInfoProp ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "uf-flex uf-w-full uf-justify-center uf-mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-gap-1", children: [
|
|
57099
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(WalletWithNetworkBadge, { walletInfo: walletInfoProp }),
|
|
57100
|
+
isCheckout && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
57101
|
+
"span",
|
|
57102
|
+
{
|
|
57103
|
+
className: "uf-text-xs",
|
|
57104
|
+
style: {
|
|
57105
|
+
color: colors2.foregroundMuted,
|
|
57106
|
+
fontFamily: fonts.regular
|
|
57107
|
+
},
|
|
57108
|
+
children: balanceSubtitle
|
|
57109
|
+
}
|
|
57110
|
+
)
|
|
57111
|
+
] }) }) : null,
|
|
56899
57112
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-flex uf-min-h-0 uf-flex-1 uf-flex-col", children: [
|
|
56900
57113
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-min-h-0 uf-flex-1", children: [
|
|
56901
57114
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-text-center uf-py-8", children: [
|
|
@@ -56918,7 +57131,9 @@ function EnterAmountView({
|
|
|
56918
57131
|
inputMode: "decimal",
|
|
56919
57132
|
placeholder: "0",
|
|
56920
57133
|
value: amountUsd,
|
|
57134
|
+
readOnly: isCheckout,
|
|
56921
57135
|
onChange: (e) => {
|
|
57136
|
+
if (isCheckout) return;
|
|
56922
57137
|
const value = e.target.value;
|
|
56923
57138
|
if (value === "" || /^\d*\.?\d*$/.test(value)) {
|
|
56924
57139
|
const decimalIndex = value.indexOf(".");
|
|
@@ -56929,7 +57144,7 @@ function EnterAmountView({
|
|
|
56929
57144
|
onAmountChange(value);
|
|
56930
57145
|
}
|
|
56931
57146
|
},
|
|
56932
|
-
className:
|
|
57147
|
+
className: `uf-bg-transparent uf-outline-none uf-text-center uf-font-normal uf-w-auto uf-min-w-[60px] ${isCheckout ? "uf-cursor-default" : ""}`,
|
|
56933
57148
|
style: {
|
|
56934
57149
|
fontSize: `${Math.max(3.75 - (amountUsd || "0").length * 0.15, 2)}rem`,
|
|
56935
57150
|
color: components.input.textColor,
|
|
@@ -56951,7 +57166,7 @@ function EnterAmountView({
|
|
|
56951
57166
|
}
|
|
56952
57167
|
)
|
|
56953
57168
|
] }),
|
|
56954
|
-
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "uf-mb-4 uf-flex uf-w-full uf-min-w-0 uf-flex-nowrap uf-gap-1.5 uf-overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: usePercentageChips ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
57169
|
+
!isCheckout && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "uf-mb-4 uf-flex uf-w-full uf-min-w-0 uf-flex-nowrap uf-gap-1.5 uf-overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: usePercentageChips ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
56955
57170
|
PERCENT_QUICK_AMOUNTS.map((pct) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
56956
57171
|
"button",
|
|
56957
57172
|
{
|
|
@@ -57020,7 +57235,46 @@ function EnterAmountView({
|
|
|
57020
57235
|
}
|
|
57021
57236
|
)
|
|
57022
57237
|
] }) }),
|
|
57023
|
-
tokenChainDetails && tokenChainDetails.minimum_deposit_amount_usd > 0 && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57238
|
+
tokenChainDetails && tokenChainDetails.minimum_deposit_amount_usd > 0 && (isCheckout && checkoutAmountUsd && inputUsdNum > parseFloat(checkoutAmountUsd) - parseFloat(checkoutReceivedUsd || "0") + 5e-3 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57239
|
+
"div",
|
|
57240
|
+
{
|
|
57241
|
+
className: "uf-rounded-lg uf-px-3 uf-py-2 uf-mb-3 uf-text-center",
|
|
57242
|
+
style: {
|
|
57243
|
+
backgroundColor: colors2.warning + "15",
|
|
57244
|
+
border: `1px solid ${colors2.warning}30`,
|
|
57245
|
+
borderRadius: components.card.borderRadius,
|
|
57246
|
+
animation: "uf-fadeSlideIn 0.4s ease-out"
|
|
57247
|
+
},
|
|
57248
|
+
children: [
|
|
57249
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57250
|
+
"div",
|
|
57251
|
+
{
|
|
57252
|
+
className: "uf-text-xs uf-font-medium",
|
|
57253
|
+
style: { color: colors2.warning, fontFamily: fonts.medium },
|
|
57254
|
+
children: [
|
|
57255
|
+
"Minimum for ",
|
|
57256
|
+
selectedToken.symbol,
|
|
57257
|
+
" on ",
|
|
57258
|
+
selectedToken.chain_name,
|
|
57259
|
+
" is $",
|
|
57260
|
+
tokenChainDetails.minimum_deposit_amount_usd.toFixed(2)
|
|
57261
|
+
]
|
|
57262
|
+
}
|
|
57263
|
+
),
|
|
57264
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57265
|
+
"div",
|
|
57266
|
+
{
|
|
57267
|
+
className: "uf-text-xs uf-mt-0.5",
|
|
57268
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
57269
|
+
children: [
|
|
57270
|
+
"Amount adjusted from remaining $",
|
|
57271
|
+
(parseFloat(checkoutAmountUsd) - parseFloat(checkoutReceivedUsd || "0")).toFixed(2)
|
|
57272
|
+
]
|
|
57273
|
+
}
|
|
57274
|
+
)
|
|
57275
|
+
]
|
|
57276
|
+
}
|
|
57277
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57024
57278
|
"div",
|
|
57025
57279
|
{
|
|
57026
57280
|
className: "uf-text-center uf-text-xs uf-mb-3",
|
|
@@ -57030,7 +57284,7 @@ function EnterAmountView({
|
|
|
57030
57284
|
tokenChainDetails.minimum_deposit_amount_usd.toFixed(2)
|
|
57031
57285
|
]
|
|
57032
57286
|
}
|
|
57033
|
-
),
|
|
57287
|
+
)),
|
|
57034
57288
|
inputUsdNum > 0 && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_jsx_runtime65.Fragment, { children: inputUsdNum > maxUsdAmount ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
57035
57289
|
"div",
|
|
57036
57290
|
{
|
|
@@ -57045,7 +57299,44 @@ function EnterAmountView({
|
|
|
57045
57299
|
style: { color: colors2.error },
|
|
57046
57300
|
children: error
|
|
57047
57301
|
}
|
|
57048
|
-
) })
|
|
57302
|
+
) }),
|
|
57303
|
+
isCheckout && selectedToken.icon_url && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-center uf-gap-2 uf-py-2", children: [
|
|
57304
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "uf-relative", children: [
|
|
57305
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
57306
|
+
"img",
|
|
57307
|
+
{
|
|
57308
|
+
src: selectedToken.icon_url,
|
|
57309
|
+
alt: selectedToken.symbol,
|
|
57310
|
+
width: 20,
|
|
57311
|
+
height: 20,
|
|
57312
|
+
className: "uf-w-5 uf-h-5 uf-rounded-full"
|
|
57313
|
+
}
|
|
57314
|
+
),
|
|
57315
|
+
selectedToken.chain_icon_url && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
57316
|
+
"img",
|
|
57317
|
+
{
|
|
57318
|
+
src: selectedToken.chain_icon_url,
|
|
57319
|
+
alt: selectedToken.chain_name,
|
|
57320
|
+
width: 10,
|
|
57321
|
+
height: 10,
|
|
57322
|
+
className: "uf-w-2.5 uf-h-2.5 uf-rounded-full uf-absolute -uf-bottom-0.5 -uf-right-0.5 uf-border",
|
|
57323
|
+
style: { borderColor: colors2.background }
|
|
57324
|
+
}
|
|
57325
|
+
)
|
|
57326
|
+
] }),
|
|
57327
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
57328
|
+
"span",
|
|
57329
|
+
{
|
|
57330
|
+
className: "uf-text-xs",
|
|
57331
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
57332
|
+
children: [
|
|
57333
|
+
selectedToken.symbol,
|
|
57334
|
+
" on ",
|
|
57335
|
+
selectedToken.chain_name
|
|
57336
|
+
]
|
|
57337
|
+
}
|
|
57338
|
+
)
|
|
57339
|
+
] })
|
|
57049
57340
|
] }),
|
|
57050
57341
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "uf-shrink-0 uf-pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
57051
57342
|
"button",
|
|
@@ -57069,6 +57360,18 @@ function EnterAmountView({
|
|
|
57069
57360
|
}
|
|
57070
57361
|
);
|
|
57071
57362
|
}
|
|
57363
|
+
var WALLET_ICONS2 = {
|
|
57364
|
+
metamask: MetamaskIcon,
|
|
57365
|
+
phantom: PhantomIcon,
|
|
57366
|
+
coinbase: CoinbaseIcon,
|
|
57367
|
+
trust: TrustIcon,
|
|
57368
|
+
rainbow: RainbowIcon,
|
|
57369
|
+
rabby: RabbyIcon,
|
|
57370
|
+
okx: OkxIcon,
|
|
57371
|
+
solflare: SolflareIcon,
|
|
57372
|
+
backpack: BackpackIcon,
|
|
57373
|
+
glow: GlowIcon
|
|
57374
|
+
};
|
|
57072
57375
|
function ReviewView({
|
|
57073
57376
|
walletInfo,
|
|
57074
57377
|
recipientAddress,
|
|
@@ -57103,30 +57406,17 @@ function ReviewView({
|
|
|
57103
57406
|
),
|
|
57104
57407
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "uf-flex uf-min-h-0 uf-flex-1 uf-flex-col", children: [
|
|
57105
57408
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "uf-min-h-0 uf-flex-1 uf-overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: [
|
|
57106
|
-
/* @__PURE__ */ (0, import_jsx_runtime66.
|
|
57107
|
-
|
|
57108
|
-
|
|
57109
|
-
|
|
57110
|
-
|
|
57111
|
-
|
|
57112
|
-
|
|
57113
|
-
|
|
57114
|
-
|
|
57115
|
-
|
|
57116
|
-
|
|
57117
|
-
),
|
|
57118
|
-
formattedTokenAmount && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
57119
|
-
"div",
|
|
57120
|
-
{
|
|
57121
|
-
className: "uf-text-sm uf-mt-2",
|
|
57122
|
-
style: { color: colors2.foregroundMuted },
|
|
57123
|
-
children: [
|
|
57124
|
-
"\u2248 ",
|
|
57125
|
-
formattedTokenAmount
|
|
57126
|
-
]
|
|
57127
|
-
}
|
|
57128
|
-
)
|
|
57129
|
-
] }),
|
|
57409
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "uf-text-center", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
57410
|
+
"div",
|
|
57411
|
+
{
|
|
57412
|
+
className: "uf-text-4xl uf-font-medium",
|
|
57413
|
+
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
57414
|
+
children: [
|
|
57415
|
+
"$",
|
|
57416
|
+
amountUsd || "0"
|
|
57417
|
+
]
|
|
57418
|
+
}
|
|
57419
|
+
) }),
|
|
57130
57420
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
57131
57421
|
"div",
|
|
57132
57422
|
{
|
|
@@ -57143,7 +57433,31 @@ function ReviewView({
|
|
|
57143
57433
|
{
|
|
57144
57434
|
className: "uf-text-sm",
|
|
57145
57435
|
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
57146
|
-
children: "
|
|
57436
|
+
children: "From"
|
|
57437
|
+
}
|
|
57438
|
+
),
|
|
57439
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
57440
|
+
WALLET_ICONS2[walletInfo.icon] && (() => {
|
|
57441
|
+
const Icon22 = WALLET_ICONS2[walletInfo.icon];
|
|
57442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "uf-w-5 uf-h-5 uf-rounded-full uf-overflow-hidden uf-flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Icon22, { size: 20, variant: "color" }) });
|
|
57443
|
+
})(),
|
|
57444
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
57445
|
+
"span",
|
|
57446
|
+
{
|
|
57447
|
+
className: "uf-text-sm uf-font-medium",
|
|
57448
|
+
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
57449
|
+
children: walletInfo.name
|
|
57450
|
+
}
|
|
57451
|
+
)
|
|
57452
|
+
] })
|
|
57453
|
+
] }),
|
|
57454
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "uf-flex uf-justify-between uf-items-center", children: [
|
|
57455
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
57456
|
+
"span",
|
|
57457
|
+
{
|
|
57458
|
+
className: "uf-text-sm",
|
|
57459
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
57460
|
+
children: "You send"
|
|
57147
57461
|
}
|
|
57148
57462
|
),
|
|
57149
57463
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
@@ -57155,17 +57469,12 @@ function ReviewView({
|
|
|
57155
57469
|
className: "uf-w-5 uf-h-5 uf-rounded-full"
|
|
57156
57470
|
}
|
|
57157
57471
|
),
|
|
57158
|
-
/* @__PURE__ */ (0, import_jsx_runtime66.
|
|
57472
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
57159
57473
|
"span",
|
|
57160
57474
|
{
|
|
57161
57475
|
className: "uf-text-sm uf-font-medium",
|
|
57162
57476
|
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
57163
|
-
children:
|
|
57164
|
-
walletInfo.name,
|
|
57165
|
-
" (",
|
|
57166
|
-
truncateAddress2(walletInfo.address),
|
|
57167
|
-
")"
|
|
57168
|
-
]
|
|
57477
|
+
children: formattedTokenAmount || `$${amountUsd}`
|
|
57169
57478
|
}
|
|
57170
57479
|
)
|
|
57171
57480
|
] })
|
|
@@ -57328,7 +57637,10 @@ function ReviewView({
|
|
|
57328
57637
|
borderRadius: components.button.borderRadius,
|
|
57329
57638
|
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
57330
57639
|
},
|
|
57331
|
-
children: isConfirming ? "
|
|
57640
|
+
children: isConfirming ? /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("span", { className: "uf-flex uf-items-center uf-justify-center uf-gap-2", children: [
|
|
57641
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }),
|
|
57642
|
+
"Confirming..."
|
|
57643
|
+
] }) : "Confirm Order"
|
|
57332
57644
|
}
|
|
57333
57645
|
) })
|
|
57334
57646
|
] })
|
|
@@ -57337,17 +57649,35 @@ function ReviewView({
|
|
|
57337
57649
|
}
|
|
57338
57650
|
);
|
|
57339
57651
|
}
|
|
57652
|
+
var SETTLE_FALLBACK_MS = 15e3;
|
|
57340
57653
|
function ConfirmingView({
|
|
57341
57654
|
isConfirming,
|
|
57342
57655
|
onClose,
|
|
57343
57656
|
executions = [],
|
|
57344
|
-
isPolling = false
|
|
57657
|
+
isPolling = false,
|
|
57658
|
+
onNewDeposit,
|
|
57659
|
+
onDone,
|
|
57660
|
+
paymentIntentStatus,
|
|
57661
|
+
amountReceivedUsd,
|
|
57662
|
+
amountReceivedUsdAtSubmission
|
|
57345
57663
|
}) {
|
|
57346
|
-
const { colors: colors2, fonts } = useTheme();
|
|
57664
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
57347
57665
|
const [containerEl, setContainerEl] = (0, import_react26.useState)(null);
|
|
57348
57666
|
const containerCallbackRef = (0, import_react26.useCallback)((el) => {
|
|
57349
57667
|
setContainerEl(el);
|
|
57350
57668
|
}, []);
|
|
57669
|
+
const [fallbackSettled, setFallbackSettled] = (0, import_react26.useState)(false);
|
|
57670
|
+
const hasExecution = executions.length > 0;
|
|
57671
|
+
const isCheckoutMode = paymentIntentStatus != null;
|
|
57672
|
+
const isPaymentComplete = paymentIntentStatus === "succeeded";
|
|
57673
|
+
const amountChanged = amountReceivedUsdAtSubmission != null && amountReceivedUsd != null && amountReceivedUsd !== amountReceivedUsdAtSubmission;
|
|
57674
|
+
const piSettled = !isCheckoutMode || isPaymentComplete || amountChanged || fallbackSettled;
|
|
57675
|
+
(0, import_react26.useEffect)(() => {
|
|
57676
|
+
if (!hasExecution || piSettled) return;
|
|
57677
|
+
const timeout = setTimeout(() => setFallbackSettled(true), SETTLE_FALLBACK_MS);
|
|
57678
|
+
return () => clearTimeout(timeout);
|
|
57679
|
+
}, [hasExecution, piSettled]);
|
|
57680
|
+
const showButtons = hasExecution && piSettled;
|
|
57351
57681
|
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PortalContainerProvider, { value: containerEl, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
57352
57682
|
"div",
|
|
57353
57683
|
{
|
|
@@ -57360,8 +57690,8 @@ function ConfirmingView({
|
|
|
57360
57690
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57361
57691
|
DepositHeader,
|
|
57362
57692
|
{
|
|
57363
|
-
title: isConfirming ? "Confirming..." : "Processing",
|
|
57364
|
-
onClose
|
|
57693
|
+
title: isConfirming ? "Confirming..." : hasExecution && isPaymentComplete ? "Payment Complete" : hasExecution ? "Deposit Received" : "Processing",
|
|
57694
|
+
onClose: isPaymentComplete && onDone ? onDone : onClose
|
|
57365
57695
|
}
|
|
57366
57696
|
),
|
|
57367
57697
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-flex uf-flex-1 uf-flex-col uf-items-center uf-justify-center uf-py-8", children: isConfirming ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
@@ -57388,12 +57718,12 @@ function ConfirmingView({
|
|
|
57388
57718
|
children: "Please confirm the transaction in your wallet"
|
|
57389
57719
|
}
|
|
57390
57720
|
)
|
|
57391
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
57721
|
+
] }) : hasExecution ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
57392
57722
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57393
57723
|
CircleCheck,
|
|
57394
57724
|
{
|
|
57395
57725
|
className: "uf-w-12 uf-h-12 uf-mb-4",
|
|
57396
|
-
style: { color:
|
|
57726
|
+
style: { color: "rgb(34, 197, 94)" }
|
|
57397
57727
|
}
|
|
57398
57728
|
),
|
|
57399
57729
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
@@ -57401,7 +57731,7 @@ function ConfirmingView({
|
|
|
57401
57731
|
{
|
|
57402
57732
|
className: "uf-text-lg uf-font-medium",
|
|
57403
57733
|
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
57404
|
-
children: "
|
|
57734
|
+
children: isPaymentComplete ? "Payment Complete" : "Deposit Received"
|
|
57405
57735
|
}
|
|
57406
57736
|
),
|
|
57407
57737
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
@@ -57409,13 +57739,72 @@ function ConfirmingView({
|
|
|
57409
57739
|
{
|
|
57410
57740
|
className: "uf-text-sm uf-mt-2 uf-text-center uf-px-6",
|
|
57411
57741
|
style: { color: colors2.foregroundMuted },
|
|
57412
|
-
children: "
|
|
57742
|
+
children: isPaymentComplete ? "Your payment has been fulfilled." : showButtons ? "Your deposit is being processed." : "Checking payment status..."
|
|
57413
57743
|
}
|
|
57414
|
-
)
|
|
57415
|
-
|
|
57416
|
-
|
|
57417
|
-
|
|
57418
|
-
|
|
57744
|
+
),
|
|
57745
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-mt-6 uf-flex uf-flex-col uf-items-center uf-gap-3", children: !showButtons ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57746
|
+
LoaderCircle,
|
|
57747
|
+
{
|
|
57748
|
+
className: "uf-w-5 uf-h-5 uf-animate-spin",
|
|
57749
|
+
style: { color: colors2.foregroundMuted }
|
|
57750
|
+
}
|
|
57751
|
+
) : isPaymentComplete && onDone ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57752
|
+
"button",
|
|
57753
|
+
{
|
|
57754
|
+
onClick: onDone,
|
|
57755
|
+
className: "uf-w-full uf-py-3 uf-px-8 uf-text-sm uf-font-medium uf-transition-opacity hover:uf-opacity-80",
|
|
57756
|
+
style: {
|
|
57757
|
+
backgroundColor: colors2.primary,
|
|
57758
|
+
color: colors2.primaryForeground,
|
|
57759
|
+
fontFamily: fonts.medium,
|
|
57760
|
+
borderRadius: components.button.borderRadius
|
|
57761
|
+
},
|
|
57762
|
+
children: "Done"
|
|
57763
|
+
}
|
|
57764
|
+
) : onNewDeposit ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
57765
|
+
"button",
|
|
57766
|
+
{
|
|
57767
|
+
onClick: onNewDeposit,
|
|
57768
|
+
className: "uf-flex uf-items-center uf-gap-2 uf-px-5 uf-py-2.5 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-opacity hover:uf-opacity-80",
|
|
57769
|
+
style: {
|
|
57770
|
+
backgroundColor: colors2.primary,
|
|
57771
|
+
color: colors2.primaryForeground,
|
|
57772
|
+
fontFamily: fonts.medium
|
|
57773
|
+
},
|
|
57774
|
+
children: [
|
|
57775
|
+
"Make another deposit",
|
|
57776
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ArrowRight, { className: "uf-w-4 uf-h-4" })
|
|
57777
|
+
]
|
|
57778
|
+
}
|
|
57779
|
+
) : null })
|
|
57780
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
57781
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57782
|
+
LoaderCircle,
|
|
57783
|
+
{
|
|
57784
|
+
className: "uf-w-12 uf-h-12 uf-animate-spin uf-mb-4",
|
|
57785
|
+
style: { color: colors2.primary }
|
|
57786
|
+
}
|
|
57787
|
+
),
|
|
57788
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57789
|
+
"div",
|
|
57790
|
+
{
|
|
57791
|
+
className: "uf-text-lg uf-font-medium",
|
|
57792
|
+
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
57793
|
+
children: "Transaction Submitted"
|
|
57794
|
+
}
|
|
57795
|
+
),
|
|
57796
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57797
|
+
"div",
|
|
57798
|
+
{
|
|
57799
|
+
className: "uf-text-sm uf-mt-2 uf-text-center uf-px-6",
|
|
57800
|
+
style: { color: colors2.foregroundMuted },
|
|
57801
|
+
children: "Waiting for your deposit to be detected..."
|
|
57802
|
+
}
|
|
57803
|
+
)
|
|
57804
|
+
] }) }),
|
|
57805
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
57806
|
+
DepositPollingToasts,
|
|
57807
|
+
{
|
|
57419
57808
|
executions,
|
|
57420
57809
|
isPolling,
|
|
57421
57810
|
horizontalPadding: "0"
|
|
@@ -57433,6 +57822,7 @@ function BrowserWalletModal({
|
|
|
57433
57822
|
depositWallet,
|
|
57434
57823
|
userId,
|
|
57435
57824
|
publishableKey,
|
|
57825
|
+
clientSecret,
|
|
57436
57826
|
assetCdnUrl,
|
|
57437
57827
|
projectName,
|
|
57438
57828
|
theme = "dark",
|
|
@@ -57441,7 +57831,13 @@ function BrowserWalletModal({
|
|
|
57441
57831
|
onDepositSuccess,
|
|
57442
57832
|
onDepositError,
|
|
57443
57833
|
amountQuickSelect = "percentage",
|
|
57444
|
-
onWalletDisconnect
|
|
57834
|
+
onWalletDisconnect,
|
|
57835
|
+
prefillAmountUsd,
|
|
57836
|
+
checkoutAmountUsd,
|
|
57837
|
+
checkoutReceivedUsd,
|
|
57838
|
+
onNewDeposit,
|
|
57839
|
+
onDone,
|
|
57840
|
+
paymentIntentStatus
|
|
57445
57841
|
}) {
|
|
57446
57842
|
const { colors: colors2, fonts, components } = useTheme();
|
|
57447
57843
|
const [step, setStep] = React262.useState("select-token");
|
|
@@ -57459,6 +57855,7 @@ function BrowserWalletModal({
|
|
|
57459
57855
|
const [tokenChainDetails, setTokenChainDetails] = React262.useState(null);
|
|
57460
57856
|
const [loadingTokenDetails, setLoadingTokenDetails] = React262.useState(false);
|
|
57461
57857
|
const [showTransactionDetails, setShowTransactionDetails] = React262.useState(false);
|
|
57858
|
+
const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React262.useState(null);
|
|
57462
57859
|
const themeClass = theme === "dark" ? "uf-dark" : "";
|
|
57463
57860
|
const chainType = depositWallet.chain_type;
|
|
57464
57861
|
const recipientAddress = depositWallet.address;
|
|
@@ -57466,15 +57863,19 @@ function BrowserWalletModal({
|
|
|
57466
57863
|
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
57467
57864
|
userId,
|
|
57468
57865
|
publishableKey,
|
|
57866
|
+
clientSecret,
|
|
57469
57867
|
enabled: open && hasSignedTransaction,
|
|
57470
57868
|
onDepositSuccess,
|
|
57471
57869
|
onDepositError
|
|
57472
57870
|
});
|
|
57871
|
+
const prevOpenRef = React262.useRef(false);
|
|
57473
57872
|
React262.useEffect(() => {
|
|
57474
|
-
|
|
57873
|
+
const wasOpen = prevOpenRef.current;
|
|
57874
|
+
prevOpenRef.current = open;
|
|
57875
|
+
if (open && !wasOpen) {
|
|
57475
57876
|
setStep("select-token");
|
|
57476
57877
|
setSelectedBalance(null);
|
|
57477
|
-
setAmountUsd("");
|
|
57878
|
+
setAmountUsd(prefillAmountUsd ?? "");
|
|
57478
57879
|
setError(null);
|
|
57479
57880
|
setIsConfirming(false);
|
|
57480
57881
|
setTokenChainDetails(null);
|
|
@@ -57482,7 +57883,15 @@ function BrowserWalletModal({
|
|
|
57482
57883
|
setHasSignedTransaction(false);
|
|
57483
57884
|
setIsDisconnectingWallet(false);
|
|
57484
57885
|
}
|
|
57485
|
-
}, [open]);
|
|
57886
|
+
}, [open, prefillAmountUsd]);
|
|
57887
|
+
React262.useEffect(() => {
|
|
57888
|
+
if (!prefillAmountUsd || !tokenChainDetails || step !== "input-amount") return;
|
|
57889
|
+
const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
|
|
57890
|
+
const currentAmount = parseFloat(amountUsd) || 0;
|
|
57891
|
+
if (currentAmount > 0 && currentAmount < minDeposit) {
|
|
57892
|
+
setAmountUsd(minDeposit.toFixed(2));
|
|
57893
|
+
}
|
|
57894
|
+
}, [tokenChainDetails, step, prefillAmountUsd]);
|
|
57486
57895
|
React262.useEffect(() => {
|
|
57487
57896
|
if (step === "review") {
|
|
57488
57897
|
setShowTransactionDetails(false);
|
|
@@ -57600,7 +58009,7 @@ function BrowserWalletModal({
|
|
|
57600
58009
|
setError(null);
|
|
57601
58010
|
if (step === "input-amount") {
|
|
57602
58011
|
setStep("select-token");
|
|
57603
|
-
setAmountUsd("");
|
|
58012
|
+
setAmountUsd(prefillAmountUsd ?? "");
|
|
57604
58013
|
setTokenChainDetails(null);
|
|
57605
58014
|
} else if (step === "review") {
|
|
57606
58015
|
setStep("input-amount");
|
|
@@ -57686,7 +58095,6 @@ function BrowserWalletModal({
|
|
|
57686
58095
|
}
|
|
57687
58096
|
}
|
|
57688
58097
|
setIsConfirming(true);
|
|
57689
|
-
setStep("confirming");
|
|
57690
58098
|
setError(null);
|
|
57691
58099
|
try {
|
|
57692
58100
|
let txHash;
|
|
@@ -57704,16 +58112,17 @@ function BrowserWalletModal({
|
|
|
57704
58112
|
} else {
|
|
57705
58113
|
txHash = await sendEthereumTransaction(token, tokenAmount.toString());
|
|
57706
58114
|
}
|
|
58115
|
+
setReceivedUsdAtSubmission(checkoutReceivedUsd ?? "0");
|
|
57707
58116
|
setHasSignedTransaction(true);
|
|
57708
|
-
onSuccess?.(txHash);
|
|
57709
58117
|
setIsConfirming(false);
|
|
58118
|
+
setStep("confirming");
|
|
58119
|
+
onSuccess?.(txHash);
|
|
57710
58120
|
} catch (err) {
|
|
57711
58121
|
console.error("[BrowserWalletModal] Transaction error:", err);
|
|
57712
58122
|
const errorMessage = err instanceof Error ? err.message : "Transaction failed";
|
|
57713
58123
|
setError(errorMessage);
|
|
57714
58124
|
onError?.(err instanceof Error ? err : new Error(errorMessage));
|
|
57715
58125
|
setIsConfirming(false);
|
|
57716
|
-
setStep("review");
|
|
57717
58126
|
}
|
|
57718
58127
|
};
|
|
57719
58128
|
const sendEthereumTransaction = async (token, amountStr) => {
|
|
@@ -57962,7 +58371,9 @@ function BrowserWalletModal({
|
|
|
57962
58371
|
onBack: handleClose,
|
|
57963
58372
|
onClose: handleFullClose,
|
|
57964
58373
|
onDisconnectWallet: onWalletDisconnect ? () => void handleDisconnectFromSelectToken() : void 0,
|
|
57965
|
-
isDisconnectingWallet
|
|
58374
|
+
isDisconnectingWallet,
|
|
58375
|
+
checkoutAmountUsd,
|
|
58376
|
+
checkoutReceivedUsd
|
|
57966
58377
|
}
|
|
57967
58378
|
),
|
|
57968
58379
|
step === "input-amount" && selectedToken && selectedBalance && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
@@ -57983,7 +58394,9 @@ function BrowserWalletModal({
|
|
|
57983
58394
|
onReview: handleReview,
|
|
57984
58395
|
onBack: handleBack,
|
|
57985
58396
|
onClose: handleFullClose,
|
|
57986
|
-
quickSelectMode: amountQuickSelect
|
|
58397
|
+
quickSelectMode: amountQuickSelect,
|
|
58398
|
+
checkoutAmountUsd,
|
|
58399
|
+
checkoutReceivedUsd
|
|
57987
58400
|
}
|
|
57988
58401
|
),
|
|
57989
58402
|
step === "review" && selectedToken && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
@@ -58012,7 +58425,12 @@ function BrowserWalletModal({
|
|
|
58012
58425
|
isConfirming,
|
|
58013
58426
|
onClose: handleFullClose,
|
|
58014
58427
|
executions: depositExecutions,
|
|
58015
|
-
isPolling
|
|
58428
|
+
isPolling,
|
|
58429
|
+
onNewDeposit,
|
|
58430
|
+
onDone,
|
|
58431
|
+
paymentIntentStatus,
|
|
58432
|
+
amountReceivedUsd: checkoutReceivedUsd,
|
|
58433
|
+
amountReceivedUsdAtSubmission: receivedUsdAtSubmission
|
|
58016
58434
|
}
|
|
58017
58435
|
)
|
|
58018
58436
|
] })
|
|
@@ -58021,7 +58439,7 @@ function BrowserWalletModal({
|
|
|
58021
58439
|
}
|
|
58022
58440
|
) });
|
|
58023
58441
|
}
|
|
58024
|
-
var
|
|
58442
|
+
var WALLET_ICONS3 = {
|
|
58025
58443
|
metamask: MetamaskIcon,
|
|
58026
58444
|
phantom: PhantomIcon,
|
|
58027
58445
|
coinbase: CoinbaseIcon,
|
|
@@ -58460,10 +58878,10 @@ function WalletSelectionModal({
|
|
|
58460
58878
|
},
|
|
58461
58879
|
children: [
|
|
58462
58880
|
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
58463
|
-
|
|
58881
|
+
WALLET_ICONS3[wallet.id] ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
58464
58882
|
WalletIconWithNetwork,
|
|
58465
58883
|
{
|
|
58466
|
-
WalletIcon:
|
|
58884
|
+
WalletIcon: WALLET_ICONS3[wallet.id],
|
|
58467
58885
|
networks: wallet.networks,
|
|
58468
58886
|
size: 40,
|
|
58469
58887
|
className: "uf-rounded-lg"
|
|
@@ -58534,10 +58952,10 @@ function WalletSelectionModal({
|
|
|
58534
58952
|
style: { minHeight: WALLET_STEP_BODY_MIN_HEIGHT },
|
|
58535
58953
|
children: [
|
|
58536
58954
|
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pb-4 uf-shrink-0", children: [
|
|
58537
|
-
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "uf-mb-2", children:
|
|
58955
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "uf-mb-2", children: WALLET_ICONS3[selectedWallet.id] ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
58538
58956
|
WalletIconWithNetwork,
|
|
58539
58957
|
{
|
|
58540
|
-
WalletIcon:
|
|
58958
|
+
WalletIcon: WALLET_ICONS3[selectedWallet.id],
|
|
58541
58959
|
networks: selectedWallet.networks,
|
|
58542
58960
|
size: 48,
|
|
58543
58961
|
className: "uf-rounded-lg"
|
|
@@ -59336,6 +59754,664 @@ function DepositModal({
|
|
|
59336
59754
|
}
|
|
59337
59755
|
) });
|
|
59338
59756
|
}
|
|
59757
|
+
function usePaymentIntent(params) {
|
|
59758
|
+
const {
|
|
59759
|
+
clientSecret,
|
|
59760
|
+
publishableKey,
|
|
59761
|
+
enabled = true,
|
|
59762
|
+
pollingInterval = 5e3
|
|
59763
|
+
} = params;
|
|
59764
|
+
return useQuery({
|
|
59765
|
+
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
59766
|
+
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
59767
|
+
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
59768
|
+
staleTime: 0,
|
|
59769
|
+
refetchInterval: pollingInterval || false,
|
|
59770
|
+
refetchOnWindowFocus: true,
|
|
59771
|
+
retry: 3,
|
|
59772
|
+
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
59773
|
+
});
|
|
59774
|
+
}
|
|
59775
|
+
function useDepositQuote(params) {
|
|
59776
|
+
const {
|
|
59777
|
+
publishableKey,
|
|
59778
|
+
sourceChainType,
|
|
59779
|
+
sourceChainId,
|
|
59780
|
+
sourceTokenAddress,
|
|
59781
|
+
destinationAmount,
|
|
59782
|
+
destinationChainType,
|
|
59783
|
+
destinationChainId,
|
|
59784
|
+
destinationTokenAddress,
|
|
59785
|
+
enabled = true
|
|
59786
|
+
} = params;
|
|
59787
|
+
const request = {
|
|
59788
|
+
source_chain_type: sourceChainType,
|
|
59789
|
+
source_chain_id: sourceChainId,
|
|
59790
|
+
source_token_address: sourceTokenAddress,
|
|
59791
|
+
destination_amount: destinationAmount,
|
|
59792
|
+
destination_chain_type: destinationChainType,
|
|
59793
|
+
destination_chain_id: destinationChainId,
|
|
59794
|
+
destination_token_address: destinationTokenAddress
|
|
59795
|
+
};
|
|
59796
|
+
return useQuery({
|
|
59797
|
+
queryKey: [
|
|
59798
|
+
"unifold",
|
|
59799
|
+
"depositQuote",
|
|
59800
|
+
sourceChainType,
|
|
59801
|
+
sourceChainId,
|
|
59802
|
+
sourceTokenAddress,
|
|
59803
|
+
destinationAmount,
|
|
59804
|
+
destinationChainType,
|
|
59805
|
+
destinationChainId,
|
|
59806
|
+
destinationTokenAddress,
|
|
59807
|
+
publishableKey
|
|
59808
|
+
],
|
|
59809
|
+
queryFn: () => getDepositQuote(request, publishableKey),
|
|
59810
|
+
enabled: enabled && !!publishableKey && !!sourceChainType && !!sourceChainId && !!sourceTokenAddress && !!destinationAmount && destinationAmount !== "0" && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress,
|
|
59811
|
+
staleTime: 6e4,
|
|
59812
|
+
gcTime: 5 * 6e4,
|
|
59813
|
+
refetchOnWindowFocus: false,
|
|
59814
|
+
retry: 2,
|
|
59815
|
+
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 5e3)
|
|
59816
|
+
});
|
|
59817
|
+
}
|
|
59818
|
+
function mapDepositAddressesToWallets(depositAddresses, pi) {
|
|
59819
|
+
return depositAddresses.map((da, idx) => ({
|
|
59820
|
+
id: da.id,
|
|
59821
|
+
chain_type: da.chain_type,
|
|
59822
|
+
address_type: da.address_type,
|
|
59823
|
+
address: da.address,
|
|
59824
|
+
destination_chain_type: pi.destination_chain_type,
|
|
59825
|
+
destination_chain_id: pi.destination_chain_id,
|
|
59826
|
+
destination_token_address: pi.destination_token_address,
|
|
59827
|
+
recipient_address: pi.recipient_address,
|
|
59828
|
+
is_primary: idx === 0
|
|
59829
|
+
}));
|
|
59830
|
+
}
|
|
59831
|
+
function SkeletonButton2() {
|
|
59832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-animate-pulse", children: [
|
|
59833
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
59834
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-bg-muted uf-rounded-lg uf-w-9 uf-h-9" }),
|
|
59835
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-space-y-1.5", children: [
|
|
59836
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-h-3.5 uf-w-24 uf-bg-muted uf-rounded" }),
|
|
59837
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded" })
|
|
59838
|
+
] })
|
|
59839
|
+
] }),
|
|
59840
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted" }) })
|
|
59841
|
+
] });
|
|
59842
|
+
}
|
|
59843
|
+
function CheckoutModal({
|
|
59844
|
+
open,
|
|
59845
|
+
onOpenChange,
|
|
59846
|
+
clientSecret,
|
|
59847
|
+
publishableKey,
|
|
59848
|
+
modalTitle,
|
|
59849
|
+
enableConnectWallet = false,
|
|
59850
|
+
theme = "dark",
|
|
59851
|
+
onCheckoutSuccess,
|
|
59852
|
+
onCheckoutError
|
|
59853
|
+
}) {
|
|
59854
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
59855
|
+
const [view, setView] = (0, import_react27.useState)("main");
|
|
59856
|
+
const resetViewTimeoutRef = (0, import_react27.useRef)(
|
|
59857
|
+
null
|
|
59858
|
+
);
|
|
59859
|
+
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react27.useState)(false);
|
|
59860
|
+
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react27.useState)(null);
|
|
59861
|
+
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react27.useState)(false);
|
|
59862
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react27.useState)(() => getStoredWalletChainType());
|
|
59863
|
+
const isMobileView = useIsMobileViewport();
|
|
59864
|
+
const [resolvedTheme, setResolvedTheme] = (0, import_react27.useState)(
|
|
59865
|
+
theme === "auto" ? "dark" : theme
|
|
59866
|
+
);
|
|
59867
|
+
(0, import_react27.useEffect)(() => {
|
|
59868
|
+
if (theme === "auto") {
|
|
59869
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
59870
|
+
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
59871
|
+
const handler = (e) => {
|
|
59872
|
+
setResolvedTheme(e.matches ? "dark" : "light");
|
|
59873
|
+
};
|
|
59874
|
+
mediaQuery.addEventListener("change", handler);
|
|
59875
|
+
return () => mediaQuery.removeEventListener("change", handler);
|
|
59876
|
+
} else {
|
|
59877
|
+
setResolvedTheme(theme);
|
|
59878
|
+
}
|
|
59879
|
+
}, [theme]);
|
|
59880
|
+
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
59881
|
+
const {
|
|
59882
|
+
data: paymentIntent,
|
|
59883
|
+
isLoading: piLoading,
|
|
59884
|
+
error: piError
|
|
59885
|
+
} = usePaymentIntent({
|
|
59886
|
+
clientSecret,
|
|
59887
|
+
publishableKey,
|
|
59888
|
+
enabled: open && !!clientSecret,
|
|
59889
|
+
pollingInterval: 5e3
|
|
59890
|
+
});
|
|
59891
|
+
const { projectConfig } = useProjectConfig({
|
|
59892
|
+
publishableKey,
|
|
59893
|
+
enabled: open
|
|
59894
|
+
});
|
|
59895
|
+
const prevStatusRef = (0, import_react27.useRef)(null);
|
|
59896
|
+
(0, import_react27.useEffect)(() => {
|
|
59897
|
+
if (!paymentIntent) return;
|
|
59898
|
+
const prev = prevStatusRef.current;
|
|
59899
|
+
prevStatusRef.current = paymentIntent.status;
|
|
59900
|
+
if (prev && prev !== paymentIntent.status && paymentIntent.status === "succeeded") {
|
|
59901
|
+
if (!browserWalletModalOpen) {
|
|
59902
|
+
setView("main");
|
|
59903
|
+
}
|
|
59904
|
+
onCheckoutSuccess?.({
|
|
59905
|
+
paymentIntentId: paymentIntent.id,
|
|
59906
|
+
status: paymentIntent.status
|
|
59907
|
+
});
|
|
59908
|
+
}
|
|
59909
|
+
}, [paymentIntent, onCheckoutSuccess, browserWalletModalOpen]);
|
|
59910
|
+
const wallets = (0, import_react27.useMemo)(() => {
|
|
59911
|
+
if (!paymentIntent) return [];
|
|
59912
|
+
return mapDepositAddressesToWallets(
|
|
59913
|
+
paymentIntent.deposit_addresses,
|
|
59914
|
+
paymentIntent
|
|
59915
|
+
);
|
|
59916
|
+
}, [paymentIntent]);
|
|
59917
|
+
const formatCryptoAmount = (0, import_react27.useMemo)(() => {
|
|
59918
|
+
if (!paymentIntent) return (_) => "";
|
|
59919
|
+
const decimals = paymentIntent.destination_token_decimals ?? 6;
|
|
59920
|
+
const symbol = paymentIntent.currency.toUpperCase();
|
|
59921
|
+
return (baseUnits) => {
|
|
59922
|
+
const num = Number(baseUnits) / 10 ** decimals;
|
|
59923
|
+
const formatted = num % 1 === 0 ? num.toFixed(0) : num.toFixed(2);
|
|
59924
|
+
return `${formatted} ${symbol}`;
|
|
59925
|
+
};
|
|
59926
|
+
}, [paymentIntent]);
|
|
59927
|
+
const remainingAmountUsd = (0, import_react27.useMemo)(() => {
|
|
59928
|
+
if (!paymentIntent) return void 0;
|
|
59929
|
+
const total = parseFloat(paymentIntent.amount_usd);
|
|
59930
|
+
const received = parseFloat(paymentIntent.amount_received_usd);
|
|
59931
|
+
if (isNaN(total) || isNaN(received)) return paymentIntent.amount_usd;
|
|
59932
|
+
const remaining = total - received;
|
|
59933
|
+
return remaining > 0 ? remaining.toFixed(2) : "0.00";
|
|
59934
|
+
}, [paymentIntent]);
|
|
59935
|
+
const remainingCrypto = (0, import_react27.useMemo)(() => {
|
|
59936
|
+
if (!paymentIntent) return void 0;
|
|
59937
|
+
const total = BigInt(paymentIntent.amount);
|
|
59938
|
+
const received = BigInt(paymentIntent.amount_received);
|
|
59939
|
+
const remaining = total - received;
|
|
59940
|
+
return remaining > 0n ? remaining.toString() : "0";
|
|
59941
|
+
}, [paymentIntent]);
|
|
59942
|
+
const [selectedSource, setSelectedSource] = (0, import_react27.useState)(null);
|
|
59943
|
+
const quoteDestinationAmount = (0, import_react27.useMemo)(() => {
|
|
59944
|
+
if (!paymentIntent || !selectedSource) return "0";
|
|
59945
|
+
const remaining = BigInt(paymentIntent.amount) - BigInt(paymentIntent.amount_received);
|
|
59946
|
+
const totalBaseUnits = Number(paymentIntent.amount);
|
|
59947
|
+
const totalUsd = parseFloat(paymentIntent.amount_usd);
|
|
59948
|
+
const baseUnitsPerUsd = totalUsd > 0 ? totalBaseUnits / totalUsd : 0;
|
|
59949
|
+
const minUsd = Math.max(selectedSource.minimumDepositAmountUsd, 3);
|
|
59950
|
+
const minDepositBaseUnits = BigInt(Math.ceil(minUsd * baseUnitsPerUsd));
|
|
59951
|
+
const effective = remaining > minDepositBaseUnits ? remaining : minDepositBaseUnits;
|
|
59952
|
+
return effective > 0n ? effective.toString() : "0";
|
|
59953
|
+
}, [paymentIntent, selectedSource]);
|
|
59954
|
+
const { data: sourceQuote } = useDepositQuote({
|
|
59955
|
+
publishableKey,
|
|
59956
|
+
sourceChainType: selectedSource?.chainType ?? "",
|
|
59957
|
+
sourceChainId: selectedSource?.chainId ?? "",
|
|
59958
|
+
sourceTokenAddress: selectedSource?.tokenAddress ?? "",
|
|
59959
|
+
destinationAmount: quoteDestinationAmount,
|
|
59960
|
+
destinationChainType: paymentIntent?.destination_chain_type ?? "",
|
|
59961
|
+
destinationChainId: paymentIntent?.destination_chain_id ?? "",
|
|
59962
|
+
destinationTokenAddress: paymentIntent?.destination_token_address ?? "",
|
|
59963
|
+
enabled: open && view === "transfer" && !!paymentIntent && !!selectedSource && quoteDestinationAmount !== "0"
|
|
59964
|
+
});
|
|
59965
|
+
const handleBrowserWalletClick = (0, import_react27.useCallback)(
|
|
59966
|
+
(walletInfo) => {
|
|
59967
|
+
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
59968
|
+
setStoredWalletChainType(walletChainType);
|
|
59969
|
+
setBrowserWalletChainType(walletChainType);
|
|
59970
|
+
const matchingDepositWallet = wallets.find(
|
|
59971
|
+
(w) => w.chain_type === walletChainType
|
|
59972
|
+
);
|
|
59973
|
+
if (!matchingDepositWallet) {
|
|
59974
|
+
onCheckoutError?.({
|
|
59975
|
+
message: `Unable to pay from ${walletChainType}. Please try a different wallet.`,
|
|
59976
|
+
code: "NO_DEPOSIT_ADDRESS"
|
|
59977
|
+
});
|
|
59978
|
+
return;
|
|
59979
|
+
}
|
|
59980
|
+
setBrowserWalletInfo({
|
|
59981
|
+
...walletInfo,
|
|
59982
|
+
depositWallet: matchingDepositWallet
|
|
59983
|
+
});
|
|
59984
|
+
setBrowserWalletModalOpen(true);
|
|
59985
|
+
},
|
|
59986
|
+
[wallets, onCheckoutError]
|
|
59987
|
+
);
|
|
59988
|
+
const handleWalletConnectClick = (0, import_react27.useCallback)(() => {
|
|
59989
|
+
setWalletSelectionModalOpen(true);
|
|
59990
|
+
}, []);
|
|
59991
|
+
const handleWalletConnected = (0, import_react27.useCallback)(
|
|
59992
|
+
(walletInfo) => {
|
|
59993
|
+
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
59994
|
+
setStoredWalletChainType(walletChainType);
|
|
59995
|
+
setBrowserWalletChainType(walletChainType);
|
|
59996
|
+
const matchingDepositWallet = wallets.find(
|
|
59997
|
+
(w) => w.chain_type === walletChainType
|
|
59998
|
+
);
|
|
59999
|
+
if (!matchingDepositWallet) {
|
|
60000
|
+
onCheckoutError?.({
|
|
60001
|
+
message: `Unable to pay from ${walletChainType}. Please try a different wallet.`,
|
|
60002
|
+
code: "NO_DEPOSIT_ADDRESS"
|
|
60003
|
+
});
|
|
60004
|
+
setWalletSelectionModalOpen(false);
|
|
60005
|
+
return;
|
|
60006
|
+
}
|
|
60007
|
+
setBrowserWalletInfo({
|
|
60008
|
+
...walletInfo,
|
|
60009
|
+
depositWallet: matchingDepositWallet
|
|
60010
|
+
});
|
|
60011
|
+
setWalletSelectionModalOpen(false);
|
|
60012
|
+
setBrowserWalletModalOpen(true);
|
|
60013
|
+
},
|
|
60014
|
+
[wallets, onCheckoutError]
|
|
60015
|
+
);
|
|
60016
|
+
const handleWalletDisconnect = (0, import_react27.useCallback)(() => {
|
|
60017
|
+
setUserDisconnectedWallet(true);
|
|
60018
|
+
clearStoredWalletChainType();
|
|
60019
|
+
setBrowserWalletChainType(void 0);
|
|
60020
|
+
setBrowserWalletInfo(null);
|
|
60021
|
+
setBrowserWalletModalOpen(false);
|
|
60022
|
+
}, []);
|
|
60023
|
+
const handleClose = (0, import_react27.useCallback)(() => {
|
|
60024
|
+
onOpenChange(false);
|
|
60025
|
+
if (resetViewTimeoutRef.current) {
|
|
60026
|
+
clearTimeout(resetViewTimeoutRef.current);
|
|
60027
|
+
}
|
|
60028
|
+
resetViewTimeoutRef.current = setTimeout(() => {
|
|
60029
|
+
setView("main");
|
|
60030
|
+
setBrowserWalletInfo(null);
|
|
60031
|
+
resetViewTimeoutRef.current = null;
|
|
60032
|
+
}, 200);
|
|
60033
|
+
}, [onOpenChange]);
|
|
60034
|
+
(0, import_react27.useLayoutEffect)(() => {
|
|
60035
|
+
if (!open) return;
|
|
60036
|
+
if (resetViewTimeoutRef.current) {
|
|
60037
|
+
clearTimeout(resetViewTimeoutRef.current);
|
|
60038
|
+
resetViewTimeoutRef.current = null;
|
|
60039
|
+
}
|
|
60040
|
+
setView("main");
|
|
60041
|
+
setBrowserWalletInfo(null);
|
|
60042
|
+
}, [open]);
|
|
60043
|
+
(0, import_react27.useEffect)(
|
|
60044
|
+
() => () => {
|
|
60045
|
+
if (resetViewTimeoutRef.current) {
|
|
60046
|
+
clearTimeout(resetViewTimeoutRef.current);
|
|
60047
|
+
}
|
|
60048
|
+
},
|
|
60049
|
+
[]
|
|
60050
|
+
);
|
|
60051
|
+
const handleBack = (0, import_react27.useCallback)(() => {
|
|
60052
|
+
setView("main");
|
|
60053
|
+
}, []);
|
|
60054
|
+
const poweredByFooter = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60055
|
+
PoweredByUnifold,
|
|
60056
|
+
{
|
|
60057
|
+
color: colors2.foregroundMuted,
|
|
60058
|
+
className: "uf-flex uf-justify-center uf-shrink-0"
|
|
60059
|
+
}
|
|
60060
|
+
) });
|
|
60061
|
+
const progressSection = paymentIntent ? (() => {
|
|
60062
|
+
const received = parseFloat(paymentIntent.amount_received_usd);
|
|
60063
|
+
const total = parseFloat(paymentIntent.amount_usd);
|
|
60064
|
+
const remaining = Math.max(total - received, 0);
|
|
60065
|
+
const pct = total > 0 ? Math.min(received / total * 100, 100) : 0;
|
|
60066
|
+
const hasPartial = received > 0;
|
|
60067
|
+
const amountStr = paymentIntent.amount_usd;
|
|
60068
|
+
const dynamicFontSize = `${Math.max(3.75 - amountStr.length * 0.15, 2)}rem`;
|
|
60069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-text-center uf-py-2 uf-space-y-1", children: [
|
|
60070
|
+
paymentIntent.description && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60071
|
+
"div",
|
|
60072
|
+
{
|
|
60073
|
+
className: "uf-text-xs",
|
|
60074
|
+
style: {
|
|
60075
|
+
color: colors2.foregroundMuted,
|
|
60076
|
+
fontFamily: fonts.regular
|
|
60077
|
+
},
|
|
60078
|
+
children: paymentIntent.description
|
|
60079
|
+
}
|
|
60080
|
+
),
|
|
60081
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-center", children: [
|
|
60082
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60083
|
+
"span",
|
|
60084
|
+
{
|
|
60085
|
+
className: "uf-mr-1",
|
|
60086
|
+
style: {
|
|
60087
|
+
fontSize: `calc(${dynamicFontSize} * 0.6)`,
|
|
60088
|
+
color: colors2.foregroundMuted,
|
|
60089
|
+
fontFamily: fonts.regular
|
|
60090
|
+
},
|
|
60091
|
+
children: "$"
|
|
60092
|
+
}
|
|
60093
|
+
),
|
|
60094
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60095
|
+
"span",
|
|
60096
|
+
{
|
|
60097
|
+
style: {
|
|
60098
|
+
fontSize: dynamicFontSize,
|
|
60099
|
+
color: colors2.foreground,
|
|
60100
|
+
fontFamily: fonts.regular,
|
|
60101
|
+
lineHeight: 1.1
|
|
60102
|
+
},
|
|
60103
|
+
children: amountStr
|
|
60104
|
+
}
|
|
60105
|
+
)
|
|
60106
|
+
] }),
|
|
60107
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60108
|
+
"div",
|
|
60109
|
+
{
|
|
60110
|
+
className: "uf-text-xs",
|
|
60111
|
+
style: {
|
|
60112
|
+
color: colors2.foregroundMuted,
|
|
60113
|
+
fontFamily: fonts.regular
|
|
60114
|
+
},
|
|
60115
|
+
children: paymentIntent.currency.toUpperCase()
|
|
60116
|
+
}
|
|
60117
|
+
),
|
|
60118
|
+
hasPartial && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-pt-2 uf-space-y-1.5", children: [
|
|
60119
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60120
|
+
"div",
|
|
60121
|
+
{
|
|
60122
|
+
className: "uf-w-full uf-h-1.5 uf-rounded-full uf-overflow-hidden",
|
|
60123
|
+
style: { backgroundColor: colors2.border },
|
|
60124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60125
|
+
"div",
|
|
60126
|
+
{
|
|
60127
|
+
className: "uf-h-full uf-rounded-full uf-transition-all uf-duration-500",
|
|
60128
|
+
style: {
|
|
60129
|
+
width: `${pct}%`,
|
|
60130
|
+
backgroundColor: paymentIntent.status === "succeeded" ? "rgb(34, 197, 94)" : colors2.primary
|
|
60131
|
+
}
|
|
60132
|
+
}
|
|
60133
|
+
)
|
|
60134
|
+
}
|
|
60135
|
+
),
|
|
60136
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
60137
|
+
"div",
|
|
60138
|
+
{
|
|
60139
|
+
className: "uf-text-xs",
|
|
60140
|
+
style: {
|
|
60141
|
+
color: colors2.foregroundMuted,
|
|
60142
|
+
fontFamily: fonts.regular
|
|
60143
|
+
},
|
|
60144
|
+
children: [
|
|
60145
|
+
"$",
|
|
60146
|
+
paymentIntent.amount_received_usd,
|
|
60147
|
+
" / $",
|
|
60148
|
+
amountStr,
|
|
60149
|
+
" received",
|
|
60150
|
+
remaining > 0 && paymentIntent.status !== "succeeded" && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { style: { color: colors2.foreground, fontFamily: fonts.medium }, children: [
|
|
60151
|
+
" ",
|
|
60152
|
+
"\xB7 $",
|
|
60153
|
+
remaining.toFixed(2),
|
|
60154
|
+
" remaining"
|
|
60155
|
+
] })
|
|
60156
|
+
]
|
|
60157
|
+
}
|
|
60158
|
+
)
|
|
60159
|
+
] }),
|
|
60160
|
+
paymentIntent.status !== "requires_payment" && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-pt-1", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60161
|
+
"span",
|
|
60162
|
+
{
|
|
60163
|
+
className: "uf-text-xs uf-font-medium uf-px-2.5 uf-py-1 uf-rounded-full uf-inline-block",
|
|
60164
|
+
style: {
|
|
60165
|
+
backgroundColor: paymentIntent.status === "succeeded" ? "rgba(34, 197, 94, 0.15)" : paymentIntent.status === "processing" ? "rgba(59, 130, 246, 0.15)" : "rgba(239, 68, 68, 0.15)",
|
|
60166
|
+
color: paymentIntent.status === "succeeded" ? "rgb(34, 197, 94)" : paymentIntent.status === "processing" ? "rgb(59, 130, 246)" : "rgb(239, 68, 68)",
|
|
60167
|
+
fontFamily: fonts.medium
|
|
60168
|
+
},
|
|
60169
|
+
children: paymentIntent.status === "succeeded" ? "Payment Complete" : paymentIntent.status === "processing" ? "Partial Payment Received" : paymentIntent.status === "canceled" ? "Canceled" : paymentIntent.status === "expired" ? "Expired" : paymentIntent.status
|
|
60170
|
+
}
|
|
60171
|
+
) })
|
|
60172
|
+
] });
|
|
60173
|
+
})() : null;
|
|
60174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PortalContainerProvider, { value: null, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Dialog2, { open, onOpenChange: handleClose, modal: true, children: [
|
|
60175
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60176
|
+
DialogContent2,
|
|
60177
|
+
{
|
|
60178
|
+
className: `sm:uf-max-w-[400px] uf-border-secondary uf-text-foreground uf-gap-0 [&>button]:uf-hidden uf-p-0 uf-overflow-visible ${view === "main" ? "!uf-top-auto !uf-h-auto !uf-max-h-[60vh] sm:!uf-max-h-none sm:!uf-top-[50%]" : "!uf-top-0 !uf-h-full sm:!uf-h-auto sm:!uf-top-[50%]"} ${themeClass}`,
|
|
60179
|
+
style: { backgroundColor: colors2.background },
|
|
60180
|
+
onPointerDownOutside: (e) => e.preventDefault(),
|
|
60181
|
+
onInteractOutside: (e) => e.preventDefault(),
|
|
60182
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ThemeStyleInjector, { children: view === "main" ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
60183
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60184
|
+
DepositHeader,
|
|
60185
|
+
{
|
|
60186
|
+
title: modalTitle || "Checkout",
|
|
60187
|
+
showClose: true,
|
|
60188
|
+
onClose: handleClose
|
|
60189
|
+
}
|
|
60190
|
+
),
|
|
60191
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
60192
|
+
piLoading ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
60193
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60194
|
+
"div",
|
|
60195
|
+
{
|
|
60196
|
+
className: "uf-rounded-xl uf-p-4 uf-animate-pulse",
|
|
60197
|
+
style: {
|
|
60198
|
+
backgroundColor: components.card.backgroundColor,
|
|
60199
|
+
borderRadius: components.card.borderRadius,
|
|
60200
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
60201
|
+
},
|
|
60202
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-gap-2", children: [
|
|
60203
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60204
|
+
"div",
|
|
60205
|
+
{
|
|
60206
|
+
className: "uf-h-8 uf-w-24 uf-rounded",
|
|
60207
|
+
style: {
|
|
60208
|
+
backgroundColor: components.card.borderColor
|
|
60209
|
+
}
|
|
60210
|
+
}
|
|
60211
|
+
),
|
|
60212
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60213
|
+
"div",
|
|
60214
|
+
{
|
|
60215
|
+
className: "uf-h-4 uf-w-16 uf-rounded",
|
|
60216
|
+
style: {
|
|
60217
|
+
backgroundColor: components.card.borderColor
|
|
60218
|
+
}
|
|
60219
|
+
}
|
|
60220
|
+
)
|
|
60221
|
+
] })
|
|
60222
|
+
}
|
|
60223
|
+
),
|
|
60224
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SkeletonButton2, {}),
|
|
60225
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SkeletonButton2, {})
|
|
60226
|
+
] }) : piError ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
60227
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
60228
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60229
|
+
"h3",
|
|
60230
|
+
{
|
|
60231
|
+
className: "uf-text-lg uf-font-semibold uf-mb-2",
|
|
60232
|
+
style: {
|
|
60233
|
+
color: colors2.foreground,
|
|
60234
|
+
fontFamily: fonts.semibold
|
|
60235
|
+
},
|
|
60236
|
+
children: "Unable to Load Checkout"
|
|
60237
|
+
}
|
|
60238
|
+
),
|
|
60239
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60240
|
+
"p",
|
|
60241
|
+
{
|
|
60242
|
+
className: "uf-text-sm uf-max-w-[280px]",
|
|
60243
|
+
style: {
|
|
60244
|
+
color: colors2.foregroundMuted,
|
|
60245
|
+
fontFamily: fonts.regular
|
|
60246
|
+
},
|
|
60247
|
+
children: piError instanceof Error ? piError.message : "Something went wrong. Please try again."
|
|
60248
|
+
}
|
|
60249
|
+
)
|
|
60250
|
+
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
60251
|
+
progressSection,
|
|
60252
|
+
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
60253
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60254
|
+
TransferCryptoButton,
|
|
60255
|
+
{
|
|
60256
|
+
onClick: () => setView("transfer"),
|
|
60257
|
+
title: "Transfer Crypto",
|
|
60258
|
+
subtitle: "Send from any wallet or exchange",
|
|
60259
|
+
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
60260
|
+
}
|
|
60261
|
+
),
|
|
60262
|
+
enableConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60263
|
+
BrowserWalletButton,
|
|
60264
|
+
{
|
|
60265
|
+
onClick: handleBrowserWalletClick,
|
|
60266
|
+
onConnectClick: handleWalletConnectClick,
|
|
60267
|
+
onDisconnect: handleWalletDisconnect,
|
|
60268
|
+
chainType: browserWalletChainType,
|
|
60269
|
+
publishableKey
|
|
60270
|
+
}
|
|
60271
|
+
)
|
|
60272
|
+
] })
|
|
60273
|
+
] }) : null,
|
|
60274
|
+
poweredByFooter
|
|
60275
|
+
] })
|
|
60276
|
+
] }) : view === "transfer" ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
60277
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60278
|
+
DepositHeader,
|
|
60279
|
+
{
|
|
60280
|
+
title: `Pay $${remainingAmountUsd ?? paymentIntent?.amount_usd ?? ""}`,
|
|
60281
|
+
showBack: true,
|
|
60282
|
+
onBack: handleBack,
|
|
60283
|
+
onClose: handleClose
|
|
60284
|
+
}
|
|
60285
|
+
),
|
|
60286
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
60287
|
+
paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
60288
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
60289
|
+
"div",
|
|
60290
|
+
{
|
|
60291
|
+
className: "uf-rounded-lg uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
|
|
60292
|
+
style: {
|
|
60293
|
+
backgroundColor: components.card.backgroundColor,
|
|
60294
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
|
|
60295
|
+
borderRadius: components.card.borderRadius
|
|
60296
|
+
},
|
|
60297
|
+
children: [
|
|
60298
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60299
|
+
"span",
|
|
60300
|
+
{
|
|
60301
|
+
className: "uf-text-xs",
|
|
60302
|
+
style: {
|
|
60303
|
+
color: colors2.foregroundMuted,
|
|
60304
|
+
fontFamily: fonts.regular
|
|
60305
|
+
},
|
|
60306
|
+
children: parseFloat(paymentIntent.amount_received_usd) > 0 ? `$${paymentIntent.amount_received_usd} / $${paymentIntent.amount_usd} received` : "Amount due"
|
|
60307
|
+
}
|
|
60308
|
+
),
|
|
60309
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
60310
|
+
"span",
|
|
60311
|
+
{
|
|
60312
|
+
className: "uf-text-sm uf-font-semibold",
|
|
60313
|
+
style: {
|
|
60314
|
+
color: colors2.foreground,
|
|
60315
|
+
fontFamily: fonts.semibold
|
|
60316
|
+
},
|
|
60317
|
+
children: [
|
|
60318
|
+
formatCryptoAmount(remainingCrypto ?? paymentIntent.amount),
|
|
60319
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
60320
|
+
"span",
|
|
60321
|
+
{
|
|
60322
|
+
className: "uf-text-xs uf-font-normal uf-ml-1",
|
|
60323
|
+
style: { color: colors2.foregroundMuted },
|
|
60324
|
+
children: [
|
|
60325
|
+
"($",
|
|
60326
|
+
remainingAmountUsd ?? paymentIntent.amount_usd,
|
|
60327
|
+
")"
|
|
60328
|
+
]
|
|
60329
|
+
}
|
|
60330
|
+
)
|
|
60331
|
+
]
|
|
60332
|
+
}
|
|
60333
|
+
)
|
|
60334
|
+
]
|
|
60335
|
+
}
|
|
60336
|
+
),
|
|
60337
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60338
|
+
TransferCryptoSingleInput,
|
|
60339
|
+
{
|
|
60340
|
+
userId: paymentIntent.user_id || "",
|
|
60341
|
+
publishableKey,
|
|
60342
|
+
clientSecret,
|
|
60343
|
+
recipientAddress: paymentIntent.recipient_address,
|
|
60344
|
+
destinationChainType: paymentIntent.destination_chain_type,
|
|
60345
|
+
destinationChainId: paymentIntent.destination_chain_id,
|
|
60346
|
+
destinationTokenAddress: paymentIntent.destination_token_address,
|
|
60347
|
+
depositConfirmationMode: "auto_ui",
|
|
60348
|
+
wallets,
|
|
60349
|
+
onSourceTokenChange: setSelectedSource,
|
|
60350
|
+
checkoutQuote: sourceQuote ? {
|
|
60351
|
+
sourceAmount: sourceQuote.source_amount,
|
|
60352
|
+
sourceTokenDecimals: sourceQuote.source_token_decimals,
|
|
60353
|
+
sourceTokenSymbol: sourceQuote.source_token_symbol,
|
|
60354
|
+
sourceAmountUsd: sourceQuote.source_amount_usd
|
|
60355
|
+
} : null
|
|
60356
|
+
}
|
|
60357
|
+
)
|
|
60358
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(SkeletonButton2, {}),
|
|
60359
|
+
poweredByFooter
|
|
60360
|
+
] })
|
|
60361
|
+
] }) : null })
|
|
60362
|
+
}
|
|
60363
|
+
),
|
|
60364
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60365
|
+
WalletSelectionModal,
|
|
60366
|
+
{
|
|
60367
|
+
open: walletSelectionModalOpen,
|
|
60368
|
+
onOpenChange: setWalletSelectionModalOpen,
|
|
60369
|
+
onWalletConnected: handleWalletConnected,
|
|
60370
|
+
onClose: () => setWalletSelectionModalOpen(false),
|
|
60371
|
+
theme: resolvedTheme
|
|
60372
|
+
}
|
|
60373
|
+
),
|
|
60374
|
+
browserWalletInfo && browserWalletInfo.depositWallet && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
60375
|
+
BrowserWalletModal,
|
|
60376
|
+
{
|
|
60377
|
+
open: browserWalletModalOpen,
|
|
60378
|
+
onOpenChange: setBrowserWalletModalOpen,
|
|
60379
|
+
onFullClose: handleClose,
|
|
60380
|
+
walletInfo: browserWalletInfo,
|
|
60381
|
+
depositWallet: browserWalletInfo.depositWallet,
|
|
60382
|
+
userId: paymentIntent?.user_id || "",
|
|
60383
|
+
publishableKey,
|
|
60384
|
+
clientSecret,
|
|
60385
|
+
theme: resolvedTheme,
|
|
60386
|
+
prefillAmountUsd: remainingAmountUsd,
|
|
60387
|
+
checkoutAmountUsd: paymentIntent?.amount_usd,
|
|
60388
|
+
checkoutReceivedUsd: paymentIntent?.amount_received_usd,
|
|
60389
|
+
onSuccess: (txHash) => {
|
|
60390
|
+
onCheckoutSuccess?.({
|
|
60391
|
+
paymentIntentId: paymentIntent?.id || "",
|
|
60392
|
+
status: "processing"
|
|
60393
|
+
});
|
|
60394
|
+
},
|
|
60395
|
+
onError: (error) => {
|
|
60396
|
+
onCheckoutError?.({
|
|
60397
|
+
message: error.message,
|
|
60398
|
+
error
|
|
60399
|
+
});
|
|
60400
|
+
},
|
|
60401
|
+
onWalletDisconnect: handleWalletDisconnect,
|
|
60402
|
+
onNewDeposit: () => {
|
|
60403
|
+
setBrowserWalletModalOpen(false);
|
|
60404
|
+
setView("main");
|
|
60405
|
+
},
|
|
60406
|
+
onDone: () => {
|
|
60407
|
+
setBrowserWalletModalOpen(false);
|
|
60408
|
+
setView("main");
|
|
60409
|
+
},
|
|
60410
|
+
paymentIntentStatus: paymentIntent?.status
|
|
60411
|
+
}
|
|
60412
|
+
)
|
|
60413
|
+
] }) });
|
|
60414
|
+
}
|
|
59339
60415
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
59340
60416
|
return useQuery({
|
|
59341
60417
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
@@ -59480,20 +60556,20 @@ function useWithdrawPolling({
|
|
|
59480
60556
|
onWithdrawSuccess,
|
|
59481
60557
|
onWithdrawError
|
|
59482
60558
|
}) {
|
|
59483
|
-
const [executions, setExecutions] = (0,
|
|
59484
|
-
const [isPolling, setIsPolling] = (0,
|
|
59485
|
-
const enabledAtRef = (0,
|
|
59486
|
-
const trackedRef = (0,
|
|
59487
|
-
const prevEnabledRef = (0,
|
|
59488
|
-
const onSuccessRef = (0,
|
|
59489
|
-
const onErrorRef = (0,
|
|
59490
|
-
(0,
|
|
60559
|
+
const [executions, setExecutions] = (0, import_react29.useState)([]);
|
|
60560
|
+
const [isPolling, setIsPolling] = (0, import_react29.useState)(false);
|
|
60561
|
+
const enabledAtRef = (0, import_react29.useRef)(/* @__PURE__ */ new Date());
|
|
60562
|
+
const trackedRef = (0, import_react29.useRef)(/* @__PURE__ */ new Map());
|
|
60563
|
+
const prevEnabledRef = (0, import_react29.useRef)(false);
|
|
60564
|
+
const onSuccessRef = (0, import_react29.useRef)(onWithdrawSuccess);
|
|
60565
|
+
const onErrorRef = (0, import_react29.useRef)(onWithdrawError);
|
|
60566
|
+
(0, import_react29.useEffect)(() => {
|
|
59491
60567
|
onSuccessRef.current = onWithdrawSuccess;
|
|
59492
60568
|
}, [onWithdrawSuccess]);
|
|
59493
|
-
(0,
|
|
60569
|
+
(0, import_react29.useEffect)(() => {
|
|
59494
60570
|
onErrorRef.current = onWithdrawError;
|
|
59495
60571
|
}, [onWithdrawError]);
|
|
59496
|
-
(0,
|
|
60572
|
+
(0, import_react29.useEffect)(() => {
|
|
59497
60573
|
if (enabled && !prevEnabledRef.current) {
|
|
59498
60574
|
enabledAtRef.current = /* @__PURE__ */ new Date();
|
|
59499
60575
|
trackedRef.current.clear();
|
|
@@ -59503,7 +60579,7 @@ function useWithdrawPolling({
|
|
|
59503
60579
|
}
|
|
59504
60580
|
prevEnabledRef.current = enabled;
|
|
59505
60581
|
}, [enabled]);
|
|
59506
|
-
(0,
|
|
60582
|
+
(0, import_react29.useEffect)(() => {
|
|
59507
60583
|
if (!userId || !enabled) return;
|
|
59508
60584
|
const enabledAt = enabledAtRef.current;
|
|
59509
60585
|
const poll = async () => {
|
|
@@ -59565,7 +60641,7 @@ function useWithdrawPolling({
|
|
|
59565
60641
|
setIsPolling(false);
|
|
59566
60642
|
};
|
|
59567
60643
|
}, [userId, publishableKey, enabled]);
|
|
59568
|
-
(0,
|
|
60644
|
+
(0, import_react29.useEffect)(() => {
|
|
59569
60645
|
if (!enabled || !depositWalletId) return;
|
|
59570
60646
|
const trigger = async () => {
|
|
59571
60647
|
try {
|
|
@@ -59593,8 +60669,8 @@ function WithdrawDoubleInput({
|
|
|
59593
60669
|
const isDarkMode = useTheme().themeClass.includes("uf-dark");
|
|
59594
60670
|
const selectedToken = selectedTokenSymbol ? tokens.find((t11) => t11.symbol === selectedTokenSymbol) : void 0;
|
|
59595
60671
|
const availableChainsForToken = selectedToken?.chains || [];
|
|
59596
|
-
const renderTokenItem = (tokenData) => /* @__PURE__ */ (0,
|
|
59597
|
-
/* @__PURE__ */ (0,
|
|
60672
|
+
const renderTokenItem = (tokenData) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
60673
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59598
60674
|
"img",
|
|
59599
60675
|
{
|
|
59600
60676
|
src: tokenData.icon_url,
|
|
@@ -59605,10 +60681,10 @@ function WithdrawDoubleInput({
|
|
|
59605
60681
|
className: "uf-rounded-full uf-flex-shrink-0"
|
|
59606
60682
|
}
|
|
59607
60683
|
),
|
|
59608
|
-
/* @__PURE__ */ (0,
|
|
60684
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-normal", children: tokenData.symbol })
|
|
59609
60685
|
] });
|
|
59610
|
-
const renderChainItem = (chainData) => /* @__PURE__ */ (0,
|
|
59611
|
-
/* @__PURE__ */ (0,
|
|
60686
|
+
const renderChainItem = (chainData) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
60687
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59612
60688
|
"img",
|
|
59613
60689
|
{
|
|
59614
60690
|
src: chainData.icon_url,
|
|
@@ -59619,14 +60695,14 @@ function WithdrawDoubleInput({
|
|
|
59619
60695
|
className: "uf-rounded-full uf-flex-shrink-0"
|
|
59620
60696
|
}
|
|
59621
60697
|
),
|
|
59622
|
-
/* @__PURE__ */ (0,
|
|
60698
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chainData.chain_name })
|
|
59623
60699
|
] });
|
|
59624
60700
|
const currentChainData = selectedChainKey ? availableChainsForToken.find(
|
|
59625
60701
|
(c) => getChainKey4(c.chain_id, c.chain_type) === selectedChainKey
|
|
59626
60702
|
) : void 0;
|
|
59627
|
-
return /* @__PURE__ */ (0,
|
|
59628
|
-
/* @__PURE__ */ (0,
|
|
59629
|
-
/* @__PURE__ */ (0,
|
|
60703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-grid uf-grid-cols-2 uf-gap-2.5", children: [
|
|
60704
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { children: [
|
|
60705
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59630
60706
|
"div",
|
|
59631
60707
|
{
|
|
59632
60708
|
className: "uf-text-xs uf-mb-2 uf-flex uf-items-center uf-gap-1",
|
|
@@ -59634,14 +60710,14 @@ function WithdrawDoubleInput({
|
|
|
59634
60710
|
children: t7.receiveToken
|
|
59635
60711
|
}
|
|
59636
60712
|
),
|
|
59637
|
-
/* @__PURE__ */ (0,
|
|
60713
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
59638
60714
|
Select2,
|
|
59639
60715
|
{
|
|
59640
60716
|
value: selectedTokenSymbol ?? "",
|
|
59641
60717
|
onValueChange: onTokenChange,
|
|
59642
60718
|
disabled: isLoading || tokens.length === 0,
|
|
59643
60719
|
children: [
|
|
59644
|
-
/* @__PURE__ */ (0,
|
|
60720
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59645
60721
|
SelectTrigger2,
|
|
59646
60722
|
{
|
|
59647
60723
|
className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50",
|
|
@@ -59649,10 +60725,10 @@ function WithdrawDoubleInput({
|
|
|
59649
60725
|
backgroundColor: components.card.backgroundColor,
|
|
59650
60726
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
59651
60727
|
},
|
|
59652
|
-
children: /* @__PURE__ */ (0,
|
|
60728
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SelectValue2, { children: isLoading || !selectedTokenSymbol ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t7.loading }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-normal", children: selectedTokenSymbol }) })
|
|
59653
60729
|
}
|
|
59654
60730
|
),
|
|
59655
|
-
/* @__PURE__ */ (0,
|
|
60731
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59656
60732
|
SelectContent2,
|
|
59657
60733
|
{
|
|
59658
60734
|
className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px]",
|
|
@@ -59660,7 +60736,7 @@ function WithdrawDoubleInput({
|
|
|
59660
60736
|
border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`,
|
|
59661
60737
|
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
59662
60738
|
},
|
|
59663
|
-
children: tokens.map((tokenData) => /* @__PURE__ */ (0,
|
|
60739
|
+
children: tokens.map((tokenData) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59664
60740
|
SelectItem2,
|
|
59665
60741
|
{
|
|
59666
60742
|
value: tokenData.symbol,
|
|
@@ -59675,8 +60751,8 @@ function WithdrawDoubleInput({
|
|
|
59675
60751
|
}
|
|
59676
60752
|
)
|
|
59677
60753
|
] }),
|
|
59678
|
-
/* @__PURE__ */ (0,
|
|
59679
|
-
/* @__PURE__ */ (0,
|
|
60754
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { children: [
|
|
60755
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59680
60756
|
"div",
|
|
59681
60757
|
{
|
|
59682
60758
|
className: "uf-text-xs uf-mb-2 uf-flex uf-items-center uf-gap-1",
|
|
@@ -59684,14 +60760,14 @@ function WithdrawDoubleInput({
|
|
|
59684
60760
|
children: t7.receiveChain
|
|
59685
60761
|
}
|
|
59686
60762
|
),
|
|
59687
|
-
/* @__PURE__ */ (0,
|
|
60763
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
59688
60764
|
Select2,
|
|
59689
60765
|
{
|
|
59690
60766
|
value: selectedChainKey ?? "",
|
|
59691
60767
|
onValueChange: onChainChange,
|
|
59692
60768
|
disabled: isLoading || availableChainsForToken.length === 0,
|
|
59693
60769
|
children: [
|
|
59694
|
-
/* @__PURE__ */ (0,
|
|
60770
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59695
60771
|
SelectTrigger2,
|
|
59696
60772
|
{
|
|
59697
60773
|
className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50",
|
|
@@ -59699,10 +60775,10 @@ function WithdrawDoubleInput({
|
|
|
59699
60775
|
backgroundColor: components.card.backgroundColor,
|
|
59700
60776
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
59701
60777
|
},
|
|
59702
|
-
children: /* @__PURE__ */ (0,
|
|
60778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SelectValue2, { children: isLoading || !selectedChainKey ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t7.loading }) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "uf-text-xs uf-font-normal", children: selectedChainKey }) })
|
|
59703
60779
|
}
|
|
59704
60780
|
),
|
|
59705
|
-
/* @__PURE__ */ (0,
|
|
60781
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59706
60782
|
SelectContent2,
|
|
59707
60783
|
{
|
|
59708
60784
|
align: "end",
|
|
@@ -59711,9 +60787,9 @@ function WithdrawDoubleInput({
|
|
|
59711
60787
|
border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`,
|
|
59712
60788
|
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
59713
60789
|
},
|
|
59714
|
-
children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0,
|
|
60790
|
+
children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "uf-px-2 uf-py-3 uf-text-xs uf-text-muted-foreground uf-text-center", children: "No chains available" }) : availableChainsForToken.map((chainData) => {
|
|
59715
60791
|
const chainKey = getChainKey4(chainData.chain_id, chainData.chain_type);
|
|
59716
|
-
return /* @__PURE__ */ (0,
|
|
60792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
59717
60793
|
SelectItem2,
|
|
59718
60794
|
{
|
|
59719
60795
|
value: chainKey,
|
|
@@ -59878,6 +60954,52 @@ async function sendSolanaWithdraw(params) {
|
|
|
59878
60954
|
);
|
|
59879
60955
|
return sendResponse.signature;
|
|
59880
60956
|
}
|
|
60957
|
+
var HYPERCORE_CHAIN_ID = "1337";
|
|
60958
|
+
var HYPERCORE_SPOT_USDC_ADDRESS = "0x6d1e7cde53ba9467b783cb7c530ce054";
|
|
60959
|
+
function isHypercoreChain(chainId) {
|
|
60960
|
+
return chainId === HYPERCORE_CHAIN_ID;
|
|
60961
|
+
}
|
|
60962
|
+
async function sendHypercoreWithdraw(params) {
|
|
60963
|
+
const {
|
|
60964
|
+
provider,
|
|
60965
|
+
fromAddress,
|
|
60966
|
+
depositWalletAddress,
|
|
60967
|
+
sourceTokenAddress,
|
|
60968
|
+
amount,
|
|
60969
|
+
tokenSymbol,
|
|
60970
|
+
publishableKey
|
|
60971
|
+
} = params;
|
|
60972
|
+
const isSpot = sourceTokenAddress.toLowerCase() === HYPERCORE_SPOT_USDC_ADDRESS;
|
|
60973
|
+
const currentChainHex = await provider.request({
|
|
60974
|
+
method: "eth_chainId",
|
|
60975
|
+
params: []
|
|
60976
|
+
});
|
|
60977
|
+
const activeChainId = String(parseInt(currentChainHex, 16));
|
|
60978
|
+
const buildResult = await buildHypercoreTransaction(
|
|
60979
|
+
{
|
|
60980
|
+
action_type: isSpot ? "spot_send" : "usd_send",
|
|
60981
|
+
signature_chain_type: "ethereum",
|
|
60982
|
+
signature_chain_id: activeChainId,
|
|
60983
|
+
recipient_address: depositWalletAddress,
|
|
60984
|
+
token_address: sourceTokenAddress,
|
|
60985
|
+
token_symbol: tokenSymbol || void 0,
|
|
60986
|
+
amount
|
|
60987
|
+
},
|
|
60988
|
+
publishableKey
|
|
60989
|
+
);
|
|
60990
|
+
const signature = await provider.request({
|
|
60991
|
+
method: "eth_signTypedData_v4",
|
|
60992
|
+
params: [fromAddress, JSON.stringify(buildResult.typed_data)]
|
|
60993
|
+
});
|
|
60994
|
+
await sendHypercoreTransaction(
|
|
60995
|
+
{
|
|
60996
|
+
action_payload: buildResult.action_payload,
|
|
60997
|
+
signature,
|
|
60998
|
+
nonce: buildResult.nonce
|
|
60999
|
+
},
|
|
61000
|
+
publishableKey
|
|
61001
|
+
);
|
|
61002
|
+
}
|
|
59881
61003
|
async function detectBrowserWallet(chainType, senderAddress) {
|
|
59882
61004
|
const win = typeof window !== "undefined" ? window : null;
|
|
59883
61005
|
if (!win || !senderAddress) return null;
|
|
@@ -60001,22 +61123,22 @@ function WithdrawForm({
|
|
|
60001
61123
|
footerLeft
|
|
60002
61124
|
}) {
|
|
60003
61125
|
const { colors: colors2, fonts, components } = useTheme();
|
|
60004
|
-
const [recipientAddress, setRecipientAddress] = (0,
|
|
60005
|
-
const [amount, setAmount] = (0,
|
|
60006
|
-
const [inputUnit, setInputUnit] = (0,
|
|
60007
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
60008
|
-
const [submitError, setSubmitError] = (0,
|
|
60009
|
-
const [detailsExpanded, setDetailsExpanded] = (0,
|
|
60010
|
-
const [glossaryOpen, setGlossaryOpen] = (0,
|
|
60011
|
-
(0,
|
|
61126
|
+
const [recipientAddress, setRecipientAddress] = (0, import_react30.useState)(recipientAddressProp || "");
|
|
61127
|
+
const [amount, setAmount] = (0, import_react30.useState)("");
|
|
61128
|
+
const [inputUnit, setInputUnit] = (0, import_react30.useState)("crypto");
|
|
61129
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react30.useState)(false);
|
|
61130
|
+
const [submitError, setSubmitError] = (0, import_react30.useState)(null);
|
|
61131
|
+
const [detailsExpanded, setDetailsExpanded] = (0, import_react30.useState)(false);
|
|
61132
|
+
const [glossaryOpen, setGlossaryOpen] = (0, import_react30.useState)(false);
|
|
61133
|
+
(0, import_react30.useEffect)(() => {
|
|
60012
61134
|
setRecipientAddress(recipientAddressProp || "");
|
|
60013
61135
|
setAmount("");
|
|
60014
61136
|
setInputUnit("crypto");
|
|
60015
61137
|
setSubmitError(null);
|
|
60016
61138
|
}, [recipientAddressProp]);
|
|
60017
61139
|
const trimmedAddress = recipientAddress.trim();
|
|
60018
|
-
const [debouncedAddress, setDebouncedAddress] = (0,
|
|
60019
|
-
(0,
|
|
61140
|
+
const [debouncedAddress, setDebouncedAddress] = (0, import_react30.useState)(trimmedAddress);
|
|
61141
|
+
(0, import_react30.useEffect)(() => {
|
|
60020
61142
|
const id = setTimeout(() => setDebouncedAddress(trimmedAddress), 500);
|
|
60021
61143
|
return () => clearTimeout(id);
|
|
60022
61144
|
}, [trimmedAddress]);
|
|
@@ -60033,7 +61155,7 @@ function WithdrawForm({
|
|
|
60033
61155
|
enabled: debouncedAddress.length > 5 && !!selectedChain
|
|
60034
61156
|
});
|
|
60035
61157
|
const isDebouncing = trimmedAddress !== debouncedAddress;
|
|
60036
|
-
const addressError = (0,
|
|
61158
|
+
const addressError = (0, import_react30.useMemo)(() => {
|
|
60037
61159
|
if (!trimmedAddress || trimmedAddress.length <= 5) return null;
|
|
60038
61160
|
if (isDebouncing || isVerifyingAddress) return null;
|
|
60039
61161
|
if (verifyError) return t8.invalidAddress;
|
|
@@ -60047,47 +61169,47 @@ function WithdrawForm({
|
|
|
60047
61169
|
return null;
|
|
60048
61170
|
}, [trimmedAddress, isDebouncing, isVerifyingAddress, verifyError, addressVerification, selectedChain, selectedToken]);
|
|
60049
61171
|
const isAddressValid = !isDebouncing && !!addressVerification?.valid && !addressError;
|
|
60050
|
-
const exchangeRate = (0,
|
|
61172
|
+
const exchangeRate = (0, import_react30.useMemo)(() => {
|
|
60051
61173
|
if (!balanceData?.exchangeRate) return 0;
|
|
60052
61174
|
return parseFloat(balanceData.exchangeRate);
|
|
60053
61175
|
}, [balanceData]);
|
|
60054
|
-
const balanceCrypto = (0,
|
|
61176
|
+
const balanceCrypto = (0, import_react30.useMemo)(() => {
|
|
60055
61177
|
if (!balanceData?.balanceHuman) return 0;
|
|
60056
61178
|
return parseFloat(balanceData.balanceHuman);
|
|
60057
61179
|
}, [balanceData]);
|
|
60058
|
-
const balanceUsdNum = (0,
|
|
61180
|
+
const balanceUsdNum = (0, import_react30.useMemo)(() => {
|
|
60059
61181
|
if (!balanceData?.balanceUsd) return 0;
|
|
60060
61182
|
return parseFloat(balanceData.balanceUsd);
|
|
60061
61183
|
}, [balanceData]);
|
|
60062
61184
|
const tokenSymbol = sourceTokenSymbol || balanceData?.symbol || "TOKEN";
|
|
60063
61185
|
const sourceDecimals = balanceData?.decimals ?? 6;
|
|
60064
|
-
const cryptoAmountFromInput = (0,
|
|
61186
|
+
const cryptoAmountFromInput = (0, import_react30.useMemo)(() => {
|
|
60065
61187
|
const val = parseFloat(amount);
|
|
60066
61188
|
if (!val || val <= 0) return 0;
|
|
60067
61189
|
if (inputUnit === "crypto") return val;
|
|
60068
61190
|
return exchangeRate > 0 ? val / exchangeRate : 0;
|
|
60069
61191
|
}, [amount, inputUnit, exchangeRate]);
|
|
60070
|
-
const fiatAmountFromInput = (0,
|
|
61192
|
+
const fiatAmountFromInput = (0, import_react30.useMemo)(() => {
|
|
60071
61193
|
const val = parseFloat(amount);
|
|
60072
61194
|
if (!val || val <= 0) return 0;
|
|
60073
61195
|
if (inputUnit === "fiat") return val;
|
|
60074
61196
|
return val * exchangeRate;
|
|
60075
61197
|
}, [amount, inputUnit, exchangeRate]);
|
|
60076
|
-
const convertedDisplay = (0,
|
|
61198
|
+
const convertedDisplay = (0, import_react30.useMemo)(() => {
|
|
60077
61199
|
if (!amount || parseFloat(amount) <= 0) return null;
|
|
60078
61200
|
if (inputUnit === "crypto") {
|
|
60079
61201
|
return `$${fiatAmountFromInput.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
60080
61202
|
}
|
|
60081
61203
|
return `${cryptoAmountFromInput.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 6 })} ${tokenSymbol}`;
|
|
60082
61204
|
}, [amount, inputUnit, fiatAmountFromInput, cryptoAmountFromInput, tokenSymbol]);
|
|
60083
|
-
const balanceDisplay = (0,
|
|
61205
|
+
const balanceDisplay = (0, import_react30.useMemo)(() => {
|
|
60084
61206
|
if (isLoadingBalance || !balanceData) return null;
|
|
60085
61207
|
if (inputUnit === "crypto") {
|
|
60086
61208
|
return `${balanceCrypto.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${tokenSymbol}`;
|
|
60087
61209
|
}
|
|
60088
61210
|
return `$${balanceUsdNum.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
60089
61211
|
}, [isLoadingBalance, balanceData, inputUnit, balanceCrypto, balanceUsdNum, tokenSymbol]);
|
|
60090
|
-
const handleSwitchUnit = (0,
|
|
61212
|
+
const handleSwitchUnit = (0, import_react30.useCallback)(() => {
|
|
60091
61213
|
const val = parseFloat(amount);
|
|
60092
61214
|
if (!val || val <= 0 || exchangeRate <= 0) {
|
|
60093
61215
|
setInputUnit((u) => u === "crypto" ? "fiat" : "crypto");
|
|
@@ -60104,7 +61226,7 @@ function WithdrawForm({
|
|
|
60104
61226
|
setInputUnit("crypto");
|
|
60105
61227
|
}
|
|
60106
61228
|
}, [amount, inputUnit, exchangeRate, sourceDecimals]);
|
|
60107
|
-
const handleMaxClick = (0,
|
|
61229
|
+
const handleMaxClick = (0, import_react30.useCallback)(() => {
|
|
60108
61230
|
if (inputUnit === "crypto") {
|
|
60109
61231
|
if (balanceCrypto <= 0) return;
|
|
60110
61232
|
setAmount(balanceData?.balanceHuman ?? "0");
|
|
@@ -60116,7 +61238,7 @@ function WithdrawForm({
|
|
|
60116
61238
|
const isBelowMinimum = minimumWithdrawAmountUsd !== null && fiatAmountFromInput > 0 && fiatAmountFromInput < minimumWithdrawAmountUsd;
|
|
60117
61239
|
const isOverBalance = inputUnit === "crypto" ? cryptoAmountFromInput > 0 && balanceCrypto > 0 && cryptoAmountFromInput > balanceCrypto : fiatAmountFromInput > 0 && balanceUsdNum > 0 && fiatAmountFromInput > balanceUsdNum;
|
|
60118
61240
|
const isFormValid = trimmedAddress.length > 0 && amount.trim().length > 0 && cryptoAmountFromInput > 0 && isAddressValid && !isBelowMinimum && !isOverBalance && !!balanceData;
|
|
60119
|
-
const handleWithdraw = (0,
|
|
61241
|
+
const handleWithdraw = (0, import_react30.useCallback)(async () => {
|
|
60120
61242
|
if (!selectedToken || !selectedChain) return;
|
|
60121
61243
|
if (!isFormValid) return;
|
|
60122
61244
|
setIsSubmitting(true);
|
|
@@ -60149,7 +61271,17 @@ function WithdrawForm({
|
|
|
60149
61271
|
recipientAddress: trimmedAddress
|
|
60150
61272
|
};
|
|
60151
61273
|
if (detectedWallet) {
|
|
60152
|
-
if (detectedWallet.chainFamily === "evm") {
|
|
61274
|
+
if (detectedWallet.chainFamily === "evm" && isHypercoreChain(sourceChainId)) {
|
|
61275
|
+
await sendHypercoreWithdraw({
|
|
61276
|
+
provider: detectedWallet.provider,
|
|
61277
|
+
fromAddress: detectedWallet.address,
|
|
61278
|
+
depositWalletAddress: depositWallet.address,
|
|
61279
|
+
sourceTokenAddress,
|
|
61280
|
+
amount: humanAmount,
|
|
61281
|
+
tokenSymbol,
|
|
61282
|
+
publishableKey
|
|
61283
|
+
});
|
|
61284
|
+
} else if (detectedWallet.chainFamily === "evm") {
|
|
60153
61285
|
await sendEvmWithdraw({
|
|
60154
61286
|
provider: detectedWallet.provider,
|
|
60155
61287
|
fromAddress: detectedWallet.address,
|
|
@@ -60186,9 +61318,9 @@ function WithdrawForm({
|
|
|
60186
61318
|
setIsSubmitting(false);
|
|
60187
61319
|
}
|
|
60188
61320
|
}, [selectedToken, selectedChain, isFormValid, cryptoAmountFromInput, sourceDecimals, trimmedAddress, publishableKey, onWithdraw, detectedWallet, sourceTokenAddress, sourceChainId, onWithdrawError, onDepositWalletCreation, onWithdrawSubmitted, amount, inputUnit, balanceCrypto, balanceUsdNum, balanceData]);
|
|
60189
|
-
return /* @__PURE__ */ (0,
|
|
60190
|
-
/* @__PURE__ */ (0,
|
|
60191
|
-
/* @__PURE__ */ (0,
|
|
61321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
61322
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { children: [
|
|
61323
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60192
61324
|
"div",
|
|
60193
61325
|
{
|
|
60194
61326
|
className: "uf-text-xs uf-mb-1.5",
|
|
@@ -60196,7 +61328,7 @@ function WithdrawForm({
|
|
|
60196
61328
|
children: t8.recipientAddress
|
|
60197
61329
|
}
|
|
60198
61330
|
),
|
|
60199
|
-
/* @__PURE__ */ (0,
|
|
61331
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60200
61332
|
"style",
|
|
60201
61333
|
{
|
|
60202
61334
|
dangerouslySetInnerHTML: {
|
|
@@ -60204,7 +61336,7 @@ function WithdrawForm({
|
|
|
60204
61336
|
}
|
|
60205
61337
|
}
|
|
60206
61338
|
),
|
|
60207
|
-
/* @__PURE__ */ (0,
|
|
61339
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
60208
61340
|
"div",
|
|
60209
61341
|
{
|
|
60210
61342
|
className: "uf-flex uf-items-center uf-gap-1 uf-pr-2",
|
|
@@ -60214,7 +61346,7 @@ function WithdrawForm({
|
|
|
60214
61346
|
border: `${components.input.borderWidth}px solid ${addressError ? colors2.error : components.input.borderColor}`
|
|
60215
61347
|
},
|
|
60216
61348
|
children: [
|
|
60217
|
-
/* @__PURE__ */ (0,
|
|
61349
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60218
61350
|
"input",
|
|
60219
61351
|
{
|
|
60220
61352
|
type: "text",
|
|
@@ -60231,7 +61363,7 @@ function WithdrawForm({
|
|
|
60231
61363
|
}
|
|
60232
61364
|
}
|
|
60233
61365
|
),
|
|
60234
|
-
/* @__PURE__ */ (0,
|
|
61366
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60235
61367
|
"button",
|
|
60236
61368
|
{
|
|
60237
61369
|
type: "button",
|
|
@@ -60248,27 +61380,27 @@ function WithdrawForm({
|
|
|
60248
61380
|
className: "uf-flex-shrink-0 uf-p-1 uf-rounded uf-transition-colors hover:uf-opacity-70",
|
|
60249
61381
|
style: { color: colors2.foregroundMuted },
|
|
60250
61382
|
title: "Paste from clipboard",
|
|
60251
|
-
children: /* @__PURE__ */ (0,
|
|
61383
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ClipboardPaste, { className: "uf-w-4 uf-h-4" })
|
|
60252
61384
|
}
|
|
60253
61385
|
)
|
|
60254
61386
|
]
|
|
60255
61387
|
}
|
|
60256
61388
|
),
|
|
60257
|
-
(isDebouncing || isVerifyingAddress) && trimmedAddress.length > 5 && /* @__PURE__ */ (0,
|
|
60258
|
-
/* @__PURE__ */ (0,
|
|
60259
|
-
/* @__PURE__ */ (0,
|
|
61389
|
+
(isDebouncing || isVerifyingAddress) && trimmedAddress.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-1.5", children: [
|
|
61390
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-3 uf-h-3 uf-animate-spin", style: { color: colors2.foregroundMuted } }),
|
|
61391
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: t8.verifyingAddress })
|
|
60260
61392
|
] }),
|
|
60261
|
-
addressError && /* @__PURE__ */ (0,
|
|
60262
|
-
/* @__PURE__ */ (0,
|
|
60263
|
-
/* @__PURE__ */ (0,
|
|
61393
|
+
addressError && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-1.5", children: [
|
|
61394
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(TriangleAlert, { className: "uf-w-3 uf-h-3", style: { color: colors2.error } }),
|
|
61395
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "uf-text-xs", style: { color: colors2.error, fontFamily: fonts.regular }, children: addressError })
|
|
60264
61396
|
] })
|
|
60265
61397
|
] }),
|
|
60266
|
-
/* @__PURE__ */ (0,
|
|
60267
|
-
/* @__PURE__ */ (0,
|
|
61398
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { children: [
|
|
61399
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-text-xs uf-mb-1.5", style: { color: components.card.labelColor, fontFamily: fonts.medium }, children: [
|
|
60268
61400
|
t8.amount,
|
|
60269
|
-
minimumWithdrawAmountUsd != null && minimumWithdrawAmountUsd > 0 && /* @__PURE__ */ (0,
|
|
61401
|
+
minimumWithdrawAmountUsd != null && minimumWithdrawAmountUsd > 0 && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { style: { color: colors2.warning, fontFamily: fonts.regular }, children: ` ($${minimumWithdrawAmountUsd.toFixed(2)} min)` })
|
|
60270
61402
|
] }),
|
|
60271
|
-
/* @__PURE__ */ (0,
|
|
61403
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60272
61404
|
"style",
|
|
60273
61405
|
{
|
|
60274
61406
|
dangerouslySetInnerHTML: {
|
|
@@ -60276,7 +61408,7 @@ function WithdrawForm({
|
|
|
60276
61408
|
}
|
|
60277
61409
|
}
|
|
60278
61410
|
),
|
|
60279
|
-
/* @__PURE__ */ (0,
|
|
61411
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
60280
61412
|
"div",
|
|
60281
61413
|
{
|
|
60282
61414
|
className: "uf-flex uf-items-center uf-gap-2 uf-px-3 uf-py-2.5",
|
|
@@ -60286,7 +61418,7 @@ function WithdrawForm({
|
|
|
60286
61418
|
border: `${components.input.borderWidth}px solid ${components.input.borderColor}`
|
|
60287
61419
|
},
|
|
60288
61420
|
children: [
|
|
60289
|
-
/* @__PURE__ */ (0,
|
|
61421
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60290
61422
|
"input",
|
|
60291
61423
|
{
|
|
60292
61424
|
type: "text",
|
|
@@ -60307,8 +61439,8 @@ function WithdrawForm({
|
|
|
60307
61439
|
}
|
|
60308
61440
|
}
|
|
60309
61441
|
),
|
|
60310
|
-
/* @__PURE__ */ (0,
|
|
60311
|
-
/* @__PURE__ */ (0,
|
|
61442
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "uf-text-sm uf-shrink-0", style: { color: colors2.foregroundMuted, fontFamily: fonts.medium }, children: inputUnit === "crypto" ? tokenSymbol : "USD" }),
|
|
61443
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60312
61444
|
"button",
|
|
60313
61445
|
{
|
|
60314
61446
|
type: "button",
|
|
@@ -60321,10 +61453,10 @@ function WithdrawForm({
|
|
|
60321
61453
|
]
|
|
60322
61454
|
}
|
|
60323
61455
|
),
|
|
60324
|
-
/* @__PURE__ */ (0,
|
|
60325
|
-
/* @__PURE__ */ (0,
|
|
60326
|
-
/* @__PURE__ */ (0,
|
|
60327
|
-
exchangeRate > 0 && /* @__PURE__ */ (0,
|
|
61456
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-mt-1.5 uf-px-3", children: [
|
|
61457
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1", children: [
|
|
61458
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: convertedDisplay || (inputUnit === "crypto" ? "$0.00" : `0.00 ${tokenSymbol}`) }),
|
|
61459
|
+
exchangeRate > 0 && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60328
61460
|
"button",
|
|
60329
61461
|
{
|
|
60330
61462
|
type: "button",
|
|
@@ -60332,49 +61464,49 @@ function WithdrawForm({
|
|
|
60332
61464
|
className: "uf-p-0.5 uf-rounded uf-transition-colors hover:uf-opacity-70",
|
|
60333
61465
|
style: { color: colors2.foregroundMuted },
|
|
60334
61466
|
title: "Switch unit",
|
|
60335
|
-
children: /* @__PURE__ */ (0,
|
|
61467
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ArrowUpDown, { className: "uf-w-3 uf-h-3" })
|
|
60336
61468
|
}
|
|
60337
61469
|
)
|
|
60338
61470
|
] }),
|
|
60339
|
-
/* @__PURE__ */ (0,
|
|
60340
|
-
balanceDisplay && /* @__PURE__ */ (0,
|
|
61471
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { children: [
|
|
61472
|
+
balanceDisplay && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: [
|
|
60341
61473
|
t8.balance,
|
|
60342
61474
|
": ",
|
|
60343
61475
|
balanceDisplay
|
|
60344
61476
|
] }),
|
|
60345
|
-
isLoadingBalance && /* @__PURE__ */ (0,
|
|
61477
|
+
isLoadingBalance && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-h-3 uf-w-16 uf-bg-muted uf-rounded uf-animate-pulse" })
|
|
60346
61478
|
] })
|
|
60347
61479
|
] })
|
|
60348
61480
|
] }),
|
|
60349
|
-
/* @__PURE__ */ (0,
|
|
60350
|
-
/* @__PURE__ */ (0,
|
|
61481
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-px-2.5", style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: [
|
|
61482
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
60351
61483
|
"button",
|
|
60352
61484
|
{
|
|
60353
61485
|
type: "button",
|
|
60354
61486
|
onClick: () => setDetailsExpanded(!detailsExpanded),
|
|
60355
61487
|
className: "uf-w-full uf-flex uf-items-center uf-justify-between uf-py-2.5",
|
|
60356
61488
|
children: [
|
|
60357
|
-
/* @__PURE__ */ (0,
|
|
60358
|
-
/* @__PURE__ */ (0,
|
|
60359
|
-
/* @__PURE__ */ (0,
|
|
61489
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
61490
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Clock, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
61491
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
60360
61492
|
tCrypto.processingTime.label,
|
|
60361
61493
|
":",
|
|
60362
61494
|
" ",
|
|
60363
|
-
/* @__PURE__ */ (0,
|
|
61495
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: formatProcessingTime2(estimatedProcessingTime) })
|
|
60364
61496
|
] })
|
|
60365
61497
|
] }),
|
|
60366
|
-
detailsExpanded ? /* @__PURE__ */ (0,
|
|
61498
|
+
detailsExpanded ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ChevronUp, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } }) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ChevronDown, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } })
|
|
60367
61499
|
]
|
|
60368
61500
|
}
|
|
60369
61501
|
),
|
|
60370
|
-
detailsExpanded && /* @__PURE__ */ (0,
|
|
60371
|
-
/* @__PURE__ */ (0,
|
|
60372
|
-
/* @__PURE__ */ (0,
|
|
60373
|
-
/* @__PURE__ */ (0,
|
|
61502
|
+
detailsExpanded && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-3 uf-space-y-2.5", children: [
|
|
61503
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
61504
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ShieldCheck, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
61505
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
60374
61506
|
tCrypto.slippage.label,
|
|
60375
61507
|
":",
|
|
60376
61508
|
" ",
|
|
60377
|
-
/* @__PURE__ */ (0,
|
|
61509
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: [
|
|
60378
61510
|
tCrypto.slippage.auto,
|
|
60379
61511
|
" \u2022 ",
|
|
60380
61512
|
(maxSlippagePercent ?? 0.25).toFixed(2),
|
|
@@ -60382,13 +61514,13 @@ function WithdrawForm({
|
|
|
60382
61514
|
] })
|
|
60383
61515
|
] })
|
|
60384
61516
|
] }),
|
|
60385
|
-
/* @__PURE__ */ (0,
|
|
60386
|
-
/* @__PURE__ */ (0,
|
|
60387
|
-
/* @__PURE__ */ (0,
|
|
61517
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
61518
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DollarSign, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
61519
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
60388
61520
|
tCrypto.priceImpact.label,
|
|
60389
61521
|
":",
|
|
60390
61522
|
" ",
|
|
60391
|
-
/* @__PURE__ */ (0,
|
|
61523
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: [
|
|
60392
61524
|
(priceImpactPercent ?? 0).toFixed(2),
|
|
60393
61525
|
"%"
|
|
60394
61526
|
] })
|
|
@@ -60396,18 +61528,18 @@ function WithdrawForm({
|
|
|
60396
61528
|
] })
|
|
60397
61529
|
] })
|
|
60398
61530
|
] }),
|
|
60399
|
-
!canWithdraw && !submitError && /* @__PURE__ */ (0,
|
|
61531
|
+
!canWithdraw && !submitError && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
60400
61532
|
"div",
|
|
60401
61533
|
{
|
|
60402
61534
|
className: "uf-flex uf-items-start uf-gap-2.5 uf-p-3 uf-rounded-xl",
|
|
60403
61535
|
style: { backgroundColor: colors2.card, border: `1px solid ${colors2.border}` },
|
|
60404
61536
|
children: [
|
|
60405
|
-
/* @__PURE__ */ (0,
|
|
60406
|
-
/* @__PURE__ */ (0,
|
|
61537
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Wallet, { className: "uf-w-4 uf-h-4 uf-flex-shrink-0 uf-mt-0.5", style: { color: colors2.warning } }),
|
|
61538
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "No connected wallet detected. Please connect a wallet that matches your account to withdraw." })
|
|
60407
61539
|
]
|
|
60408
61540
|
}
|
|
60409
61541
|
),
|
|
60410
|
-
isWalletMatch && connectedWalletName ? /* @__PURE__ */ (0,
|
|
61542
|
+
isWalletMatch && connectedWalletName ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60411
61543
|
"button",
|
|
60412
61544
|
{
|
|
60413
61545
|
type: "button",
|
|
@@ -60421,16 +61553,16 @@ function WithdrawForm({
|
|
|
60421
61553
|
borderRadius: components.button.borderRadius,
|
|
60422
61554
|
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
60423
61555
|
},
|
|
60424
|
-
children: isSubmitting ? /* @__PURE__ */ (0,
|
|
60425
|
-
/* @__PURE__ */ (0,
|
|
61556
|
+
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
61557
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }),
|
|
60426
61558
|
"Processing..."
|
|
60427
|
-
] }) : isOverBalance ? /* @__PURE__ */ (0,
|
|
60428
|
-
/* @__PURE__ */ (0,
|
|
61559
|
+
] }) : isOverBalance ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_jsx_runtime73.Fragment, { children: "Insufficient balance" }) : isBelowMinimum ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_jsx_runtime73.Fragment, { children: "Minimum amount not met" }) : submitError ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_jsx_runtime73.Fragment, { children: "Withdrawal failed. Try again" }) : /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
61560
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Wallet, { className: "uf-w-4 uf-h-4" }),
|
|
60429
61561
|
"Withdraw from ",
|
|
60430
61562
|
connectedWalletName
|
|
60431
61563
|
] })
|
|
60432
61564
|
}
|
|
60433
|
-
) : /* @__PURE__ */ (0,
|
|
61565
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60434
61566
|
"button",
|
|
60435
61567
|
{
|
|
60436
61568
|
type: "button",
|
|
@@ -60444,17 +61576,17 @@ function WithdrawForm({
|
|
|
60444
61576
|
borderRadius: components.button.borderRadius,
|
|
60445
61577
|
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
60446
61578
|
},
|
|
60447
|
-
children: isSubmitting ? /* @__PURE__ */ (0,
|
|
60448
|
-
/* @__PURE__ */ (0,
|
|
61579
|
+
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("span", { className: "uf-flex uf-items-center uf-justify-center uf-gap-2", children: [
|
|
61580
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }),
|
|
60449
61581
|
"Processing..."
|
|
60450
61582
|
] }) : isOverBalance ? "Insufficient balance" : isBelowMinimum ? "Minimum amount not met" : submitError ? "Withdrawal failed. Try again" : t8.withdraw
|
|
60451
61583
|
}
|
|
60452
61584
|
),
|
|
60453
|
-
/* @__PURE__ */ (0,
|
|
60454
|
-
/* @__PURE__ */ (0,
|
|
60455
|
-
/* @__PURE__ */ (0,
|
|
61585
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-text-xs uf-pt-1", children: [
|
|
61586
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { children: footerLeft }),
|
|
61587
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositFooterLinks, { onGlossaryClick: () => setGlossaryOpen(true) })
|
|
60456
61588
|
] }),
|
|
60457
|
-
/* @__PURE__ */ (0,
|
|
61589
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
60458
61590
|
GlossaryModal,
|
|
60459
61591
|
{
|
|
60460
61592
|
open: glossaryOpen,
|
|
@@ -60500,7 +61632,7 @@ function WithdrawExecutionItem({
|
|
|
60500
61632
|
return "$0.00";
|
|
60501
61633
|
}
|
|
60502
61634
|
};
|
|
60503
|
-
return /* @__PURE__ */ (0,
|
|
61635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
|
|
60504
61636
|
"button",
|
|
60505
61637
|
{
|
|
60506
61638
|
onClick,
|
|
@@ -60511,8 +61643,8 @@ function WithdrawExecutionItem({
|
|
|
60511
61643
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
60512
61644
|
},
|
|
60513
61645
|
children: [
|
|
60514
|
-
/* @__PURE__ */ (0,
|
|
60515
|
-
/* @__PURE__ */ (0,
|
|
61646
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-relative uf-flex-shrink-0 uf-w-9 uf-h-9", children: [
|
|
61647
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60516
61648
|
"img",
|
|
60517
61649
|
{
|
|
60518
61650
|
src: execution.destination_token_metadata?.icon_url || getIconUrl("/icons/tokens/svg/usdc.svg"),
|
|
@@ -60523,12 +61655,12 @@ function WithdrawExecutionItem({
|
|
|
60523
61655
|
className: "uf-rounded-full uf-w-9 uf-h-9"
|
|
60524
61656
|
}
|
|
60525
61657
|
),
|
|
60526
|
-
isPending ? /* @__PURE__ */ (0,
|
|
61658
|
+
isPending ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60527
61659
|
"div",
|
|
60528
61660
|
{
|
|
60529
61661
|
className: "uf-absolute -uf-bottom-0.5 -uf-right-0.5 uf-rounded-full uf-p-0.5",
|
|
60530
61662
|
style: { backgroundColor: colors2.warning },
|
|
60531
|
-
children: /* @__PURE__ */ (0,
|
|
61663
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60532
61664
|
"svg",
|
|
60533
61665
|
{
|
|
60534
61666
|
width: "10",
|
|
@@ -60536,7 +61668,7 @@ function WithdrawExecutionItem({
|
|
|
60536
61668
|
viewBox: "0 0 12 12",
|
|
60537
61669
|
fill: "none",
|
|
60538
61670
|
className: "uf-animate-spin uf-block",
|
|
60539
|
-
children: /* @__PURE__ */ (0,
|
|
61671
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60540
61672
|
"path",
|
|
60541
61673
|
{
|
|
60542
61674
|
d: "M6 1V3M6 9V11M1 6H3M9 6H11M2.5 2.5L4 4M8 8L9.5 9.5M2.5 9.5L4 8M8 4L9.5 2.5",
|
|
@@ -60548,12 +61680,12 @@ function WithdrawExecutionItem({
|
|
|
60548
61680
|
}
|
|
60549
61681
|
)
|
|
60550
61682
|
}
|
|
60551
|
-
) : /* @__PURE__ */ (0,
|
|
61683
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60552
61684
|
"div",
|
|
60553
61685
|
{
|
|
60554
61686
|
className: "uf-absolute -uf-bottom-0.5 -uf-right-0.5 uf-rounded-full uf-p-0.5",
|
|
60555
61687
|
style: { backgroundColor: colors2.success },
|
|
60556
|
-
children: /* @__PURE__ */ (0,
|
|
61688
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60557
61689
|
"svg",
|
|
60558
61690
|
{
|
|
60559
61691
|
width: "10",
|
|
@@ -60561,7 +61693,7 @@ function WithdrawExecutionItem({
|
|
|
60561
61693
|
viewBox: "0 0 12 12",
|
|
60562
61694
|
fill: "none",
|
|
60563
61695
|
className: "uf-block",
|
|
60564
|
-
children: /* @__PURE__ */ (0,
|
|
61696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60565
61697
|
"path",
|
|
60566
61698
|
{
|
|
60567
61699
|
d: "M10 3L4.5 8.5L2 6",
|
|
@@ -60576,8 +61708,8 @@ function WithdrawExecutionItem({
|
|
|
60576
61708
|
}
|
|
60577
61709
|
)
|
|
60578
61710
|
] }),
|
|
60579
|
-
/* @__PURE__ */ (0,
|
|
60580
|
-
/* @__PURE__ */ (0,
|
|
61711
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex-1 uf-min-w-0", children: [
|
|
61712
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60581
61713
|
"h3",
|
|
60582
61714
|
{
|
|
60583
61715
|
className: "uf-font-medium uf-text-sm uf-leading-tight",
|
|
@@ -60588,7 +61720,7 @@ function WithdrawExecutionItem({
|
|
|
60588
61720
|
children: isPending ? "Withdrawal processing" : "Withdrawal completed"
|
|
60589
61721
|
}
|
|
60590
61722
|
),
|
|
60591
|
-
/* @__PURE__ */ (0,
|
|
61723
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60592
61724
|
"p",
|
|
60593
61725
|
{
|
|
60594
61726
|
className: "uf-text-xs uf-leading-tight",
|
|
@@ -60600,7 +61732,7 @@ function WithdrawExecutionItem({
|
|
|
60600
61732
|
}
|
|
60601
61733
|
)
|
|
60602
61734
|
] }),
|
|
60603
|
-
/* @__PURE__ */ (0,
|
|
61735
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60604
61736
|
"span",
|
|
60605
61737
|
{
|
|
60606
61738
|
className: "uf-font-medium uf-text-sm uf-flex-shrink-0",
|
|
@@ -60611,7 +61743,7 @@ function WithdrawExecutionItem({
|
|
|
60611
61743
|
children: formatUsdAmount2(execution.source_amount_usd || "0")
|
|
60612
61744
|
}
|
|
60613
61745
|
),
|
|
60614
|
-
/* @__PURE__ */ (0,
|
|
61746
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
60615
61747
|
ChevronRight,
|
|
60616
61748
|
{
|
|
60617
61749
|
className: "uf-w-4 uf-h-4 uf-flex-shrink-0",
|
|
@@ -60634,9 +61766,9 @@ function WithdrawConfirmingView({
|
|
|
60634
61766
|
onViewTracker
|
|
60635
61767
|
}) {
|
|
60636
61768
|
const { colors: colors2, fonts, components } = useTheme();
|
|
60637
|
-
const [showButton, setShowButton] = (0,
|
|
61769
|
+
const [showButton, setShowButton] = (0, import_react31.useState)(false);
|
|
60638
61770
|
const latestExecution = executions.length > 0 ? executions[executions.length - 1] : null;
|
|
60639
|
-
(0,
|
|
61771
|
+
(0, import_react31.useEffect)(() => {
|
|
60640
61772
|
if (latestExecution) return;
|
|
60641
61773
|
const timer = setTimeout(() => setShowButton(true), SHOW_BUTTON_DELAY_MS);
|
|
60642
61774
|
return () => clearTimeout(timer);
|
|
@@ -60644,11 +61776,11 @@ function WithdrawConfirmingView({
|
|
|
60644
61776
|
const btnRadius = components.button.borderRadius;
|
|
60645
61777
|
const btnBorder = `${components.button.borderWidth}px solid ${components.button.borderColor}`;
|
|
60646
61778
|
if (latestExecution) {
|
|
60647
|
-
return /* @__PURE__ */ (0,
|
|
60648
|
-
/* @__PURE__ */ (0,
|
|
60649
|
-
/* @__PURE__ */ (0,
|
|
60650
|
-
/* @__PURE__ */ (0,
|
|
60651
|
-
/* @__PURE__ */ (0,
|
|
61779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
|
|
61780
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DepositHeader, { title: "Withdrawal Details", showClose: true, onClose }),
|
|
61781
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DepositDetailContent, { execution: latestExecution, variant: "withdraw" }),
|
|
61782
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-flex uf-gap-2 uf-px-2 uf-pt-2", children: [
|
|
61783
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60652
61784
|
"button",
|
|
60653
61785
|
{
|
|
60654
61786
|
type: "button",
|
|
@@ -60664,7 +61796,7 @@ function WithdrawConfirmingView({
|
|
|
60664
61796
|
children: "Withdrawal History"
|
|
60665
61797
|
}
|
|
60666
61798
|
),
|
|
60667
|
-
/* @__PURE__ */ (0,
|
|
61799
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60668
61800
|
"button",
|
|
60669
61801
|
{
|
|
60670
61802
|
type: "button",
|
|
@@ -60681,7 +61813,7 @@ function WithdrawConfirmingView({
|
|
|
60681
61813
|
}
|
|
60682
61814
|
)
|
|
60683
61815
|
] }),
|
|
60684
|
-
/* @__PURE__ */ (0,
|
|
61816
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60685
61817
|
PoweredByUnifold,
|
|
60686
61818
|
{
|
|
60687
61819
|
color: colors2.foregroundMuted,
|
|
@@ -60690,15 +61822,15 @@ function WithdrawConfirmingView({
|
|
|
60690
61822
|
) })
|
|
60691
61823
|
] });
|
|
60692
61824
|
}
|
|
60693
|
-
return /* @__PURE__ */ (0,
|
|
60694
|
-
/* @__PURE__ */ (0,
|
|
60695
|
-
/* @__PURE__ */ (0,
|
|
60696
|
-
/* @__PURE__ */ (0,
|
|
61825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
|
|
61826
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DepositHeader, { title: "Withdrawal Status", showClose: true, onClose }),
|
|
61827
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16 uf-px-4", children: [
|
|
61828
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60697
61829
|
"div",
|
|
60698
61830
|
{
|
|
60699
61831
|
className: "uf-w-20 uf-h-20 uf-rounded-full uf-flex uf-items-center uf-justify-center uf-mb-6",
|
|
60700
61832
|
style: { backgroundColor: `${colors2.primary}20` },
|
|
60701
|
-
children: /* @__PURE__ */ (0,
|
|
61833
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60702
61834
|
"svg",
|
|
60703
61835
|
{
|
|
60704
61836
|
width: "40",
|
|
@@ -60706,7 +61838,7 @@ function WithdrawConfirmingView({
|
|
|
60706
61838
|
viewBox: "0 0 24 24",
|
|
60707
61839
|
fill: "none",
|
|
60708
61840
|
className: "uf-animate-spin",
|
|
60709
|
-
children: /* @__PURE__ */ (0,
|
|
61841
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60710
61842
|
"path",
|
|
60711
61843
|
{
|
|
60712
61844
|
d: "M21 12a9 9 0 1 1-6.22-8.56",
|
|
@@ -60719,7 +61851,7 @@ function WithdrawConfirmingView({
|
|
|
60719
61851
|
)
|
|
60720
61852
|
}
|
|
60721
61853
|
),
|
|
60722
|
-
/* @__PURE__ */ (0,
|
|
61854
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60723
61855
|
"h3",
|
|
60724
61856
|
{
|
|
60725
61857
|
className: "uf-text-xl uf-mb-2",
|
|
@@ -60727,7 +61859,7 @@ function WithdrawConfirmingView({
|
|
|
60727
61859
|
children: "Checking Withdrawal"
|
|
60728
61860
|
}
|
|
60729
61861
|
),
|
|
60730
|
-
/* @__PURE__ */ (0,
|
|
61862
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
60731
61863
|
"p",
|
|
60732
61864
|
{
|
|
60733
61865
|
className: "uf-text-sm uf-text-center",
|
|
@@ -60743,7 +61875,7 @@ function WithdrawConfirmingView({
|
|
|
60743
61875
|
}
|
|
60744
61876
|
)
|
|
60745
61877
|
] }),
|
|
60746
|
-
showButton && /* @__PURE__ */ (0,
|
|
61878
|
+
showButton && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "uf-px-1 uf-pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60747
61879
|
"button",
|
|
60748
61880
|
{
|
|
60749
61881
|
type: "button",
|
|
@@ -60759,7 +61891,7 @@ function WithdrawConfirmingView({
|
|
|
60759
61891
|
children: "Withdrawal History"
|
|
60760
61892
|
}
|
|
60761
61893
|
) }),
|
|
60762
|
-
/* @__PURE__ */ (0,
|
|
61894
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
60763
61895
|
PoweredByUnifold,
|
|
60764
61896
|
{
|
|
60765
61897
|
color: colors2.foregroundMuted,
|
|
@@ -60789,14 +61921,14 @@ function WithdrawModal({
|
|
|
60789
61921
|
hideOverlay = false
|
|
60790
61922
|
}) {
|
|
60791
61923
|
const { colors: colors2, fonts, components } = useTheme();
|
|
60792
|
-
const [containerEl, setContainerEl] = (0,
|
|
60793
|
-
const containerCallbackRef = (0,
|
|
61924
|
+
const [containerEl, setContainerEl] = (0, import_react28.useState)(null);
|
|
61925
|
+
const containerCallbackRef = (0, import_react28.useCallback)((el) => {
|
|
60794
61926
|
setContainerEl(el);
|
|
60795
61927
|
}, []);
|
|
60796
|
-
const [resolvedTheme, setResolvedTheme] = (0,
|
|
61928
|
+
const [resolvedTheme, setResolvedTheme] = (0, import_react28.useState)(
|
|
60797
61929
|
theme === "auto" ? "dark" : theme
|
|
60798
61930
|
);
|
|
60799
|
-
(0,
|
|
61931
|
+
(0, import_react28.useEffect)(() => {
|
|
60800
61932
|
if (theme === "auto") {
|
|
60801
61933
|
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
60802
61934
|
setResolvedTheme(mq.matches ? "dark" : "light");
|
|
@@ -60825,12 +61957,12 @@ function WithdrawModal({
|
|
|
60825
61957
|
publishableKey,
|
|
60826
61958
|
enabled: open
|
|
60827
61959
|
});
|
|
60828
|
-
const [selectedToken, setSelectedToken] = (0,
|
|
60829
|
-
const [selectedChain, setSelectedChain] = (0,
|
|
60830
|
-
const [detectedWallet, setDetectedWallet] = (0,
|
|
61960
|
+
const [selectedToken, setSelectedToken] = (0, import_react28.useState)(null);
|
|
61961
|
+
const [selectedChain, setSelectedChain] = (0, import_react28.useState)(null);
|
|
61962
|
+
const [detectedWallet, setDetectedWallet] = (0, import_react28.useState)(null);
|
|
60831
61963
|
const connectedWalletName = detectedWallet?.name ?? null;
|
|
60832
61964
|
const isWalletMatch = !!detectedWallet;
|
|
60833
|
-
(0,
|
|
61965
|
+
(0, import_react28.useEffect)(() => {
|
|
60834
61966
|
if (!senderAddress || !open) {
|
|
60835
61967
|
setDetectedWallet(null);
|
|
60836
61968
|
return;
|
|
@@ -60843,10 +61975,10 @@ function WithdrawModal({
|
|
|
60843
61975
|
cancelled = true;
|
|
60844
61976
|
};
|
|
60845
61977
|
}, [senderAddress, sourceChainType, open]);
|
|
60846
|
-
const [view, setView] = (0,
|
|
60847
|
-
const [withdrawDepositWalletId, setWithdrawDepositWalletId] = (0,
|
|
60848
|
-
const [selectedExecution, setSelectedExecution] = (0,
|
|
60849
|
-
const [submittedTxInfo, setSubmittedTxInfo] = (0,
|
|
61978
|
+
const [view, setView] = (0, import_react28.useState)("form");
|
|
61979
|
+
const [withdrawDepositWalletId, setWithdrawDepositWalletId] = (0, import_react28.useState)();
|
|
61980
|
+
const [selectedExecution, setSelectedExecution] = (0, import_react28.useState)(null);
|
|
61981
|
+
const [submittedTxInfo, setSubmittedTxInfo] = (0, import_react28.useState)(null);
|
|
60850
61982
|
const { executions: realtimeExecutions } = useWithdrawPolling({
|
|
60851
61983
|
userId: externalUserId,
|
|
60852
61984
|
publishableKey,
|
|
@@ -60861,7 +61993,7 @@ function WithdrawModal({
|
|
|
60861
61993
|
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
60862
61994
|
});
|
|
60863
61995
|
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
60864
|
-
const handleDepositWalletCreation = (0,
|
|
61996
|
+
const handleDepositWalletCreation = (0, import_react28.useCallback)(async (params) => {
|
|
60865
61997
|
const { data: wallets } = await createDepositAddress(
|
|
60866
61998
|
{
|
|
60867
61999
|
external_user_id: externalUserId,
|
|
@@ -60880,11 +62012,11 @@ function WithdrawModal({
|
|
|
60880
62012
|
setWithdrawDepositWalletId(depositWallet.id);
|
|
60881
62013
|
return depositWallet;
|
|
60882
62014
|
}, [externalUserId, publishableKey, sourceChainType]);
|
|
60883
|
-
const handleWithdrawSubmitted = (0,
|
|
62015
|
+
const handleWithdrawSubmitted = (0, import_react28.useCallback)((txInfo) => {
|
|
60884
62016
|
setSubmittedTxInfo(txInfo);
|
|
60885
62017
|
setView("confirming");
|
|
60886
62018
|
}, []);
|
|
60887
|
-
(0,
|
|
62019
|
+
(0, import_react28.useEffect)(() => {
|
|
60888
62020
|
if (!destinationTokens.length || selectedToken) return;
|
|
60889
62021
|
const first = destinationTokens[0];
|
|
60890
62022
|
if (first?.chains.length > 0) {
|
|
@@ -60892,8 +62024,8 @@ function WithdrawModal({
|
|
|
60892
62024
|
setSelectedChain(first.chains[0]);
|
|
60893
62025
|
}
|
|
60894
62026
|
}, [destinationTokens, selectedToken]);
|
|
60895
|
-
const resetViewTimeoutRef = (0,
|
|
60896
|
-
const handleClose = (0,
|
|
62027
|
+
const resetViewTimeoutRef = (0, import_react28.useRef)(null);
|
|
62028
|
+
const handleClose = (0, import_react28.useCallback)(() => {
|
|
60897
62029
|
onOpenChange(false);
|
|
60898
62030
|
if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
|
|
60899
62031
|
resetViewTimeoutRef.current = setTimeout(() => {
|
|
@@ -60906,7 +62038,7 @@ function WithdrawModal({
|
|
|
60906
62038
|
resetViewTimeoutRef.current = null;
|
|
60907
62039
|
}, 200);
|
|
60908
62040
|
}, [onOpenChange]);
|
|
60909
|
-
(0,
|
|
62041
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
60910
62042
|
if (!open) return;
|
|
60911
62043
|
if (resetViewTimeoutRef.current) {
|
|
60912
62044
|
clearTimeout(resetViewTimeoutRef.current);
|
|
@@ -60919,17 +62051,17 @@ function WithdrawModal({
|
|
|
60919
62051
|
setSubmittedTxInfo(null);
|
|
60920
62052
|
setWithdrawDepositWalletId(void 0);
|
|
60921
62053
|
}, [open]);
|
|
60922
|
-
(0,
|
|
62054
|
+
(0, import_react28.useEffect)(() => () => {
|
|
60923
62055
|
if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
|
|
60924
62056
|
}, []);
|
|
60925
|
-
const handleTokenSymbolChange = (0,
|
|
62057
|
+
const handleTokenSymbolChange = (0, import_react28.useCallback)((symbol) => {
|
|
60926
62058
|
const tok = destinationTokens.find((t11) => t11.symbol === symbol);
|
|
60927
62059
|
if (tok) {
|
|
60928
62060
|
setSelectedToken(tok);
|
|
60929
62061
|
if (tok.chains.length > 0) setSelectedChain(tok.chains[0]);
|
|
60930
62062
|
}
|
|
60931
62063
|
}, [destinationTokens]);
|
|
60932
|
-
const handleChainKeyChange = (0,
|
|
62064
|
+
const handleChainKeyChange = (0, import_react28.useCallback)((chainKey) => {
|
|
60933
62065
|
if (!selectedToken) return;
|
|
60934
62066
|
const chain = selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === chainKey);
|
|
60935
62067
|
if (chain) setSelectedChain(chain);
|
|
@@ -60937,8 +62069,8 @@ function WithdrawModal({
|
|
|
60937
62069
|
const isSourceSupported = sourceValidation?.isSupported ?? null;
|
|
60938
62070
|
const canWithdraw = !!onWithdraw || isWalletMatch;
|
|
60939
62071
|
const isAnyLoading = tokensLoading || isCheckingSourceToken;
|
|
60940
|
-
const withdrawPoweredByFooter = /* @__PURE__ */ (0,
|
|
60941
|
-
return /* @__PURE__ */ (0,
|
|
62072
|
+
const withdrawPoweredByFooter = /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PoweredByUnifold, { color: colors2.foregroundMuted, className: "uf-flex uf-justify-center uf-shrink-0" }) });
|
|
62073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PortalContainerProvider, { value: hideOverlay ? containerEl : null, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Dialog2, { open: hideOverlay || open, onOpenChange: hideOverlay ? void 0 : handleClose, modal: !hideOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
60942
62074
|
DialogContent2,
|
|
60943
62075
|
{
|
|
60944
62076
|
ref: hideOverlay ? containerCallbackRef : void 0,
|
|
@@ -60947,7 +62079,7 @@ function WithdrawModal({
|
|
|
60947
62079
|
style: { backgroundColor: colors2.background },
|
|
60948
62080
|
onPointerDownOutside: (e) => e.preventDefault(),
|
|
60949
62081
|
onInteractOutside: (e) => e.preventDefault(),
|
|
60950
|
-
children: /* @__PURE__ */ (0,
|
|
62082
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ThemeStyleInjector, { children: view === "confirming" && submittedTxInfo ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
60951
62083
|
WithdrawConfirmingView,
|
|
60952
62084
|
{
|
|
60953
62085
|
txInfo: submittedTxInfo,
|
|
@@ -60955,18 +62087,18 @@ function WithdrawModal({
|
|
|
60955
62087
|
onClose: handleClose,
|
|
60956
62088
|
onViewTracker: () => setView("tracker")
|
|
60957
62089
|
}
|
|
60958
|
-
) : view === "detail" && selectedExecution ? /* @__PURE__ */ (0,
|
|
60959
|
-
/* @__PURE__ */ (0,
|
|
62090
|
+
) : view === "detail" && selectedExecution ? /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
62091
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DepositHeader, { title: "Withdrawal Details", showBack: true, showClose: !hideOverlay, onBack: () => {
|
|
60960
62092
|
setSelectedExecution(null);
|
|
60961
62093
|
setView("tracker");
|
|
60962
62094
|
}, onClose: handleClose }),
|
|
60963
|
-
/* @__PURE__ */ (0,
|
|
62095
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DepositDetailContent, { execution: selectedExecution, variant: "withdraw" }),
|
|
60964
62096
|
withdrawPoweredByFooter
|
|
60965
62097
|
] }) : view === "tracker" ? (
|
|
60966
62098
|
/* ---------- Tracker view: execution list ---------- */
|
|
60967
|
-
/* @__PURE__ */ (0,
|
|
60968
|
-
/* @__PURE__ */ (0,
|
|
60969
|
-
/* @__PURE__ */ (0,
|
|
62099
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
62100
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DepositHeader, { title: "Withdrawal History", showBack: true, showClose: !hideOverlay, onBack: () => setView("form"), onClose: handleClose }),
|
|
62101
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-flex uf-flex-col uf-gap-2", style: { minHeight: 200 }, children: allWithdrawals.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-flex uf-items-center uf-justify-center uf-py-8", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "uf-text-sm", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "No withdrawals to track yet" }) }) : allWithdrawals.map((ex) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
60970
62102
|
WithdrawExecutionItem,
|
|
60971
62103
|
{
|
|
60972
62104
|
execution: ex,
|
|
@@ -60981,15 +62113,15 @@ function WithdrawModal({
|
|
|
60981
62113
|
] })
|
|
60982
62114
|
) : (
|
|
60983
62115
|
/* ---------- Form view (default) ---------- */
|
|
60984
|
-
/* @__PURE__ */ (0,
|
|
60985
|
-
/* @__PURE__ */ (0,
|
|
60986
|
-
/* @__PURE__ */ (0,
|
|
60987
|
-
isAnyLoading ? /* @__PURE__ */ (0,
|
|
60988
|
-
/* @__PURE__ */ (0,
|
|
60989
|
-
/* @__PURE__ */ (0,
|
|
60990
|
-
/* @__PURE__ */ (0,
|
|
60991
|
-
] }) : /* @__PURE__ */ (0,
|
|
60992
|
-
/* @__PURE__ */ (0,
|
|
62116
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
62117
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DepositHeader, { title: modalTitle || t9.title, showClose: !hideOverlay, onClose: handleClose }),
|
|
62118
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-3", children: [
|
|
62119
|
+
isAnyLoading ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-animate-pulse", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-bg-muted uf-rounded-lg uf-w-full uf-h-10" }) }, i)) }) : isSourceSupported === false ? /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
62120
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
62121
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-mb-2", style: { color: colors2.foreground, fontFamily: fonts.medium }, children: "Unsupported Source Token" }),
|
|
62122
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)("p", { className: "uf-text-sm uf-max-w-[280px]", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: sourceValidation?.errorMessage })
|
|
62123
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
|
|
62124
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
60993
62125
|
WithdrawDoubleInput,
|
|
60994
62126
|
{
|
|
60995
62127
|
tokens: destinationTokens,
|
|
@@ -61000,7 +62132,7 @@ function WithdrawModal({
|
|
|
61000
62132
|
isLoading: tokensLoading
|
|
61001
62133
|
}
|
|
61002
62134
|
),
|
|
61003
|
-
/* @__PURE__ */ (0,
|
|
62135
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
61004
62136
|
WithdrawForm,
|
|
61005
62137
|
{
|
|
61006
62138
|
publishableKey,
|
|
@@ -61026,16 +62158,16 @@ function WithdrawModal({
|
|
|
61026
62158
|
onWithdrawError,
|
|
61027
62159
|
onDepositWalletCreation: handleDepositWalletCreation,
|
|
61028
62160
|
onWithdrawSubmitted: handleWithdrawSubmitted,
|
|
61029
|
-
footerLeft: /* @__PURE__ */ (0,
|
|
62161
|
+
footerLeft: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
|
|
61030
62162
|
"button",
|
|
61031
62163
|
{
|
|
61032
62164
|
onClick: () => setView("tracker"),
|
|
61033
62165
|
className: "uf-flex uf-items-center uf-gap-1 uf-transition-colors hover:uf-opacity-70",
|
|
61034
62166
|
style: { color: colors2.foregroundMuted },
|
|
61035
62167
|
children: [
|
|
61036
|
-
/* @__PURE__ */ (0,
|
|
62168
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Clock, { className: "uf-w-3.5 uf-h-3.5" }),
|
|
61037
62169
|
"Withdrawal History",
|
|
61038
|
-
/* @__PURE__ */ (0,
|
|
62170
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ChevronRight, { className: "uf-w-3 uf-h-3" })
|
|
61039
62171
|
]
|
|
61040
62172
|
}
|
|
61041
62173
|
)
|
|
@@ -61059,6 +62191,10 @@ function UnifoldProvider2({
|
|
|
61059
62191
|
const [depositConfig, setDepositConfig] = (0, import_react.useState)(
|
|
61060
62192
|
null
|
|
61061
62193
|
);
|
|
62194
|
+
const [isCheckoutOpen, setIsCheckoutOpen] = (0, import_react.useState)(false);
|
|
62195
|
+
const [checkoutConfig, setCheckoutConfig] = (0, import_react.useState)(
|
|
62196
|
+
null
|
|
62197
|
+
);
|
|
61062
62198
|
const [isWithdrawOpen, setIsWithdrawOpen] = (0, import_react.useState)(false);
|
|
61063
62199
|
const [withdrawConfig, setWithdrawConfig] = (0, import_react.useState)(
|
|
61064
62200
|
null
|
|
@@ -61158,6 +62294,75 @@ function UnifoldProvider2({
|
|
|
61158
62294
|
depositPromiseRef.current = null;
|
|
61159
62295
|
}
|
|
61160
62296
|
}, [depositConfig]);
|
|
62297
|
+
const checkoutPromiseRef = import_react.default.useRef(null);
|
|
62298
|
+
const checkoutConfigRef = import_react.default.useRef(null);
|
|
62299
|
+
checkoutConfigRef.current = checkoutConfig;
|
|
62300
|
+
const checkoutCloseTimeoutRef = import_react.default.useRef(null);
|
|
62301
|
+
const checkoutCloseGuardRef = import_react.default.useRef(false);
|
|
62302
|
+
const beginCheckout = (0, import_react.useCallback)((config2) => {
|
|
62303
|
+
if (checkoutCloseTimeoutRef.current) {
|
|
62304
|
+
clearTimeout(checkoutCloseTimeoutRef.current);
|
|
62305
|
+
checkoutCloseTimeoutRef.current = null;
|
|
62306
|
+
}
|
|
62307
|
+
checkoutCloseGuardRef.current = false;
|
|
62308
|
+
if (checkoutPromiseRef.current) {
|
|
62309
|
+
console.warn("[UnifoldProvider] A checkout is already in progress. Cancelling previous checkout.");
|
|
62310
|
+
checkoutPromiseRef.current.reject({
|
|
62311
|
+
message: "Checkout cancelled - new checkout started",
|
|
62312
|
+
code: "CHECKOUT_SUPERSEDED"
|
|
62313
|
+
});
|
|
62314
|
+
checkoutPromiseRef.current = null;
|
|
62315
|
+
}
|
|
62316
|
+
const promise = new Promise((resolve, reject) => {
|
|
62317
|
+
checkoutPromiseRef.current = { resolve, reject };
|
|
62318
|
+
});
|
|
62319
|
+
promise.catch(() => {
|
|
62320
|
+
});
|
|
62321
|
+
setCheckoutConfig(config2);
|
|
62322
|
+
setIsCheckoutOpen(true);
|
|
62323
|
+
return promise;
|
|
62324
|
+
}, []);
|
|
62325
|
+
const closeCheckout = (0, import_react.useCallback)(() => {
|
|
62326
|
+
if (checkoutCloseGuardRef.current) {
|
|
62327
|
+
return;
|
|
62328
|
+
}
|
|
62329
|
+
checkoutCloseGuardRef.current = true;
|
|
62330
|
+
const promiseToReject = checkoutPromiseRef.current;
|
|
62331
|
+
checkoutPromiseRef.current = null;
|
|
62332
|
+
if (checkoutConfigRef.current?.onClose) {
|
|
62333
|
+
checkoutConfigRef.current.onClose();
|
|
62334
|
+
}
|
|
62335
|
+
if (promiseToReject) {
|
|
62336
|
+
promiseToReject.reject({
|
|
62337
|
+
message: "Checkout cancelled by user",
|
|
62338
|
+
code: "CHECKOUT_CANCELLED"
|
|
62339
|
+
});
|
|
62340
|
+
}
|
|
62341
|
+
setIsCheckoutOpen(false);
|
|
62342
|
+
checkoutCloseTimeoutRef.current = setTimeout(() => {
|
|
62343
|
+
setCheckoutConfig(null);
|
|
62344
|
+
checkoutCloseTimeoutRef.current = null;
|
|
62345
|
+
}, 200);
|
|
62346
|
+
}, []);
|
|
62347
|
+
const handleCheckoutSuccess = (0, import_react.useCallback)((data) => {
|
|
62348
|
+
if (checkoutConfig?.onSuccess) {
|
|
62349
|
+
checkoutConfig.onSuccess(data);
|
|
62350
|
+
}
|
|
62351
|
+
if (checkoutPromiseRef.current) {
|
|
62352
|
+
checkoutPromiseRef.current.resolve(data);
|
|
62353
|
+
checkoutPromiseRef.current = null;
|
|
62354
|
+
}
|
|
62355
|
+
}, [checkoutConfig]);
|
|
62356
|
+
const handleCheckoutError = (0, import_react.useCallback)((error) => {
|
|
62357
|
+
console.error("[UnifoldProvider] Checkout error:", error);
|
|
62358
|
+
if (checkoutConfig?.onError) {
|
|
62359
|
+
checkoutConfig.onError(error);
|
|
62360
|
+
}
|
|
62361
|
+
if (checkoutPromiseRef.current) {
|
|
62362
|
+
checkoutPromiseRef.current.reject(error);
|
|
62363
|
+
checkoutPromiseRef.current = null;
|
|
62364
|
+
}
|
|
62365
|
+
}, [checkoutConfig]);
|
|
61161
62366
|
const beginWithdraw = (0, import_react.useCallback)((config2) => {
|
|
61162
62367
|
if (withdrawCloseTimeoutRef.current) {
|
|
61163
62368
|
clearTimeout(withdrawCloseTimeoutRef.current);
|
|
@@ -61226,16 +62431,16 @@ function UnifoldProvider2({
|
|
|
61226
62431
|
() => ({
|
|
61227
62432
|
beginDeposit,
|
|
61228
62433
|
closeDeposit,
|
|
61229
|
-
|
|
61230
|
-
|
|
62434
|
+
beginCheckout,
|
|
62435
|
+
closeCheckout,
|
|
61231
62436
|
beginWithdraw,
|
|
61232
62437
|
closeWithdraw,
|
|
61233
62438
|
handleWithdrawSuccess,
|
|
61234
62439
|
handleWithdrawError
|
|
61235
62440
|
}),
|
|
61236
|
-
[beginDeposit, closeDeposit,
|
|
62441
|
+
[beginDeposit, closeDeposit, beginCheckout, closeCheckout, beginWithdraw, closeWithdraw, handleWithdrawSuccess, handleWithdrawError]
|
|
61237
62442
|
);
|
|
61238
|
-
return /* @__PURE__ */ (0,
|
|
62443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(UnifoldProvider, { publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ConnectContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
61239
62444
|
ThemeProvider,
|
|
61240
62445
|
{
|
|
61241
62446
|
mode: resolvedTheme,
|
|
@@ -61246,7 +62451,20 @@ function UnifoldProvider2({
|
|
|
61246
62451
|
components: config?.components,
|
|
61247
62452
|
children: [
|
|
61248
62453
|
children,
|
|
61249
|
-
|
|
62454
|
+
checkoutConfig && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
62455
|
+
CheckoutModal,
|
|
62456
|
+
{
|
|
62457
|
+
open: isCheckoutOpen,
|
|
62458
|
+
onOpenChange: closeCheckout,
|
|
62459
|
+
clientSecret: checkoutConfig.clientSecret,
|
|
62460
|
+
publishableKey,
|
|
62461
|
+
enableConnectWallet: config?.enableConnectWallet,
|
|
62462
|
+
theme: resolvedTheme,
|
|
62463
|
+
onCheckoutSuccess: handleCheckoutSuccess,
|
|
62464
|
+
onCheckoutError: handleCheckoutError
|
|
62465
|
+
}
|
|
62466
|
+
),
|
|
62467
|
+
withdrawConfig && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
61250
62468
|
WithdrawModal,
|
|
61251
62469
|
{
|
|
61252
62470
|
open: isWithdrawOpen,
|
|
@@ -61266,7 +62484,7 @@ function UnifoldProvider2({
|
|
|
61266
62484
|
theme: resolvedTheme
|
|
61267
62485
|
}
|
|
61268
62486
|
),
|
|
61269
|
-
depositConfig && /* @__PURE__ */ (0,
|
|
62487
|
+
depositConfig && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
61270
62488
|
DepositModal,
|
|
61271
62489
|
{
|
|
61272
62490
|
open: isOpen,
|
|
@@ -61317,6 +62535,9 @@ function useUnifold2() {
|
|
|
61317
62535
|
beginDeposit: () => Promise.reject(new Error("SSR not supported")),
|
|
61318
62536
|
closeDeposit: () => {
|
|
61319
62537
|
},
|
|
62538
|
+
beginCheckout: () => Promise.reject(new Error("SSR not supported")),
|
|
62539
|
+
closeCheckout: () => {
|
|
62540
|
+
},
|
|
61320
62541
|
beginWithdraw: () => Promise.reject(new Error("SSR not supported")),
|
|
61321
62542
|
closeWithdraw: () => {
|
|
61322
62543
|
}
|
|
@@ -61329,15 +62550,17 @@ function useUnifold2() {
|
|
|
61329
62550
|
publishableKey: baseContext.publishableKey,
|
|
61330
62551
|
beginDeposit: connectContext.beginDeposit,
|
|
61331
62552
|
closeDeposit: connectContext.closeDeposit,
|
|
62553
|
+
beginCheckout: connectContext.beginCheckout,
|
|
62554
|
+
closeCheckout: connectContext.closeCheckout,
|
|
61332
62555
|
beginWithdraw: connectContext.beginWithdraw,
|
|
61333
62556
|
closeWithdraw: connectContext.closeWithdraw
|
|
61334
62557
|
};
|
|
61335
62558
|
}
|
|
61336
62559
|
|
|
61337
62560
|
// src/unifold.tsx
|
|
61338
|
-
var UnifoldBridge = (0,
|
|
62561
|
+
var UnifoldBridge = (0, import_react33.forwardRef)((_, ref) => {
|
|
61339
62562
|
const { beginDeposit, closeDeposit, beginWithdraw, closeWithdraw } = useUnifold2();
|
|
61340
|
-
(0,
|
|
62563
|
+
(0, import_react33.useImperativeHandle)(ref, () => ({ beginDeposit, closeDeposit, beginWithdraw, closeWithdraw }), [
|
|
61341
62564
|
beginDeposit,
|
|
61342
62565
|
closeDeposit,
|
|
61343
62566
|
beginWithdraw,
|
|
@@ -61346,7 +62569,7 @@ var UnifoldBridge = (0, import_react32.forwardRef)((_, ref) => {
|
|
|
61346
62569
|
return null;
|
|
61347
62570
|
});
|
|
61348
62571
|
UnifoldBridge.displayName = "UnifoldBridge";
|
|
61349
|
-
var RenderErrorBoundary = class extends
|
|
62572
|
+
var RenderErrorBoundary = class extends import_react33.Component {
|
|
61350
62573
|
constructor() {
|
|
61351
62574
|
super(...arguments);
|
|
61352
62575
|
this.state = { hasError: false };
|
|
@@ -61420,13 +62643,13 @@ function createUnifold(publishableKey, config) {
|
|
|
61420
62643
|
};
|
|
61421
62644
|
try {
|
|
61422
62645
|
root.render(
|
|
61423
|
-
|
|
62646
|
+
import_react33.default.createElement(
|
|
61424
62647
|
RenderErrorBoundary,
|
|
61425
62648
|
{ onError: handleRenderError },
|
|
61426
|
-
|
|
62649
|
+
import_react33.default.createElement(
|
|
61427
62650
|
UnifoldProvider2,
|
|
61428
62651
|
{ publishableKey, config },
|
|
61429
|
-
|
|
62652
|
+
import_react33.default.createElement(UnifoldBridge, { ref: refCallback })
|
|
61430
62653
|
)
|
|
61431
62654
|
)
|
|
61432
62655
|
);
|
|
@@ -61450,6 +62673,7 @@ lucide-react/dist/esm/Icon.js:
|
|
|
61450
62673
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
61451
62674
|
lucide-react/dist/esm/icons/arrow-left-right.js:
|
|
61452
62675
|
lucide-react/dist/esm/icons/arrow-left.js:
|
|
62676
|
+
lucide-react/dist/esm/icons/arrow-right.js:
|
|
61453
62677
|
lucide-react/dist/esm/icons/arrow-up-down.js:
|
|
61454
62678
|
lucide-react/dist/esm/icons/check.js:
|
|
61455
62679
|
lucide-react/dist/esm/icons/chevron-down.js:
|