@unifold/ui-react 0.1.6 → 0.1.7
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 +58 -42
- package/dist/index.d.ts +58 -42
- package/dist/index.js +192 -154
- package/dist/index.mjs +192 -154
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
94
94
|
|
|
95
95
|
// src/components/deposits/DepositModal.tsx
|
|
96
96
|
var import_react6 = require("react");
|
|
97
|
+
var import_lucide_react12 = require("lucide-react");
|
|
97
98
|
|
|
98
99
|
// src/components/shared/dialog.tsx
|
|
99
100
|
var React2 = __toESM(require("react"));
|
|
@@ -527,6 +528,20 @@ async function getFiatCurrencies(publishableKey) {
|
|
|
527
528
|
}
|
|
528
529
|
return response.json();
|
|
529
530
|
}
|
|
531
|
+
async function getProjectConfig(publishableKey) {
|
|
532
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
533
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/projects/config`, {
|
|
534
|
+
method: "GET",
|
|
535
|
+
headers: {
|
|
536
|
+
accept: "application/json",
|
|
537
|
+
"x-publishable-key": pk
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
if (!response.ok) {
|
|
541
|
+
throw new Error(`Failed to fetch project config: ${response.statusText}`);
|
|
542
|
+
}
|
|
543
|
+
return response.json();
|
|
544
|
+
}
|
|
530
545
|
|
|
531
546
|
// src/components/deposits/DepositExecutionItem.tsx
|
|
532
547
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1001,15 +1016,17 @@ function TransferCryptoBase({
|
|
|
1001
1016
|
showDetailedDropdowns = false,
|
|
1002
1017
|
onExecutionsChange,
|
|
1003
1018
|
onDepositSuccess,
|
|
1004
|
-
onDepositError
|
|
1019
|
+
onDepositError,
|
|
1020
|
+
wallets: externalWallets
|
|
1005
1021
|
}) {
|
|
1006
1022
|
const { themeClass } = useTheme();
|
|
1007
1023
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
1008
1024
|
const [token, setToken] = (0, import_react3.useState)("USDC");
|
|
1009
1025
|
const [chain, setChain] = (0, import_react3.useState)("solana:mainnet");
|
|
1010
1026
|
const [copied, setCopied] = (0, import_react3.useState)(false);
|
|
1011
|
-
const [
|
|
1012
|
-
const [loading, setLoading] = (0, import_react3.useState)(
|
|
1027
|
+
const [internalWallets, setInternalWallets] = (0, import_react3.useState)([]);
|
|
1028
|
+
const [loading, setLoading] = (0, import_react3.useState)(!externalWallets?.length);
|
|
1029
|
+
const wallets = externalWallets?.length ? externalWallets : internalWallets;
|
|
1013
1030
|
const [error, setError] = (0, import_react3.useState)(null);
|
|
1014
1031
|
const [depositExecutions, setDepositExecutions] = (0, import_react3.useState)([]);
|
|
1015
1032
|
const [trackedExecutions, setTrackedExecutions] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
|
|
@@ -1073,9 +1090,16 @@ function TransferCryptoBase({
|
|
|
1073
1090
|
}
|
|
1074
1091
|
}, [depositExecutions, onExecutionsChange]);
|
|
1075
1092
|
(0, import_react3.useEffect)(() => {
|
|
1076
|
-
|
|
1093
|
+
if (externalWallets?.length) {
|
|
1094
|
+
setLoading(false);
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
let retryTimeout = null;
|
|
1098
|
+
let isCancelled = false;
|
|
1099
|
+
const fetchWallets = async () => {
|
|
1100
|
+
if (isCancelled) return;
|
|
1101
|
+
setLoading(true);
|
|
1077
1102
|
try {
|
|
1078
|
-
setLoading(true);
|
|
1079
1103
|
const response = await createEOA(
|
|
1080
1104
|
{
|
|
1081
1105
|
user_id: userId,
|
|
@@ -1086,23 +1110,35 @@ function TransferCryptoBase({
|
|
|
1086
1110
|
},
|
|
1087
1111
|
publishableKey
|
|
1088
1112
|
);
|
|
1089
|
-
|
|
1090
|
-
|
|
1113
|
+
if (!isCancelled) {
|
|
1114
|
+
setInternalWallets(response.data);
|
|
1115
|
+
setError(null);
|
|
1116
|
+
setLoading(false);
|
|
1117
|
+
}
|
|
1091
1118
|
} catch (err) {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1119
|
+
console.error("Error fetching wallets, retrying in 5s:", err);
|
|
1120
|
+
if (!isCancelled) {
|
|
1121
|
+
setError(err instanceof Error ? err.message : "Failed to load wallets");
|
|
1122
|
+
setLoading(false);
|
|
1123
|
+
retryTimeout = setTimeout(fetchWallets, 5e3);
|
|
1124
|
+
}
|
|
1096
1125
|
}
|
|
1097
|
-
}
|
|
1126
|
+
};
|
|
1098
1127
|
fetchWallets();
|
|
1128
|
+
return () => {
|
|
1129
|
+
isCancelled = true;
|
|
1130
|
+
if (retryTimeout) {
|
|
1131
|
+
clearTimeout(retryTimeout);
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1099
1134
|
}, [
|
|
1100
1135
|
userId,
|
|
1101
1136
|
recipientAddress,
|
|
1102
1137
|
destinationChainType,
|
|
1103
1138
|
destinationChainId,
|
|
1104
1139
|
destinationTokenAddress,
|
|
1105
|
-
publishableKey
|
|
1140
|
+
publishableKey,
|
|
1141
|
+
externalWallets
|
|
1106
1142
|
]);
|
|
1107
1143
|
(0, import_react3.useEffect)(() => {
|
|
1108
1144
|
if (!supportedTokens.length) return;
|
|
@@ -1353,7 +1389,7 @@ function TransferCryptoBase({
|
|
|
1353
1389
|
{
|
|
1354
1390
|
value: depositAddress,
|
|
1355
1391
|
size: 180,
|
|
1356
|
-
imageUrl: currentChainData?.icon_url || currentChainFromBackend?.icon_url
|
|
1392
|
+
imageUrl: currentChainData?.icon_url || currentChainFromBackend?.icon_url,
|
|
1357
1393
|
imageSize: 45,
|
|
1358
1394
|
darkMode: isDarkMode
|
|
1359
1395
|
},
|
|
@@ -1570,7 +1606,7 @@ function TransferCryptoBase({
|
|
|
1570
1606
|
orderSubmittedAt: depositExecutions[0].created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1571
1607
|
orderFilledAt: depositExecutions[0].updated_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1572
1608
|
explorerUrl: depositExecutions[0].explorer_url,
|
|
1573
|
-
completionExplorerUrl: depositExecutions[0].
|
|
1609
|
+
completionExplorerUrl: depositExecutions[0].destination_explorer_url ?? void 0,
|
|
1574
1610
|
status: depositExecutions[0].status,
|
|
1575
1611
|
tokenIconUrl: depositExecutions[0].source_token_metadata?.icon_url,
|
|
1576
1612
|
onClose: () => setDepositExecutions([])
|
|
@@ -1620,6 +1656,7 @@ function CurrencyListItem({
|
|
|
1620
1656
|
isSelected,
|
|
1621
1657
|
onSelect
|
|
1622
1658
|
}) {
|
|
1659
|
+
const iconUrl = currency.icon_url;
|
|
1623
1660
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1624
1661
|
"button",
|
|
1625
1662
|
{
|
|
@@ -1627,14 +1664,14 @@ function CurrencyListItem({
|
|
|
1627
1664
|
className: "uf-w-full uf-bg-secondary hover:uf-bg-accent uf-transition-colors uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-group",
|
|
1628
1665
|
children: [
|
|
1629
1666
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
1630
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "uf-w-10 uf-h-10 uf-flex
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "uf-w-10 uf-h-10 uf-flex-shrink-0 uf-rounded-full uf-overflow-hidden uf-bg-card", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1631
1668
|
"img",
|
|
1632
1669
|
{
|
|
1633
|
-
src:
|
|
1670
|
+
src: iconUrl,
|
|
1634
1671
|
alt: currency.name,
|
|
1635
1672
|
width: 40,
|
|
1636
1673
|
height: 40,
|
|
1637
|
-
className: "uf-w-full uf-h-full uf-object-cover
|
|
1674
|
+
className: "uf-w-full uf-h-full uf-object-cover"
|
|
1638
1675
|
}
|
|
1639
1676
|
) }),
|
|
1640
1677
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "uf-text-left", children: [
|
|
@@ -1759,18 +1796,6 @@ function CurrencyModal({
|
|
|
1759
1796
|
|
|
1760
1797
|
// src/hooks/use-user-ip.ts
|
|
1761
1798
|
var import_react_query = require("@tanstack/react-query");
|
|
1762
|
-
async function getIpViaMoonpay(moonpayApiKey) {
|
|
1763
|
-
const url = `https://api.moonpay.com/v3/ip_address?apiKey=${moonpayApiKey}`;
|
|
1764
|
-
const response = await fetch(url);
|
|
1765
|
-
if (!response.ok) {
|
|
1766
|
-
throw new Error(`Moonpay IP API failed: ${response.statusText}`);
|
|
1767
|
-
}
|
|
1768
|
-
const data = await response.json();
|
|
1769
|
-
return {
|
|
1770
|
-
alpha2: data.alpha2.toLowerCase(),
|
|
1771
|
-
state: data.state?.toLowerCase()
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
1799
|
async function getIpViaIpApi() {
|
|
1775
1800
|
const url = "https://ipapi.co/json";
|
|
1776
1801
|
const response = await fetch(url);
|
|
@@ -1783,7 +1808,7 @@ async function getIpViaIpApi() {
|
|
|
1783
1808
|
state: data.region_code?.toLowerCase()
|
|
1784
1809
|
};
|
|
1785
1810
|
}
|
|
1786
|
-
function useUserIp(
|
|
1811
|
+
function useUserIp() {
|
|
1787
1812
|
const {
|
|
1788
1813
|
data: userIpInfo,
|
|
1789
1814
|
isLoading,
|
|
@@ -1791,21 +1816,12 @@ function useUserIp(moonpayApiKey) {
|
|
|
1791
1816
|
} = (0, import_react_query.useQuery)({
|
|
1792
1817
|
queryKey: ["getUserIpInfo"],
|
|
1793
1818
|
queryFn: async () => {
|
|
1794
|
-
if (moonpayApiKey) {
|
|
1795
|
-
try {
|
|
1796
|
-
const moonpayIpData = await getIpViaMoonpay(moonpayApiKey);
|
|
1797
|
-
console.log("IP detected via Moonpay:", moonpayIpData);
|
|
1798
|
-
return moonpayIpData;
|
|
1799
|
-
} catch (error2) {
|
|
1800
|
-
console.warn("Moonpay IP API failed, trying fallback:", error2);
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
1819
|
try {
|
|
1804
1820
|
const ipApiData = await getIpViaIpApi();
|
|
1805
1821
|
console.log("IP detected via ipapi.co:", ipApiData);
|
|
1806
1822
|
return ipApiData;
|
|
1807
1823
|
} catch (ipApiError) {
|
|
1808
|
-
console.error("
|
|
1824
|
+
console.error("IP detection failed:", ipApiError);
|
|
1809
1825
|
throw ipApiError;
|
|
1810
1826
|
}
|
|
1811
1827
|
},
|
|
@@ -1854,7 +1870,8 @@ function BuyWithCard({
|
|
|
1854
1870
|
destinationChainType,
|
|
1855
1871
|
destinationChainId,
|
|
1856
1872
|
destinationTokenAddress,
|
|
1857
|
-
themeClass = ""
|
|
1873
|
+
themeClass = "",
|
|
1874
|
+
wallets: externalWallets
|
|
1858
1875
|
}) {
|
|
1859
1876
|
const [amount, setAmount] = (0, import_react5.useState)("500.00");
|
|
1860
1877
|
const [currency, setCurrency] = (0, import_react5.useState)("usd");
|
|
@@ -1889,8 +1906,9 @@ function BuyWithCard({
|
|
|
1889
1906
|
const [isAutoSelected, setIsAutoSelected] = (0, import_react5.useState)(true);
|
|
1890
1907
|
const [autoSelectedProvider, setAutoSelectedProvider] = (0, import_react5.useState)(null);
|
|
1891
1908
|
const [hasManualSelection, setHasManualSelection] = (0, import_react5.useState)(false);
|
|
1892
|
-
const [
|
|
1893
|
-
const [walletsLoading, setWalletsLoading] = (0, import_react5.useState)(
|
|
1909
|
+
const [internalWallets, setInternalWallets] = (0, import_react5.useState)([]);
|
|
1910
|
+
const [walletsLoading, setWalletsLoading] = (0, import_react5.useState)(!externalWallets?.length);
|
|
1911
|
+
const wallets = externalWallets?.length ? externalWallets : internalWallets;
|
|
1894
1912
|
const [countdown, setCountdown] = (0, import_react5.useState)(60);
|
|
1895
1913
|
const [fiatCurrencies, setFiatCurrencies] = (0, import_react5.useState)([]);
|
|
1896
1914
|
const [preferredCurrencyCodes, setPreferredCurrencyCodes] = (0, import_react5.useState)([]);
|
|
@@ -1919,7 +1937,15 @@ function BuyWithCard({
|
|
|
1919
1937
|
fetchFiatCurrencies();
|
|
1920
1938
|
}, [publishableKey]);
|
|
1921
1939
|
(0, import_react5.useEffect)(() => {
|
|
1922
|
-
|
|
1940
|
+
if (externalWallets?.length) {
|
|
1941
|
+
setWalletsLoading(false);
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
let retryTimeout = null;
|
|
1945
|
+
let isCancelled = false;
|
|
1946
|
+
const fetchWallets = async () => {
|
|
1947
|
+
if (isCancelled) return;
|
|
1948
|
+
setWalletsLoading(true);
|
|
1923
1949
|
try {
|
|
1924
1950
|
const response = await createEOA(
|
|
1925
1951
|
{
|
|
@@ -1931,16 +1957,26 @@ function BuyWithCard({
|
|
|
1931
1957
|
},
|
|
1932
1958
|
publishableKey
|
|
1933
1959
|
);
|
|
1934
|
-
|
|
1960
|
+
if (!isCancelled) {
|
|
1961
|
+
setInternalWallets(response.data);
|
|
1962
|
+
setWalletsLoading(false);
|
|
1963
|
+
}
|
|
1935
1964
|
} catch (err) {
|
|
1936
|
-
console.error("Error fetching wallets:", err);
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1965
|
+
console.error("Error fetching wallets, retrying in 5s:", err);
|
|
1966
|
+
if (!isCancelled) {
|
|
1967
|
+
setWalletsLoading(false);
|
|
1968
|
+
retryTimeout = setTimeout(fetchWallets, 5e3);
|
|
1969
|
+
}
|
|
1940
1970
|
}
|
|
1941
|
-
}
|
|
1971
|
+
};
|
|
1942
1972
|
fetchWallets();
|
|
1943
|
-
|
|
1973
|
+
return () => {
|
|
1974
|
+
isCancelled = true;
|
|
1975
|
+
if (retryTimeout) {
|
|
1976
|
+
clearTimeout(retryTimeout);
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
}, [userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey, externalWallets]);
|
|
1944
1980
|
(0, import_react5.useEffect)(() => {
|
|
1945
1981
|
async function fetchSupportedTokens() {
|
|
1946
1982
|
try {
|
|
@@ -2434,8 +2470,10 @@ var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
|
2434
2470
|
function TransferCryptoButton({
|
|
2435
2471
|
onClick,
|
|
2436
2472
|
title,
|
|
2437
|
-
subtitle
|
|
2473
|
+
subtitle,
|
|
2474
|
+
featuredTokens
|
|
2438
2475
|
}) {
|
|
2476
|
+
const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
|
|
2439
2477
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2440
2478
|
"button",
|
|
2441
2479
|
{
|
|
@@ -2450,88 +2488,20 @@ function TransferCryptoButton({
|
|
|
2450
2488
|
] })
|
|
2451
2489
|
] }),
|
|
2452
2490
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
2453
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
{
|
|
2457
|
-
src: getIconUrl("/icons/networks/ethereum.svg"),
|
|
2458
|
-
alt: "ETH",
|
|
2459
|
-
width: 20,
|
|
2460
|
-
height: 20,
|
|
2461
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2462
|
-
}
|
|
2463
|
-
),
|
|
2464
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2465
|
-
"img",
|
|
2466
|
-
{
|
|
2467
|
-
src: getIconUrl("/icons/networks/optimism.svg"),
|
|
2468
|
-
alt: "OP",
|
|
2469
|
-
width: 20,
|
|
2470
|
-
height: 20,
|
|
2471
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2472
|
-
}
|
|
2473
|
-
),
|
|
2474
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2475
|
-
"img",
|
|
2476
|
-
{
|
|
2477
|
-
src: getIconUrl("/icons/networks/polygon.svg"),
|
|
2478
|
-
alt: "MATIC",
|
|
2479
|
-
width: 20,
|
|
2480
|
-
height: 20,
|
|
2481
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2482
|
-
}
|
|
2483
|
-
),
|
|
2484
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2485
|
-
"img",
|
|
2486
|
-
{
|
|
2487
|
-
src: getIconUrl("/icons/networks/arbitrum.svg"),
|
|
2488
|
-
alt: "ARB",
|
|
2489
|
-
width: 20,
|
|
2490
|
-
height: 20,
|
|
2491
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2492
|
-
}
|
|
2493
|
-
),
|
|
2494
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2491
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "uf-flex uf--space-x-2", children: sortedTokens.map((token) => {
|
|
2492
|
+
const iconUrl = token.icon_urls.find((u) => u.format === "svg")?.url || token.icon_urls.find((u) => u.format === "png")?.url;
|
|
2493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2495
2494
|
"img",
|
|
2496
2495
|
{
|
|
2497
|
-
src:
|
|
2498
|
-
alt:
|
|
2496
|
+
src: iconUrl,
|
|
2497
|
+
alt: token.name,
|
|
2499
2498
|
width: 20,
|
|
2500
2499
|
height: 20,
|
|
2501
2500
|
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
{
|
|
2507
|
-
src: getIconUrl("/icons/networks/solana.svg"),
|
|
2508
|
-
alt: "SOL",
|
|
2509
|
-
width: 20,
|
|
2510
|
-
height: 20,
|
|
2511
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2512
|
-
}
|
|
2513
|
-
),
|
|
2514
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2515
|
-
"img",
|
|
2516
|
-
{
|
|
2517
|
-
src: getIconUrl("/icons/tokens/avax.svg"),
|
|
2518
|
-
alt: "AVAX",
|
|
2519
|
-
width: 20,
|
|
2520
|
-
height: 20,
|
|
2521
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2522
|
-
}
|
|
2523
|
-
),
|
|
2524
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2525
|
-
"img",
|
|
2526
|
-
{
|
|
2527
|
-
src: getIconUrl("/icons/networks/bitcoin.svg"),
|
|
2528
|
-
alt: "BTC",
|
|
2529
|
-
width: 20,
|
|
2530
|
-
height: 20,
|
|
2531
|
-
className: "uf-rounded-full uf-border-2 uf-border-secondary"
|
|
2532
|
-
}
|
|
2533
|
-
)
|
|
2534
|
-
] }),
|
|
2501
|
+
},
|
|
2502
|
+
token.name
|
|
2503
|
+
);
|
|
2504
|
+
}) }),
|
|
2535
2505
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react9.ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted-foreground group-hover:uf-text-foreground uf-transition-colors" })
|
|
2536
2506
|
] })
|
|
2537
2507
|
]
|
|
@@ -2545,7 +2515,8 @@ var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
|
2545
2515
|
function DepositWithCardButton({
|
|
2546
2516
|
onClick,
|
|
2547
2517
|
title,
|
|
2548
|
-
subtitle
|
|
2518
|
+
subtitle,
|
|
2519
|
+
paymentNetworks
|
|
2549
2520
|
}) {
|
|
2550
2521
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2551
2522
|
"button",
|
|
@@ -2561,28 +2532,20 @@ function DepositWithCardButton({
|
|
|
2561
2532
|
] })
|
|
2562
2533
|
] }),
|
|
2563
2534
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
2564
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
{
|
|
2568
|
-
src: getIconUrl("/icons/networks/mastercard.svg"),
|
|
2569
|
-
alt: "Mastercard",
|
|
2570
|
-
width: 32,
|
|
2571
|
-
height: 32,
|
|
2572
|
-
className: "uf-rounded"
|
|
2573
|
-
}
|
|
2574
|
-
),
|
|
2575
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2535
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5", children: paymentNetworks?.map((network) => {
|
|
2536
|
+
const iconUrl = network.icon_urls.find((u) => u.format === "svg")?.url || network.icon_urls.find((u) => u.format === "png")?.url;
|
|
2537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2576
2538
|
"img",
|
|
2577
2539
|
{
|
|
2578
|
-
src:
|
|
2579
|
-
alt:
|
|
2540
|
+
src: iconUrl,
|
|
2541
|
+
alt: network.name,
|
|
2580
2542
|
width: 32,
|
|
2581
2543
|
height: 32,
|
|
2582
2544
|
className: "uf-rounded"
|
|
2583
|
-
}
|
|
2584
|
-
|
|
2585
|
-
|
|
2545
|
+
},
|
|
2546
|
+
network.name
|
|
2547
|
+
);
|
|
2548
|
+
}) }),
|
|
2586
2549
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted-foreground group-hover:uf-text-foreground uf-transition-colors" })
|
|
2587
2550
|
] })
|
|
2588
2551
|
]
|
|
@@ -2623,6 +2586,21 @@ function DepositTrackerButton({
|
|
|
2623
2586
|
|
|
2624
2587
|
// src/components/deposits/DepositModal.tsx
|
|
2625
2588
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2589
|
+
function SkeletonButton({ variant = "default" }) {
|
|
2590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-animate-pulse", children: [
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-bg-muted uf-rounded-lg uf-w-9 uf-h-9" }),
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-space-y-1.5", children: [
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-h-3.5 uf-w-24 uf-bg-muted uf-rounded" }),
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded" })
|
|
2596
|
+
] })
|
|
2597
|
+
] }),
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
2599
|
+
variant === "with-icons" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf--space-x-1", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-w-5 uf-h-5 uf-rounded-full uf-bg-muted uf-border-2 uf-border-secondary" }, i)) }),
|
|
2600
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react12.ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted" })
|
|
2601
|
+
] })
|
|
2602
|
+
] });
|
|
2603
|
+
}
|
|
2626
2604
|
var t3 = i18n.depositModal;
|
|
2627
2605
|
function DepositModal({
|
|
2628
2606
|
open,
|
|
@@ -2647,6 +2625,15 @@ function DepositModal({
|
|
|
2647
2625
|
const [quotesCount, setQuotesCount] = (0, import_react6.useState)(0);
|
|
2648
2626
|
const [depositsModalOpen, setDepositsModalOpen] = (0, import_react6.useState)(false);
|
|
2649
2627
|
const [depositExecutions, setDepositExecutions] = (0, import_react6.useState)([]);
|
|
2628
|
+
const [projectConfig, setProjectConfig] = (0, import_react6.useState)(null);
|
|
2629
|
+
const [wallets, setWallets] = (0, import_react6.useState)([]);
|
|
2630
|
+
const [walletsLoading, setWalletsLoading] = (0, import_react6.useState)(false);
|
|
2631
|
+
(0, import_react6.useEffect)(() => {
|
|
2632
|
+
setProjectConfig(null);
|
|
2633
|
+
}, [publishableKey]);
|
|
2634
|
+
(0, import_react6.useEffect)(() => {
|
|
2635
|
+
setWallets([]);
|
|
2636
|
+
}, [userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey]);
|
|
2650
2637
|
const [resolvedTheme, setResolvedTheme] = (0, import_react6.useState)(theme === "auto" ? "dark" : theme);
|
|
2651
2638
|
(0, import_react6.useEffect)(() => {
|
|
2652
2639
|
if (theme === "auto") {
|
|
@@ -2661,6 +2648,49 @@ function DepositModal({
|
|
|
2661
2648
|
setResolvedTheme(theme);
|
|
2662
2649
|
}
|
|
2663
2650
|
}, [theme]);
|
|
2651
|
+
(0, import_react6.useEffect)(() => {
|
|
2652
|
+
if (open && !projectConfig) {
|
|
2653
|
+
getProjectConfig(publishableKey).then(setProjectConfig).catch(console.error);
|
|
2654
|
+
}
|
|
2655
|
+
}, [open, publishableKey, projectConfig]);
|
|
2656
|
+
(0, import_react6.useEffect)(() => {
|
|
2657
|
+
if (!open || wallets.length > 0) return;
|
|
2658
|
+
let retryTimeout = null;
|
|
2659
|
+
let isCancelled = false;
|
|
2660
|
+
const fetchWallets = async () => {
|
|
2661
|
+
if (isCancelled) return;
|
|
2662
|
+
setWalletsLoading(true);
|
|
2663
|
+
try {
|
|
2664
|
+
const response = await createEOA(
|
|
2665
|
+
{
|
|
2666
|
+
user_id: userId,
|
|
2667
|
+
recipient_address: recipientAddress,
|
|
2668
|
+
destination_chain_type: destinationChainType,
|
|
2669
|
+
destination_chain_id: destinationChainId,
|
|
2670
|
+
destination_token_address: destinationTokenAddress
|
|
2671
|
+
},
|
|
2672
|
+
publishableKey
|
|
2673
|
+
);
|
|
2674
|
+
if (!isCancelled) {
|
|
2675
|
+
setWallets(response.data);
|
|
2676
|
+
setWalletsLoading(false);
|
|
2677
|
+
}
|
|
2678
|
+
} catch (error) {
|
|
2679
|
+
console.error("Error fetching wallets, retrying in 5s:", error);
|
|
2680
|
+
if (!isCancelled) {
|
|
2681
|
+
setWalletsLoading(false);
|
|
2682
|
+
retryTimeout = setTimeout(fetchWallets, 5e3);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
fetchWallets();
|
|
2687
|
+
return () => {
|
|
2688
|
+
isCancelled = true;
|
|
2689
|
+
if (retryTimeout) {
|
|
2690
|
+
clearTimeout(retryTimeout);
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
}, [open, userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey, wallets.length]);
|
|
2664
2694
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
2665
2695
|
const handleClose = () => {
|
|
2666
2696
|
onOpenChange(false);
|
|
@@ -2700,13 +2730,18 @@ function DepositModal({
|
|
|
2700
2730
|
onClose: handleClose
|
|
2701
2731
|
}
|
|
2702
2732
|
),
|
|
2703
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.
|
|
2733
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: !projectConfig ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
2735
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
2736
|
+
!hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SkeletonButton, {})
|
|
2737
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2704
2738
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2705
2739
|
TransferCryptoButton,
|
|
2706
2740
|
{
|
|
2707
2741
|
onClick: () => setView("transfer"),
|
|
2708
2742
|
title: t3.transferCrypto.title,
|
|
2709
|
-
subtitle: t3.transferCrypto.subtitle
|
|
2743
|
+
subtitle: t3.transferCrypto.subtitle,
|
|
2744
|
+
featuredTokens: projectConfig.transfer_crypto.networks
|
|
2710
2745
|
}
|
|
2711
2746
|
),
|
|
2712
2747
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
@@ -2714,7 +2749,8 @@ function DepositModal({
|
|
|
2714
2749
|
{
|
|
2715
2750
|
onClick: () => setView("card"),
|
|
2716
2751
|
title: t3.depositWithCard.title,
|
|
2717
|
-
subtitle: t3.depositWithCard.subtitle
|
|
2752
|
+
subtitle: t3.depositWithCard.subtitle,
|
|
2753
|
+
paymentNetworks: projectConfig.payment_networks.networks
|
|
2718
2754
|
}
|
|
2719
2755
|
),
|
|
2720
2756
|
!hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
@@ -2726,7 +2762,7 @@ function DepositModal({
|
|
|
2726
2762
|
badge: depositExecutions.length > 0 ? depositExecutions.length : void 0
|
|
2727
2763
|
}
|
|
2728
2764
|
)
|
|
2729
|
-
] })
|
|
2765
|
+
] }) })
|
|
2730
2766
|
] }) : view === "transfer" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2731
2767
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2732
2768
|
DepositHeader,
|
|
@@ -2748,7 +2784,8 @@ function DepositModal({
|
|
|
2748
2784
|
destinationTokenAddress,
|
|
2749
2785
|
onExecutionsChange: setDepositExecutions,
|
|
2750
2786
|
onDepositSuccess,
|
|
2751
|
-
onDepositError
|
|
2787
|
+
onDepositError,
|
|
2788
|
+
wallets
|
|
2752
2789
|
}
|
|
2753
2790
|
)
|
|
2754
2791
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
@@ -2776,7 +2813,8 @@ function DepositModal({
|
|
|
2776
2813
|
destinationTokenAddress,
|
|
2777
2814
|
onDepositSuccess,
|
|
2778
2815
|
onDepositError,
|
|
2779
|
-
themeClass
|
|
2816
|
+
themeClass,
|
|
2817
|
+
wallets
|
|
2780
2818
|
}
|
|
2781
2819
|
)
|
|
2782
2820
|
] })
|