@rash2x/bridge-widget 0.6.35 → 0.6.37
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/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-DvKN7Y1C.js → index-Ba8WNSvX.js} +156 -70
- package/dist/index-Ba8WNSvX.js.map +1 -0
- package/dist/{index-DJbbVeMD.cjs → index-BdVobQxB.cjs} +2 -2
- package/dist/{index-DJbbVeMD.cjs.map → index-BdVobQxB.cjs.map} +1 -1
- package/dist/{index-BXp-N4UF.cjs → index-DLEm1SpB.cjs} +155 -69
- package/dist/index-DLEm1SpB.cjs.map +1 -0
- package/dist/{index-Cd_UnZsU.js → index-YEwKytA_.js} +2 -2
- package/dist/{index-Cd_UnZsU.js.map → index-YEwKytA_.js.map} +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/index-BXp-N4UF.cjs.map +0 -1
- package/dist/index-DvKN7Y1C.js.map +0 -1
package/dist/evaa-bridge.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-DLEm1SpB.cjs");
|
|
4
4
|
exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
|
|
5
5
|
exports.EvaaBridge = index.EvaaBridge;
|
|
6
6
|
exports.RoutePriority = index.RoutePriority;
|
package/dist/evaa-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U, d, f, e, H, B, F, X, N, z, $, G, A, D, Z, w, s, v, r, p, q, L, a2, aa, a4, a7, x, I, y, a5, J, a3, a8, a9, Y, a6, W, P, _, a1, ab, Q, S, a0, K, V, t, o, i, u, l, m, j, n, h, k } from "./index-
|
|
1
|
+
import { U, d, f, e, H, B, F, X, N, z, $, G, A, D, Z, w, s, v, r, p, q, L, a2, aa, a4, a7, x, I, y, a5, J, a3, a8, a9, Y, a6, W, P, _, a1, ab, Q, S, a0, K, V, t, o, i, u, l, m, j, n, h, k } from "./index-Ba8WNSvX.js";
|
|
2
2
|
export {
|
|
3
3
|
U as DEFAULT_SLIPPAGE_BPS,
|
|
4
4
|
d as EvaaBridge,
|
|
@@ -18,7 +18,7 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|
|
18
18
|
import { Input } from "@/components/ui/input";
|
|
19
19
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from "@/components/ui/dialog";
|
|
20
20
|
import { Switch } from "@/components/ui/switch";
|
|
21
|
-
import { X as X$3, Loader2, AlertCircleIcon, CheckCircle2, Clock } from "lucide-react";
|
|
21
|
+
import { X as X$3, Loader2, AlertCircleIcon, ArrowRight, CheckCircle2, Clock } from "lucide-react";
|
|
22
22
|
import { AnimatePresence, motion } from "framer-motion";
|
|
23
23
|
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@/components/ui/accordion";
|
|
24
24
|
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
|
|
@@ -498,6 +498,7 @@ const useTronWalletConnectStore = create(
|
|
|
498
498
|
isConnecting: false,
|
|
499
499
|
connect: null,
|
|
500
500
|
disconnect: null,
|
|
501
|
+
cancelConnection: null,
|
|
501
502
|
signTransaction: null,
|
|
502
503
|
setAddress: (address) => set2({
|
|
503
504
|
address,
|
|
@@ -507,6 +508,7 @@ const useTronWalletConnectStore = create(
|
|
|
507
508
|
setActions: (actions) => set2({
|
|
508
509
|
connect: actions.connect,
|
|
509
510
|
disconnect: actions.disconnect,
|
|
511
|
+
cancelConnection: actions.cancelConnection,
|
|
510
512
|
signTransaction: actions.signTransaction
|
|
511
513
|
}),
|
|
512
514
|
reset: () => set2({
|
|
@@ -2641,7 +2643,7 @@ const ChainSelectModal = ({
|
|
|
2641
2643
|
chain2.chainKey
|
|
2642
2644
|
);
|
|
2643
2645
|
};
|
|
2644
|
-
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90dvh] h-[90dvh] overflow-hidden flex flex-col p-10 pt-7", children: [
|
|
2646
|
+
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "md:max-h-[90dvh] md:h-[90dvh] fixed top-0 left-0 right-0 bottom-0 overflow-hidden flex flex-col p-10 pt-7", children: [
|
|
2645
2647
|
/* @__PURE__ */ jsx(DialogHeader, { className: "text-left pb-0", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-xl leading-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0", children: [
|
|
2646
2648
|
/* @__PURE__ */ jsx("div", { children: t2("bridge.select") }),
|
|
2647
2649
|
/* @__PURE__ */ jsx("div", { children: t2(isSource ? "bridge.sourceNetwork" : "bridge.destinationNetwork") })
|
|
@@ -2655,7 +2657,7 @@ const ChainSelectModal = ({
|
|
|
2655
2657
|
className: "text-foreground placeholder:text-muted-foreground"
|
|
2656
2658
|
}
|
|
2657
2659
|
),
|
|
2658
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto", children: [
|
|
2660
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 [&::-webkit-scrollbar-thumb]:rounded-full hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/30", children: [
|
|
2659
2661
|
groupedChains.available.length > 0 && groupedChains.available.map((c2) => renderChainItem(c2, false)),
|
|
2660
2662
|
groupedChains.willChangeSrc.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2661
2663
|
/* @__PURE__ */ jsx(
|
|
@@ -3149,7 +3151,7 @@ function getSimpleFallback(chainKey) {
|
|
|
3149
3151
|
const key = chainKey.toLowerCase();
|
|
3150
3152
|
if (key === "ton") return 0.15;
|
|
3151
3153
|
if (key === "tron") return 10;
|
|
3152
|
-
return
|
|
3154
|
+
return 2e-3;
|
|
3153
3155
|
}
|
|
3154
3156
|
function useGasEstimate(amountNum) {
|
|
3155
3157
|
const { fromChain } = useChainsStore();
|
|
@@ -3183,6 +3185,7 @@ function useGasEstimate(amountNum) {
|
|
|
3183
3185
|
const nativeBalance = nativeBalanceValue;
|
|
3184
3186
|
const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
|
|
3185
3187
|
let requiredNative = 0;
|
|
3188
|
+
let quoteFeesAvailable = false;
|
|
3186
3189
|
if (quoteFees && quoteSrcChainKey === chainKey) {
|
|
3187
3190
|
const fees = quoteFees;
|
|
3188
3191
|
const feesInNative = fees.filter(
|
|
@@ -3193,6 +3196,7 @@ function useGasEstimate(amountNum) {
|
|
|
3193
3196
|
);
|
|
3194
3197
|
const decimals = nativeCurrencyDecimals || 18;
|
|
3195
3198
|
requiredNative = Number(feesInNative) / Math.pow(10, decimals);
|
|
3199
|
+
quoteFeesAvailable = true;
|
|
3196
3200
|
} else {
|
|
3197
3201
|
requiredNative = getSimpleFallback(chainKey);
|
|
3198
3202
|
}
|
|
@@ -3202,13 +3206,14 @@ function useGasEstimate(amountNum) {
|
|
|
3202
3206
|
} else {
|
|
3203
3207
|
hasEnoughGas = nativeBalance >= requiredNative;
|
|
3204
3208
|
}
|
|
3209
|
+
const shouldCheckGas = balancesKnown && quoteFeesAvailable;
|
|
3205
3210
|
return {
|
|
3206
3211
|
nativeSym,
|
|
3207
3212
|
nativeBalance,
|
|
3208
3213
|
requiredNative,
|
|
3209
3214
|
balancesKnown,
|
|
3210
3215
|
isNativeSelected,
|
|
3211
|
-
hasEnoughGas:
|
|
3216
|
+
hasEnoughGas: shouldCheckGas ? hasEnoughGas : true
|
|
3212
3217
|
};
|
|
3213
3218
|
}, [
|
|
3214
3219
|
chainKey,
|
|
@@ -3762,11 +3767,9 @@ function useBridgeTransaction() {
|
|
|
3762
3767
|
);
|
|
3763
3768
|
feeSymbol = srcChain2?.nativeCurrency?.symbol || "";
|
|
3764
3769
|
}
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
txStore.updateActualFee(feeValue, feeSymbol);
|
|
3769
|
-
}
|
|
3770
|
+
const feeValue = parseFloat(result.actualFeeValue);
|
|
3771
|
+
if (!isNaN(feeValue)) {
|
|
3772
|
+
txStore.updateActualFee(feeValue, feeSymbol);
|
|
3770
3773
|
}
|
|
3771
3774
|
}
|
|
3772
3775
|
txStore.updateStatus("completed");
|
|
@@ -3784,15 +3787,19 @@ function useBridgeTransaction() {
|
|
|
3784
3787
|
txStore.setError("COMPLETION_TRACKING_FAILED");
|
|
3785
3788
|
}
|
|
3786
3789
|
console.error("Error tracking completion:", err);
|
|
3790
|
+
}).finally(() => {
|
|
3791
|
+
setIsProcessing(false);
|
|
3787
3792
|
});
|
|
3793
|
+
return txResult;
|
|
3788
3794
|
} else {
|
|
3795
|
+
setIsProcessing(false);
|
|
3789
3796
|
throw new TransactionFailedError(
|
|
3790
3797
|
chainKey,
|
|
3791
3798
|
"Transaction hash not received from wallet"
|
|
3792
3799
|
);
|
|
3793
3800
|
}
|
|
3794
|
-
return txResult;
|
|
3795
3801
|
} catch (err) {
|
|
3802
|
+
setIsProcessing(false);
|
|
3796
3803
|
if (isUserRejection(err)) {
|
|
3797
3804
|
txStore.setError("TRANSACTION_REJECTED");
|
|
3798
3805
|
throw new TransactionFailedError(
|
|
@@ -3808,8 +3815,6 @@ function useBridgeTransaction() {
|
|
|
3808
3815
|
console.log(err);
|
|
3809
3816
|
txStore.setError("UNKNOWN_ERROR");
|
|
3810
3817
|
throw err;
|
|
3811
|
-
} finally {
|
|
3812
|
-
setIsProcessing(false);
|
|
3813
3818
|
}
|
|
3814
3819
|
};
|
|
3815
3820
|
return {
|
|
@@ -4314,7 +4319,7 @@ const WalletSelectModal = () => {
|
|
|
4314
4319
|
}
|
|
4315
4320
|
return a2.order - b2.order;
|
|
4316
4321
|
});
|
|
4317
|
-
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-10 pt-7", children: [
|
|
4322
|
+
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 p-10 pt-7", children: [
|
|
4318
4323
|
/* @__PURE__ */ jsxs(DialogHeader, { className: "text-left", children: [
|
|
4319
4324
|
/* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("wallets.chooseWallet") }),
|
|
4320
4325
|
/* @__PURE__ */ jsx(DialogDescription, { children: t2("wallets.oneWalletPerEnv") })
|
|
@@ -4547,67 +4552,114 @@ const SuccessStep = ({
|
|
|
4547
4552
|
}) => {
|
|
4548
4553
|
const { current, reset } = useTransactionStore();
|
|
4549
4554
|
const { t: t2 } = useBridgeTranslation();
|
|
4555
|
+
const { chains } = useChainsStore();
|
|
4550
4556
|
const metadata = current?.metadata;
|
|
4551
4557
|
const srcTxHash = current?.srcTxHash;
|
|
4552
4558
|
const srcChainKey = current?.quote?.srcChainKey;
|
|
4559
|
+
const quote = current?.quote;
|
|
4560
|
+
const estimatedFee = useMemo(() => {
|
|
4561
|
+
if (!quote?.fees || !srcChainKey || !chains) return null;
|
|
4562
|
+
const srcChain = chains.find((c2) => c2.chainKey === srcChainKey);
|
|
4563
|
+
if (!srcChain) return null;
|
|
4564
|
+
const nativeCurrencyAddress = srcChain.nativeCurrency.address;
|
|
4565
|
+
const nativeCurrencyDecimals = srcChain.nativeCurrency.decimals;
|
|
4566
|
+
const nativeCurrencySymbol = srcChain.nativeCurrency.symbol;
|
|
4567
|
+
const feesInNative = quote.fees.filter(
|
|
4568
|
+
(f4) => f4.chainKey === srcChainKey && f4.token === nativeCurrencyAddress
|
|
4569
|
+
).reduce((sum, f4) => sum + BigInt(f4.amount || "0"), 0n);
|
|
4570
|
+
if (feesInNative === 0n) return null;
|
|
4571
|
+
const feeValue = Number(feesInNative) / Math.pow(10, nativeCurrencyDecimals);
|
|
4572
|
+
return {
|
|
4573
|
+
value: feeValue,
|
|
4574
|
+
symbol: nativeCurrencySymbol
|
|
4575
|
+
};
|
|
4576
|
+
}, [quote, srcChainKey, chains]);
|
|
4577
|
+
const finalFee = useMemo(() => {
|
|
4578
|
+
if (metadata?.actualFeeValue !== void 0 && metadata?.actualFeeSymbol) {
|
|
4579
|
+
return {
|
|
4580
|
+
value: metadata.actualFeeValue,
|
|
4581
|
+
symbol: metadata.actualFeeSymbol
|
|
4582
|
+
};
|
|
4583
|
+
}
|
|
4584
|
+
return estimatedFee;
|
|
4585
|
+
}, [metadata?.actualFeeValue, metadata?.actualFeeSymbol, estimatedFee]);
|
|
4553
4586
|
const handleOpenExplorer = () => {
|
|
4554
4587
|
if (srcTxHash && srcChainKey) {
|
|
4555
4588
|
openTransactionInExplorer(srcChainKey, srcTxHash);
|
|
4556
4589
|
}
|
|
4557
4590
|
};
|
|
4558
|
-
return /* @__PURE__ */ jsxs(
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
metadata?.
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
metadata?.srcChainName,
|
|
4577
|
-
" ",
|
|
4578
|
-
/* @__PURE__ */ jsx(NetworkSymbol, { chainKey: metadata.srcChainName })
|
|
4591
|
+
return /* @__PURE__ */ jsxs(
|
|
4592
|
+
DialogContent,
|
|
4593
|
+
{
|
|
4594
|
+
showCloseButton: true,
|
|
4595
|
+
className: "overflow-hidden md:max-w-[420px] p-10",
|
|
4596
|
+
children: [
|
|
4597
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 flex-1 justify-start items-center text-center bg-background", children: [
|
|
4598
|
+
icon,
|
|
4599
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-[28px]", children: t2("transaction.success") }) }),
|
|
4600
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 mt-3 relative z-10 pb-14", children: [
|
|
4601
|
+
metadata?.srcAmountHuman && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4602
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.bridged") }),
|
|
4603
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 font-medium", children: [
|
|
4604
|
+
formatBalance(metadata.srcAmountHuman, 2),
|
|
4605
|
+
" ",
|
|
4606
|
+
metadata?.srcTokenSymbol,
|
|
4607
|
+
/* @__PURE__ */ jsx(TokenSymbol, { className: "w-[18px] h-[18px]", symbol: metadata?.srcTokenSymbol })
|
|
4608
|
+
] })
|
|
4579
4609
|
] }),
|
|
4580
|
-
/* @__PURE__ */
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4610
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4611
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.transferTitle") }),
|
|
4612
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium flex gap-1 items-center", children: [
|
|
4613
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex gap-1 items-center", children: [
|
|
4614
|
+
metadata?.srcChainName,
|
|
4615
|
+
" ",
|
|
4616
|
+
/* @__PURE__ */ jsx(
|
|
4617
|
+
NetworkSymbol,
|
|
4618
|
+
{
|
|
4619
|
+
className: "w-[18px] h-[18px] rounded-full",
|
|
4620
|
+
chainKey: metadata.srcChainName
|
|
4621
|
+
}
|
|
4622
|
+
)
|
|
4623
|
+
] }),
|
|
4624
|
+
/* @__PURE__ */ jsx(ArrowRight, { className: "text-muted-foreground/50 size-4" }),
|
|
4625
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex gap-1 items-center", children: [
|
|
4626
|
+
metadata?.dstChainName,
|
|
4627
|
+
" ",
|
|
4628
|
+
/* @__PURE__ */ jsx(
|
|
4629
|
+
NetworkSymbol,
|
|
4630
|
+
{
|
|
4631
|
+
className: "w-[18px] h-[18px] rounded-full",
|
|
4632
|
+
chainKey: metadata.dstChainName
|
|
4633
|
+
}
|
|
4634
|
+
)
|
|
4635
|
+
] })
|
|
4636
|
+
] })
|
|
4637
|
+
] }),
|
|
4638
|
+
srcTxHash && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4639
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.hash") }),
|
|
4640
|
+
/* @__PURE__ */ jsx(
|
|
4641
|
+
"button",
|
|
4642
|
+
{
|
|
4643
|
+
onClick: handleOpenExplorer,
|
|
4644
|
+
className: "font-medium cursor-pointer inline-flex items-center gap-1 underline hover:no-underline",
|
|
4645
|
+
children: formatHash(srcTxHash)
|
|
4646
|
+
}
|
|
4647
|
+
)
|
|
4648
|
+
] }),
|
|
4649
|
+
finalFee && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4650
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.finalFee") }),
|
|
4651
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
4652
|
+
formatBalance(finalFee.value, 6),
|
|
4653
|
+
" ",
|
|
4654
|
+
finalFee.symbol
|
|
4655
|
+
] })
|
|
4585
4656
|
] })
|
|
4586
4657
|
] })
|
|
4587
4658
|
] }),
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
{
|
|
4593
|
-
onClick: handleOpenExplorer,
|
|
4594
|
-
className: "font-medium cursor-pointer inline-flex items-center gap-1 underline hover:no-underline",
|
|
4595
|
-
children: formatHash(srcTxHash)
|
|
4596
|
-
}
|
|
4597
|
-
)
|
|
4598
|
-
] }),
|
|
4599
|
-
metadata?.actualFeeValue && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4600
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.finalFee") }),
|
|
4601
|
-
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
4602
|
-
metadata.actualFeeValue,
|
|
4603
|
-
" ",
|
|
4604
|
-
metadata.actualFeeSymbol
|
|
4605
|
-
] })
|
|
4606
|
-
] })
|
|
4607
|
-
] })
|
|
4608
|
-
] }),
|
|
4609
|
-
/* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(Button, { onClick: reset, className: "w-full", children: t2("transaction.done") }) })
|
|
4610
|
-
] });
|
|
4659
|
+
/* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(Button, { onClick: reset, className: "w-full", children: t2("transaction.done") }) })
|
|
4660
|
+
]
|
|
4661
|
+
}
|
|
4662
|
+
);
|
|
4611
4663
|
};
|
|
4612
4664
|
const useCountdown = (initialSeconds) => {
|
|
4613
4665
|
const [time2, setTime] = useState(initialSeconds);
|
|
@@ -6621,7 +6673,7 @@ const SettingsModal = ({ isOpen, onClose }) => {
|
|
|
6621
6673
|
DialogContent,
|
|
6622
6674
|
{
|
|
6623
6675
|
onOpenAutoFocus: (e2) => e2.preventDefault(),
|
|
6624
|
-
className: "p-10 pt-7",
|
|
6676
|
+
className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 p-10 pt-7",
|
|
6625
6677
|
children: [
|
|
6626
6678
|
/* @__PURE__ */ jsx(DialogHeader, { className: "text-left", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("settings.title") }) }),
|
|
6627
6679
|
/* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
|
|
@@ -6937,7 +6989,6 @@ const TokenSelectModal = ({
|
|
|
6937
6989
|
useLayoutEffect(() => {
|
|
6938
6990
|
const updateHeight = () => {
|
|
6939
6991
|
const container2 = document.getElementById("token-select-list");
|
|
6940
|
-
console.log("CONTAINER", container2);
|
|
6941
6992
|
if (!container2) return;
|
|
6942
6993
|
const height = container2.getBoundingClientRect().height;
|
|
6943
6994
|
if (height > 0) {
|
|
@@ -7010,7 +7061,7 @@ const TokenSelectModal = ({
|
|
|
7010
7061
|
},
|
|
7011
7062
|
[effectiveTab, virtualItems]
|
|
7012
7063
|
);
|
|
7013
|
-
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90dvh] h-[90dvh] overflow-hidden flex flex-col p-10 pt-7", children: [
|
|
7064
|
+
return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "md:max-h-[90dvh] md:h-[90dvh] overflow-hidden flex flex-col fixed top-0 left-0 right-0 bottom-0 p-10 pt-7", children: [
|
|
7014
7065
|
/* @__PURE__ */ jsx(DialogHeader, { className: "text-left", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("bridge.selectToken") }) }),
|
|
7015
7066
|
/* @__PURE__ */ jsx(
|
|
7016
7067
|
SearchInput,
|
|
@@ -25914,7 +25965,7 @@ class WalletConnectModal {
|
|
|
25914
25965
|
}
|
|
25915
25966
|
async initUi() {
|
|
25916
25967
|
if (typeof window !== "undefined") {
|
|
25917
|
-
await import("./index-
|
|
25968
|
+
await import("./index-YEwKytA_.js");
|
|
25918
25969
|
const modal = document.createElement("wcm-modal");
|
|
25919
25970
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25920
25971
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -25959,11 +26010,13 @@ const useThemeStore = create((set2) => ({
|
|
|
25959
26010
|
}
|
|
25960
26011
|
}));
|
|
25961
26012
|
const TRON_MAINNET_CHAIN_ID = "tron:0x2b6653dc";
|
|
26013
|
+
const CONNECTION_TIMEOUT = 6e4;
|
|
25962
26014
|
function useTronWalletConnect(projectId) {
|
|
25963
26015
|
const { address, isConnected, isConnecting } = useTronWalletConnectStore();
|
|
25964
26016
|
const { setAddress, setIsConnecting, setActions, reset } = useTronWalletConnectStore();
|
|
25965
26017
|
const providerRef = useRef(null);
|
|
25966
26018
|
const modalRef = useRef(null);
|
|
26019
|
+
const abortControllerRef = useRef(null);
|
|
25967
26020
|
const { onClose: closeWalletSelectModal } = useWalletSelectModal();
|
|
25968
26021
|
const appliedTheme = useThemeStore((state2) => state2.appliedTheme);
|
|
25969
26022
|
useEffect(() => {
|
|
@@ -26026,6 +26079,9 @@ function useTronWalletConnect(projectId) {
|
|
|
26026
26079
|
};
|
|
26027
26080
|
initProvider();
|
|
26028
26081
|
return () => {
|
|
26082
|
+
if (abortControllerRef.current) {
|
|
26083
|
+
abortControllerRef.current.abort();
|
|
26084
|
+
}
|
|
26029
26085
|
if (providerRef.current) {
|
|
26030
26086
|
providerRef.current.disconnect();
|
|
26031
26087
|
}
|
|
@@ -26052,9 +26108,14 @@ function useTronWalletConnect(projectId) {
|
|
|
26052
26108
|
"WalletConnect not initialized. Please provide a valid project ID."
|
|
26053
26109
|
);
|
|
26054
26110
|
}
|
|
26111
|
+
if (abortControllerRef.current) {
|
|
26112
|
+
abortControllerRef.current.abort();
|
|
26113
|
+
}
|
|
26114
|
+
abortControllerRef.current = new AbortController();
|
|
26115
|
+
const abortController = abortControllerRef.current;
|
|
26055
26116
|
setIsConnecting(true);
|
|
26056
26117
|
try {
|
|
26057
|
-
const
|
|
26118
|
+
const connectionPromise = providerRef.current.connect({
|
|
26058
26119
|
namespaces: {
|
|
26059
26120
|
tron: {
|
|
26060
26121
|
methods: ["tron_signTransaction", "tron_signMessage"],
|
|
@@ -26063,6 +26124,19 @@ function useTronWalletConnect(projectId) {
|
|
|
26063
26124
|
}
|
|
26064
26125
|
}
|
|
26065
26126
|
});
|
|
26127
|
+
const timeoutPromise = new Promise((_3, reject) => {
|
|
26128
|
+
const timeoutId = setTimeout(() => {
|
|
26129
|
+
reject(new Error("Connection timeout - please try again"));
|
|
26130
|
+
}, CONNECTION_TIMEOUT);
|
|
26131
|
+
abortController.signal.addEventListener("abort", () => {
|
|
26132
|
+
clearTimeout(timeoutId);
|
|
26133
|
+
reject(new Error("Connection cancelled"));
|
|
26134
|
+
});
|
|
26135
|
+
});
|
|
26136
|
+
const session = await Promise.race([connectionPromise, timeoutPromise]);
|
|
26137
|
+
if (abortController.signal.aborted) {
|
|
26138
|
+
throw new Error("Connection cancelled");
|
|
26139
|
+
}
|
|
26066
26140
|
if (session) {
|
|
26067
26141
|
const accounts = session.namespaces?.tron?.accounts || [];
|
|
26068
26142
|
if (accounts.length > 0) {
|
|
@@ -26087,8 +26161,18 @@ function useTronWalletConnect(projectId) {
|
|
|
26087
26161
|
throw error;
|
|
26088
26162
|
} finally {
|
|
26089
26163
|
setIsConnecting(false);
|
|
26164
|
+
abortControllerRef.current = null;
|
|
26090
26165
|
}
|
|
26091
26166
|
}, [setAddress, setIsConnecting]);
|
|
26167
|
+
const cancelConnection = useCallback(() => {
|
|
26168
|
+
if (abortControllerRef.current) {
|
|
26169
|
+
abortControllerRef.current.abort();
|
|
26170
|
+
console.log("TRON WalletConnect connection cancelled");
|
|
26171
|
+
}
|
|
26172
|
+
if (modalRef.current) {
|
|
26173
|
+
modalRef.current.closeModal();
|
|
26174
|
+
}
|
|
26175
|
+
}, []);
|
|
26092
26176
|
const disconnect = useCallback(async () => {
|
|
26093
26177
|
if (!providerRef.current) return;
|
|
26094
26178
|
try {
|
|
@@ -26125,15 +26209,17 @@ function useTronWalletConnect(projectId) {
|
|
|
26125
26209
|
setActions({
|
|
26126
26210
|
connect,
|
|
26127
26211
|
disconnect,
|
|
26212
|
+
cancelConnection,
|
|
26128
26213
|
signTransaction
|
|
26129
26214
|
});
|
|
26130
|
-
}, [connect, disconnect, signTransaction, setActions]);
|
|
26215
|
+
}, [connect, disconnect, cancelConnection, signTransaction, setActions]);
|
|
26131
26216
|
return {
|
|
26132
26217
|
address,
|
|
26133
26218
|
isConnected,
|
|
26134
26219
|
isConnecting,
|
|
26135
26220
|
connect,
|
|
26136
26221
|
disconnect,
|
|
26222
|
+
cancelConnection,
|
|
26137
26223
|
signTransaction
|
|
26138
26224
|
};
|
|
26139
26225
|
}
|
|
@@ -26638,4 +26724,4 @@ export {
|
|
|
26638
26724
|
getQuoteFees as y,
|
|
26639
26725
|
calculateMinReceived as z
|
|
26640
26726
|
};
|
|
26641
|
-
//# sourceMappingURL=index-
|
|
26727
|
+
//# sourceMappingURL=index-Ba8WNSvX.js.map
|