@unifold/ui-react 0.1.68 → 0.1.69
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.d.mts +24 -7
- package/dist/index.d.ts +24 -7
- package/dist/index.js +510 -226
- package/dist/index.mjs +660 -374
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -697,7 +697,9 @@ function GeoRestrictionScreen({ methodName, message }) {
|
|
|
697
697
|
}
|
|
698
698
|
|
|
699
699
|
// src/components/deposits/BuyWithCard.tsx
|
|
700
|
+
var React5 = __toESM(require("react"));
|
|
700
701
|
var import_react8 = require("react");
|
|
702
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
701
703
|
var import_lucide_react8 = require("lucide-react");
|
|
702
704
|
var import_core9 = require("@unifold/core");
|
|
703
705
|
|
|
@@ -2685,13 +2687,25 @@ function BuyWithCard({
|
|
|
2685
2687
|
wallets: externalWallets,
|
|
2686
2688
|
assetCdnUrl,
|
|
2687
2689
|
hideDepositFlowInfo = false,
|
|
2688
|
-
hideDisplayDescription = false
|
|
2690
|
+
hideDisplayDescription = false,
|
|
2691
|
+
prefilledAmountUsd
|
|
2689
2692
|
}) {
|
|
2690
2693
|
const { colors: colors2, fonts, components } = useTheme();
|
|
2691
|
-
const
|
|
2694
|
+
const cleanedPrefilledAmountUsd = React5.useMemo(() => {
|
|
2695
|
+
if (!prefilledAmountUsd) return "";
|
|
2696
|
+
return prefilledAmountUsd.replace(/[^0-9.]/g, "");
|
|
2697
|
+
}, [prefilledAmountUsd]);
|
|
2698
|
+
const parsedPrefilledAmountUsd = React5.useMemo(() => {
|
|
2699
|
+
const parsed = parseFloat(cleanedPrefilledAmountUsd);
|
|
2700
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
2701
|
+
}, [cleanedPrefilledAmountUsd]);
|
|
2702
|
+
const shouldAutoConvertPrefilledRef = (0, import_react8.useRef)(!!cleanedPrefilledAmountUsd);
|
|
2703
|
+
const [amount, setAmount] = (0, import_react8.useState)(() => cleanedPrefilledAmountUsd);
|
|
2692
2704
|
const [currency, setCurrency] = (0, import_react8.useState)("usd");
|
|
2693
2705
|
const [hasManualCurrencySelection, setHasManualCurrencySelection] = (0, import_react8.useState)(false);
|
|
2694
|
-
const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react8.useState)(
|
|
2706
|
+
const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react8.useState)(
|
|
2707
|
+
() => !!cleanedPrefilledAmountUsd
|
|
2708
|
+
);
|
|
2695
2709
|
const [showCurrencyModal, setShowCurrencyModal] = (0, import_react8.useState)(false);
|
|
2696
2710
|
const [quotes, setQuotes] = (0, import_react8.useState)([]);
|
|
2697
2711
|
const [quotesLoading, setQuotesLoading] = (0, import_react8.useState)(false);
|
|
@@ -2748,6 +2762,71 @@ function BuyWithCard({
|
|
|
2748
2762
|
const [preferredCurrencyCodes, setPreferredCurrencyCodes] = (0, import_react8.useState)([]);
|
|
2749
2763
|
const [currenciesLoading, setCurrenciesLoading] = (0, import_react8.useState)(true);
|
|
2750
2764
|
const [destinationToken, setDestinationToken] = (0, import_react8.useState)(null);
|
|
2765
|
+
(0, import_react8.useEffect)(() => {
|
|
2766
|
+
const hasPrefilledAmount = !!cleanedPrefilledAmountUsd;
|
|
2767
|
+
shouldAutoConvertPrefilledRef.current = hasPrefilledAmount;
|
|
2768
|
+
if (!hasPrefilledAmount) return;
|
|
2769
|
+
setAmount(cleanedPrefilledAmountUsd);
|
|
2770
|
+
setHasManualAmountEntry(true);
|
|
2771
|
+
}, [cleanedPrefilledAmountUsd]);
|
|
2772
|
+
const { data: fiatExchangeRatesResponse, isLoading: isFiatExchangeRatesLoading } = (0, import_react_query3.useQuery)({
|
|
2773
|
+
queryKey: ["fiat-exchange-rates", publishableKey],
|
|
2774
|
+
staleTime: 3e4,
|
|
2775
|
+
refetchInterval: 3e4,
|
|
2776
|
+
queryFn: async () => {
|
|
2777
|
+
try {
|
|
2778
|
+
return await (0, import_core9.getFiatExchangeRates)({}, publishableKey);
|
|
2779
|
+
} catch (error) {
|
|
2780
|
+
console.error("Error fetching fiat exchange rates:", error);
|
|
2781
|
+
return { base_currency: "usd", rates: {} };
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
});
|
|
2785
|
+
const fiatExchangeRates = fiatExchangeRatesResponse?.rates ?? {};
|
|
2786
|
+
const convertAmountBetweenCurrencies = React5.useCallback(
|
|
2787
|
+
(rawAmount, fromCurrencyCode, toCurrencyCode) => {
|
|
2788
|
+
const parsedAmount = parseFloat(rawAmount);
|
|
2789
|
+
if (!Number.isFinite(parsedAmount) || parsedAmount <= 0) return null;
|
|
2790
|
+
const fromCode = fromCurrencyCode.toLowerCase();
|
|
2791
|
+
const toCode = toCurrencyCode.toLowerCase();
|
|
2792
|
+
const fromRate = fromCode === "usd" ? 1 : fiatExchangeRates[fromCode];
|
|
2793
|
+
const toRate = toCode === "usd" ? 1 : fiatExchangeRates[toCode];
|
|
2794
|
+
if (!Number.isFinite(fromRate) || fromRate <= 0) return null;
|
|
2795
|
+
if (!Number.isFinite(toRate) || toRate <= 0) return null;
|
|
2796
|
+
const usdAmount = parsedAmount / fromRate;
|
|
2797
|
+
return parseFloat((usdAmount * toRate).toFixed(2)).toString();
|
|
2798
|
+
},
|
|
2799
|
+
[fiatExchangeRates]
|
|
2800
|
+
);
|
|
2801
|
+
const getConvertedPrefilledAmount = React5.useCallback(
|
|
2802
|
+
(targetCurrencyCode) => {
|
|
2803
|
+
if (!parsedPrefilledAmountUsd) return null;
|
|
2804
|
+
const normalizedTargetCurrency = targetCurrencyCode.toLowerCase();
|
|
2805
|
+
const rate = normalizedTargetCurrency === "usd" ? 1 : fiatExchangeRates[normalizedTargetCurrency];
|
|
2806
|
+
if (!Number.isFinite(rate) || rate <= 0) return null;
|
|
2807
|
+
return parseFloat((parsedPrefilledAmountUsd * rate).toFixed(2)).toString();
|
|
2808
|
+
},
|
|
2809
|
+
[parsedPrefilledAmountUsd, fiatExchangeRates]
|
|
2810
|
+
);
|
|
2811
|
+
(0, import_react8.useEffect)(() => {
|
|
2812
|
+
if (!cleanedPrefilledAmountUsd || !shouldAutoConvertPrefilledRef.current) return;
|
|
2813
|
+
const convertedAmount = getConvertedPrefilledAmount(currency);
|
|
2814
|
+
if (!convertedAmount) {
|
|
2815
|
+
if (isFiatExchangeRatesLoading) return;
|
|
2816
|
+
const targetCurrency = currency.toLowerCase();
|
|
2817
|
+
if (targetCurrency !== "usd") {
|
|
2818
|
+
setCurrency("usd");
|
|
2819
|
+
}
|
|
2820
|
+
return;
|
|
2821
|
+
}
|
|
2822
|
+
setAmount(convertedAmount);
|
|
2823
|
+
setHasManualAmountEntry(true);
|
|
2824
|
+
}, [
|
|
2825
|
+
cleanedPrefilledAmountUsd,
|
|
2826
|
+
currency,
|
|
2827
|
+
getConvertedPrefilledAmount,
|
|
2828
|
+
isFiatExchangeRatesLoading
|
|
2829
|
+
]);
|
|
2751
2830
|
const depositWalletId = defaultToken ? (0, import_core9.getWalletByChainType)(wallets, defaultToken.destination_token_metadata.chain_type)?.id : void 0;
|
|
2752
2831
|
const { executions, isPolling, showWaitingUi } = useDepositPolling({
|
|
2753
2832
|
userId,
|
|
@@ -2778,6 +2857,7 @@ function BuyWithCard({
|
|
|
2778
2857
|
}, [publishableKey]);
|
|
2779
2858
|
(0, import_react8.useEffect)(() => {
|
|
2780
2859
|
if (hasManualCurrencySelection) return;
|
|
2860
|
+
if (hasManualAmountEntry && !shouldAutoConvertPrefilledRef.current) return;
|
|
2781
2861
|
if (fiatCurrencies.length === 0 || !userIpInfo?.alpha2) return;
|
|
2782
2862
|
const userCountryCode = userIpInfo.alpha2;
|
|
2783
2863
|
const matchingCurrency = fiatCurrencies.find((c) => c.country_codes.includes(userCountryCode));
|
|
@@ -2796,7 +2876,15 @@ function BuyWithCard({
|
|
|
2796
2876
|
const prevCurrencyRef = (0, import_react8.useRef)(null);
|
|
2797
2877
|
(0, import_react8.useEffect)(() => {
|
|
2798
2878
|
if (fiatCurrencies.length === 0) return;
|
|
2879
|
+
if (shouldAutoConvertPrefilledRef.current) {
|
|
2880
|
+
prevCurrencyRef.current = currency;
|
|
2881
|
+
return;
|
|
2882
|
+
}
|
|
2799
2883
|
if (prevCurrencyRef.current !== null && prevCurrencyRef.current !== currency) {
|
|
2884
|
+
if (hasManualAmountEntry) {
|
|
2885
|
+
prevCurrencyRef.current = currency;
|
|
2886
|
+
return;
|
|
2887
|
+
}
|
|
2800
2888
|
const currentCurrency = fiatCurrencies.find(
|
|
2801
2889
|
(c) => c.currency_code.toLowerCase() === currency.toLowerCase()
|
|
2802
2890
|
);
|
|
@@ -2805,7 +2893,7 @@ function BuyWithCard({
|
|
|
2805
2893
|
}
|
|
2806
2894
|
}
|
|
2807
2895
|
prevCurrencyRef.current = currency;
|
|
2808
|
-
}, [currency]);
|
|
2896
|
+
}, [currency, fiatCurrencies, hasManualAmountEntry]);
|
|
2809
2897
|
(0, import_react8.useEffect)(() => {
|
|
2810
2898
|
async function fetchDestinationToken() {
|
|
2811
2899
|
try {
|
|
@@ -2982,6 +3070,7 @@ function BuyWithCard({
|
|
|
2982
3070
|
return () => clearInterval(timer);
|
|
2983
3071
|
}, [quotes.length, amount]);
|
|
2984
3072
|
const handleAmountChange = (value) => {
|
|
3073
|
+
shouldAutoConvertPrefilledRef.current = false;
|
|
2985
3074
|
if (value === "") {
|
|
2986
3075
|
setAmount(value);
|
|
2987
3076
|
setHasManualAmountEntry(true);
|
|
@@ -2995,6 +3084,7 @@ function BuyWithCard({
|
|
|
2995
3084
|
}
|
|
2996
3085
|
};
|
|
2997
3086
|
const handleQuickAmount = (quickAmount) => {
|
|
3087
|
+
shouldAutoConvertPrefilledRef.current = false;
|
|
2998
3088
|
setAmount(quickAmount.toString());
|
|
2999
3089
|
setHasManualAmountEntry(true);
|
|
3000
3090
|
};
|
|
@@ -3598,8 +3688,43 @@ function BuyWithCard({
|
|
|
3598
3688
|
preferredCurrencyCodes,
|
|
3599
3689
|
selectedCurrency: currency,
|
|
3600
3690
|
onSelectCurrency: (currencyCode) => {
|
|
3601
|
-
|
|
3691
|
+
const nextCurrency = currencyCode.toLowerCase();
|
|
3692
|
+
if (nextCurrency === currency.toLowerCase()) {
|
|
3693
|
+
setHasManualCurrencySelection(true);
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
const currentCurrency = currency;
|
|
3602
3697
|
setHasManualCurrencySelection(true);
|
|
3698
|
+
if (shouldAutoConvertPrefilledRef.current) {
|
|
3699
|
+
const convertedAmount = getConvertedPrefilledAmount(nextCurrency);
|
|
3700
|
+
if (convertedAmount) {
|
|
3701
|
+
setCurrency(nextCurrency);
|
|
3702
|
+
setAmount(convertedAmount);
|
|
3703
|
+
setHasManualAmountEntry(true);
|
|
3704
|
+
} else {
|
|
3705
|
+
if (isFiatExchangeRatesLoading) return;
|
|
3706
|
+
const fallbackUsdAmount = getConvertedPrefilledAmount("usd");
|
|
3707
|
+
setCurrency("usd");
|
|
3708
|
+
if (fallbackUsdAmount) {
|
|
3709
|
+
setAmount(fallbackUsdAmount);
|
|
3710
|
+
setHasManualAmountEntry(true);
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
if (hasManualAmountEntry && amount) {
|
|
3716
|
+
const convertedAmount = convertAmountBetweenCurrencies(
|
|
3717
|
+
amount,
|
|
3718
|
+
currentCurrency,
|
|
3719
|
+
nextCurrency
|
|
3720
|
+
);
|
|
3721
|
+
if (convertedAmount) {
|
|
3722
|
+
setCurrency(nextCurrency);
|
|
3723
|
+
setAmount(convertedAmount);
|
|
3724
|
+
}
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
setCurrency(nextCurrency);
|
|
3603
3728
|
},
|
|
3604
3729
|
themeClass
|
|
3605
3730
|
}
|
|
@@ -3618,7 +3743,7 @@ function BuyWithCard({
|
|
|
3618
3743
|
}
|
|
3619
3744
|
|
|
3620
3745
|
// src/components/deposits/BuyWithApplePay.tsx
|
|
3621
|
-
var
|
|
3746
|
+
var React6 = __toESM(require("react"));
|
|
3622
3747
|
var import_react10 = require("react");
|
|
3623
3748
|
var import_lucide_react9 = require("lucide-react");
|
|
3624
3749
|
var import_core13 = require("@unifold/core");
|
|
@@ -3665,13 +3790,13 @@ function isOnrampTokenFresh(contact) {
|
|
|
3665
3790
|
}
|
|
3666
3791
|
|
|
3667
3792
|
// src/hooks/use-coinbase-legal-agreements.ts
|
|
3668
|
-
var
|
|
3793
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
3669
3794
|
var import_core10 = require("@unifold/core");
|
|
3670
3795
|
function useCoinbaseLegalAgreements({
|
|
3671
3796
|
publishableKey,
|
|
3672
3797
|
enabled = true
|
|
3673
3798
|
}) {
|
|
3674
|
-
return (0,
|
|
3799
|
+
return (0, import_react_query4.useQuery)({
|
|
3675
3800
|
queryKey: ["unifold", "coinbaseLegalAgreements", publishableKey],
|
|
3676
3801
|
queryFn: () => (0, import_core10.getCoinbaseLegalAgreements)(publishableKey),
|
|
3677
3802
|
enabled: enabled && !!publishableKey,
|
|
@@ -3687,7 +3812,7 @@ function useCoinbaseLegalAgreements({
|
|
|
3687
3812
|
var import_react9 = require("react");
|
|
3688
3813
|
|
|
3689
3814
|
// src/hooks/use-apple-pay-limits.ts
|
|
3690
|
-
var
|
|
3815
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
3691
3816
|
var import_core11 = require("@unifold/core");
|
|
3692
3817
|
var US_E164_REGEX = /^\+1\d{10}$/;
|
|
3693
3818
|
function useApplePayLimits({
|
|
@@ -3696,7 +3821,7 @@ function useApplePayLimits({
|
|
|
3696
3821
|
enabled = true
|
|
3697
3822
|
}) {
|
|
3698
3823
|
const phoneValid = US_E164_REGEX.test(phone);
|
|
3699
|
-
return (0,
|
|
3824
|
+
return (0, import_react_query5.useQuery)({
|
|
3700
3825
|
queryKey: ["unifold", "applePayLimits", phone, publishableKey],
|
|
3701
3826
|
queryFn: ({ signal }) => (0, import_core11.getCoinbaseApplePayLimits)(phone, publishableKey, signal),
|
|
3702
3827
|
enabled: enabled && phoneValid && !!publishableKey,
|
|
@@ -3786,7 +3911,7 @@ function useApplePayInitialScreen({
|
|
|
3786
3911
|
}
|
|
3787
3912
|
|
|
3788
3913
|
// src/hooks/use-default-onramp-token.ts
|
|
3789
|
-
var
|
|
3914
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
3790
3915
|
var import_core12 = require("@unifold/core");
|
|
3791
3916
|
function useDefaultOnrampToken({
|
|
3792
3917
|
publishableKey,
|
|
@@ -3802,7 +3927,7 @@ function useDefaultOnrampToken({
|
|
|
3802
3927
|
isLoading,
|
|
3803
3928
|
isError,
|
|
3804
3929
|
error
|
|
3805
|
-
} = (0,
|
|
3930
|
+
} = (0, import_react_query6.useQuery)({
|
|
3806
3931
|
queryKey: [
|
|
3807
3932
|
"unifold",
|
|
3808
3933
|
"defaultOnrampToken",
|
|
@@ -3879,7 +4004,7 @@ function parseCoinbasePostMessage(raw) {
|
|
|
3879
4004
|
} : void 0
|
|
3880
4005
|
};
|
|
3881
4006
|
}
|
|
3882
|
-
var BuyWithApplePay =
|
|
4007
|
+
var BuyWithApplePay = React6.forwardRef(
|
|
3883
4008
|
function BuyWithApplePay2({
|
|
3884
4009
|
userId,
|
|
3885
4010
|
publishableKey,
|
|
@@ -4038,7 +4163,7 @@ var BuyWithApplePay = React5.forwardRef(
|
|
|
4038
4163
|
popupRef.current = null;
|
|
4039
4164
|
};
|
|
4040
4165
|
}, []);
|
|
4041
|
-
|
|
4166
|
+
React6.useImperativeHandle(
|
|
4042
4167
|
ref,
|
|
4043
4168
|
() => ({
|
|
4044
4169
|
requestBack: () => {
|
|
@@ -5348,7 +5473,7 @@ function LegalDisclaimer({ legalAgreements, loading }) {
|
|
|
5348
5473
|
children: [
|
|
5349
5474
|
"By continuing, you agree to Coinbase's",
|
|
5350
5475
|
" ",
|
|
5351
|
-
agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5476
|
+
agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(React6.Fragment, { children: [
|
|
5352
5477
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5353
5478
|
"a",
|
|
5354
5479
|
{
|
|
@@ -5784,10 +5909,10 @@ function useIsMobileViewport() {
|
|
|
5784
5909
|
}
|
|
5785
5910
|
|
|
5786
5911
|
// src/hooks/use-cashapp-limits.ts
|
|
5787
|
-
var
|
|
5912
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
5788
5913
|
var import_core15 = require("@unifold/core");
|
|
5789
5914
|
function useCashAppLimits({ publishableKey, currency = "usd" }) {
|
|
5790
|
-
return (0,
|
|
5915
|
+
return (0, import_react_query7.useQuery)({
|
|
5791
5916
|
queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
|
|
5792
5917
|
queryFn: () => (0, import_core15.getCashAppLimits)(currency, publishableKey),
|
|
5793
5918
|
enabled: !!publishableKey,
|
|
@@ -5803,6 +5928,7 @@ var POLL_INTERVAL_MS2 = 5e3;
|
|
|
5803
5928
|
var FALLBACK_MIN_USD = 5;
|
|
5804
5929
|
var SUGGESTED_AMOUNTS = [25, 50, 100];
|
|
5805
5930
|
var t3 = i18n.depositModal.cashApp;
|
|
5931
|
+
var sanitizePrefilledUsd = (value) => value?.replace(/[^0-9.]/g, "") ?? "";
|
|
5806
5932
|
function PayWithCashApp({
|
|
5807
5933
|
userId,
|
|
5808
5934
|
publishableKey,
|
|
@@ -5817,6 +5943,7 @@ function PayWithCashApp({
|
|
|
5817
5943
|
onEvent,
|
|
5818
5944
|
onDepositSuccess,
|
|
5819
5945
|
onDepositError,
|
|
5946
|
+
prefilledAmountUsd,
|
|
5820
5947
|
wallets = []
|
|
5821
5948
|
}) {
|
|
5822
5949
|
const { colors: colors2, fonts, components } = useTheme();
|
|
@@ -5832,7 +5959,7 @@ function PayWithCashApp({
|
|
|
5832
5959
|
const { data: limits, isLoading: limitsLoading } = useCashAppLimits({ publishableKey });
|
|
5833
5960
|
const minUsd = limits?.minimum_amount ?? FALLBACK_MIN_USD;
|
|
5834
5961
|
const maxUsd = limits?.maximum_amount ?? null;
|
|
5835
|
-
const [amount, setAmount] = (0, import_react14.useState)(
|
|
5962
|
+
const [amount, setAmount] = (0, import_react14.useState)(() => sanitizePrefilledUsd(prefilledAmountUsd));
|
|
5836
5963
|
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
5837
5964
|
const [session, setSession] = (0, import_react14.useState)(null);
|
|
5838
5965
|
const [status, setStatus] = (0, import_react14.useState)("pending");
|
|
@@ -5955,6 +6082,13 @@ function PayWithCashApp({
|
|
|
5955
6082
|
return () => clearInterval(interval);
|
|
5956
6083
|
}, [session, view, status, publishableKey, onDepositSuccess, onDepositError]);
|
|
5957
6084
|
const [softExpired, setSoftExpired] = (0, import_react14.useState)(false);
|
|
6085
|
+
(0, import_react14.useEffect)(() => {
|
|
6086
|
+
if (!prefilledAmountUsd) return;
|
|
6087
|
+
const cleaned = sanitizePrefilledUsd(prefilledAmountUsd);
|
|
6088
|
+
if (!cleaned) return;
|
|
6089
|
+
setAmount(cleaned);
|
|
6090
|
+
onAmountChange?.(cleaned);
|
|
6091
|
+
}, [prefilledAmountUsd, onAmountChange]);
|
|
5958
6092
|
(0, import_react14.useEffect)(() => {
|
|
5959
6093
|
if (!session?.expires_at || view !== "payment") return;
|
|
5960
6094
|
const expiresMs = new Date(session.expires_at).getTime();
|
|
@@ -6310,7 +6444,7 @@ var import_lucide_react12 = require("lucide-react");
|
|
|
6310
6444
|
var import_core18 = require("@unifold/core");
|
|
6311
6445
|
|
|
6312
6446
|
// src/hooks/use-bank-transfer-providers.ts
|
|
6313
|
-
var
|
|
6447
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
6314
6448
|
var import_core17 = require("@unifold/core");
|
|
6315
6449
|
function useBankTransferProviders({
|
|
6316
6450
|
publishableKey,
|
|
@@ -6318,7 +6452,7 @@ function useBankTransferProviders({
|
|
|
6318
6452
|
countryCode
|
|
6319
6453
|
}) {
|
|
6320
6454
|
const normalizedCountry = countryCode?.toUpperCase();
|
|
6321
|
-
const { data: providers, isLoading } = (0,
|
|
6455
|
+
const { data: providers, isLoading } = (0, import_react_query8.useQuery)({
|
|
6322
6456
|
queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
|
|
6323
6457
|
queryFn: () => (0, import_core17.getBankTransferProviders)(publishableKey, { countryCode: normalizedCountry }),
|
|
6324
6458
|
enabled,
|
|
@@ -6359,7 +6493,8 @@ function BankTransfer({
|
|
|
6359
6493
|
assetCdnUrl,
|
|
6360
6494
|
onDepositSuccess,
|
|
6361
6495
|
onEvent,
|
|
6362
|
-
onDepositError
|
|
6496
|
+
onDepositError,
|
|
6497
|
+
prefilledAmountUsd
|
|
6363
6498
|
}) {
|
|
6364
6499
|
const { colors: colors2, fonts, components } = useTheme();
|
|
6365
6500
|
const [internalView, setInternalView] = (0, import_react15.useState)("providers");
|
|
@@ -6369,6 +6504,10 @@ function BankTransfer({
|
|
|
6369
6504
|
const [requestBase, setRequestBase] = (0, import_react15.useState)(null);
|
|
6370
6505
|
const [activeRequest, setActiveRequest] = (0, import_react15.useState)(null);
|
|
6371
6506
|
const [amount, setAmount] = (0, import_react15.useState)("");
|
|
6507
|
+
const [fiatExchangeRates, setFiatExchangeRates] = (0, import_react15.useState)({
|
|
6508
|
+
usd: 1
|
|
6509
|
+
});
|
|
6510
|
+
const providerSelectionRequestIdRef = (0, import_react15.useRef)(0);
|
|
6372
6511
|
const currentView = externalView ?? internalView;
|
|
6373
6512
|
const setView = (v) => {
|
|
6374
6513
|
setInternalView(v);
|
|
@@ -6418,7 +6557,38 @@ function BankTransfer({
|
|
|
6418
6557
|
() => destinationTokenSymbol?.toUpperCase() ?? defaultToken?.destination_token_metadata?.symbol?.toUpperCase() ?? defaultToken?.destination_currency?.toUpperCase() ?? "USDC",
|
|
6419
6558
|
[destinationTokenSymbol, defaultToken]
|
|
6420
6559
|
);
|
|
6421
|
-
const
|
|
6560
|
+
const resolvePrefilledSourceAmount = (0, import_react15.useCallback)(
|
|
6561
|
+
async (sourceCurrencyCode) => {
|
|
6562
|
+
const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
|
|
6563
|
+
if (!cleanedPrefilled) return "";
|
|
6564
|
+
const prefilledUsd = parseFloat(cleanedPrefilled);
|
|
6565
|
+
if (!Number.isFinite(prefilledUsd) || prefilledUsd <= 0) return "";
|
|
6566
|
+
const sourceCurrency2 = sourceCurrencyCode.toLowerCase();
|
|
6567
|
+
let rate = sourceCurrency2 === "usd" ? 1 : fiatExchangeRates[sourceCurrency2];
|
|
6568
|
+
if ((!rate || rate <= 0) && sourceCurrency2 !== "usd") {
|
|
6569
|
+
try {
|
|
6570
|
+
const response = await (0, import_core18.getFiatExchangeRates)({}, publishableKey);
|
|
6571
|
+
if (response?.rates) {
|
|
6572
|
+
setFiatExchangeRates((prev) => ({
|
|
6573
|
+
...prev,
|
|
6574
|
+
...response.rates,
|
|
6575
|
+
usd: 1
|
|
6576
|
+
}));
|
|
6577
|
+
}
|
|
6578
|
+
const fetchedRate = response.rates?.[sourceCurrency2];
|
|
6579
|
+
if (Number.isFinite(fetchedRate) && fetchedRate > 0) {
|
|
6580
|
+
rate = fetchedRate;
|
|
6581
|
+
}
|
|
6582
|
+
} catch (error) {
|
|
6583
|
+
console.error("Error fetching fiat exchange rates for bank transfer:", error);
|
|
6584
|
+
}
|
|
6585
|
+
}
|
|
6586
|
+
if (!rate || rate <= 0) return sourceCurrency2 === "usd" ? cleanedPrefilled : "";
|
|
6587
|
+
return parseFloat((prefilledUsd * rate).toFixed(2)).toString();
|
|
6588
|
+
},
|
|
6589
|
+
[fiatExchangeRates, prefilledAmountUsd, publishableKey]
|
|
6590
|
+
);
|
|
6591
|
+
const handleProviderClick = async (provider) => {
|
|
6422
6592
|
if (!provider.enabled) return;
|
|
6423
6593
|
setSessionError(null);
|
|
6424
6594
|
if (!defaultToken) {
|
|
@@ -6437,6 +6607,7 @@ function BankTransfer({
|
|
|
6437
6607
|
});
|
|
6438
6608
|
return;
|
|
6439
6609
|
}
|
|
6610
|
+
const requestId = ++providerSelectionRequestIdRef.current;
|
|
6440
6611
|
setRequestBase({
|
|
6441
6612
|
service_provider: provider.service_provider,
|
|
6442
6613
|
country_code: (userIpInfo?.alpha2 || "DE").toUpperCase(),
|
|
@@ -6450,7 +6621,10 @@ function BankTransfer({
|
|
|
6450
6621
|
payment_method: provider.payment_methods[0]
|
|
6451
6622
|
});
|
|
6452
6623
|
setActiveProvider(provider);
|
|
6453
|
-
|
|
6624
|
+
const convertedPrefilled = await resolvePrefilledSourceAmount(provider.source_currency);
|
|
6625
|
+
if (requestId !== providerSelectionRequestIdRef.current) return;
|
|
6626
|
+
const hasPrefilledAmount = !!prefilledAmountUsd?.replace(/[^0-9.]/g, "");
|
|
6627
|
+
setAmount(hasPrefilledAmount ? convertedPrefilled : "100");
|
|
6454
6628
|
setView("amount");
|
|
6455
6629
|
};
|
|
6456
6630
|
const handleAmountChange = (value) => {
|
|
@@ -6548,7 +6722,7 @@ function BankTransfer({
|
|
|
6548
6722
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
6549
6723
|
"button",
|
|
6550
6724
|
{
|
|
6551
|
-
onClick: () => handleProviderClick(provider),
|
|
6725
|
+
onClick: () => void handleProviderClick(provider),
|
|
6552
6726
|
onMouseEnter: () => !disabled && setHoveredId(provider.service_provider),
|
|
6553
6727
|
onMouseLeave: () => setHoveredId(null),
|
|
6554
6728
|
disabled,
|
|
@@ -7117,7 +7291,7 @@ function DepositExecutionItem({ execution, onClick }) {
|
|
|
7117
7291
|
}
|
|
7118
7292
|
|
|
7119
7293
|
// src/components/deposits/buttons/TransferCryptoButton.tsx
|
|
7120
|
-
var
|
|
7294
|
+
var React7 = __toESM(require("react"));
|
|
7121
7295
|
var import_lucide_react14 = require("lucide-react");
|
|
7122
7296
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
7123
7297
|
function TransferCryptoButton({
|
|
@@ -7127,9 +7301,9 @@ function TransferCryptoButton({
|
|
|
7127
7301
|
featuredTokens
|
|
7128
7302
|
}) {
|
|
7129
7303
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7130
|
-
const [isHovered, setIsHovered] =
|
|
7131
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7132
|
-
|
|
7304
|
+
const [isHovered, setIsHovered] = React7.useState(false);
|
|
7305
|
+
const [isTouchDevice, setIsTouchDevice] = React7.useState(false);
|
|
7306
|
+
React7.useEffect(() => {
|
|
7133
7307
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7134
7308
|
}, []);
|
|
7135
7309
|
const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
|
|
@@ -7204,7 +7378,7 @@ function TransferCryptoButton({
|
|
|
7204
7378
|
}
|
|
7205
7379
|
|
|
7206
7380
|
// src/components/deposits/buttons/DepositWithCardButton.tsx
|
|
7207
|
-
var
|
|
7381
|
+
var React8 = __toESM(require("react"));
|
|
7208
7382
|
var import_lucide_react15 = require("lucide-react");
|
|
7209
7383
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7210
7384
|
function DepositWithCardButton({
|
|
@@ -7214,9 +7388,9 @@ function DepositWithCardButton({
|
|
|
7214
7388
|
paymentNetworks
|
|
7215
7389
|
}) {
|
|
7216
7390
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7217
|
-
const [isHovered, setIsHovered] =
|
|
7218
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7219
|
-
|
|
7391
|
+
const [isHovered, setIsHovered] = React8.useState(false);
|
|
7392
|
+
const [isTouchDevice, setIsTouchDevice] = React8.useState(false);
|
|
7393
|
+
React8.useEffect(() => {
|
|
7220
7394
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7221
7395
|
}, []);
|
|
7222
7396
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
@@ -7289,7 +7463,7 @@ function DepositWithCardButton({
|
|
|
7289
7463
|
}
|
|
7290
7464
|
|
|
7291
7465
|
// src/components/deposits/buttons/PayWithExchangeButton.tsx
|
|
7292
|
-
var
|
|
7466
|
+
var React9 = __toESM(require("react"));
|
|
7293
7467
|
var import_lucide_react16 = require("lucide-react");
|
|
7294
7468
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7295
7469
|
function PayWithExchangeButton({
|
|
@@ -7300,9 +7474,9 @@ function PayWithExchangeButton({
|
|
|
7300
7474
|
loading = false
|
|
7301
7475
|
}) {
|
|
7302
7476
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7303
|
-
const [isHovered, setIsHovered] =
|
|
7304
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7305
|
-
|
|
7477
|
+
const [isHovered, setIsHovered] = React9.useState(false);
|
|
7478
|
+
const [isTouchDevice, setIsTouchDevice] = React9.useState(false);
|
|
7479
|
+
React9.useEffect(() => {
|
|
7306
7480
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7307
7481
|
}, []);
|
|
7308
7482
|
if (loading) {
|
|
@@ -7381,11 +7555,11 @@ function PayWithExchangeButton({
|
|
|
7381
7555
|
}
|
|
7382
7556
|
|
|
7383
7557
|
// src/components/deposits/buttons/ConnectExchangeButton.tsx
|
|
7384
|
-
var
|
|
7558
|
+
var React11 = __toESM(require("react"));
|
|
7385
7559
|
var import_lucide_react17 = require("lucide-react");
|
|
7386
7560
|
|
|
7387
7561
|
// src/components/shared/button.tsx
|
|
7388
|
-
var
|
|
7562
|
+
var React10 = __toESM(require("react"));
|
|
7389
7563
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
7390
7564
|
var import_class_variance_authority = require("class-variance-authority");
|
|
7391
7565
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
@@ -7414,11 +7588,11 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
7414
7588
|
}
|
|
7415
7589
|
}
|
|
7416
7590
|
);
|
|
7417
|
-
var Button =
|
|
7591
|
+
var Button = React10.forwardRef(
|
|
7418
7592
|
({ className, variant, size, asChild = false, style, ...props }, ref) => {
|
|
7419
7593
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
7420
7594
|
const { components, fonts } = useTheme();
|
|
7421
|
-
const themeStyle =
|
|
7595
|
+
const themeStyle = React10.useMemo(() => {
|
|
7422
7596
|
const baseStyle = { ...style };
|
|
7423
7597
|
if (variant === "default" || !variant) {
|
|
7424
7598
|
baseStyle.backgroundColor = components.button.primaryBackground;
|
|
@@ -7456,9 +7630,9 @@ function ConnectExchangeButton({
|
|
|
7456
7630
|
connectedExchange
|
|
7457
7631
|
}) {
|
|
7458
7632
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7459
|
-
const [isHovered, setIsHovered] =
|
|
7460
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7461
|
-
|
|
7633
|
+
const [isHovered, setIsHovered] = React11.useState(false);
|
|
7634
|
+
const [isTouchDevice, setIsTouchDevice] = React11.useState(false);
|
|
7635
|
+
React11.useEffect(() => {
|
|
7462
7636
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7463
7637
|
}, []);
|
|
7464
7638
|
const isConnected = connectedExchange != null;
|
|
@@ -7598,7 +7772,7 @@ function ConnectExchangeButton({
|
|
|
7598
7772
|
}
|
|
7599
7773
|
|
|
7600
7774
|
// src/components/deposits/buttons/DepositTrackerButton.tsx
|
|
7601
|
-
var
|
|
7775
|
+
var React12 = __toESM(require("react"));
|
|
7602
7776
|
var import_lucide_react18 = require("lucide-react");
|
|
7603
7777
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
7604
7778
|
function DepositTrackerButton({
|
|
@@ -7608,9 +7782,9 @@ function DepositTrackerButton({
|
|
|
7608
7782
|
badge
|
|
7609
7783
|
}) {
|
|
7610
7784
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7611
|
-
const [isHovered, setIsHovered] =
|
|
7612
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7613
|
-
|
|
7785
|
+
const [isHovered, setIsHovered] = React12.useState(false);
|
|
7786
|
+
const [isTouchDevice, setIsTouchDevice] = React12.useState(false);
|
|
7787
|
+
React12.useEffect(() => {
|
|
7614
7788
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7615
7789
|
}, []);
|
|
7616
7790
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
@@ -7681,14 +7855,14 @@ function DepositTrackerButton({
|
|
|
7681
7855
|
}
|
|
7682
7856
|
|
|
7683
7857
|
// src/components/deposits/buttons/CashAppButton.tsx
|
|
7684
|
-
var
|
|
7858
|
+
var React13 = __toESM(require("react"));
|
|
7685
7859
|
var import_lucide_react19 = require("lucide-react");
|
|
7686
7860
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7687
7861
|
function CashAppButton({ onClick, title, subtitle, iconUrl }) {
|
|
7688
7862
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7689
|
-
const [isHovered, setIsHovered] =
|
|
7690
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7691
|
-
|
|
7863
|
+
const [isHovered, setIsHovered] = React13.useState(false);
|
|
7864
|
+
const [isTouchDevice, setIsTouchDevice] = React13.useState(false);
|
|
7865
|
+
React13.useEffect(() => {
|
|
7692
7866
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7693
7867
|
}, []);
|
|
7694
7868
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
@@ -7752,7 +7926,7 @@ function CashAppButton({ onClick, title, subtitle, iconUrl }) {
|
|
|
7752
7926
|
}
|
|
7753
7927
|
|
|
7754
7928
|
// src/components/deposits/buttons/ApplePayButton.tsx
|
|
7755
|
-
var
|
|
7929
|
+
var React14 = __toESM(require("react"));
|
|
7756
7930
|
var import_lucide_react20 = require("lucide-react");
|
|
7757
7931
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
7758
7932
|
function AppleLogo({ className, style }) {
|
|
@@ -7777,9 +7951,9 @@ function AppleLogo({ className, style }) {
|
|
|
7777
7951
|
}
|
|
7778
7952
|
function ApplePayButton({ onClick, title, subtitle }) {
|
|
7779
7953
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7780
|
-
const [isHovered, setIsHovered] =
|
|
7781
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7782
|
-
|
|
7954
|
+
const [isHovered, setIsHovered] = React14.useState(false);
|
|
7955
|
+
const [isTouchDevice, setIsTouchDevice] = React14.useState(false);
|
|
7956
|
+
React14.useEffect(() => {
|
|
7783
7957
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7784
7958
|
}, []);
|
|
7785
7959
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
@@ -7836,7 +8010,7 @@ function ApplePayButton({ onClick, title, subtitle }) {
|
|
|
7836
8010
|
}
|
|
7837
8011
|
|
|
7838
8012
|
// src/components/deposits/buttons/BankTransferButton.tsx
|
|
7839
|
-
var
|
|
8013
|
+
var React15 = __toESM(require("react"));
|
|
7840
8014
|
var import_lucide_react21 = require("lucide-react");
|
|
7841
8015
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
7842
8016
|
function BankTransferButton({
|
|
@@ -7846,9 +8020,9 @@ function BankTransferButton({
|
|
|
7846
8020
|
comingSoon = false
|
|
7847
8021
|
}) {
|
|
7848
8022
|
const { colors: colors2, fonts, components } = useTheme();
|
|
7849
|
-
const [isHovered, setIsHovered] =
|
|
7850
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
7851
|
-
|
|
8023
|
+
const [isHovered, setIsHovered] = React15.useState(false);
|
|
8024
|
+
const [isTouchDevice, setIsTouchDevice] = React15.useState(false);
|
|
8025
|
+
React15.useEffect(() => {
|
|
7852
8026
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
7853
8027
|
}, []);
|
|
7854
8028
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
@@ -7906,7 +8080,7 @@ function BankTransferButton({
|
|
|
7906
8080
|
}
|
|
7907
8081
|
|
|
7908
8082
|
// src/components/deposits/buttons/BrowserWalletButton.tsx
|
|
7909
|
-
var
|
|
8083
|
+
var React29 = __toESM(require("react"));
|
|
7910
8084
|
var import_lucide_react22 = require("lucide-react");
|
|
7911
8085
|
var import_core20 = require("@unifold/core");
|
|
7912
8086
|
|
|
@@ -7961,7 +8135,7 @@ function collectAllEip6963EthProviders() {
|
|
|
7961
8135
|
}
|
|
7962
8136
|
|
|
7963
8137
|
// src/components/deposits/browser-wallets/useDetectedBrowserWallet.ts
|
|
7964
|
-
var
|
|
8138
|
+
var React16 = __toESM(require("react"));
|
|
7965
8139
|
|
|
7966
8140
|
// src/components/deposits/browser-wallets/detectConnectedWallet.ts
|
|
7967
8141
|
function identifyEthWallet(provider, hint) {
|
|
@@ -8112,18 +8286,18 @@ async function detectConnectedBrowserWallet(chainType) {
|
|
|
8112
8286
|
// src/components/deposits/browser-wallets/useDetectedBrowserWallet.ts
|
|
8113
8287
|
function useDetectedBrowserWallet(opts = {}) {
|
|
8114
8288
|
const { chainType, enabled = true, onDisconnect } = opts;
|
|
8115
|
-
const [wallet, setWallet] =
|
|
8116
|
-
const [isLoading, setIsLoading] =
|
|
8117
|
-
const [eip6963ProviderCount, setEip6963ProviderCount] =
|
|
8118
|
-
const onDisconnectRef =
|
|
8289
|
+
const [wallet, setWallet] = React16.useState(null);
|
|
8290
|
+
const [isLoading, setIsLoading] = React16.useState(enabled);
|
|
8291
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React16.useState(0);
|
|
8292
|
+
const onDisconnectRef = React16.useRef(onDisconnect);
|
|
8119
8293
|
onDisconnectRef.current = onDisconnect;
|
|
8120
|
-
|
|
8294
|
+
React16.useEffect(() => {
|
|
8121
8295
|
const store = getEip6963Store();
|
|
8122
8296
|
if (!store) return;
|
|
8123
8297
|
setEip6963ProviderCount(store.getProviders().length);
|
|
8124
8298
|
return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
|
|
8125
8299
|
}, []);
|
|
8126
|
-
|
|
8300
|
+
React16.useEffect(() => {
|
|
8127
8301
|
if (!enabled) {
|
|
8128
8302
|
setWallet(null);
|
|
8129
8303
|
setIsLoading(false);
|
|
@@ -8267,10 +8441,10 @@ async function disconnectInjectedBrowserWallet(wallet) {
|
|
|
8267
8441
|
}
|
|
8268
8442
|
|
|
8269
8443
|
// src/resources/icons/MetamaskIcon.tsx
|
|
8270
|
-
var
|
|
8444
|
+
var React17 = __toESM(require("react"));
|
|
8271
8445
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
8272
8446
|
function MetamaskIcon({ size = 24, className, variant = "color" }) {
|
|
8273
|
-
const id =
|
|
8447
|
+
const id = React17.useId();
|
|
8274
8448
|
if (variant === "light" || variant === "dark") {
|
|
8275
8449
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
8276
8450
|
"svg",
|
|
@@ -8392,10 +8566,10 @@ function MetamaskIcon({ size = 24, className, variant = "color" }) {
|
|
|
8392
8566
|
}
|
|
8393
8567
|
|
|
8394
8568
|
// src/resources/icons/PhantomIcon.tsx
|
|
8395
|
-
var
|
|
8569
|
+
var React18 = __toESM(require("react"));
|
|
8396
8570
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
8397
8571
|
function PhantomIcon({ size = 24, className, variant = "color" }) {
|
|
8398
|
-
const id =
|
|
8572
|
+
const id = React18.useId();
|
|
8399
8573
|
if (variant === "light") {
|
|
8400
8574
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
8401
8575
|
"svg",
|
|
@@ -8463,10 +8637,10 @@ function PhantomIcon({ size = 24, className, variant = "color" }) {
|
|
|
8463
8637
|
}
|
|
8464
8638
|
|
|
8465
8639
|
// src/resources/icons/CoinbaseIcon.tsx
|
|
8466
|
-
var
|
|
8640
|
+
var React19 = __toESM(require("react"));
|
|
8467
8641
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
8468
8642
|
function CoinbaseIcon({ size = 24, className, variant = "color" }) {
|
|
8469
|
-
const id =
|
|
8643
|
+
const id = React19.useId();
|
|
8470
8644
|
if (variant === "light") {
|
|
8471
8645
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
8472
8646
|
"svg",
|
|
@@ -8547,10 +8721,10 @@ function CoinbaseIcon({ size = 24, className, variant = "color" }) {
|
|
|
8547
8721
|
}
|
|
8548
8722
|
|
|
8549
8723
|
// src/resources/icons/RabbyIcon.tsx
|
|
8550
|
-
var
|
|
8724
|
+
var React20 = __toESM(require("react"));
|
|
8551
8725
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
8552
8726
|
function RabbyIcon({ size = 24, className, variant = "color" }) {
|
|
8553
|
-
const id =
|
|
8727
|
+
const id = React20.useId();
|
|
8554
8728
|
if (variant === "light") {
|
|
8555
8729
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
8556
8730
|
"svg",
|
|
@@ -8898,10 +9072,10 @@ function RabbyIcon({ size = 24, className, variant = "color" }) {
|
|
|
8898
9072
|
}
|
|
8899
9073
|
|
|
8900
9074
|
// src/resources/icons/RainbowIcon.tsx
|
|
8901
|
-
var
|
|
9075
|
+
var React21 = __toESM(require("react"));
|
|
8902
9076
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
8903
9077
|
function RainbowIcon({ size = 24, className, variant = "color" }) {
|
|
8904
|
-
const id =
|
|
9078
|
+
const id = React21.useId();
|
|
8905
9079
|
if (variant === "light") {
|
|
8906
9080
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
8907
9081
|
"svg",
|
|
@@ -9316,10 +9490,10 @@ function RainbowIcon({ size = 24, className, variant = "color" }) {
|
|
|
9316
9490
|
}
|
|
9317
9491
|
|
|
9318
9492
|
// src/resources/icons/TrustIcon.tsx
|
|
9319
|
-
var
|
|
9493
|
+
var React22 = __toESM(require("react"));
|
|
9320
9494
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
9321
9495
|
function TrustIcon({ size = 24, className, variant = "color" }) {
|
|
9322
|
-
const id =
|
|
9496
|
+
const id = React22.useId();
|
|
9323
9497
|
if (variant === "light") {
|
|
9324
9498
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
9325
9499
|
"svg",
|
|
@@ -9403,10 +9577,10 @@ function TrustIcon({ size = 24, className, variant = "color" }) {
|
|
|
9403
9577
|
}
|
|
9404
9578
|
|
|
9405
9579
|
// src/resources/icons/OkxIcon.tsx
|
|
9406
|
-
var
|
|
9580
|
+
var React23 = __toESM(require("react"));
|
|
9407
9581
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
9408
9582
|
function OkxIcon({ size = 24, className, variant = "color" }) {
|
|
9409
|
-
const id =
|
|
9583
|
+
const id = React23.useId();
|
|
9410
9584
|
if (variant === "light") {
|
|
9411
9585
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
9412
9586
|
"svg",
|
|
@@ -9462,10 +9636,10 @@ function OkxIcon({ size = 24, className, variant = "color" }) {
|
|
|
9462
9636
|
}
|
|
9463
9637
|
|
|
9464
9638
|
// src/resources/icons/GlowIcon.tsx
|
|
9465
|
-
var
|
|
9639
|
+
var React24 = __toESM(require("react"));
|
|
9466
9640
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
9467
9641
|
function GlowIcon({ size = 24, className, variant = "color" }) {
|
|
9468
|
-
const id =
|
|
9642
|
+
const id = React24.useId();
|
|
9469
9643
|
if (variant === "light") {
|
|
9470
9644
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9471
9645
|
"svg",
|
|
@@ -9567,10 +9741,10 @@ function GlowIcon({ size = 24, className, variant = "color" }) {
|
|
|
9567
9741
|
}
|
|
9568
9742
|
|
|
9569
9743
|
// src/resources/icons/BackpackIcon.tsx
|
|
9570
|
-
var
|
|
9744
|
+
var React25 = __toESM(require("react"));
|
|
9571
9745
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9572
9746
|
function BackpackIcon({ size = 24, className, variant = "color" }) {
|
|
9573
|
-
const id =
|
|
9747
|
+
const id = React25.useId();
|
|
9574
9748
|
if (variant === "light") {
|
|
9575
9749
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
9576
9750
|
"svg",
|
|
@@ -9644,10 +9818,10 @@ function BackpackIcon({ size = 24, className, variant = "color" }) {
|
|
|
9644
9818
|
}
|
|
9645
9819
|
|
|
9646
9820
|
// src/resources/icons/SolflareIcon.tsx
|
|
9647
|
-
var
|
|
9821
|
+
var React26 = __toESM(require("react"));
|
|
9648
9822
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
9649
9823
|
function SolflareIcon({ size = 24, className, variant = "color" }) {
|
|
9650
|
-
const id =
|
|
9824
|
+
const id = React26.useId();
|
|
9651
9825
|
if (variant === "light") {
|
|
9652
9826
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
9653
9827
|
"svg",
|
|
@@ -9715,10 +9889,10 @@ function SolflareIcon({ size = 24, className, variant = "color" }) {
|
|
|
9715
9889
|
}
|
|
9716
9890
|
|
|
9717
9891
|
// src/resources/icons/EthereumIcon.tsx
|
|
9718
|
-
var
|
|
9892
|
+
var React27 = __toESM(require("react"));
|
|
9719
9893
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
9720
9894
|
function EthereumIcon({ size = 24, className, variant = "color" }) {
|
|
9721
|
-
const id =
|
|
9895
|
+
const id = React27.useId();
|
|
9722
9896
|
if (variant === "light") {
|
|
9723
9897
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
9724
9898
|
"svg",
|
|
@@ -9843,10 +10017,10 @@ function EthereumIcon({ size = 24, className, variant = "color" }) {
|
|
|
9843
10017
|
}
|
|
9844
10018
|
|
|
9845
10019
|
// src/resources/icons/SolanaIcon.tsx
|
|
9846
|
-
var
|
|
10020
|
+
var React28 = __toESM(require("react"));
|
|
9847
10021
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
9848
10022
|
function SolanaIcon({ size = 24, className, variant = "color" }) {
|
|
9849
|
-
const id =
|
|
10023
|
+
const id = React28.useId();
|
|
9850
10024
|
if (variant === "light") {
|
|
9851
10025
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
9852
10026
|
"svg",
|
|
@@ -10097,19 +10271,19 @@ function BrowserWalletButton({
|
|
|
10097
10271
|
subtitle = i18n.depositModal.browserWallet.subtitle
|
|
10098
10272
|
}) {
|
|
10099
10273
|
const { colors: colors2, fonts, components } = useTheme();
|
|
10100
|
-
const [isHovered, setIsHovered] =
|
|
10101
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
10274
|
+
const [isHovered, setIsHovered] = React29.useState(false);
|
|
10275
|
+
const [isTouchDevice, setIsTouchDevice] = React29.useState(false);
|
|
10102
10276
|
const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
|
|
10103
|
-
const [isConnecting, setIsConnecting] =
|
|
10104
|
-
const [balanceText, setBalanceText] =
|
|
10105
|
-
const [isLoadingBalance, setIsLoadingBalance] =
|
|
10106
|
-
const [isDisconnecting, setIsDisconnecting] =
|
|
10107
|
-
const onDisconnectRef =
|
|
10277
|
+
const [isConnecting, setIsConnecting] = React29.useState(false);
|
|
10278
|
+
const [balanceText, setBalanceText] = React29.useState(null);
|
|
10279
|
+
const [isLoadingBalance, setIsLoadingBalance] = React29.useState(false);
|
|
10280
|
+
const [isDisconnecting, setIsDisconnecting] = React29.useState(false);
|
|
10281
|
+
const onDisconnectRef = React29.useRef(onDisconnect);
|
|
10108
10282
|
onDisconnectRef.current = onDisconnect;
|
|
10109
|
-
|
|
10283
|
+
React29.useEffect(() => {
|
|
10110
10284
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
10111
10285
|
}, []);
|
|
10112
|
-
|
|
10286
|
+
React29.useEffect(() => {
|
|
10113
10287
|
if (!wallet || !publishableKey) {
|
|
10114
10288
|
setBalanceText(null);
|
|
10115
10289
|
return;
|
|
@@ -10236,7 +10410,7 @@ function BrowserWalletButton({
|
|
|
10236
10410
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
10237
10411
|
};
|
|
10238
10412
|
const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
|
|
10239
|
-
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ?
|
|
10413
|
+
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React29.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
|
|
10240
10414
|
size: 36,
|
|
10241
10415
|
className: "uf-rounded-lg",
|
|
10242
10416
|
variant: "color"
|
|
@@ -10381,7 +10555,7 @@ function BrowserWalletButton({
|
|
|
10381
10555
|
}
|
|
10382
10556
|
|
|
10383
10557
|
// src/components/deposits/buttons/StripeLinkButton.tsx
|
|
10384
|
-
var
|
|
10558
|
+
var React30 = __toESM(require("react"));
|
|
10385
10559
|
var import_lucide_react23 = require("lucide-react");
|
|
10386
10560
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
10387
10561
|
var t4 = i18n.depositModal.stripeLink;
|
|
@@ -10392,9 +10566,9 @@ function StripeLinkButton({
|
|
|
10392
10566
|
iconUrl
|
|
10393
10567
|
}) {
|
|
10394
10568
|
const { colors: colors2, fonts, components } = useTheme();
|
|
10395
|
-
const [isHovered, setIsHovered] =
|
|
10396
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
10397
|
-
|
|
10569
|
+
const [isHovered, setIsHovered] = React30.useState(false);
|
|
10570
|
+
const [isTouchDevice, setIsTouchDevice] = React30.useState(false);
|
|
10571
|
+
React30.useEffect(() => {
|
|
10398
10572
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
10399
10573
|
}, []);
|
|
10400
10574
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
@@ -10899,6 +11073,8 @@ function PayWithStripeLink({
|
|
|
10899
11073
|
destinationChainType,
|
|
10900
11074
|
destinationChainId,
|
|
10901
11075
|
destinationTokenAddress,
|
|
11076
|
+
countryCode,
|
|
11077
|
+
subdivisionCode,
|
|
10902
11078
|
wallets: externalWallets,
|
|
10903
11079
|
email: emailProp,
|
|
10904
11080
|
iconUrl,
|
|
@@ -11293,7 +11469,9 @@ function PayWithStripeLink({
|
|
|
11293
11469
|
{
|
|
11294
11470
|
tokenAddress: destinationTokenAddress,
|
|
11295
11471
|
chainId: destinationChainId,
|
|
11296
|
-
chainType: destinationChainType
|
|
11472
|
+
chainType: destinationChainType,
|
|
11473
|
+
countryCode,
|
|
11474
|
+
subdivisionCode
|
|
11297
11475
|
},
|
|
11298
11476
|
publishableKey
|
|
11299
11477
|
).then((token) => {
|
|
@@ -11312,7 +11490,14 @@ function PayWithStripeLink({
|
|
|
11312
11490
|
return () => {
|
|
11313
11491
|
cancelled = true;
|
|
11314
11492
|
};
|
|
11315
|
-
}, [
|
|
11493
|
+
}, [
|
|
11494
|
+
publishableKey,
|
|
11495
|
+
destinationTokenAddress,
|
|
11496
|
+
destinationChainId,
|
|
11497
|
+
destinationChainType,
|
|
11498
|
+
countryCode,
|
|
11499
|
+
subdivisionCode
|
|
11500
|
+
]);
|
|
11316
11501
|
const destinationCurrency = stripeDestCurrency;
|
|
11317
11502
|
const authInnerRef = (0, import_react17.useRef)(null);
|
|
11318
11503
|
const paymentInnerRef = (0, import_react17.useRef)(null);
|
|
@@ -14167,7 +14352,7 @@ var import_lucide_react26 = require("lucide-react");
|
|
|
14167
14352
|
var import_core25 = require("@unifold/core");
|
|
14168
14353
|
|
|
14169
14354
|
// src/hooks/use-project-config.ts
|
|
14170
|
-
var
|
|
14355
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
14171
14356
|
var import_core22 = require("@unifold/core");
|
|
14172
14357
|
function useProjectConfig({
|
|
14173
14358
|
publishableKey,
|
|
@@ -14179,7 +14364,7 @@ function useProjectConfig({
|
|
|
14179
14364
|
data: projectConfig,
|
|
14180
14365
|
isLoading,
|
|
14181
14366
|
error
|
|
14182
|
-
} = (0,
|
|
14367
|
+
} = (0, import_react_query9.useQuery)({
|
|
14183
14368
|
// Country is part of the key so a region change refetches the region-aware
|
|
14184
14369
|
// config. Omitted when undefined so callers that don't pass a country keep
|
|
14185
14370
|
// sharing the base cache entry.
|
|
@@ -14189,7 +14374,7 @@ function useProjectConfig({
|
|
|
14189
14374
|
// Keep the previous (e.g. no-country) config visible while the region-aware
|
|
14190
14375
|
// config refetches after the country resolves, so unrelated config-driven
|
|
14191
14376
|
// UI doesn't flash back to defaults.
|
|
14192
|
-
placeholderData:
|
|
14377
|
+
placeholderData: import_react_query9.keepPreviousData,
|
|
14193
14378
|
staleTime: 1e3 * 60 * 30,
|
|
14194
14379
|
refetchOnMount: true,
|
|
14195
14380
|
refetchOnWindowFocus: true
|
|
@@ -14198,7 +14383,7 @@ function useProjectConfig({
|
|
|
14198
14383
|
}
|
|
14199
14384
|
|
|
14200
14385
|
// src/hooks/use-supported-deposit-tokens.ts
|
|
14201
|
-
var
|
|
14386
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
14202
14387
|
var import_core23 = require("@unifold/core");
|
|
14203
14388
|
function useSupportedDepositTokens(publishableKey, options) {
|
|
14204
14389
|
const hasDestination = options?.destination_token_address && options?.destination_chain_id && options?.destination_chain_type;
|
|
@@ -14211,7 +14396,7 @@ function useSupportedDepositTokens(publishableKey, options) {
|
|
|
14211
14396
|
...options?.product_type ? { product_type: options.product_type } : {}
|
|
14212
14397
|
};
|
|
14213
14398
|
const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
|
|
14214
|
-
return (0,
|
|
14399
|
+
return (0, import_react_query10.useQuery)({
|
|
14215
14400
|
queryKey: [
|
|
14216
14401
|
"unifold",
|
|
14217
14402
|
"supportedDepositTokens",
|
|
@@ -14232,14 +14417,14 @@ function useSupportedDepositTokens(publishableKey, options) {
|
|
|
14232
14417
|
}
|
|
14233
14418
|
|
|
14234
14419
|
// src/hooks/use-integration-transfer-default-token.ts
|
|
14235
|
-
var
|
|
14420
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
14236
14421
|
var import_core24 = require("@unifold/core");
|
|
14237
14422
|
function useIntegrationTransferDefaultToken({
|
|
14238
14423
|
params,
|
|
14239
14424
|
publishableKey,
|
|
14240
14425
|
enabled = true
|
|
14241
14426
|
}) {
|
|
14242
|
-
return (0,
|
|
14427
|
+
return (0, import_react_query11.useQuery)({
|
|
14243
14428
|
queryKey: [
|
|
14244
14429
|
"unifold",
|
|
14245
14430
|
"integrationTransferDefaultToken",
|
|
@@ -14310,7 +14495,8 @@ function CoinbaseConnect({
|
|
|
14310
14495
|
defaultSourceChainType,
|
|
14311
14496
|
defaultSourceChainId,
|
|
14312
14497
|
defaultSourceTokenAddress,
|
|
14313
|
-
defaultSourceSymbol
|
|
14498
|
+
defaultSourceSymbol,
|
|
14499
|
+
prefilledAmountUsd
|
|
14314
14500
|
}) {
|
|
14315
14501
|
const { colors: colors2, fonts, components } = useTheme();
|
|
14316
14502
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -14633,7 +14819,8 @@ function CoinbaseConnect({
|
|
|
14633
14819
|
};
|
|
14634
14820
|
const handleSelectAsset = (asset) => {
|
|
14635
14821
|
setSelectedAsset(asset);
|
|
14636
|
-
|
|
14822
|
+
const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
|
|
14823
|
+
setSendAmount(cleanedPrefilled);
|
|
14637
14824
|
transitionTo("enter_amount");
|
|
14638
14825
|
};
|
|
14639
14826
|
const handleCreateTransfer = async () => {
|
|
@@ -16219,13 +16406,13 @@ function CoinbaseConnect({
|
|
|
16219
16406
|
CoinbaseConnect.displayName = "CoinbaseConnect";
|
|
16220
16407
|
|
|
16221
16408
|
// src/hooks/use-exchanges.ts
|
|
16222
|
-
var
|
|
16409
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
16223
16410
|
var import_core26 = require("@unifold/core");
|
|
16224
16411
|
function useExchanges({
|
|
16225
16412
|
publishableKey,
|
|
16226
16413
|
enabled = true
|
|
16227
16414
|
}) {
|
|
16228
|
-
const { data: exchanges = [], isLoading } = (0,
|
|
16415
|
+
const { data: exchanges = [], isLoading } = (0, import_react_query12.useQuery)({
|
|
16229
16416
|
queryKey: ["unifold", "exchanges", publishableKey],
|
|
16230
16417
|
queryFn: () => (0, import_core26.getExchanges)(void 0, publishableKey).then((res) => res.data),
|
|
16231
16418
|
enabled,
|
|
@@ -16237,13 +16424,13 @@ function useExchanges({
|
|
|
16237
16424
|
}
|
|
16238
16425
|
|
|
16239
16426
|
// src/hooks/use-apple-pay-providers.ts
|
|
16240
|
-
var
|
|
16427
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
16241
16428
|
var import_core27 = require("@unifold/core");
|
|
16242
16429
|
function useApplePayProviders({
|
|
16243
16430
|
publishableKey,
|
|
16244
16431
|
enabled = true
|
|
16245
16432
|
}) {
|
|
16246
|
-
const { data: providers, isLoading } = (0,
|
|
16433
|
+
const { data: providers, isLoading } = (0, import_react_query13.useQuery)({
|
|
16247
16434
|
queryKey: ["unifold", "applePayProviders", publishableKey],
|
|
16248
16435
|
queryFn: () => (0, import_core27.getApplePayProviders)(publishableKey),
|
|
16249
16436
|
enabled,
|
|
@@ -16300,7 +16487,7 @@ function useAllowedCountry(publishableKey) {
|
|
|
16300
16487
|
}
|
|
16301
16488
|
|
|
16302
16489
|
// src/hooks/use-address-validation.ts
|
|
16303
|
-
var
|
|
16490
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
16304
16491
|
var import_core28 = require("@unifold/core");
|
|
16305
16492
|
function useAddressValidation({
|
|
16306
16493
|
recipientAddress,
|
|
@@ -16312,7 +16499,7 @@ function useAddressValidation({
|
|
|
16312
16499
|
refetchOnMount = false
|
|
16313
16500
|
}) {
|
|
16314
16501
|
const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
16315
|
-
const { data, isLoading, error } = (0,
|
|
16502
|
+
const { data, isLoading, error } = (0, import_react_query14.useQuery)({
|
|
16316
16503
|
queryKey: [
|
|
16317
16504
|
"unifold",
|
|
16318
16505
|
"addressValidation",
|
|
@@ -16365,14 +16552,14 @@ var import_lucide_react30 = require("lucide-react");
|
|
|
16365
16552
|
var import_react19 = require("react");
|
|
16366
16553
|
|
|
16367
16554
|
// src/components/shared/ThemeStyleInjector.tsx
|
|
16368
|
-
var
|
|
16555
|
+
var React32 = __toESM(require("react"));
|
|
16369
16556
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
16370
16557
|
function ThemeStyleInjector({
|
|
16371
16558
|
children,
|
|
16372
16559
|
className
|
|
16373
16560
|
}) {
|
|
16374
16561
|
const { colors: colors2, fonts, mode } = useTheme();
|
|
16375
|
-
const cssVars =
|
|
16562
|
+
const cssVars = React32.useMemo(() => {
|
|
16376
16563
|
const hexToHSL = (hex) => {
|
|
16377
16564
|
hex = hex.replace("#", "");
|
|
16378
16565
|
const r = parseInt(hex.slice(0, 2), 16) / 255;
|
|
@@ -16432,7 +16619,7 @@ function ThemeStyleInjector({
|
|
|
16432
16619
|
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
16433
16620
|
};
|
|
16434
16621
|
}, [colors2, fonts.regular]);
|
|
16435
|
-
|
|
16622
|
+
React32.useEffect(() => {
|
|
16436
16623
|
if (typeof document === "undefined") return;
|
|
16437
16624
|
if (fonts.regular) {
|
|
16438
16625
|
document.documentElement.style.setProperty("--uf-font-family", fonts.regular);
|
|
@@ -17606,7 +17793,7 @@ function useCopyAddress() {
|
|
|
17606
17793
|
}
|
|
17607
17794
|
|
|
17608
17795
|
// src/components/shared/tooltip.tsx
|
|
17609
|
-
var
|
|
17796
|
+
var React33 = __toESM(require("react"));
|
|
17610
17797
|
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
|
17611
17798
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
17612
17799
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
@@ -17614,20 +17801,20 @@ function Tooltip({
|
|
|
17614
17801
|
children,
|
|
17615
17802
|
...props
|
|
17616
17803
|
}) {
|
|
17617
|
-
const [open, setOpen] =
|
|
17804
|
+
const [open, setOpen] = React33.useState(props.defaultOpen ?? false);
|
|
17618
17805
|
const isControlled = props.open !== void 0;
|
|
17619
17806
|
const isOpen = isControlled ? props.open : open;
|
|
17620
17807
|
const onOpenChange = isControlled ? props.onOpenChange : (nextOpen) => setOpen(nextOpen);
|
|
17621
17808
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TooltipContext.Provider, { value: { open: isOpen, onOpenChange }, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TooltipPrimitive.Root, { ...props, open: isOpen, onOpenChange, children }) });
|
|
17622
17809
|
}
|
|
17623
|
-
var TooltipContext =
|
|
17810
|
+
var TooltipContext = React33.createContext({
|
|
17624
17811
|
open: false,
|
|
17625
17812
|
onOpenChange: () => {
|
|
17626
17813
|
}
|
|
17627
17814
|
});
|
|
17628
|
-
var TooltipTrigger =
|
|
17629
|
-
const { open, onOpenChange } =
|
|
17630
|
-
const handleClick =
|
|
17815
|
+
var TooltipTrigger = React33.forwardRef(({ onClick, ...props }, ref) => {
|
|
17816
|
+
const { open, onOpenChange } = React33.useContext(TooltipContext);
|
|
17817
|
+
const handleClick = React33.useCallback(
|
|
17631
17818
|
(e) => {
|
|
17632
17819
|
onOpenChange(!open);
|
|
17633
17820
|
onClick?.(e);
|
|
@@ -17637,7 +17824,7 @@ var TooltipTrigger = React32.forwardRef(({ onClick, ...props }, ref) => {
|
|
|
17637
17824
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TooltipPrimitive.Trigger, { ref, onClick: handleClick, ...props });
|
|
17638
17825
|
});
|
|
17639
17826
|
TooltipTrigger.displayName = TooltipPrimitive.Trigger.displayName;
|
|
17640
|
-
var TooltipContent =
|
|
17827
|
+
var TooltipContent = React33.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
|
|
17641
17828
|
const { themeClass, colors: colors2 } = useTheme();
|
|
17642
17829
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
17643
17830
|
TooltipPrimitive.Content,
|
|
@@ -17660,7 +17847,7 @@ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
|
17660
17847
|
var import_core31 = require("@unifold/core");
|
|
17661
17848
|
|
|
17662
17849
|
// src/hooks/use-hypercore-activation.ts
|
|
17663
|
-
var
|
|
17850
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
17664
17851
|
var import_core30 = require("@unifold/core");
|
|
17665
17852
|
|
|
17666
17853
|
// src/lib/constants.ts
|
|
@@ -17679,7 +17866,7 @@ function useHypercoreActivation(params) {
|
|
|
17679
17866
|
const recipient = recipientAddress?.trim() ?? "";
|
|
17680
17867
|
const source = sourceAddress?.trim() ?? "";
|
|
17681
17868
|
const hasAddresses = !!recipient && !!source;
|
|
17682
|
-
const { data, isLoading } = (0,
|
|
17869
|
+
const { data, isLoading } = (0, import_react_query15.useQuery)({
|
|
17683
17870
|
queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
|
|
17684
17871
|
queryFn: () => (0, import_core30.checkHypercoreActivation)(
|
|
17685
17872
|
{
|
|
@@ -17765,6 +17952,7 @@ function TransferCryptoSingleInput({
|
|
|
17765
17952
|
onDepositError,
|
|
17766
17953
|
wallets: externalWallets,
|
|
17767
17954
|
onSourceTokenChange,
|
|
17955
|
+
prefilledAmountUsd,
|
|
17768
17956
|
checkoutQuote,
|
|
17769
17957
|
isCheckoutQuoteLoading = false,
|
|
17770
17958
|
persistCheckingIndicator = false,
|
|
@@ -17908,6 +18096,22 @@ function TransferCryptoSingleInput({
|
|
|
17908
18096
|
const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
|
|
17909
18097
|
const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
|
|
17910
18098
|
const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
|
|
18099
|
+
const parsedPrefilledUsd = (0, import_react23.useMemo)(() => {
|
|
18100
|
+
const value = parseFloat(prefilledAmountUsd ?? "");
|
|
18101
|
+
return Number.isFinite(value) && value > 0 ? value : null;
|
|
18102
|
+
}, [prefilledAmountUsd]);
|
|
18103
|
+
const effectivePrefilledUsd = (0, import_react23.useMemo)(() => {
|
|
18104
|
+
if (parsedPrefilledUsd === null) return null;
|
|
18105
|
+
return Math.max(parsedPrefilledUsd, minDepositUsd);
|
|
18106
|
+
}, [parsedPrefilledUsd, minDepositUsd]);
|
|
18107
|
+
const prefillDisplay = (0, import_react23.useMemo)(() => {
|
|
18108
|
+
if (effectivePrefilledUsd === null) return null;
|
|
18109
|
+
const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
|
|
18110
|
+
if (selectedToken?.is_stablecoin) {
|
|
18111
|
+
return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
|
|
18112
|
+
}
|
|
18113
|
+
return `${usdLabel} USD`;
|
|
18114
|
+
}, [effectivePrefilledUsd, selectedToken]);
|
|
17911
18115
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(TooltipProvider, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
17912
18116
|
"div",
|
|
17913
18117
|
{
|
|
@@ -18034,7 +18238,7 @@ function TransferCryptoSingleInput({
|
|
|
18034
18238
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
|
|
18035
18239
|
] })
|
|
18036
18240
|
] }),
|
|
18037
|
-
(checkoutQuote || isCheckoutQuoteLoading) && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
18241
|
+
(checkoutQuote || isCheckoutQuoteLoading || prefillDisplay) && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
18038
18242
|
"div",
|
|
18039
18243
|
{
|
|
18040
18244
|
className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
|
|
@@ -18078,6 +18282,13 @@ function TransferCryptoSingleInput({
|
|
|
18078
18282
|
)
|
|
18079
18283
|
]
|
|
18080
18284
|
}
|
|
18285
|
+
) : prefillDisplay ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
18286
|
+
"span",
|
|
18287
|
+
{
|
|
18288
|
+
className: "uf-text-sm uf-font-semibold",
|
|
18289
|
+
style: { color: components.card.titleColor, fontFamily: fonts.semibold },
|
|
18290
|
+
children: prefillDisplay
|
|
18291
|
+
}
|
|
18081
18292
|
) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
18082
18293
|
"div",
|
|
18083
18294
|
{
|
|
@@ -18411,14 +18622,14 @@ var import_react24 = require("react");
|
|
|
18411
18622
|
var import_lucide_react32 = require("lucide-react");
|
|
18412
18623
|
|
|
18413
18624
|
// src/components/shared/select.tsx
|
|
18414
|
-
var
|
|
18625
|
+
var React34 = __toESM(require("react"));
|
|
18415
18626
|
var SelectPrimitive = __toESM(require("@radix-ui/react-select"));
|
|
18416
18627
|
var import_lucide_react31 = require("lucide-react");
|
|
18417
18628
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
18418
18629
|
var Select = SelectPrimitive.Root;
|
|
18419
18630
|
var SelectGroup = SelectPrimitive.Group;
|
|
18420
18631
|
var SelectValue = SelectPrimitive.Value;
|
|
18421
|
-
var SelectTrigger =
|
|
18632
|
+
var SelectTrigger = React34.forwardRef(({ className, style, children, ...props }, ref) => {
|
|
18422
18633
|
const { components } = useTheme();
|
|
18423
18634
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
18424
18635
|
SelectPrimitive.Trigger,
|
|
@@ -18442,7 +18653,7 @@ var SelectTrigger = React33.forwardRef(({ className, style, children, ...props }
|
|
|
18442
18653
|
);
|
|
18443
18654
|
});
|
|
18444
18655
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
18445
|
-
var SelectScrollUpButton =
|
|
18656
|
+
var SelectScrollUpButton = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
18446
18657
|
SelectPrimitive.ScrollUpButton,
|
|
18447
18658
|
{
|
|
18448
18659
|
ref,
|
|
@@ -18452,7 +18663,7 @@ var SelectScrollUpButton = React33.forwardRef(({ className, ...props }, ref) =>
|
|
|
18452
18663
|
}
|
|
18453
18664
|
));
|
|
18454
18665
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
18455
|
-
var SelectScrollDownButton =
|
|
18666
|
+
var SelectScrollDownButton = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
18456
18667
|
SelectPrimitive.ScrollDownButton,
|
|
18457
18668
|
{
|
|
18458
18669
|
ref,
|
|
@@ -18462,7 +18673,7 @@ var SelectScrollDownButton = React33.forwardRef(({ className, ...props }, ref) =
|
|
|
18462
18673
|
}
|
|
18463
18674
|
));
|
|
18464
18675
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
18465
|
-
var SelectContent =
|
|
18676
|
+
var SelectContent = React34.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
|
|
18466
18677
|
const { themeClass, colors: colors2, components } = useTheme();
|
|
18467
18678
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SelectPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
18468
18679
|
SelectPrimitive.Content,
|
|
@@ -18500,7 +18711,7 @@ var SelectContent = React33.forwardRef(({ className, style, children, position =
|
|
|
18500
18711
|
) });
|
|
18501
18712
|
});
|
|
18502
18713
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
18503
|
-
var SelectLabel =
|
|
18714
|
+
var SelectLabel = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
18504
18715
|
SelectPrimitive.Label,
|
|
18505
18716
|
{
|
|
18506
18717
|
ref,
|
|
@@ -18509,7 +18720,7 @@ var SelectLabel = React33.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
18509
18720
|
}
|
|
18510
18721
|
));
|
|
18511
18722
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
18512
|
-
var SelectItem =
|
|
18723
|
+
var SelectItem = React34.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
18513
18724
|
SelectPrimitive.Item,
|
|
18514
18725
|
{
|
|
18515
18726
|
ref,
|
|
@@ -18525,7 +18736,7 @@ var SelectItem = React33.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
18525
18736
|
}
|
|
18526
18737
|
));
|
|
18527
18738
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
18528
|
-
var SelectSeparator =
|
|
18739
|
+
var SelectSeparator = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
18529
18740
|
SelectPrimitive.Separator,
|
|
18530
18741
|
{
|
|
18531
18742
|
ref,
|
|
@@ -18557,6 +18768,7 @@ function TransferCryptoDoubleInput({
|
|
|
18557
18768
|
defaultSourceChainId,
|
|
18558
18769
|
defaultSourceTokenAddress,
|
|
18559
18770
|
defaultSourceSymbol,
|
|
18771
|
+
prefilledAmountUsd,
|
|
18560
18772
|
depositConfirmationMode = "auto_ui",
|
|
18561
18773
|
onExecutionsChange,
|
|
18562
18774
|
onDepositSuccess,
|
|
@@ -18681,6 +18893,22 @@ function TransferCryptoDoubleInput({
|
|
|
18681
18893
|
const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
|
|
18682
18894
|
const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
|
|
18683
18895
|
const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
|
|
18896
|
+
const parsedPrefilledUsd = (0, import_react24.useMemo)(() => {
|
|
18897
|
+
const value = parseFloat(prefilledAmountUsd ?? "");
|
|
18898
|
+
return Number.isFinite(value) && value > 0 ? value : null;
|
|
18899
|
+
}, [prefilledAmountUsd]);
|
|
18900
|
+
const effectivePrefilledUsd = (0, import_react24.useMemo)(() => {
|
|
18901
|
+
if (parsedPrefilledUsd === null) return null;
|
|
18902
|
+
return Math.max(parsedPrefilledUsd, minDepositUsd);
|
|
18903
|
+
}, [parsedPrefilledUsd, minDepositUsd]);
|
|
18904
|
+
const prefillDisplay = (0, import_react24.useMemo)(() => {
|
|
18905
|
+
if (effectivePrefilledUsd === null) return null;
|
|
18906
|
+
const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
|
|
18907
|
+
if (selectedToken?.is_stablecoin) {
|
|
18908
|
+
return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
|
|
18909
|
+
}
|
|
18910
|
+
return `${usdLabel} USD`;
|
|
18911
|
+
}, [effectivePrefilledUsd, selectedToken]);
|
|
18684
18912
|
const renderTokenItem = (tokenData) => {
|
|
18685
18913
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
18686
18914
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
@@ -18861,6 +19089,35 @@ function TransferCryptoDoubleInput({
|
|
|
18861
19089
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
|
|
18862
19090
|
] })
|
|
18863
19091
|
] }),
|
|
19092
|
+
prefillDisplay && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
19093
|
+
"div",
|
|
19094
|
+
{
|
|
19095
|
+
className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
|
|
19096
|
+
style: {
|
|
19097
|
+
backgroundColor: components.card.backgroundColor,
|
|
19098
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
|
|
19099
|
+
borderRadius: components.card.borderRadius
|
|
19100
|
+
},
|
|
19101
|
+
children: [
|
|
19102
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
19103
|
+
"span",
|
|
19104
|
+
{
|
|
19105
|
+
className: "uf-text-xs",
|
|
19106
|
+
style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
|
|
19107
|
+
children: "You send"
|
|
19108
|
+
}
|
|
19109
|
+
),
|
|
19110
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
19111
|
+
"span",
|
|
19112
|
+
{
|
|
19113
|
+
className: "uf-text-sm uf-font-semibold",
|
|
19114
|
+
style: { color: components.card.titleColor, fontFamily: fonts.semibold },
|
|
19115
|
+
children: prefillDisplay
|
|
19116
|
+
}
|
|
19117
|
+
)
|
|
19118
|
+
]
|
|
19119
|
+
}
|
|
19120
|
+
),
|
|
18864
19121
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pt-2", children: [
|
|
18865
19122
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
18866
19123
|
"div",
|
|
@@ -19143,7 +19400,7 @@ function TransferCryptoDoubleInput({
|
|
|
19143
19400
|
}
|
|
19144
19401
|
|
|
19145
19402
|
// src/components/deposits/WalletConnect.tsx
|
|
19146
|
-
var
|
|
19403
|
+
var React35 = __toESM(require("react"));
|
|
19147
19404
|
var import_lucide_react36 = require("lucide-react");
|
|
19148
19405
|
var import_core36 = require("@unifold/core");
|
|
19149
19406
|
|
|
@@ -19184,7 +19441,7 @@ async function sendHypercoreEvmTransfer(params) {
|
|
|
19184
19441
|
}
|
|
19185
19442
|
|
|
19186
19443
|
// src/hooks/use-deposit-quote.ts
|
|
19187
|
-
var
|
|
19444
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
19188
19445
|
var import_core34 = require("@unifold/core");
|
|
19189
19446
|
function useDepositQuote(params) {
|
|
19190
19447
|
const {
|
|
@@ -19211,7 +19468,7 @@ function useDepositQuote(params) {
|
|
|
19211
19468
|
...adjustForSlippage ? { adjust_for_slippage: true } : {},
|
|
19212
19469
|
...stablecoinParity ? { stablecoin_parity: true } : {}
|
|
19213
19470
|
};
|
|
19214
|
-
return (0,
|
|
19471
|
+
return (0, import_react_query16.useQuery)({
|
|
19215
19472
|
queryKey: [
|
|
19216
19473
|
"unifold",
|
|
19217
19474
|
"depositQuote",
|
|
@@ -19239,13 +19496,13 @@ function useDepositQuote(params) {
|
|
|
19239
19496
|
}
|
|
19240
19497
|
|
|
19241
19498
|
// src/hooks/use-external-wallets.ts
|
|
19242
|
-
var
|
|
19499
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
19243
19500
|
var import_core35 = require("@unifold/core");
|
|
19244
19501
|
function useExternalWallets({
|
|
19245
19502
|
publishableKey,
|
|
19246
19503
|
enabled = true
|
|
19247
19504
|
}) {
|
|
19248
|
-
const { data: wallets = [], isLoading } = (0,
|
|
19505
|
+
const { data: wallets = [], isLoading } = (0, import_react_query17.useQuery)({
|
|
19249
19506
|
queryKey: ["unifold", "external-wallets", publishableKey],
|
|
19250
19507
|
queryFn: () => (0, import_core35.getExternalWallets)(publishableKey).then((res) => res.data),
|
|
19251
19508
|
enabled: enabled && !!publishableKey,
|
|
@@ -20492,7 +20749,7 @@ function WalletConnect({
|
|
|
20492
20749
|
amountQuickSelect = "percentage",
|
|
20493
20750
|
onWalletDisconnect,
|
|
20494
20751
|
onWalletConnected,
|
|
20495
|
-
|
|
20752
|
+
prefilledAmountUsd,
|
|
20496
20753
|
checkoutAmountUsd,
|
|
20497
20754
|
checkoutReceivedUsd,
|
|
20498
20755
|
onNewDeposit,
|
|
@@ -20514,28 +20771,28 @@ function WalletConnect({
|
|
|
20514
20771
|
onExecutionsChange
|
|
20515
20772
|
}) {
|
|
20516
20773
|
const { colors: colors2, fonts, components, mode } = useTheme();
|
|
20517
|
-
const walletProvidedAtMount =
|
|
20518
|
-
const [activeWalletInfo, setActiveWalletInfo] =
|
|
20774
|
+
const walletProvidedAtMount = React35.useRef(!!initialWalletInfo && !!initialDepositWallet);
|
|
20775
|
+
const [activeWalletInfo, setActiveWalletInfo] = React35.useState(
|
|
20519
20776
|
initialWalletInfo ?? null
|
|
20520
20777
|
);
|
|
20521
|
-
const [activeDepositWallet, setActiveDepositWallet] =
|
|
20778
|
+
const [activeDepositWallet, setActiveDepositWallet] = React35.useState(
|
|
20522
20779
|
initialDepositWallet ?? null
|
|
20523
20780
|
);
|
|
20524
20781
|
const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
|
|
20525
|
-
const [view, setView] =
|
|
20526
|
-
const [isTransitioning, setIsTransitioning] =
|
|
20527
|
-
const viewRef =
|
|
20782
|
+
const [view, setView] = React35.useState(initialView);
|
|
20783
|
+
const [isTransitioning, setIsTransitioning] = React35.useState(false);
|
|
20784
|
+
const viewRef = React35.useRef(initialView);
|
|
20528
20785
|
const standalone = !canGoBack && !walletProvidedAtMount.current;
|
|
20529
20786
|
const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({
|
|
20530
20787
|
enabled: standalone
|
|
20531
20788
|
});
|
|
20532
|
-
const [autoResolved, setAutoResolved] =
|
|
20533
|
-
const [selectedWalletDef, setSelectedWalletDef] =
|
|
20534
|
-
const [connectingNetwork, setConnectingNetwork] =
|
|
20535
|
-
const [walletError, setWalletError] =
|
|
20536
|
-
const [isWalletConnecting, setIsWalletConnecting] =
|
|
20537
|
-
const [eip6963ProviderCount, setEip6963ProviderCount] =
|
|
20538
|
-
|
|
20789
|
+
const [autoResolved, setAutoResolved] = React35.useState(false);
|
|
20790
|
+
const [selectedWalletDef, setSelectedWalletDef] = React35.useState(null);
|
|
20791
|
+
const [connectingNetwork, setConnectingNetwork] = React35.useState(null);
|
|
20792
|
+
const [walletError, setWalletError] = React35.useState(null);
|
|
20793
|
+
const [isWalletConnecting, setIsWalletConnecting] = React35.useState(false);
|
|
20794
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React35.useState(0);
|
|
20795
|
+
React35.useEffect(() => {
|
|
20539
20796
|
const store = getEip6963Store();
|
|
20540
20797
|
if (!store) return;
|
|
20541
20798
|
setEip6963ProviderCount(store.getProviders().length);
|
|
@@ -20544,7 +20801,7 @@ function WalletConnect({
|
|
|
20544
20801
|
});
|
|
20545
20802
|
}, []);
|
|
20546
20803
|
const { wallets: backendWallets } = useExternalWallets({ publishableKey });
|
|
20547
|
-
const walletDefinitions =
|
|
20804
|
+
const walletDefinitions = React35.useMemo(
|
|
20548
20805
|
() => backendWallets.length > 0 ? backendWallets.map((w) => ({
|
|
20549
20806
|
id: w.id,
|
|
20550
20807
|
name: w.name,
|
|
@@ -20555,32 +20812,32 @@ function WalletConnect({
|
|
|
20555
20812
|
})) : FALLBACK_WALLET_DEFINITIONS,
|
|
20556
20813
|
[backendWallets]
|
|
20557
20814
|
);
|
|
20558
|
-
const [recentWalletId, setRecentWalletIdState] =
|
|
20559
|
-
|
|
20815
|
+
const [recentWalletId, setRecentWalletIdState] = React35.useState(getLastOpenedWallet);
|
|
20816
|
+
React35.useEffect(() => {
|
|
20560
20817
|
if (view === "select_wallet") {
|
|
20561
20818
|
setRecentWalletIdState(getLastOpenedWallet());
|
|
20562
20819
|
}
|
|
20563
20820
|
}, [view]);
|
|
20564
|
-
const availableWallets =
|
|
20821
|
+
const availableWallets = React35.useMemo(
|
|
20565
20822
|
() => detectAvailableWallets(walletDefinitions, recentWalletId),
|
|
20566
20823
|
[walletDefinitions, eip6963ProviderCount, recentWalletId]
|
|
20567
20824
|
);
|
|
20568
|
-
const [isMobile, setIsMobile] =
|
|
20569
|
-
|
|
20825
|
+
const [isMobile, setIsMobile] = React35.useState(false);
|
|
20826
|
+
React35.useEffect(() => {
|
|
20570
20827
|
setIsMobile(isMobileDevice());
|
|
20571
20828
|
}, []);
|
|
20572
|
-
const mobileDepositAddresses =
|
|
20829
|
+
const mobileDepositAddresses = React35.useMemo(
|
|
20573
20830
|
() => (depositWallets ?? []).map((w) => ({ chain_type: w.chain_type, address: w.address })),
|
|
20574
20831
|
[depositWallets]
|
|
20575
20832
|
);
|
|
20576
|
-
const mobileDepositWalletIds =
|
|
20833
|
+
const mobileDepositWalletIds = React35.useMemo(
|
|
20577
20834
|
() => (depositWallets ?? []).filter((w) => w.chain_type === "ethereum" || w.chain_type === "solana").map((w) => w.id),
|
|
20578
20835
|
[depositWallets]
|
|
20579
20836
|
);
|
|
20580
|
-
const [mobileRedirect, setMobileRedirect] =
|
|
20581
|
-
const [pendingMobileWallet, setPendingMobileWallet] =
|
|
20582
|
-
const [awaitingMobileDeposit, setAwaitingMobileDeposit] =
|
|
20583
|
-
|
|
20837
|
+
const [mobileRedirect, setMobileRedirect] = React35.useState(null);
|
|
20838
|
+
const [pendingMobileWallet, setPendingMobileWallet] = React35.useState(null);
|
|
20839
|
+
const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React35.useState(false);
|
|
20840
|
+
React35.useEffect(() => {
|
|
20584
20841
|
if (!standalone || autoResolved || detectingWallet) return;
|
|
20585
20842
|
if (!detectedWallet) {
|
|
20586
20843
|
setAutoResolved(true);
|
|
@@ -20606,32 +20863,36 @@ function WalletConnect({
|
|
|
20606
20863
|
depositWallets,
|
|
20607
20864
|
depositWalletsLoading
|
|
20608
20865
|
]);
|
|
20609
|
-
|
|
20866
|
+
React35.useEffect(() => {
|
|
20610
20867
|
if (!standalone || autoResolved) return;
|
|
20611
20868
|
const t13 = setTimeout(() => setAutoResolved(true), 5e3);
|
|
20612
20869
|
return () => clearTimeout(t13);
|
|
20613
20870
|
}, [standalone, autoResolved]);
|
|
20614
|
-
const [balances, setBalances] =
|
|
20615
|
-
const [isLoading, setIsLoading] =
|
|
20616
|
-
const [selectedBalance, setSelectedBalance] =
|
|
20617
|
-
const [totalBalanceUsd, setTotalBalanceUsd] =
|
|
20618
|
-
const [error, setError] =
|
|
20619
|
-
const [isDisconnectingWallet, setIsDisconnectingWallet] =
|
|
20620
|
-
const [amountUsd, setAmountUsd] =
|
|
20621
|
-
const [isConfirming, setIsConfirming] =
|
|
20622
|
-
const [hasSignedTransaction, setHasSignedTransaction] =
|
|
20623
|
-
const [tokenChainDetails, setTokenChainDetails] =
|
|
20624
|
-
const [loadingTokenDetails, setLoadingTokenDetails] =
|
|
20625
|
-
const [showTransactionDetails, setShowTransactionDetails] =
|
|
20626
|
-
const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] =
|
|
20871
|
+
const [balances, setBalances] = React35.useState([]);
|
|
20872
|
+
const [isLoading, setIsLoading] = React35.useState(false);
|
|
20873
|
+
const [selectedBalance, setSelectedBalance] = React35.useState(null);
|
|
20874
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = React35.useState(null);
|
|
20875
|
+
const [error, setError] = React35.useState(null);
|
|
20876
|
+
const [isDisconnectingWallet, setIsDisconnectingWallet] = React35.useState(false);
|
|
20877
|
+
const [amountUsd, setAmountUsd] = React35.useState(prefilledAmountUsd ?? "");
|
|
20878
|
+
const [isConfirming, setIsConfirming] = React35.useState(false);
|
|
20879
|
+
const [hasSignedTransaction, setHasSignedTransaction] = React35.useState(false);
|
|
20880
|
+
const [tokenChainDetails, setTokenChainDetails] = React35.useState(null);
|
|
20881
|
+
const [loadingTokenDetails, setLoadingTokenDetails] = React35.useState(false);
|
|
20882
|
+
const [showTransactionDetails, setShowTransactionDetails] = React35.useState(false);
|
|
20883
|
+
const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React35.useState(null);
|
|
20627
20884
|
const walletInfo = activeWalletInfo;
|
|
20628
20885
|
const depositWallet = activeDepositWallet;
|
|
20629
20886
|
const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
|
|
20887
|
+
React35.useEffect(() => {
|
|
20888
|
+
const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
|
|
20889
|
+
setAmountUsd(cleanedPrefilled);
|
|
20890
|
+
}, [prefilledAmountUsd]);
|
|
20630
20891
|
const chainType = activeDepositWallet?.chain_type ?? "ethereum";
|
|
20631
20892
|
const recipientAddress = activeDepositWallet?.address ?? "";
|
|
20632
20893
|
const isCheckoutMode = !!checkoutAmountUsd;
|
|
20633
20894
|
const supportedChainType = chainType === "algorand" || chainType === "xrpl" || chainType === "cardano" || chainType === "n1" ? "ethereum" : chainType;
|
|
20634
|
-
const transitionTo =
|
|
20895
|
+
const transitionTo = React35.useCallback((nextView) => {
|
|
20635
20896
|
if (nextView === viewRef.current) return;
|
|
20636
20897
|
setIsTransitioning(true);
|
|
20637
20898
|
setTimeout(() => {
|
|
@@ -20696,7 +20957,7 @@ function WalletConnect({
|
|
|
20696
20957
|
if (!selectedWalletDef) return;
|
|
20697
20958
|
handleConnectWallet(selectedWalletDef, network);
|
|
20698
20959
|
};
|
|
20699
|
-
|
|
20960
|
+
React35.useEffect(() => {
|
|
20700
20961
|
if (!pendingMobileWallet) return;
|
|
20701
20962
|
if (mobileDepositAddresses.length > 0) {
|
|
20702
20963
|
const wallet = pendingMobileWallet;
|
|
@@ -20860,7 +21121,7 @@ function WalletConnect({
|
|
|
20860
21121
|
publishableKey,
|
|
20861
21122
|
enabled: !!activeWalletInfo && !!recipientAddress
|
|
20862
21123
|
});
|
|
20863
|
-
const effectiveDestinationAmount =
|
|
21124
|
+
const effectiveDestinationAmount = React35.useMemo(() => {
|
|
20864
21125
|
if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
|
|
20865
21126
|
if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
|
|
20866
21127
|
const remaining = BigInt(checkoutRemainingBaseUnits);
|
|
@@ -20888,7 +21149,7 @@ function WalletConnect({
|
|
|
20888
21149
|
stablecoinParity,
|
|
20889
21150
|
enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
|
|
20890
21151
|
});
|
|
20891
|
-
const activeCheckoutQuote =
|
|
21152
|
+
const activeCheckoutQuote = React35.useMemo(() => {
|
|
20892
21153
|
if (!isCheckoutMode) return null;
|
|
20893
21154
|
if (walletCheckoutQuote)
|
|
20894
21155
|
return {
|
|
@@ -20918,10 +21179,10 @@ function WalletConnect({
|
|
|
20918
21179
|
onDepositSuccess,
|
|
20919
21180
|
onDepositError
|
|
20920
21181
|
});
|
|
20921
|
-
|
|
21182
|
+
React35.useEffect(() => {
|
|
20922
21183
|
onExecutionsChange?.(depositExecutions);
|
|
20923
21184
|
}, [depositExecutions, onExecutionsChange]);
|
|
20924
|
-
const latestDepositExecution =
|
|
21185
|
+
const latestDepositExecution = React35.useMemo(() => {
|
|
20925
21186
|
if (depositExecutions.length === 0) return null;
|
|
20926
21187
|
return [...depositExecutions].sort((a, b) => {
|
|
20927
21188
|
const ta = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
@@ -20929,21 +21190,21 @@ function WalletConnect({
|
|
|
20929
21190
|
return tb - ta;
|
|
20930
21191
|
})[0];
|
|
20931
21192
|
}, [depositExecutions]);
|
|
20932
|
-
|
|
21193
|
+
React35.useEffect(() => {
|
|
20933
21194
|
if (awaitingMobileDeposit && latestDepositExecution && (viewRef.current === "mobile_redirect" || viewRef.current === "connecting")) {
|
|
20934
21195
|
transitionTo("mobile_deposit_status");
|
|
20935
21196
|
}
|
|
20936
21197
|
}, [awaitingMobileDeposit, latestDepositExecution, transitionTo]);
|
|
20937
|
-
|
|
20938
|
-
if (!
|
|
21198
|
+
React35.useEffect(() => {
|
|
21199
|
+
if (!isCheckoutMode || !tokenChainDetails || view !== "enter_amount") return;
|
|
20939
21200
|
const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
|
|
20940
21201
|
const currentAmount = parseFloat(amountUsd) || 0;
|
|
20941
21202
|
if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
|
|
20942
|
-
}, [tokenChainDetails, view,
|
|
20943
|
-
|
|
21203
|
+
}, [isCheckoutMode, tokenChainDetails, view, amountUsd]);
|
|
21204
|
+
React35.useEffect(() => {
|
|
20944
21205
|
if (view === "review") setShowTransactionDetails(false);
|
|
20945
21206
|
}, [view]);
|
|
20946
|
-
|
|
21207
|
+
React35.useEffect(() => {
|
|
20947
21208
|
if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet)
|
|
20948
21209
|
return;
|
|
20949
21210
|
let cancelled = false;
|
|
@@ -20980,7 +21241,7 @@ function WalletConnect({
|
|
|
20980
21241
|
cancelled = true;
|
|
20981
21242
|
};
|
|
20982
21243
|
}, [view, selectedBalance, publishableKey, activeDepositWallet]);
|
|
20983
|
-
|
|
21244
|
+
React35.useEffect(() => {
|
|
20984
21245
|
if (!activeWalletInfo || !activeDepositWallet) return;
|
|
20985
21246
|
let cancelled = false;
|
|
20986
21247
|
setIsLoading(true);
|
|
@@ -21045,21 +21306,21 @@ function WalletConnect({
|
|
|
21045
21306
|
defaultSourceTokenAddress,
|
|
21046
21307
|
defaultSourceSymbol
|
|
21047
21308
|
]);
|
|
21048
|
-
const usdToTokenRate =
|
|
21309
|
+
const usdToTokenRate = React35.useMemo(() => {
|
|
21049
21310
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
21050
21311
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
21051
21312
|
const balanceUsd = parseFloat(selectedBalance.amount_usd);
|
|
21052
21313
|
if (balanceAmount === 0 || balanceUsd === 0) return 0;
|
|
21053
21314
|
return balanceAmount / balanceUsd;
|
|
21054
21315
|
}, [selectedBalance, selectedToken]);
|
|
21055
|
-
const tokenAmount =
|
|
21316
|
+
const tokenAmount = React35.useMemo(() => {
|
|
21056
21317
|
if (isCheckoutMode && activeCheckoutQuote && selectedToken)
|
|
21057
21318
|
return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
|
|
21058
21319
|
const usdNum = parseFloat(amountUsd) || 0;
|
|
21059
21320
|
if (usdNum === 0 || usdToTokenRate === 0) return 0;
|
|
21060
21321
|
return usdNum * usdToTokenRate;
|
|
21061
21322
|
}, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
|
|
21062
|
-
|
|
21323
|
+
React35.useEffect(() => {
|
|
21063
21324
|
if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount")
|
|
21064
21325
|
setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
|
|
21065
21326
|
}, [isCheckoutMode, activeCheckoutQuote, view]);
|
|
@@ -21068,7 +21329,7 @@ function WalletConnect({
|
|
|
21068
21329
|
const inputUsdNum = parseFloat(amountUsd) || 0;
|
|
21069
21330
|
const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
|
|
21070
21331
|
const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
|
|
21071
|
-
const formattedTokenAmount =
|
|
21332
|
+
const formattedTokenAmount = React35.useMemo(() => {
|
|
21072
21333
|
if (tokenAmount === 0 || !selectedToken) return null;
|
|
21073
21334
|
return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
|
|
21074
21335
|
}, [tokenAmount, selectedToken]);
|
|
@@ -21101,7 +21362,7 @@ function WalletConnect({
|
|
|
21101
21362
|
break;
|
|
21102
21363
|
case "enter_amount":
|
|
21103
21364
|
transitionTo("select_token");
|
|
21104
|
-
setAmountUsd(
|
|
21365
|
+
setAmountUsd(prefilledAmountUsd ?? "");
|
|
21105
21366
|
setTokenChainDetails(null);
|
|
21106
21367
|
break;
|
|
21107
21368
|
case "review":
|
|
@@ -21133,7 +21394,7 @@ function WalletConnect({
|
|
|
21133
21394
|
setSelectedBalance(null);
|
|
21134
21395
|
setBalances([]);
|
|
21135
21396
|
setTotalBalanceUsd(null);
|
|
21136
|
-
setAmountUsd(
|
|
21397
|
+
setAmountUsd(prefilledAmountUsd ?? "");
|
|
21137
21398
|
setError(null);
|
|
21138
21399
|
};
|
|
21139
21400
|
if (standalone) {
|
|
@@ -21860,6 +22121,15 @@ function SkeletonButton({ variant = "default" }) {
|
|
|
21860
22121
|
] });
|
|
21861
22122
|
}
|
|
21862
22123
|
var t8 = i18n.depositModal;
|
|
22124
|
+
function normalizePrefilledUsdAmount(value) {
|
|
22125
|
+
if (!value) return void 0;
|
|
22126
|
+
const cleaned = value.replace(/[^0-9.]/g, "");
|
|
22127
|
+
if (!cleaned) return void 0;
|
|
22128
|
+
const normalizedNumeric = cleaned.replace(/(\..*)\./g, "$1");
|
|
22129
|
+
const parsed = parseFloat(normalizedNumeric);
|
|
22130
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return void 0;
|
|
22131
|
+
return parseFloat(parsed.toFixed(2)).toString();
|
|
22132
|
+
}
|
|
21863
22133
|
function depositTabForScreen(screen) {
|
|
21864
22134
|
return screen === "card" || screen === "cashapp" || screen === "bank_transfer" || screen === "stripe_link" || screen === "apple_pay" ? "cash" : "crypto";
|
|
21865
22135
|
}
|
|
@@ -21879,6 +22149,7 @@ function DepositModal({
|
|
|
21879
22149
|
defaultSourceChainId,
|
|
21880
22150
|
defaultSourceTokenAddress,
|
|
21881
22151
|
defaultSourceSymbol,
|
|
22152
|
+
prefilledAmountUsd,
|
|
21882
22153
|
hideDepositTracker,
|
|
21883
22154
|
showBalanceHeader = false,
|
|
21884
22155
|
transferInputVariant = "double_input",
|
|
@@ -21914,6 +22185,10 @@ function DepositModal({
|
|
|
21914
22185
|
depositTrackerSubTitle = t8.depositTracker.subtitle
|
|
21915
22186
|
}) {
|
|
21916
22187
|
const { colors: colors2, fonts, components } = useTheme();
|
|
22188
|
+
const normalizedPrefilledAmountUsd = (0, import_react26.useMemo)(
|
|
22189
|
+
() => normalizePrefilledUsdAmount(prefilledAmountUsd),
|
|
22190
|
+
[prefilledAmountUsd]
|
|
22191
|
+
);
|
|
21917
22192
|
const onDepositSuccessFor = (0, import_react26.useCallback)(
|
|
21918
22193
|
(method) => onDepositSuccess || onEvent ? (data) => {
|
|
21919
22194
|
const payload = { ...data, method };
|
|
@@ -22779,6 +23054,7 @@ function DepositModal({
|
|
|
22779
23054
|
defaultSourceChainId,
|
|
22780
23055
|
defaultSourceTokenAddress,
|
|
22781
23056
|
defaultSourceSymbol,
|
|
23057
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd,
|
|
22782
23058
|
depositConfirmationMode,
|
|
22783
23059
|
onExecutionsChange: setDepositExecutions,
|
|
22784
23060
|
onDepositSuccess: onDepositSuccessFor("transfer"),
|
|
@@ -22798,6 +23074,7 @@ function DepositModal({
|
|
|
22798
23074
|
defaultSourceChainId,
|
|
22799
23075
|
defaultSourceTokenAddress,
|
|
22800
23076
|
defaultSourceSymbol,
|
|
23077
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd,
|
|
22801
23078
|
depositConfirmationMode,
|
|
22802
23079
|
onExecutionsChange: setDepositExecutions,
|
|
22803
23080
|
onDepositSuccess: onDepositSuccessFor("transfer"),
|
|
@@ -22882,7 +23159,8 @@ function DepositModal({
|
|
|
22882
23159
|
wallets,
|
|
22883
23160
|
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
22884
23161
|
hideDepositFlowInfo,
|
|
22885
|
-
hideDisplayDescription
|
|
23162
|
+
hideDisplayDescription,
|
|
23163
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd
|
|
22886
23164
|
}
|
|
22887
23165
|
),
|
|
22888
23166
|
depositPoweredByFooter
|
|
@@ -22947,7 +23225,8 @@ function DepositModal({
|
|
|
22947
23225
|
defaultSourceChainType,
|
|
22948
23226
|
defaultSourceChainId,
|
|
22949
23227
|
defaultSourceTokenAddress,
|
|
22950
|
-
defaultSourceSymbol
|
|
23228
|
+
defaultSourceSymbol,
|
|
23229
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd
|
|
22951
23230
|
}
|
|
22952
23231
|
),
|
|
22953
23232
|
depositPoweredByFooter
|
|
@@ -22979,6 +23258,7 @@ function DepositModal({
|
|
|
22979
23258
|
onDepositSuccess: onDepositSuccessFor("wallet_connect"),
|
|
22980
23259
|
onDepositError: onDepositErrorFor("wallet_connect"),
|
|
22981
23260
|
amountQuickSelect: browserWalletAmountQuickSelect,
|
|
23261
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd,
|
|
22982
23262
|
onWalletDisconnect: handleWalletDisconnect,
|
|
22983
23263
|
onWalletConnected: (info, dw) => {
|
|
22984
23264
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
@@ -23027,7 +23307,8 @@ function DepositModal({
|
|
|
23027
23307
|
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
23028
23308
|
onEvent,
|
|
23029
23309
|
onDepositSuccess,
|
|
23030
|
-
onDepositError
|
|
23310
|
+
onDepositError,
|
|
23311
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd
|
|
23031
23312
|
}
|
|
23032
23313
|
),
|
|
23033
23314
|
depositPoweredByFooter
|
|
@@ -23039,7 +23320,7 @@ function DepositModal({
|
|
|
23039
23320
|
title: "Deposit with Link",
|
|
23040
23321
|
showBack: stripeLinkStep !== "checkout" && stripeLinkStep !== "success",
|
|
23041
23322
|
onBack: handleBack,
|
|
23042
|
-
showClose: stripeLinkStep !== "checkout",
|
|
23323
|
+
showClose: stripeLinkStep !== "checkout" && stripeLinkStep !== "auth",
|
|
23043
23324
|
onClose: handleClose
|
|
23044
23325
|
}
|
|
23045
23326
|
),
|
|
@@ -23070,6 +23351,8 @@ function DepositModal({
|
|
|
23070
23351
|
destinationChainType,
|
|
23071
23352
|
destinationChainId,
|
|
23072
23353
|
destinationTokenAddress,
|
|
23354
|
+
countryCode: userIpInfo?.alpha2,
|
|
23355
|
+
subdivisionCode: userIpInfo?.subdivisionCode ?? void 0,
|
|
23073
23356
|
wallets,
|
|
23074
23357
|
email: userEmail,
|
|
23075
23358
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/link.svg` : void 0,
|
|
@@ -23109,6 +23392,7 @@ function DepositModal({
|
|
|
23109
23392
|
onEvent,
|
|
23110
23393
|
onDepositSuccess: onDepositSuccessFor("cashapp"),
|
|
23111
23394
|
onDepositError: onDepositErrorFor("cashapp"),
|
|
23395
|
+
prefilledAmountUsd: normalizedPrefilledAmountUsd,
|
|
23112
23396
|
wallets
|
|
23113
23397
|
}
|
|
23114
23398
|
),
|
|
@@ -23170,12 +23454,12 @@ var import_react27 = require("react");
|
|
|
23170
23454
|
var import_lucide_react38 = require("lucide-react");
|
|
23171
23455
|
|
|
23172
23456
|
// src/hooks/use-payment-intent.ts
|
|
23173
|
-
var
|
|
23457
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
23174
23458
|
var import_core38 = require("@unifold/core");
|
|
23175
23459
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
|
|
23176
23460
|
function usePaymentIntent(params) {
|
|
23177
23461
|
const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
|
|
23178
|
-
return (0,
|
|
23462
|
+
return (0, import_react_query18.useQuery)({
|
|
23179
23463
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
23180
23464
|
queryFn: () => (0, import_core38.retrievePaymentIntent)(clientSecret, publishableKey),
|
|
23181
23465
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
@@ -23820,7 +24104,7 @@ function CheckoutModal({
|
|
|
23820
24104
|
userId: paymentIntent.user_id || "",
|
|
23821
24105
|
publishableKey,
|
|
23822
24106
|
clientSecret,
|
|
23823
|
-
|
|
24107
|
+
prefilledAmountUsd: remainingAmountUsd,
|
|
23824
24108
|
checkoutAmountUsd: paymentIntent.amount_usd,
|
|
23825
24109
|
checkoutReceivedUsd: paymentIntent.amount_received_usd,
|
|
23826
24110
|
checkoutDestination: {
|
|
@@ -23886,10 +24170,10 @@ var import_react32 = require("react");
|
|
|
23886
24170
|
var import_lucide_react41 = require("lucide-react");
|
|
23887
24171
|
|
|
23888
24172
|
// src/hooks/use-supported-destination-tokens.ts
|
|
23889
|
-
var
|
|
24173
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
23890
24174
|
var import_core40 = require("@unifold/core");
|
|
23891
24175
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
23892
|
-
return (0,
|
|
24176
|
+
return (0, import_react_query19.useQuery)({
|
|
23893
24177
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
23894
24178
|
queryFn: () => (0, import_core40.getSupportedDestinationTokens)(publishableKey),
|
|
23895
24179
|
staleTime: 1e3 * 60 * 5,
|
|
@@ -23918,7 +24202,7 @@ function useDefaultDestinationToken({
|
|
|
23918
24202
|
}
|
|
23919
24203
|
|
|
23920
24204
|
// src/hooks/use-source-token-validation.ts
|
|
23921
|
-
var
|
|
24205
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
23922
24206
|
var import_core41 = require("@unifold/core");
|
|
23923
24207
|
function useSourceTokenValidation(params) {
|
|
23924
24208
|
const {
|
|
@@ -23930,7 +24214,7 @@ function useSourceTokenValidation(params) {
|
|
|
23930
24214
|
enabled = true
|
|
23931
24215
|
} = params;
|
|
23932
24216
|
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
23933
|
-
return (0,
|
|
24217
|
+
return (0, import_react_query20.useQuery)({
|
|
23934
24218
|
queryKey: [
|
|
23935
24219
|
"unifold",
|
|
23936
24220
|
"sourceTokenValidation",
|
|
@@ -23978,12 +24262,12 @@ function useSourceTokenValidation(params) {
|
|
|
23978
24262
|
}
|
|
23979
24263
|
|
|
23980
24264
|
// src/hooks/use-address-balance.ts
|
|
23981
|
-
var
|
|
24265
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
23982
24266
|
var import_core42 = require("@unifold/core");
|
|
23983
24267
|
function useAddressBalance(params) {
|
|
23984
24268
|
const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
|
|
23985
24269
|
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
23986
|
-
return (0,
|
|
24270
|
+
return (0, import_react_query21.useQuery)({
|
|
23987
24271
|
queryKey: [
|
|
23988
24272
|
"unifold",
|
|
23989
24273
|
"addressBalance",
|
|
@@ -24039,11 +24323,11 @@ function useAddressBalance(params) {
|
|
|
24039
24323
|
}
|
|
24040
24324
|
|
|
24041
24325
|
// src/hooks/use-executions.ts
|
|
24042
|
-
var
|
|
24326
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
24043
24327
|
var import_core43 = require("@unifold/core");
|
|
24044
24328
|
function useExecutions(userId, publishableKey, options) {
|
|
24045
24329
|
const actionType = options?.actionType ?? import_core43.ActionType.Deposit;
|
|
24046
|
-
return (0,
|
|
24330
|
+
return (0, import_react_query22.useQuery)({
|
|
24047
24331
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
24048
24332
|
queryFn: () => (0, import_core43.queryExecutions)(userId, publishableKey, actionType),
|
|
24049
24333
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
@@ -24372,7 +24656,7 @@ var import_lucide_react39 = require("lucide-react");
|
|
|
24372
24656
|
var import_core49 = require("@unifold/core");
|
|
24373
24657
|
|
|
24374
24658
|
// src/hooks/use-verify-recipient-address.ts
|
|
24375
|
-
var
|
|
24659
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
24376
24660
|
var import_core45 = require("@unifold/core");
|
|
24377
24661
|
function useVerifyRecipientAddress(params) {
|
|
24378
24662
|
const {
|
|
@@ -24385,7 +24669,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
24385
24669
|
} = params;
|
|
24386
24670
|
const trimmedAddress = recipientAddress?.trim() || "";
|
|
24387
24671
|
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
24388
|
-
return (0,
|
|
24672
|
+
return (0, import_react_query23.useQuery)({
|
|
24389
24673
|
queryKey: [
|
|
24390
24674
|
"unifold",
|
|
24391
24675
|
"verifyRecipientAddress",
|
|
@@ -24633,7 +24917,7 @@ var import_react29 = require("react");
|
|
|
24633
24917
|
var import_core48 = require("@unifold/core");
|
|
24634
24918
|
|
|
24635
24919
|
// src/hooks/use-get-deposit-address.ts
|
|
24636
|
-
var
|
|
24920
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
24637
24921
|
var import_core47 = require("@unifold/core");
|
|
24638
24922
|
function useGetDepositAddress(params) {
|
|
24639
24923
|
const {
|
|
@@ -24647,7 +24931,7 @@ function useGetDepositAddress(params) {
|
|
|
24647
24931
|
enabled = true
|
|
24648
24932
|
} = params;
|
|
24649
24933
|
const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
24650
|
-
return (0,
|
|
24934
|
+
return (0, import_react_query24.useQuery)({
|
|
24651
24935
|
queryKey: [
|
|
24652
24936
|
"unifold",
|
|
24653
24937
|
"getDepositAddress",
|