@unifold/connect-react 0.1.21 → 0.1.22
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +439 -111
- package/dist/index.mjs +479 -151
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1181,7 +1181,7 @@ __export(index_exports, {
|
|
|
1181
1181
|
module.exports = __toCommonJS(index_exports);
|
|
1182
1182
|
|
|
1183
1183
|
// src/provider.tsx
|
|
1184
|
-
var
|
|
1184
|
+
var import_react21 = __toESM(require("react"));
|
|
1185
1185
|
|
|
1186
1186
|
// ../react-provider/dist/index.mjs
|
|
1187
1187
|
var import_react = require("react");
|
|
@@ -6320,12 +6320,14 @@ async function getTokenChains() {
|
|
|
6320
6320
|
return response.json();
|
|
6321
6321
|
}
|
|
6322
6322
|
function getChainName(chains, chainType, chainId) {
|
|
6323
|
+
if (!chainType && !chainId) return "Unknown";
|
|
6323
6324
|
const target = chains.find((c) => c.chain_id === chainId && c.chain_type === chainType);
|
|
6324
6325
|
if (target) return target.chain_name;
|
|
6325
6326
|
const byId = chains.find((c) => c.chain_id === chainId);
|
|
6326
6327
|
if (byId) return byId.chain_name;
|
|
6327
6328
|
const byType = chains.find((c) => c.chain_type === chainType);
|
|
6328
6329
|
if (byType) return byType.chain_name;
|
|
6330
|
+
if (!chainType) return chainId || "Unknown";
|
|
6329
6331
|
return chainType.charAt(0).toUpperCase() + chainType.slice(1);
|
|
6330
6332
|
}
|
|
6331
6333
|
async function getProjectConfig(publishableKey) {
|
|
@@ -6359,6 +6361,49 @@ async function getIpAddress() {
|
|
|
6359
6361
|
}
|
|
6360
6362
|
return response.json();
|
|
6361
6363
|
}
|
|
6364
|
+
async function getAddressBalance(address, chainType, chainId, tokenAddress, publishableKey) {
|
|
6365
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6366
|
+
validatePublishableKey(pk);
|
|
6367
|
+
const url = `${API_BASE_URL}/v1/public/addresses/balance`;
|
|
6368
|
+
const response = await fetch(url, {
|
|
6369
|
+
method: "POST",
|
|
6370
|
+
headers: {
|
|
6371
|
+
"Content-Type": "application/json",
|
|
6372
|
+
accept: "application/json",
|
|
6373
|
+
"x-publishable-key": pk
|
|
6374
|
+
},
|
|
6375
|
+
body: JSON.stringify({
|
|
6376
|
+
address,
|
|
6377
|
+
chain_type: chainType,
|
|
6378
|
+
chain_id: chainId,
|
|
6379
|
+
token_address: tokenAddress
|
|
6380
|
+
})
|
|
6381
|
+
});
|
|
6382
|
+
if (!response.ok) {
|
|
6383
|
+
throw new Error(`Failed to fetch address balance: ${response.statusText}`);
|
|
6384
|
+
}
|
|
6385
|
+
const data = await response.json();
|
|
6386
|
+
return data;
|
|
6387
|
+
}
|
|
6388
|
+
async function verifyRecipientAddress(request, publishableKey) {
|
|
6389
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6390
|
+
validatePublishableKey(pk);
|
|
6391
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/addresses/verify`, {
|
|
6392
|
+
method: "POST",
|
|
6393
|
+
headers: {
|
|
6394
|
+
accept: "application/json",
|
|
6395
|
+
"x-publishable-key": pk,
|
|
6396
|
+
"Content-Type": "application/json"
|
|
6397
|
+
},
|
|
6398
|
+
body: JSON.stringify(request)
|
|
6399
|
+
});
|
|
6400
|
+
if (!response.ok) {
|
|
6401
|
+
throw new Error(
|
|
6402
|
+
`Failed to verify recipient address: ${response.statusText}`
|
|
6403
|
+
);
|
|
6404
|
+
}
|
|
6405
|
+
return response.json();
|
|
6406
|
+
}
|
|
6362
6407
|
function useUserIp() {
|
|
6363
6408
|
const {
|
|
6364
6409
|
data: userIpInfo,
|
|
@@ -6459,21 +6504,22 @@ var i18n = en_default;
|
|
|
6459
6504
|
|
|
6460
6505
|
// ../ui-react/dist/index.mjs
|
|
6461
6506
|
var import_react10 = require("react");
|
|
6507
|
+
var import_react11 = require("react");
|
|
6462
6508
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6463
6509
|
var React37 = __toESM(require("react"), 1);
|
|
6464
6510
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
6465
6511
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6466
6512
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6467
6513
|
var import_react_query3 = require("@tanstack/react-query");
|
|
6468
|
-
var import_react11 = require("react");
|
|
6469
6514
|
var import_react12 = require("react");
|
|
6470
6515
|
var import_react13 = require("react");
|
|
6471
6516
|
var import_react14 = require("react");
|
|
6517
|
+
var import_react15 = require("react");
|
|
6472
6518
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
6473
6519
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
6474
6520
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6475
6521
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6476
|
-
var
|
|
6522
|
+
var import_react16 = require("react");
|
|
6477
6523
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6478
6524
|
var React42 = __toESM(require("react"), 1);
|
|
6479
6525
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
@@ -6485,11 +6531,12 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
|
6485
6531
|
var React72 = __toESM(require("react"), 1);
|
|
6486
6532
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6487
6533
|
var import_react_query4 = require("@tanstack/react-query");
|
|
6488
|
-
var
|
|
6534
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
6489
6535
|
var import_react17 = require("react");
|
|
6536
|
+
var import_react18 = require("react");
|
|
6490
6537
|
var import_qr_code_styling = __toESM(require_qr_code_styling(), 1);
|
|
6491
6538
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
6492
|
-
var
|
|
6539
|
+
var import_react19 = require("react");
|
|
6493
6540
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
6494
6541
|
var React82 = __toESM(require("react"), 1);
|
|
6495
6542
|
|
|
@@ -9231,7 +9278,7 @@ var Content22 = TooltipContent;
|
|
|
9231
9278
|
// ../ui-react/dist/index.mjs
|
|
9232
9279
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9233
9280
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
9234
|
-
var
|
|
9281
|
+
var import_react20 = require("react");
|
|
9235
9282
|
var React92 = __toESM(require("react"), 1);
|
|
9236
9283
|
|
|
9237
9284
|
// ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_5n4syhs66qrtkkphe44qzgdimq/node_modules/@radix-ui/react-select/dist/index.mjs
|
|
@@ -10620,6 +10667,29 @@ var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
|
10620
10667
|
function cn(...inputs) {
|
|
10621
10668
|
return twMerge(clsx(inputs));
|
|
10622
10669
|
}
|
|
10670
|
+
function formatEstimatedTime(seconds) {
|
|
10671
|
+
if (seconds == null) {
|
|
10672
|
+
return "< 1 min";
|
|
10673
|
+
}
|
|
10674
|
+
if (seconds < 60) {
|
|
10675
|
+
return `< ${seconds} sec${seconds > 1 ? "s" : ""}`;
|
|
10676
|
+
} else if (seconds < 3600) {
|
|
10677
|
+
const mins = Math.ceil(seconds / 60);
|
|
10678
|
+
return `< ${mins} min${mins > 1 ? "s" : ""}`;
|
|
10679
|
+
} else {
|
|
10680
|
+
let hrs = Math.floor(seconds / 3600);
|
|
10681
|
+
let mins = Math.ceil(seconds % 3600 / 60);
|
|
10682
|
+
if (mins === 60) {
|
|
10683
|
+
hrs += 1;
|
|
10684
|
+
mins = 0;
|
|
10685
|
+
}
|
|
10686
|
+
const hrLabel = hrs > 1 ? "hrs" : "hr";
|
|
10687
|
+
if (mins === 0) {
|
|
10688
|
+
return `< ${hrs} ${hrLabel}`;
|
|
10689
|
+
}
|
|
10690
|
+
return `< ${hrs} ${hrLabel} ${mins} min${mins > 1 ? "s" : ""}`;
|
|
10691
|
+
}
|
|
10692
|
+
}
|
|
10623
10693
|
var defaultColors = {
|
|
10624
10694
|
light: {
|
|
10625
10695
|
// Background colors
|
|
@@ -11061,10 +11131,83 @@ function DepositHeader({
|
|
|
11061
11131
|
showClose = true,
|
|
11062
11132
|
onBack,
|
|
11063
11133
|
onClose,
|
|
11064
|
-
badge
|
|
11134
|
+
badge,
|
|
11135
|
+
showBalance = false,
|
|
11136
|
+
balanceAddress,
|
|
11137
|
+
balanceChainType,
|
|
11138
|
+
balanceChainId,
|
|
11139
|
+
balanceTokenAddress,
|
|
11140
|
+
publishableKey
|
|
11065
11141
|
}) {
|
|
11066
11142
|
const { colors: colors2, fonts, components } = useTheme();
|
|
11067
|
-
|
|
11143
|
+
const [balance, setBalance] = (0, import_react11.useState)(null);
|
|
11144
|
+
const [isLoadingBalance, setIsLoadingBalance] = (0, import_react11.useState)(false);
|
|
11145
|
+
(0, import_react11.useEffect)(() => {
|
|
11146
|
+
if (!showBalance || !balanceAddress || !balanceChainType || !balanceChainId || !balanceTokenAddress || !publishableKey) {
|
|
11147
|
+
setBalance(null);
|
|
11148
|
+
setIsLoadingBalance(false);
|
|
11149
|
+
return;
|
|
11150
|
+
}
|
|
11151
|
+
let cancelled = false;
|
|
11152
|
+
setIsLoadingBalance(true);
|
|
11153
|
+
getAddressBalance(
|
|
11154
|
+
balanceAddress,
|
|
11155
|
+
balanceChainType,
|
|
11156
|
+
balanceChainId,
|
|
11157
|
+
balanceTokenAddress,
|
|
11158
|
+
publishableKey
|
|
11159
|
+
).then((response) => {
|
|
11160
|
+
if (cancelled) return;
|
|
11161
|
+
if (response.balance && response.balance.amount !== "0") {
|
|
11162
|
+
const value = Number(response.balance.amount) / 10 ** response.balance.token.decimals;
|
|
11163
|
+
let formatted;
|
|
11164
|
+
let maxDecimals = 4;
|
|
11165
|
+
const symbol = response.balance.token.symbol?.toUpperCase() || "";
|
|
11166
|
+
if (symbol === "BTC" || symbol === "WBTC") {
|
|
11167
|
+
maxDecimals = 8;
|
|
11168
|
+
} else if (symbol === "ETH" || symbol === "WETH") {
|
|
11169
|
+
maxDecimals = 6;
|
|
11170
|
+
}
|
|
11171
|
+
if (value >= 1) {
|
|
11172
|
+
formatted = value.toLocaleString(void 0, {
|
|
11173
|
+
minimumFractionDigits: 2,
|
|
11174
|
+
maximumFractionDigits: maxDecimals
|
|
11175
|
+
});
|
|
11176
|
+
} else if (value > 0) {
|
|
11177
|
+
formatted = value.toLocaleString(void 0, {
|
|
11178
|
+
minimumFractionDigits: 2,
|
|
11179
|
+
maximumFractionDigits: maxDecimals,
|
|
11180
|
+
minimumSignificantDigits: 2,
|
|
11181
|
+
maximumSignificantDigits: 6
|
|
11182
|
+
});
|
|
11183
|
+
} else {
|
|
11184
|
+
formatted = value.toExponential(2);
|
|
11185
|
+
}
|
|
11186
|
+
const balanceText = response.balance.amount_usd ? `Balance: $${response.balance.amount_usd} (${formatted} ${response.balance.token.symbol})` : `Balance: ${formatted} ${response.balance.token.symbol}`;
|
|
11187
|
+
setBalance(balanceText);
|
|
11188
|
+
} else {
|
|
11189
|
+
setBalance(null);
|
|
11190
|
+
}
|
|
11191
|
+
}).catch((error) => {
|
|
11192
|
+
if (cancelled) return;
|
|
11193
|
+
console.error("Error fetching balance:", error);
|
|
11194
|
+
setBalance(null);
|
|
11195
|
+
}).finally(() => {
|
|
11196
|
+
if (cancelled) return;
|
|
11197
|
+
setIsLoadingBalance(false);
|
|
11198
|
+
});
|
|
11199
|
+
return () => {
|
|
11200
|
+
cancelled = true;
|
|
11201
|
+
};
|
|
11202
|
+
}, [
|
|
11203
|
+
showBalance,
|
|
11204
|
+
balanceAddress,
|
|
11205
|
+
balanceChainType,
|
|
11206
|
+
balanceChainId,
|
|
11207
|
+
balanceTokenAddress,
|
|
11208
|
+
publishableKey
|
|
11209
|
+
]);
|
|
11210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-pb-6", children: [
|
|
11068
11211
|
showBack ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11069
11212
|
"button",
|
|
11070
11213
|
{
|
|
@@ -11074,8 +11217,32 @@ function DepositHeader({
|
|
|
11074
11217
|
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArrowLeft, { className: "uf-w-5 uf-h-5" })
|
|
11075
11218
|
}
|
|
11076
11219
|
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" }),
|
|
11077
|
-
|
|
11078
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.
|
|
11220
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center", children: [
|
|
11221
|
+
badge ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
11222
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11223
|
+
DialogTitle2,
|
|
11224
|
+
{
|
|
11225
|
+
className: "uf-text-center uf-text-base",
|
|
11226
|
+
style: {
|
|
11227
|
+
color: components.header.titleColor,
|
|
11228
|
+
fontFamily: fonts.medium
|
|
11229
|
+
},
|
|
11230
|
+
children: title
|
|
11231
|
+
}
|
|
11232
|
+
),
|
|
11233
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11234
|
+
"div",
|
|
11235
|
+
{
|
|
11236
|
+
className: "uf-px-2 uf-py-0.5 uf-rounded-full uf-text-[10px]",
|
|
11237
|
+
style: {
|
|
11238
|
+
backgroundColor: colors2.card,
|
|
11239
|
+
color: colors2.foregroundMuted,
|
|
11240
|
+
fontFamily: fonts.regular
|
|
11241
|
+
},
|
|
11242
|
+
children: badge.count
|
|
11243
|
+
}
|
|
11244
|
+
)
|
|
11245
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11079
11246
|
DialogTitle2,
|
|
11080
11247
|
{
|
|
11081
11248
|
className: "uf-text-center uf-text-base",
|
|
@@ -11086,29 +11253,19 @@ function DepositHeader({
|
|
|
11086
11253
|
children: title
|
|
11087
11254
|
}
|
|
11088
11255
|
),
|
|
11089
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11256
|
+
showBalance && (isLoadingBalance ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-2" }) : balance ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11090
11257
|
"div",
|
|
11091
11258
|
{
|
|
11092
|
-
className: "uf-
|
|
11259
|
+
className: "uf-text-xs uf-mt-2",
|
|
11093
11260
|
style: {
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11261
|
+
color: colors2.foreground,
|
|
11262
|
+
fontFamily: fonts.regular,
|
|
11263
|
+
opacity: 0.7
|
|
11097
11264
|
},
|
|
11098
|
-
children:
|
|
11265
|
+
children: balance
|
|
11099
11266
|
}
|
|
11100
|
-
)
|
|
11101
|
-
] })
|
|
11102
|
-
DialogTitle2,
|
|
11103
|
-
{
|
|
11104
|
-
className: "uf-text-center uf-text-base",
|
|
11105
|
-
style: {
|
|
11106
|
-
color: components.header.titleColor,
|
|
11107
|
-
fontFamily: fonts.medium
|
|
11108
|
-
},
|
|
11109
|
-
children: title
|
|
11110
|
-
}
|
|
11111
|
-
),
|
|
11267
|
+
) : null)
|
|
11268
|
+
] }),
|
|
11112
11269
|
showClose ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
11113
11270
|
"button",
|
|
11114
11271
|
{
|
|
@@ -11118,7 +11275,7 @@ function DepositHeader({
|
|
|
11118
11275
|
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(X, { className: "uf-w-5 uf-h-5" })
|
|
11119
11276
|
}
|
|
11120
11277
|
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" })
|
|
11121
|
-
] });
|
|
11278
|
+
] }) });
|
|
11122
11279
|
}
|
|
11123
11280
|
function CurrencyListItem({
|
|
11124
11281
|
currency,
|
|
@@ -11389,7 +11546,19 @@ var en_default2 = {
|
|
|
11389
11546
|
minimumDeposit: "Minimum: {{amount}}",
|
|
11390
11547
|
minimumDepositTooltip: "The minimum amount you can deposit on the selected network.",
|
|
11391
11548
|
selectTokenDeposit: "Your deposit token",
|
|
11392
|
-
selectTokenDepositTooltip: "Select the token you want to deposit with in order to begin the deposit process."
|
|
11549
|
+
selectTokenDepositTooltip: "Select the token you want to deposit with in order to begin the deposit process.",
|
|
11550
|
+
addressValidation: {
|
|
11551
|
+
validating: "Verifying recipient address...",
|
|
11552
|
+
unableToReceiveFunds: "Unable to Receive Funds",
|
|
11553
|
+
errors: {
|
|
11554
|
+
token_not_supported: "The destination token is not supported",
|
|
11555
|
+
not_opted_in: "Please make sure you opt-in {{token_symbol}}({{chain_name}}) before receiving funds",
|
|
11556
|
+
insufficient_balance: "Recipient account does not meet the minimum balance requirement",
|
|
11557
|
+
account_not_found: "Recipient account does not exist on {{chain_name}}",
|
|
11558
|
+
validation_error: "Unable to verify recipient address on {{chain_name}}"
|
|
11559
|
+
},
|
|
11560
|
+
defaultError: "The recipient address cannot receive funds for the selected token"
|
|
11561
|
+
}
|
|
11393
11562
|
},
|
|
11394
11563
|
depositModal: {
|
|
11395
11564
|
transferCrypto: {
|
|
@@ -11398,7 +11567,7 @@ var en_default2 = {
|
|
|
11398
11567
|
},
|
|
11399
11568
|
depositWithCard: {
|
|
11400
11569
|
title: "Deposit with Card",
|
|
11401
|
-
subtitle: "$50,000 limit
|
|
11570
|
+
subtitle: "$50,000 limit"
|
|
11402
11571
|
},
|
|
11403
11572
|
quotes: "Quotes"
|
|
11404
11573
|
},
|
|
@@ -11414,6 +11583,13 @@ var en_default2 = {
|
|
|
11414
11583
|
}
|
|
11415
11584
|
};
|
|
11416
11585
|
var i18n2 = en_default2;
|
|
11586
|
+
function interpolate(template, params) {
|
|
11587
|
+
if (!params) return template;
|
|
11588
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => {
|
|
11589
|
+
const value = params[key];
|
|
11590
|
+
return value !== void 0 ? String(value) : `{{${key}}}`;
|
|
11591
|
+
});
|
|
11592
|
+
}
|
|
11417
11593
|
function useDepositPolling({
|
|
11418
11594
|
userId,
|
|
11419
11595
|
publishableKey,
|
|
@@ -11421,14 +11597,14 @@ function useDepositPolling({
|
|
|
11421
11597
|
onDepositSuccess,
|
|
11422
11598
|
onDepositError
|
|
11423
11599
|
}) {
|
|
11424
|
-
const [executions, setExecutions] = (0,
|
|
11425
|
-
const [isPolling, setIsPolling] = (0,
|
|
11426
|
-
const pollingIntervalRef = (0,
|
|
11600
|
+
const [executions, setExecutions] = (0, import_react12.useState)([]);
|
|
11601
|
+
const [isPolling, setIsPolling] = (0, import_react12.useState)(false);
|
|
11602
|
+
const pollingIntervalRef = (0, import_react12.useRef)(
|
|
11427
11603
|
null
|
|
11428
11604
|
);
|
|
11429
|
-
const [modalOpenedAt] = (0,
|
|
11430
|
-
const [trackedExecutions, setTrackedExecutions] = (0,
|
|
11431
|
-
(0,
|
|
11605
|
+
const [modalOpenedAt] = (0, import_react12.useState)(/* @__PURE__ */ new Date());
|
|
11606
|
+
const [trackedExecutions, setTrackedExecutions] = (0, import_react12.useState)(/* @__PURE__ */ new Map());
|
|
11607
|
+
(0, import_react12.useEffect)(() => {
|
|
11432
11608
|
if (!userId || !modalOpenedAt || !enabled) return;
|
|
11433
11609
|
const pollInterval = setInterval(async () => {
|
|
11434
11610
|
try {
|
|
@@ -11539,12 +11715,12 @@ function formatCurrency(currency) {
|
|
|
11539
11715
|
}
|
|
11540
11716
|
function DepositDetailContent({ execution }) {
|
|
11541
11717
|
const { colors: colors2, fonts, components } = useTheme();
|
|
11542
|
-
const [chains, setChains] = (0,
|
|
11543
|
-
const [showNetworkDetails, setShowNetworkDetails] = (0,
|
|
11544
|
-
(0,
|
|
11718
|
+
const [chains, setChains] = (0, import_react15.useState)([]);
|
|
11719
|
+
const [showNetworkDetails, setShowNetworkDetails] = (0, import_react15.useState)(false);
|
|
11720
|
+
(0, import_react15.useEffect)(() => {
|
|
11545
11721
|
getTokenChains().then((response) => setChains(response.data)).catch((err) => console.error("Failed to fetch chains:", err));
|
|
11546
11722
|
}, []);
|
|
11547
|
-
(0,
|
|
11723
|
+
(0, import_react15.useEffect)(() => {
|
|
11548
11724
|
setShowNetworkDetails(false);
|
|
11549
11725
|
}, [execution?.id]);
|
|
11550
11726
|
const isPending = execution.status === ExecutionStatus.PENDING || execution.status === ExecutionStatus.WAITING || execution.status === ExecutionStatus.DELAYED;
|
|
@@ -11839,6 +12015,37 @@ function DepositDetailContent({ execution }) {
|
|
|
11839
12015
|
]
|
|
11840
12016
|
}
|
|
11841
12017
|
),
|
|
12018
|
+
isPending && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
12019
|
+
"div",
|
|
12020
|
+
{
|
|
12021
|
+
className: "uf-flex uf-justify-between uf-items-center uf-px-4 uf-py-3 uf-border-b",
|
|
12022
|
+
style: { borderColor: colors2.border },
|
|
12023
|
+
children: [
|
|
12024
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
12025
|
+
"span",
|
|
12026
|
+
{
|
|
12027
|
+
className: "uf-text-sm",
|
|
12028
|
+
style: {
|
|
12029
|
+
color: components.card.labelColor,
|
|
12030
|
+
fontFamily: fonts.regular
|
|
12031
|
+
},
|
|
12032
|
+
children: "Estimated delivery time"
|
|
12033
|
+
}
|
|
12034
|
+
),
|
|
12035
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
12036
|
+
"span",
|
|
12037
|
+
{
|
|
12038
|
+
style: {
|
|
12039
|
+
color: components.card.titleColor,
|
|
12040
|
+
fontFamily: fonts.regular,
|
|
12041
|
+
fontSize: "14px"
|
|
12042
|
+
},
|
|
12043
|
+
children: formatEstimatedTime(execution?.estimated_processing_time)
|
|
12044
|
+
}
|
|
12045
|
+
)
|
|
12046
|
+
]
|
|
12047
|
+
}
|
|
12048
|
+
),
|
|
11842
12049
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
11843
12050
|
"div",
|
|
11844
12051
|
{
|
|
@@ -12022,7 +12229,7 @@ function DepositSuccessToast({
|
|
|
12022
12229
|
onClose,
|
|
12023
12230
|
execution
|
|
12024
12231
|
}) {
|
|
12025
|
-
const [detailModalOpen, setDetailModalOpen] = (0,
|
|
12232
|
+
const [detailModalOpen, setDetailModalOpen] = (0, import_react14.useState)(false);
|
|
12026
12233
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
12027
12234
|
const isPending = status === ExecutionStatus.PENDING || status === ExecutionStatus.WAITING || status === ExecutionStatus.DELAYED;
|
|
12028
12235
|
const formatDateTime = (timestamp) => {
|
|
@@ -12156,14 +12363,27 @@ function DepositSuccessToast({
|
|
|
12156
12363
|
}
|
|
12157
12364
|
)
|
|
12158
12365
|
] }),
|
|
12159
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12366
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "uf-flex-shrink-0 uf-text-right", children: [
|
|
12367
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
12368
|
+
"div",
|
|
12369
|
+
{
|
|
12370
|
+
className: "uf-font-medium uf-text-sm",
|
|
12371
|
+
style: { color: colors2.background },
|
|
12372
|
+
children: formatUsdAmount(sourceAmountUsd)
|
|
12373
|
+
}
|
|
12374
|
+
),
|
|
12375
|
+
isPending && execution?.estimated_processing_time && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
12376
|
+
"p",
|
|
12377
|
+
{
|
|
12378
|
+
className: "uf-text-xs",
|
|
12379
|
+
style: { color: colors2.foregroundMuted },
|
|
12380
|
+
children: [
|
|
12381
|
+
"Est. ",
|
|
12382
|
+
formatEstimatedTime(execution.estimated_processing_time)
|
|
12383
|
+
]
|
|
12384
|
+
}
|
|
12385
|
+
)
|
|
12386
|
+
] }),
|
|
12167
12387
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
12168
12388
|
"button",
|
|
12169
12389
|
{
|
|
@@ -12209,7 +12429,7 @@ function DepositPollingToasts({
|
|
|
12209
12429
|
executions,
|
|
12210
12430
|
horizontalPadding = "24px"
|
|
12211
12431
|
}) {
|
|
12212
|
-
const [closedExecutionIds, setClosedExecutionIds] = (0,
|
|
12432
|
+
const [closedExecutionIds, setClosedExecutionIds] = (0, import_react13.useState)(
|
|
12213
12433
|
/* @__PURE__ */ new Set()
|
|
12214
12434
|
);
|
|
12215
12435
|
const handleClose = (executionId) => {
|
|
@@ -12962,6 +13182,20 @@ function BuyWithCard({
|
|
|
12962
13182
|
},
|
|
12963
13183
|
children: quotesError
|
|
12964
13184
|
}
|
|
13185
|
+
),
|
|
13186
|
+
defaultToken?.estimated_processing_time && !quotesLoading && selectedProvider && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
13187
|
+
"div",
|
|
13188
|
+
{
|
|
13189
|
+
className: "uf-text-xs uf-mt-2 uf-px-1",
|
|
13190
|
+
style: {
|
|
13191
|
+
color: components.card.subtitleColor,
|
|
13192
|
+
fontFamily: fonts.regular
|
|
13193
|
+
},
|
|
13194
|
+
children: [
|
|
13195
|
+
"Estimated delivery time: ",
|
|
13196
|
+
formatEstimatedTime(defaultToken.estimated_processing_time)
|
|
13197
|
+
]
|
|
13198
|
+
}
|
|
12965
13199
|
)
|
|
12966
13200
|
] }),
|
|
12967
13201
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
@@ -13405,9 +13639,9 @@ function DepositsModal({
|
|
|
13405
13639
|
themeClass = ""
|
|
13406
13640
|
}) {
|
|
13407
13641
|
const { colors: colors2 } = useTheme();
|
|
13408
|
-
const [allExecutions, setAllExecutions] = (0,
|
|
13409
|
-
const [selectedExecution, setSelectedExecution] = (0,
|
|
13410
|
-
(0,
|
|
13642
|
+
const [allExecutions, setAllExecutions] = (0, import_react16.useState)(sessionExecutions);
|
|
13643
|
+
const [selectedExecution, setSelectedExecution] = (0, import_react16.useState)(null);
|
|
13644
|
+
(0, import_react16.useEffect)(() => {
|
|
13411
13645
|
if (!open || !userId) return;
|
|
13412
13646
|
const fetchExecutions = async () => {
|
|
13413
13647
|
try {
|
|
@@ -13429,7 +13663,7 @@ function DepositsModal({
|
|
|
13429
13663
|
clearInterval(pollInterval);
|
|
13430
13664
|
};
|
|
13431
13665
|
}, [open, userId, publishableKey, sessionExecutions]);
|
|
13432
|
-
(0,
|
|
13666
|
+
(0, import_react16.useEffect)(() => {
|
|
13433
13667
|
if (!open) {
|
|
13434
13668
|
setSelectedExecution(null);
|
|
13435
13669
|
}
|
|
@@ -13788,6 +14022,60 @@ function useAllowedCountry(publishableKey) {
|
|
|
13788
14022
|
error
|
|
13789
14023
|
};
|
|
13790
14024
|
}
|
|
14025
|
+
function useAddressValidation({
|
|
14026
|
+
recipientAddress,
|
|
14027
|
+
destinationChainType,
|
|
14028
|
+
destinationChainId,
|
|
14029
|
+
destinationTokenAddress,
|
|
14030
|
+
publishableKey,
|
|
14031
|
+
enabled = true,
|
|
14032
|
+
refetchOnMount = false
|
|
14033
|
+
}) {
|
|
14034
|
+
const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
14035
|
+
const { data, isLoading, error } = (0, import_react_query5.useQuery)({
|
|
14036
|
+
queryKey: [
|
|
14037
|
+
"unifold",
|
|
14038
|
+
"addressValidation",
|
|
14039
|
+
recipientAddress,
|
|
14040
|
+
destinationChainType,
|
|
14041
|
+
destinationChainId,
|
|
14042
|
+
destinationTokenAddress
|
|
14043
|
+
],
|
|
14044
|
+
queryFn: () => verifyRecipientAddress(
|
|
14045
|
+
{
|
|
14046
|
+
chain_type: destinationChainType,
|
|
14047
|
+
chain_id: destinationChainId,
|
|
14048
|
+
token_address: destinationTokenAddress,
|
|
14049
|
+
recipient_address: recipientAddress
|
|
14050
|
+
},
|
|
14051
|
+
publishableKey
|
|
14052
|
+
),
|
|
14053
|
+
enabled: shouldValidate,
|
|
14054
|
+
refetchOnMount,
|
|
14055
|
+
refetchOnReconnect: false,
|
|
14056
|
+
refetchOnWindowFocus: false,
|
|
14057
|
+
staleTime: 1e3 * 60 * 5,
|
|
14058
|
+
// 5 minutes - address state can change
|
|
14059
|
+
gcTime: 1e3 * 60 * 30
|
|
14060
|
+
// 30 minutes
|
|
14061
|
+
});
|
|
14062
|
+
if (!shouldValidate) {
|
|
14063
|
+
return {
|
|
14064
|
+
isValid: null,
|
|
14065
|
+
failureCode: null,
|
|
14066
|
+
metadata: null,
|
|
14067
|
+
isLoading: false,
|
|
14068
|
+
error: null
|
|
14069
|
+
};
|
|
14070
|
+
}
|
|
14071
|
+
return {
|
|
14072
|
+
isValid: data?.valid ?? null,
|
|
14073
|
+
failureCode: data?.failure_code ?? null,
|
|
14074
|
+
metadata: data?.metadata ?? null,
|
|
14075
|
+
isLoading,
|
|
14076
|
+
error: error ?? null
|
|
14077
|
+
};
|
|
14078
|
+
}
|
|
13791
14079
|
function StyledQRCode({
|
|
13792
14080
|
value,
|
|
13793
14081
|
size: size4 = 200,
|
|
@@ -13795,9 +14083,9 @@ function StyledQRCode({
|
|
|
13795
14083
|
imageSize = 50,
|
|
13796
14084
|
darkMode = false
|
|
13797
14085
|
}) {
|
|
13798
|
-
const ref = (0,
|
|
13799
|
-
const qrCodeRef = (0,
|
|
13800
|
-
(0,
|
|
14086
|
+
const ref = (0, import_react18.useRef)(null);
|
|
14087
|
+
const qrCodeRef = (0, import_react18.useRef)(null);
|
|
14088
|
+
(0, import_react18.useEffect)(() => {
|
|
13801
14089
|
if (!ref.current) return;
|
|
13802
14090
|
if (!qrCodeRef.current) {
|
|
13803
14091
|
qrCodeRef.current = new import_qr_code_styling.default({
|
|
@@ -13837,7 +14125,7 @@ function StyledQRCode({
|
|
|
13837
14125
|
qrCodeRef.current.append(ref.current);
|
|
13838
14126
|
}
|
|
13839
14127
|
}, []);
|
|
13840
|
-
(0,
|
|
14128
|
+
(0, import_react18.useEffect)(() => {
|
|
13841
14129
|
if (qrCodeRef.current) {
|
|
13842
14130
|
qrCodeRef.current.update({
|
|
13843
14131
|
data: value,
|
|
@@ -13931,13 +14219,13 @@ function TokenSelectorSheet({
|
|
|
13931
14219
|
}) {
|
|
13932
14220
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
13933
14221
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
13934
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
13935
|
-
const [recentTokens, setRecentTokens] = (0,
|
|
13936
|
-
const [hoveredTokenKey, setHoveredTokenKey] = (0,
|
|
13937
|
-
(0,
|
|
14222
|
+
const [searchQuery, setSearchQuery] = (0, import_react19.useState)("");
|
|
14223
|
+
const [recentTokens, setRecentTokens] = (0, import_react19.useState)([]);
|
|
14224
|
+
const [hoveredTokenKey, setHoveredTokenKey] = (0, import_react19.useState)(null);
|
|
14225
|
+
(0, import_react19.useEffect)(() => {
|
|
13938
14226
|
setRecentTokens(getRecentTokens());
|
|
13939
14227
|
}, []);
|
|
13940
|
-
const allOptions = (0,
|
|
14228
|
+
const allOptions = (0, import_react19.useMemo)(() => {
|
|
13941
14229
|
const options = [];
|
|
13942
14230
|
tokens.forEach((token) => {
|
|
13943
14231
|
token.chains.forEach((chain) => {
|
|
@@ -13946,7 +14234,7 @@ function TokenSelectorSheet({
|
|
|
13946
14234
|
});
|
|
13947
14235
|
return options;
|
|
13948
14236
|
}, [tokens]);
|
|
13949
|
-
const quickSelectOptions = (0,
|
|
14237
|
+
const quickSelectOptions = (0, import_react19.useMemo)(() => {
|
|
13950
14238
|
const result = [];
|
|
13951
14239
|
const seen = /* @__PURE__ */ new Set();
|
|
13952
14240
|
const addOption = (symbol, chainType, chainId, isRecent) => {
|
|
@@ -13978,7 +14266,7 @@ function TokenSelectorSheet({
|
|
|
13978
14266
|
});
|
|
13979
14267
|
setRecentTokens(updated);
|
|
13980
14268
|
};
|
|
13981
|
-
const filteredOptions = (0,
|
|
14269
|
+
const filteredOptions = (0, import_react19.useMemo)(() => {
|
|
13982
14270
|
if (!searchQuery.trim()) return allOptions;
|
|
13983
14271
|
const query = searchQuery.toLowerCase();
|
|
13984
14272
|
return allOptions.filter(
|
|
@@ -14363,13 +14651,13 @@ function TransferCryptoSingleInput({
|
|
|
14363
14651
|
}) {
|
|
14364
14652
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
14365
14653
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
14366
|
-
const [token, setToken] = (0,
|
|
14367
|
-
const [chain, setChain] = (0,
|
|
14368
|
-
const [copied, setCopied] = (0,
|
|
14369
|
-
const [internalWallets, setInternalWallets] = (0,
|
|
14370
|
-
const [loading, setLoading] = (0,
|
|
14654
|
+
const [token, setToken] = (0, import_react17.useState)("USDC");
|
|
14655
|
+
const [chain, setChain] = (0, import_react17.useState)("solana:mainnet");
|
|
14656
|
+
const [copied, setCopied] = (0, import_react17.useState)(false);
|
|
14657
|
+
const [internalWallets, setInternalWallets] = (0, import_react17.useState)([]);
|
|
14658
|
+
const [loading, setLoading] = (0, import_react17.useState)(!externalWallets?.length);
|
|
14371
14659
|
const wallets = externalWallets?.length ? externalWallets : internalWallets;
|
|
14372
|
-
const [error, setError] = (0,
|
|
14660
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
14373
14661
|
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
14374
14662
|
userId,
|
|
14375
14663
|
publishableKey,
|
|
@@ -14377,11 +14665,11 @@ function TransferCryptoSingleInput({
|
|
|
14377
14665
|
onDepositSuccess,
|
|
14378
14666
|
onDepositError
|
|
14379
14667
|
});
|
|
14380
|
-
const [supportedTokens, setSupportedTokens] = (0,
|
|
14381
|
-
const [tokensLoading, setTokensLoading] = (0,
|
|
14382
|
-
const [detailsExpanded, setDetailsExpanded] = (0,
|
|
14383
|
-
const [depositsModalOpen, setDepositsModalOpen] = (0,
|
|
14384
|
-
const [tokenSelectorOpen, setTokenSelectorOpen] = (0,
|
|
14668
|
+
const [supportedTokens, setSupportedTokens] = (0, import_react17.useState)([]);
|
|
14669
|
+
const [tokensLoading, setTokensLoading] = (0, import_react17.useState)(true);
|
|
14670
|
+
const [detailsExpanded, setDetailsExpanded] = (0, import_react17.useState)(false);
|
|
14671
|
+
const [depositsModalOpen, setDepositsModalOpen] = (0, import_react17.useState)(false);
|
|
14672
|
+
const [tokenSelectorOpen, setTokenSelectorOpen] = (0, import_react17.useState)(false);
|
|
14385
14673
|
const allChainsMap = /* @__PURE__ */ new Map();
|
|
14386
14674
|
supportedTokens.forEach((t5) => {
|
|
14387
14675
|
t5.chains.forEach((c) => {
|
|
@@ -14399,7 +14687,7 @@ function TransferCryptoSingleInput({
|
|
|
14399
14687
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
14400
14688
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
14401
14689
|
const depositAddress = currentWallet?.address || "";
|
|
14402
|
-
(0,
|
|
14690
|
+
(0, import_react17.useEffect)(() => {
|
|
14403
14691
|
async function fetchSupportedTokens() {
|
|
14404
14692
|
try {
|
|
14405
14693
|
setTokensLoading(true);
|
|
@@ -14471,12 +14759,12 @@ function TransferCryptoSingleInput({
|
|
|
14471
14759
|
destinationChainId,
|
|
14472
14760
|
destinationChainType
|
|
14473
14761
|
]);
|
|
14474
|
-
(0,
|
|
14762
|
+
(0, import_react17.useEffect)(() => {
|
|
14475
14763
|
if (onExecutionsChange) {
|
|
14476
14764
|
onExecutionsChange(depositExecutions);
|
|
14477
14765
|
}
|
|
14478
14766
|
}, [depositExecutions, onExecutionsChange]);
|
|
14479
|
-
(0,
|
|
14767
|
+
(0, import_react17.useEffect)(() => {
|
|
14480
14768
|
if (externalWallets?.length) {
|
|
14481
14769
|
setLoading(false);
|
|
14482
14770
|
return;
|
|
@@ -14533,7 +14821,7 @@ function TransferCryptoSingleInput({
|
|
|
14533
14821
|
publishableKey,
|
|
14534
14822
|
externalWallets
|
|
14535
14823
|
]);
|
|
14536
|
-
(0,
|
|
14824
|
+
(0, import_react17.useEffect)(() => {
|
|
14537
14825
|
if (!supportedTokens.length) return;
|
|
14538
14826
|
const currentToken = supportedTokens.find((t5) => t5.symbol === token);
|
|
14539
14827
|
if (!currentToken || currentToken.chains.length === 0) return;
|
|
@@ -15045,13 +15333,13 @@ function TransferCryptoDoubleInput({
|
|
|
15045
15333
|
}) {
|
|
15046
15334
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
15047
15335
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
15048
|
-
const [token, setToken] = (0,
|
|
15049
|
-
const [chain, setChain] = (0,
|
|
15050
|
-
const [copied, setCopied] = (0,
|
|
15051
|
-
const [internalWallets, setInternalWallets] = (0,
|
|
15052
|
-
const [loading, setLoading] = (0,
|
|
15336
|
+
const [token, setToken] = (0, import_react20.useState)("USDC");
|
|
15337
|
+
const [chain, setChain] = (0, import_react20.useState)("solana:mainnet");
|
|
15338
|
+
const [copied, setCopied] = (0, import_react20.useState)(false);
|
|
15339
|
+
const [internalWallets, setInternalWallets] = (0, import_react20.useState)([]);
|
|
15340
|
+
const [loading, setLoading] = (0, import_react20.useState)(!externalWallets?.length);
|
|
15053
15341
|
const wallets = externalWallets?.length ? externalWallets : internalWallets;
|
|
15054
|
-
const [error, setError] = (0,
|
|
15342
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
15055
15343
|
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
15056
15344
|
userId,
|
|
15057
15345
|
publishableKey,
|
|
@@ -15059,10 +15347,10 @@ function TransferCryptoDoubleInput({
|
|
|
15059
15347
|
onDepositSuccess,
|
|
15060
15348
|
onDepositError
|
|
15061
15349
|
});
|
|
15062
|
-
const [supportedTokens, setSupportedTokens] = (0,
|
|
15063
|
-
const [tokensLoading, setTokensLoading] = (0,
|
|
15064
|
-
const [detailsExpanded, setDetailsExpanded] = (0,
|
|
15065
|
-
const [depositsModalOpen, setDepositsModalOpen] = (0,
|
|
15350
|
+
const [supportedTokens, setSupportedTokens] = (0, import_react20.useState)([]);
|
|
15351
|
+
const [tokensLoading, setTokensLoading] = (0, import_react20.useState)(true);
|
|
15352
|
+
const [detailsExpanded, setDetailsExpanded] = (0, import_react20.useState)(false);
|
|
15353
|
+
const [depositsModalOpen, setDepositsModalOpen] = (0, import_react20.useState)(false);
|
|
15066
15354
|
const allChainsMap = /* @__PURE__ */ new Map();
|
|
15067
15355
|
supportedTokens.forEach((t5) => {
|
|
15068
15356
|
t5.chains.forEach((c) => {
|
|
@@ -15080,7 +15368,7 @@ function TransferCryptoDoubleInput({
|
|
|
15080
15368
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
15081
15369
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
15082
15370
|
const depositAddress = currentWallet?.address || "";
|
|
15083
|
-
(0,
|
|
15371
|
+
(0, import_react20.useEffect)(() => {
|
|
15084
15372
|
async function fetchSupportedTokens() {
|
|
15085
15373
|
try {
|
|
15086
15374
|
setTokensLoading(true);
|
|
@@ -15123,12 +15411,12 @@ function TransferCryptoDoubleInput({
|
|
|
15123
15411
|
destinationChainId,
|
|
15124
15412
|
destinationChainType
|
|
15125
15413
|
]);
|
|
15126
|
-
(0,
|
|
15414
|
+
(0, import_react20.useEffect)(() => {
|
|
15127
15415
|
if (onExecutionsChange) {
|
|
15128
15416
|
onExecutionsChange(depositExecutions);
|
|
15129
15417
|
}
|
|
15130
15418
|
}, [depositExecutions, onExecutionsChange]);
|
|
15131
|
-
(0,
|
|
15419
|
+
(0, import_react20.useEffect)(() => {
|
|
15132
15420
|
if (externalWallets?.length) {
|
|
15133
15421
|
setLoading(false);
|
|
15134
15422
|
return;
|
|
@@ -15185,7 +15473,7 @@ function TransferCryptoDoubleInput({
|
|
|
15185
15473
|
publishableKey,
|
|
15186
15474
|
externalWallets
|
|
15187
15475
|
]);
|
|
15188
|
-
(0,
|
|
15476
|
+
(0, import_react20.useEffect)(() => {
|
|
15189
15477
|
if (!supportedTokens.length) return;
|
|
15190
15478
|
const currentToken = supportedTokens.find((t5) => t5.symbol === token);
|
|
15191
15479
|
if (!currentToken || currentToken.chains.length === 0) return;
|
|
@@ -15633,12 +15921,13 @@ function DepositModal({
|
|
|
15633
15921
|
destinationChainId,
|
|
15634
15922
|
destinationTokenAddress,
|
|
15635
15923
|
hideDepositTracker = false,
|
|
15924
|
+
showBalanceHeader = false,
|
|
15636
15925
|
transferInputVariant = "double_input",
|
|
15637
15926
|
onDepositSuccess,
|
|
15638
15927
|
onDepositError,
|
|
15639
15928
|
theme = "dark"
|
|
15640
15929
|
}) {
|
|
15641
|
-
const { colors: colors2 } = useTheme();
|
|
15930
|
+
const { colors: colors2, fonts } = useTheme();
|
|
15642
15931
|
const [view, setView] = (0, import_react8.useState)("main");
|
|
15643
15932
|
const [cardView, setCardView] = (0, import_react8.useState)(
|
|
15644
15933
|
"amount"
|
|
@@ -15688,6 +15977,28 @@ function DepositModal({
|
|
|
15688
15977
|
isLoading: isCountryLoading,
|
|
15689
15978
|
error: countryError
|
|
15690
15979
|
} = useAllowedCountry(publishableKey);
|
|
15980
|
+
const {
|
|
15981
|
+
isValid: isAddressValid,
|
|
15982
|
+
failureCode: addressFailureCode,
|
|
15983
|
+
metadata: addressFailureMetadata,
|
|
15984
|
+
isLoading: isAddressValidationLoading
|
|
15985
|
+
} = useAddressValidation({
|
|
15986
|
+
recipientAddress,
|
|
15987
|
+
destinationChainType,
|
|
15988
|
+
destinationChainId,
|
|
15989
|
+
destinationTokenAddress,
|
|
15990
|
+
publishableKey,
|
|
15991
|
+
enabled: open,
|
|
15992
|
+
// Only validate when modal is open
|
|
15993
|
+
refetchOnMount: "always"
|
|
15994
|
+
});
|
|
15995
|
+
const addressValidationMessages = i18n2.transferCrypto.addressValidation;
|
|
15996
|
+
const getAddressValidationErrorMessage = (code, metadata) => {
|
|
15997
|
+
if (!code) return addressValidationMessages.defaultError;
|
|
15998
|
+
const errors = addressValidationMessages.errors;
|
|
15999
|
+
const template = errors[code] ?? addressValidationMessages.defaultError;
|
|
16000
|
+
return interpolate(template, metadata);
|
|
16001
|
+
};
|
|
15691
16002
|
(0, import_react8.useEffect)(() => {
|
|
15692
16003
|
if (!open || wallets.length > 0) return;
|
|
15693
16004
|
let retryTimeout = null;
|
|
@@ -15772,10 +16083,16 @@ function DepositModal({
|
|
|
15772
16083
|
DepositHeader,
|
|
15773
16084
|
{
|
|
15774
16085
|
title: modalTitle || "Deposit",
|
|
15775
|
-
onClose: handleClose
|
|
16086
|
+
onClose: handleClose,
|
|
16087
|
+
showBalance: showBalanceHeader,
|
|
16088
|
+
balanceAddress: recipientAddress,
|
|
16089
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
16090
|
+
balanceChainId: destinationChainId,
|
|
16091
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
16092
|
+
publishableKey
|
|
15776
16093
|
}
|
|
15777
16094
|
),
|
|
15778
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: isCountryLoading || !projectConfig ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
16095
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: isCountryLoading || isAddressValidationLoading || !projectConfig ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
15779
16096
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
15780
16097
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
15781
16098
|
!hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(SkeletonButton, {})
|
|
@@ -15793,6 +16110,16 @@ function DepositModal({
|
|
|
15793
16110
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: "No Tokens Available" }),
|
|
15794
16111
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: "There are no supported tokens available from your current location." })
|
|
15795
16112
|
] })
|
|
16113
|
+
) : isAddressValid === false ? (
|
|
16114
|
+
/* Invalid recipient address state (e.g., Algorand not opted in) */
|
|
16115
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
16116
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
16117
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: addressValidationMessages.unableToReceiveFunds }),
|
|
16118
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: getAddressValidationErrorMessage(
|
|
16119
|
+
addressFailureCode,
|
|
16120
|
+
addressFailureMetadata
|
|
16121
|
+
) })
|
|
16122
|
+
] })
|
|
15796
16123
|
) : (
|
|
15797
16124
|
/* Normal deposit options */
|
|
15798
16125
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
@@ -15974,12 +16301,12 @@ function UnifoldProvider2({
|
|
|
15974
16301
|
publishableKey,
|
|
15975
16302
|
config
|
|
15976
16303
|
}) {
|
|
15977
|
-
const [isOpen, setIsOpen] = (0,
|
|
15978
|
-
const [depositConfig, setDepositConfig] = (0,
|
|
16304
|
+
const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
|
|
16305
|
+
const [depositConfig, setDepositConfig] = (0, import_react21.useState)(
|
|
15979
16306
|
null
|
|
15980
16307
|
);
|
|
15981
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
15982
|
-
|
|
16308
|
+
const [resolvedTheme, setResolvedTheme] = import_react21.default.useState("dark");
|
|
16309
|
+
import_react21.default.useEffect(() => {
|
|
15983
16310
|
const appearance = config?.appearance || "dark";
|
|
15984
16311
|
if (appearance === "auto") {
|
|
15985
16312
|
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -15994,9 +16321,9 @@ function UnifoldProvider2({
|
|
|
15994
16321
|
setResolvedTheme(appearance);
|
|
15995
16322
|
}
|
|
15996
16323
|
}, [config?.appearance]);
|
|
15997
|
-
const depositPromiseRef =
|
|
15998
|
-
const closeTimeoutRef =
|
|
15999
|
-
const beginDeposit = (0,
|
|
16324
|
+
const depositPromiseRef = import_react21.default.useRef(null);
|
|
16325
|
+
const closeTimeoutRef = import_react21.default.useRef(null);
|
|
16326
|
+
const beginDeposit = (0, import_react21.useCallback)((config2) => {
|
|
16000
16327
|
if (closeTimeoutRef.current) {
|
|
16001
16328
|
clearTimeout(closeTimeoutRef.current);
|
|
16002
16329
|
closeTimeoutRef.current = null;
|
|
@@ -16016,7 +16343,7 @@ function UnifoldProvider2({
|
|
|
16016
16343
|
setIsOpen(true);
|
|
16017
16344
|
return promise;
|
|
16018
16345
|
}, []);
|
|
16019
|
-
const closeDeposit = (0,
|
|
16346
|
+
const closeDeposit = (0, import_react21.useCallback)(() => {
|
|
16020
16347
|
if (depositPromiseRef.current) {
|
|
16021
16348
|
depositPromiseRef.current.reject({
|
|
16022
16349
|
message: "Deposit cancelled by user",
|
|
@@ -16030,7 +16357,7 @@ function UnifoldProvider2({
|
|
|
16030
16357
|
closeTimeoutRef.current = null;
|
|
16031
16358
|
}, 200);
|
|
16032
16359
|
}, []);
|
|
16033
|
-
const handleDepositSuccess = (0,
|
|
16360
|
+
const handleDepositSuccess = (0, import_react21.useCallback)((data) => {
|
|
16034
16361
|
if (depositConfig?.onSuccess) {
|
|
16035
16362
|
depositConfig.onSuccess(data);
|
|
16036
16363
|
}
|
|
@@ -16039,7 +16366,7 @@ function UnifoldProvider2({
|
|
|
16039
16366
|
depositPromiseRef.current = null;
|
|
16040
16367
|
}
|
|
16041
16368
|
}, [depositConfig]);
|
|
16042
|
-
const handleDepositError = (0,
|
|
16369
|
+
const handleDepositError = (0, import_react21.useCallback)((error) => {
|
|
16043
16370
|
console.error("[UnifoldProvider] Deposit error:", error);
|
|
16044
16371
|
if (depositConfig?.onError) {
|
|
16045
16372
|
depositConfig.onError(error);
|
|
@@ -16049,7 +16376,7 @@ function UnifoldProvider2({
|
|
|
16049
16376
|
depositPromiseRef.current = null;
|
|
16050
16377
|
}
|
|
16051
16378
|
}, [depositConfig]);
|
|
16052
|
-
const contextValue = (0,
|
|
16379
|
+
const contextValue = (0, import_react21.useMemo)(
|
|
16053
16380
|
() => ({
|
|
16054
16381
|
beginDeposit,
|
|
16055
16382
|
closeDeposit,
|
|
@@ -16083,6 +16410,7 @@ function UnifoldProvider2({
|
|
|
16083
16410
|
destinationChainId: depositConfig.destinationChainId,
|
|
16084
16411
|
destinationTokenAddress: depositConfig.destinationTokenAddress,
|
|
16085
16412
|
hideDepositTracker: config?.hideDepositTracker,
|
|
16413
|
+
showBalanceHeader: config?.showBalanceHeader,
|
|
16086
16414
|
transferInputVariant: config?.transferInputVariant,
|
|
16087
16415
|
onDepositSuccess: handleDepositSuccess,
|
|
16088
16416
|
onDepositError: handleDepositError,
|
|
@@ -16093,10 +16421,10 @@ function UnifoldProvider2({
|
|
|
16093
16421
|
}
|
|
16094
16422
|
) }) });
|
|
16095
16423
|
}
|
|
16096
|
-
var ConnectContext =
|
|
16424
|
+
var ConnectContext = import_react21.default.createContext(null);
|
|
16097
16425
|
function useUnifold2() {
|
|
16098
16426
|
const baseContext = useUnifold();
|
|
16099
|
-
const connectContext =
|
|
16427
|
+
const connectContext = import_react21.default.useContext(ConnectContext);
|
|
16100
16428
|
if (typeof window === "undefined") {
|
|
16101
16429
|
return {
|
|
16102
16430
|
publishableKey: "",
|