@rash2x/bridge-widget 0.8.5 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1334,9 +1334,14 @@ const ChainSelectModal = ({
1334
1334
  const switchToEquivalentIfNeeded = useCallback(
1335
1335
  (chainKey) => {
1336
1336
  if (!selectedAssetSymbol || !assetMatrix) return;
1337
- const effectiveSym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, chainKey);
1338
- if (effectiveSym !== selectedAssetSymbol.toUpperCase()) {
1339
- setSelectedAssetSymbol(effectiveSym);
1337
+ const hasDirectToken = !!assetMatrix[selectedAssetSymbol.toUpperCase()]?.[chainKey];
1338
+ if (!hasDirectToken) {
1339
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
1340
+ if (assetMatrix[eq]?.[chainKey]) {
1341
+ setSelectedAssetSymbol(eq);
1342
+ break;
1343
+ }
1344
+ }
1340
1345
  }
1341
1346
  },
1342
1347
  [selectedAssetSymbol, assetMatrix, setSelectedAssetSymbol]
@@ -2303,6 +2308,21 @@ function resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey) {
2303
2308
  const byChain = assetMatrix[assetSymbol.toUpperCase()];
2304
2309
  return byChain?.[chainKey];
2305
2310
  }
2311
+ function resolveBridgeSourceTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2312
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2313
+ const resolvedSymbol = getBridgeTokenSymbol(assetSymbol, assetMatrix, chainKey);
2314
+ return resolveTokenOnChainFromMatrix$1(assetMatrix, resolvedSymbol, chainKey);
2315
+ }
2316
+ function resolveBridgeDestinationTokenOnChainFromMatrix(assetMatrix, assetSymbol, chainKey) {
2317
+ if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
2318
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey);
2319
+ if (direct) return direct;
2320
+ for (const eq of getEquivalentSymbols(assetSymbol)) {
2321
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, chainKey);
2322
+ if (eqToken) return eqToken;
2323
+ }
2324
+ return void 0;
2325
+ }
2306
2326
  const DEFAULT_SLIPPAGE_BPS = 50;
2307
2327
  const lower = (s2) => (s2 ?? "").toLowerCase();
2308
2328
  const normSym = (s2) => (s2 ?? "").toUpperCase().replace(/₮/g, "T").replace(/[^A-Z0-9]/g, "");
@@ -2649,12 +2669,25 @@ function useBridgeQuote() {
2649
2669
  const srcTokenOnFrom = useMemo(() => {
2650
2670
  if (!assetMatrix || !selectedAssetSymbol || !fromChain?.chainKey) return void 0;
2651
2671
  const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, fromChain.chainKey);
2652
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2672
+ const token = resolveTokenOnChainFromMatrix$1(assetMatrix, sym, fromChain.chainKey);
2673
+ console.log("[quote] srcToken", { selected: selectedAssetSymbol, resolved: sym, chain: fromChain.chainKey, addr: token?.address });
2674
+ return token;
2653
2675
  }, [assetMatrix, selectedAssetSymbol, fromChain?.chainKey]);
2654
2676
  const dstTokenOnTo = useMemo(() => {
2655
2677
  if (!assetMatrix || !selectedAssetSymbol || !toChain?.chainKey) return void 0;
2656
- const sym = getBridgeTokenSymbol(selectedAssetSymbol, assetMatrix, toChain.chainKey);
2657
- return resolveTokenOnChainFromMatrix$1(assetMatrix, sym, toChain.chainKey);
2678
+ const direct = resolveTokenOnChainFromMatrix$1(assetMatrix, selectedAssetSymbol, toChain.chainKey);
2679
+ if (direct) {
2680
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: selectedAssetSymbol, chain: toChain.chainKey, addr: direct.address });
2681
+ return direct;
2682
+ }
2683
+ for (const eq of getEquivalentSymbols(selectedAssetSymbol)) {
2684
+ const eqToken = resolveTokenOnChainFromMatrix$1(assetMatrix, eq, toChain.chainKey);
2685
+ if (eqToken) {
2686
+ console.log("[quote] dstToken", { selected: selectedAssetSymbol, resolved: eq, chain: toChain.chainKey, addr: eqToken.address });
2687
+ return eqToken;
2688
+ }
2689
+ }
2690
+ return void 0;
2658
2691
  }, [assetMatrix, selectedAssetSymbol, toChain?.chainKey]);
2659
2692
  const [loading, setLoading] = useState(false);
2660
2693
  useEffect(() => {
@@ -3875,12 +3908,12 @@ function useFeeBreakdown() {
3875
3908
  const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
3876
3909
  const { fromChain, toChain, chains } = useChainsStore();
3877
3910
  return useMemo(() => {
3878
- const srcToken = resolveTokenOnChainFromMatrix$1(
3911
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
3879
3912
  assetMatrix,
3880
3913
  selectedAssetSymbol,
3881
3914
  fromChain?.chainKey
3882
3915
  );
3883
- const dstToken = resolveTokenOnChainFromMatrix$1(
3916
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3884
3917
  assetMatrix,
3885
3918
  selectedAssetSymbol,
3886
3919
  toChain?.chainKey
@@ -3957,12 +3990,12 @@ function buildBridgeExternalData({
3957
3990
  dstChain: toChain?.chainKey,
3958
3991
  amount: normalizedAmount || void 0
3959
3992
  };
3960
- const sourceToken = resolveTokenOnChainFromMatrix$1(
3993
+ const sourceToken = resolveBridgeSourceTokenOnChainFromMatrix(
3961
3994
  assetMatrix,
3962
3995
  selectedAssetSymbol,
3963
3996
  fromChain?.chainKey
3964
3997
  );
3965
- const destinationToken = resolveTokenOnChainFromMatrix$1(
3998
+ const destinationToken = resolveBridgeDestinationTokenOnChainFromMatrix(
3966
3999
  assetMatrix,
3967
4000
  selectedAssetSymbol,
3968
4001
  toChain?.chainKey
@@ -4590,7 +4623,7 @@ function useBridgeTransaction() {
4590
4623
  const txStore = useTransactionStore();
4591
4624
  const gas = useGasEstimate();
4592
4625
  const srcToken = useMemo(
4593
- () => resolveTokenOnChainFromMatrix$1(
4626
+ () => resolveBridgeSourceTokenOnChainFromMatrix(
4594
4627
  assetMatrix,
4595
4628
  selectedAssetSymbol,
4596
4629
  quote?.srcChainKey
@@ -4598,7 +4631,7 @@ function useBridgeTransaction() {
4598
4631
  [assetMatrix, selectedAssetSymbol, quote?.srcChainKey]
4599
4632
  );
4600
4633
  const dstToken = useMemo(
4601
- () => resolveTokenOnChainFromMatrix$1(
4634
+ () => resolveBridgeDestinationTokenOnChainFromMatrix(
4602
4635
  assetMatrix,
4603
4636
  selectedAssetSymbol,
4604
4637
  quote?.dstChainKey
@@ -4896,8 +4929,13 @@ function useSilentValidations(amountString) {
4896
4929
  const hasTooManyDecimals = (() => {
4897
4930
  if (!amountString || !fromChain?.chainKey || !selectedAssetSymbol)
4898
4931
  return false;
4932
+ const resolvedSym = getBridgeTokenSymbol(
4933
+ selectedAssetSymbol,
4934
+ assetMatrix,
4935
+ fromChain.chainKey
4936
+ );
4899
4937
  const sourceToken = tokens?.find(
4900
- (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === (selectedAssetSymbol ?? "").toUpperCase()
4938
+ (t2) => t2.chainKey === fromChain.chainKey && (t2.symbol ?? "").toUpperCase() === resolvedSym
4901
4939
  );
4902
4940
  if (!sourceToken) return false;
4903
4941
  const decimalPart = amountString.split(".")[1];
@@ -4908,11 +4946,18 @@ function useSilentValidations(amountString) {
4908
4946
  if (!selectedAssetSymbol || !fromChain?.chainKey || !toChain?.chainKey)
4909
4947
  return false;
4910
4948
  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];
4949
+ const allSymbols = [
4950
+ selectedAssetSymbol.toUpperCase(),
4951
+ ...getEquivalentSymbols(selectedAssetSymbol).map(
4952
+ (s2) => s2.toUpperCase()
4953
+ )
4954
+ ];
4955
+ const existsOnSource = allSymbols.some(
4956
+ (sym) => !!assetMatrix[sym]?.[fromChain.chainKey]
4957
+ );
4958
+ const existsOnDestination = allSymbols.some(
4959
+ (sym) => !!assetMatrix[sym]?.[toChain.chainKey]
4960
+ );
4916
4961
  return !existsOnSource || !existsOnDestination;
4917
4962
  })();
4918
4963
  const hasInsufficientLiquidity = (() => {
@@ -26604,7 +26649,7 @@ class WalletConnectModal {
26604
26649
  }
26605
26650
  async initUi() {
26606
26651
  if (typeof window !== "undefined") {
26607
- await import("./index-B1odZ4FL.js");
26652
+ await import("./index-B9_Kn_rc.js");
26608
26653
  const modal = document.createElement("wcm-modal");
26609
26654
  document.body.insertAdjacentElement("beforeend", modal);
26610
26655
  OptionsCtrl.setIsUiLoaded(true);
@@ -27317,12 +27362,12 @@ const EvaaBridgeContent = ({
27317
27362
  );
27318
27363
  const outputAmount = useMemo(() => {
27319
27364
  if (!quote || loading) return "";
27320
- const srcToken = resolveTokenOnChainFromMatrix$1(
27365
+ const srcToken = resolveBridgeSourceTokenOnChainFromMatrix(
27321
27366
  assetMatrix,
27322
27367
  selectedAssetSymbol,
27323
27368
  fromChain?.chainKey
27324
27369
  );
27325
- const dstToken = resolveTokenOnChainFromMatrix$1(
27370
+ const dstToken = resolveBridgeDestinationTokenOnChainFromMatrix(
27326
27371
  assetMatrix,
27327
27372
  selectedAssetSymbol,
27328
27373
  toChain?.chainKey
@@ -27445,7 +27490,7 @@ const EvaaBridgeContent = ({
27445
27490
  };
27446
27491
  const EvaaBridge = EvaaBridgeWithProviders;
27447
27492
  export {
27448
- getDestTokens as $,
27493
+ getChains as $,
27449
27494
  getRouteDisplayName as A,
27450
27495
  computeFeeBreakdownUsd as B,
27451
27496
  ConfigCtrl as C,
@@ -27457,32 +27502,34 @@ export {
27457
27502
  listAssetsForSelect as I,
27458
27503
  resolveTokenOnChain as J,
27459
27504
  resolveTokenOnChainFromMatrix$1 as K,
27460
- DEFAULT_SLIPPAGE_BPS as L,
27505
+ resolveBridgeSourceTokenOnChainFromMatrix as L,
27461
27506
  ModalCtrl as M,
27462
- tonNorm as N,
27507
+ resolveBridgeDestinationTokenOnChainFromMatrix as N,
27463
27508
  OptionsCtrl as O,
27464
- isZeroAddr as P,
27465
- addrForApi as Q,
27509
+ DEFAULT_SLIPPAGE_BPS as P,
27510
+ tonNorm as Q,
27466
27511
  RouterCtrl as R,
27467
- isNativeAddrEqual as S,
27512
+ isZeroAddr as S,
27468
27513
  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 _,
27514
+ addrForApi as U,
27515
+ isNativeAddrEqual as V,
27516
+ findNativeMeta as W,
27517
+ lookupTokenMeta as X,
27518
+ normalizeTickerSymbol as Y,
27519
+ isAllowedFromChain as Z,
27520
+ isAllowedToChain as _,
27476
27521
  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,
27522
+ getTokens as a0,
27523
+ getDestTokens as a1,
27524
+ getQuotesByPriority as a2,
27525
+ isNativeAddress as a3,
27526
+ makeTokenBalanceKey as a4,
27527
+ getEvmBalances as a5,
27528
+ getTonBalances as a6,
27529
+ getTronBalances as a7,
27530
+ getDeliveryStatus as a8,
27531
+ pollUntilDelivered as a9,
27532
+ reportBridgeTransaction as aa,
27486
27533
  ExplorerCtrl as b,
27487
27534
  CoreUtil as c,
27488
27535
  EvaaBridge as d,
@@ -27509,4 +27556,4 @@ export {
27509
27556
  calculateMinReceived as y,
27510
27557
  getQuoteDetails as z
27511
27558
  };
27512
- //# sourceMappingURL=index-BIpr23sm.js.map
27559
+ //# sourceMappingURL=index-UBA5Oxdc.js.map