@unifold/connect-react 0.1.26 → 0.1.27
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +575 -742
- package/dist/index.mjs +633 -800
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1146,7 +1146,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
1146
1146
|
// src/provider.tsx
|
|
1147
1147
|
import React38, {
|
|
1148
1148
|
useState as useState28,
|
|
1149
|
-
useCallback as
|
|
1149
|
+
useCallback as useCallback12,
|
|
1150
1150
|
useMemo as useMemo15
|
|
1151
1151
|
} from "react";
|
|
1152
1152
|
|
|
@@ -1217,7 +1217,7 @@ function useUnifold() {
|
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
1219
|
// ../ui-react/dist/index.mjs
|
|
1220
|
-
import { useState as
|
|
1220
|
+
import { useState as useState24, useEffect as useEffect18 } from "react";
|
|
1221
1221
|
|
|
1222
1222
|
// ../../node_modules/.pnpm/lucide-react@0.454.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
1223
1223
|
import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
|
|
@@ -6374,6 +6374,11 @@ async function getIpAddress() {
|
|
|
6374
6374
|
}
|
|
6375
6375
|
return response.json();
|
|
6376
6376
|
}
|
|
6377
|
+
var IneligibilityReason = /* @__PURE__ */ ((IneligibilityReason2) => {
|
|
6378
|
+
IneligibilityReason2["MINIMUM_NOT_MET"] = "minimum_not_met";
|
|
6379
|
+
IneligibilityReason2["NOT_SUPPORTED_DEPOSIT_FROM"] = "not_supported_deposit_from";
|
|
6380
|
+
return IneligibilityReason2;
|
|
6381
|
+
})(IneligibilityReason || {});
|
|
6377
6382
|
async function getAddressBalances(address, chainType, publishableKey) {
|
|
6378
6383
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6379
6384
|
validatePublishableKey(pk);
|
|
@@ -6580,7 +6585,7 @@ var i18n = en_default;
|
|
|
6580
6585
|
// ../ui-react/dist/index.mjs
|
|
6581
6586
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
6582
6587
|
import { useState as useState42 } from "react";
|
|
6583
|
-
import { useEffect as useEffect22, useState as useState22 } from "react";
|
|
6588
|
+
import { useEffect as useEffect22, useLayoutEffect as useLayoutEffect5, useState as useState22 } from "react";
|
|
6584
6589
|
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6585
6590
|
import * as React37 from "react";
|
|
6586
6591
|
import { jsx as jsx42, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
@@ -6637,16 +6642,16 @@ import { useState as useState152, useEffect as useEffect112 } from "react";
|
|
|
6637
6642
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
6638
6643
|
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
6639
6644
|
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
6640
|
-
import { useState as
|
|
6645
|
+
import { useState as useState192, useEffect as useEffect142, useMemo as useMemo42 } from "react";
|
|
6641
6646
|
var import_qr_code_styling = __toESM(require_qr_code_styling(), 1);
|
|
6642
|
-
import { useEffect as useEffect122, useRef as
|
|
6643
|
-
import { jsx as jsx31
|
|
6644
|
-
import { useState as
|
|
6645
|
-
import { jsx as jsx322, jsxs as
|
|
6646
|
-
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
6647
|
+
import { useEffect as useEffect122, useRef as useRef42 } from "react";
|
|
6648
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
6649
|
+
import { useState as useState162, useMemo as useMemo32, useEffect as useEffect132 } from "react";
|
|
6650
|
+
import { jsx as jsx322, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
6651
|
+
import { jsx as jsx33, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6647
6652
|
import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6648
6653
|
import { jsx as jsx35, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
6649
|
-
import { useState as
|
|
6654
|
+
import { useState as useState172 } from "react";
|
|
6650
6655
|
import * as React212 from "react";
|
|
6651
6656
|
|
|
6652
6657
|
// ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._aqltx4jspgwttwvtzmq3z5uagy/node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
@@ -9386,7 +9391,7 @@ var Content22 = TooltipContent;
|
|
|
9386
9391
|
// ../ui-react/dist/index.mjs
|
|
9387
9392
|
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
9388
9393
|
import { Fragment as Fragment42, jsx as jsx37, jsxs as jsxs322 } from "react/jsx-runtime";
|
|
9389
|
-
import { useState as
|
|
9394
|
+
import { useState as useState202, useEffect as useEffect152, useMemo as useMemo52 } from "react";
|
|
9390
9395
|
import * as React222 from "react";
|
|
9391
9396
|
|
|
9392
9397
|
// ../../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
|
|
@@ -10785,6 +10790,26 @@ function cn(...inputs) {
|
|
|
10785
10790
|
return twMerge(clsx(inputs));
|
|
10786
10791
|
}
|
|
10787
10792
|
var WALLET_CHAIN_TYPE_STORAGE_KEY = "unifold_last_wallet_type";
|
|
10793
|
+
var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
|
|
10794
|
+
function getUserDisconnectedWallet() {
|
|
10795
|
+
if (typeof window === "undefined") return false;
|
|
10796
|
+
try {
|
|
10797
|
+
return localStorage.getItem(WALLET_USER_DISCONNECTED_KEY) === "true";
|
|
10798
|
+
} catch {
|
|
10799
|
+
return false;
|
|
10800
|
+
}
|
|
10801
|
+
}
|
|
10802
|
+
function setUserDisconnectedWallet(disconnected) {
|
|
10803
|
+
if (typeof window === "undefined") return;
|
|
10804
|
+
try {
|
|
10805
|
+
if (disconnected) {
|
|
10806
|
+
localStorage.setItem(WALLET_USER_DISCONNECTED_KEY, "true");
|
|
10807
|
+
} else {
|
|
10808
|
+
localStorage.removeItem(WALLET_USER_DISCONNECTED_KEY);
|
|
10809
|
+
}
|
|
10810
|
+
} catch {
|
|
10811
|
+
}
|
|
10812
|
+
}
|
|
10788
10813
|
function getStoredWalletChainType() {
|
|
10789
10814
|
if (typeof window === "undefined") return void 0;
|
|
10790
10815
|
try {
|
|
@@ -11320,8 +11345,119 @@ function useDepositAddress(params) {
|
|
|
11320
11345
|
// 1s, 2s, 4s (max 10s)
|
|
11321
11346
|
});
|
|
11322
11347
|
}
|
|
11348
|
+
function getIconUrl2(iconUrl, assetCdnUrl) {
|
|
11349
|
+
if (!iconUrl) return void 0;
|
|
11350
|
+
if (iconUrl.startsWith("http://") || iconUrl.startsWith("https://")) {
|
|
11351
|
+
return iconUrl;
|
|
11352
|
+
}
|
|
11353
|
+
if (assetCdnUrl) {
|
|
11354
|
+
return `${assetCdnUrl}${iconUrl.startsWith("/") ? "" : "/"}${iconUrl}`;
|
|
11355
|
+
}
|
|
11356
|
+
return iconUrl;
|
|
11357
|
+
}
|
|
11358
|
+
function getTokenFromBalance(balance) {
|
|
11359
|
+
if (balance.token) {
|
|
11360
|
+
return balance.token;
|
|
11361
|
+
}
|
|
11362
|
+
const legacyBalance = balance;
|
|
11363
|
+
if (legacyBalance.symbol && legacyBalance.decimals !== void 0) {
|
|
11364
|
+
return {
|
|
11365
|
+
symbol: legacyBalance.symbol,
|
|
11366
|
+
name: legacyBalance.name,
|
|
11367
|
+
icon_url: legacyBalance.icon_url,
|
|
11368
|
+
icon_urls: [],
|
|
11369
|
+
token_address: legacyBalance.token_address,
|
|
11370
|
+
chain_id: legacyBalance.chain_id,
|
|
11371
|
+
chain_name: legacyBalance.chain_name,
|
|
11372
|
+
chain_type: legacyBalance.chain_type,
|
|
11373
|
+
decimals: legacyBalance.decimals,
|
|
11374
|
+
chain_icon_url: legacyBalance.chain_icon_url,
|
|
11375
|
+
chain_icon_urls: [],
|
|
11376
|
+
minimum_deposit_amount_usd: 0
|
|
11377
|
+
};
|
|
11378
|
+
}
|
|
11379
|
+
return null;
|
|
11380
|
+
}
|
|
11381
|
+
function isBalanceEligible(balance) {
|
|
11382
|
+
if (balance.is_eligible !== void 0) {
|
|
11383
|
+
return balance.is_eligible;
|
|
11384
|
+
}
|
|
11385
|
+
const legacyBalance = balance;
|
|
11386
|
+
if (legacyBalance.is_eligible !== void 0) {
|
|
11387
|
+
return legacyBalance.is_eligible;
|
|
11388
|
+
}
|
|
11389
|
+
return true;
|
|
11390
|
+
}
|
|
11391
|
+
function getIneligibilityMessage(balance) {
|
|
11392
|
+
if (isBalanceEligible(balance)) {
|
|
11393
|
+
return null;
|
|
11394
|
+
}
|
|
11395
|
+
switch (balance.ineligibility_reason) {
|
|
11396
|
+
case IneligibilityReason.MINIMUM_NOT_MET:
|
|
11397
|
+
return "Low balance";
|
|
11398
|
+
case IneligibilityReason.NOT_SUPPORTED_DEPOSIT_FROM:
|
|
11399
|
+
return "Not supported";
|
|
11400
|
+
default:
|
|
11401
|
+
return "Not eligible";
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
function formatTokenAmount(amount, decimals, symbol) {
|
|
11405
|
+
const value = Number(amount) / 10 ** decimals;
|
|
11406
|
+
const upperSymbol = symbol.toUpperCase();
|
|
11407
|
+
let maxDecimals = 4;
|
|
11408
|
+
if (upperSymbol === "BTC" || upperSymbol === "WBTC") {
|
|
11409
|
+
maxDecimals = 8;
|
|
11410
|
+
} else if (upperSymbol === "ETH" || upperSymbol === "WETH" || upperSymbol === "SOL") {
|
|
11411
|
+
maxDecimals = 6;
|
|
11412
|
+
}
|
|
11413
|
+
if (value >= 1) {
|
|
11414
|
+
return value.toLocaleString(void 0, {
|
|
11415
|
+
minimumFractionDigits: 2,
|
|
11416
|
+
maximumFractionDigits: maxDecimals
|
|
11417
|
+
});
|
|
11418
|
+
} else if (value > 0) {
|
|
11419
|
+
return value.toLocaleString(void 0, {
|
|
11420
|
+
minimumFractionDigits: 2,
|
|
11421
|
+
maximumFractionDigits: maxDecimals,
|
|
11422
|
+
minimumSignificantDigits: 2,
|
|
11423
|
+
maximumSignificantDigits: 6
|
|
11424
|
+
});
|
|
11425
|
+
}
|
|
11426
|
+
return "0.00";
|
|
11427
|
+
}
|
|
11428
|
+
function formatUsdAmount(amountUsd) {
|
|
11429
|
+
if (!amountUsd) return null;
|
|
11430
|
+
const value = parseFloat(amountUsd);
|
|
11431
|
+
if (value <= 0) return null;
|
|
11432
|
+
return value.toLocaleString(void 0, {
|
|
11433
|
+
minimumFractionDigits: 2,
|
|
11434
|
+
maximumFractionDigits: 2
|
|
11435
|
+
});
|
|
11436
|
+
}
|
|
11437
|
+
function truncateAddress2(address) {
|
|
11438
|
+
if (address.length <= 13) return address;
|
|
11439
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
11440
|
+
}
|
|
11441
|
+
function formatBalanceDisplay(balance, projectName) {
|
|
11442
|
+
return projectName ? `${projectName} Balance: ${balance}` : `Balance: ${balance}`;
|
|
11443
|
+
}
|
|
11444
|
+
function formatProcessingTime(seconds) {
|
|
11445
|
+
if (seconds === null || seconds === 0) {
|
|
11446
|
+
return "< 1 min";
|
|
11447
|
+
}
|
|
11448
|
+
const minutes = Math.floor(seconds / 60);
|
|
11449
|
+
const remainingSeconds = seconds % 60;
|
|
11450
|
+
if (minutes === 0) {
|
|
11451
|
+
return `< ${remainingSeconds} sec`;
|
|
11452
|
+
} else if (remainingSeconds === 0) {
|
|
11453
|
+
return `< ${minutes} min`;
|
|
11454
|
+
} else {
|
|
11455
|
+
return `< ${minutes} min ${remainingSeconds} sec`;
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11323
11458
|
function DepositHeader({
|
|
11324
11459
|
title,
|
|
11460
|
+
subtitle,
|
|
11325
11461
|
showBack = false,
|
|
11326
11462
|
showClose = true,
|
|
11327
11463
|
onBack,
|
|
@@ -11332,19 +11468,41 @@ function DepositHeader({
|
|
|
11332
11468
|
balanceChainType,
|
|
11333
11469
|
balanceChainId,
|
|
11334
11470
|
balanceTokenAddress,
|
|
11471
|
+
projectName,
|
|
11335
11472
|
publishableKey
|
|
11336
11473
|
}) {
|
|
11337
11474
|
const { colors: colors2, fonts, components } = useTheme();
|
|
11338
11475
|
const [balance, setBalance] = useState22(null);
|
|
11339
11476
|
const [isLoadingBalance, setIsLoadingBalance] = useState22(false);
|
|
11477
|
+
const [showBalanceSkeleton, setShowBalanceSkeleton] = useState22(false);
|
|
11478
|
+
const showBalanceBlock = showBalance === true;
|
|
11479
|
+
useLayoutEffect5(() => {
|
|
11480
|
+
if (!showBalanceBlock) {
|
|
11481
|
+
setBalance(null);
|
|
11482
|
+
setIsLoadingBalance(false);
|
|
11483
|
+
setShowBalanceSkeleton(false);
|
|
11484
|
+
}
|
|
11485
|
+
}, [showBalanceBlock]);
|
|
11340
11486
|
useEffect22(() => {
|
|
11341
11487
|
if (!showBalance || !balanceAddress || !balanceChainType || !balanceChainId || !balanceTokenAddress || !publishableKey) {
|
|
11342
11488
|
setBalance(null);
|
|
11343
11489
|
setIsLoadingBalance(false);
|
|
11490
|
+
setShowBalanceSkeleton(false);
|
|
11491
|
+
return;
|
|
11492
|
+
}
|
|
11493
|
+
const supportedChainTypes = ["ethereum", "solana", "bitcoin"];
|
|
11494
|
+
if (!supportedChainTypes.includes(balanceChainType)) {
|
|
11495
|
+
setBalance(null);
|
|
11496
|
+
setIsLoadingBalance(false);
|
|
11497
|
+
setShowBalanceSkeleton(false);
|
|
11344
11498
|
return;
|
|
11345
11499
|
}
|
|
11346
11500
|
let cancelled = false;
|
|
11347
11501
|
setIsLoadingBalance(true);
|
|
11502
|
+
setShowBalanceSkeleton(false);
|
|
11503
|
+
const skeletonTimer = window.setTimeout(() => {
|
|
11504
|
+
if (!cancelled) setShowBalanceSkeleton(true);
|
|
11505
|
+
}, 150);
|
|
11348
11506
|
getAddressBalance(
|
|
11349
11507
|
balanceAddress,
|
|
11350
11508
|
balanceChainType,
|
|
@@ -11353,7 +11511,7 @@ function DepositHeader({
|
|
|
11353
11511
|
publishableKey
|
|
11354
11512
|
).then((response) => {
|
|
11355
11513
|
if (cancelled) return;
|
|
11356
|
-
if (response.balance
|
|
11514
|
+
if (response.balance) {
|
|
11357
11515
|
const token = response.balance.token;
|
|
11358
11516
|
if (!token) {
|
|
11359
11517
|
setBalance(null);
|
|
@@ -11381,12 +11539,12 @@ function DepositHeader({
|
|
|
11381
11539
|
maximumSignificantDigits: 6
|
|
11382
11540
|
});
|
|
11383
11541
|
} else {
|
|
11384
|
-
formatted = value.toExponential(2);
|
|
11542
|
+
formatted = value === 0 ? "0.00" : value.toExponential(2);
|
|
11385
11543
|
}
|
|
11386
|
-
const
|
|
11387
|
-
setBalance(
|
|
11544
|
+
const amountPart = response.balance.amount_usd != null && response.balance.amount_usd !== "" ? `$${response.balance.amount_usd} (${formatted} ${response.balance.token.symbol})` : `${formatted} ${response.balance.token.symbol}`;
|
|
11545
|
+
setBalance(amountPart);
|
|
11388
11546
|
} else {
|
|
11389
|
-
setBalance(
|
|
11547
|
+
setBalance("$0.00");
|
|
11390
11548
|
}
|
|
11391
11549
|
}).catch((error) => {
|
|
11392
11550
|
if (cancelled) return;
|
|
@@ -11395,9 +11553,11 @@ function DepositHeader({
|
|
|
11395
11553
|
}).finally(() => {
|
|
11396
11554
|
if (cancelled) return;
|
|
11397
11555
|
setIsLoadingBalance(false);
|
|
11556
|
+
setShowBalanceSkeleton(false);
|
|
11398
11557
|
});
|
|
11399
11558
|
return () => {
|
|
11400
11559
|
cancelled = true;
|
|
11560
|
+
window.clearTimeout(skeletonTimer);
|
|
11401
11561
|
};
|
|
11402
11562
|
}, [
|
|
11403
11563
|
showBalance,
|
|
@@ -11453,18 +11613,27 @@ function DepositHeader({
|
|
|
11453
11613
|
children: title
|
|
11454
11614
|
}
|
|
11455
11615
|
),
|
|
11456
|
-
|
|
11616
|
+
subtitle ? /* @__PURE__ */ jsx32(
|
|
11457
11617
|
"div",
|
|
11458
11618
|
{
|
|
11459
|
-
className: "uf-text-xs uf-mt-
|
|
11619
|
+
className: "uf-text-xs uf-mt-1",
|
|
11460
11620
|
style: {
|
|
11461
|
-
color: colors2.
|
|
11462
|
-
fontFamily: fonts.regular
|
|
11463
|
-
|
|
11621
|
+
color: colors2.foregroundMuted,
|
|
11622
|
+
fontFamily: fonts.regular
|
|
11623
|
+
},
|
|
11624
|
+
children: subtitle
|
|
11625
|
+
}
|
|
11626
|
+
) : showBalanceBlock ? isLoadingBalance && showBalanceSkeleton ? /* @__PURE__ */ jsx32("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-1" }) : balance ? /* @__PURE__ */ jsx32(
|
|
11627
|
+
"div",
|
|
11628
|
+
{
|
|
11629
|
+
className: "uf-text-xs uf-mt-1",
|
|
11630
|
+
style: {
|
|
11631
|
+
color: colors2.foregroundMuted,
|
|
11632
|
+
fontFamily: fonts.regular
|
|
11464
11633
|
},
|
|
11465
|
-
children: balance
|
|
11634
|
+
children: formatBalanceDisplay(balance, projectName)
|
|
11466
11635
|
}
|
|
11467
|
-
) : null
|
|
11636
|
+
) : null : null
|
|
11468
11637
|
] }),
|
|
11469
11638
|
showClose ? /* @__PURE__ */ jsx32(
|
|
11470
11639
|
"button",
|
|
@@ -11800,32 +11969,62 @@ function interpolate(template, params) {
|
|
|
11800
11969
|
return value !== void 0 ? String(value) : `{{${key}}}`;
|
|
11801
11970
|
});
|
|
11802
11971
|
}
|
|
11972
|
+
var DEPOSIT_CONFIRM_DELAY_MS = 1e4;
|
|
11973
|
+
var POLL_INTERVAL_MS = 2500;
|
|
11974
|
+
var POLL_ENDPOINT_INTERVAL_MS = 3e3;
|
|
11975
|
+
var CUTOFF_BUFFER_MS = 6e4;
|
|
11803
11976
|
function useDepositPolling({
|
|
11804
11977
|
userId,
|
|
11805
11978
|
publishableKey,
|
|
11979
|
+
depositConfirmationMode = "auto_ui",
|
|
11980
|
+
depositWalletId,
|
|
11806
11981
|
enabled = true,
|
|
11807
11982
|
onDepositSuccess,
|
|
11808
11983
|
onDepositError
|
|
11809
11984
|
}) {
|
|
11810
11985
|
const [executions, setExecutions] = useState52([]);
|
|
11811
11986
|
const [isPolling, setIsPolling] = useState52(false);
|
|
11812
|
-
const
|
|
11813
|
-
|
|
11814
|
-
);
|
|
11815
|
-
const
|
|
11816
|
-
const
|
|
11987
|
+
const [pollingEnabled, setPollingEnabled] = useState52(false);
|
|
11988
|
+
const [showWaitingUi, setShowWaitingUi] = useState52(false);
|
|
11989
|
+
const modalOpenedAtRef = useRef16(/* @__PURE__ */ new Date());
|
|
11990
|
+
const trackedExecutionsRef = useRef16(/* @__PURE__ */ new Map());
|
|
11991
|
+
const onDepositSuccessRef = useRef16(onDepositSuccess);
|
|
11992
|
+
const onDepositErrorRef = useRef16(onDepositError);
|
|
11993
|
+
useEffect32(() => {
|
|
11994
|
+
onDepositSuccessRef.current = onDepositSuccess;
|
|
11995
|
+
}, [onDepositSuccess]);
|
|
11996
|
+
useEffect32(() => {
|
|
11997
|
+
onDepositErrorRef.current = onDepositError;
|
|
11998
|
+
}, [onDepositError]);
|
|
11999
|
+
useEffect32(() => {
|
|
12000
|
+
if (depositConfirmationMode === "manual" || !enabled) return;
|
|
12001
|
+
const timeout = setTimeout(() => {
|
|
12002
|
+
setPollingEnabled(true);
|
|
12003
|
+
if (depositConfirmationMode === "auto_ui") {
|
|
12004
|
+
setShowWaitingUi(true);
|
|
12005
|
+
}
|
|
12006
|
+
}, DEPOSIT_CONFIRM_DELAY_MS);
|
|
12007
|
+
return () => clearTimeout(timeout);
|
|
12008
|
+
}, [depositConfirmationMode, enabled]);
|
|
11817
12009
|
useEffect32(() => {
|
|
11818
|
-
if (!userId || !
|
|
11819
|
-
const
|
|
12010
|
+
if (!userId || !enabled) return;
|
|
12011
|
+
const modalOpenedAt = modalOpenedAtRef.current;
|
|
12012
|
+
const poll = async () => {
|
|
11820
12013
|
try {
|
|
11821
12014
|
const response = await queryExecutions(userId, publishableKey);
|
|
12015
|
+
const cutoff = new Date(modalOpenedAt.getTime() - CUTOFF_BUFFER_MS);
|
|
12016
|
+
const sortedExecutions = [...response.data].sort((a, b) => {
|
|
12017
|
+
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
12018
|
+
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
12019
|
+
return timeB - timeA;
|
|
12020
|
+
});
|
|
11822
12021
|
let executionToShow = null;
|
|
11823
|
-
for (const execution of
|
|
12022
|
+
for (const execution of sortedExecutions) {
|
|
11824
12023
|
const executionTime = execution.created_at ? new Date(execution.created_at) : null;
|
|
11825
|
-
if (!executionTime || executionTime
|
|
12024
|
+
if (!executionTime || executionTime < cutoff) {
|
|
11826
12025
|
continue;
|
|
11827
12026
|
}
|
|
11828
|
-
const trackedStatus =
|
|
12027
|
+
const trackedStatus = trackedExecutionsRef.current.get(execution.id);
|
|
11829
12028
|
if (!trackedStatus) {
|
|
11830
12029
|
executionToShow = execution;
|
|
11831
12030
|
break;
|
|
@@ -11846,35 +12045,30 @@ function useDepositPolling({
|
|
|
11846
12045
|
}
|
|
11847
12046
|
if (executionToShow) {
|
|
11848
12047
|
const execution = executionToShow;
|
|
12048
|
+
const previousStatus = trackedExecutionsRef.current.get(execution.id);
|
|
12049
|
+
trackedExecutionsRef.current.set(execution.id, execution.status);
|
|
11849
12050
|
setExecutions((prev) => {
|
|
11850
12051
|
const existingIndex = prev.findIndex((e) => e.id === execution.id);
|
|
11851
12052
|
if (existingIndex >= 0) {
|
|
11852
12053
|
const updated = [...prev];
|
|
11853
12054
|
updated[existingIndex] = execution;
|
|
11854
12055
|
return updated;
|
|
11855
|
-
} else {
|
|
11856
|
-
return [...prev, execution];
|
|
11857
12056
|
}
|
|
11858
|
-
|
|
11859
|
-
const previousStatus = trackedExecutions.get(execution.id);
|
|
11860
|
-
setTrackedExecutions((prev) => {
|
|
11861
|
-
const updated = new Map(prev);
|
|
11862
|
-
updated.set(execution.id, execution.status);
|
|
11863
|
-
return updated;
|
|
12057
|
+
return [...prev, execution];
|
|
11864
12058
|
});
|
|
11865
12059
|
const inProgressStatuses = [
|
|
11866
12060
|
ExecutionStatus.PENDING,
|
|
11867
12061
|
ExecutionStatus.WAITING,
|
|
11868
12062
|
ExecutionStatus.DELAYED
|
|
11869
12063
|
];
|
|
11870
|
-
if (execution.status === ExecutionStatus.SUCCEEDED &&
|
|
11871
|
-
|
|
12064
|
+
if (execution.status === ExecutionStatus.SUCCEEDED && (!previousStatus || inProgressStatuses.includes(previousStatus))) {
|
|
12065
|
+
onDepositSuccessRef.current?.({
|
|
11872
12066
|
message: "Deposit completed successfully",
|
|
11873
12067
|
executionId: execution.id,
|
|
11874
12068
|
transaction: execution
|
|
11875
12069
|
});
|
|
11876
|
-
} else if (execution.status === ExecutionStatus.FAILED &&
|
|
11877
|
-
|
|
12070
|
+
} else if (execution.status === ExecutionStatus.FAILED && previousStatus !== ExecutionStatus.FAILED) {
|
|
12071
|
+
onDepositErrorRef.current?.({
|
|
11878
12072
|
message: "Deposit failed",
|
|
11879
12073
|
code: "DEPOSIT_FAILED",
|
|
11880
12074
|
error: execution
|
|
@@ -11883,36 +12077,45 @@ function useDepositPolling({
|
|
|
11883
12077
|
}
|
|
11884
12078
|
} catch (error) {
|
|
11885
12079
|
console.error("Failed to fetch executions:", error);
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
});
|
|
11892
|
-
}
|
|
12080
|
+
onDepositErrorRef.current?.({
|
|
12081
|
+
message: "Failed to fetch deposit status",
|
|
12082
|
+
code: "POLLING_ERROR",
|
|
12083
|
+
error
|
|
12084
|
+
});
|
|
11893
12085
|
}
|
|
11894
|
-
}
|
|
12086
|
+
};
|
|
12087
|
+
const pollInterval = setInterval(poll, POLL_INTERVAL_MS);
|
|
11895
12088
|
setIsPolling(true);
|
|
11896
|
-
pollingIntervalRef.current = pollInterval;
|
|
11897
12089
|
return () => {
|
|
11898
|
-
|
|
11899
|
-
clearInterval(pollingIntervalRef.current);
|
|
11900
|
-
pollingIntervalRef.current = null;
|
|
11901
|
-
}
|
|
12090
|
+
clearInterval(pollInterval);
|
|
11902
12091
|
setIsPolling(false);
|
|
11903
12092
|
};
|
|
11904
|
-
}, [
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
12093
|
+
}, [userId, publishableKey, enabled]);
|
|
12094
|
+
useEffect32(() => {
|
|
12095
|
+
if (!pollingEnabled || !depositWalletId) return;
|
|
12096
|
+
const triggerPoll = async () => {
|
|
12097
|
+
try {
|
|
12098
|
+
await pollDirectExecutions(
|
|
12099
|
+
{ deposit_wallet_id: depositWalletId },
|
|
12100
|
+
publishableKey
|
|
12101
|
+
);
|
|
12102
|
+
} catch {
|
|
12103
|
+
}
|
|
12104
|
+
};
|
|
12105
|
+
triggerPoll();
|
|
12106
|
+
const interval = setInterval(triggerPoll, POLL_ENDPOINT_INTERVAL_MS);
|
|
12107
|
+
return () => clearInterval(interval);
|
|
12108
|
+
}, [pollingEnabled, depositWalletId, publishableKey]);
|
|
12109
|
+
const handleIveDeposited = () => {
|
|
12110
|
+
setPollingEnabled(true);
|
|
12111
|
+
setShowWaitingUi(true);
|
|
12112
|
+
};
|
|
11913
12113
|
return {
|
|
11914
12114
|
executions,
|
|
11915
|
-
isPolling
|
|
12115
|
+
isPolling,
|
|
12116
|
+
pollingEnabled,
|
|
12117
|
+
showWaitingUi,
|
|
12118
|
+
handleIveDeposited
|
|
11916
12119
|
};
|
|
11917
12120
|
}
|
|
11918
12121
|
function formatCurrency(currency) {
|
|
@@ -15660,10 +15863,48 @@ var WALLET_ICON_COMPONENTS = {
|
|
|
15660
15863
|
backpack: BackpackIcon,
|
|
15661
15864
|
glow: GlowIcon
|
|
15662
15865
|
};
|
|
15663
|
-
function
|
|
15866
|
+
function truncateAddress3(address) {
|
|
15664
15867
|
if (address.length <= 10) return address;
|
|
15665
15868
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
15666
15869
|
}
|
|
15870
|
+
function identifyEthWallet(provider, _win, hint) {
|
|
15871
|
+
switch (hint) {
|
|
15872
|
+
case "metamask":
|
|
15873
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
15874
|
+
case "phantom":
|
|
15875
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
15876
|
+
case "coinbase":
|
|
15877
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
15878
|
+
case "okx":
|
|
15879
|
+
return { type: "okx", name: "OKX Wallet", icon: "okx" };
|
|
15880
|
+
case "rabby":
|
|
15881
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
15882
|
+
case "trust":
|
|
15883
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
15884
|
+
case "rainbow":
|
|
15885
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
15886
|
+
}
|
|
15887
|
+
const anyProvider = provider;
|
|
15888
|
+
if (provider.isPhantom) {
|
|
15889
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
15890
|
+
}
|
|
15891
|
+
if (anyProvider.isCoinbaseWallet) {
|
|
15892
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
15893
|
+
}
|
|
15894
|
+
if (anyProvider.isRabby) {
|
|
15895
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
15896
|
+
}
|
|
15897
|
+
if (anyProvider.isTrust) {
|
|
15898
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
15899
|
+
}
|
|
15900
|
+
if (anyProvider.isRainbow) {
|
|
15901
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
15902
|
+
}
|
|
15903
|
+
if (provider.isMetaMask && !provider.isPhantom) {
|
|
15904
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
15905
|
+
}
|
|
15906
|
+
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
15907
|
+
}
|
|
15667
15908
|
function BrowserWalletButton({
|
|
15668
15909
|
onClick,
|
|
15669
15910
|
onConnectClick,
|
|
@@ -15680,9 +15921,35 @@ function BrowserWalletButton({
|
|
|
15680
15921
|
const [balanceText, setBalanceText] = React202.useState(null);
|
|
15681
15922
|
const [isLoadingBalance, setIsLoadingBalance] = React202.useState(false);
|
|
15682
15923
|
const iconVariant = mode === "dark" ? "light" : "dark";
|
|
15924
|
+
const onDisconnectRef = React202.useRef(onDisconnect);
|
|
15925
|
+
onDisconnectRef.current = onDisconnect;
|
|
15683
15926
|
React202.useEffect(() => {
|
|
15684
15927
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
15685
15928
|
}, []);
|
|
15929
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React202.useState(0);
|
|
15930
|
+
React202.useEffect(() => {
|
|
15931
|
+
if (typeof window === "undefined") return;
|
|
15932
|
+
const anyWin = window;
|
|
15933
|
+
if (!anyWin.__eip6963Providers) {
|
|
15934
|
+
anyWin.__eip6963Providers = [];
|
|
15935
|
+
}
|
|
15936
|
+
const handleAnnouncement = (event) => {
|
|
15937
|
+
const { detail } = event;
|
|
15938
|
+
if (!detail?.info || !detail?.provider) return;
|
|
15939
|
+
const exists = anyWin.__eip6963Providers.some(
|
|
15940
|
+
(p) => p.info.uuid === detail.info.uuid
|
|
15941
|
+
);
|
|
15942
|
+
if (!exists) {
|
|
15943
|
+
anyWin.__eip6963Providers.push(detail);
|
|
15944
|
+
setEip6963ProviderCount(anyWin.__eip6963Providers.length);
|
|
15945
|
+
}
|
|
15946
|
+
};
|
|
15947
|
+
window.addEventListener("eip6963:announceProvider", handleAnnouncement);
|
|
15948
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
15949
|
+
return () => {
|
|
15950
|
+
window.removeEventListener("eip6963:announceProvider", handleAnnouncement);
|
|
15951
|
+
};
|
|
15952
|
+
}, []);
|
|
15686
15953
|
React202.useEffect(() => {
|
|
15687
15954
|
if (!wallet || !publishableKey) {
|
|
15688
15955
|
setBalanceText(null);
|
|
@@ -15732,166 +15999,85 @@ function BrowserWalletButton({
|
|
|
15732
15999
|
try {
|
|
15733
16000
|
const win = typeof window !== "undefined" ? window : null;
|
|
15734
16001
|
if (!win) return;
|
|
16002
|
+
if (getUserDisconnectedWallet()) {
|
|
16003
|
+
if (mounted) {
|
|
16004
|
+
setWallet(null);
|
|
16005
|
+
setIsLoading(false);
|
|
16006
|
+
}
|
|
16007
|
+
return;
|
|
16008
|
+
}
|
|
15735
16009
|
if (!chainType || chainType === "solana") {
|
|
15736
|
-
const
|
|
15737
|
-
|
|
15738
|
-
if (
|
|
16010
|
+
const anyWin2 = win;
|
|
16011
|
+
const trySilentSolana = async (provider, type, name, icon) => {
|
|
16012
|
+
if (!provider) return false;
|
|
16013
|
+
if (provider.isConnected && provider.publicKey) {
|
|
15739
16014
|
if (mounted) {
|
|
15740
|
-
setWallet({
|
|
15741
|
-
type: "phantom-solana",
|
|
15742
|
-
name: "Phantom",
|
|
15743
|
-
address: phantomSolana.publicKey.toString(),
|
|
15744
|
-
icon: "phantom"
|
|
15745
|
-
});
|
|
16015
|
+
setWallet({ type, name, address: provider.publicKey.toString(), icon });
|
|
15746
16016
|
setIsLoading(false);
|
|
15747
16017
|
}
|
|
15748
|
-
return;
|
|
16018
|
+
return true;
|
|
15749
16019
|
}
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
icon: "solflare"
|
|
15759
|
-
});
|
|
15760
|
-
setIsLoading(false);
|
|
16020
|
+
try {
|
|
16021
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
16022
|
+
if (mounted && resp.publicKey) {
|
|
16023
|
+
setWallet({ type, name, address: resp.publicKey.toString(), icon });
|
|
16024
|
+
setIsLoading(false);
|
|
16025
|
+
return true;
|
|
16026
|
+
}
|
|
16027
|
+
} catch {
|
|
15761
16028
|
}
|
|
15762
|
-
return;
|
|
16029
|
+
return false;
|
|
16030
|
+
};
|
|
16031
|
+
if (await trySilentSolana(win.phantom?.solana, "phantom-solana", "Phantom", "phantom")) return;
|
|
16032
|
+
if (await trySilentSolana(anyWin2.solflare, "solflare", "Solflare", "solflare")) return;
|
|
16033
|
+
if (await trySilentSolana(anyWin2.backpack, "backpack", "Backpack", "backpack")) return;
|
|
16034
|
+
if (await trySilentSolana(anyWin2.glow, "glow", "Glow", "glow")) return;
|
|
16035
|
+
}
|
|
16036
|
+
if (!chainType || chainType === "ethereum") {
|
|
16037
|
+
const anyWin2 = win;
|
|
16038
|
+
const allProviders = [];
|
|
16039
|
+
const eip6963Providers = anyWin2.__eip6963Providers || [];
|
|
16040
|
+
for (const { info, provider } of eip6963Providers) {
|
|
16041
|
+
let walletId = "default";
|
|
16042
|
+
if (info.rdns.includes("metamask")) walletId = "metamask";
|
|
16043
|
+
else if (info.rdns.includes("phantom")) walletId = "phantom";
|
|
16044
|
+
else if (info.rdns.includes("coinbase")) walletId = "coinbase";
|
|
16045
|
+
else if (info.rdns.includes("okx")) walletId = "okx";
|
|
16046
|
+
else if (info.rdns.includes("rabby")) walletId = "rabby";
|
|
16047
|
+
else if (info.rdns.includes("trust")) walletId = "trust";
|
|
16048
|
+
else if (info.rdns.includes("rainbow")) walletId = "rainbow";
|
|
16049
|
+
allProviders.push({ provider, walletId });
|
|
15763
16050
|
}
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
setWallet({
|
|
15768
|
-
type: "backpack",
|
|
15769
|
-
name: "Backpack",
|
|
15770
|
-
address: backpack.publicKey.toString(),
|
|
15771
|
-
icon: "backpack"
|
|
15772
|
-
});
|
|
15773
|
-
setIsLoading(false);
|
|
16051
|
+
if (allProviders.length === 0) {
|
|
16052
|
+
if (win.phantom?.ethereum) {
|
|
16053
|
+
allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
|
|
15774
16054
|
}
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
}
|
|
15786
|
-
setIsLoading(false);
|
|
16055
|
+
if (anyWin2.okxwallet) {
|
|
16056
|
+
allProviders.push({ provider: anyWin2.okxwallet, walletId: "okx" });
|
|
16057
|
+
}
|
|
16058
|
+
if (anyWin2.coinbaseWalletExtension) {
|
|
16059
|
+
allProviders.push({ provider: anyWin2.coinbaseWalletExtension, walletId: "coinbase" });
|
|
16060
|
+
}
|
|
16061
|
+
if (win.ethereum) {
|
|
16062
|
+
const isDuplicate = allProviders.some((p) => p.provider === win.ethereum);
|
|
16063
|
+
if (!isDuplicate) {
|
|
16064
|
+
allProviders.push({ provider: win.ethereum, walletId: "default" });
|
|
16065
|
+
}
|
|
15787
16066
|
}
|
|
15788
|
-
return;
|
|
15789
16067
|
}
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
const ethProvider2 = win.ethereum;
|
|
15793
|
-
if (ethProvider2) {
|
|
16068
|
+
for (const { provider, walletId } of allProviders) {
|
|
16069
|
+
if (!provider) continue;
|
|
15794
16070
|
try {
|
|
15795
|
-
const accounts = await
|
|
15796
|
-
if (accounts
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
setWallet({
|
|
15803
|
-
type: "okx",
|
|
15804
|
-
name: "OKX Wallet",
|
|
15805
|
-
address,
|
|
15806
|
-
icon: "okx"
|
|
15807
|
-
});
|
|
15808
|
-
setIsLoading(false);
|
|
15809
|
-
}
|
|
15810
|
-
return;
|
|
15811
|
-
}
|
|
15812
|
-
if (ethProvider2.isRabby) {
|
|
15813
|
-
if (mounted) {
|
|
15814
|
-
setWallet({
|
|
15815
|
-
type: "rabby",
|
|
15816
|
-
name: "Rabby",
|
|
15817
|
-
address,
|
|
15818
|
-
icon: "rabby"
|
|
15819
|
-
});
|
|
15820
|
-
setIsLoading(false);
|
|
15821
|
-
}
|
|
15822
|
-
return;
|
|
15823
|
-
}
|
|
15824
|
-
if (ethProvider2.isTrust || win.trustwallet) {
|
|
15825
|
-
if (mounted) {
|
|
15826
|
-
setWallet({
|
|
15827
|
-
type: "trust",
|
|
15828
|
-
name: "Trust Wallet",
|
|
15829
|
-
address,
|
|
15830
|
-
icon: "trust"
|
|
15831
|
-
});
|
|
15832
|
-
setIsLoading(false);
|
|
15833
|
-
}
|
|
15834
|
-
return;
|
|
15835
|
-
}
|
|
15836
|
-
if (ethProvider2.isRainbow) {
|
|
15837
|
-
if (mounted) {
|
|
15838
|
-
setWallet({
|
|
15839
|
-
type: "rainbow",
|
|
15840
|
-
name: "Rainbow",
|
|
15841
|
-
address,
|
|
15842
|
-
icon: "rainbow"
|
|
15843
|
-
});
|
|
15844
|
-
setIsLoading(false);
|
|
15845
|
-
}
|
|
15846
|
-
return;
|
|
15847
|
-
}
|
|
15848
|
-
if (mounted) {
|
|
15849
|
-
setWallet({
|
|
15850
|
-
type: "metamask",
|
|
15851
|
-
name: "MetaMask",
|
|
15852
|
-
address,
|
|
15853
|
-
icon: "metamask"
|
|
15854
|
-
});
|
|
15855
|
-
setIsLoading(false);
|
|
15856
|
-
}
|
|
15857
|
-
return;
|
|
15858
|
-
}
|
|
15859
|
-
if (ethProvider2.isPhantom) {
|
|
15860
|
-
if (mounted) {
|
|
15861
|
-
setWallet({
|
|
15862
|
-
type: "phantom-ethereum",
|
|
15863
|
-
name: "Phantom",
|
|
15864
|
-
address,
|
|
15865
|
-
icon: "phantom"
|
|
15866
|
-
});
|
|
15867
|
-
setIsLoading(false);
|
|
15868
|
-
}
|
|
15869
|
-
return;
|
|
15870
|
-
}
|
|
15871
|
-
if (ethProvider2.isCoinbaseWallet) {
|
|
15872
|
-
if (mounted) {
|
|
15873
|
-
setWallet({
|
|
15874
|
-
type: "coinbase",
|
|
15875
|
-
name: "Coinbase Wallet",
|
|
15876
|
-
address,
|
|
15877
|
-
icon: "coinbase"
|
|
15878
|
-
});
|
|
15879
|
-
setIsLoading(false);
|
|
15880
|
-
}
|
|
15881
|
-
return;
|
|
15882
|
-
}
|
|
15883
|
-
if (mounted) {
|
|
15884
|
-
setWallet({
|
|
15885
|
-
type: "metamask",
|
|
15886
|
-
name: "Wallet",
|
|
15887
|
-
address,
|
|
15888
|
-
icon: "metamask"
|
|
15889
|
-
});
|
|
15890
|
-
setIsLoading(false);
|
|
15891
|
-
}
|
|
15892
|
-
return;
|
|
16071
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
16072
|
+
if (!accounts || accounts.length === 0) continue;
|
|
16073
|
+
const address = accounts[0];
|
|
16074
|
+
const resolved = identifyEthWallet(provider, anyWin2, walletId);
|
|
16075
|
+
if (mounted) {
|
|
16076
|
+
setWallet({ ...resolved, address });
|
|
16077
|
+
setIsLoading(false);
|
|
15893
16078
|
}
|
|
15894
|
-
|
|
16079
|
+
return;
|
|
16080
|
+
} catch {
|
|
15895
16081
|
}
|
|
15896
16082
|
}
|
|
15897
16083
|
}
|
|
@@ -15912,12 +16098,12 @@ function BrowserWalletButton({
|
|
|
15912
16098
|
detectWallet();
|
|
15913
16099
|
};
|
|
15914
16100
|
const handleDisconnect = () => {
|
|
15915
|
-
|
|
16101
|
+
onDisconnectRef.current?.();
|
|
15916
16102
|
detectWallet();
|
|
15917
16103
|
};
|
|
15918
16104
|
const handleEthAccountsChanged = (accounts) => {
|
|
15919
16105
|
if (Array.isArray(accounts) && accounts.length === 0) {
|
|
15920
|
-
|
|
16106
|
+
onDisconnectRef.current?.();
|
|
15921
16107
|
}
|
|
15922
16108
|
detectWallet();
|
|
15923
16109
|
};
|
|
@@ -15927,10 +16113,24 @@ function BrowserWalletButton({
|
|
|
15927
16113
|
solanaProvider.on("disconnect", handleDisconnect);
|
|
15928
16114
|
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
15929
16115
|
}
|
|
15930
|
-
const
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
16116
|
+
const anyWin = window;
|
|
16117
|
+
const ethProviders = [];
|
|
16118
|
+
if (anyWin.__eip6963Providers) {
|
|
16119
|
+
for (const { provider } of anyWin.__eip6963Providers) {
|
|
16120
|
+
if (provider && !ethProviders.includes(provider)) {
|
|
16121
|
+
ethProviders.push(provider);
|
|
16122
|
+
}
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
16126
|
+
ethProviders.push(window.ethereum);
|
|
16127
|
+
}
|
|
16128
|
+
if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
|
|
16129
|
+
ethProviders.push(window.phantom.ethereum);
|
|
16130
|
+
}
|
|
16131
|
+
for (const provider of ethProviders) {
|
|
16132
|
+
provider.on("accountsChanged", handleEthAccountsChanged);
|
|
16133
|
+
provider.on("chainChanged", handleAccountsChanged);
|
|
15934
16134
|
}
|
|
15935
16135
|
return () => {
|
|
15936
16136
|
mounted = false;
|
|
@@ -15939,12 +16139,12 @@ function BrowserWalletButton({
|
|
|
15939
16139
|
solanaProvider.off("disconnect", handleDisconnect);
|
|
15940
16140
|
solanaProvider.off("accountChanged", handleAccountsChanged);
|
|
15941
16141
|
}
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
16142
|
+
for (const provider of ethProviders) {
|
|
16143
|
+
provider.removeListener("accountsChanged", handleEthAccountsChanged);
|
|
16144
|
+
provider.removeListener("chainChanged", handleAccountsChanged);
|
|
15945
16145
|
}
|
|
15946
16146
|
};
|
|
15947
|
-
}, [chainType]);
|
|
16147
|
+
}, [chainType, eip6963ProviderCount]);
|
|
15948
16148
|
const handleConnect = async () => {
|
|
15949
16149
|
if (wallet) {
|
|
15950
16150
|
onClick(wallet);
|
|
@@ -15960,6 +16160,7 @@ function BrowserWalletButton({
|
|
|
15960
16160
|
const solanaProvider = window.phantom?.solana || window.solana;
|
|
15961
16161
|
if (solanaProvider?.isPhantom) {
|
|
15962
16162
|
const { publicKey } = await solanaProvider.connect();
|
|
16163
|
+
setUserDisconnectedWallet(false);
|
|
15963
16164
|
setWallet({
|
|
15964
16165
|
type: "phantom-solana",
|
|
15965
16166
|
name: "Phantom",
|
|
@@ -15977,6 +16178,7 @@ function BrowserWalletButton({
|
|
|
15977
16178
|
method: "eth_requestAccounts"
|
|
15978
16179
|
});
|
|
15979
16180
|
if (accounts && accounts.length > 0) {
|
|
16181
|
+
setUserDisconnectedWallet(false);
|
|
15980
16182
|
const isPhantom = ethProvider.isPhantom;
|
|
15981
16183
|
setWallet({
|
|
15982
16184
|
type: isPhantom ? "phantom-ethereum" : "metamask",
|
|
@@ -15988,7 +16190,10 @@ function BrowserWalletButton({
|
|
|
15988
16190
|
}
|
|
15989
16191
|
}
|
|
15990
16192
|
} catch (error) {
|
|
15991
|
-
|
|
16193
|
+
if (error && typeof error === "object" && "code" in error && error.code === 4001) {
|
|
16194
|
+
} else {
|
|
16195
|
+
console.error("Error connecting wallet:", error);
|
|
16196
|
+
}
|
|
15992
16197
|
} finally {
|
|
15993
16198
|
setIsConnecting(false);
|
|
15994
16199
|
}
|
|
@@ -16034,7 +16239,7 @@ function BrowserWalletButton({
|
|
|
16034
16239
|
color: components.card.titleColor,
|
|
16035
16240
|
fontFamily: fonts.regular
|
|
16036
16241
|
},
|
|
16037
|
-
children: wallet ? `${wallet.name} (${
|
|
16242
|
+
children: wallet ? `${wallet.name} (${truncateAddress3(wallet.address)})` : "Connect Wallet"
|
|
16038
16243
|
}
|
|
16039
16244
|
),
|
|
16040
16245
|
isLoadingBalance ? /* @__PURE__ */ jsx30("div", { className: "uf-h-3 uf-w-24 uf-bg-muted uf-rounded uf-animate-pulse" }) : /* @__PURE__ */ jsx30(
|
|
@@ -16206,11 +16411,6 @@ function useSupportedDepositTokens(publishableKey, options) {
|
|
|
16206
16411
|
refetchOnWindowFocus: false
|
|
16207
16412
|
});
|
|
16208
16413
|
}
|
|
16209
|
-
var qrCache = /* @__PURE__ */ new Map();
|
|
16210
|
-
var imageCache = /* @__PURE__ */ new Map();
|
|
16211
|
-
function getCacheKey(value, size4, imageUrl, darkMode) {
|
|
16212
|
-
return `${value}|${size4}|${imageUrl || ""}|${darkMode}`;
|
|
16213
|
-
}
|
|
16214
16414
|
function createQRConfig(value, size4, imageUrl, imageSize, darkMode) {
|
|
16215
16415
|
return {
|
|
16216
16416
|
type: "svg",
|
|
@@ -16247,72 +16447,6 @@ function createQRConfig(value, size4, imageUrl, imageSize, darkMode) {
|
|
|
16247
16447
|
}
|
|
16248
16448
|
};
|
|
16249
16449
|
}
|
|
16250
|
-
async function preloadImageAsync(url) {
|
|
16251
|
-
if (!url || imageCache.has(url)) return;
|
|
16252
|
-
return new Promise((resolve) => {
|
|
16253
|
-
const img = new Image();
|
|
16254
|
-
img.crossOrigin = "anonymous";
|
|
16255
|
-
img.onload = () => {
|
|
16256
|
-
imageCache.set(url, true);
|
|
16257
|
-
resolve();
|
|
16258
|
-
};
|
|
16259
|
-
img.onerror = () => {
|
|
16260
|
-
imageCache.set(url, false);
|
|
16261
|
-
resolve();
|
|
16262
|
-
};
|
|
16263
|
-
img.src = url;
|
|
16264
|
-
});
|
|
16265
|
-
}
|
|
16266
|
-
function waitForStyledQR(container, maxAttempts = 20) {
|
|
16267
|
-
return new Promise((resolve) => {
|
|
16268
|
-
let attempts = 0;
|
|
16269
|
-
const check = () => {
|
|
16270
|
-
const svg = container.querySelector("svg");
|
|
16271
|
-
if (!svg) {
|
|
16272
|
-
if (attempts++ < maxAttempts) {
|
|
16273
|
-
requestAnimationFrame(check);
|
|
16274
|
-
} else {
|
|
16275
|
-
resolve(null);
|
|
16276
|
-
}
|
|
16277
|
-
return;
|
|
16278
|
-
}
|
|
16279
|
-
const hasCircles = svg.querySelectorAll("circle").length > 0;
|
|
16280
|
-
const hasPaths = svg.querySelectorAll("path").length > 0;
|
|
16281
|
-
if (hasCircles || hasPaths) {
|
|
16282
|
-
resolve(svg.outerHTML);
|
|
16283
|
-
} else if (attempts++ < maxAttempts) {
|
|
16284
|
-
requestAnimationFrame(check);
|
|
16285
|
-
} else {
|
|
16286
|
-
resolve(svg.outerHTML);
|
|
16287
|
-
}
|
|
16288
|
-
};
|
|
16289
|
-
requestAnimationFrame(check);
|
|
16290
|
-
});
|
|
16291
|
-
}
|
|
16292
|
-
async function preloadQRCode(value, size4 = 180, imageUrl, imageSize = 45, darkMode = false) {
|
|
16293
|
-
if (!value) return;
|
|
16294
|
-
const cacheKey = getCacheKey(value, size4, imageUrl, darkMode);
|
|
16295
|
-
if (qrCache.has(cacheKey)) return;
|
|
16296
|
-
if (imageUrl) {
|
|
16297
|
-
await preloadImageAsync(imageUrl);
|
|
16298
|
-
}
|
|
16299
|
-
const tempContainer = document.createElement("div");
|
|
16300
|
-
tempContainer.style.position = "absolute";
|
|
16301
|
-
tempContainer.style.left = "-9999px";
|
|
16302
|
-
tempContainer.style.top = "-9999px";
|
|
16303
|
-
document.body.appendChild(tempContainer);
|
|
16304
|
-
try {
|
|
16305
|
-
const config = createQRConfig(value, size4, imageUrl, imageSize, darkMode);
|
|
16306
|
-
const qrInstance = new import_qr_code_styling.default(config);
|
|
16307
|
-
qrInstance.append(tempContainer);
|
|
16308
|
-
const svgString = await waitForStyledQR(tempContainer);
|
|
16309
|
-
if (svgString) {
|
|
16310
|
-
qrCache.set(cacheKey, { svgString });
|
|
16311
|
-
}
|
|
16312
|
-
} finally {
|
|
16313
|
-
document.body.removeChild(tempContainer);
|
|
16314
|
-
}
|
|
16315
|
-
}
|
|
16316
16450
|
function StyledQRCode({
|
|
16317
16451
|
value,
|
|
16318
16452
|
size: size4 = 180,
|
|
@@ -16320,108 +16454,29 @@ function StyledQRCode({
|
|
|
16320
16454
|
imageSize = 45,
|
|
16321
16455
|
darkMode = false
|
|
16322
16456
|
}) {
|
|
16323
|
-
const containerRef =
|
|
16324
|
-
const
|
|
16325
|
-
|
|
16326
|
-
const cacheKey = getCacheKey(value, size4, imageUrl, darkMode);
|
|
16327
|
-
const cachedEntry = qrCache.get(cacheKey);
|
|
16328
|
-
const renderQR = useCallback10(async () => {
|
|
16457
|
+
const containerRef = useRef42(null);
|
|
16458
|
+
const qrRef = useRef42(null);
|
|
16459
|
+
useEffect122(() => {
|
|
16329
16460
|
if (!containerRef.current || !value) return;
|
|
16330
|
-
const key = getCacheKey(value, size4, imageUrl, darkMode);
|
|
16331
|
-
if (currentKeyRef.current === key) {
|
|
16332
|
-
setIsReady(true);
|
|
16333
|
-
return;
|
|
16334
|
-
}
|
|
16335
|
-
currentKeyRef.current = key;
|
|
16336
|
-
containerRef.current.innerHTML = "";
|
|
16337
|
-
const cached = qrCache.get(key);
|
|
16338
|
-
if (cached?.svgString) {
|
|
16339
|
-
containerRef.current.innerHTML = cached.svgString;
|
|
16340
|
-
setIsReady(true);
|
|
16341
|
-
return;
|
|
16342
|
-
}
|
|
16343
|
-
if (imageUrl) {
|
|
16344
|
-
await preloadImageAsync(imageUrl);
|
|
16345
|
-
}
|
|
16346
16461
|
const config = createQRConfig(value, size4, imageUrl, imageSize, darkMode);
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16462
|
+
if (!qrRef.current) {
|
|
16463
|
+
qrRef.current = new import_qr_code_styling.default(config);
|
|
16464
|
+
qrRef.current.append(containerRef.current);
|
|
16465
|
+
} else {
|
|
16466
|
+
qrRef.current.update(config);
|
|
16352
16467
|
}
|
|
16353
|
-
setIsReady(true);
|
|
16354
16468
|
}, [value, size4, imageUrl, imageSize, darkMode]);
|
|
16355
|
-
|
|
16356
|
-
let mounted = true;
|
|
16357
|
-
const init = async () => {
|
|
16358
|
-
if (!mounted) return;
|
|
16359
|
-
await renderQR();
|
|
16360
|
-
};
|
|
16361
|
-
setIsReady(false);
|
|
16362
|
-
init();
|
|
16363
|
-
return () => {
|
|
16364
|
-
mounted = false;
|
|
16365
|
-
};
|
|
16366
|
-
}, [renderQR]);
|
|
16367
|
-
const showSkeleton = !isReady && !cachedEntry?.svgString;
|
|
16368
|
-
return /* @__PURE__ */ jsxs28(
|
|
16469
|
+
return /* @__PURE__ */ jsx31(
|
|
16369
16470
|
"div",
|
|
16370
16471
|
{
|
|
16472
|
+
ref: containerRef,
|
|
16371
16473
|
style: {
|
|
16372
16474
|
width: size4,
|
|
16373
16475
|
height: size4,
|
|
16374
16476
|
display: "flex",
|
|
16375
16477
|
alignItems: "center",
|
|
16376
|
-
justifyContent: "center"
|
|
16377
|
-
|
|
16378
|
-
},
|
|
16379
|
-
children: [
|
|
16380
|
-
showSkeleton && /* @__PURE__ */ jsx31(
|
|
16381
|
-
"div",
|
|
16382
|
-
{
|
|
16383
|
-
style: {
|
|
16384
|
-
position: "absolute",
|
|
16385
|
-
inset: 0,
|
|
16386
|
-
display: "flex",
|
|
16387
|
-
alignItems: "center",
|
|
16388
|
-
justifyContent: "center",
|
|
16389
|
-
background: darkMode ? "linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%)" : "linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%)",
|
|
16390
|
-
borderRadius: 8,
|
|
16391
|
-
animation: "uf-qr-pulse 1.5s ease-in-out infinite"
|
|
16392
|
-
},
|
|
16393
|
-
children: /* @__PURE__ */ jsx31(
|
|
16394
|
-
"div",
|
|
16395
|
-
{
|
|
16396
|
-
style: {
|
|
16397
|
-
width: size4 * 0.6,
|
|
16398
|
-
height: size4 * 0.6,
|
|
16399
|
-
background: darkMode ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",
|
|
16400
|
-
borderRadius: 4
|
|
16401
|
-
}
|
|
16402
|
-
}
|
|
16403
|
-
)
|
|
16404
|
-
}
|
|
16405
|
-
),
|
|
16406
|
-
/* @__PURE__ */ jsx31(
|
|
16407
|
-
"div",
|
|
16408
|
-
{
|
|
16409
|
-
ref: containerRef,
|
|
16410
|
-
style: {
|
|
16411
|
-
width: size4,
|
|
16412
|
-
height: size4,
|
|
16413
|
-
opacity: isReady ? 1 : 0,
|
|
16414
|
-
transition: "opacity 0.15s ease-out"
|
|
16415
|
-
}
|
|
16416
|
-
}
|
|
16417
|
-
),
|
|
16418
|
-
/* @__PURE__ */ jsx31("style", { children: `
|
|
16419
|
-
@keyframes uf-qr-pulse {
|
|
16420
|
-
0%, 100% { opacity: 1; }
|
|
16421
|
-
50% { opacity: 0.6; }
|
|
16422
|
-
}
|
|
16423
|
-
` })
|
|
16424
|
-
]
|
|
16478
|
+
justifyContent: "center"
|
|
16479
|
+
}
|
|
16425
16480
|
}
|
|
16426
16481
|
);
|
|
16427
16482
|
}
|
|
@@ -16433,7 +16488,8 @@ var COMMON_TOKENS = [
|
|
|
16433
16488
|
{ symbol: "USDC", chainType: "solana", chainId: "mainnet" },
|
|
16434
16489
|
{ symbol: "POL", chainType: "ethereum", chainId: "137" },
|
|
16435
16490
|
{ symbol: "BNB", chainType: "ethereum", chainId: "56" },
|
|
16436
|
-
{ symbol: "BTC", chainType: "bitcoin", chainId: "mainnet" }
|
|
16491
|
+
{ symbol: "BTC", chainType: "bitcoin", chainId: "mainnet" },
|
|
16492
|
+
{ symbol: "XRP", chainType: "xrpl", chainId: "mainnet" }
|
|
16437
16493
|
];
|
|
16438
16494
|
function getRecentTokens() {
|
|
16439
16495
|
if (typeof window === "undefined") return [];
|
|
@@ -16480,9 +16536,9 @@ function TokenSelectorSheet({
|
|
|
16480
16536
|
}) {
|
|
16481
16537
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
16482
16538
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
16483
|
-
const [searchQuery, setSearchQuery] =
|
|
16484
|
-
const [recentTokens, setRecentTokens] =
|
|
16485
|
-
const [hoveredTokenKey, setHoveredTokenKey] =
|
|
16539
|
+
const [searchQuery, setSearchQuery] = useState162("");
|
|
16540
|
+
const [recentTokens, setRecentTokens] = useState162([]);
|
|
16541
|
+
const [hoveredTokenKey, setHoveredTokenKey] = useState162(null);
|
|
16486
16542
|
useEffect132(() => {
|
|
16487
16543
|
setRecentTokens(getRecentTokens());
|
|
16488
16544
|
}, []);
|
|
@@ -16554,7 +16610,7 @@ function TokenSelectorSheet({
|
|
|
16554
16610
|
onOpenChange(false);
|
|
16555
16611
|
};
|
|
16556
16612
|
if (!open) return null;
|
|
16557
|
-
return /* @__PURE__ */
|
|
16613
|
+
return /* @__PURE__ */ jsxs28(
|
|
16558
16614
|
"div",
|
|
16559
16615
|
{
|
|
16560
16616
|
className: `${themeClass} uf-px-6`,
|
|
@@ -16569,7 +16625,7 @@ function TokenSelectorSheet({
|
|
|
16569
16625
|
backgroundColor: colors2.background
|
|
16570
16626
|
},
|
|
16571
16627
|
children: [
|
|
16572
|
-
/* @__PURE__ */
|
|
16628
|
+
/* @__PURE__ */ jsxs28("div", { className: "uf-flex uf-items-center uf-justify-between uf-py-3", children: [
|
|
16573
16629
|
/* @__PURE__ */ jsx322(
|
|
16574
16630
|
"button",
|
|
16575
16631
|
{
|
|
@@ -16608,7 +16664,7 @@ function TokenSelectorSheet({
|
|
|
16608
16664
|
}
|
|
16609
16665
|
}
|
|
16610
16666
|
) }) }),
|
|
16611
|
-
quickSelectOptions.length > 0 && !searchQuery && /* @__PURE__ */
|
|
16667
|
+
quickSelectOptions.length > 0 && !searchQuery && /* @__PURE__ */ jsxs28("div", { className: "uf-pb-3 uf--mx-6", children: [
|
|
16612
16668
|
/* @__PURE__ */ jsx322(
|
|
16613
16669
|
"div",
|
|
16614
16670
|
{
|
|
@@ -16628,7 +16684,7 @@ function TokenSelectorSheet({
|
|
|
16628
16684
|
children: quickSelectOptions.map(({ token, chain, isRecent }) => {
|
|
16629
16685
|
const chainKey = `${chain.chain_type}:${chain.chain_id}`;
|
|
16630
16686
|
const isSelected = token.symbol === selectedToken && chainKey === selectedChainKey;
|
|
16631
|
-
return /* @__PURE__ */
|
|
16687
|
+
return /* @__PURE__ */ jsxs28(
|
|
16632
16688
|
"div",
|
|
16633
16689
|
{
|
|
16634
16690
|
style: { position: "relative", flexShrink: 0 },
|
|
@@ -16656,7 +16712,7 @@ function TokenSelectorSheet({
|
|
|
16656
16712
|
children: /* @__PURE__ */ jsx322(X, { style: { width: 12, height: 12 } })
|
|
16657
16713
|
}
|
|
16658
16714
|
),
|
|
16659
|
-
/* @__PURE__ */
|
|
16715
|
+
/* @__PURE__ */ jsxs28(
|
|
16660
16716
|
"button",
|
|
16661
16717
|
{
|
|
16662
16718
|
type: "button",
|
|
@@ -16675,7 +16731,7 @@ function TokenSelectorSheet({
|
|
|
16675
16731
|
backgroundColor: isSelected ? components.card.backgroundColor : hoveredTokenKey === `${token.symbol}-${chainKey}` ? colors2.cardHover : "transparent"
|
|
16676
16732
|
},
|
|
16677
16733
|
children: [
|
|
16678
|
-
/* @__PURE__ */
|
|
16734
|
+
/* @__PURE__ */ jsxs28("div", { style: { position: "relative", flexShrink: 0 }, children: [
|
|
16679
16735
|
/* @__PURE__ */ jsx322(
|
|
16680
16736
|
"img",
|
|
16681
16737
|
{
|
|
@@ -16709,7 +16765,7 @@ function TokenSelectorSheet({
|
|
|
16709
16765
|
}
|
|
16710
16766
|
)
|
|
16711
16767
|
] }),
|
|
16712
|
-
/* @__PURE__ */
|
|
16768
|
+
/* @__PURE__ */ jsxs28("div", { style: { textAlign: "left" }, children: [
|
|
16713
16769
|
/* @__PURE__ */ jsx322(
|
|
16714
16770
|
"div",
|
|
16715
16771
|
{
|
|
@@ -16773,7 +16829,7 @@ function TokenSelectorSheet({
|
|
|
16773
16829
|
) : /* @__PURE__ */ jsx322("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: filteredOptions.map(({ token, chain }) => {
|
|
16774
16830
|
const chainKey = `${chain.chain_type}:${chain.chain_id}`;
|
|
16775
16831
|
const isSelected = token.symbol === selectedToken && chainKey === selectedChainKey;
|
|
16776
|
-
return /* @__PURE__ */
|
|
16832
|
+
return /* @__PURE__ */ jsxs28(
|
|
16777
16833
|
"button",
|
|
16778
16834
|
{
|
|
16779
16835
|
type: "button",
|
|
@@ -16794,7 +16850,7 @@ function TokenSelectorSheet({
|
|
|
16794
16850
|
backgroundColor: isSelected ? components.card.backgroundColor : hoveredTokenKey === `${token.symbol}-${chainKey}` ? colors2.cardHover : "transparent"
|
|
16795
16851
|
},
|
|
16796
16852
|
children: [
|
|
16797
|
-
/* @__PURE__ */
|
|
16853
|
+
/* @__PURE__ */ jsxs28("div", { style: { position: "relative", flexShrink: 0 }, children: [
|
|
16798
16854
|
/* @__PURE__ */ jsx322(
|
|
16799
16855
|
"img",
|
|
16800
16856
|
{
|
|
@@ -16828,7 +16884,7 @@ function TokenSelectorSheet({
|
|
|
16828
16884
|
}
|
|
16829
16885
|
)
|
|
16830
16886
|
] }),
|
|
16831
|
-
/* @__PURE__ */
|
|
16887
|
+
/* @__PURE__ */ jsxs28("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
16832
16888
|
/* @__PURE__ */ jsx322(
|
|
16833
16889
|
"div",
|
|
16834
16890
|
{
|
|
@@ -16853,7 +16909,7 @@ function TokenSelectorSheet({
|
|
|
16853
16909
|
}
|
|
16854
16910
|
)
|
|
16855
16911
|
] }),
|
|
16856
|
-
/* @__PURE__ */
|
|
16912
|
+
/* @__PURE__ */ jsxs28(
|
|
16857
16913
|
"div",
|
|
16858
16914
|
{
|
|
16859
16915
|
style: {
|
|
@@ -16865,7 +16921,7 @@ function TokenSelectorSheet({
|
|
|
16865
16921
|
children: [
|
|
16866
16922
|
"Minimum:",
|
|
16867
16923
|
" ",
|
|
16868
|
-
/* @__PURE__ */
|
|
16924
|
+
/* @__PURE__ */ jsxs28("span", { style: { color: isDarkMode ? "#fbbf24" : "#d97706" }, children: [
|
|
16869
16925
|
"$",
|
|
16870
16926
|
chain.minimum_deposit_amount_usd
|
|
16871
16927
|
] })
|
|
@@ -16881,47 +16937,32 @@ function TokenSelectorSheet({
|
|
|
16881
16937
|
}
|
|
16882
16938
|
);
|
|
16883
16939
|
}
|
|
16884
|
-
function
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
cooldownRef,
|
|
16890
|
-
buttonText = "Check again"
|
|
16940
|
+
function DepositPollingUi({
|
|
16941
|
+
depositConfirmationMode,
|
|
16942
|
+
showWaitingUi,
|
|
16943
|
+
hasExecution,
|
|
16944
|
+
onIveDeposited
|
|
16891
16945
|
}) {
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
} catch (error) {
|
|
16913
|
-
console.error("Failed to start poll workflow:", error);
|
|
16914
|
-
}
|
|
16915
|
-
};
|
|
16916
|
-
return /* @__PURE__ */ jsx33("div", { children: /* @__PURE__ */ jsx33(
|
|
16917
|
-
"button",
|
|
16918
|
-
{
|
|
16919
|
-
onClick: handleClick,
|
|
16920
|
-
disabled: !currentWalletId || pollCooldown > 0,
|
|
16921
|
-
className: "uf-w-full uf-rounded-xl uf-py-2.5 uf-px-2 uf-flex uf-items-center uf-gap-3 uf-justify-center uf-text-center uf-text-sm uf-bg-primary hover:uf-bg-primary/80 uf-transition-colors uf-text-left disabled:uf-opacity-50 disabled:uf-cursor-not-allowed",
|
|
16922
|
-
children: pollCooldown > 0 ? `${buttonText} in ${pollCooldown}s` : "I've made the deposit"
|
|
16923
|
-
}
|
|
16924
|
-
) });
|
|
16946
|
+
if (depositConfirmationMode === "manual" && !showWaitingUi) {
|
|
16947
|
+
return /* @__PURE__ */ jsx33(
|
|
16948
|
+
"button",
|
|
16949
|
+
{
|
|
16950
|
+
onClick: onIveDeposited,
|
|
16951
|
+
className: "uf-w-full uf-rounded-xl uf-py-2.5 uf-px-2 uf-flex uf-items-center uf-justify-center uf-text-sm uf-bg-primary hover:uf-bg-primary/80 uf-transition-colors",
|
|
16952
|
+
children: "I've made the deposit"
|
|
16953
|
+
}
|
|
16954
|
+
);
|
|
16955
|
+
}
|
|
16956
|
+
if (showWaitingUi && !hasExecution) {
|
|
16957
|
+
return /* @__PURE__ */ jsxs29("div", { className: "uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-gap-3 uf-animate-in uf-fade-in uf-duration-500", children: [
|
|
16958
|
+
/* @__PURE__ */ jsx33("div", { className: "uf-flex-shrink-0", children: /* @__PURE__ */ jsx33("div", { className: "uf-w-9 uf-h-9 uf-rounded-full uf-border-2 uf-border-t-primary uf-border-primary/20 uf-animate-spin" }) }),
|
|
16959
|
+
/* @__PURE__ */ jsxs29("div", { children: [
|
|
16960
|
+
/* @__PURE__ */ jsx33("div", { className: "uf-text-sm uf-font-medium uf-text-foreground", children: "Processing deposit transactions" }),
|
|
16961
|
+
/* @__PURE__ */ jsx33("div", { className: "uf-text-xs uf-text-muted-foreground", children: "We're checking if your deposit has landed." })
|
|
16962
|
+
] })
|
|
16963
|
+
] });
|
|
16964
|
+
}
|
|
16965
|
+
return null;
|
|
16925
16966
|
}
|
|
16926
16967
|
function DepositFooterLinks({ onGlossaryClick }) {
|
|
16927
16968
|
return /* @__PURE__ */ jsxs30("div", { className: "uf-flex uf-justify-end uf-items-center uf-gap-2 uf-text-xs uf-text-muted-foreground", children: [
|
|
@@ -17020,7 +17061,7 @@ function GlossaryModal({
|
|
|
17020
17061
|
) });
|
|
17021
17062
|
}
|
|
17022
17063
|
function useCopyAddress() {
|
|
17023
|
-
const [copied, setCopied] =
|
|
17064
|
+
const [copied, setCopied] = useState172(false);
|
|
17024
17065
|
const handleCopy = (address) => {
|
|
17025
17066
|
if (!address) return;
|
|
17026
17067
|
navigator.clipboard.writeText(address);
|
|
@@ -17080,6 +17121,7 @@ function TransferCryptoSingleInput({
|
|
|
17080
17121
|
destinationChainType,
|
|
17081
17122
|
destinationChainId,
|
|
17082
17123
|
destinationTokenAddress,
|
|
17124
|
+
depositConfirmationMode = "auto_ui",
|
|
17083
17125
|
onExecutionsChange,
|
|
17084
17126
|
onDepositSuccess,
|
|
17085
17127
|
onDepositError,
|
|
@@ -17087,25 +17129,15 @@ function TransferCryptoSingleInput({
|
|
|
17087
17129
|
}) {
|
|
17088
17130
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
17089
17131
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
17090
|
-
const [token, setToken] =
|
|
17091
|
-
const [chain, setChain] =
|
|
17092
|
-
const [copied, setCopied] =
|
|
17132
|
+
const [token, setToken] = useState192("USDC");
|
|
17133
|
+
const [chain, setChain] = useState192("solana:mainnet");
|
|
17134
|
+
const [copied, setCopied] = useState192(false);
|
|
17093
17135
|
const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
|
|
17094
|
-
const [glossaryOpen, setGlossaryOpen] =
|
|
17095
|
-
const [
|
|
17096
|
-
const
|
|
17097
|
-
const [
|
|
17098
|
-
const [
|
|
17099
|
-
const [tokenSelectorOpen, setTokenSelectorOpen] = useState202(false);
|
|
17100
|
-
const [initialSelectionDone, setInitialSelectionDone] = useState202(false);
|
|
17101
|
-
useEffect142(() => {
|
|
17102
|
-
return () => {
|
|
17103
|
-
if (cooldownRef.current) {
|
|
17104
|
-
clearInterval(cooldownRef.current);
|
|
17105
|
-
cooldownRef.current = null;
|
|
17106
|
-
}
|
|
17107
|
-
};
|
|
17108
|
-
}, []);
|
|
17136
|
+
const [glossaryOpen, setGlossaryOpen] = useState192(false);
|
|
17137
|
+
const [detailsExpanded, setDetailsExpanded] = useState192(false);
|
|
17138
|
+
const [depositsModalOpen, setDepositsModalOpen] = useState192(false);
|
|
17139
|
+
const [tokenSelectorOpen, setTokenSelectorOpen] = useState192(false);
|
|
17140
|
+
const [initialSelectionDone, setInitialSelectionDone] = useState192(false);
|
|
17109
17141
|
const {
|
|
17110
17142
|
data: tokensResponse,
|
|
17111
17143
|
isLoading: tokensLoading
|
|
@@ -17132,13 +17164,6 @@ function TransferCryptoSingleInput({
|
|
|
17132
17164
|
const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
|
|
17133
17165
|
const loading = externalWallets?.length ? false : walletsLoading;
|
|
17134
17166
|
const error = walletsError?.message ?? null;
|
|
17135
|
-
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
17136
|
-
userId,
|
|
17137
|
-
publishableKey,
|
|
17138
|
-
enabled: true,
|
|
17139
|
-
onDepositSuccess,
|
|
17140
|
-
onDepositError
|
|
17141
|
-
});
|
|
17142
17167
|
const allAvailableChains = useMemo42(() => {
|
|
17143
17168
|
const chainsMap = /* @__PURE__ */ new Map();
|
|
17144
17169
|
supportedTokens.forEach((t6) => {
|
|
@@ -17158,6 +17183,15 @@ function TransferCryptoSingleInput({
|
|
|
17158
17183
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
17159
17184
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
17160
17185
|
const depositAddress = currentWallet?.address || "";
|
|
17186
|
+
const { executions: depositExecutions, isPolling, showWaitingUi, handleIveDeposited } = useDepositPolling({
|
|
17187
|
+
userId,
|
|
17188
|
+
publishableKey,
|
|
17189
|
+
depositConfirmationMode,
|
|
17190
|
+
depositWalletId: currentWallet?.id,
|
|
17191
|
+
enabled: true,
|
|
17192
|
+
onDepositSuccess,
|
|
17193
|
+
onDepositError
|
|
17194
|
+
});
|
|
17161
17195
|
useEffect142(() => {
|
|
17162
17196
|
if (!supportedTokens.length || initialSelectionDone) return;
|
|
17163
17197
|
let selectedTokenData;
|
|
@@ -17207,28 +17241,6 @@ function TransferCryptoSingleInput({
|
|
|
17207
17241
|
onExecutionsChange(depositExecutions);
|
|
17208
17242
|
}
|
|
17209
17243
|
}, [depositExecutions, onExecutionsChange]);
|
|
17210
|
-
useEffect142(() => {
|
|
17211
|
-
if (!wallets.length || !allAvailableChains.length) return;
|
|
17212
|
-
const preloadAllQRCodes = async () => {
|
|
17213
|
-
for (const wallet of wallets) {
|
|
17214
|
-
if (!wallet.address) continue;
|
|
17215
|
-
const chainData = allAvailableChains.find(
|
|
17216
|
-
(c) => c.chain_type === wallet.chain_type
|
|
17217
|
-
);
|
|
17218
|
-
const chainIconUrl = chainData?.icon_url;
|
|
17219
|
-
await preloadQRCode(
|
|
17220
|
-
wallet.address,
|
|
17221
|
-
180,
|
|
17222
|
-
// size
|
|
17223
|
-
chainIconUrl,
|
|
17224
|
-
45,
|
|
17225
|
-
// imageSize
|
|
17226
|
-
isDarkMode
|
|
17227
|
-
);
|
|
17228
|
-
}
|
|
17229
|
-
};
|
|
17230
|
-
preloadAllQRCodes();
|
|
17231
|
-
}, [wallets, allAvailableChains, isDarkMode]);
|
|
17232
17244
|
useEffect142(() => {
|
|
17233
17245
|
if (!supportedTokens.length) return;
|
|
17234
17246
|
const currentToken = supportedTokens.find((t6) => t6.symbol === token);
|
|
@@ -17501,14 +17513,12 @@ function TransferCryptoSingleInput({
|
|
|
17501
17513
|
] })
|
|
17502
17514
|
] }),
|
|
17503
17515
|
/* @__PURE__ */ jsx37(
|
|
17504
|
-
|
|
17516
|
+
DepositPollingUi,
|
|
17505
17517
|
{
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
cooldownRef,
|
|
17511
|
-
buttonText: "Try again"
|
|
17518
|
+
depositConfirmationMode,
|
|
17519
|
+
showWaitingUi,
|
|
17520
|
+
hasExecution: depositExecutions.length > 0,
|
|
17521
|
+
onIveDeposited: handleIveDeposited
|
|
17512
17522
|
}
|
|
17513
17523
|
),
|
|
17514
17524
|
/* @__PURE__ */ jsx37(DepositFooterLinks, { onGlossaryClick: () => setGlossaryOpen(true) }),
|
|
@@ -17686,6 +17696,7 @@ function TransferCryptoDoubleInput({
|
|
|
17686
17696
|
destinationChainType,
|
|
17687
17697
|
destinationChainId,
|
|
17688
17698
|
destinationTokenAddress,
|
|
17699
|
+
depositConfirmationMode = "auto_ui",
|
|
17689
17700
|
onExecutionsChange,
|
|
17690
17701
|
onDepositSuccess,
|
|
17691
17702
|
onDepositError,
|
|
@@ -17693,24 +17704,14 @@ function TransferCryptoDoubleInput({
|
|
|
17693
17704
|
}) {
|
|
17694
17705
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
17695
17706
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
17696
|
-
const [token, setToken] =
|
|
17697
|
-
const [chain, setChain] =
|
|
17698
|
-
const [copied, setCopied] =
|
|
17707
|
+
const [token, setToken] = useState202("USDC");
|
|
17708
|
+
const [chain, setChain] = useState202("solana:mainnet");
|
|
17709
|
+
const [copied, setCopied] = useState202(false);
|
|
17699
17710
|
const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
|
|
17700
|
-
const [glossaryOpen, setGlossaryOpen] =
|
|
17701
|
-
const [
|
|
17702
|
-
const
|
|
17703
|
-
const [
|
|
17704
|
-
const [depositsModalOpen, setDepositsModalOpen] = useState212(false);
|
|
17705
|
-
const [initialSelectionDone, setInitialSelectionDone] = useState212(false);
|
|
17706
|
-
useEffect152(() => {
|
|
17707
|
-
return () => {
|
|
17708
|
-
if (cooldownRef.current) {
|
|
17709
|
-
clearInterval(cooldownRef.current);
|
|
17710
|
-
cooldownRef.current = null;
|
|
17711
|
-
}
|
|
17712
|
-
};
|
|
17713
|
-
}, []);
|
|
17711
|
+
const [glossaryOpen, setGlossaryOpen] = useState202(false);
|
|
17712
|
+
const [detailsExpanded, setDetailsExpanded] = useState202(false);
|
|
17713
|
+
const [depositsModalOpen, setDepositsModalOpen] = useState202(false);
|
|
17714
|
+
const [initialSelectionDone, setInitialSelectionDone] = useState202(false);
|
|
17714
17715
|
const {
|
|
17715
17716
|
data: tokensResponse,
|
|
17716
17717
|
isLoading: tokensLoading
|
|
@@ -17737,13 +17738,6 @@ function TransferCryptoDoubleInput({
|
|
|
17737
17738
|
const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
|
|
17738
17739
|
const loading = externalWallets?.length ? false : walletsLoading;
|
|
17739
17740
|
const error = walletsError?.message ?? null;
|
|
17740
|
-
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
17741
|
-
userId,
|
|
17742
|
-
publishableKey,
|
|
17743
|
-
enabled: true,
|
|
17744
|
-
onDepositSuccess,
|
|
17745
|
-
onDepositError
|
|
17746
|
-
});
|
|
17747
17741
|
const allAvailableChains = useMemo52(() => {
|
|
17748
17742
|
const chainsMap = /* @__PURE__ */ new Map();
|
|
17749
17743
|
supportedTokens.forEach((t6) => {
|
|
@@ -17763,6 +17757,15 @@ function TransferCryptoDoubleInput({
|
|
|
17763
17757
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
17764
17758
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
17765
17759
|
const depositAddress = currentWallet?.address || "";
|
|
17760
|
+
const { executions: depositExecutions, isPolling, showWaitingUi, handleIveDeposited } = useDepositPolling({
|
|
17761
|
+
userId,
|
|
17762
|
+
publishableKey,
|
|
17763
|
+
depositConfirmationMode,
|
|
17764
|
+
depositWalletId: currentWallet?.id,
|
|
17765
|
+
enabled: true,
|
|
17766
|
+
onDepositSuccess,
|
|
17767
|
+
onDepositError
|
|
17768
|
+
});
|
|
17766
17769
|
useEffect152(() => {
|
|
17767
17770
|
if (!supportedTokens.length || initialSelectionDone) return;
|
|
17768
17771
|
const allChains = /* @__PURE__ */ new Set();
|
|
@@ -17785,28 +17788,6 @@ function TransferCryptoDoubleInput({
|
|
|
17785
17788
|
onExecutionsChange(depositExecutions);
|
|
17786
17789
|
}
|
|
17787
17790
|
}, [depositExecutions, onExecutionsChange]);
|
|
17788
|
-
useEffect152(() => {
|
|
17789
|
-
if (!wallets.length || !allAvailableChains.length) return;
|
|
17790
|
-
const preloadAllQRCodes = async () => {
|
|
17791
|
-
for (const wallet of wallets) {
|
|
17792
|
-
if (!wallet.address) continue;
|
|
17793
|
-
const chainData = allAvailableChains.find(
|
|
17794
|
-
(c) => c.chain_type === wallet.chain_type
|
|
17795
|
-
);
|
|
17796
|
-
const chainIconUrl = chainData?.icon_url;
|
|
17797
|
-
await preloadQRCode(
|
|
17798
|
-
wallet.address,
|
|
17799
|
-
180,
|
|
17800
|
-
// size
|
|
17801
|
-
chainIconUrl,
|
|
17802
|
-
45,
|
|
17803
|
-
// imageSize
|
|
17804
|
-
isDarkMode
|
|
17805
|
-
);
|
|
17806
|
-
}
|
|
17807
|
-
};
|
|
17808
|
-
preloadAllQRCodes();
|
|
17809
|
-
}, [wallets, allAvailableChains, isDarkMode]);
|
|
17810
17791
|
useEffect152(() => {
|
|
17811
17792
|
if (!supportedTokens.length) return;
|
|
17812
17793
|
const currentToken = supportedTokens.find((t6) => t6.symbol === token);
|
|
@@ -18113,14 +18094,12 @@ function TransferCryptoDoubleInput({
|
|
|
18113
18094
|
] })
|
|
18114
18095
|
] }),
|
|
18115
18096
|
/* @__PURE__ */ jsx39(
|
|
18116
|
-
|
|
18097
|
+
DepositPollingUi,
|
|
18117
18098
|
{
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
cooldownRef,
|
|
18123
|
-
buttonText: "Check again"
|
|
18099
|
+
depositConfirmationMode,
|
|
18100
|
+
showWaitingUi,
|
|
18101
|
+
hasExecution: depositExecutions.length > 0,
|
|
18102
|
+
onIveDeposited: handleIveDeposited
|
|
18124
18103
|
}
|
|
18125
18104
|
),
|
|
18126
18105
|
/* @__PURE__ */ jsx39(DepositFooterLinks, { onGlossaryClick: () => setGlossaryOpen(true) }),
|
|
@@ -18169,105 +18148,7 @@ function TransferCryptoDoubleInput({
|
|
|
18169
18148
|
}
|
|
18170
18149
|
) });
|
|
18171
18150
|
}
|
|
18172
|
-
function getIconUrl4(iconUrl, assetCdnUrl) {
|
|
18173
|
-
if (!iconUrl) return void 0;
|
|
18174
|
-
if (iconUrl.startsWith("http://") || iconUrl.startsWith("https://")) {
|
|
18175
|
-
return iconUrl;
|
|
18176
|
-
}
|
|
18177
|
-
if (assetCdnUrl) {
|
|
18178
|
-
return `${assetCdnUrl}${iconUrl.startsWith("/") ? "" : "/"}${iconUrl}`;
|
|
18179
|
-
}
|
|
18180
|
-
return iconUrl;
|
|
18181
|
-
}
|
|
18182
|
-
function getTokenFromBalance(balance) {
|
|
18183
|
-
if (balance.token) {
|
|
18184
|
-
return balance.token;
|
|
18185
|
-
}
|
|
18186
|
-
const legacyBalance = balance;
|
|
18187
|
-
if (legacyBalance.symbol && legacyBalance.decimals !== void 0) {
|
|
18188
|
-
return {
|
|
18189
|
-
symbol: legacyBalance.symbol,
|
|
18190
|
-
name: legacyBalance.name,
|
|
18191
|
-
icon_url: legacyBalance.icon_url,
|
|
18192
|
-
icon_urls: [],
|
|
18193
|
-
token_address: legacyBalance.token_address,
|
|
18194
|
-
chain_id: legacyBalance.chain_id,
|
|
18195
|
-
chain_name: legacyBalance.chain_name,
|
|
18196
|
-
chain_type: legacyBalance.chain_type,
|
|
18197
|
-
decimals: legacyBalance.decimals,
|
|
18198
|
-
chain_icon_url: legacyBalance.chain_icon_url,
|
|
18199
|
-
chain_icon_urls: [],
|
|
18200
|
-
minimum_deposit_amount_usd: 0
|
|
18201
|
-
};
|
|
18202
|
-
}
|
|
18203
|
-
return null;
|
|
18204
|
-
}
|
|
18205
|
-
function isBalanceEligible(balance) {
|
|
18206
|
-
if (balance.is_eligible !== void 0) {
|
|
18207
|
-
return balance.is_eligible;
|
|
18208
|
-
}
|
|
18209
|
-
const legacyBalance = balance;
|
|
18210
|
-
if (legacyBalance.is_eligible !== void 0) {
|
|
18211
|
-
return legacyBalance.is_eligible;
|
|
18212
|
-
}
|
|
18213
|
-
return true;
|
|
18214
|
-
}
|
|
18215
|
-
function formatTokenAmount(amount, decimals, symbol) {
|
|
18216
|
-
const value = Number(amount) / 10 ** decimals;
|
|
18217
|
-
const upperSymbol = symbol.toUpperCase();
|
|
18218
|
-
let maxDecimals = 4;
|
|
18219
|
-
if (upperSymbol === "BTC" || upperSymbol === "WBTC") {
|
|
18220
|
-
maxDecimals = 8;
|
|
18221
|
-
} else if (upperSymbol === "ETH" || upperSymbol === "WETH" || upperSymbol === "SOL") {
|
|
18222
|
-
maxDecimals = 6;
|
|
18223
|
-
}
|
|
18224
|
-
if (value >= 1) {
|
|
18225
|
-
return value.toLocaleString(void 0, {
|
|
18226
|
-
minimumFractionDigits: 2,
|
|
18227
|
-
maximumFractionDigits: maxDecimals
|
|
18228
|
-
});
|
|
18229
|
-
} else if (value > 0) {
|
|
18230
|
-
return value.toLocaleString(void 0, {
|
|
18231
|
-
minimumFractionDigits: 2,
|
|
18232
|
-
maximumFractionDigits: maxDecimals,
|
|
18233
|
-
minimumSignificantDigits: 2,
|
|
18234
|
-
maximumSignificantDigits: 6
|
|
18235
|
-
});
|
|
18236
|
-
}
|
|
18237
|
-
return "0.00";
|
|
18238
|
-
}
|
|
18239
|
-
function formatUsdAmount(amountUsd) {
|
|
18240
|
-
if (!amountUsd) return null;
|
|
18241
|
-
const value = parseFloat(amountUsd);
|
|
18242
|
-
if (value <= 0) return null;
|
|
18243
|
-
return value.toLocaleString(void 0, {
|
|
18244
|
-
minimumFractionDigits: 2,
|
|
18245
|
-
maximumFractionDigits: 2
|
|
18246
|
-
});
|
|
18247
|
-
}
|
|
18248
|
-
function truncateAddress3(address) {
|
|
18249
|
-
if (address.length <= 13) return address;
|
|
18250
|
-
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
18251
|
-
}
|
|
18252
|
-
function formatBalanceDisplay(balance, projectName) {
|
|
18253
|
-
return projectName ? `${projectName} Balance: ${balance}` : `Balance: ${balance}`;
|
|
18254
|
-
}
|
|
18255
|
-
function formatProcessingTime(seconds) {
|
|
18256
|
-
if (seconds === null || seconds === 0) {
|
|
18257
|
-
return "< 1 min";
|
|
18258
|
-
}
|
|
18259
|
-
const minutes = Math.floor(seconds / 60);
|
|
18260
|
-
const remainingSeconds = seconds % 60;
|
|
18261
|
-
if (minutes === 0) {
|
|
18262
|
-
return `< ${remainingSeconds} sec`;
|
|
18263
|
-
} else if (remainingSeconds === 0) {
|
|
18264
|
-
return `< ${minutes} min`;
|
|
18265
|
-
} else {
|
|
18266
|
-
return `< ${minutes} min ${remainingSeconds} sec`;
|
|
18267
|
-
}
|
|
18268
|
-
}
|
|
18269
18151
|
function SelectTokenView({
|
|
18270
|
-
walletInfo,
|
|
18271
18152
|
projectName,
|
|
18272
18153
|
assetCdnUrl,
|
|
18273
18154
|
balances,
|
|
@@ -18286,27 +18167,12 @@ function SelectTokenView({
|
|
|
18286
18167
|
DepositHeader,
|
|
18287
18168
|
{
|
|
18288
18169
|
title: "Select Token",
|
|
18170
|
+
subtitle: formatBalanceDisplay(`$${totalBalanceUsd || "0.00"}`, projectName),
|
|
18289
18171
|
showBack: true,
|
|
18290
18172
|
onBack,
|
|
18291
18173
|
onClose
|
|
18292
18174
|
}
|
|
18293
18175
|
),
|
|
18294
|
-
/* @__PURE__ */ jsxs35(
|
|
18295
|
-
"div",
|
|
18296
|
-
{
|
|
18297
|
-
className: "uf-flex uf-flex-col uf-w-full uf-items-center uf-pb-3",
|
|
18298
|
-
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
18299
|
-
children: [
|
|
18300
|
-
/* @__PURE__ */ jsxs35("div", { className: "uf-text-xs", children: [
|
|
18301
|
-
walletInfo.name,
|
|
18302
|
-
" (",
|
|
18303
|
-
truncateAddress3(walletInfo.address),
|
|
18304
|
-
")"
|
|
18305
|
-
] }),
|
|
18306
|
-
/* @__PURE__ */ jsx40("div", { className: "uf-text-xs", children: formatBalanceDisplay(`$${totalBalanceUsd || "0.00"}`, projectName) })
|
|
18307
|
-
]
|
|
18308
|
-
}
|
|
18309
|
-
),
|
|
18310
18176
|
/* @__PURE__ */ jsx40("div", { className: "uf-h-[300px] uf-overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: /* @__PURE__ */ jsx40("div", { className: "uf-space-y-2", children: isLoading ? /* @__PURE__ */ jsx40("div", { className: "uf-flex uf-items-center uf-justify-center uf-py-12", children: /* @__PURE__ */ jsx40(
|
|
18311
18177
|
LoaderCircle,
|
|
18312
18178
|
{
|
|
@@ -18317,6 +18183,7 @@ function SelectTokenView({
|
|
|
18317
18183
|
const token = getTokenFromBalance(balance);
|
|
18318
18184
|
if (!token) return null;
|
|
18319
18185
|
const isEligible = isBalanceEligible(balance);
|
|
18186
|
+
const ineligibilityMessage = getIneligibilityMessage(balance);
|
|
18320
18187
|
const isSelected = selectedBalance && getTokenFromBalance(selectedBalance)?.token_address === token.token_address && getTokenFromBalance(selectedBalance)?.chain_id === token.chain_id;
|
|
18321
18188
|
const formattedAmount = formatTokenAmount(balance.amount, token.decimals, token.symbol);
|
|
18322
18189
|
const formattedUsd = formatUsdAmount(balance.amount_usd);
|
|
@@ -18334,10 +18201,10 @@ function SelectTokenView({
|
|
|
18334
18201
|
children: [
|
|
18335
18202
|
/* @__PURE__ */ jsxs35("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
18336
18203
|
/* @__PURE__ */ jsxs35("div", { className: "uf-relative uf-w-9 uf-h-9", children: [
|
|
18337
|
-
|
|
18204
|
+
getIconUrl2(token.icon_url, assetCdnUrl) ? /* @__PURE__ */ jsx40(
|
|
18338
18205
|
"img",
|
|
18339
18206
|
{
|
|
18340
|
-
src:
|
|
18207
|
+
src: getIconUrl2(token.icon_url, assetCdnUrl),
|
|
18341
18208
|
alt: token.symbol,
|
|
18342
18209
|
width: 36,
|
|
18343
18210
|
height: 36,
|
|
@@ -18352,10 +18219,10 @@ function SelectTokenView({
|
|
|
18352
18219
|
children: /* @__PURE__ */ jsx40("span", { className: "uf-text-xs uf-font-medium", style: { color: colors2.foreground }, children: token.symbol.slice(0, 2) })
|
|
18353
18220
|
}
|
|
18354
18221
|
),
|
|
18355
|
-
|
|
18222
|
+
getIconUrl2(token.chain_icon_url, assetCdnUrl) && /* @__PURE__ */ jsx40(
|
|
18356
18223
|
"img",
|
|
18357
18224
|
{
|
|
18358
|
-
src:
|
|
18225
|
+
src: getIconUrl2(token.chain_icon_url, assetCdnUrl),
|
|
18359
18226
|
alt: token.chain_name,
|
|
18360
18227
|
width: 16,
|
|
18361
18228
|
height: 16,
|
|
@@ -18386,7 +18253,7 @@ function SelectTokenView({
|
|
|
18386
18253
|
style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
|
|
18387
18254
|
children: [
|
|
18388
18255
|
token.chain_name,
|
|
18389
|
-
|
|
18256
|
+
ineligibilityMessage && ` \u2022 ${ineligibilityMessage}`
|
|
18390
18257
|
]
|
|
18391
18258
|
}
|
|
18392
18259
|
)
|
|
@@ -18442,8 +18309,6 @@ function SelectTokenView({
|
|
|
18442
18309
|
] });
|
|
18443
18310
|
}
|
|
18444
18311
|
function EnterAmountView({
|
|
18445
|
-
walletInfo,
|
|
18446
|
-
projectName,
|
|
18447
18312
|
selectedBalance,
|
|
18448
18313
|
selectedToken,
|
|
18449
18314
|
amountUsd,
|
|
@@ -18460,54 +18325,20 @@ function EnterAmountView({
|
|
|
18460
18325
|
onClose
|
|
18461
18326
|
}) {
|
|
18462
18327
|
const { colors: colors2, fonts, components } = useTheme();
|
|
18463
|
-
|
|
18328
|
+
const balanceSubtitle = selectedBalance?.amount_usd ? `Balance: $${parseFloat(selectedBalance.amount_usd).toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} (${formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol)} ${selectedToken.symbol})` : `Balance: ${formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol)} ${selectedToken.symbol}`;
|
|
18329
|
+
return /* @__PURE__ */ jsxs36(Fragment62, { children: [
|
|
18464
18330
|
/* @__PURE__ */ jsx41(
|
|
18465
18331
|
DepositHeader,
|
|
18466
18332
|
{
|
|
18467
18333
|
title: "Enter Amount",
|
|
18334
|
+
subtitle: balanceSubtitle,
|
|
18468
18335
|
showBack: true,
|
|
18469
18336
|
onBack,
|
|
18470
18337
|
onClose
|
|
18471
18338
|
}
|
|
18472
18339
|
),
|
|
18473
|
-
/* @__PURE__ */ jsxs36("div", { className: "uf-text-center uf-
|
|
18474
|
-
/* @__PURE__ */ jsxs36(
|
|
18475
|
-
"div",
|
|
18476
|
-
{
|
|
18477
|
-
className: "uf-text-xs",
|
|
18478
|
-
style: { color: colors2.foreground, fontFamily: fonts.regular },
|
|
18479
|
-
children: [
|
|
18480
|
-
walletInfo.name,
|
|
18481
|
-
" (",
|
|
18482
|
-
truncateAddress3(walletInfo.address),
|
|
18483
|
-
")"
|
|
18484
|
-
]
|
|
18485
|
-
}
|
|
18486
|
-
),
|
|
18487
|
-
/* @__PURE__ */ jsx41(
|
|
18488
|
-
"div",
|
|
18489
|
-
{
|
|
18490
|
-
className: "uf-text-sm uf-mt-1",
|
|
18491
|
-
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
18492
|
-
children: selectedBalance?.amount_usd ? /* @__PURE__ */ jsxs36(Fragment62, { children: [
|
|
18493
|
-
"Balance: $",
|
|
18494
|
-
parseFloat(selectedBalance.amount_usd).toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }),
|
|
18495
|
-
" (",
|
|
18496
|
-
formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol),
|
|
18497
|
-
" ",
|
|
18498
|
-
selectedToken.symbol,
|
|
18499
|
-
")"
|
|
18500
|
-
] }) : /* @__PURE__ */ jsxs36(Fragment62, { children: [
|
|
18501
|
-
"Balance: ",
|
|
18502
|
-
formatTokenAmount(selectedBalance.amount, selectedToken.decimals, selectedToken.symbol),
|
|
18503
|
-
" ",
|
|
18504
|
-
selectedToken.symbol
|
|
18505
|
-
] })
|
|
18506
|
-
}
|
|
18507
|
-
)
|
|
18508
|
-
] }),
|
|
18509
|
-
/* @__PURE__ */ jsxs36("div", { className: "uf-flex-1 uf-overflow-y-auto", children: [
|
|
18510
|
-
/* @__PURE__ */ jsx41("div", { className: "uf-text-center uf-h-[100px] uf-flex uf-flex-col uf-justify-center", children: /* @__PURE__ */ jsxs36("div", { className: "uf-flex uf-items-center uf-justify-center", children: [
|
|
18340
|
+
/* @__PURE__ */ jsxs36("div", { className: "uf-text-center uf-py-6", children: [
|
|
18341
|
+
/* @__PURE__ */ jsxs36("div", { className: "uf-flex uf-items-center uf-justify-center", children: [
|
|
18511
18342
|
/* @__PURE__ */ jsx41(
|
|
18512
18343
|
"span",
|
|
18513
18344
|
{
|
|
@@ -18543,60 +18374,57 @@ function EnterAmountView({
|
|
|
18543
18374
|
}
|
|
18544
18375
|
}
|
|
18545
18376
|
)
|
|
18546
|
-
] })
|
|
18547
|
-
formattedTokenAmount && /* @__PURE__ */ jsxs36("div", { className: "uf-text-sm uf-
|
|
18377
|
+
] }),
|
|
18378
|
+
formattedTokenAmount && /* @__PURE__ */ jsxs36("div", { className: "uf-text-sm uf-mt-2", style: { color: colors2.foregroundMuted }, children: [
|
|
18548
18379
|
"\u2248 ",
|
|
18549
18380
|
formattedTokenAmount
|
|
18550
|
-
] })
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
onClick: () => onAmountChange(quickAmount.toString()),
|
|
18556
|
-
className: "uf-flex-1 uf-py-2 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-colors hover:uf-opacity-80",
|
|
18557
|
-
style: {
|
|
18558
|
-
backgroundColor: components.card.backgroundColor,
|
|
18559
|
-
color: colors2.foreground,
|
|
18560
|
-
fontFamily: fonts.medium
|
|
18561
|
-
},
|
|
18562
|
-
children: [
|
|
18563
|
-
"$",
|
|
18564
|
-
quickAmount
|
|
18565
|
-
]
|
|
18566
|
-
},
|
|
18567
|
-
quickAmount
|
|
18568
|
-
)),
|
|
18569
|
-
/* @__PURE__ */ jsx41(
|
|
18570
|
-
"button",
|
|
18571
|
-
{
|
|
18572
|
-
onClick: onMaxClick,
|
|
18573
|
-
className: "uf-flex-1 uf-py-2 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-colors hover:uf-opacity-80",
|
|
18574
|
-
style: {
|
|
18575
|
-
backgroundColor: colors2.primary + "20",
|
|
18576
|
-
color: colors2.primary,
|
|
18577
|
-
fontFamily: fonts.medium
|
|
18578
|
-
},
|
|
18579
|
-
children: "MAX"
|
|
18580
|
-
}
|
|
18581
|
-
)
|
|
18582
|
-
] }),
|
|
18583
|
-
tokenChainDetails && tokenChainDetails.minimum_deposit_amount_usd > 0 && /* @__PURE__ */ jsxs36(
|
|
18584
|
-
"div",
|
|
18381
|
+
] })
|
|
18382
|
+
] }),
|
|
18383
|
+
/* @__PURE__ */ jsxs36("div", { className: "uf-flex uf-gap-2 uf-mb-4", children: [
|
|
18384
|
+
[25, 50, 100, 500].map((quickAmount) => /* @__PURE__ */ jsxs36(
|
|
18385
|
+
"button",
|
|
18585
18386
|
{
|
|
18586
|
-
|
|
18387
|
+
onClick: () => onAmountChange(quickAmount.toString()),
|
|
18388
|
+
className: "uf-flex-1 uf-py-2 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-colors hover:uf-opacity-80",
|
|
18587
18389
|
style: {
|
|
18588
|
-
|
|
18589
|
-
|
|
18390
|
+
backgroundColor: components.card.backgroundColor,
|
|
18391
|
+
color: colors2.foreground,
|
|
18392
|
+
fontFamily: fonts.medium
|
|
18590
18393
|
},
|
|
18591
18394
|
children: [
|
|
18592
|
-
"
|
|
18593
|
-
|
|
18395
|
+
"$",
|
|
18396
|
+
quickAmount
|
|
18594
18397
|
]
|
|
18398
|
+
},
|
|
18399
|
+
quickAmount
|
|
18400
|
+
)),
|
|
18401
|
+
/* @__PURE__ */ jsx41(
|
|
18402
|
+
"button",
|
|
18403
|
+
{
|
|
18404
|
+
onClick: onMaxClick,
|
|
18405
|
+
className: "uf-flex-1 uf-py-2 uf-rounded-lg uf-text-sm uf-font-medium uf-transition-colors hover:uf-opacity-80",
|
|
18406
|
+
style: {
|
|
18407
|
+
backgroundColor: colors2.primary + "20",
|
|
18408
|
+
color: colors2.primary,
|
|
18409
|
+
fontFamily: fonts.medium
|
|
18410
|
+
},
|
|
18411
|
+
children: "MAX"
|
|
18595
18412
|
}
|
|
18596
|
-
)
|
|
18597
|
-
inputUsdNum > 0 && /* @__PURE__ */ jsx41(Fragment62, { children: inputUsdNum > maxUsdAmount ? /* @__PURE__ */ jsx41("div", { className: "uf-text-center uf-text-sm uf-mb-2", style: { color: colors2.error }, children: "Insufficient balance" }) : error && /* @__PURE__ */ jsx41("div", { className: "uf-text-center uf-text-sm uf-mb-2 uf-px-2", style: { color: colors2.error }, children: error }) })
|
|
18413
|
+
)
|
|
18598
18414
|
] }),
|
|
18599
|
-
|
|
18415
|
+
tokenChainDetails && tokenChainDetails.minimum_deposit_amount_usd > 0 && /* @__PURE__ */ jsxs36(
|
|
18416
|
+
"div",
|
|
18417
|
+
{
|
|
18418
|
+
className: "uf-text-center uf-text-xs uf-mb-3",
|
|
18419
|
+
style: { color: colors2.warning, fontFamily: fonts.regular },
|
|
18420
|
+
children: [
|
|
18421
|
+
"Minimum deposit: $",
|
|
18422
|
+
tokenChainDetails.minimum_deposit_amount_usd.toFixed(2)
|
|
18423
|
+
]
|
|
18424
|
+
}
|
|
18425
|
+
),
|
|
18426
|
+
inputUsdNum > 0 && /* @__PURE__ */ jsx41(Fragment62, { children: inputUsdNum > maxUsdAmount ? /* @__PURE__ */ jsx41("div", { className: "uf-text-center uf-text-sm uf-mb-3", style: { color: colors2.error }, children: "Insufficient balance" }) : error && /* @__PURE__ */ jsx41("div", { className: "uf-text-center uf-text-sm uf-mb-3 uf-px-2", style: { color: colors2.error }, children: error }) }),
|
|
18427
|
+
/* @__PURE__ */ jsx41(
|
|
18600
18428
|
"button",
|
|
18601
18429
|
{
|
|
18602
18430
|
onClick: onReview,
|
|
@@ -18609,7 +18437,7 @@ function EnterAmountView({
|
|
|
18609
18437
|
},
|
|
18610
18438
|
children: "Review"
|
|
18611
18439
|
}
|
|
18612
|
-
)
|
|
18440
|
+
)
|
|
18613
18441
|
] });
|
|
18614
18442
|
}
|
|
18615
18443
|
function ReviewView({
|
|
@@ -18673,10 +18501,10 @@ function ReviewView({
|
|
|
18673
18501
|
}
|
|
18674
18502
|
),
|
|
18675
18503
|
/* @__PURE__ */ jsxs37("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
18676
|
-
|
|
18504
|
+
getIconUrl2(selectedToken.icon_url, assetCdnUrl) && /* @__PURE__ */ jsx422(
|
|
18677
18505
|
"img",
|
|
18678
18506
|
{
|
|
18679
|
-
src:
|
|
18507
|
+
src: getIconUrl2(selectedToken.icon_url, assetCdnUrl),
|
|
18680
18508
|
alt: selectedToken.symbol,
|
|
18681
18509
|
className: "uf-w-5 uf-h-5 uf-rounded-full"
|
|
18682
18510
|
}
|
|
@@ -18689,7 +18517,7 @@ function ReviewView({
|
|
|
18689
18517
|
children: [
|
|
18690
18518
|
walletInfo.name,
|
|
18691
18519
|
" (",
|
|
18692
|
-
|
|
18520
|
+
truncateAddress2(walletInfo.address),
|
|
18693
18521
|
")"
|
|
18694
18522
|
]
|
|
18695
18523
|
}
|
|
@@ -18710,7 +18538,7 @@ function ReviewView({
|
|
|
18710
18538
|
{
|
|
18711
18539
|
className: "uf-text-sm uf-font-medium",
|
|
18712
18540
|
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
18713
|
-
children:
|
|
18541
|
+
children: truncateAddress2(recipientAddress)
|
|
18714
18542
|
}
|
|
18715
18543
|
)
|
|
18716
18544
|
] }),
|
|
@@ -18906,7 +18734,7 @@ function BrowserWalletModal({
|
|
|
18906
18734
|
const themeClass = theme === "dark" ? "uf-dark" : "";
|
|
18907
18735
|
const chainType = depositWallet.chain_type;
|
|
18908
18736
|
const recipientAddress = depositWallet.address;
|
|
18909
|
-
const supportedChainType = chainType === "algorand" ? "ethereum" : chainType;
|
|
18737
|
+
const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
|
|
18910
18738
|
const { executions: depositExecutions, isPolling } = useDepositPolling({
|
|
18911
18739
|
userId,
|
|
18912
18740
|
publishableKey,
|
|
@@ -19317,20 +19145,6 @@ function BrowserWalletModal({
|
|
|
19317
19145
|
if (tokenAmount === 0 || !selectedToken) return null;
|
|
19318
19146
|
return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
|
|
19319
19147
|
}, [tokenAmount, selectedToken]);
|
|
19320
|
-
const getTitle = () => {
|
|
19321
|
-
switch (step) {
|
|
19322
|
-
case "select-token":
|
|
19323
|
-
return "Select Token";
|
|
19324
|
-
case "input-amount":
|
|
19325
|
-
return "Enter Amount";
|
|
19326
|
-
case "review":
|
|
19327
|
-
return "Review";
|
|
19328
|
-
case "confirming":
|
|
19329
|
-
return "Confirming...";
|
|
19330
|
-
default:
|
|
19331
|
-
return "Browser Wallet";
|
|
19332
|
-
}
|
|
19333
|
-
};
|
|
19334
19148
|
return /* @__PURE__ */ jsx44(Fragment9, { children: /* @__PURE__ */ jsx44(
|
|
19335
19149
|
Dialog2,
|
|
19336
19150
|
{
|
|
@@ -19352,7 +19166,6 @@ function BrowserWalletModal({
|
|
|
19352
19166
|
step === "select-token" && /* @__PURE__ */ jsx44(
|
|
19353
19167
|
SelectTokenView,
|
|
19354
19168
|
{
|
|
19355
|
-
walletInfo,
|
|
19356
19169
|
projectName,
|
|
19357
19170
|
assetCdnUrl,
|
|
19358
19171
|
balances,
|
|
@@ -19369,8 +19182,6 @@ function BrowserWalletModal({
|
|
|
19369
19182
|
step === "input-amount" && selectedToken && selectedBalance && /* @__PURE__ */ jsx44(
|
|
19370
19183
|
EnterAmountView,
|
|
19371
19184
|
{
|
|
19372
|
-
walletInfo,
|
|
19373
|
-
projectName,
|
|
19374
19185
|
selectedBalance,
|
|
19375
19186
|
selectedToken,
|
|
19376
19187
|
amountUsd,
|
|
@@ -19717,6 +19528,7 @@ function WalletSelectionModal({
|
|
|
19717
19528
|
if (!accounts || accounts.length === 0) {
|
|
19718
19529
|
throw new Error("No accounts returned from wallet");
|
|
19719
19530
|
}
|
|
19531
|
+
setUserDisconnectedWallet(false);
|
|
19720
19532
|
const address = accounts[0];
|
|
19721
19533
|
const walletType = wallet.id === "phantom" ? "phantom-ethereum" : wallet.id === "coinbase" ? "coinbase" : "metamask";
|
|
19722
19534
|
onWalletConnected({
|
|
@@ -19756,6 +19568,7 @@ function WalletSelectionModal({
|
|
|
19756
19568
|
}
|
|
19757
19569
|
const response = await provider.connect();
|
|
19758
19570
|
const address = response.publicKey.toString();
|
|
19571
|
+
setUserDisconnectedWallet(false);
|
|
19759
19572
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
19760
19573
|
onWalletConnected({
|
|
19761
19574
|
type: walletType,
|
|
@@ -20060,24 +19873,25 @@ function DepositModal({
|
|
|
20060
19873
|
hideDepositTracker = false,
|
|
20061
19874
|
showBalanceHeader = false,
|
|
20062
19875
|
transferInputVariant = "double_input",
|
|
19876
|
+
depositConfirmationMode = "auto_ui",
|
|
20063
19877
|
enableConnectWallet = false,
|
|
20064
19878
|
onDepositSuccess,
|
|
20065
19879
|
onDepositError,
|
|
20066
19880
|
theme = "dark"
|
|
20067
19881
|
}) {
|
|
20068
19882
|
const { colors: colors2, fonts } = useTheme();
|
|
20069
|
-
const [view, setView] =
|
|
20070
|
-
const [cardView, setCardView] =
|
|
19883
|
+
const [view, setView] = useState24("main");
|
|
19884
|
+
const [cardView, setCardView] = useState24(
|
|
20071
19885
|
"amount"
|
|
20072
19886
|
);
|
|
20073
|
-
const [browserWalletModalOpen, setBrowserWalletModalOpen] =
|
|
20074
|
-
const [browserWalletInfo, setBrowserWalletInfo] =
|
|
20075
|
-
const [walletSelectionModalOpen, setWalletSelectionModalOpen] =
|
|
20076
|
-
const [browserWalletChainType, setBrowserWalletChainType] =
|
|
20077
|
-
const [quotesCount, setQuotesCount] =
|
|
20078
|
-
const [depositsModalOpen, setDepositsModalOpen] =
|
|
20079
|
-
const [depositExecutions, setDepositExecutions] =
|
|
20080
|
-
const [projectConfig, setProjectConfig] =
|
|
19887
|
+
const [browserWalletModalOpen, setBrowserWalletModalOpen] = useState24(false);
|
|
19888
|
+
const [browserWalletInfo, setBrowserWalletInfo] = useState24(null);
|
|
19889
|
+
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = useState24(false);
|
|
19890
|
+
const [browserWalletChainType, setBrowserWalletChainType] = useState24(() => getStoredWalletChainType());
|
|
19891
|
+
const [quotesCount, setQuotesCount] = useState24(0);
|
|
19892
|
+
const [depositsModalOpen, setDepositsModalOpen] = useState24(false);
|
|
19893
|
+
const [depositExecutions, setDepositExecutions] = useState24([]);
|
|
19894
|
+
const [projectConfig, setProjectConfig] = useState24(null);
|
|
20081
19895
|
const isMobileView = useIsMobileViewport();
|
|
20082
19896
|
useEffect18(() => {
|
|
20083
19897
|
setProjectConfig(null);
|
|
@@ -20096,7 +19910,7 @@ function DepositModal({
|
|
|
20096
19910
|
// Only fetch when modal is open
|
|
20097
19911
|
});
|
|
20098
19912
|
const wallets = depositAddressResponse?.data ?? [];
|
|
20099
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
19913
|
+
const [resolvedTheme, setResolvedTheme] = useState24(
|
|
20100
19914
|
theme === "auto" ? "dark" : theme
|
|
20101
19915
|
);
|
|
20102
19916
|
useEffect18(() => {
|
|
@@ -20151,6 +19965,7 @@ function DepositModal({
|
|
|
20151
19965
|
};
|
|
20152
19966
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
20153
19967
|
const handleWalletDisconnect = () => {
|
|
19968
|
+
setUserDisconnectedWallet(true);
|
|
20154
19969
|
clearStoredWalletChainType();
|
|
20155
19970
|
setBrowserWalletChainType(void 0);
|
|
20156
19971
|
setBrowserWalletInfo(null);
|
|
@@ -20242,6 +20057,7 @@ function DepositModal({
|
|
|
20242
20057
|
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
20243
20058
|
balanceChainId: destinationChainId,
|
|
20244
20059
|
balanceTokenAddress: destinationTokenAddress,
|
|
20060
|
+
projectName: projectConfig?.project_name,
|
|
20245
20061
|
publishableKey
|
|
20246
20062
|
}
|
|
20247
20063
|
),
|
|
@@ -20322,7 +20138,14 @@ function DepositModal({
|
|
|
20322
20138
|
title: t5.transferCrypto.title,
|
|
20323
20139
|
showBack: true,
|
|
20324
20140
|
onBack: handleBack,
|
|
20325
|
-
onClose: handleClose
|
|
20141
|
+
onClose: handleClose,
|
|
20142
|
+
showBalance: showBalanceHeader,
|
|
20143
|
+
balanceAddress: recipientAddress,
|
|
20144
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
20145
|
+
balanceChainId: destinationChainId,
|
|
20146
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
20147
|
+
projectName: projectConfig?.project_name,
|
|
20148
|
+
publishableKey
|
|
20326
20149
|
}
|
|
20327
20150
|
),
|
|
20328
20151
|
transferInputVariant === "single_input" ? /* @__PURE__ */ jsx46(
|
|
@@ -20334,6 +20157,7 @@ function DepositModal({
|
|
|
20334
20157
|
destinationChainType,
|
|
20335
20158
|
destinationChainId,
|
|
20336
20159
|
destinationTokenAddress,
|
|
20160
|
+
depositConfirmationMode,
|
|
20337
20161
|
onExecutionsChange: setDepositExecutions,
|
|
20338
20162
|
onDepositSuccess,
|
|
20339
20163
|
onDepositError,
|
|
@@ -20348,6 +20172,7 @@ function DepositModal({
|
|
|
20348
20172
|
destinationChainType,
|
|
20349
20173
|
destinationChainId,
|
|
20350
20174
|
destinationTokenAddress,
|
|
20175
|
+
depositConfirmationMode,
|
|
20351
20176
|
onExecutionsChange: setDepositExecutions,
|
|
20352
20177
|
onDepositSuccess,
|
|
20353
20178
|
onDepositError,
|
|
@@ -20362,7 +20187,14 @@ function DepositModal({
|
|
|
20362
20187
|
showBack: true,
|
|
20363
20188
|
onBack: handleBack,
|
|
20364
20189
|
onClose: handleClose,
|
|
20365
|
-
badge: cardView === "quotes" ? { count: quotesCount } : void 0
|
|
20190
|
+
badge: cardView === "quotes" ? { count: quotesCount } : void 0,
|
|
20191
|
+
showBalance: showBalanceHeader,
|
|
20192
|
+
balanceAddress: recipientAddress,
|
|
20193
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
20194
|
+
balanceChainId: destinationChainId,
|
|
20195
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
20196
|
+
projectName: projectConfig?.project_name,
|
|
20197
|
+
publishableKey
|
|
20366
20198
|
}
|
|
20367
20199
|
),
|
|
20368
20200
|
/* @__PURE__ */ jsx46(
|
|
@@ -20526,7 +20358,7 @@ function UnifoldProvider2({
|
|
|
20526
20358
|
}, [config?.appearance]);
|
|
20527
20359
|
const depositPromiseRef = React38.useRef(null);
|
|
20528
20360
|
const closeTimeoutRef = React38.useRef(null);
|
|
20529
|
-
const beginDeposit =
|
|
20361
|
+
const beginDeposit = useCallback12((config2) => {
|
|
20530
20362
|
if (closeTimeoutRef.current) {
|
|
20531
20363
|
clearTimeout(closeTimeoutRef.current);
|
|
20532
20364
|
closeTimeoutRef.current = null;
|
|
@@ -20546,7 +20378,7 @@ function UnifoldProvider2({
|
|
|
20546
20378
|
setIsOpen(true);
|
|
20547
20379
|
return promise;
|
|
20548
20380
|
}, []);
|
|
20549
|
-
const closeDeposit =
|
|
20381
|
+
const closeDeposit = useCallback12(() => {
|
|
20550
20382
|
if (depositPromiseRef.current) {
|
|
20551
20383
|
depositPromiseRef.current.reject({
|
|
20552
20384
|
message: "Deposit cancelled by user",
|
|
@@ -20560,7 +20392,7 @@ function UnifoldProvider2({
|
|
|
20560
20392
|
closeTimeoutRef.current = null;
|
|
20561
20393
|
}, 200);
|
|
20562
20394
|
}, []);
|
|
20563
|
-
const handleDepositSuccess =
|
|
20395
|
+
const handleDepositSuccess = useCallback12((data) => {
|
|
20564
20396
|
if (depositConfig?.onSuccess) {
|
|
20565
20397
|
depositConfig.onSuccess(data);
|
|
20566
20398
|
}
|
|
@@ -20569,7 +20401,7 @@ function UnifoldProvider2({
|
|
|
20569
20401
|
depositPromiseRef.current = null;
|
|
20570
20402
|
}
|
|
20571
20403
|
}, [depositConfig]);
|
|
20572
|
-
const handleDepositError =
|
|
20404
|
+
const handleDepositError = useCallback12((error) => {
|
|
20573
20405
|
console.error("[UnifoldProvider] Deposit error:", error);
|
|
20574
20406
|
if (depositConfig?.onError) {
|
|
20575
20407
|
depositConfig.onError(error);
|
|
@@ -20612,6 +20444,7 @@ function UnifoldProvider2({
|
|
|
20612
20444
|
destinationChainType: depositConfig.destinationChainType,
|
|
20613
20445
|
destinationChainId: depositConfig.destinationChainId,
|
|
20614
20446
|
destinationTokenAddress: depositConfig.destinationTokenAddress,
|
|
20447
|
+
depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
|
|
20615
20448
|
hideDepositTracker: config?.hideDepositTracker,
|
|
20616
20449
|
showBalanceHeader: config?.showBalanceHeader,
|
|
20617
20450
|
transferInputVariant: config?.transferInputVariant,
|