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