@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.
@@ -1071,6 +1071,7 @@ const useTokensStore = create((set2) => ({
1071
1071
  });
1072
1072
  }
1073
1073
  }));
1074
+ const STARGATE_API_BASE_URL = "https://stargate-archive.vercel.app/api/";
1074
1075
  const ALLOWED_TO_CHAINS = /* @__PURE__ */ new Set([
1075
1076
  "ethereum",
1076
1077
  "manta",
@@ -1115,7 +1116,7 @@ function isAllowedToChain(chainKey) {
1115
1116
  return ALLOWED_TO_CHAINS.has(chainKey);
1116
1117
  }
1117
1118
  async function getChains() {
1118
- const res = await fetch("https://stargate.finance/api/v1/chains", {
1119
+ const res = await fetch(`${STARGATE_API_BASE_URL}v1/chains`, {
1119
1120
  credentials: "same-origin"
1120
1121
  });
1121
1122
  if (!res.ok) {
@@ -1126,7 +1127,7 @@ async function getChains() {
1126
1127
  return all.filter((c2) => ALLOWED_TO_CHAINS.has(c2.chainKey));
1127
1128
  }
1128
1129
  async function getTokens() {
1129
- const res = await fetch("https://stargate.finance/api/v1/tokens", {
1130
+ const res = await fetch(`${STARGATE_API_BASE_URL}v1/tokens`, {
1130
1131
  credentials: "same-origin"
1131
1132
  });
1132
1133
  if (!res.ok) {
@@ -1137,7 +1138,7 @@ async function getTokens() {
1137
1138
  return tokens.map(normalizeTokenSymbol);
1138
1139
  }
1139
1140
  async function getDestTokens(srcChainKey, srcTokenAddr) {
1140
- const url = new URL("https://stargate.finance/api/v1/tokens");
1141
+ const url = new URL(`${STARGATE_API_BASE_URL}v1/tokens`);
1141
1142
  url.searchParams.set("srcChainKey", srcChainKey);
1142
1143
  url.searchParams.set("srcToken", srcTokenAddr);
1143
1144
  const res = await fetch(url.toString(), { credentials: "omit" });
@@ -1334,9 +1335,14 @@ const ChainSelectModal = ({
1334
1335
  const switchToEquivalentIfNeeded = useCallback(
1335
1336
  (chainKey) => {
1336
1337
  if (!selectedAssetSymbol || !assetMatrix) return;
1337
- const effectiveSym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, chainKey);
1338
- if (effectiveSym !== selectedAssetSymbol.toUpperCase()) {
1339
- setSelectedAssetSymbol(effectiveSym);
1338
+ const hasDirectToken = !!assetMatrix[selectedAssetSymbol.toUpperCase()]?.[chainKey];
1339
+ if (!hasDirectToken) {
1340
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
1341
+ if (assetMatrix[eq]?.[chainKey]) {
1342
+ setSelectedAssetSymbol(eq);
1343
+ break;
1344
+ }
1345
+ }
1340
1346
  }
1341
1347
  },
1342
1348
  [selectedAssetSymbol, assetMatrix, setSelectedAssetSymbol]
@@ -1656,6 +1662,7 @@ const WalletInlineButton = ({
1656
1662
  const connection = chainRegistry.getStrategyByType(walletType);
1657
1663
  const account = connection?.getAccount();
1658
1664
  const isConnected = connection?.isConnected();
1665
+ const isReconnecting = connection?.isConnecting();
1659
1666
  const error = connection?.getError();
1660
1667
  const availableConnections = useMemo(
1661
1668
  () => connection?.getAvailableConnections() ?? [],
@@ -1679,10 +1686,11 @@ const WalletInlineButton = ({
1679
1686
  }, [onOpen, addressType]);
1680
1687
  const buttonText = useMemo(() => {
1681
1688
  if (isConnected && account) return formatAddress(account);
1689
+ if (isReconnecting) return t2("wallets.reconnecting") ?? "Reconnecting...";
1682
1690
  if (wallet === "ton") return t2("wallets.addTonWallet");
1683
1691
  if (wallet === "tronlink") return t2("wallets.addTronWallet");
1684
1692
  return t2("wallets.addEvmWallet");
1685
- }, [wallet, isConnected, account, t2]);
1693
+ }, [wallet, isConnected, isReconnecting, account, t2]);
1686
1694
  const connectedIcon = useMemo(() => {
1687
1695
  if (!isConnected) return null;
1688
1696
  if (walletType === "tron" && activeTronConnection) {
@@ -2253,7 +2261,7 @@ async function fetchQuotes(req) {
2253
2261
  if (req.dstNativeAmount && req.dstNativeAmount !== "0")
2254
2262
  params.dstNativeAmount = req.dstNativeAmount;
2255
2263
  if (req.slippage && req.slippage > 0) params.slippage = String(req.slippage);
2256
- const url = `https://stargate.finance/api/v1/quotes?${new URLSearchParams(
2264
+ const url = `${STARGATE_API_BASE_URL}v1/quotes?${new URLSearchParams(
2257
2265
  params
2258
2266
  ).toString()}`;
2259
2267
  const res = await fetch(url);
@@ -2303,6 +2311,21 @@ function resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey) {
2303
2311
  const byChain = assetMatrix[assetSymbol.toUpperCase()];
2304
2312
  return byChain?.[chainKey];
2305
2313
  }
2314
+ function resolveBridgeSourceTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2315
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2316
+ const resolvedSymbol = getBridgeTokenSymbol(assetSymbol, assetMatrix, chainKey);
2317
+ return resolveTokenOnChainFromMatrix$1(assetMatrix, resolvedSymbol, chainKey);
2318
+ }
2319
+ function resolveBridgeDestinationTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2320
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2321
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey);
2322
+ if (direct) return direct;
2323
+ for (const eq of getEquivalentSymbols(assetSymbol)) {
2324
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, chainKey);
2325
+ if (eqToken) return eqToken;
2326
+ }
2327
+ return void 0;
2328
+ }
2306
2329
  const DEFAULT_SLIPPAGE_BPS = 50;
2307
2330
  const lower = (s2) => (s2 ?? "").toLowerCase();
2308
2331
  const normSym = (s2) => (s2 ?? "").toUpperCase().replace(/₮/g, "T").replace(/[^A-Z0-9]/g, "");
@@ -2649,12 +2672,25 @@ function useBridgeQuote() {
2649
2672
  const srcTokenOnFrom = useMemo(() => {
2650
2673
  if (!assetMatrix || !selectedAssetSymbol || !fromChain?.chainKey) return void 0;
2651
2674
  const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, fromChain.chainKey);
2652
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2675
+ const token = resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2676
+ console.log("[quote] srcToken", { selected: selectedAssetSymbol, resolved: sym, chain: fromChain.chainKey, addr: token?.address });
2677
+ return token;
2653
2678
  }, [assetMatrix, selectedAssetSymbol, fromChain?.chainKey]);
2654
2679
  const dstTokenOnTo = useMemo(() => {
2655
2680
  if (!assetMatrix || !selectedAssetSymbol || !toChain?.chainKey) return void 0;
2656
- const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, toChain.chainKey);
2657
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, toChain.chainKey);
2681
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, selectedAssetSymbol, toChain.chainKey);
2682
+ if (direct) {
2683
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: selectedAssetSymbol, chain: toChain.chainKey, addr: direct.address });
2684
+ return direct;
2685
+ }
2686
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
2687
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, toChain.chainKey);
2688
+ if (eqToken) {
2689
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: eq, chain: toChain.chainKey, addr: eqToken.address });
2690
+ return eqToken;
2691
+ }
2692
+ }
2693
+ return void 0;
2658
2694
  }, [assetMatrix, selectedAssetSymbol, toChain?.chainKey]);
2659
2695
  const [loading, setLoading] = useState(false);
2660
2696
  useEffect(() => {
@@ -3875,12 +3911,12 @@ function useFeeBreakdown() {
3875
3911
  const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
3876
3912
  const { fromChain, toChain, chains } = useChainsStore();
3877
3913
  return useMemo(() => {
3878
- const srcToken = resolveTokenOnChainFromMatrix$1(
3914
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
3879
3915
  assetMatrix,
3880
3916
  selectedAssetSymbol,
3881
3917
  fromChain?.chainKey
3882
3918
  );
3883
- const dstToken = resolveTokenOnChainFromMatrix$1(
3919
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3884
3920
  assetMatrix,
3885
3921
  selectedAssetSymbol,
3886
3922
  toChain?.chainKey
@@ -3957,12 +3993,12 @@ function buildBridgeExternalData({
3957
3993
  dstChain: toChain?.chainKey,
3958
3994
  amount: normalizedAmount || void 0
3959
3995
  };
3960
- const sourceToken = resolveTokenOnChainFromMatrix$1(
3996
+ const sourceToken = resolveBridgeSourceTokenOnChainFromMatrix(
3961
3997
  assetMatrix,
3962
3998
  selectedAssetSymbol,
3963
3999
  fromChain?.chainKey
3964
4000
  );
3965
- const destinationToken = resolveTokenOnChainFromMatrix$1(
4001
+ const destinationToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3966
4002
  assetMatrix,
3967
4003
  selectedAssetSymbol,
3968
4004
  toChain?.chainKey
@@ -4431,9 +4467,9 @@ async function getDeliveryStatus(params) {
4431
4467
  if (params.dstChainKey) query.set("dstChainKey", params.dstChainKey);
4432
4468
  query.set("srcTxHash", params.srcTxHash);
4433
4469
  const bases2 = [
4434
- `https://stargate.finance/api/v1/transactions?${query.toString()}`,
4435
- `https://stargate.finance/api/v1/txStatus?${query.toString()}`,
4436
- `https://stargate.finance/api/v1/messageStatus?${query.toString()}`
4470
+ `${STARGATE_API_BASE_URL}v1/transactions?${query.toString()}`,
4471
+ `${STARGATE_API_BASE_URL}v1/txStatus?${query.toString()}`,
4472
+ `${STARGATE_API_BASE_URL}v1/messageStatus?${query.toString()}`
4437
4473
  ];
4438
4474
  for (const url of bases2) {
4439
4475
  const json = await tryFetch(url);
@@ -4896,8 +4932,13 @@ function useSilentValidations(amountString) {
4896
4932
  const hasTooManyDecimals = (() => {
4897
4933
  if (!amountString || !fromChain?.chainKey || !selectedAssetSymbol)
4898
4934
  return false;
4935
+ const resolvedSym = getBridgeTokenSymbol(
4936
+ selectedAssetSymbol,
4937
+ assetMatrix,
4938
+ fromChain.chainKey
4939
+ );
4899
4940
  const sourceToken = tokens?.find(
4900
- (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === (selectedAssetSymbol ?? "").toUpperCase()
4941
+ (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === resolvedSym
4901
4942
  );
4902
4943
  if (!sourceToken) return false;
4903
4944
  const decimalPart = amountString.split(".")[1];
@@ -4908,11 +4949,18 @@ function useSilentValidations(amountString) {
4908
4949
  if (!selectedAssetSymbol || !fromChain?.chainKey || !toChain?.chainKey)
4909
4950
  return false;
4910
4951
  if (!assetMatrix) return false;
4911
- const normalizedSymbol = selectedAssetSymbol.toUpperCase();
4912
- const tokenMatrix = assetMatrix[normalizedSymbol];
4913
- if (!tokenMatrix) return true;
4914
- const existsOnSource = !!tokenMatrix[fromChain.chainKey];
4915
- const existsOnDestination = !!tokenMatrix[toChain.chainKey];
4952
+ const allSymbols = [
4953
+ selectedAssetSymbol.toUpperCase(),
4954
+ ...getEquivalentSymbols(selectedAssetSymbol).map(
4955
+ (s2) => s2.toUpperCase()
4956
+ )
4957
+ ];
4958
+ const existsOnSource = allSymbols.some(
4959
+ (sym) => !!assetMatrix[sym]?.[fromChain.chainKey]
4960
+ );
4961
+ const existsOnDestination = allSymbols.some(
4962
+ (sym) => !!assetMatrix[sym]?.[toChain.chainKey]
4963
+ );
4916
4964
  return !existsOnSource || !existsOnDestination;
4917
4965
  })();
4918
4966
  const hasInsufficientLiquidity = (() => {
@@ -5244,7 +5292,7 @@ const WalletSelectModal = () => {
5244
5292
  const { t: t2 } = useBridgeTranslation();
5245
5293
  const { isOpen, onClose } = useWalletSelectModal();
5246
5294
  const { connectors } = useConnect();
5247
- const { address: evmAddress, connector: connectedConnector } = useAccount();
5295
+ const { address: evmAddress, connector: connectedConnector, isReconnecting: evmIsReconnecting } = useAccount();
5248
5296
  const { chainRegistry } = useChainStrategies();
5249
5297
  const tonWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.TON);
5250
5298
  const metaMaskWallet = chainRegistry.getStrategyByType(CHAIN_TYPES.EVM);
@@ -5288,6 +5336,14 @@ const WalletSelectModal = () => {
5288
5336
  address: evmAddress,
5289
5337
  onDisconnect: () => metaMaskWallet?.disconnect()
5290
5338
  });
5339
+ } else if (evmIsReconnecting) {
5340
+ evmConnectedWallets.push({
5341
+ id: "walletConnect",
5342
+ name: t2("wallets.reconnecting") || "Reconnecting...",
5343
+ icon: WalletConnectIcon,
5344
+ address: "...",
5345
+ onDisconnect: () => metaMaskWallet?.disconnect()
5346
+ });
5291
5347
  }
5292
5348
  const tronConnectedWallets = [];
5293
5349
  tronConnections.forEach((connection) => {
@@ -5309,7 +5365,7 @@ const WalletSelectModal = () => {
5309
5365
  enabled: true
5310
5366
  }
5311
5367
  ];
5312
- const evmWallets = evmConnectedWallets.length > 0 ? [] : connectors.filter(
5368
+ const evmWallets = evmConnectedWallets.length > 0 || evmIsReconnecting ? [] : connectors.filter(
5313
5369
  (connector) => connector.id === "walletConnect" || connector.id === "metaMaskSDK"
5314
5370
  ).map((connector) => ({
5315
5371
  id: connector.id,
@@ -5841,7 +5897,7 @@ class EvmChainStrategy {
5841
5897
  return !!this.config.evmIsConnected;
5842
5898
  }
5843
5899
  isConnecting() {
5844
- return false;
5900
+ return !!this.config.evmIsReconnecting;
5845
5901
  }
5846
5902
  getAccount() {
5847
5903
  return this.config.evmAddress || null;
@@ -5858,15 +5914,49 @@ class EvmChainStrategy {
5858
5914
  getClient() {
5859
5915
  return this.walletClient;
5860
5916
  }
5861
- async getBalances(address, tokens) {
5862
- const chainKey = tokens[0]?.chainKey;
5917
+ resolvePublicClientForChain(chainKey) {
5863
5918
  let client = this.publicClient;
5864
- if (chainKey && this.config.getPublicClientForChain && this.config.chainKeyToId) {
5865
- const chainId = this.config.chainKeyToId[chainKey.toLowerCase()];
5866
- if (chainId) {
5867
- client = this.config.getPublicClientForChain(chainId) ?? client;
5868
- }
5919
+ if (!chainKey || !this.config.getPublicClientForChain || !this.config.chainKeyToId) {
5920
+ return client;
5921
+ }
5922
+ const chainId = this.config.chainKeyToId[chainKey.toLowerCase()];
5923
+ if (!chainId) {
5924
+ return client;
5925
+ }
5926
+ client = this.config.getPublicClientForChain(chainId) ?? client;
5927
+ return client;
5928
+ }
5929
+ getRpcErrorDetails(error) {
5930
+ if (error instanceof Error) {
5931
+ const rpcError = error;
5932
+ return {
5933
+ code: rpcError.code,
5934
+ message: rpcError.message,
5935
+ shortMessage: rpcError.shortMessage,
5936
+ details: rpcError.details
5937
+ };
5869
5938
  }
5939
+ if (typeof error === "object" && error !== null) {
5940
+ const candidate = error;
5941
+ return {
5942
+ code: typeof candidate.code === "number" ? candidate.code : void 0,
5943
+ message: typeof candidate.message === "string" ? candidate.message : String(error),
5944
+ shortMessage: typeof candidate.shortMessage === "string" ? candidate.shortMessage : void 0,
5945
+ details: typeof candidate.details === "string" ? candidate.details : void 0
5946
+ };
5947
+ }
5948
+ return { message: String(error) };
5949
+ }
5950
+ logRpcWarning(context, error, extra) {
5951
+ const rpcError = this.getRpcErrorDetails(error);
5952
+ console.warn(`[evm] ${context}`, {
5953
+ ...extra,
5954
+ ...rpcError
5955
+ });
5956
+ }
5957
+ async getBalances(address, tokens) {
5958
+ const chainKey = tokens[0]?.chainKey;
5959
+ const client = this.resolvePublicClientForChain(chainKey);
5870
5960
  if (!client) {
5871
5961
  return {};
5872
5962
  }
@@ -5905,7 +5995,7 @@ class EvmChainStrategy {
5905
5995
  }
5906
5996
  }
5907
5997
  async estimateNetworkFee(steps) {
5908
- if (!this.walletClient) {
5998
+ if (!this.config.evmAddress) {
5909
5999
  return 0;
5910
6000
  }
5911
6001
  const account = this.config.evmAddress;
@@ -5922,23 +6012,67 @@ class EvmChainStrategy {
5922
6012
  return (feePerGas * scaled + 99n) / 100n;
5923
6013
  };
5924
6014
  let totalFeeWei = 0n;
5925
- for (const step of txSteps) {
6015
+ for (let i3 = 0; i3 < txSteps.length; i3++) {
6016
+ const step = txSteps[i3];
5926
6017
  const tx = step.transaction;
5927
6018
  if (!tx?.to) continue;
6019
+ const client = this.resolvePublicClientForChain(step.chainKey);
6020
+ if (!client) {
6021
+ this.logRpcWarning("Skipped network fee estimation: no public client", "no-client", {
6022
+ chainKey: step.chainKey,
6023
+ stepType: step.type,
6024
+ stepIndex: i3 + 1,
6025
+ totalSteps: txSteps.length
6026
+ });
6027
+ continue;
6028
+ }
5928
6029
  try {
5929
- const request = await this.walletClient.prepareTransactionRequest({
6030
+ const gas = await client.estimateGas({
5930
6031
  account: tx.from || account,
5931
6032
  to: tx.to,
5932
6033
  data: tx.data,
5933
- value: tx.value ? BigInt(tx.value) : void 0,
5934
- chain: this.walletClient.chain
6034
+ value: tx.value ? BigInt(tx.value) : void 0
5935
6035
  });
5936
- const gasLimit = request.gas;
5937
- const maxFeePerGas = request.maxFeePerGas ?? request.gasPrice;
5938
- if (gasLimit && maxFeePerGas) {
5939
- totalFeeWei += gasLimit * applyFeeMultiplier(maxFeePerGas);
6036
+ let feePerGas;
6037
+ try {
6038
+ const estimatedFees = await client.estimateFeesPerGas();
6039
+ feePerGas = estimatedFees.maxFeePerGas ?? estimatedFees.gasPrice;
6040
+ } catch (feeError) {
6041
+ this.logRpcWarning(
6042
+ "Failed to estimate fees per gas, falling back to gas price",
6043
+ feeError,
6044
+ {
6045
+ chainKey: step.chainKey,
6046
+ stepType: step.type,
6047
+ stepIndex: i3 + 1,
6048
+ totalSteps: txSteps.length
6049
+ }
6050
+ );
6051
+ try {
6052
+ feePerGas = await client.getGasPrice();
6053
+ } catch (gasPriceError) {
6054
+ this.logRpcWarning("Failed to get gas price for network fee estimation", gasPriceError, {
6055
+ chainKey: step.chainKey,
6056
+ stepType: step.type,
6057
+ stepIndex: i3 + 1,
6058
+ totalSteps: txSteps.length
6059
+ });
6060
+ }
5940
6061
  }
5941
- } catch {
6062
+ if (gas && feePerGas) {
6063
+ totalFeeWei += gas * applyFeeMultiplier(feePerGas);
6064
+ }
6065
+ } catch (error) {
6066
+ this.logRpcWarning("Failed to estimate gas for network fee", error, {
6067
+ chainKey: step.chainKey,
6068
+ stepType: step.type,
6069
+ stepIndex: i3 + 1,
6070
+ totalSteps: txSteps.length,
6071
+ to: tx.to,
6072
+ from: tx.from || account,
6073
+ hasData: Boolean(tx.data),
6074
+ hasValue: Boolean(tx.value)
6075
+ });
5942
6076
  }
5943
6077
  }
5944
6078
  if (totalFeeWei === 0n) {
@@ -7143,6 +7277,7 @@ function ChainStrategyProvider({
7143
7277
  () => new EvmChainStrategy({
7144
7278
  evmAddress: evmWallet.address,
7145
7279
  evmIsConnected: evmWallet.isConnected,
7280
+ evmIsReconnecting: evmWallet.isReconnecting,
7146
7281
  evmDisconnect: evmWallet.disconnect,
7147
7282
  walletClient: evmWallet.walletClient,
7148
7283
  publicClient: evmWallet.publicClient,
@@ -7152,6 +7287,7 @@ function ChainStrategyProvider({
7152
7287
  [
7153
7288
  evmWallet.address,
7154
7289
  evmWallet.isConnected,
7290
+ evmWallet.isReconnecting,
7155
7291
  evmWallet.disconnect,
7156
7292
  evmWallet.walletClient,
7157
7293
  evmWallet.publicClient,
@@ -26604,7 +26740,7 @@ class WalletConnectModal {
26604
26740
  }
26605
26741
  async initUi() {
26606
26742
  if (typeof window !== "undefined") {
26607
- await import("./index-B1odZ4FL.js");
26743
+ await import("./index-CZGfdIKB.js");
26608
26744
  const modal = document.createElement("wcm-modal");
26609
26745
  document.body.insertAdjacentElement("beforeend", modal);
26610
26746
  OptionsCtrl.setIsUiLoaded(true);
@@ -26721,10 +26857,12 @@ function useTronWalletConnect(projectId) {
26721
26857
  appliedThemeRef.current = appliedTheme;
26722
26858
  useEffect(() => {
26723
26859
  if (!projectId || providerRef.current) return;
26860
+ let cancelled = false;
26724
26861
  const initProvider = async () => {
26725
26862
  try {
26726
26863
  const provider = await N.init({
26727
26864
  projectId,
26865
+ name: "evaa-bridge-tron",
26728
26866
  metadata: {
26729
26867
  name: "EVAA Bridge",
26730
26868
  description: "Cross-chain bridge powered by Stargate Protocol",
@@ -26732,6 +26870,7 @@ function useTronWalletConnect(projectId) {
26732
26870
  icons: [`${window.location.origin}/favicon.ico`]
26733
26871
  }
26734
26872
  });
26873
+ if (cancelled) return;
26735
26874
  providerRef.current = provider;
26736
26875
  if (projectId) {
26737
26876
  const modal = new WalletConnectModal({
@@ -26761,17 +26900,32 @@ function useTronWalletConnect(projectId) {
26761
26900
  console.log("TRON WalletConnect session deleted");
26762
26901
  setAddress(null);
26763
26902
  });
26764
- if (provider.session) {
26765
- const accounts = provider.session.namespaces?.tron?.accounts || [];
26766
- if (accounts.length > 0) {
26767
- const account = accounts[0];
26768
- const extractedAddress = account.split(":")[2];
26769
- console.log(
26770
- "TRON WalletConnect restored session:",
26771
- extractedAddress
26772
- );
26903
+ let tronAccounts = [];
26904
+ if (provider.session?.namespaces?.tron?.accounts?.length) {
26905
+ tronAccounts = provider.session.namespaces.tron.accounts;
26906
+ console.log("TRON WalletConnect: found session via provider.session");
26907
+ } else if (provider.client?.session) {
26908
+ const allSessions = provider.client.session.getAll();
26909
+ console.log("TRON WalletConnect: searching all sessions, count:", allSessions.length);
26910
+ const tronSession = allSessions.find(
26911
+ (s2) => s2.namespaces?.tron?.accounts?.length
26912
+ );
26913
+ if (tronSession) {
26914
+ tronAccounts = tronSession.namespaces.tron.accounts;
26915
+ console.log("TRON WalletConnect: found tron session in all sessions");
26916
+ }
26917
+ }
26918
+ if (tronAccounts.length > 0) {
26919
+ const extractedAddress = tronAccounts[0].split(":")[2];
26920
+ console.log(
26921
+ "TRON WalletConnect restored session:",
26922
+ extractedAddress
26923
+ );
26924
+ if (!cancelled) {
26773
26925
  setAddress(extractedAddress);
26774
26926
  }
26927
+ } else {
26928
+ console.log("TRON WalletConnect: no tron session found to restore");
26775
26929
  }
26776
26930
  } catch (error) {
26777
26931
  console.error("Failed to initialize TRON WalletConnect:", error);
@@ -26779,17 +26933,15 @@ function useTronWalletConnect(projectId) {
26779
26933
  };
26780
26934
  initProvider();
26781
26935
  return () => {
26782
- console.warn("TRON WalletConnect useEffect CLEANUP running");
26936
+ cancelled = true;
26783
26937
  if (abortControllerRef.current) {
26784
26938
  abortControllerRef.current.abort();
26785
26939
  }
26786
- if (providerRef.current) {
26787
- console.warn("TRON WalletConnect: disconnecting provider in cleanup");
26788
- providerRef.current.disconnect();
26789
- }
26790
26940
  if (modalRef.current) {
26791
26941
  modalRef.current.closeModal();
26792
26942
  }
26943
+ providerRef.current = null;
26944
+ modalRef.current = null;
26793
26945
  };
26794
26946
  }, [projectId, setAddress]);
26795
26947
  useEffect(() => {
@@ -27176,7 +27328,7 @@ function useUrlSync(options) {
27176
27328
  const EvaaBridgeWithProviders = (props) => {
27177
27329
  const [tonConnectUI] = useTonConnectUI();
27178
27330
  const tonAddress = useTonAddress();
27179
- const { address: evmAddress, isConnected: evmIsConnected } = useAccount();
27331
+ const { address: evmAddress, isConnected: evmIsConnected, isReconnecting: evmIsReconnecting } = useAccount();
27180
27332
  const wagmiConfig = useConfig();
27181
27333
  const { disconnect: evmDisconnect } = useDisconnect();
27182
27334
  const { data: walletClient } = useWalletClient();
@@ -27240,6 +27392,7 @@ const EvaaBridgeWithProviders = (props) => {
27240
27392
  evmWallet: {
27241
27393
  address: evmAddress,
27242
27394
  isConnected: evmIsConnected,
27395
+ isReconnecting: evmIsReconnecting,
27243
27396
  disconnect: evmDisconnect,
27244
27397
  walletClient,
27245
27398
  publicClient,
@@ -27317,12 +27470,12 @@ const EvaaBridgeContent = ({
27317
27470
  );
27318
27471
  const outputAmount = useMemo(() => {
27319
27472
  if (!quote || loading) return "";
27320
- const srcToken = resolveTokenOnChainFromMatrix$1(
27473
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
27321
27474
  assetMatrix,
27322
27475
  selectedAssetSymbol,
27323
27476
  fromChain?.chainKey
27324
27477
  );
27325
- const dstToken = resolveTokenOnChainFromMatrix$1(
27478
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
27326
27479
  assetMatrix,
27327
27480
  selectedAssetSymbol,
27328
27481
  toChain?.chainKey
@@ -27445,7 +27598,7 @@ const EvaaBridgeContent = ({
27445
27598
  };
27446
27599
  const EvaaBridge = EvaaBridgeWithProviders;
27447
27600
  export {
27448
- getDestTokens as $,
27601
+ getChains as $,
27449
27602
  getRouteDisplayName as A,
27450
27603
  computeFeeBreakdownUsd as B,
27451
27604
  ConfigCtrl as C,
@@ -27457,32 +27610,34 @@ export {
27457
27610
  listAssetsForSelect as I,
27458
27611
  resolveTokenOnChain as J,
27459
27612
  resolveTokenOnChainFromMatrix$1 as K,
27460
- DEFAULT_SLIPPAGE_BPS as L,
27613
+ resolveBridgeSourceTokenOnChainFromMatrix as L,
27461
27614
  ModalCtrl as M,
27462
- tonNorm as N,
27615
+ resolveBridgeDestinationTokenOnChainFromMatrix as N,
27463
27616
  OptionsCtrl as O,
27464
- isZeroAddr as P,
27465
- addrForApi as Q,
27617
+ DEFAULT_SLIPPAGE_BPS as P,
27618
+ tonNorm as Q,
27466
27619
  RouterCtrl as R,
27467
- isNativeAddrEqual as S,
27620
+ isZeroAddr as S,
27468
27621
  ToastCtrl as T,
27469
- findNativeMeta as U,
27470
- lookupTokenMeta as V,
27471
- normalizeTickerSymbol as W,
27472
- isAllowedFromChain as X,
27473
- isAllowedToChain as Y,
27474
- getChains as Z,
27475
- getTokens as _,
27622
+ addrForApi as U,
27623
+ isNativeAddrEqual as V,
27624
+ findNativeMeta as W,
27625
+ lookupTokenMeta as X,
27626
+ normalizeTickerSymbol as Y,
27627
+ isAllowedFromChain as Z,
27628
+ isAllowedToChain as _,
27476
27629
  ThemeCtrl as a,
27477
- getQuotesByPriority as a0,
27478
- isNativeAddress as a1,
27479
- makeTokenBalanceKey as a2,
27480
- getEvmBalances as a3,
27481
- getTonBalances as a4,
27482
- getTronBalances as a5,
27483
- getDeliveryStatus as a6,
27484
- pollUntilDelivered as a7,
27485
- reportBridgeTransaction as a8,
27630
+ getTokens as a0,
27631
+ getDestTokens as a1,
27632
+ getQuotesByPriority as a2,
27633
+ isNativeAddress as a3,
27634
+ makeTokenBalanceKey as a4,
27635
+ getEvmBalances as a5,
27636
+ getTonBalances as a6,
27637
+ getTronBalances as a7,
27638
+ getDeliveryStatus as a8,
27639
+ pollUntilDelivered as a9,
27640
+ reportBridgeTransaction as aa,
27486
27641
  ExplorerCtrl as b,
27487
27642
  CoreUtil as c,
27488
27643
  EvaaBridge as d,
@@ -27509,4 +27664,4 @@ export {
27509
27664
  calculateMinReceived as y,
27510
27665
  getQuoteDetails as z
27511
27666
  };
27512
- //# sourceMappingURL=index-BIpr23sm.js.map
27667
+ //# sourceMappingURL=index-JmSrX7Hz.js.map