@rash2x/bridge-widget 0.5.9 → 0.6.0

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.
@@ -25808,7 +25808,7 @@ class WalletConnectModal {
25808
25808
  }
25809
25809
  async initUi() {
25810
25810
  if (typeof window !== "undefined") {
25811
- await import("./index-Ciui5BKt.js");
25811
+ await import("./index-UecTcXLf.js");
25812
25812
  const modal = document.createElement("wcm-modal");
25813
25813
  document.body.insertAdjacentElement("beforeend", modal);
25814
25814
  OptionsCtrl.setIsUiLoaded(true);
@@ -26500,45 +26500,204 @@ async function pollUntilDelivered(args) {
26500
26500
  await new Promise((r2) => setTimeout(r2, intervalMs));
26501
26501
  }
26502
26502
  }
26503
+ const TOKEN_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
26504
+ const NETWORK_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/networks";
26505
+ function getTokenIconUrl(symbol) {
26506
+ const normalizedSymbol = normalizeTickerSymbol$1(symbol).toLowerCase();
26507
+ return `${TOKEN_ICON_BASE_URL}/${normalizedSymbol}.svg`;
26508
+ }
26509
+ function getNetworkIconUrl(chainKey) {
26510
+ const normalizedChainKey = chainKey.toLowerCase();
26511
+ return `${NETWORK_ICON_BASE_URL}/${normalizedChainKey}.svg`;
26512
+ }
26513
+ function formatEstimatedTime(seconds) {
26514
+ if (seconds < 60) {
26515
+ return `~${seconds}s`;
26516
+ }
26517
+ const minutes = Math.round(seconds / 60);
26518
+ if (minutes === 1) {
26519
+ return "~1 min";
26520
+ }
26521
+ if (minutes < 60) {
26522
+ return `~${minutes} min`;
26523
+ }
26524
+ const hours = Math.round(minutes / 60);
26525
+ return `~${hours}h`;
26526
+ }
26527
+ function parseRouteType(route) {
26528
+ if (!route) return "STARGATE_V2_FAST";
26529
+ const routeUpper = route.toUpperCase();
26530
+ if (routeUpper.includes("STARGATE_V2") || routeUpper.includes("STARGATEV2")) {
26531
+ return "STARGATE_V2_FAST";
26532
+ }
26533
+ if (routeUpper.includes("OFT")) {
26534
+ return "OFT";
26535
+ }
26536
+ if (routeUpper.includes("STARGATE_V1") || routeUpper.includes("STARGATEV1")) {
26537
+ return "STARGATE_V1";
26538
+ }
26539
+ return "STARGATE_V2_FAST";
26540
+ }
26541
+ function useBridgeData() {
26542
+ const { quote, status, error, noRoute } = useBridgeQuoteStore();
26543
+ const { selectedAssetSymbol, assetMatrix, tokens } = useTokensStore();
26544
+ const { chains } = useChainsStore();
26545
+ const { slippageBps } = useSettingsStore();
26546
+ return useMemo(() => {
26547
+ if (!quote || !chains || !tokens) {
26548
+ return {
26549
+ token: null,
26550
+ sourceNetwork: null,
26551
+ destinationNetwork: null,
26552
+ gateway: null,
26553
+ amounts: null,
26554
+ fees: null,
26555
+ estimatedTime: null,
26556
+ status,
26557
+ isReady: false,
26558
+ error,
26559
+ noRoute
26560
+ };
26561
+ }
26562
+ const sourceChain = chains.find(
26563
+ (c2) => c2.chainKey.toLowerCase() === quote.srcChainKey.toLowerCase()
26564
+ );
26565
+ const destinationChain = chains.find(
26566
+ (c2) => c2.chainKey.toLowerCase() === quote.dstChainKey.toLowerCase()
26567
+ );
26568
+ const srcToken = resolveTokenOnChainFromMatrix$2(
26569
+ assetMatrix,
26570
+ selectedAssetSymbol,
26571
+ quote.srcChainKey
26572
+ );
26573
+ const dstToken = resolveTokenOnChainFromMatrix$2(
26574
+ assetMatrix,
26575
+ selectedAssetSymbol,
26576
+ quote.dstChainKey
26577
+ );
26578
+ const amounts = getQuoteAmounts(quote, srcToken, dstToken);
26579
+ const minReceived = calculateMinReceived(quote, slippageBps, dstToken);
26580
+ const feeData = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
26581
+ const fees = {
26582
+ source: feeData.inSrcToken && srcToken ? {
26583
+ amount: feeData.inSrcToken,
26584
+ symbol: srcToken.symbol,
26585
+ usd: feeData.inSrcToken * (srcToken.price?.usd || 0)
26586
+ } : null,
26587
+ destination: feeData.inDstToken && dstToken ? {
26588
+ amount: feeData.inDstToken,
26589
+ symbol: dstToken.symbol,
26590
+ usd: feeData.inDstToken * (dstToken.price?.usd || 0)
26591
+ } : null,
26592
+ protocol: feeData.protocolFeeUsd ? { usd: feeData.protocolFeeUsd } : null,
26593
+ message: feeData.messageFeeUsd ? { usd: feeData.messageFeeUsd } : null,
26594
+ service: feeData.serviceUsd ? { usd: feeData.serviceUsd } : null,
26595
+ blockchain: feeData.blockchainUsd ? { usd: feeData.blockchainUsd } : null,
26596
+ total: {
26597
+ usd: feeData.totalUsd
26598
+ }
26599
+ };
26600
+ const estimatedTime = quote.duration?.estimated ? {
26601
+ seconds: quote.duration.estimated,
26602
+ formatted: formatEstimatedTime(quote.duration.estimated)
26603
+ } : null;
26604
+ const token = srcToken ? {
26605
+ symbol: srcToken.symbol,
26606
+ address: srcToken.address,
26607
+ decimals: srcToken.decimals,
26608
+ name: srcToken.name,
26609
+ iconUrl: getTokenIconUrl(srcToken.symbol)
26610
+ } : null;
26611
+ const sourceNetwork = sourceChain ? {
26612
+ chainKey: sourceChain.chainKey,
26613
+ name: sourceChain.name,
26614
+ chainId: sourceChain.chainId,
26615
+ chainType: sourceChain.chainType,
26616
+ iconUrl: getNetworkIconUrl(sourceChain.chainKey)
26617
+ } : null;
26618
+ const destinationNetwork = destinationChain ? {
26619
+ chainKey: destinationChain.chainKey,
26620
+ name: destinationChain.name,
26621
+ chainId: destinationChain.chainId,
26622
+ chainType: destinationChain.chainType,
26623
+ iconUrl: getNetworkIconUrl(destinationChain.chainKey)
26624
+ } : null;
26625
+ const gateway = {
26626
+ route: quote.route,
26627
+ routeType: parseRouteType(quote.route)
26628
+ };
26629
+ return {
26630
+ token,
26631
+ sourceNetwork,
26632
+ destinationNetwork,
26633
+ gateway,
26634
+ amounts: {
26635
+ input: quote.srcAmount,
26636
+ inputHuman: amounts.inputHuman,
26637
+ output: quote.dstAmount,
26638
+ outputHuman: amounts.outputHuman,
26639
+ outputRounded: amounts.outputHumanRounded,
26640
+ minimumReceived: minReceived
26641
+ },
26642
+ fees,
26643
+ estimatedTime,
26644
+ status,
26645
+ isReady: status === "success" && !!quote && !noRoute,
26646
+ error,
26647
+ noRoute
26648
+ };
26649
+ }, [
26650
+ quote,
26651
+ chains,
26652
+ tokens,
26653
+ selectedAssetSymbol,
26654
+ assetMatrix,
26655
+ slippageBps,
26656
+ status,
26657
+ error,
26658
+ noRoute
26659
+ ]);
26660
+ }
26503
26661
  export {
26504
- normalizeTickerSymbol$1 as $,
26505
- addTonNetworkFee as A,
26506
- estimateTronNetworkFee as B,
26662
+ sumFeeByTokenLD as $,
26663
+ estimateTonNetworkFee as A,
26664
+ addTonNetworkFee as B,
26507
26665
  ConfigCtrl as C,
26508
- addTronNetworkFee as D,
26666
+ estimateTronNetworkFee as D,
26509
26667
  EventsCtrl as E,
26510
- estimateEvmNetworkFee as F,
26511
- addEvmNetworkFee as G,
26512
- getQuoteDetails as H,
26513
- toLD as I,
26514
- fromLD as J,
26515
- buildAssetMatrix as K,
26516
- listAssetsForSelect as L,
26668
+ addTronNetworkFee as F,
26669
+ estimateEvmNetworkFee as G,
26670
+ addEvmNetworkFee as H,
26671
+ getQuoteDetails as I,
26672
+ toLD as J,
26673
+ fromLD as K,
26674
+ buildAssetMatrix as L,
26517
26675
  ModalCtrl as M,
26518
- resolveTokenOnChain as N,
26676
+ listAssetsForSelect as N,
26519
26677
  OptionsCtrl as O,
26520
- resolveTokenOnChainFromMatrix$2 as P,
26521
- DEFAULT_SLIPPAGE_BPS as Q,
26678
+ resolveTokenOnChain as P,
26679
+ resolveTokenOnChainFromMatrix$2 as Q,
26522
26680
  RouterCtrl as R,
26523
- tonNorm as S,
26681
+ DEFAULT_SLIPPAGE_BPS as S,
26524
26682
  ToastCtrl as T,
26525
- isZeroAddr as U,
26526
- addrForApi as V,
26527
- isNativeAddrEqual as W,
26528
- findNativeMeta as X,
26529
- lookupTokenMeta as Y,
26530
- computeFeesUsdFromArray as Z,
26531
- sumFeeByTokenLD as _,
26683
+ tonNorm as U,
26684
+ isZeroAddr as V,
26685
+ addrForApi as W,
26686
+ isNativeAddrEqual as X,
26687
+ findNativeMeta as Y,
26688
+ lookupTokenMeta as Z,
26689
+ computeFeesUsdFromArray as _,
26532
26690
  ThemeCtrl as a,
26533
- getChains as a0,
26534
- getTokens as a1,
26535
- getDestTokens as a2,
26536
- getQuotesByPriority as a3,
26537
- getEvmBalances as a4,
26538
- getTonBalances as a5,
26539
- getTronBalances as a6,
26540
- getDeliveryStatus as a7,
26541
- pollUntilDelivered as a8,
26691
+ normalizeTickerSymbol$1 as a0,
26692
+ getChains as a1,
26693
+ getTokens as a2,
26694
+ getDestTokens as a3,
26695
+ getQuotesByPriority as a4,
26696
+ getEvmBalances as a5,
26697
+ getTonBalances as a6,
26698
+ getTronBalances as a7,
26699
+ getDeliveryStatus as a8,
26700
+ pollUntilDelivered as a9,
26542
26701
  ExplorerCtrl as b,
26543
26702
  CoreUtil as c,
26544
26703
  EvaaBridge as d,
@@ -26552,17 +26711,17 @@ export {
26552
26711
  useConnectedWalletsStore as l,
26553
26712
  useCustomAddressStore as m,
26554
26713
  useSwapModel as n,
26555
- formatTokenAmount as o,
26556
- formatUsd as p,
26557
- formatPercentage as q,
26558
- formatBalance as r,
26559
- formatHash as s,
26714
+ useBridgeData as o,
26715
+ formatTokenAmount as p,
26716
+ formatUsd as q,
26717
+ formatPercentage as r,
26718
+ formatBalance as s,
26560
26719
  truncateToDecimals as t,
26561
26720
  useChainsStore as u,
26562
- formatAddress as v,
26563
- getQuoteAmounts as w,
26564
- getQuoteFees as x,
26565
- calculateMinReceived as y,
26566
- estimateTonNetworkFee as z
26721
+ formatHash as v,
26722
+ formatAddress as w,
26723
+ getQuoteAmounts as x,
26724
+ getQuoteFees as y,
26725
+ calculateMinReceived as z
26567
26726
  };
26568
- //# sourceMappingURL=index-BXdYB1Ge.js.map
26727
+ //# sourceMappingURL=index-BwXs7MXT.js.map