@rash2x/bridge-widget 0.8.5 → 0.8.8

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-CytmPXNr.cjs");
3
+ const index = require("./index-CCiUu9QP.cjs");
4
4
  exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
5
5
  exports.EvaaBridge = index.EvaaBridge;
6
6
  exports.RoutePriority = index.RoutePriority;
@@ -40,6 +40,8 @@ exports.makeTokenBalanceKey = index.makeTokenBalanceKey;
40
40
  exports.normalizeTickerSymbol = index.normalizeTickerSymbol;
41
41
  exports.pollUntilDelivered = index.pollUntilDelivered;
42
42
  exports.reportBridgeTransaction = index.reportBridgeTransaction;
43
+ exports.resolveBridgeDestinationTokenOnChainFromMatrix = index.resolveBridgeDestinationTokenOnChainFromMatrix;
44
+ exports.resolveBridgeSourceTokenOnChainFromMatrix = index.resolveBridgeSourceTokenOnChainFromMatrix;
43
45
  exports.resolveTokenOnChain = index.resolveTokenOnChain;
44
46
  exports.resolveTokenOnChainFromMatrix = index.resolveTokenOnChainFromMatrix;
45
47
  exports.toLD = index.toLD;
@@ -1 +1 @@
1
- {"version":3,"file":"evaa-bridge.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"evaa-bridge.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,15 +1,15 @@
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-BIpr23sm.js";
1
+ import { P, d, f, e, D, U, H, y, B, W, w, s, v, r, p, q, G, $, a8, a1, a5, x, z, a2, A, a0, a6, a7, Z, _, V, a3, S, I, X, a4, Y, a9, aa, N, L, J, K, F, Q, t, o, i, u, l, m, j, n, h, k } from "./index-JmSrX7Hz.js";
2
2
  export {
3
- L as DEFAULT_SLIPPAGE_BPS,
3
+ P as DEFAULT_SLIPPAGE_BPS,
4
4
  d as EvaaBridge,
5
5
  f as RoutePriority,
6
6
  e as RouteType,
7
7
  D as addNetworkFeesToQuote,
8
- Q as addrForApi,
8
+ U as addrForApi,
9
9
  H as buildAssetMatrix,
10
10
  y as calculateMinReceived,
11
11
  B as computeFeeBreakdownUsd,
12
- U as findNativeMeta,
12
+ W as findNativeMeta,
13
13
  w as formatAddress,
14
14
  s as formatBalance,
15
15
  v as formatHash,
@@ -17,32 +17,34 @@ export {
17
17
  p as formatTokenAmount,
18
18
  q as formatUsd,
19
19
  G as fromLD,
20
- Z as getChains,
21
- a6 as getDeliveryStatus,
22
- $ as getDestTokens,
23
- a3 as getEvmBalances,
20
+ $ as getChains,
21
+ a8 as getDeliveryStatus,
22
+ a1 as getDestTokens,
23
+ a5 as getEvmBalances,
24
24
  x as getQuoteAmounts,
25
25
  z as getQuoteDetails,
26
- a0 as getQuotesByPriority,
26
+ a2 as getQuotesByPriority,
27
27
  A as getRouteDisplayName,
28
- _ as getTokens,
29
- a4 as getTonBalances,
30
- a5 as getTronBalances,
31
- X as isAllowedFromChain,
32
- Y as isAllowedToChain,
33
- S as isNativeAddrEqual,
34
- a1 as isNativeAddress,
35
- P as isZeroAddr,
28
+ a0 as getTokens,
29
+ a6 as getTonBalances,
30
+ a7 as getTronBalances,
31
+ Z as isAllowedFromChain,
32
+ _ as isAllowedToChain,
33
+ V as isNativeAddrEqual,
34
+ a3 as isNativeAddress,
35
+ S as isZeroAddr,
36
36
  I as listAssetsForSelect,
37
- V as lookupTokenMeta,
38
- a2 as makeTokenBalanceKey,
39
- W as normalizeTickerSymbol,
40
- a7 as pollUntilDelivered,
41
- a8 as reportBridgeTransaction,
37
+ X as lookupTokenMeta,
38
+ a4 as makeTokenBalanceKey,
39
+ Y as normalizeTickerSymbol,
40
+ a9 as pollUntilDelivered,
41
+ aa as reportBridgeTransaction,
42
+ N as resolveBridgeDestinationTokenOnChainFromMatrix,
43
+ L as resolveBridgeSourceTokenOnChainFromMatrix,
42
44
  J as resolveTokenOnChain,
43
45
  K as resolveTokenOnChainFromMatrix,
44
46
  F as toLD,
45
- N as tonNorm,
47
+ Q as tonNorm,
46
48
  t as truncateToDecimals,
47
49
  o as useBridgeExternalData,
48
50
  i as useBridgeQuoteStore,
@@ -1088,6 +1088,7 @@ const useTokensStore = zustand.create((set2) => ({
1088
1088
  });
1089
1089
  }
1090
1090
  }));
1091
+ const STARGATE_API_BASE_URL = "https://stargate-archive.vercel.app/api/";
1091
1092
  const ALLOWED_TO_CHAINS = /* @__PURE__ */ new Set([
1092
1093
  "ethereum",
1093
1094
  "manta",
@@ -1132,7 +1133,7 @@ function isAllowedToChain(chainKey) {
1132
1133
  return ALLOWED_TO_CHAINS.has(chainKey);
1133
1134
  }
1134
1135
  async function getChains() {
1135
- const res = await fetch("https://stargate.finance/api/v1/chains", {
1136
+ const res = await fetch(`${STARGATE_API_BASE_URL}v1/chains`, {
1136
1137
  credentials: "same-origin"
1137
1138
  });
1138
1139
  if (!res.ok) {
@@ -1143,7 +1144,7 @@ async function getChains() {
1143
1144
  return all.filter((c2) => ALLOWED_TO_CHAINS.has(c2.chainKey));
1144
1145
  }
1145
1146
  async function getTokens() {
1146
- const res = await fetch("https://stargate.finance/api/v1/tokens", {
1147
+ const res = await fetch(`${STARGATE_API_BASE_URL}v1/tokens`, {
1147
1148
  credentials: "same-origin"
1148
1149
  });
1149
1150
  if (!res.ok) {
@@ -1154,7 +1155,7 @@ async function getTokens() {
1154
1155
  return tokens.map(normalizeTokenSymbol);
1155
1156
  }
1156
1157
  async function getDestTokens(srcChainKey, srcTokenAddr) {
1157
- const url = new URL("https://stargate.finance/api/v1/tokens");
1158
+ const url = new URL(`${STARGATE_API_BASE_URL}v1/tokens`);
1158
1159
  url.searchParams.set("srcChainKey", srcChainKey);
1159
1160
  url.searchParams.set("srcToken", srcTokenAddr);
1160
1161
  const res = await fetch(url.toString(), { credentials: "omit" });
@@ -1351,9 +1352,14 @@ const ChainSelectModal = ({
1351
1352
  const switchToEquivalentIfNeeded = React.useCallback(
1352
1353
  (chainKey) => {
1353
1354
  if (!selectedAssetSymbol || !assetMatrix) return;
1354
- const effectiveSym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, chainKey);
1355
- if (effectiveSym !== selectedAssetSymbol.toUpperCase()) {
1356
- setSelectedAssetSymbol(effectiveSym);
1355
+ const hasDirectToken = !!assetMatrix[selectedAssetSymbol.toUpperCase()]?.[chainKey];
1356
+ if (!hasDirectToken) {
1357
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
1358
+ if (assetMatrix[eq]?.[chainKey]) {
1359
+ setSelectedAssetSymbol(eq);
1360
+ break;
1361
+ }
1362
+ }
1357
1363
  }
1358
1364
  },
1359
1365
  [selectedAssetSymbol, assetMatrix, setSelectedAssetSymbol]
@@ -1673,6 +1679,7 @@ const WalletInlineButton = ({
1673
1679
  const connection = chainRegistry.getStrategyByType(walletType);
1674
1680
  const account = connection?.getAccount();
1675
1681
  const isConnected = connection?.isConnected();
1682
+ const isReconnecting = connection?.isConnecting();
1676
1683
  const error = connection?.getError();
1677
1684
  const availableConnections = React.useMemo(
1678
1685
  () => connection?.getAvailableConnections() ?? [],
@@ -1696,10 +1703,11 @@ const WalletInlineButton = ({
1696
1703
  }, [onOpen, addressType]);
1697
1704
  const buttonText = React.useMemo(() => {
1698
1705
  if (isConnected && account) return formatAddress(account);
1706
+ if (isReconnecting) return t2("wallets.reconnecting") ?? "Reconnecting...";
1699
1707
  if (wallet === "ton") return t2("wallets.addTonWallet");
1700
1708
  if (wallet === "tronlink") return t2("wallets.addTronWallet");
1701
1709
  return t2("wallets.addEvmWallet");
1702
- }, [wallet, isConnected, account, t2]);
1710
+ }, [wallet, isConnected, isReconnecting, account, t2]);
1703
1711
  const connectedIcon = React.useMemo(() => {
1704
1712
  if (!isConnected) return null;
1705
1713
  if (walletType === "tron" && activeTronConnection) {
@@ -2270,7 +2278,7 @@ async function fetchQuotes(req) {
2270
2278
  if (req.dstNativeAmount && req.dstNativeAmount !== "0")
2271
2279
  params.dstNativeAmount = req.dstNativeAmount;
2272
2280
  if (req.slippage && req.slippage > 0) params.slippage = String(req.slippage);
2273
- const url = `https://stargate.finance/api/v1/quotes?${new URLSearchParams(
2281
+ const url = `${STARGATE_API_BASE_URL}v1/quotes?${new URLSearchParams(
2274
2282
  params
2275
2283
  ).toString()}`;
2276
2284
  const res = await fetch(url);
@@ -2320,6 +2328,21 @@ function resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey) {
2320
2328
  const byChain = assetMatrix[assetSymbol.toUpperCase()];
2321
2329
  return byChain?.[chainKey];
2322
2330
  }
2331
+ function resolveBridgeSourceTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2332
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2333
+ const resolvedSymbol = getBridgeTokenSymbol(assetSymbol, assetMatrix, chainKey);
2334
+ return resolveTokenOnChainFromMatrix$1(assetMatrix, resolvedSymbol, chainKey);
2335
+ }
2336
+ function resolveBridgeDestinationTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2337
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2338
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey);
2339
+ if (direct) return direct;
2340
+ for (const eq of getEquivalentSymbols(assetSymbol)) {
2341
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, chainKey);
2342
+ if (eqToken) return eqToken;
2343
+ }
2344
+ return void 0;
2345
+ }
2323
2346
  const DEFAULT_SLIPPAGE_BPS = 50;
2324
2347
  const lower = (s2) => (s2 ?? "").toLowerCase();
2325
2348
  const normSym = (s2) => (s2 ?? "").toUpperCase().replace(/₮/g, "T").replace(/[^A-Z0-9]/g, "");
@@ -2666,12 +2689,25 @@ function useBridgeQuote() {
2666
2689
  const srcTokenOnFrom = React.useMemo(() => {
2667
2690
  if (!assetMatrix || !selectedAssetSymbol || !fromChain?.chainKey) return void 0;
2668
2691
  const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, fromChain.chainKey);
2669
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2692
+ const token = resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2693
+ console.log("[quote] srcToken", { selected: selectedAssetSymbol, resolved: sym, chain: fromChain.chainKey, addr: token?.address });
2694
+ return token;
2670
2695
  }, [assetMatrix, selectedAssetSymbol, fromChain?.chainKey]);
2671
2696
  const dstTokenOnTo = React.useMemo(() => {
2672
2697
  if (!assetMatrix || !selectedAssetSymbol || !toChain?.chainKey) return void 0;
2673
- const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, toChain.chainKey);
2674
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, toChain.chainKey);
2698
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, selectedAssetSymbol, toChain.chainKey);
2699
+ if (direct) {
2700
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: selectedAssetSymbol, chain: toChain.chainKey, addr: direct.address });
2701
+ return direct;
2702
+ }
2703
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
2704
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, toChain.chainKey);
2705
+ if (eqToken) {
2706
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: eq, chain: toChain.chainKey, addr: eqToken.address });
2707
+ return eqToken;
2708
+ }
2709
+ }
2710
+ return void 0;
2675
2711
  }, [assetMatrix, selectedAssetSymbol, toChain?.chainKey]);
2676
2712
  const [loading, setLoading] = React.useState(false);
2677
2713
  React.useEffect(() => {
@@ -3892,12 +3928,12 @@ function useFeeBreakdown() {
3892
3928
  const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
3893
3929
  const { fromChain, toChain, chains } = useChainsStore();
3894
3930
  return React.useMemo(() => {
3895
- const srcToken = resolveTokenOnChainFromMatrix$1(
3931
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
3896
3932
  assetMatrix,
3897
3933
  selectedAssetSymbol,
3898
3934
  fromChain?.chainKey
3899
3935
  );
3900
- const dstToken = resolveTokenOnChainFromMatrix$1(
3936
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3901
3937
  assetMatrix,
3902
3938
  selectedAssetSymbol,
3903
3939
  toChain?.chainKey
@@ -3974,12 +4010,12 @@ function buildBridgeExternalData({
3974
4010
  dstChain: toChain?.chainKey,
3975
4011
  amount: normalizedAmount || void 0
3976
4012
  };
3977
- const sourceToken = resolveTokenOnChainFromMatrix$1(
4013
+ const sourceToken = resolveBridgeSourceTokenOnChainFromMatrix(
3978
4014
  assetMatrix,
3979
4015
  selectedAssetSymbol,
3980
4016
  fromChain?.chainKey
3981
4017
  );
3982
- const destinationToken = resolveTokenOnChainFromMatrix$1(
4018
+ const destinationToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3983
4019
  assetMatrix,
3984
4020
  selectedAssetSymbol,
3985
4021
  toChain?.chainKey
@@ -4448,9 +4484,9 @@ async function getDeliveryStatus(params) {
4448
4484
  if (params.dstChainKey) query.set("dstChainKey", params.dstChainKey);
4449
4485
  query.set("srcTxHash", params.srcTxHash);
4450
4486
  const bases2 = [
4451
- `https://stargate.finance/api/v1/transactions?${query.toString()}`,
4452
- `https://stargate.finance/api/v1/txStatus?${query.toString()}`,
4453
- `https://stargate.finance/api/v1/messageStatus?${query.toString()}`
4487
+ `${STARGATE_API_BASE_URL}v1/transactions?${query.toString()}`,
4488
+ `${STARGATE_API_BASE_URL}v1/txStatus?${query.toString()}`,
4489
+ `${STARGATE_API_BASE_URL}v1/messageStatus?${query.toString()}`
4454
4490
  ];
4455
4491
  for (const url of bases2) {
4456
4492
  const json = await tryFetch(url);
@@ -4913,8 +4949,13 @@ function useSilentValidations(amountString) {
4913
4949
  const hasTooManyDecimals = (() => {
4914
4950
  if (!amountString || !fromChain?.chainKey || !selectedAssetSymbol)
4915
4951
  return false;
4952
+ const resolvedSym = getBridgeTokenSymbol(
4953
+ selectedAssetSymbol,
4954
+ assetMatrix,
4955
+ fromChain.chainKey
4956
+ );
4916
4957
  const sourceToken = tokens?.find(
4917
- (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === (selectedAssetSymbol ?? "").toUpperCase()
4958
+ (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === resolvedSym
4918
4959
  );
4919
4960
  if (!sourceToken) return false;
4920
4961
  const decimalPart = amountString.split(".")[1];
@@ -4925,11 +4966,18 @@ function useSilentValidations(amountString) {
4925
4966
  if (!selectedAssetSymbol || !fromChain?.chainKey || !toChain?.chainKey)
4926
4967
  return false;
4927
4968
  if (!assetMatrix) return false;
4928
- const normalizedSymbol = selectedAssetSymbol.toUpperCase();
4929
- const tokenMatrix = assetMatrix[normalizedSymbol];
4930
- if (!tokenMatrix) return true;
4931
- const existsOnSource = !!tokenMatrix[fromChain.chainKey];
4932
- const existsOnDestination = !!tokenMatrix[toChain.chainKey];
4969
+ const allSymbols = [
4970
+ selectedAssetSymbol.toUpperCase(),
4971
+ ...getEquivalentSymbols(selectedAssetSymbol).map(
4972
+ (s2) => s2.toUpperCase()
4973
+ )
4974
+ ];
4975
+ const existsOnSource = allSymbols.some(
4976
+ (sym) => !!assetMatrix[sym]?.[fromChain.chainKey]
4977
+ );
4978
+ const existsOnDestination = allSymbols.some(
4979
+ (sym) => !!assetMatrix[sym]?.[toChain.chainKey]
4980
+ );
4933
4981
  return !existsOnSource || !existsOnDestination;
4934
4982
  })();
4935
4983
  const hasInsufficientLiquidity = (() => {
@@ -5261,7 +5309,7 @@ const WalletSelectModal = () => {
5261
5309
  const { t: t2 } = useBridgeTranslation();
5262
5310
  const { isOpen, onClose } = useWalletSelectModal();
5263
5311
  const { connectors } = wagmi.useConnect();
5264
- const { address: evmAddress, connector: connectedConnector } = wagmi.useAccount();
5312
+ const { address: evmAddress, connector: connectedConnector, isReconnecting: evmIsReconnecting } = wagmi.useAccount();
5265
5313
  const { chainRegistry } = useChainStrategies();
5266
5314
  const tonWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.TON);
5267
5315
  const metaMaskWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.EVM);
@@ -5305,6 +5353,14 @@ const WalletSelectModal = () => {
5305
5353
  address: evmAddress,
5306
5354
  onDisconnect: () => metaMaskWallet?.disconnect()
5307
5355
  });
5356
+ } else if (evmIsReconnecting) {
5357
+ evmConnectedWallets.push({
5358
+ id: "walletConnect",
5359
+ name: t2("wallets.reconnecting") || "Reconnecting...",
5360
+ icon: WalletConnectIcon,
5361
+ address: "...",
5362
+ onDisconnect: () => metaMaskWallet?.disconnect()
5363
+ });
5308
5364
  }
5309
5365
  const tronConnectedWallets = [];
5310
5366
  tronConnections.forEach((connection) => {
@@ -5326,7 +5382,7 @@ const WalletSelectModal = () => {
5326
5382
  enabled: true
5327
5383
  }
5328
5384
  ];
5329
- const evmWallets = evmConnectedWallets.length > 0 ? [] : connectors.filter(
5385
+ const evmWallets = evmConnectedWallets.length > 0 || evmIsReconnecting ? [] : connectors.filter(
5330
5386
  (connector) => connector.id === "walletConnect" || connector.id === "metaMaskSDK"
5331
5387
  ).map((connector) => ({
5332
5388
  id: connector.id,
@@ -5858,7 +5914,7 @@ class EvmChainStrategy {
5858
5914
  return !!this.config.evmIsConnected;
5859
5915
  }
5860
5916
  isConnecting() {
5861
- return false;
5917
+ return !!this.config.evmIsReconnecting;
5862
5918
  }
5863
5919
  getAccount() {
5864
5920
  return this.config.evmAddress || null;
@@ -5875,15 +5931,49 @@ class EvmChainStrategy {
5875
5931
  getClient() {
5876
5932
  return this.walletClient;
5877
5933
  }
5878
- async getBalances(address, tokens) {
5879
- const chainKey = tokens[0]?.chainKey;
5934
+ resolvePublicClientForChain(chainKey) {
5880
5935
  let client = this.publicClient;
5881
- if (chainKey && this.config.getPublicClientForChain && this.config.chainKeyToId) {
5882
- const chainId = this.config.chainKeyToId[chainKey.toLowerCase()];
5883
- if (chainId) {
5884
- client = this.config.getPublicClientForChain(chainId) ?? client;
5885
- }
5936
+ if (!chainKey || !this.config.getPublicClientForChain || !this.config.chainKeyToId) {
5937
+ return client;
5938
+ }
5939
+ const chainId = this.config.chainKeyToId[chainKey.toLowerCase()];
5940
+ if (!chainId) {
5941
+ return client;
5942
+ }
5943
+ client = this.config.getPublicClientForChain(chainId) ?? client;
5944
+ return client;
5945
+ }
5946
+ getRpcErrorDetails(error) {
5947
+ if (error instanceof Error) {
5948
+ const rpcError = error;
5949
+ return {
5950
+ code: rpcError.code,
5951
+ message: rpcError.message,
5952
+ shortMessage: rpcError.shortMessage,
5953
+ details: rpcError.details
5954
+ };
5886
5955
  }
5956
+ if (typeof error === "object" && error !== null) {
5957
+ const candidate = error;
5958
+ return {
5959
+ code: typeof candidate.code === "number" ? candidate.code : void 0,
5960
+ message: typeof candidate.message === "string" ? candidate.message : String(error),
5961
+ shortMessage: typeof candidate.shortMessage === "string" ? candidate.shortMessage : void 0,
5962
+ details: typeof candidate.details === "string" ? candidate.details : void 0
5963
+ };
5964
+ }
5965
+ return { message: String(error) };
5966
+ }
5967
+ logRpcWarning(context, error, extra) {
5968
+ const rpcError = this.getRpcErrorDetails(error);
5969
+ console.warn(`[evm] ${context}`, {
5970
+ ...extra,
5971
+ ...rpcError
5972
+ });
5973
+ }
5974
+ async getBalances(address, tokens) {
5975
+ const chainKey = tokens[0]?.chainKey;
5976
+ const client = this.resolvePublicClientForChain(chainKey);
5887
5977
  if (!client) {
5888
5978
  return {};
5889
5979
  }
@@ -5922,7 +6012,7 @@ class EvmChainStrategy {
5922
6012
  }
5923
6013
  }
5924
6014
  async estimateNetworkFee(steps) {
5925
- if (!this.walletClient) {
6015
+ if (!this.config.evmAddress) {
5926
6016
  return 0;
5927
6017
  }
5928
6018
  const account = this.config.evmAddress;
@@ -5939,23 +6029,67 @@ class EvmChainStrategy {
5939
6029
  return (feePerGas * scaled + 99n) / 100n;
5940
6030
  };
5941
6031
  let totalFeeWei = 0n;
5942
- for (const step of txSteps) {
6032
+ for (let i3 = 0; i3 < txSteps.length; i3++) {
6033
+ const step = txSteps[i3];
5943
6034
  const tx = step.transaction;
5944
6035
  if (!tx?.to) continue;
6036
+ const client = this.resolvePublicClientForChain(step.chainKey);
6037
+ if (!client) {
6038
+ this.logRpcWarning("Skipped network fee estimation: no public client", "no-client", {
6039
+ chainKey: step.chainKey,
6040
+ stepType: step.type,
6041
+ stepIndex: i3 + 1,
6042
+ totalSteps: txSteps.length
6043
+ });
6044
+ continue;
6045
+ }
5945
6046
  try {
5946
- const request = await this.walletClient.prepareTransactionRequest({
6047
+ const gas = await client.estimateGas({
5947
6048
  account: tx.from || account,
5948
6049
  to: tx.to,
5949
6050
  data: tx.data,
5950
- value: tx.value ? BigInt(tx.value) : void 0,
5951
- chain: this.walletClient.chain
6051
+ value: tx.value ? BigInt(tx.value) : void 0
5952
6052
  });
5953
- const gasLimit = request.gas;
5954
- const maxFeePerGas = request.maxFeePerGas ?? request.gasPrice;
5955
- if (gasLimit && maxFeePerGas) {
5956
- totalFeeWei += gasLimit * applyFeeMultiplier(maxFeePerGas);
6053
+ let feePerGas;
6054
+ try {
6055
+ const estimatedFees = await client.estimateFeesPerGas();
6056
+ feePerGas = estimatedFees.maxFeePerGas ?? estimatedFees.gasPrice;
6057
+ } catch (feeError) {
6058
+ this.logRpcWarning(
6059
+ "Failed to estimate fees per gas, falling back to gas price",
6060
+ feeError,
6061
+ {
6062
+ chainKey: step.chainKey,
6063
+ stepType: step.type,
6064
+ stepIndex: i3 + 1,
6065
+ totalSteps: txSteps.length
6066
+ }
6067
+ );
6068
+ try {
6069
+ feePerGas = await client.getGasPrice();
6070
+ } catch (gasPriceError) {
6071
+ this.logRpcWarning("Failed to get gas price for network fee estimation", gasPriceError, {
6072
+ chainKey: step.chainKey,
6073
+ stepType: step.type,
6074
+ stepIndex: i3 + 1,
6075
+ totalSteps: txSteps.length
6076
+ });
6077
+ }
5957
6078
  }
5958
- } catch {
6079
+ if (gas && feePerGas) {
6080
+ totalFeeWei += gas * applyFeeMultiplier(feePerGas);
6081
+ }
6082
+ } catch (error) {
6083
+ this.logRpcWarning("Failed to estimate gas for network fee", error, {
6084
+ chainKey: step.chainKey,
6085
+ stepType: step.type,
6086
+ stepIndex: i3 + 1,
6087
+ totalSteps: txSteps.length,
6088
+ to: tx.to,
6089
+ from: tx.from || account,
6090
+ hasData: Boolean(tx.data),
6091
+ hasValue: Boolean(tx.value)
6092
+ });
5959
6093
  }
5960
6094
  }
5961
6095
  if (totalFeeWei === 0n) {
@@ -7160,6 +7294,7 @@ function ChainStrategyProvider({
7160
7294
  () => new EvmChainStrategy({
7161
7295
  evmAddress: evmWallet.address,
7162
7296
  evmIsConnected: evmWallet.isConnected,
7297
+ evmIsReconnecting: evmWallet.isReconnecting,
7163
7298
  evmDisconnect: evmWallet.disconnect,
7164
7299
  walletClient: evmWallet.walletClient,
7165
7300
  publicClient: evmWallet.publicClient,
@@ -7169,6 +7304,7 @@ function ChainStrategyProvider({
7169
7304
  [
7170
7305
  evmWallet.address,
7171
7306
  evmWallet.isConnected,
7307
+ evmWallet.isReconnecting,
7172
7308
  evmWallet.disconnect,
7173
7309
  evmWallet.walletClient,
7174
7310
  evmWallet.publicClient,
@@ -26621,7 +26757,7 @@ class WalletConnectModal {
26621
26757
  }
26622
26758
  async initUi() {
26623
26759
  if (typeof window !== "undefined") {
26624
- await Promise.resolve().then(() => require("./index-DiFbb5zn.cjs"));
26760
+ await Promise.resolve().then(() => require("./index-CrZzrVbc.cjs"));
26625
26761
  const modal = document.createElement("wcm-modal");
26626
26762
  document.body.insertAdjacentElement("beforeend", modal);
26627
26763
  OptionsCtrl.setIsUiLoaded(true);
@@ -26738,10 +26874,12 @@ function useTronWalletConnect(projectId) {
26738
26874
  appliedThemeRef.current = appliedTheme;
26739
26875
  React.useEffect(() => {
26740
26876
  if (!projectId || providerRef.current) return;
26877
+ let cancelled = false;
26741
26878
  const initProvider = async () => {
26742
26879
  try {
26743
26880
  const provider = await N.init({
26744
26881
  projectId,
26882
+ name: "evaa-bridge-tron",
26745
26883
  metadata: {
26746
26884
  name: "EVAA Bridge",
26747
26885
  description: "Cross-chain bridge powered by Stargate Protocol",
@@ -26749,6 +26887,7 @@ function useTronWalletConnect(projectId) {
26749
26887
  icons: [`${window.location.origin}/favicon.ico`]
26750
26888
  }
26751
26889
  });
26890
+ if (cancelled) return;
26752
26891
  providerRef.current = provider;
26753
26892
  if (projectId) {
26754
26893
  const modal = new WalletConnectModal({
@@ -26778,17 +26917,32 @@ function useTronWalletConnect(projectId) {
26778
26917
  console.log("TRON WalletConnect session deleted");
26779
26918
  setAddress(null);
26780
26919
  });
26781
- if (provider.session) {
26782
- const accounts = provider.session.namespaces?.tron?.accounts || [];
26783
- if (accounts.length > 0) {
26784
- const account = accounts[0];
26785
- const extractedAddress = account.split(":")[2];
26786
- console.log(
26787
- "TRON WalletConnect restored session:",
26788
- extractedAddress
26789
- );
26920
+ let tronAccounts = [];
26921
+ if (provider.session?.namespaces?.tron?.accounts?.length) {
26922
+ tronAccounts = provider.session.namespaces.tron.accounts;
26923
+ console.log("TRON WalletConnect: found session via provider.session");
26924
+ } else if (provider.client?.session) {
26925
+ const allSessions = provider.client.session.getAll();
26926
+ console.log("TRON WalletConnect: searching all sessions, count:", allSessions.length);
26927
+ const tronSession = allSessions.find(
26928
+ (s2) => s2.namespaces?.tron?.accounts?.length
26929
+ );
26930
+ if (tronSession) {
26931
+ tronAccounts = tronSession.namespaces.tron.accounts;
26932
+ console.log("TRON WalletConnect: found tron session in all sessions");
26933
+ }
26934
+ }
26935
+ if (tronAccounts.length > 0) {
26936
+ const extractedAddress = tronAccounts[0].split(":")[2];
26937
+ console.log(
26938
+ "TRON WalletConnect restored session:",
26939
+ extractedAddress
26940
+ );
26941
+ if (!cancelled) {
26790
26942
  setAddress(extractedAddress);
26791
26943
  }
26944
+ } else {
26945
+ console.log("TRON WalletConnect: no tron session found to restore");
26792
26946
  }
26793
26947
  } catch (error) {
26794
26948
  console.error("Failed to initialize TRON WalletConnect:", error);
@@ -26796,17 +26950,15 @@ function useTronWalletConnect(projectId) {
26796
26950
  };
26797
26951
  initProvider();
26798
26952
  return () => {
26799
- console.warn("TRON WalletConnect useEffect CLEANUP running");
26953
+ cancelled = true;
26800
26954
  if (abortControllerRef.current) {
26801
26955
  abortControllerRef.current.abort();
26802
26956
  }
26803
- if (providerRef.current) {
26804
- console.warn("TRON WalletConnect: disconnecting provider in cleanup");
26805
- providerRef.current.disconnect();
26806
- }
26807
26957
  if (modalRef.current) {
26808
26958
  modalRef.current.closeModal();
26809
26959
  }
26960
+ providerRef.current = null;
26961
+ modalRef.current = null;
26810
26962
  };
26811
26963
  }, [projectId, setAddress]);
26812
26964
  React.useEffect(() => {
@@ -27193,7 +27345,7 @@ function useUrlSync(options) {
27193
27345
  const EvaaBridgeWithProviders = (props) => {
27194
27346
  const [tonConnectUI] = uiReact.useTonConnectUI();
27195
27347
  const tonAddress = uiReact.useTonAddress();
27196
- const { address: evmAddress, isConnected: evmIsConnected } = wagmi.useAccount();
27348
+ const { address: evmAddress, isConnected: evmIsConnected, isReconnecting: evmIsReconnecting } = wagmi.useAccount();
27197
27349
  const wagmiConfig = wagmi.useConfig();
27198
27350
  const { disconnect: evmDisconnect } = wagmi.useDisconnect();
27199
27351
  const { data: walletClient } = wagmi.useWalletClient();
@@ -27257,6 +27409,7 @@ const EvaaBridgeWithProviders = (props) => {
27257
27409
  evmWallet: {
27258
27410
  address: evmAddress,
27259
27411
  isConnected: evmIsConnected,
27412
+ isReconnecting: evmIsReconnecting,
27260
27413
  disconnect: evmDisconnect,
27261
27414
  walletClient,
27262
27415
  publicClient,
@@ -27334,12 +27487,12 @@ const EvaaBridgeContent = ({
27334
27487
  );
27335
27488
  const outputAmount = React.useMemo(() => {
27336
27489
  if (!quote || loading) return "";
27337
- const srcToken = resolveTokenOnChainFromMatrix$1(
27490
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
27338
27491
  assetMatrix,
27339
27492
  selectedAssetSymbol,
27340
27493
  fromChain?.chainKey
27341
27494
  );
27342
- const dstToken = resolveTokenOnChainFromMatrix$1(
27495
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
27343
27496
  assetMatrix,
27344
27497
  selectedAssetSymbol,
27345
27498
  toChain?.chainKey
@@ -27510,6 +27663,8 @@ exports.makeTokenBalanceKey = makeTokenBalanceKey;
27510
27663
  exports.normalizeTickerSymbol = normalizeTickerSymbol;
27511
27664
  exports.pollUntilDelivered = pollUntilDelivered;
27512
27665
  exports.reportBridgeTransaction = reportBridgeTransaction;
27666
+ exports.resolveBridgeDestinationTokenOnChainFromMatrix = resolveBridgeDestinationTokenOnChainFromMatrix;
27667
+ exports.resolveBridgeSourceTokenOnChainFromMatrix = resolveBridgeSourceTokenOnChainFromMatrix;
27513
27668
  exports.resolveTokenOnChain = resolveTokenOnChain;
27514
27669
  exports.resolveTokenOnChainFromMatrix = resolveTokenOnChainFromMatrix$1;
27515
27670
  exports.toLD = toLD;
@@ -27524,4 +27679,4 @@ exports.useSettingsStore = useSettingsStore;
27524
27679
  exports.useSwapModel = useSwapModel;
27525
27680
  exports.useTokensStore = useTokensStore;
27526
27681
  exports.useTransactionStore = useTransactionStore;
27527
- //# sourceMappingURL=index-CytmPXNr.cjs.map
27682
+ //# sourceMappingURL=index-CCiUu9QP.cjs.map