@rash2x/bridge-widget 0.6.92 → 0.6.94

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.
@@ -34,7 +34,7 @@ import { FixedSizeList } from "react-window";
34
34
  const common$1 = { "connecting": "Connecting…", "initializing": "Initializing...", "loading": "Loading...", "paste": "paste", "close": "Close", "zeroPlaceholder": "0", "nativeToken": "Native Token" };
35
35
  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", "connectedStatus": "Connected", "disconnect": "Disconnect", "chooseWallet": "Connect wallet", "oneWalletPerEnv": "You can only connect one wallet per environment.", "connect": "Connect", "connectTronWallet": "Connect Tron wallet", "connectWallet": "Connect wallet" };
36
36
  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", "willChangeDestinationChain": "Will change destination network", "willChangeBothChains": "Will change both networks", "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" };
37
- 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": "Transaction in progress...", "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", "layerzeroScan": "TxHash", "finalFee": "Final Fee", "route": "Route", "routeTooltip": "Route is the path your transfer takes between networks. The bridge is powered by LayerZero, and the specific path can affect the fee, slippage, and estimated time.", "estTime": "Est. Time", "estTimeTooltip": "Estimated time is the approximate completion time. It depends on the route and network load; actual time may vary.", "slippage": "Slippage", "slippageTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "minimumReceived": "Minimum received", "totalFee": "Total Fee", "totalFeeTooltip": "Total fee is the estimated total cost of the transfer. It includes network gas and bridge/route fees. The final fee may vary slightly.", "noRouteFound": "No route found", "notEnoughGas": "Not enough gas", "pasteAddressToTransfer": "Paste address to transfer", "noRouteFoundForSettings": "No route found for current settings.", "tryAdjustSettings": "Try disabling Gas on Destination, or adjust amount/networks.", "quoteError": "Quote error", "steps": { "sent": "Sent", "approving": "Approving Token", "approvingNote": "Step {{current}} of {{total}}: Confirm approval in wallet", "bridging": "Bridging", "processing": "Processing", "processingNote": "Up to 2 minutes", "completed": "Completed" } };
37
+ 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": "Transaction in progress...", "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", "layerzeroScan": "TxHash", "finalFee": "Final Fee", "route": "Route", "routeTooltip": "Route is the path your transfer takes between networks. The bridge is powered by LayerZero, and the specific path can affect the fee, slippage, and estimated time.", "estTime": "Est. Time", "estTimeTooltip": "Estimated time is the approximate completion time. It depends on the route and network load; actual time may vary.", "slippage": "Slippage", "slippageTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "minimumReceived": "Minimum received", "messageFee": "Message Fee", "messageFeeTooltip": "Message fee is the LayerZero cross-chain messaging cost paid to relay your transaction between networks.", "bridgeFee": "Bridge Fee", "bridgeFeeTooltip": "Bridge fee is the difference between the amount you send and the amount you receive, charged by the bridge protocol.", "totalFee": "Total Fee", "totalFeeTooltip": "Total fee is the estimated total cost of the transfer, including message and bridge fees. The final fee may vary slightly.", "gasEstimate": "Gas: {{gas}}", "noRouteFound": "No route found", "notEnoughGas": "Not enough gas", "pasteAddressToTransfer": "Paste address to transfer", "noRouteFoundForSettings": "No route found for current settings.", "tryAdjustSettings": "Try disabling Gas on Destination, or adjust amount/networks.", "quoteError": "Quote error", "steps": { "sent": "Sent", "approving": "Approving Token", "approvingNote": "Step {{current}} of {{total}}: Confirm approval in wallet", "bridging": "Bridging", "processing": "Processing", "processingNote": "Up to 2 minutes", "completed": "Completed" } };
38
38
  const telegram$1 = { "openWebVersion": "Open EVAA Web to Bridge", "restrictionMessage": "You can bridge between the chosen networks on EVAA web version" };
39
39
  const app$1 = { "stargateWidgetName": "Stargate Bridge Widget", "liveWidget": "Live Widget", "getStarted": "Get Started" };
40
40
  const settings$1 = { "title": "Settings", "gasOnDestination": "Gas on destination", "gasOnDestinationTooltip": "Adds the destination network's native token to cover fees for transactions after bridging. Increases the total fee.", "slippageTolerance": "Slippage tolerance", "slippageToleranceTooltip": "If the received amount goes below this tolerance, the transaction will be reverted.", "routePriority": "Route Priority", "routePriorityTooltip": "Select how the bridge chooses a route. Recommended balances options to find the best overall cost. Fastest prioritizes completion speed over everything else.", "highSlippageWarning": "High slippage warning", "gasPresets": { "auto": "Auto", "none": "None", "medium": "Medium", "max": "Max" }, "routePresets": { "fastest": "Fastest", "cheapest": "Cheapest", "recommended": "Recommended" } };
@@ -52,7 +52,7 @@ const en$3 = {
52
52
  const common = { "connecting": "Подключение…", "initializing": "Инициализация...", "loading": "Загрузка...", "paste": "вставить", "close": "Закрыть", "zeroPlaceholder": "0", "nativeToken": "Нативный токен" };
53
53
  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": "ПОДКЛЮЧЕНО", "connectedStatus": "Подключён", "disconnect": "Отключить", "chooseWallet": "Подключите кошелек", "oneWalletPerEnv": "Можно подключить только один кошелёк на окружение.", "connect": "Подключить", "connectTronWallet": "Подключить Tron кошелёк", "connectWallet": "Подключить кошелёк" };
54
54
  const bridge = { "max": "Макс", "sourceNetwork": "Исходная сеть", "destinationNetwork": "Целевая сеть", "selectToken": "Выбрать токен", "selectNetwork": "Выбрать сеть", "selectSourceNetwork": "Выбрать исходную сеть", "selectDestinationNetwork": "Выбрать целевую сеть", "searchToken": "Поиск токена", "myTokens": "Мои токены", "allTokens": "Все токены", "search": "Поиск", "select": "Выбрать", "willChangeSourceChain": "Сменит исходную сеть", "willChangeDestinationChain": "Сменит целевую сеть", "willChangeBothChains": "Сменит обе сети", "willChangeSourceNetworkAndToken": "Сменит исходный токен", "noBalancesFound": "Балансы не найдены.", "noResults": "Нет результатов", "tokenNotFound": "Мы не смогли найти токен с таким названием или символом. Пожалуйста, попробуйте снова.", "chainNotFound": "Мы не смогли найти сеть с таким названием. Пожалуйста, попробуйте снова.", "sendToAnotherAddress": "Отправить на другой адрес", "youWillReceive": "Вы получите", "anotherAddressPlaceholder": "Адрес", "addressDoesntMatch": "Адрес не соответствует сети {{network}}", "checkBeforeTransfer": "Проверьте корректность перед переводом" };
55
- const transaction = { "enterAmount": "Введите сумму", "transfer": "Перевести", "getQuote": "Получить котировку", "quoting": "Расчет котировки...", "failed": "Ошибка транзакции", "confirm": "Подтвердите транзакцию", "signTransaction": "Подпишите транзакцию в кошельке", "inProgress": "Транзакция выполняется...", "checkingBalance": "Проверка баланса...", "insufficientBalance": "Недостаточно средств", "amountTooSmall": "Минимум {{min}}", "amountTooLarge": "Максимум {{max}}", "success": "Успех", "successTitle": "Успех", "done": "Готово", "hashCopied": "Хэш скопирован в буфер обмена", "bridged": "Переведено", "transferTitle": "Перевод", "hash": "Хэш", "layerzeroScan": "TxHash", "finalFee": "Итоговая комиссия", "route": "Маршрут", "routeTooltip": "Маршрут — это путь, по которому будет выполнен перевод. Мост работает на базе LayerZero, а конкретный путь передачи между сетями может влиять на комиссию, проскальзывание и время.", "estTime": "Время", "estTimeTooltip": "Среднее время — примерное время завершения перевода. Зависит от маршрута и нагрузки сети; фактическое время может отличаться.", "slippage": "Проскальзывание", "slippageTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "minimumReceived": "Минимум к получению", "totalFee": "Общая комиссия", "totalFeeTooltip": "Общая комиссия за перевод. Включает оценку комиссии сети (газ) и комиссии моста/маршрута. Фактическая сумма может немного измениться.", "noRouteFound": "Маршрут не найден", "notEnoughGas": "Недостаточно газа", "pasteAddressToTransfer": "Укажите адрес получателя", "noRouteFoundForSettings": "Маршрут не найден для текущих настроек.", "tryAdjustSettings": "Попробуйте отключить Gas on Destination или измените сумму/сети.", "quoteError": "Ошибка котировки", "steps": { "sent": "Отправлено", "approving": "Одобрение токена", "approvingNote": "Шаг {{current}} из {{total}}: Подтвердите одобрение в кошельке", "bridging": "Перевод через мост", "processing": "Обработка", "processingNote": "До 2 минут", "completed": "Завершено" } };
55
+ const transaction = { "enterAmount": "Введите сумму", "transfer": "Перевести", "getQuote": "Получить котировку", "quoting": "Расчет котировки...", "failed": "Ошибка транзакции", "confirm": "Подтвердите транзакцию", "signTransaction": "Подпишите транзакцию в кошельке", "inProgress": "Транзакция выполняется...", "checkingBalance": "Проверка баланса...", "insufficientBalance": "Недостаточно средств", "amountTooSmall": "Минимум {{min}}", "amountTooLarge": "Максимум {{max}}", "success": "Успех", "successTitle": "Успех", "done": "Готово", "hashCopied": "Хэш скопирован в буфер обмена", "bridged": "Переведено", "transferTitle": "Перевод", "hash": "Хэш", "layerzeroScan": "TxHash", "finalFee": "Итоговая комиссия", "route": "Маршрут", "routeTooltip": "Маршрут — это путь, по которому будет выполнен перевод. Мост работает на базе LayerZero, а конкретный путь передачи между сетями может влиять на комиссию, проскальзывание и время.", "estTime": "Время", "estTimeTooltip": "Среднее время — примерное время завершения перевода. Зависит от маршрута и нагрузки сети; фактическое время может отличаться.", "slippage": "Проскальзывание", "slippageTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "minimumReceived": "Минимум к получению", "messageFee": "Комиссия сообщения", "messageFeeTooltip": "Комиссия сообщения — стоимость кросс-чейн передачи через LayerZero для ретрансляции транзакции между сетями.", "bridgeFee": "Комиссия моста", "bridgeFeeTooltip": "Комиссия моста — разница между отправленной и полученной суммой, взимаемая протоколом моста.", "totalFee": "Общая комиссия", "totalFeeTooltip": "Общая комиссия за перевод, включая комиссию сообщения и моста. Фактическая сумма может немного измениться.", "gasEstimate": "Газ: {{gas}}", "noRouteFound": "Маршрут не найден", "notEnoughGas": "Недостаточно газа", "pasteAddressToTransfer": "Укажите адрес получателя", "noRouteFoundForSettings": "Маршрут не найден для текущих настроек.", "tryAdjustSettings": "Попробуйте отключить Gas on Destination или измените сумму/сети.", "quoteError": "Ошибка котировки", "steps": { "sent": "Отправлено", "approving": "Одобрение токена", "approvingNote": "Шаг {{current}} из {{total}}: Подтвердите одобрение в кошельке", "bridging": "Перевод через мост", "processing": "Обработка", "processingNote": "До 2 минут", "completed": "Завершено" } };
56
56
  const telegram = { "openWebVersion": "Открыть EVAA веб для трансфера", "restrictionMessage": "Трансфер между выбранными сетями доступен только в веб-версии EVAA" };
57
57
  const app = { "stargateWidgetName": "Виджет Stargate Bridge", "liveWidget": "Живой виджет", "getStarted": "Начало работы" };
58
58
  const settings = { "title": "Настройки", "gasOnDestination": "Газ на назначении", "gasOnDestinationTooltip": "Добавляет нативный токен целевой сети для оплаты комиссий за транзакции после бриджа. Увеличивает общую комиссию.", "slippageTolerance": "Толерантность к проскальзыванию", "slippageToleranceTooltip": "Если получаемая сумма окажется ниже этого допуска, транзакция будет отклонена.", "routePriority": "Приоритет маршрута", "routePriorityTooltip": "Выберите маршрут перевода. Рекомендуемый — подбирает самый выгодный вариант по общей стоимости. Быстрый — выбирает маршрут с приоритетом скорости, даже если это дороже.", "highSlippageWarning": "Высокое проскальзывание", "gasPresets": { "auto": "Авто", "none": "Нет", "medium": "Средний", "max": "Макс" }, "routePresets": { "fastest": "Быстрый", "cheapest": "Дешевый", "recommended": "Рекомендуемый" } };
@@ -2285,62 +2285,6 @@ function lookupTokenMeta(tokens, chains, chainKey, tokenAddr) {
2285
2285
  priceUsd: void 0
2286
2286
  };
2287
2287
  }
2288
- function computeFeesUsdFromArray(fees, tokens, chains) {
2289
- const emptyResult = {
2290
- usd: /* @__PURE__ */ new Map(),
2291
- human: /* @__PURE__ */ new Map(),
2292
- original: void 0
2293
- };
2294
- if (!fees?.length) return emptyResult;
2295
- let totalUsd = 0;
2296
- const byTypeUsd = /* @__PURE__ */ new Map();
2297
- const byTypeHuman = /* @__PURE__ */ new Map();
2298
- for (const f4 of fees) {
2299
- let usd = Number(f4.usd ?? 0);
2300
- let human = 0;
2301
- const amount = String(f4.amount ?? "0");
2302
- if (!usd) {
2303
- const { decimals, priceUsd } = lookupTokenMeta(
2304
- tokens,
2305
- chains,
2306
- f4.chainKey,
2307
- f4.token
2308
- );
2309
- human = fromLD(amount, decimals);
2310
- usd = (priceUsd ?? 0) * human;
2311
- }
2312
- totalUsd += usd;
2313
- const type = (f4.type ?? "other").toLowerCase();
2314
- byTypeUsd.set(type, (byTypeUsd.get(type) ?? 0) + usd);
2315
- const existing = byTypeHuman.get(type);
2316
- if (existing) {
2317
- existing.amount += human;
2318
- } else {
2319
- byTypeHuman.set(type, {
2320
- amount: human,
2321
- token: f4.token,
2322
- chainKey: f4.chainKey
2323
- });
2324
- }
2325
- }
2326
- byTypeUsd.set("total", totalUsd);
2327
- return {
2328
- usd: byTypeUsd,
2329
- human: byTypeHuman,
2330
- original: fees
2331
- };
2332
- }
2333
- function sumFeeByTokenLD(fees, dstTokenAddr, dstChainKey) {
2334
- if (!fees?.length || !dstTokenAddr || !dstChainKey) return "0";
2335
- let acc = 0n;
2336
- for (const f4 of fees) {
2337
- if (f4.chainKey !== dstChainKey) continue;
2338
- const same = dstChainKey === "ton" ? tonNorm(f4.token) === tonNorm(dstTokenAddr) : lower(f4.token) === lower(dstTokenAddr);
2339
- if (!same) continue;
2340
- acc += BigInt(f4.amount ?? "0");
2341
- }
2342
- return acc.toString();
2343
- }
2344
2288
  function getQuoteAmounts(quote, srcToken, dstToken) {
2345
2289
  if (!quote || !srcToken || !dstToken) {
2346
2290
  return {
@@ -2361,48 +2305,6 @@ function getQuoteAmounts(quote, srcToken, dstToken) {
2361
2305
  minReceivedHuman
2362
2306
  };
2363
2307
  }
2364
- function getQuoteFees(quote, tokens, chains, srcToken, dstToken) {
2365
- if (!quote || !tokens || !chains) {
2366
- return {
2367
- fees: { usd: /* @__PURE__ */ new Map(), original: /* @__PURE__ */ new Map(), formatted: /* @__PURE__ */ new Map() },
2368
- inSrcToken: void 0,
2369
- inDstToken: void 0
2370
- };
2371
- }
2372
- const feeData = computeFeesUsdFromArray(quote.fees, tokens, chains);
2373
- let inSrcToken = void 0;
2374
- let inDstToken = void 0;
2375
- if (srcToken && quote.srcChainKey) {
2376
- const feeInSrcLD = sumFeeByTokenLD(
2377
- quote.fees,
2378
- srcToken.address,
2379
- quote.srcChainKey
2380
- );
2381
- const feeInSrcHuman = fromLD(feeInSrcLD, srcToken.decimals);
2382
- if (feeInSrcHuman > 0) {
2383
- inSrcToken = Number(truncateToDecimals(feeInSrcHuman, 8));
2384
- } else if ((feeData.usd.get("total") || 0) > 0 && srcToken.price?.usd) {
2385
- const feeInSrcApprox = (feeData.usd.get("total") || 0) / srcToken.price.usd;
2386
- inSrcToken = Number(truncateToDecimals(feeInSrcApprox, 8));
2387
- }
2388
- }
2389
- if (dstToken && quote.dstChainKey) {
2390
- const feeInDstLD = sumFeeByTokenLD(
2391
- quote.fees,
2392
- dstToken.address,
2393
- quote.dstChainKey
2394
- );
2395
- const feeInDstHuman = fromLD(feeInDstLD, dstToken.decimals);
2396
- if (feeInDstHuman > 0) {
2397
- inDstToken = Number(truncateToDecimals(feeInDstHuman, 8));
2398
- }
2399
- }
2400
- return {
2401
- fees: feeData,
2402
- inSrcToken,
2403
- inDstToken
2404
- };
2405
- }
2406
2308
  function calculateMinReceived(quote, slippageBps, dstToken) {
2407
2309
  if (!quote || !dstToken) return 0;
2408
2310
  const dstAmountLD = BigInt(quote.dstAmount);
@@ -2411,7 +2313,7 @@ function calculateMinReceived(quote, slippageBps, dstToken) {
2411
2313
  }
2412
2314
  function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
2413
2315
  const amounts = getQuoteAmounts(quote, srcToken, dstToken);
2414
- const fees = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
2316
+ const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
2415
2317
  const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
2416
2318
  return {
2417
2319
  inputAmount: amounts.inputHuman,
@@ -2431,6 +2333,28 @@ function getRouteDisplayName(route) {
2431
2333
  if (routeLower.includes("v2")) return "Stargate V2";
2432
2334
  return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
2433
2335
  }
2336
+ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
2337
+ const empty = { messageFeeUsd: 0, bridgeFeeUsd: 0, totalFeeUsd: 0 };
2338
+ if (!quote || !srcToken) return empty;
2339
+ let messageFeeUsd = 0;
2340
+ const messageFees = quote.fees.filter((f4) => f4.type === "message");
2341
+ for (const f4 of messageFees) {
2342
+ const { decimals, priceUsd } = lookupTokenMeta(tokens, chains, f4.chainKey, f4.token);
2343
+ const human = fromLD(f4.amount || "0", decimals);
2344
+ messageFeeUsd += human * (priceUsd ?? 0);
2345
+ }
2346
+ let bridgeFeeUsd = 0;
2347
+ if (srcToken.price?.usd) {
2348
+ const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
2349
+ const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
2350
+ const diff = srcHuman - dstHuman;
2351
+ if (diff > 0) {
2352
+ bridgeFeeUsd = diff * srcToken.price.usd;
2353
+ }
2354
+ }
2355
+ const totalFeeUsd = messageFeeUsd + bridgeFeeUsd;
2356
+ return { messageFeeUsd, bridgeFeeUsd, totalFeeUsd };
2357
+ }
2434
2358
  async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
2435
2359
  if (!quote || !chains) {
2436
2360
  return quote;
@@ -2936,79 +2860,18 @@ const TokenSymbol = ({
2936
2860
  const src2 = `${BASE_URL}/${normalizedSymbol}.svg`;
2937
2861
  return /* @__PURE__ */ jsx("img", { src: src2, alt: alt ?? symbol, className });
2938
2862
  };
2939
- function useGasEstimate(amountNum) {
2940
- const { fromChain } = useChainsStore();
2941
- const { selectedAssetSymbol } = useTokensStore();
2942
- const { srcAddress } = useAddresses();
2943
- const { balances, isLoading: balancesLoading } = useBalances(
2944
- fromChain?.chainKey,
2945
- srcAddress
2946
- );
2863
+ function useFeeBreakdown() {
2947
2864
  const { quote } = useBridgeQuoteStore();
2948
- const balancesKnown = !balancesLoading;
2949
- const chainKey = fromChain?.chainKey;
2950
- const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
2951
- const nativeCurrencyAddress = fromChain?.nativeCurrency?.address;
2952
- const nativeCurrencyDecimals = fromChain?.nativeCurrency?.decimals;
2953
- const quoteFees = quote?.fees;
2954
- const quoteSrcChainKey = quote?.srcChainKey;
2955
- const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
2956
- const result = useMemo(() => {
2957
- if (!chainKey || !nativeCurrencySymbol) {
2958
- return {
2959
- nativeSym: "",
2960
- nativeBalance: 0,
2961
- requiredNative: 0,
2962
- balancesKnown,
2963
- isNativeSelected: false,
2964
- hasEnoughGas: true
2965
- };
2966
- }
2967
- const nativeSym = nativeCurrencySymbol.toUpperCase();
2968
- const nativeBalance = nativeBalanceValue;
2969
- const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
2970
- let requiredNative = 0;
2971
- let quoteFeesAvailable = false;
2972
- if (quoteFees && quoteSrcChainKey === chainKey) {
2973
- const fees = quoteFees;
2974
- const feesInNative = fees.filter(
2975
- (f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress
2976
- ).reduce(
2977
- (sum, f4) => sum + BigInt(f4.amount || "0"),
2978
- 0n
2979
- );
2980
- const decimals = nativeCurrencyDecimals || 18;
2981
- requiredNative = Number(feesInNative) / Math.pow(10, decimals);
2982
- quoteFeesAvailable = true;
2983
- }
2984
- let hasEnoughGas = true;
2985
- if (isNativeSelected) {
2986
- hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
2987
- } else {
2988
- hasEnoughGas = nativeBalance >= requiredNative;
2989
- }
2990
- const shouldCheckGas = balancesKnown && quoteFeesAvailable;
2991
- return {
2992
- nativeSym,
2993
- nativeBalance,
2994
- requiredNative,
2995
- balancesKnown,
2996
- isNativeSelected,
2997
- hasEnoughGas: shouldCheckGas ? hasEnoughGas : true
2998
- };
2999
- }, [
3000
- chainKey,
3001
- nativeCurrencySymbol,
3002
- nativeCurrencyAddress,
3003
- nativeCurrencyDecimals,
3004
- selectedAssetSymbol,
3005
- quoteFees,
3006
- quoteSrcChainKey,
3007
- amountNum,
3008
- balancesKnown,
3009
- nativeBalanceValue
3010
- ]);
3011
- return result;
2865
+ const { tokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
2866
+ const { fromChain, chains } = useChainsStore();
2867
+ return useMemo(() => {
2868
+ const srcToken = resolveTokenOnChainFromMatrix$1(
2869
+ assetMatrix,
2870
+ selectedAssetSymbol,
2871
+ fromChain?.chainKey
2872
+ );
2873
+ return computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
2874
+ }, [quote, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
3012
2875
  }
3013
2876
  function useBridgeExternalData(options) {
3014
2877
  const selectedAssetSymbol = useTokensStore(
@@ -3148,7 +3011,7 @@ const Details = () => {
3148
3011
  const { selectedAssetSymbol } = useTokensStore();
3149
3012
  const { quote, status } = useBridgeQuoteStore();
3150
3013
  const { slippageBps } = useSettingsStore();
3151
- const gas = useGasEstimate();
3014
+ const fees = useFeeBreakdown();
3152
3015
  const bridgeData = useBridgeExternalData();
3153
3016
  const symbol = (selectedAssetSymbol ?? bridgeData.dstToken?.symbol ?? "—").toUpperCase();
3154
3017
  const isLoading = status === "loading";
@@ -3157,7 +3020,9 @@ const Details = () => {
3157
3020
  1,
3158
3021
  Math.round(bridgeData.quoteDetails?.etaSeconds / 60)
3159
3022
  )}m` : "—";
3160
- const totalFeeDisplay = !quote ? "—" : gas.requiredNative > 0 ? `${truncateToDecimals(gas.requiredNative, 6)} ${gas.nativeSym}` : "—";
3023
+ const messageFeeDisplay = !quote ? "—" : formatUsd(fees.messageFeeUsd);
3024
+ const bridgeFeeDisplay = !quote ? "—" : formatUsd(fees.bridgeFeeUsd);
3025
+ const totalFeeDisplay = !quote ? "—" : formatUsd(fees.totalFeeUsd);
3161
3026
  const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
3162
3027
  const routeText = getRouteDisplayName(quote?.route);
3163
3028
  return /* @__PURE__ */ jsx(Accordion, { type: "single", collapsible: true, className: "w-full border-none", children: /* @__PURE__ */ jsxs(AccordionItem, { value: "item-1", className: "bg-muted rounded-sm", children: [
@@ -3198,22 +3063,30 @@ const Details = () => {
3198
3063
  value: currentSlippageText
3199
3064
  }
3200
3065
  ),
3066
+ /* @__PURE__ */ jsx(
3067
+ DetailsRow,
3068
+ {
3069
+ label: t2("transaction.messageFee"),
3070
+ tooltip: t2("transaction.messageFeeTooltip"),
3071
+ value: messageFeeDisplay,
3072
+ isLoading
3073
+ }
3074
+ ),
3075
+ /* @__PURE__ */ jsx(
3076
+ DetailsRow,
3077
+ {
3078
+ label: t2("transaction.bridgeFee"),
3079
+ tooltip: t2("transaction.bridgeFeeTooltip"),
3080
+ value: bridgeFeeDisplay,
3081
+ isLoading
3082
+ }
3083
+ ),
3201
3084
  /* @__PURE__ */ jsx(
3202
3085
  DetailsRow,
3203
3086
  {
3204
3087
  label: t2("transaction.totalFee"),
3205
3088
  tooltip: t2("transaction.totalFeeTooltip"),
3206
- value: /* @__PURE__ */ jsxs("strong", { className: "inline-flex items-center gap-1", children: [
3207
- /* @__PURE__ */ jsx("span", { children: totalFeeDisplay }),
3208
- /* @__PURE__ */ jsx(
3209
- TokenSymbol,
3210
- {
3211
- symbol: gas.nativeSym,
3212
- className: "w-4 h-4",
3213
- alt: "token"
3214
- }
3215
- )
3216
- ] }),
3089
+ value: /* @__PURE__ */ jsx("strong", { children: totalFeeDisplay }),
3217
3090
  isLoading
3218
3091
  }
3219
3092
  )
@@ -3607,6 +3480,93 @@ async function reportBridgeTransaction(params, config) {
3607
3480
  };
3608
3481
  }
3609
3482
  }
3483
+ function useGasEstimate(amountNum) {
3484
+ const { fromChain } = useChainsStore();
3485
+ const { selectedAssetSymbol } = useTokensStore();
3486
+ const { srcAddress } = useAddresses();
3487
+ const { balances, isLoading: balancesLoading } = useBalances(
3488
+ fromChain?.chainKey,
3489
+ srcAddress
3490
+ );
3491
+ const { quote } = useBridgeQuoteStore();
3492
+ const balancesKnown = !balancesLoading;
3493
+ const chainKey = fromChain?.chainKey;
3494
+ const nativeCurrencySymbol = fromChain?.nativeCurrency?.symbol;
3495
+ const nativeCurrencyAddress = fromChain?.nativeCurrency?.address;
3496
+ const nativeCurrencyDecimals = fromChain?.nativeCurrency?.decimals;
3497
+ const quoteFees = quote?.fees;
3498
+ const quoteSrcChainKey = quote?.srcChainKey;
3499
+ const nativeBalanceValue = nativeCurrencySymbol ? Number(balances[nativeCurrencySymbol.toUpperCase()]?.balance ?? 0) : 0;
3500
+ const result = useMemo(() => {
3501
+ if (!chainKey || !nativeCurrencySymbol) {
3502
+ return {
3503
+ nativeSym: "",
3504
+ nativeBalance: 0,
3505
+ requiredNative: 0,
3506
+ gasOnlyNative: 0,
3507
+ gasDisplayText: "",
3508
+ balancesKnown,
3509
+ isNativeSelected: false,
3510
+ hasEnoughGas: true
3511
+ };
3512
+ }
3513
+ const nativeSym = nativeCurrencySymbol.toUpperCase();
3514
+ const nativeBalance = nativeBalanceValue;
3515
+ const isNativeSelected = nativeSym === (selectedAssetSymbol || "").toUpperCase();
3516
+ let requiredNative = 0;
3517
+ let quoteFeesAvailable = false;
3518
+ let gasOnlyNative = 0;
3519
+ if (quoteFees && quoteSrcChainKey === chainKey) {
3520
+ const fees = quoteFees;
3521
+ const feesInNative = fees.filter(
3522
+ (f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress
3523
+ ).reduce(
3524
+ (sum, f4) => sum + BigInt(f4.amount || "0"),
3525
+ 0n
3526
+ );
3527
+ const decimals = nativeCurrencyDecimals || 18;
3528
+ requiredNative = Number(feesInNative) / Math.pow(10, decimals);
3529
+ const networkFeesInNative = fees.filter(
3530
+ (f4) => f4.chainKey === chainKey && f4.token === nativeCurrencyAddress && f4.type === "network"
3531
+ ).reduce(
3532
+ (sum, f4) => sum + BigInt(f4.amount || "0"),
3533
+ 0n
3534
+ );
3535
+ gasOnlyNative = Number(networkFeesInNative) / Math.pow(10, decimals);
3536
+ quoteFeesAvailable = true;
3537
+ }
3538
+ let hasEnoughGas = true;
3539
+ if (isNativeSelected) {
3540
+ hasEnoughGas = nativeBalance - (amountNum ?? 0) >= requiredNative;
3541
+ } else {
3542
+ hasEnoughGas = nativeBalance >= requiredNative;
3543
+ }
3544
+ const shouldCheckGas = balancesKnown && quoteFeesAvailable;
3545
+ const gasDisplayText = gasOnlyNative > 0 ? `~${gasOnlyNative.toFixed(6).replace(/0+$/, "").replace(/\.$/, "")} ${nativeSym}` : "";
3546
+ return {
3547
+ nativeSym,
3548
+ nativeBalance,
3549
+ requiredNative,
3550
+ gasOnlyNative,
3551
+ gasDisplayText,
3552
+ balancesKnown,
3553
+ isNativeSelected,
3554
+ hasEnoughGas: shouldCheckGas ? hasEnoughGas : true
3555
+ };
3556
+ }, [
3557
+ chainKey,
3558
+ nativeCurrencySymbol,
3559
+ nativeCurrencyAddress,
3560
+ nativeCurrencyDecimals,
3561
+ selectedAssetSymbol,
3562
+ quoteFees,
3563
+ quoteSrcChainKey,
3564
+ amountNum,
3565
+ balancesKnown,
3566
+ nativeBalanceValue
3567
+ ]);
3568
+ return result;
3569
+ }
3610
3570
  function useBridgeTransaction() {
3611
3571
  const { quote } = useBridgeQuoteStore();
3612
3572
  const { chainRegistry } = useChainStrategies();
@@ -4137,7 +4097,8 @@ const MainButton = ({
4137
4097
  className: "w-full",
4138
4098
  children: label
4139
4099
  }
4140
- )
4100
+ ),
4101
+ gas.gasDisplayText && quote && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground text-center", children: t2("transaction.gasEstimate", { gas: gas.gasDisplayText }) })
4141
4102
  ] });
4142
4103
  };
4143
4104
  const WalletModalButton = (props) => {
@@ -5305,6 +5266,15 @@ class EvmChainStrategy {
5305
5266
  throw toChainStrategyError(error, "evm", "transaction");
5306
5267
  }
5307
5268
  }
5269
+ async getNextNonce() {
5270
+ if (!this.publicClient || !this.config.evmAddress) {
5271
+ throw new WalletNotConnectedError("evm");
5272
+ }
5273
+ return await this.publicClient.getTransactionCount({
5274
+ address: this.config.evmAddress,
5275
+ blockTag: "pending"
5276
+ });
5277
+ }
5308
5278
  async executeTransaction(step) {
5309
5279
  const walletClient = this.walletClient;
5310
5280
  if (!walletClient) {
@@ -5317,12 +5287,14 @@ class EvmChainStrategy {
5317
5287
  );
5318
5288
  }
5319
5289
  const tx = step.transaction;
5290
+ const nonce = await this.getNextNonce();
5320
5291
  const hash = await walletClient.sendTransaction({
5321
5292
  to: tx.to,
5322
5293
  data: tx.data,
5323
5294
  account: tx.from || this.config.evmAddress,
5324
5295
  value: tx.value ? BigInt(tx.value) : void 0,
5325
- chain: walletClient.chain
5296
+ chain: walletClient.chain,
5297
+ nonce
5326
5298
  });
5327
5299
  return hash;
5328
5300
  }
@@ -5364,13 +5336,15 @@ class EvmChainStrategy {
5364
5336
  });
5365
5337
  if (currentAllowance > 0n) {
5366
5338
  try {
5339
+ const resetNonce = await this.getNextNonce();
5367
5340
  const resetHash = await walletClient.writeContract({
5368
5341
  address: tokenAddress,
5369
5342
  abi: ERC20_ABI,
5370
5343
  functionName: "approve",
5371
5344
  args: [spenderAddress, 0n],
5372
5345
  account: this.config.evmAddress,
5373
- chain: walletClient.chain
5346
+ chain: walletClient.chain,
5347
+ nonce: resetNonce
5374
5348
  });
5375
5349
  await publicClient.waitForTransactionReceipt({
5376
5350
  hash: resetHash
@@ -5387,13 +5361,15 @@ class EvmChainStrategy {
5387
5361
  console.log("USDT allowance is 0, no reset needed");
5388
5362
  }
5389
5363
  try {
5364
+ const approveNonce = await this.getNextNonce();
5390
5365
  const approveHash = await walletClient.writeContract({
5391
5366
  address: tokenAddress,
5392
5367
  abi: ERC20_ABI,
5393
5368
  functionName: "approve",
5394
5369
  args: [spenderAddress, amount],
5395
5370
  account: this.config.evmAddress,
5396
- chain: walletClient.chain
5371
+ chain: walletClient.chain,
5372
+ nonce: approveNonce
5397
5373
  });
5398
5374
  return approveHash;
5399
5375
  } catch (approveError) {
@@ -6258,6 +6234,13 @@ class TronChainStrategy {
6258
6234
  } else {
6259
6235
  signedTx = await tronWeb.trx.sign(unsignedTx);
6260
6236
  }
6237
+ const signatures = signedTx.signature;
6238
+ if (!Array.isArray(signatures) || signatures.length === 0) {
6239
+ throw new TransactionFailedError(
6240
+ "tron",
6241
+ "Wallet returned unsigned transaction"
6242
+ );
6243
+ }
6261
6244
  const sent = await tronWeb.trx.sendRawTransaction(signedTx);
6262
6245
  if (!sent?.result || !sent?.txid) {
6263
6246
  throw new TransactionFailedError(
@@ -25760,7 +25743,7 @@ class WalletConnectModal {
25760
25743
  }
25761
25744
  async initUi() {
25762
25745
  if (typeof window !== "undefined") {
25763
- await import("./index--FWEmzfG.js");
25746
+ await import("./index-DVx8ZHwV.js");
25764
25747
  const modal = document.createElement("wcm-modal");
25765
25748
  document.body.insertAdjacentElement("beforeend", modal);
25766
25749
  OptionsCtrl.setIsUiLoaded(true);
@@ -25806,6 +25789,59 @@ const useThemeStore = create((set2) => ({
25806
25789
  }));
25807
25790
  const TRON_MAINNET_CHAIN_ID = "tron:0x2b6653dc";
25808
25791
  const CONNECTION_TIMEOUT = 6e4;
25792
+ function isRecord(value) {
25793
+ return typeof value === "object" && value !== null;
25794
+ }
25795
+ function hasValidSignature(transaction2) {
25796
+ if (!isRecord(transaction2)) return false;
25797
+ const signature = transaction2.signature;
25798
+ return Array.isArray(signature) && signature.length > 0 && signature.every((item) => typeof item === "string" && item.length > 0);
25799
+ }
25800
+ function normalizeSignature(signature) {
25801
+ return signature.replace(/^0x/i, "");
25802
+ }
25803
+ function toSignedTransaction(result, unsignedTx) {
25804
+ if (hasValidSignature(result)) {
25805
+ return result;
25806
+ }
25807
+ if (isRecord(result)) {
25808
+ const nestedTx = result.transaction;
25809
+ if (hasValidSignature(nestedTx)) {
25810
+ return nestedTx;
25811
+ }
25812
+ const nestedSignedTx = result.signedTransaction;
25813
+ if (hasValidSignature(nestedSignedTx)) {
25814
+ return nestedSignedTx;
25815
+ }
25816
+ const signature = result.signature;
25817
+ if (typeof signature === "string" && signature.length > 0) {
25818
+ return {
25819
+ ...unsignedTx,
25820
+ signature: [normalizeSignature(signature)]
25821
+ };
25822
+ }
25823
+ if (Array.isArray(signature) && signature.length > 0 && signature.every((item) => typeof item === "string" && item.length > 0)) {
25824
+ return {
25825
+ ...unsignedTx,
25826
+ signature: signature.map((item) => normalizeSignature(item))
25827
+ };
25828
+ }
25829
+ }
25830
+ if (typeof result === "string" && result.length > 0) {
25831
+ return {
25832
+ ...unsignedTx,
25833
+ signature: [normalizeSignature(result)]
25834
+ };
25835
+ }
25836
+ return null;
25837
+ }
25838
+ function isUserRejectedError(error) {
25839
+ if (isRecord(error) && typeof error.code === "number" && error.code === 4001) {
25840
+ return true;
25841
+ }
25842
+ const msg = error instanceof Error ? error.message.toLowerCase() : "";
25843
+ return msg.includes("user rejected") || msg.includes("rejected by user");
25844
+ }
25809
25845
  function useTronWalletConnect(projectId) {
25810
25846
  const { address, isConnected, isConnecting } = useTronWalletConnectStore();
25811
25847
  const { setAddress, setActions, reset } = useTronWalletConnectStore();
@@ -25986,11 +26022,41 @@ function useTronWalletConnect(projectId) {
25986
26022
  throw new Error("WalletConnect not connected");
25987
26023
  }
25988
26024
  try {
25989
- const result = await providerRef.current.request({
25990
- method: "tron_signTransaction",
25991
- params: [transaction2]
25992
- });
25993
- return result;
26025
+ const requestVariants = [
26026
+ [transaction2],
26027
+ [transaction2, address],
26028
+ [{ transaction: transaction2, address }],
26029
+ { transaction: transaction2, address }
26030
+ ];
26031
+ let lastResponse;
26032
+ let lastError;
26033
+ for (const params of requestVariants) {
26034
+ try {
26035
+ const result = await providerRef.current.request(
26036
+ {
26037
+ method: "tron_signTransaction",
26038
+ params
26039
+ },
26040
+ TRON_MAINNET_CHAIN_ID
26041
+ );
26042
+ lastResponse = result;
26043
+ const signedTx = toSignedTransaction(result, transaction2);
26044
+ if (signedTx) {
26045
+ return signedTx;
26046
+ }
26047
+ } catch (error) {
26048
+ if (isUserRejectedError(error)) {
26049
+ throw error;
26050
+ }
26051
+ lastError = error;
26052
+ }
26053
+ }
26054
+ if (lastError) {
26055
+ throw lastError;
26056
+ }
26057
+ throw new Error(
26058
+ `WalletConnect returned unsigned transaction: ${JSON.stringify(lastResponse)}`
26059
+ );
25994
26060
  } catch (error) {
25995
26061
  console.error("TRON WalletConnect transaction signing failed:", error);
25996
26062
  throw error;
@@ -26453,9 +26519,9 @@ const EvaaBridgeContent = ({
26453
26519
  };
26454
26520
  const EvaaBridge = EvaaBridgeWithProviders;
26455
26521
  export {
26456
- getDestTokens as $,
26457
- getQuoteDetails as A,
26458
- getRouteDisplayName as B,
26522
+ isNativeAddress as $,
26523
+ getRouteDisplayName as A,
26524
+ computeFeeBreakdownUsd as B,
26459
26525
  ConfigCtrl as C,
26460
26526
  addNetworkFeesToQuote as D,
26461
26527
  EventsCtrl as E,
@@ -26476,20 +26542,18 @@ export {
26476
26542
  ToastCtrl as T,
26477
26543
  findNativeMeta as U,
26478
26544
  lookupTokenMeta as V,
26479
- computeFeesUsdFromArray as W,
26480
- sumFeeByTokenLD as X,
26481
- normalizeTickerSymbol$1 as Y,
26482
- getChains as Z,
26483
- getTokens as _,
26545
+ normalizeTickerSymbol$1 as W,
26546
+ getChains as X,
26547
+ getTokens as Y,
26548
+ getDestTokens as Z,
26549
+ getQuotesByPriority as _,
26484
26550
  ThemeCtrl as a,
26485
- getQuotesByPriority as a0,
26486
- isNativeAddress as a1,
26487
- getEvmBalances as a2,
26488
- getTonBalances as a3,
26489
- getTronBalances as a4,
26490
- getDeliveryStatus as a5,
26491
- pollUntilDelivered as a6,
26492
- reportBridgeTransaction as a7,
26551
+ getEvmBalances as a0,
26552
+ getTonBalances as a1,
26553
+ getTronBalances as a2,
26554
+ getDeliveryStatus as a3,
26555
+ pollUntilDelivered as a4,
26556
+ reportBridgeTransaction as a5,
26493
26557
  ExplorerCtrl as b,
26494
26558
  CoreUtil as c,
26495
26559
  EvaaBridge as d,
@@ -26513,7 +26577,7 @@ export {
26513
26577
  formatHash as v,
26514
26578
  formatAddress as w,
26515
26579
  getQuoteAmounts as x,
26516
- getQuoteFees as y,
26517
- calculateMinReceived as z
26580
+ calculateMinReceived as y,
26581
+ getQuoteDetails as z
26518
26582
  };
26519
- //# sourceMappingURL=index-j6yDeMSt.js.map
26583
+ //# sourceMappingURL=index-DCLfFVh_.js.map