@rash2x/bridge-widget 0.5.1 → 0.5.6
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/README.md +73 -2
- package/dist/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-C0llk2Pm.cjs → index-BXUBhn_o.cjs} +528 -121
- package/dist/index-BXUBhn_o.cjs.map +1 -0
- package/dist/{index-CwCBOFR2.js → index-Bj6AJLyW.js} +2 -2
- package/dist/{index-CwCBOFR2.js.map → index-Bj6AJLyW.js.map} +1 -1
- package/dist/{index-DedRamsD.cjs → index-CebGXD16.cjs} +2 -2
- package/dist/{index-DedRamsD.cjs.map → index-CebGXD16.cjs.map} +1 -1
- package/dist/{index-NQh101e3.js → index-w-PXiL0q.js} +528 -121
- package/dist/index-w-PXiL0q.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/dist/index-C0llk2Pm.cjs.map +0 -1
- package/dist/index-NQh101e3.js.map +0 -1
|
@@ -22,16 +22,19 @@ import { X as X$3, Loader2, AlertCircleIcon, CheckCircle2, Clock } from "lucide-
|
|
|
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";
|
|
25
|
+
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
25
26
|
import { toast, Toaster } from "sonner";
|
|
26
27
|
import { DialogDescription as DialogDescription$1 } from "@radix-ui/react-dialog";
|
|
27
28
|
import { isAddress, formatUnits, parseUnits } from "viem";
|
|
28
29
|
import { TronLinkAdapterName } from "@tronweb3/tronwallet-adapters";
|
|
30
|
+
import { TronWeb } from "tronweb";
|
|
29
31
|
import { CardHeader, CardTitle, CardAction, Card, CardContent, CardFooter } from "@/components/ui/card";
|
|
30
32
|
import { Badge } from "@/components/ui/badge";
|
|
31
33
|
const common$1 = { "connecting": "Connecting…", "initializing": "Initializing...", "loading": "Loading...", "paste": "paste", "close": "Close", "zeroPlaceholder": "0", "nativeToken": "Native Token" };
|
|
32
34
|
const wallets$1 = { "addTonWallet": "Add TON wallet", "addEvmWallet": "Add EVM wallet", "connectTonWallet": "Connect TON wallet", "connectEvmWallet": "Connect EVM wallet", "initializingMetamask": "Initializing MetaMask SDK...", "initializingTronlink": "Initializing TronLink...", "failedToConnectTon": "Failed to connect to TON wallet", "failedToDisconnect": "Failed to disconnect", "metamaskConnectionError": "MetaMask connection error", "failedToConnectMetamask": "Failed to connect to MetaMask", "failedToDisconnectMetamask": "Failed to disconnect from MetaMask", "selectWallet": "Select Wallet", "tonWallets": "TON", "evmWallets": "EVM", "tronWallets": "TRON", "tonconnect": "TonConnect", "metaMask": "WalletConnect", "walletConnect": "WalletConnect", "tronLink": "TronLink", "addTronWallet": "Add Tron wallet", "comingSoon": "Coming Soon", "connected": "CONNECTED", "disconnect": "Disconnect", "chooseWallet": "Choose wallet", "oneWalletPerEnv": "You can only connect one wallet per environment.", "connect": "Connect", "connectTronWallet": "Connect Tron wallet", "connectWallet": "Connect wallet" };
|
|
33
35
|
const bridge$1 = { "max": "Max", "sourceNetwork": "Source network", "destinationNetwork": "Destination network", "selectToken": "Select token", "selectNetwork": "Select network", "selectSourceNetwork": "Select source network", "selectDestinationNetwork": "Select destination network", "searchToken": "Search token", "myTokens": "My tokens", "allTokens": "All tokens", "search": "Search", "select": "Select", "willChangeSourceChain": "Will change source network", "willChangeSourceNetworkAndToken": "Will change source token", "noBalancesFound": "No balances found.", "noResults": "No results", "tokenNotFound": "We couldn't find a token with that name or symbol. Please try again.", "chainNotFound": "We couldn't find a chain with that name. Please try again.", "sendToAnotherAddress": "Send to another address", "youWillReceive": "You will receive", "anotherAddressPlaceholder": "Address", "addressDoesntMatch": "Address doesn't match the {{network}} network", "checkBeforeTransfer": "Check correctness before transfer" };
|
|
34
36
|
const transaction$1 = { "enterAmount": "Enter amount", "transfer": "Transfer", "getQuote": "Get quote", "failed": "Transaction Failed", "confirm": "Confirm transaction", "signTransaction": "Sign in transaction in wallet", "quoting": "Quoting...", "inProgress": "Processing...", "checkingBalance": "Checking balance...", "insufficientBalance": "Insufficient balance", "amountTooSmall": "Min {{min}}", "amountTooLarge": "Max {{max}}", "success": "Success", "successTitle": "Success", "done": "Done", "hashCopied": "Hash copied to clipboard", "bridged": "Bridged", "transferTitle": "Transfer", "hash": "Hash", "finalFee": "Final Fee", "route": "Route", "estTime": "Est. Time", "slippage": "Slippage", "minimumReceived": "Minimum received", "totalFee": "Total Fee", "noRouteFound": "No route found", "notEnoughGas": "Not enough gas", "noRouteFoundForSettings": "No route found for current settings.", "tryAdjustSettings": "Try disabling Gas on Destination, or adjust amount/networks.", "quoteError": "Quote error" };
|
|
37
|
+
const telegram$1 = { "openWebVersion": "Open EVAA Web to Bridge", "restrictionMessage": "You can bridge between the chosen networks on EVAA web version" };
|
|
35
38
|
const app$1 = { "stargateWidgetName": "Stargate Bridge Widget", "liveWidget": "Live Widget", "getStarted": "Get Started" };
|
|
36
39
|
const settings$1 = { "title": "Settings", "gasOnDestination": "Gas on destination", "slippageTolerance": "Slippage tolerance", "routePriority": "Route Priority", "highSlippageWarning": "High slippage warning", "gasPresets": { "auto": "Auto", "none": "None", "medium": "Medium", "max": "Max" }, "routePresets": { "fastest": "Fastest", "cheapest": "Cheapest", "recommended": "Recommended" } };
|
|
37
40
|
const errors$1 = { "WALLET_NOT_CONNECTED": "{{chainKey}} wallet not connected", "WALLET_CONNECTION_FAILED": "Failed to connect {{chainKey}} wallet", "WALLET_NOT_FOUND": "No {{chainKey}} wallet found. Please install a wallet extension.", "INVALID_ADDRESS": "Invalid {{chainKey}} address format", "INVALID_STEPS": "Invalid transaction steps for {{chainKey}}", "INVALID_TRANSACTION_DATA": "Invalid transaction data for {{chainKey}}", "TRANSACTION_REJECTED": "Transaction rejected by user", "TRANSACTION_FAILED": "Transaction failed", "TRANSACTION_TIMEOUT": "Transaction confirmation timeout", "TRANSACTION_REVERTED": "Transaction reverted on-chain", "INSUFFICIENT_GAS": "Insufficient {{chainKey}} gas", "PROVIDER_NOT_AVAILABLE": "{{chainKey}} provider not available", "NETWORK_REQUEST_FAILED": "Network request failed", "TRANSACTION_FAILED_TO_COMPLETE": "Transaction failed to complete", "COMPLETION_TRACKING_FAILED": "Completion tracking failed", "UNKNOWN_ERROR": "An unknown error occurred" };
|
|
@@ -40,6 +43,7 @@ const en$3 = {
|
|
|
40
43
|
wallets: wallets$1,
|
|
41
44
|
bridge: bridge$1,
|
|
42
45
|
transaction: transaction$1,
|
|
46
|
+
telegram: telegram$1,
|
|
43
47
|
app: app$1,
|
|
44
48
|
settings: settings$1,
|
|
45
49
|
errors: errors$1
|
|
@@ -48,6 +52,7 @@ const common = { "connecting": "Подключение…", "initializing": "И
|
|
|
48
52
|
const wallets = { "addTonWallet": "Добавить TON кошелёк", "addEvmWallet": "Добавить EVM кошелёк", "connectTonWallet": "Подключить TON кошелёк", "connectEvmWallet": "Подключить EVM кошелёк", "initializingMetamask": "Инициализация MetaMask SDK...", "initializingTronlink": "Инициализация TronLink...", "failedToConnectTon": "Не удалось подключиться к TON кошельку", "failedToDisconnect": "Не удалось отключиться", "metamaskConnectionError": "Ошибка подключения MetaMask", "failedToConnectMetamask": "Не удалось подключиться к MetaMask", "failedToDisconnectMetamask": "Не удалось отключиться от MetaMask", "selectWallet": "Выберите кошелёк", "tonWallets": "TON", "evmWallets": "EVM", "tronWallets": "TRON", "tonconnect": "TonConnect", "metaMask": "WalletConnect", "walletConnect": "WalletConnect", "tronLink": "TronLink", "addTronWallet": "Добавить Tron кошелёк", "comingSoon": "Скоро", "connected": "ПОДКЛЮЧЕНО", "disconnect": "Отключить", "chooseWallet": "Выберите кошелёк", "oneWalletPerEnv": "Можно подключить только один кошелёк на окружение.", "connect": "Подключить", "connectTronWallet": "Подключить Tron кошелёк", "connectWallet": "Подключить кошелёк" };
|
|
49
53
|
const bridge = { "max": "Макс", "sourceNetwork": "Исходная сеть", "destinationNetwork": "Целевая сеть", "selectToken": "Выбрать токен", "selectNetwork": "Выбрать сеть", "selectSourceNetwork": "Выбрать исходную сеть", "selectDestinationNetwork": "Выбрать целевую сеть", "searchToken": "Поиск токена", "myTokens": "Мои токены", "allTokens": "Все токены", "search": "Поиск", "select": "Выбрать", "willChangeSourceChain": "Сменит исходную сеть", "willChangeSourceNetworkAndToken": "Сменит исходный токен", "noBalancesFound": "Балансы не найдены.", "noResults": "Нет результатов", "tokenNotFound": "Мы не смогли найти токен с таким названием или символом. Пожалуйста, попробуйте снова.", "chainNotFound": "Мы не смогли найти сеть с таким названием. Пожалуйста, попробуйте снова.", "sendToAnotherAddress": "Отправить на другой адрес", "youWillReceive": "Вы получите", "anotherAddressPlaceholder": "Адрес", "addressDoesntMatch": "Адрес не соответствует сети {{network}}", "checkBeforeTransfer": "Проверьте корректность перед переводом" };
|
|
50
54
|
const transaction = { "enterAmount": "Введите сумму", "transfer": "Перевести", "getQuote": "Получить котировку", "quoting": "Расчет котировки...", "failed": "Ошибка транзакции", "confirm": "Подтвердите транзакцию", "signTransaction": "Подпишите транзакцию в кошельке", "inProgress": "Выполнение...", "checkingBalance": "Проверка баланса...", "insufficientBalance": "Недостаточно средств", "amountTooSmall": "Минимум {{min}}", "amountTooLarge": "Максимум {{max}}", "success": "Успех", "successTitle": "Успех", "done": "Готово", "hashCopied": "Хэш скопирован в буфер обмена", "bridged": "Переведено", "transferTitle": "Перевод", "hash": "Хэш", "finalFee": "Итоговая комиссия", "route": "Маршрут", "estTime": "Время", "slippage": "Проскальзывание", "minimumReceived": "Минимум к получению", "totalFee": "Общая комиссия", "noRouteFound": "Маршрут не найден", "notEnoughGas": "Недостаточно газа", "noRouteFoundForSettings": "Маршрут не найден для текущих настроек.", "tryAdjustSettings": "Попробуйте отключить Gas on Destination или измените сумму/сети.", "quoteError": "Ошибка котировки" };
|
|
55
|
+
const telegram = { "openWebVersion": "Открыть EVAA веб для трансфера", "restrictionMessage": "Трансфер между выбранными сетями доступен только в веб-версии EVAA" };
|
|
51
56
|
const app = { "stargateWidgetName": "Виджет Stargate Bridge", "liveWidget": "Живой виджет", "getStarted": "Начало работы" };
|
|
52
57
|
const settings = { "title": "Настройки", "gasOnDestination": "Газ на назначении", "slippageTolerance": "Толерантность к проскальзыванию", "routePriority": "Приоритет маршрута", "highSlippageWarning": "Высокое проскальзывание", "gasPresets": { "auto": "Авто", "none": "Нет", "medium": "Средний", "max": "Макс" }, "routePresets": { "fastest": "Быстрейший", "cheapest": "Дешевейший", "recommended": "Рекомендуемый" } };
|
|
53
58
|
const errors = { "WALLET_NOT_CONNECTED": "{{chainKey}} кошелёк не подключен", "WALLET_CONNECTION_FAILED": "Не удалось подключить {{chainKey}} кошелёк", "WALLET_NOT_FOUND": "{{chainKey}} кошелёк не найден. Пожалуйста, установите расширение кошелька.", "INVALID_ADDRESS": "Неверный формат {{chainKey}} адреса", "INVALID_STEPS": "Недопустимые шаги транзакции для {{chainKey}}", "INVALID_TRANSACTION_DATA": "Недопустимые данные транзакции для {{chainKey}}", "TRANSACTION_REJECTED": "Транзакция отклонена пользователем", "TRANSACTION_FAILED": "Транзакция не удалась", "TRANSACTION_TIMEOUT": "Время ожидания подтверждения транзакции истекло", "TRANSACTION_REVERTED": "Транзакция отменена в блокчейне", "INSUFFICIENT_GAS": "Недостаточно {{chainKey}} газа", "PROVIDER_NOT_AVAILABLE": "{{chainKey}} провайдер недоступен", "NETWORK_REQUEST_FAILED": "Сетевой запрос не удался", "TRANSACTION_FAILED_TO_COMPLETE": "Транзакция не завершилась", "COMPLETION_TRACKING_FAILED": "Отслеживание завершения не удалось", "UNKNOWN_ERROR": "Произошла неизвестная ошибка" };
|
|
@@ -56,6 +61,7 @@ const ru$1 = {
|
|
|
56
61
|
wallets,
|
|
57
62
|
bridge,
|
|
58
63
|
transaction,
|
|
64
|
+
telegram,
|
|
59
65
|
app,
|
|
60
66
|
settings,
|
|
61
67
|
errors
|
|
@@ -480,11 +486,40 @@ function fromLD(ld, decimals) {
|
|
|
480
486
|
const frac = Number(bi2 % base3) / Number(base3);
|
|
481
487
|
return Number(int) + frac;
|
|
482
488
|
}
|
|
489
|
+
const useTronWalletConnectStore = create(
|
|
490
|
+
(set2) => ({
|
|
491
|
+
address: null,
|
|
492
|
+
isConnected: false,
|
|
493
|
+
isConnecting: false,
|
|
494
|
+
connect: null,
|
|
495
|
+
disconnect: null,
|
|
496
|
+
signTransaction: null,
|
|
497
|
+
setAddress: (address) => set2({
|
|
498
|
+
address,
|
|
499
|
+
isConnected: !!address
|
|
500
|
+
}),
|
|
501
|
+
setIsConnecting: (connecting) => set2({ isConnecting: connecting }),
|
|
502
|
+
setActions: (actions) => set2({
|
|
503
|
+
connect: actions.connect,
|
|
504
|
+
disconnect: actions.disconnect,
|
|
505
|
+
signTransaction: actions.signTransaction
|
|
506
|
+
}),
|
|
507
|
+
reset: () => set2({
|
|
508
|
+
address: null,
|
|
509
|
+
isConnected: false,
|
|
510
|
+
isConnecting: false
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
);
|
|
483
514
|
function useAddresses() {
|
|
484
515
|
const { fromChain, toChain } = useChainsStore();
|
|
485
516
|
const { address: evmAddress } = useAccount();
|
|
486
517
|
const tonAddress = useTonAddress();
|
|
487
|
-
const { address:
|
|
518
|
+
const { address: tronLinkAddress } = useWallet();
|
|
519
|
+
const tronWalletConnectAddress = useTronWalletConnectStore(
|
|
520
|
+
(state2) => state2.address
|
|
521
|
+
);
|
|
522
|
+
const tronAddress = tronLinkAddress || tronWalletConnectAddress || void 0;
|
|
488
523
|
const srcAddress = useMemo(() => {
|
|
489
524
|
if (!fromChain?.chainKey) return void 0;
|
|
490
525
|
const chainKey = fromChain.chainKey.toLowerCase();
|
|
@@ -821,7 +856,14 @@ const isEvmAddress = (addr) => {
|
|
|
821
856
|
return /^0x[0-9a-fA-F]{40}$/.test(addr ?? "");
|
|
822
857
|
};
|
|
823
858
|
const isTronAddress = (addr) => {
|
|
824
|
-
|
|
859
|
+
if (!addr) return false;
|
|
860
|
+
const trimmed = addr.trim();
|
|
861
|
+
if (/^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(trimmed)) {
|
|
862
|
+
return true;
|
|
863
|
+
}
|
|
864
|
+
const normalized = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed.startsWith("41") ? trimmed : "";
|
|
865
|
+
if (!normalized) return false;
|
|
866
|
+
return /^41[0-9a-fA-F]{40}$/.test(normalized);
|
|
825
867
|
};
|
|
826
868
|
const isTonAddress = (addr) => {
|
|
827
869
|
if (!addr) return false;
|
|
@@ -2330,6 +2372,7 @@ const TokenInput = forwardRef(
|
|
|
2330
2372
|
({
|
|
2331
2373
|
value,
|
|
2332
2374
|
onAmountChange,
|
|
2375
|
+
onAmountBlur,
|
|
2333
2376
|
showSkeleton = false,
|
|
2334
2377
|
className,
|
|
2335
2378
|
max,
|
|
@@ -2353,6 +2396,7 @@ const TokenInput = forwardRef(
|
|
|
2353
2396
|
if (showSkeleton && readOnly) {
|
|
2354
2397
|
return /* @__PURE__ */ jsx(Skeleton, { className: cn$2("h-8 my-2 w-1/3 bg-secondary rounded-md", className) });
|
|
2355
2398
|
}
|
|
2399
|
+
const { onBlur: restOnBlur, ...restWithoutOnBlur } = rest;
|
|
2356
2400
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
2357
2401
|
Input,
|
|
2358
2402
|
{
|
|
@@ -2369,7 +2413,11 @@ const TokenInput = forwardRef(
|
|
|
2369
2413
|
className
|
|
2370
2414
|
),
|
|
2371
2415
|
max,
|
|
2372
|
-
...
|
|
2416
|
+
...restWithoutOnBlur,
|
|
2417
|
+
onBlur: (e2) => {
|
|
2418
|
+
restOnBlur?.(e2);
|
|
2419
|
+
onAmountBlur?.();
|
|
2420
|
+
}
|
|
2373
2421
|
}
|
|
2374
2422
|
) });
|
|
2375
2423
|
}
|
|
@@ -2739,7 +2787,8 @@ const SwapSection = ({
|
|
|
2739
2787
|
disableNetworkSelect,
|
|
2740
2788
|
isSource,
|
|
2741
2789
|
onSelect,
|
|
2742
|
-
onAmountChange
|
|
2790
|
+
onAmountChange,
|
|
2791
|
+
onAmountBlur
|
|
2743
2792
|
}) => {
|
|
2744
2793
|
const { isOpen, onClose, onOpen } = useModal();
|
|
2745
2794
|
const { assetMatrix, selectedAssetSymbol } = useTokensStore();
|
|
@@ -2810,6 +2859,7 @@ const SwapSection = ({
|
|
|
2810
2859
|
(v3) => onAmountChange?.(v3),
|
|
2811
2860
|
[onAmountChange]
|
|
2812
2861
|
),
|
|
2862
|
+
onAmountBlur,
|
|
2813
2863
|
readOnly: !!readOnlyAmount,
|
|
2814
2864
|
showSkeleton: status === "loading",
|
|
2815
2865
|
className: "p-0",
|
|
@@ -3391,12 +3441,9 @@ class TransactionRevertedError extends ChainStrategyError {
|
|
|
3391
3441
|
}
|
|
3392
3442
|
}
|
|
3393
3443
|
class ProviderNotAvailableError extends ChainStrategyError {
|
|
3394
|
-
constructor(chainKey) {
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
"PROVIDER_NOT_AVAILABLE",
|
|
3398
|
-
chainKey
|
|
3399
|
-
);
|
|
3444
|
+
constructor(chainKey, reason) {
|
|
3445
|
+
const message = reason ? `${chainKey.toUpperCase()} provider not available: ${reason}` : `${chainKey.toUpperCase()} provider not available`;
|
|
3446
|
+
super(message, "PROVIDER_NOT_AVAILABLE", chainKey);
|
|
3400
3447
|
this.name = "ProviderNotAvailableError";
|
|
3401
3448
|
}
|
|
3402
3449
|
}
|
|
@@ -3715,6 +3762,22 @@ function useSilentValidations(amountString) {
|
|
|
3715
3762
|
]);
|
|
3716
3763
|
return validationResult;
|
|
3717
3764
|
}
|
|
3765
|
+
function useTelegramRestriction() {
|
|
3766
|
+
const { fromChain, toChain } = useChainsStore();
|
|
3767
|
+
const restriction = useMemo(() => {
|
|
3768
|
+
const isTelegramEnv = typeof window !== "undefined" && /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3769
|
+
typeof window.TelegramWebviewProxy?.postEvent === "function";
|
|
3770
|
+
if (!isTelegramEnv) {
|
|
3771
|
+
return { isRestricted: false, isTelegramEnv: false };
|
|
3772
|
+
}
|
|
3773
|
+
const hasTonInvolved = fromChain?.chainKey?.toLowerCase() === "ton" || toChain?.chainKey?.toLowerCase() === "ton";
|
|
3774
|
+
return {
|
|
3775
|
+
isRestricted: !hasTonInvolved,
|
|
3776
|
+
isTelegramEnv: true
|
|
3777
|
+
};
|
|
3778
|
+
}, [fromChain?.chainKey, toChain?.chainKey]);
|
|
3779
|
+
return restriction;
|
|
3780
|
+
}
|
|
3718
3781
|
const MainButton = () => {
|
|
3719
3782
|
const { t: t2 } = useBridgeTranslation();
|
|
3720
3783
|
const { chainRegistry } = useChainStrategies();
|
|
@@ -3731,6 +3794,7 @@ const MainButton = () => {
|
|
|
3731
3794
|
);
|
|
3732
3795
|
const { hasAmountTooLarge, maximumAmountFormatted } = useAmountLimits(amountNum);
|
|
3733
3796
|
const { isValidForTransfer } = useSilentValidations(inputAmount || "");
|
|
3797
|
+
const { isRestricted: isTelegramRestricted } = useTelegramRestriction();
|
|
3734
3798
|
const srcChainKey = quote?.srcChainKey ?? fromChain?.chainKey;
|
|
3735
3799
|
const dstChainKey = quote?.dstChainKey ?? toChain?.chainKey;
|
|
3736
3800
|
const srcConnectedOk = srcChainKey && chainRegistry.isWalletConnected(srcChainKey);
|
|
@@ -3743,6 +3807,8 @@ const MainButton = () => {
|
|
|
3743
3807
|
const canTransfer = !missingSrc && !missingDst && amountNum > 0 && !!srcChainKey && !!dstChainKey;
|
|
3744
3808
|
const label = useMemo(() => {
|
|
3745
3809
|
switch (true) {
|
|
3810
|
+
case isTelegramRestricted:
|
|
3811
|
+
return t2("telegram.openWebVersion");
|
|
3746
3812
|
case status === "loading":
|
|
3747
3813
|
return t2("transaction.quoting");
|
|
3748
3814
|
case isTxProcessing:
|
|
@@ -3774,6 +3840,7 @@ const MainButton = () => {
|
|
|
3774
3840
|
}
|
|
3775
3841
|
}, [
|
|
3776
3842
|
t2,
|
|
3843
|
+
isTelegramRestricted,
|
|
3777
3844
|
status,
|
|
3778
3845
|
isTxProcessing,
|
|
3779
3846
|
isBusy,
|
|
@@ -3793,6 +3860,12 @@ const MainButton = () => {
|
|
|
3793
3860
|
]);
|
|
3794
3861
|
const handleClick = async () => {
|
|
3795
3862
|
if (isBusy) return;
|
|
3863
|
+
if (isTelegramRestricted) {
|
|
3864
|
+
const searchParams = typeof window !== "undefined" ? window.location.search || "" : "";
|
|
3865
|
+
const targetUrl = `https://app.evaa.finance/bridge${searchParams}`;
|
|
3866
|
+
window.open(targetUrl, "_blank", "noopener,noreferrer");
|
|
3867
|
+
return;
|
|
3868
|
+
}
|
|
3796
3869
|
if (missingSrc) {
|
|
3797
3870
|
onOpen("src");
|
|
3798
3871
|
return;
|
|
@@ -3810,51 +3883,26 @@ const MainButton = () => {
|
|
|
3810
3883
|
return;
|
|
3811
3884
|
}
|
|
3812
3885
|
};
|
|
3813
|
-
const disabled = isBusy || status === "loading" || !missingSrc && !missingDst && (amountNum <= 0 || isBalanceLoading || hasInsufficientBalance || hasAmountTooLarge || !gas.hasEnoughGas || noRoute || !isValidForTransfer);
|
|
3814
|
-
return /* @__PURE__ */
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3886
|
+
const disabled = isBusy || status === "loading" || !isTelegramRestricted && !missingSrc && !missingDst && (amountNum <= 0 || isBalanceLoading || hasInsufficientBalance || hasAmountTooLarge || !gas.hasEnoughGas || noRoute || !isValidForTransfer);
|
|
3887
|
+
return /* @__PURE__ */ jsxs("div", { className: "pt-4 space-y-4", children: [
|
|
3888
|
+
isTelegramRestricted && /* @__PURE__ */ jsx(Alert, { variant: "warning", className: "mt-2 text-sm font-medium text-center", children: /* @__PURE__ */ jsx(AlertDescription, { children: t2("telegram.restrictionMessage") }) }),
|
|
3889
|
+
/* @__PURE__ */ jsx(
|
|
3890
|
+
Button,
|
|
3891
|
+
{
|
|
3892
|
+
onClick: handleClick,
|
|
3893
|
+
disabled,
|
|
3894
|
+
size: "lg",
|
|
3895
|
+
className: "w-full",
|
|
3896
|
+
children: label
|
|
3897
|
+
}
|
|
3898
|
+
)
|
|
3899
|
+
] });
|
|
3824
3900
|
};
|
|
3825
|
-
const useTronWalletConnectStore = create(
|
|
3826
|
-
(set2) => ({
|
|
3827
|
-
// State
|
|
3828
|
-
address: null,
|
|
3829
|
-
isConnected: false,
|
|
3830
|
-
isConnecting: false,
|
|
3831
|
-
connect: null,
|
|
3832
|
-
disconnect: null,
|
|
3833
|
-
signTransaction: null,
|
|
3834
|
-
// Actions
|
|
3835
|
-
setAddress: (address) => set2({
|
|
3836
|
-
address,
|
|
3837
|
-
isConnected: !!address
|
|
3838
|
-
}),
|
|
3839
|
-
setIsConnecting: (connecting) => set2({ isConnecting: connecting }),
|
|
3840
|
-
setActions: (actions) => set2({
|
|
3841
|
-
connect: actions.connect,
|
|
3842
|
-
disconnect: actions.disconnect,
|
|
3843
|
-
signTransaction: actions.signTransaction
|
|
3844
|
-
}),
|
|
3845
|
-
reset: () => set2({
|
|
3846
|
-
address: null,
|
|
3847
|
-
isConnected: false,
|
|
3848
|
-
isConnecting: false
|
|
3849
|
-
})
|
|
3850
|
-
})
|
|
3851
|
-
);
|
|
3852
3901
|
const WalletModalButton = (props) => {
|
|
3853
3902
|
const { t: t2 } = useTranslation();
|
|
3854
3903
|
const { icon: IconComponent, name, onClose } = props;
|
|
3855
3904
|
const { chainRegistry } = useChainStrategies();
|
|
3856
3905
|
const { connect, isPending } = useConnect();
|
|
3857
|
-
const { connect: connectTronWC } = useTronWalletConnectStore();
|
|
3858
3906
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
3859
3907
|
if (props.variant === "connected") {
|
|
3860
3908
|
const { address, onDisconnect } = props;
|
|
@@ -3892,15 +3940,13 @@ const WalletModalButton = (props) => {
|
|
|
3892
3940
|
try {
|
|
3893
3941
|
if (connector) {
|
|
3894
3942
|
connect({ connector });
|
|
3895
|
-
} else if (walletId === "
|
|
3896
|
-
|
|
3897
|
-
await connectTronWC();
|
|
3898
|
-
}
|
|
3899
|
-
} else {
|
|
3900
|
-
const strategy = chainRegistry.getStrategyByType(
|
|
3901
|
-
walletId === "ton" ? "ton" : "tron"
|
|
3902
|
-
);
|
|
3943
|
+
} else if (walletId === "ton") {
|
|
3944
|
+
const strategy = chainRegistry.getStrategyByType("ton");
|
|
3903
3945
|
await strategy?.connect();
|
|
3946
|
+
} else {
|
|
3947
|
+
const strategy = chainRegistry.getStrategyByType("tron");
|
|
3948
|
+
const provider = walletId === "tronwc" ? "walletconnect" : "tronlink";
|
|
3949
|
+
await strategy?.connect({ provider });
|
|
3904
3950
|
}
|
|
3905
3951
|
onClose?.();
|
|
3906
3952
|
} catch (error) {
|
|
@@ -3943,7 +3989,10 @@ const WalletSelectModal = () => {
|
|
|
3943
3989
|
const tonWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.TON);
|
|
3944
3990
|
const metaMaskWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.EVM);
|
|
3945
3991
|
const tronWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.TRON);
|
|
3946
|
-
const
|
|
3992
|
+
const tronConnections = tronWallet?.getAvailableConnections() ?? [];
|
|
3993
|
+
const isTronWalletConnectConnected = tronConnections.some(
|
|
3994
|
+
(conn) => conn.connected && conn.provider === "walletconnect"
|
|
3995
|
+
);
|
|
3947
3996
|
const walletConfigs = [
|
|
3948
3997
|
{
|
|
3949
3998
|
strategy: tonWallet,
|
|
@@ -3956,12 +4005,6 @@ const WalletSelectModal = () => {
|
|
|
3956
4005
|
walletId: "metamask",
|
|
3957
4006
|
name: t2("wallets.metaMask"),
|
|
3958
4007
|
icon: MetaMaskIcon
|
|
3959
|
-
},
|
|
3960
|
-
{
|
|
3961
|
-
strategy: tronWallet,
|
|
3962
|
-
walletId: "tronlink",
|
|
3963
|
-
name: t2("wallets.tronLink"),
|
|
3964
|
-
icon: TronLinkIcon
|
|
3965
4008
|
}
|
|
3966
4009
|
];
|
|
3967
4010
|
const connectedWallets = walletConfigs.reduce((acc, { strategy, walletId, name, icon }) => {
|
|
@@ -3977,21 +4020,25 @@ const WalletSelectModal = () => {
|
|
|
3977
4020
|
}
|
|
3978
4021
|
return acc;
|
|
3979
4022
|
}, []);
|
|
3980
|
-
|
|
4023
|
+
tronConnections.forEach((connection) => {
|
|
4024
|
+
if (!connection.connected || !connection.address) return;
|
|
4025
|
+
const isWalletConnect = connection.provider === "walletconnect";
|
|
3981
4026
|
connectedWallets.push({
|
|
3982
|
-
id: "tronwc",
|
|
3983
|
-
name: t2("wallets.walletConnect"),
|
|
3984
|
-
icon: WalletConnectIcon,
|
|
3985
|
-
address:
|
|
3986
|
-
onDisconnect: () =>
|
|
4027
|
+
id: isWalletConnect ? "tronwc" : "tronlink",
|
|
4028
|
+
name: isWalletConnect ? t2("wallets.walletConnect") : t2("wallets.tronLink"),
|
|
4029
|
+
icon: isWalletConnect ? WalletConnectIcon : TronLinkIcon,
|
|
4030
|
+
address: connection.address,
|
|
4031
|
+
onDisconnect: () => tronWallet?.disconnect({ provider: connection.provider })
|
|
3987
4032
|
});
|
|
3988
|
-
}
|
|
4033
|
+
});
|
|
3989
4034
|
const isWalletConnected = (walletId) => {
|
|
3990
4035
|
const isEvmConnector = connectors.some((c2) => c2.id === walletId);
|
|
3991
4036
|
if (isEvmConnector && metaMaskWallet?.isConnected()) {
|
|
3992
4037
|
return true;
|
|
3993
4038
|
}
|
|
3994
|
-
if (walletId === "tronwc"
|
|
4039
|
+
if ((walletId === "tronwc" || walletId === "tronlink") && tronConnections.some(
|
|
4040
|
+
(conn) => conn.connected && (walletId === "tronwc" ? conn.provider === "walletconnect" : conn.provider !== "walletconnect")
|
|
4041
|
+
)) {
|
|
3995
4042
|
return true;
|
|
3996
4043
|
}
|
|
3997
4044
|
return connectedWallets.some((w2) => w2.id === walletId);
|
|
@@ -4025,7 +4072,12 @@ const WalletSelectModal = () => {
|
|
|
4025
4072
|
icon: WalletConnectIcon,
|
|
4026
4073
|
enabled: true
|
|
4027
4074
|
}
|
|
4028
|
-
]
|
|
4075
|
+
].filter((wallet) => {
|
|
4076
|
+
if (wallet.id === "tronlink" && isTronWalletConnectConnected) {
|
|
4077
|
+
return false;
|
|
4078
|
+
}
|
|
4079
|
+
return true;
|
|
4080
|
+
});
|
|
4029
4081
|
const notConnected = (w2) => !isWalletConnected(w2.id);
|
|
4030
4082
|
const categories = [
|
|
4031
4083
|
{
|
|
@@ -4426,19 +4478,19 @@ class ChainStrategyRegistry {
|
|
|
4426
4478
|
if (!strategy) return t2("wallets.connectWallet");
|
|
4427
4479
|
return strategy.getConnectLabel(t2);
|
|
4428
4480
|
}
|
|
4429
|
-
async connectWallet(chainKey) {
|
|
4481
|
+
async connectWallet(chainKey, options) {
|
|
4430
4482
|
const strategy = this.getStrategy(chainKey);
|
|
4431
4483
|
if (!strategy) {
|
|
4432
4484
|
throw new Error(`No strategy available for chain: ${chainKey}`);
|
|
4433
4485
|
}
|
|
4434
|
-
await strategy.connect();
|
|
4486
|
+
await strategy.connect(options);
|
|
4435
4487
|
}
|
|
4436
|
-
async disconnectWallet(chainKey) {
|
|
4488
|
+
async disconnectWallet(chainKey, options) {
|
|
4437
4489
|
const strategy = this.getStrategy(chainKey);
|
|
4438
4490
|
if (!strategy) {
|
|
4439
4491
|
throw new Error(`No strategy available for chain: ${chainKey}`);
|
|
4440
4492
|
}
|
|
4441
|
-
await strategy.disconnect();
|
|
4493
|
+
await strategy.disconnect(options);
|
|
4442
4494
|
}
|
|
4443
4495
|
}
|
|
4444
4496
|
function isNativeAddress(addr) {
|
|
@@ -4776,6 +4828,16 @@ class EvmChainStrategy {
|
|
|
4776
4828
|
if (!address) return false;
|
|
4777
4829
|
return /^0x[0-9a-fA-F]{40}$/.test(address);
|
|
4778
4830
|
}
|
|
4831
|
+
getAvailableConnections() {
|
|
4832
|
+
return [
|
|
4833
|
+
{
|
|
4834
|
+
provider: "evm",
|
|
4835
|
+
address: this.config.evmAddress || null,
|
|
4836
|
+
connected: this.config.evmIsConnected,
|
|
4837
|
+
isConnecting: false
|
|
4838
|
+
}
|
|
4839
|
+
];
|
|
4840
|
+
}
|
|
4779
4841
|
validateSteps(steps) {
|
|
4780
4842
|
if (!steps || steps.length === 0) {
|
|
4781
4843
|
throw new InvalidStepsError("evm", "No transaction steps provided");
|
|
@@ -5166,6 +5228,16 @@ class TonChainStrategy {
|
|
|
5166
5228
|
if (!address) return false;
|
|
5167
5229
|
return true;
|
|
5168
5230
|
}
|
|
5231
|
+
getAvailableConnections() {
|
|
5232
|
+
return [
|
|
5233
|
+
{
|
|
5234
|
+
provider: "tonconnect",
|
|
5235
|
+
address: this.config.tonAddress || null,
|
|
5236
|
+
connected: !!this.config.tonAddress,
|
|
5237
|
+
isConnecting: false
|
|
5238
|
+
}
|
|
5239
|
+
];
|
|
5240
|
+
}
|
|
5169
5241
|
validateSteps(steps) {
|
|
5170
5242
|
if (!steps || steps.length === 0) {
|
|
5171
5243
|
throw new InvalidStepsError("ton", "No transaction steps provided");
|
|
@@ -5366,9 +5438,11 @@ class TonChainStrategy {
|
|
|
5366
5438
|
}
|
|
5367
5439
|
}
|
|
5368
5440
|
}
|
|
5441
|
+
const DEFAULT_TRON_NODE = "https://api.trongrid.io";
|
|
5369
5442
|
class TronChainStrategy {
|
|
5370
5443
|
constructor(config) {
|
|
5371
5444
|
__publicField(this, "config");
|
|
5445
|
+
__publicField(this, "fallbackClient");
|
|
5372
5446
|
this.config = config;
|
|
5373
5447
|
}
|
|
5374
5448
|
canHandle(chainKey) {
|
|
@@ -5380,7 +5454,19 @@ class TronChainStrategy {
|
|
|
5380
5454
|
getName() {
|
|
5381
5455
|
return "TRON Chain Strategy";
|
|
5382
5456
|
}
|
|
5383
|
-
async connect() {
|
|
5457
|
+
async connect(options) {
|
|
5458
|
+
const provider = this.resolveProvider(options?.provider);
|
|
5459
|
+
if (provider === "walletconnect") {
|
|
5460
|
+
const walletConnect = this.config.walletConnect;
|
|
5461
|
+
if (!walletConnect?.connect) {
|
|
5462
|
+
throw new ProviderNotAvailableError(
|
|
5463
|
+
"tron",
|
|
5464
|
+
"WalletConnect is not configured for TRON"
|
|
5465
|
+
);
|
|
5466
|
+
}
|
|
5467
|
+
await walletConnect.connect();
|
|
5468
|
+
return;
|
|
5469
|
+
}
|
|
5384
5470
|
if (!this.isTronLinkInstalled()) {
|
|
5385
5471
|
if (typeof window !== "undefined") {
|
|
5386
5472
|
window.open("https://www.tronlink.org/", "_blank");
|
|
@@ -5390,21 +5476,83 @@ class TronChainStrategy {
|
|
|
5390
5476
|
"TronLink wallet is not installed. Please install TronLink extension and try again."
|
|
5391
5477
|
);
|
|
5392
5478
|
}
|
|
5393
|
-
this.config.
|
|
5479
|
+
this.config.tronLink.select(TronLinkAdapterName);
|
|
5394
5480
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
5395
|
-
await this.config.
|
|
5481
|
+
await this.config.tronLink.connect();
|
|
5396
5482
|
}
|
|
5397
|
-
async disconnect() {
|
|
5398
|
-
|
|
5483
|
+
async disconnect(options) {
|
|
5484
|
+
const provider = options?.provider !== void 0 ? this.resolveProvider(options.provider) : this.getActiveConnector()?.provider ?? "tronlink";
|
|
5485
|
+
if (provider === "walletconnect") {
|
|
5486
|
+
const walletConnect = this.config.walletConnect;
|
|
5487
|
+
if (walletConnect?.disconnect) {
|
|
5488
|
+
await walletConnect.disconnect();
|
|
5489
|
+
}
|
|
5490
|
+
return;
|
|
5491
|
+
}
|
|
5492
|
+
await this.config.tronLink.disconnect();
|
|
5399
5493
|
}
|
|
5400
5494
|
isConnected() {
|
|
5401
|
-
return !!this.
|
|
5495
|
+
return !!this.getActiveConnector();
|
|
5402
5496
|
}
|
|
5403
5497
|
isConnecting() {
|
|
5404
|
-
return
|
|
5498
|
+
return !!this.config.walletConnect?.connecting;
|
|
5405
5499
|
}
|
|
5406
5500
|
getAccount() {
|
|
5407
|
-
return this.
|
|
5501
|
+
return this.getActiveConnector()?.address || null;
|
|
5502
|
+
}
|
|
5503
|
+
getAvailableConnections() {
|
|
5504
|
+
const connections = [
|
|
5505
|
+
this.getConnectorState("tronlink")
|
|
5506
|
+
];
|
|
5507
|
+
if (this.config.walletConnect) {
|
|
5508
|
+
connections.push(this.getConnectorState("walletconnect"));
|
|
5509
|
+
}
|
|
5510
|
+
return connections;
|
|
5511
|
+
}
|
|
5512
|
+
getActiveConnector() {
|
|
5513
|
+
const walletConnect = this.config.walletConnect && this.getConnectorState("walletconnect");
|
|
5514
|
+
if (walletConnect && walletConnect.connected && !!walletConnect.address) {
|
|
5515
|
+
return walletConnect;
|
|
5516
|
+
}
|
|
5517
|
+
const tronLink = this.getConnectorState("tronlink");
|
|
5518
|
+
if (tronLink.connected && !!tronLink.address) {
|
|
5519
|
+
return tronLink;
|
|
5520
|
+
}
|
|
5521
|
+
return null;
|
|
5522
|
+
}
|
|
5523
|
+
getConnectorState(provider) {
|
|
5524
|
+
if (provider === "walletconnect") {
|
|
5525
|
+
const walletConnect = this.config.walletConnect;
|
|
5526
|
+
return {
|
|
5527
|
+
provider: "walletconnect",
|
|
5528
|
+
address: walletConnect?.address ?? null,
|
|
5529
|
+
connected: !!walletConnect?.connected,
|
|
5530
|
+
isConnecting: !!walletConnect?.connecting,
|
|
5531
|
+
connect: walletConnect?.connect,
|
|
5532
|
+
disconnect: walletConnect?.disconnect,
|
|
5533
|
+
signTransaction: walletConnect?.signTransaction
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
const tronLink = this.config.tronLink;
|
|
5537
|
+
return {
|
|
5538
|
+
provider: "tronlink",
|
|
5539
|
+
address: tronLink.address ?? null,
|
|
5540
|
+
connected: !!tronLink.connected,
|
|
5541
|
+
isConnecting: false,
|
|
5542
|
+
connect: tronLink.connect,
|
|
5543
|
+
disconnect: tronLink.disconnect,
|
|
5544
|
+
select: tronLink.select
|
|
5545
|
+
};
|
|
5546
|
+
}
|
|
5547
|
+
resolveProvider(provider) {
|
|
5548
|
+
if (!provider) {
|
|
5549
|
+
return "tronlink";
|
|
5550
|
+
}
|
|
5551
|
+
const normalized = typeof provider === "string" ? provider.toLowerCase() : provider;
|
|
5552
|
+
if (normalized === "walletconnect" || normalized === "tronwc") {
|
|
5553
|
+
return "walletconnect";
|
|
5554
|
+
}
|
|
5555
|
+
return "tronlink";
|
|
5408
5556
|
}
|
|
5409
5557
|
getError() {
|
|
5410
5558
|
return null;
|
|
@@ -5422,7 +5570,7 @@ class TronChainStrategy {
|
|
|
5422
5570
|
}
|
|
5423
5571
|
isAddressValid(address) {
|
|
5424
5572
|
if (!address) return false;
|
|
5425
|
-
return
|
|
5573
|
+
return isTronAddress(address);
|
|
5426
5574
|
}
|
|
5427
5575
|
validateSteps(steps) {
|
|
5428
5576
|
console.log("validateSteps");
|
|
@@ -5444,14 +5592,13 @@ class TronChainStrategy {
|
|
|
5444
5592
|
if (!tronWeb) {
|
|
5445
5593
|
throw new ProviderNotAvailableError("tron");
|
|
5446
5594
|
}
|
|
5447
|
-
|
|
5595
|
+
const connector = this.getActiveConnector();
|
|
5596
|
+
if (!connector?.connected || !connector.address) {
|
|
5448
5597
|
throw new WalletNotConnectedError("tron");
|
|
5449
5598
|
}
|
|
5450
5599
|
this.validateSteps(steps);
|
|
5451
|
-
const fromB58 =
|
|
5452
|
-
|
|
5453
|
-
throw new WalletNotConnectedError("tron");
|
|
5454
|
-
}
|
|
5600
|
+
const fromB58 = connector.address;
|
|
5601
|
+
this.ensureDefaultAddress(tronWeb, fromB58);
|
|
5455
5602
|
let lastTxId;
|
|
5456
5603
|
let isFirstHash = true;
|
|
5457
5604
|
for (const step of steps) {
|
|
@@ -5517,7 +5664,7 @@ class TronChainStrategy {
|
|
|
5517
5664
|
"Unsupported TRON parsed tx kind"
|
|
5518
5665
|
);
|
|
5519
5666
|
}
|
|
5520
|
-
const { txid } = await this.signAndBroadcast(tronWeb, unsigned);
|
|
5667
|
+
const { txid } = await this.signAndBroadcast(tronWeb, unsigned, connector);
|
|
5521
5668
|
lastTxId = txid;
|
|
5522
5669
|
if (isFirstHash) {
|
|
5523
5670
|
onFirstHash?.(txid);
|
|
@@ -5640,7 +5787,26 @@ class TronChainStrategy {
|
|
|
5640
5787
|
}
|
|
5641
5788
|
}
|
|
5642
5789
|
getClient() {
|
|
5643
|
-
|
|
5790
|
+
if (typeof window !== "undefined" && window.tronWeb) {
|
|
5791
|
+
return window.tronWeb;
|
|
5792
|
+
}
|
|
5793
|
+
if (!this.fallbackClient) {
|
|
5794
|
+
this.fallbackClient = this.createFallbackClient();
|
|
5795
|
+
}
|
|
5796
|
+
return this.fallbackClient;
|
|
5797
|
+
}
|
|
5798
|
+
createFallbackClient() {
|
|
5799
|
+
try {
|
|
5800
|
+
const tronWeb = new TronWeb(
|
|
5801
|
+
DEFAULT_TRON_NODE,
|
|
5802
|
+
DEFAULT_TRON_NODE,
|
|
5803
|
+
DEFAULT_TRON_NODE
|
|
5804
|
+
);
|
|
5805
|
+
return tronWeb;
|
|
5806
|
+
} catch (error) {
|
|
5807
|
+
console.warn("Failed to create fallback TronWeb client", error);
|
|
5808
|
+
return void 0;
|
|
5809
|
+
}
|
|
5644
5810
|
}
|
|
5645
5811
|
/**
|
|
5646
5812
|
* Check if TronLink wallet is actually installed
|
|
@@ -5659,6 +5825,21 @@ class TronChainStrategy {
|
|
|
5659
5825
|
}
|
|
5660
5826
|
return true;
|
|
5661
5827
|
}
|
|
5828
|
+
ensureDefaultAddress(tronWeb, address) {
|
|
5829
|
+
if (!address) return;
|
|
5830
|
+
try {
|
|
5831
|
+
const hex = tronWeb.address.toHex(address);
|
|
5832
|
+
const current = tronWeb.defaultAddress || {};
|
|
5833
|
+
if (current.base58 !== address) {
|
|
5834
|
+
tronWeb.defaultAddress = {
|
|
5835
|
+
base58: address,
|
|
5836
|
+
hex
|
|
5837
|
+
};
|
|
5838
|
+
}
|
|
5839
|
+
} catch (error) {
|
|
5840
|
+
console.debug("Failed to set TronWeb default address:", error);
|
|
5841
|
+
}
|
|
5842
|
+
}
|
|
5662
5843
|
hexToAscii(h4) {
|
|
5663
5844
|
if (!h4) return null;
|
|
5664
5845
|
const clean2 = h4.replace(/^0x/, "");
|
|
@@ -5932,9 +6113,20 @@ class TronChainStrategy {
|
|
|
5932
6113
|
}
|
|
5933
6114
|
return res.transaction;
|
|
5934
6115
|
}
|
|
5935
|
-
async signAndBroadcast(tronWeb, unsignedTx) {
|
|
5936
|
-
|
|
5937
|
-
|
|
6116
|
+
async signAndBroadcast(tronWeb, unsignedTx, connector) {
|
|
6117
|
+
let signedTx;
|
|
6118
|
+
if (connector.provider === "walletconnect") {
|
|
6119
|
+
if (!connector.signTransaction) {
|
|
6120
|
+
throw new ProviderNotAvailableError(
|
|
6121
|
+
"tron",
|
|
6122
|
+
"WalletConnect signing is unavailable"
|
|
6123
|
+
);
|
|
6124
|
+
}
|
|
6125
|
+
signedTx = await connector.signTransaction(unsignedTx);
|
|
6126
|
+
} else {
|
|
6127
|
+
signedTx = await tronWeb.trx.sign(unsignedTx);
|
|
6128
|
+
}
|
|
6129
|
+
const sent = await tronWeb.trx.sendRawTransaction(signedTx);
|
|
5938
6130
|
if (!sent?.result || !sent?.txid) {
|
|
5939
6131
|
throw new TransactionFailedError(
|
|
5940
6132
|
"tron",
|
|
@@ -6017,18 +6209,29 @@ function ChainStrategyProvider({
|
|
|
6017
6209
|
);
|
|
6018
6210
|
const tronStrategy = useMemo(
|
|
6019
6211
|
() => new TronChainStrategy({
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6212
|
+
tronLink: {
|
|
6213
|
+
address: tronWallet.tronLink.address,
|
|
6214
|
+
connected: tronWallet.tronLink.connected,
|
|
6215
|
+
select: tronWallet.tronLink.select,
|
|
6216
|
+
connect: tronWallet.tronLink.connect,
|
|
6217
|
+
disconnect: tronWallet.tronLink.disconnect
|
|
6218
|
+
},
|
|
6219
|
+
walletConnect: tronWallet.walletConnect ? {
|
|
6220
|
+
address: tronWallet.walletConnect.address,
|
|
6221
|
+
connected: tronWallet.walletConnect.connected,
|
|
6222
|
+
connecting: tronWallet.walletConnect.connecting,
|
|
6223
|
+
connect: tronWallet.walletConnect.connect,
|
|
6224
|
+
disconnect: tronWallet.walletConnect.disconnect,
|
|
6225
|
+
signTransaction: tronWallet.walletConnect.signTransaction
|
|
6226
|
+
} : void 0
|
|
6025
6227
|
}),
|
|
6026
6228
|
[
|
|
6027
|
-
tronWallet.address,
|
|
6028
|
-
tronWallet.connected,
|
|
6029
|
-
tronWallet.select,
|
|
6030
|
-
tronWallet.connect,
|
|
6031
|
-
tronWallet.disconnect
|
|
6229
|
+
tronWallet.tronLink.address,
|
|
6230
|
+
tronWallet.tronLink.connected,
|
|
6231
|
+
tronWallet.tronLink.select,
|
|
6232
|
+
tronWallet.tronLink.connect,
|
|
6233
|
+
tronWallet.tronLink.disconnect,
|
|
6234
|
+
tronWallet.walletConnect
|
|
6032
6235
|
]
|
|
6033
6236
|
);
|
|
6034
6237
|
const chainRegistry = useMemo(
|
|
@@ -25605,7 +25808,7 @@ class WalletConnectModal {
|
|
|
25605
25808
|
}
|
|
25606
25809
|
async initUi() {
|
|
25607
25810
|
if (typeof window !== "undefined") {
|
|
25608
|
-
await import("./index-
|
|
25811
|
+
await import("./index-Bj6AJLyW.js");
|
|
25609
25812
|
const modal = document.createElement("wcm-modal");
|
|
25610
25813
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25611
25814
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -25653,14 +25856,10 @@ const TRON_MAINNET_CHAIN_ID = "tron:0x2b6653dc";
|
|
|
25653
25856
|
function useTronWalletConnect(projectId) {
|
|
25654
25857
|
const { address, isConnected, isConnecting } = useTronWalletConnectStore();
|
|
25655
25858
|
const { setAddress, setIsConnecting, setActions, reset } = useTronWalletConnectStore();
|
|
25656
|
-
const { setTronConnected } = useConnectedWalletsStore();
|
|
25657
25859
|
const providerRef = useRef(null);
|
|
25658
25860
|
const modalRef = useRef(null);
|
|
25659
25861
|
const { onClose: closeWalletSelectModal } = useWalletSelectModal();
|
|
25660
25862
|
const appliedTheme = useThemeStore((state2) => state2.appliedTheme);
|
|
25661
|
-
useEffect(() => {
|
|
25662
|
-
setTronConnected(isConnected);
|
|
25663
|
-
}, [isConnected, setTronConnected]);
|
|
25664
25863
|
useEffect(() => {
|
|
25665
25864
|
if (!projectId || providerRef.current) return;
|
|
25666
25865
|
const initProvider = async () => {
|
|
@@ -25832,6 +26031,194 @@ function useTronWalletConnect(projectId) {
|
|
|
25832
26031
|
signTransaction
|
|
25833
26032
|
};
|
|
25834
26033
|
}
|
|
26034
|
+
function parseBridgeUrlParams(source) {
|
|
26035
|
+
if (source && typeof source === "object") {
|
|
26036
|
+
return source;
|
|
26037
|
+
}
|
|
26038
|
+
const queryString = typeof source === "string" ? source : typeof window !== "undefined" ? window.location.search : "";
|
|
26039
|
+
const searchParams = new URLSearchParams(queryString);
|
|
26040
|
+
return {
|
|
26041
|
+
srcToken: searchParams.get("srcToken") || void 0,
|
|
26042
|
+
srcChain: searchParams.get("srcChain") || void 0,
|
|
26043
|
+
dstChain: searchParams.get("dstChain") || void 0,
|
|
26044
|
+
amount: searchParams.get("amount") || void 0
|
|
26045
|
+
};
|
|
26046
|
+
}
|
|
26047
|
+
function buildQueryString(params) {
|
|
26048
|
+
const searchParams = new URLSearchParams();
|
|
26049
|
+
if (params.srcToken) searchParams.set("srcToken", params.srcToken);
|
|
26050
|
+
if (params.srcChain) searchParams.set("srcChain", params.srcChain);
|
|
26051
|
+
if (params.dstChain) searchParams.set("dstChain", params.dstChain);
|
|
26052
|
+
if (params.amount) searchParams.set("amount", params.amount);
|
|
26053
|
+
const queryString = searchParams.toString();
|
|
26054
|
+
return queryString ? `?${queryString}` : "";
|
|
26055
|
+
}
|
|
26056
|
+
function updateBridgeUrlNative(params) {
|
|
26057
|
+
if (typeof window === "undefined" || !window.history) return;
|
|
26058
|
+
const queryString = buildQueryString(params);
|
|
26059
|
+
const newUrl = `${window.location.pathname}${queryString}${window.location.hash}`;
|
|
26060
|
+
window.history.replaceState(null, "", newUrl);
|
|
26061
|
+
}
|
|
26062
|
+
function useUrlSync(options) {
|
|
26063
|
+
const {
|
|
26064
|
+
enabled = true,
|
|
26065
|
+
urlParams: externalUrlParams,
|
|
26066
|
+
onUrlParamsChange
|
|
26067
|
+
} = options || {};
|
|
26068
|
+
const { chains, fromChain, toChain, setFromChain, setToChain } = useChainsStore();
|
|
26069
|
+
const { tokens, assetMatrix, selectedAssetSymbol, setSelectedAssetSymbol } = useTokensStore();
|
|
26070
|
+
const { inputAmount, setInputAmount } = useBridgeQuoteStore();
|
|
26071
|
+
const [hasInitialized, setHasInitialized] = useState(false);
|
|
26072
|
+
const isSyncingRef = useRef(false);
|
|
26073
|
+
const lastSyncedParamsRef = useRef({});
|
|
26074
|
+
const validateParams = useCallback(
|
|
26075
|
+
(urlParams) => {
|
|
26076
|
+
const result = {};
|
|
26077
|
+
if (!chains?.length || !tokens?.length || !assetMatrix) {
|
|
26078
|
+
return result;
|
|
26079
|
+
}
|
|
26080
|
+
if (urlParams.srcToken) {
|
|
26081
|
+
const token = tokens.find(
|
|
26082
|
+
(t2) => t2.symbol.toUpperCase() === urlParams.srcToken?.toUpperCase()
|
|
26083
|
+
);
|
|
26084
|
+
if (token) {
|
|
26085
|
+
result.token = token;
|
|
26086
|
+
}
|
|
26087
|
+
}
|
|
26088
|
+
if (urlParams.srcChain) {
|
|
26089
|
+
const chain2 = chains.find((c2) => c2.chainKey === urlParams.srcChain);
|
|
26090
|
+
if (chain2) {
|
|
26091
|
+
if (result.token) {
|
|
26092
|
+
const tokenOnChain = assetMatrix[result.token.symbol.toUpperCase()]?.[chain2.chainKey];
|
|
26093
|
+
if (tokenOnChain) {
|
|
26094
|
+
result.srcChain = chain2;
|
|
26095
|
+
}
|
|
26096
|
+
} else {
|
|
26097
|
+
result.srcChain = chain2;
|
|
26098
|
+
}
|
|
26099
|
+
}
|
|
26100
|
+
}
|
|
26101
|
+
if (urlParams.dstChain) {
|
|
26102
|
+
const chain2 = chains.find((c2) => c2.chainKey === urlParams.dstChain);
|
|
26103
|
+
if (chain2 && chain2.chainKey !== result.srcChain?.chainKey) {
|
|
26104
|
+
if (result.token) {
|
|
26105
|
+
const tokenOnChain = assetMatrix[result.token.symbol.toUpperCase()]?.[chain2.chainKey];
|
|
26106
|
+
if (tokenOnChain) {
|
|
26107
|
+
result.dstChain = chain2;
|
|
26108
|
+
}
|
|
26109
|
+
} else {
|
|
26110
|
+
result.dstChain = chain2;
|
|
26111
|
+
}
|
|
26112
|
+
}
|
|
26113
|
+
}
|
|
26114
|
+
if (urlParams.amount) {
|
|
26115
|
+
const decimalRegex = /^(\d+([.]\d*)?|[.]\d+)?$/;
|
|
26116
|
+
if (decimalRegex.test(urlParams.amount)) {
|
|
26117
|
+
const numValue = parseFloat(urlParams.amount);
|
|
26118
|
+
if (!isNaN(numValue) && numValue > 0) {
|
|
26119
|
+
result.amount = urlParams.amount;
|
|
26120
|
+
}
|
|
26121
|
+
}
|
|
26122
|
+
}
|
|
26123
|
+
return result;
|
|
26124
|
+
},
|
|
26125
|
+
[chains, tokens, assetMatrix]
|
|
26126
|
+
);
|
|
26127
|
+
const syncStateToUrl = useCallback(
|
|
26128
|
+
(includeAmount = false) => {
|
|
26129
|
+
if (!enabled || isSyncingRef.current || !hasInitialized) {
|
|
26130
|
+
return;
|
|
26131
|
+
}
|
|
26132
|
+
isSyncingRef.current = true;
|
|
26133
|
+
const normalizedAmount = inputAmount?.trim();
|
|
26134
|
+
const params = {
|
|
26135
|
+
srcToken: selectedAssetSymbol || void 0,
|
|
26136
|
+
srcChain: fromChain?.chainKey,
|
|
26137
|
+
dstChain: toChain?.chainKey,
|
|
26138
|
+
amount: includeAmount ? normalizedAmount || void 0 : lastSyncedParamsRef.current.amount
|
|
26139
|
+
};
|
|
26140
|
+
lastSyncedParamsRef.current = params;
|
|
26141
|
+
if (onUrlParamsChange) {
|
|
26142
|
+
onUrlParamsChange(params);
|
|
26143
|
+
} else {
|
|
26144
|
+
updateBridgeUrlNative(params);
|
|
26145
|
+
}
|
|
26146
|
+
setTimeout(() => {
|
|
26147
|
+
isSyncingRef.current = false;
|
|
26148
|
+
}, 0);
|
|
26149
|
+
},
|
|
26150
|
+
[
|
|
26151
|
+
enabled,
|
|
26152
|
+
hasInitialized,
|
|
26153
|
+
selectedAssetSymbol,
|
|
26154
|
+
fromChain,
|
|
26155
|
+
toChain,
|
|
26156
|
+
inputAmount,
|
|
26157
|
+
onUrlParamsChange
|
|
26158
|
+
]
|
|
26159
|
+
);
|
|
26160
|
+
const handleAmountBlur = useCallback(() => {
|
|
26161
|
+
if (!enabled || !hasInitialized) return;
|
|
26162
|
+
syncStateToUrl(true);
|
|
26163
|
+
}, [enabled, hasInitialized, syncStateToUrl]);
|
|
26164
|
+
useEffect(() => {
|
|
26165
|
+
if (!enabled || !chains?.length || !tokens?.length) {
|
|
26166
|
+
return;
|
|
26167
|
+
}
|
|
26168
|
+
const urlParams = externalUrlParams ? parseBridgeUrlParams(externalUrlParams) : parseBridgeUrlParams();
|
|
26169
|
+
if (!urlParams.srcToken && !urlParams.srcChain && !urlParams.dstChain && !urlParams.amount) {
|
|
26170
|
+
setHasInitialized(true);
|
|
26171
|
+
return;
|
|
26172
|
+
}
|
|
26173
|
+
const validated = validateParams(urlParams);
|
|
26174
|
+
const timeoutId = setTimeout(() => {
|
|
26175
|
+
if (validated.token) {
|
|
26176
|
+
setSelectedAssetSymbol(validated.token.symbol);
|
|
26177
|
+
}
|
|
26178
|
+
if (validated.srcChain) {
|
|
26179
|
+
setFromChain(validated.srcChain);
|
|
26180
|
+
}
|
|
26181
|
+
if (validated.dstChain) {
|
|
26182
|
+
setToChain(validated.dstChain);
|
|
26183
|
+
}
|
|
26184
|
+
if (validated.amount) {
|
|
26185
|
+
setInputAmount(validated.amount);
|
|
26186
|
+
}
|
|
26187
|
+
lastSyncedParamsRef.current = {
|
|
26188
|
+
srcToken: validated.token?.symbol || void 0,
|
|
26189
|
+
srcChain: validated.srcChain?.chainKey,
|
|
26190
|
+
dstChain: validated.dstChain?.chainKey,
|
|
26191
|
+
amount: validated.amount
|
|
26192
|
+
};
|
|
26193
|
+
setHasInitialized(true);
|
|
26194
|
+
}, 0);
|
|
26195
|
+
return () => clearTimeout(timeoutId);
|
|
26196
|
+
}, [
|
|
26197
|
+
enabled,
|
|
26198
|
+
chains,
|
|
26199
|
+
tokens,
|
|
26200
|
+
externalUrlParams,
|
|
26201
|
+
validateParams,
|
|
26202
|
+
setSelectedAssetSymbol,
|
|
26203
|
+
setFromChain,
|
|
26204
|
+
setToChain,
|
|
26205
|
+
setInputAmount
|
|
26206
|
+
]);
|
|
26207
|
+
useEffect(() => {
|
|
26208
|
+
if (!enabled || !hasInitialized) return;
|
|
26209
|
+
syncStateToUrl(false);
|
|
26210
|
+
}, [
|
|
26211
|
+
enabled,
|
|
26212
|
+
hasInitialized,
|
|
26213
|
+
fromChain?.chainKey,
|
|
26214
|
+
toChain?.chainKey,
|
|
26215
|
+
selectedAssetSymbol,
|
|
26216
|
+
syncStateToUrl
|
|
26217
|
+
]);
|
|
26218
|
+
return {
|
|
26219
|
+
handleAmountBlur
|
|
26220
|
+
};
|
|
26221
|
+
}
|
|
25835
26222
|
const EvaaBridgeWithProviders = (props) => {
|
|
25836
26223
|
const [tonConnectUI] = useTonConnectUI();
|
|
25837
26224
|
const tonAddress = useTonAddress();
|
|
@@ -25846,7 +26233,7 @@ const EvaaBridgeWithProviders = (props) => {
|
|
|
25846
26233
|
connect: tronConnect,
|
|
25847
26234
|
disconnect: tronDisconnect
|
|
25848
26235
|
} = useWallet();
|
|
25849
|
-
useTronWalletConnect(props.walletConnectProjectId);
|
|
26236
|
+
const tronWalletConnect = useTronWalletConnect(props.walletConnectProjectId);
|
|
25850
26237
|
const { setTonConnected, setMetaMaskConnected, setTronConnected } = useConnectedWalletsStore();
|
|
25851
26238
|
useEffect(() => {
|
|
25852
26239
|
setTonConnected(!!tonAddress);
|
|
@@ -25854,12 +26241,13 @@ const EvaaBridgeWithProviders = (props) => {
|
|
|
25854
26241
|
useEffect(() => {
|
|
25855
26242
|
setMetaMaskConnected(!!evmIsConnected);
|
|
25856
26243
|
}, [evmIsConnected, setMetaMaskConnected]);
|
|
26244
|
+
const isAnyTronConnected = !!tronConnected || !!tronWalletConnect.isConnected;
|
|
25857
26245
|
useEffect(() => {
|
|
25858
|
-
setTronConnected(
|
|
25859
|
-
}, [
|
|
26246
|
+
setTronConnected(isAnyTronConnected);
|
|
26247
|
+
}, [isAnyTronConnected, setTronConnected]);
|
|
25860
26248
|
useAutoSelectNetwork({
|
|
25861
26249
|
tonAddress,
|
|
25862
|
-
tronConnected,
|
|
26250
|
+
tronConnected: isAnyTronConnected,
|
|
25863
26251
|
evmIsConnected
|
|
25864
26252
|
});
|
|
25865
26253
|
return /* @__PURE__ */ jsx(BridgeI18nProvider, { defaultLanguage: props.defaultLanguage, children: /* @__PURE__ */ jsx(
|
|
@@ -25877,11 +26265,21 @@ const EvaaBridgeWithProviders = (props) => {
|
|
|
25877
26265
|
address: tonAddress
|
|
25878
26266
|
},
|
|
25879
26267
|
tronWallet: {
|
|
25880
|
-
|
|
25881
|
-
|
|
25882
|
-
|
|
25883
|
-
|
|
25884
|
-
|
|
26268
|
+
tronLink: {
|
|
26269
|
+
address: tronAddress,
|
|
26270
|
+
connected: tronConnected,
|
|
26271
|
+
select: tronSelect,
|
|
26272
|
+
connect: tronConnect,
|
|
26273
|
+
disconnect: tronDisconnect
|
|
26274
|
+
},
|
|
26275
|
+
walletConnect: props.walletConnectProjectId ? {
|
|
26276
|
+
address: tronWalletConnect.address,
|
|
26277
|
+
connected: tronWalletConnect.isConnected,
|
|
26278
|
+
connecting: tronWalletConnect.isConnecting,
|
|
26279
|
+
connect: tronWalletConnect.connect,
|
|
26280
|
+
disconnect: tronWalletConnect.disconnect,
|
|
26281
|
+
signTransaction: tronWalletConnect.signTransaction
|
|
26282
|
+
} : void 0
|
|
25885
26283
|
},
|
|
25886
26284
|
tonClient: props.tonClient,
|
|
25887
26285
|
tonApiKey: props.tonApiKey,
|
|
@@ -25892,6 +26290,9 @@ const EvaaBridgeWithProviders = (props) => {
|
|
|
25892
26290
|
const EvaaBridgeContent = ({
|
|
25893
26291
|
className,
|
|
25894
26292
|
transactionIcons,
|
|
26293
|
+
enableUrlSync = true,
|
|
26294
|
+
urlParams,
|
|
26295
|
+
onUrlParamsChange,
|
|
25895
26296
|
onInitialized,
|
|
25896
26297
|
onAmountChange,
|
|
25897
26298
|
onChainChange
|
|
@@ -25900,6 +26301,11 @@ const EvaaBridgeContent = ({
|
|
|
25900
26301
|
useTokens();
|
|
25901
26302
|
useChains();
|
|
25902
26303
|
const swap = useSwapModel();
|
|
26304
|
+
const { handleAmountBlur } = useUrlSync({
|
|
26305
|
+
enabled: enableUrlSync,
|
|
26306
|
+
urlParams,
|
|
26307
|
+
onUrlParamsChange
|
|
26308
|
+
});
|
|
25903
26309
|
const { fromChain, toChain } = swap;
|
|
25904
26310
|
const { selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
25905
26311
|
const { quote } = useBridgeQuoteStore();
|
|
@@ -26009,6 +26415,7 @@ const EvaaBridgeContent = ({
|
|
|
26009
26415
|
amount,
|
|
26010
26416
|
isSource: true,
|
|
26011
26417
|
onAmountChange: handleAmountChange,
|
|
26418
|
+
onAmountBlur: handleAmountBlur,
|
|
26012
26419
|
onSelect: handleFromChainChange
|
|
26013
26420
|
}
|
|
26014
26421
|
),
|
|
@@ -26158,4 +26565,4 @@ export {
|
|
|
26158
26565
|
calculateMinReceived as y,
|
|
26159
26566
|
estimateTonNetworkFee as z
|
|
26160
26567
|
};
|
|
26161
|
-
//# sourceMappingURL=index-
|
|
26568
|
+
//# sourceMappingURL=index-w-PXiL0q.js.map
|