@rash2x/bridge-widget 0.8.2 → 0.8.4

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-BcqN6B-E.cjs");
3
+ const index = require("./index-BDGHvxEQ.cjs");
4
4
  exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
5
5
  exports.EvaaBridge = index.EvaaBridge;
6
6
  exports.RoutePriority = index.RoutePriority;
@@ -1,4 +1,4 @@
1
- import { L, d, f, e, D, Q, H, y, B, U, w, s, v, r, p, q, G, Z, a6, $, a3, x, z, a0, A, _, a4, a5, X, Y, S, a1, P, I, V, a2, W, a7, a8, J, K, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-BiPDLFPf.js";
1
+ import { L, d, f, e, D, Q, H, y, B, U, w, s, v, r, p, q, G, Z, a6, $, a3, x, z, a0, A, _, a4, a5, X, Y, S, a1, P, I, V, a2, W, a7, a8, J, K, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-B5QQQ8Nj.js";
2
2
  export {
3
3
  L as DEFAULT_SLIPPAGE_BPS,
4
4
  d as EvaaBridge,
@@ -2445,6 +2445,7 @@ function computeFeeBreakdownUsd(quote, srcToken, dstToken, tokens, chains, srcCh
2445
2445
  let messageFeeUsd = 0;
2446
2446
  let messageFeeAmount = 0;
2447
2447
  let messageFeeSymbol = "";
2448
+ let messageFeeTokenPriceUsd = 0;
2448
2449
  const messageFees = quote.fees.filter((f4) => f4.type === "message");
2449
2450
  for (const f4 of messageFees) {
2450
2451
  const { decimals, priceUsd } = lookupTokenMeta(
@@ -2462,6 +2463,7 @@ function computeFeeBreakdownUsd(quote, srcToken, dstToken, tokens, chains, srcCh
2462
2463
  (t2) => t2.chainKey === f4.chainKey && t2.address.toLowerCase() === f4.token.toLowerCase()
2463
2464
  );
2464
2465
  messageFeeSymbol = token?.symbol?.toUpperCase() ?? chain2?.nativeCurrency?.symbol?.toUpperCase() ?? "";
2466
+ messageFeeTokenPriceUsd = priceUsd ?? 0;
2465
2467
  }
2466
2468
  }
2467
2469
  let bridgeFeeAmount = 0;
@@ -2492,7 +2494,14 @@ function computeFeeBreakdownUsd(quote, srcToken, dstToken, tokens, chains, srcCh
2492
2494
  dstGasUsd = dstGasAmount * (priceUsd ?? 0);
2493
2495
  }
2494
2496
  }
2495
- const totalFeeUsd = messageFeeUsd + bridgeFeeUsd + dstGasUsd;
2497
+ if (dstGasAmount > 0 && messageFeeSymbol) {
2498
+ if (messageFeeSymbol === dstGasSymbol) {
2499
+ messageFeeAmount += dstGasAmount;
2500
+ } else if (messageFeeTokenPriceUsd > 0) {
2501
+ messageFeeAmount += dstGasUsd / messageFeeTokenPriceUsd;
2502
+ }
2503
+ }
2504
+ const totalFeeUsd = messageFeeUsd + bridgeFeeUsd;
2496
2505
  return {
2497
2506
  messageFeeAmount,
2498
2507
  messageFeeSymbol,
@@ -5030,6 +5039,44 @@ const MainButton = ({
5030
5039
  )
5031
5040
  ] });
5032
5041
  };
5042
+ const MOBILE_UA_REGEX = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i;
5043
+ function isMobileDevice() {
5044
+ if (typeof navigator === "undefined") return false;
5045
+ return MOBILE_UA_REGEX.test(navigator.userAgent);
5046
+ }
5047
+ function isTronLinkInstalled() {
5048
+ if (typeof window === "undefined") {
5049
+ return false;
5050
+ }
5051
+ const win = window;
5052
+ if (!win.tronWeb) {
5053
+ return false;
5054
+ }
5055
+ const tronLink = win.tronWeb;
5056
+ if (typeof tronLink.isTronLink === "boolean") {
5057
+ return tronLink.isTronLink;
5058
+ }
5059
+ if (typeof tronLink.ready === "boolean") {
5060
+ return tronLink.ready;
5061
+ }
5062
+ return true;
5063
+ }
5064
+ function buildTronLinkDeepLink(targetUrl) {
5065
+ const param = encodeURIComponent(
5066
+ JSON.stringify({
5067
+ url: targetUrl,
5068
+ action: "open",
5069
+ protocol: "tronlink",
5070
+ version: "1.0"
5071
+ })
5072
+ );
5073
+ return `tronlinkoutside://pull.activity?param=${param}`;
5074
+ }
5075
+ function openInTronLink(targetUrl) {
5076
+ if (typeof window === "undefined") return false;
5077
+ window.location.href = buildTronLinkDeepLink(targetUrl);
5078
+ return true;
5079
+ }
5033
5080
  const WalletModalButton = (props) => {
5034
5081
  const { t: t2 } = useTranslation();
5035
5082
  const { icon: IconComponent, name, onClose } = props;
@@ -5086,6 +5133,17 @@ const WalletModalButton = (props) => {
5086
5133
  const strategy = chainRegistry.getStrategyByType("ton");
5087
5134
  await strategy?.connect();
5088
5135
  } else {
5136
+ if (walletId === "tronlink" && isMobileDevice() && !isTronLinkInstalled()) {
5137
+ const opened = openInTronLink(window.location.href);
5138
+ if (!opened) {
5139
+ toast.error(
5140
+ "Failed to open TronLink app. Please use WalletConnect."
5141
+ );
5142
+ return;
5143
+ }
5144
+ onClose?.();
5145
+ return;
5146
+ }
5089
5147
  const strategy = chainRegistry.getStrategyByType("tron");
5090
5148
  const provider = walletId === "tronwc" ? "walletconnect" : "tronlink";
5091
5149
  await strategy?.connect({ provider });
@@ -6282,14 +6340,17 @@ class TronChainStrategy {
6282
6340
  await walletConnect.connect();
6283
6341
  return;
6284
6342
  }
6285
- if (!this.isTronLinkInstalled()) {
6286
- if (typeof window !== "undefined") {
6343
+ if (!isTronLinkInstalled()) {
6344
+ if (typeof window !== "undefined" && !isMobileDevice()) {
6287
6345
  window.open("https://www.tronlink.org/", "_blank");
6288
6346
  }
6289
- throw new WalletNotFoundError(
6290
- "tron",
6291
- "TronLink wallet is not installed. Please install TronLink extension and try again."
6292
- );
6347
+ if (isMobileDevice()) {
6348
+ throw new ProviderNotAvailableError(
6349
+ "tron",
6350
+ "TronLink is not available in this mobile browser. Use WalletConnect or open this dApp in TronLink's in-app browser."
6351
+ );
6352
+ }
6353
+ throw new WalletNotFoundError("tron", "TronLink");
6293
6354
  }
6294
6355
  if (this.config.tronLink.connected && this.config.tronLink.address) {
6295
6356
  console.log("TronLink already connected, skipping connection");
@@ -6499,7 +6560,7 @@ class TronChainStrategy {
6499
6560
  if (preferProvider === "walletconnect") {
6500
6561
  return this.getFallbackClient();
6501
6562
  }
6502
- if (typeof window !== "undefined" && window.tronWeb && this.isTronLinkInstalled()) {
6563
+ if (typeof window !== "undefined" && window.tronWeb && isTronLinkInstalled()) {
6503
6564
  this.applyTronApiKey(window.tronWeb);
6504
6565
  return window.tronWeb;
6505
6566
  }
@@ -6554,27 +6615,6 @@ class TronChainStrategy {
6554
6615
  } catch {
6555
6616
  }
6556
6617
  }
6557
- /**
6558
- * Check if TronLink wallet is actually installed
6559
- * This excludes Bybit Wallet which also injects tronLink for compatibility
6560
- */
6561
- isTronLinkInstalled() {
6562
- if (typeof window === "undefined") {
6563
- return false;
6564
- }
6565
- const win = window;
6566
- if (!win.tronWeb) {
6567
- return false;
6568
- }
6569
- const tronLink = win.tronWeb;
6570
- if (typeof tronLink.isTronLink === "boolean") {
6571
- return tronLink.isTronLink;
6572
- }
6573
- if (typeof tronLink.ready === "boolean") {
6574
- return tronLink.ready;
6575
- }
6576
- return true;
6577
- }
6578
6618
  ensureDefaultAddress(tronWeb, address) {
6579
6619
  if (!address) return;
6580
6620
  try {
@@ -26505,7 +26545,7 @@ class WalletConnectModal {
26505
26545
  }
26506
26546
  async initUi() {
26507
26547
  if (typeof window !== "undefined") {
26508
- await import("./index-BqxDubHD.js");
26548
+ await import("./index-BKyBBUlY.js");
26509
26549
  const modal = document.createElement("wcm-modal");
26510
26550
  document.body.insertAdjacentElement("beforeend", modal);
26511
26551
  OptionsCtrl.setIsUiLoaded(true);
@@ -27410,4 +27450,4 @@ export {
27410
27450
  calculateMinReceived as y,
27411
27451
  getQuoteDetails as z
27412
27452
  };
27413
- //# sourceMappingURL=index-BiPDLFPf.js.map
27453
+ //# sourceMappingURL=index-B5QQQ8Nj.js.map