@rash2x/bridge-widget 0.5.9 → 0.6.1

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-CphEQoZi.cjs");
3
+ const index = require("./index-DJobWPVa.cjs");
4
4
  exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
5
5
  exports.EvaaBridge = index.EvaaBridge;
6
6
  exports.RoutePriority = index.RoutePriority;
@@ -46,6 +46,7 @@ exports.sumFeeByTokenLD = index.sumFeeByTokenLD;
46
46
  exports.toLD = index.toLD;
47
47
  exports.tonNorm = index.tonNorm;
48
48
  exports.truncateToDecimals = index.truncateToDecimals;
49
+ exports.useBridgeData = index.useBridgeData;
49
50
  exports.useBridgeQuoteStore = index.useBridgeQuoteStore;
50
51
  exports.useChainsStore = index.useChainsStore;
51
52
  exports.useConnectedWalletsStore = index.useConnectedWalletsStore;
@@ -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,50 +1,51 @@
1
- import { Q, d, f, e, G, A, D, V, K, y, Z, F, z, B, X, v, r, s, q, o, p, J, a0, a7, a2, a4, w, H, x, a3, a1, a5, a6, W, U, L, Y, $, a8, N, P, _, I, S, t, i, u, l, m, j, n, h, k } from "./index-BXdYB1Ge.js";
1
+ import { S, d, f, e, H, B, F, W, L, z, _, G, A, D, Y, w, s, v, r, p, q, K, a1, a8, a3, a5, x, I, y, a4, a2, a6, a7, X, V, N, Z, a0, a9, P, Q, $, J, U, t, o, i, u, l, m, j, n, h, k } from "./index-BZISqglL.js";
2
2
  export {
3
- Q as DEFAULT_SLIPPAGE_BPS,
3
+ S as DEFAULT_SLIPPAGE_BPS,
4
4
  d as EvaaBridge,
5
5
  f as RoutePriority,
6
6
  e as RouteType,
7
- G as addEvmNetworkFee,
8
- A as addTonNetworkFee,
9
- D as addTronNetworkFee,
10
- V as addrForApi,
11
- K as buildAssetMatrix,
12
- y as calculateMinReceived,
13
- Z as computeFeesUsdFromArray,
14
- F as estimateEvmNetworkFee,
15
- z as estimateTonNetworkFee,
16
- B as estimateTronNetworkFee,
17
- X as findNativeMeta,
18
- v as formatAddress,
19
- r as formatBalance,
20
- s as formatHash,
21
- q as formatPercentage,
22
- o as formatTokenAmount,
23
- p as formatUsd,
24
- J as fromLD,
25
- a0 as getChains,
26
- a7 as getDeliveryStatus,
27
- a2 as getDestTokens,
28
- a4 as getEvmBalances,
29
- w as getQuoteAmounts,
30
- H as getQuoteDetails,
31
- x as getQuoteFees,
32
- a3 as getQuotesByPriority,
33
- a1 as getTokens,
34
- a5 as getTonBalances,
35
- a6 as getTronBalances,
36
- W as isNativeAddrEqual,
37
- U as isZeroAddr,
38
- L as listAssetsForSelect,
39
- Y as lookupTokenMeta,
40
- $ as normalizeTickerSymbol,
41
- a8 as pollUntilDelivered,
42
- N as resolveTokenOnChain,
43
- P as resolveTokenOnChainFromMatrix,
44
- _ as sumFeeByTokenLD,
45
- I as toLD,
46
- S as tonNorm,
7
+ H as addEvmNetworkFee,
8
+ B as addTonNetworkFee,
9
+ F as addTronNetworkFee,
10
+ W as addrForApi,
11
+ L as buildAssetMatrix,
12
+ z as calculateMinReceived,
13
+ _ as computeFeesUsdFromArray,
14
+ G as estimateEvmNetworkFee,
15
+ A as estimateTonNetworkFee,
16
+ D as estimateTronNetworkFee,
17
+ Y as findNativeMeta,
18
+ w as formatAddress,
19
+ s as formatBalance,
20
+ v as formatHash,
21
+ r as formatPercentage,
22
+ p as formatTokenAmount,
23
+ q as formatUsd,
24
+ K as fromLD,
25
+ a1 as getChains,
26
+ a8 as getDeliveryStatus,
27
+ a3 as getDestTokens,
28
+ a5 as getEvmBalances,
29
+ x as getQuoteAmounts,
30
+ I as getQuoteDetails,
31
+ y as getQuoteFees,
32
+ a4 as getQuotesByPriority,
33
+ a2 as getTokens,
34
+ a6 as getTonBalances,
35
+ a7 as getTronBalances,
36
+ X as isNativeAddrEqual,
37
+ V as isZeroAddr,
38
+ N as listAssetsForSelect,
39
+ Z as lookupTokenMeta,
40
+ a0 as normalizeTickerSymbol,
41
+ a9 as pollUntilDelivered,
42
+ P as resolveTokenOnChain,
43
+ Q as resolveTokenOnChainFromMatrix,
44
+ $ as sumFeeByTokenLD,
45
+ J as toLD,
46
+ U as tonNorm,
47
47
  t as truncateToDecimals,
48
+ o as useBridgeData,
48
49
  i as useBridgeQuoteStore,
49
50
  u as useChainsStore,
50
51
  l as useConnectedWalletsStore,
@@ -4372,6 +4372,164 @@ const StatusStepsDialog = ({
4372
4372
  }
4373
4373
  return /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: () => reset(), children: step });
4374
4374
  };
4375
+ const TOKEN_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
4376
+ const NETWORK_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/networks";
4377
+ function getTokenIconUrl(symbol) {
4378
+ const normalizedSymbol = normalizeTickerSymbol$1(symbol).toLowerCase();
4379
+ return `${TOKEN_ICON_BASE_URL}/${normalizedSymbol}.svg`;
4380
+ }
4381
+ function getNetworkIconUrl(chainKey) {
4382
+ const normalizedChainKey = chainKey.toLowerCase();
4383
+ return `${NETWORK_ICON_BASE_URL}/${normalizedChainKey}.svg`;
4384
+ }
4385
+ function formatEstimatedTime(seconds) {
4386
+ if (seconds < 60) {
4387
+ return `~${seconds}s`;
4388
+ }
4389
+ const minutes = Math.round(seconds / 60);
4390
+ if (minutes === 1) {
4391
+ return "~1 min";
4392
+ }
4393
+ if (minutes < 60) {
4394
+ return `~${minutes} min`;
4395
+ }
4396
+ const hours = Math.round(minutes / 60);
4397
+ return `~${hours}h`;
4398
+ }
4399
+ function parseRouteType(route) {
4400
+ if (!route) return "STARGATE_V2_FAST";
4401
+ const routeUpper = route.toUpperCase();
4402
+ if (routeUpper.includes("STARGATE_V2") || routeUpper.includes("STARGATEV2")) {
4403
+ return "STARGATE_V2_FAST";
4404
+ }
4405
+ if (routeUpper.includes("OFT")) {
4406
+ return "OFT";
4407
+ }
4408
+ if (routeUpper.includes("STARGATE_V1") || routeUpper.includes("STARGATEV1")) {
4409
+ return "STARGATE_V1";
4410
+ }
4411
+ return "STARGATE_V2_FAST";
4412
+ }
4413
+ function useBridgeData() {
4414
+ const { quote, status, error, noRoute } = useBridgeQuoteStore();
4415
+ const { selectedAssetSymbol, assetMatrix, tokens } = useTokensStore();
4416
+ const { chains } = useChainsStore();
4417
+ const { slippageBps } = useSettingsStore();
4418
+ return useMemo(() => {
4419
+ if (!quote || !chains || !tokens) {
4420
+ return {
4421
+ token: null,
4422
+ sourceNetwork: null,
4423
+ destinationNetwork: null,
4424
+ gateway: null,
4425
+ amounts: null,
4426
+ fees: null,
4427
+ estimatedTime: null,
4428
+ status,
4429
+ isReady: false,
4430
+ error,
4431
+ noRoute
4432
+ };
4433
+ }
4434
+ const sourceChain = chains.find(
4435
+ (c2) => c2.chainKey.toLowerCase() === quote.srcChainKey.toLowerCase()
4436
+ );
4437
+ const destinationChain = chains.find(
4438
+ (c2) => c2.chainKey.toLowerCase() === quote.dstChainKey.toLowerCase()
4439
+ );
4440
+ const srcToken = resolveTokenOnChainFromMatrix$2(
4441
+ assetMatrix,
4442
+ selectedAssetSymbol,
4443
+ quote.srcChainKey
4444
+ );
4445
+ const dstToken = resolveTokenOnChainFromMatrix$2(
4446
+ assetMatrix,
4447
+ selectedAssetSymbol,
4448
+ quote.dstChainKey
4449
+ );
4450
+ const amounts = getQuoteAmounts(quote, srcToken, dstToken);
4451
+ const minReceived = calculateMinReceived(quote, slippageBps, dstToken);
4452
+ const feeData = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
4453
+ const fees = {
4454
+ source: feeData.inSrcToken && srcToken ? {
4455
+ amount: feeData.inSrcToken,
4456
+ symbol: srcToken.symbol,
4457
+ usd: feeData.inSrcToken * (srcToken.price?.usd || 0)
4458
+ } : null,
4459
+ destination: feeData.inDstToken && dstToken ? {
4460
+ amount: feeData.inDstToken,
4461
+ symbol: dstToken.symbol,
4462
+ usd: feeData.inDstToken * (dstToken.price?.usd || 0)
4463
+ } : null,
4464
+ protocol: feeData.protocolFeeUsd ? { usd: feeData.protocolFeeUsd } : null,
4465
+ message: feeData.messageFeeUsd ? { usd: feeData.messageFeeUsd } : null,
4466
+ service: feeData.serviceUsd ? { usd: feeData.serviceUsd } : null,
4467
+ blockchain: feeData.blockchainUsd ? { usd: feeData.blockchainUsd } : null,
4468
+ total: {
4469
+ usd: feeData.totalUsd
4470
+ }
4471
+ };
4472
+ const estimatedTime = quote.duration?.estimated ? {
4473
+ seconds: quote.duration.estimated,
4474
+ formatted: formatEstimatedTime(quote.duration.estimated)
4475
+ } : null;
4476
+ const token = srcToken ? {
4477
+ symbol: srcToken.symbol,
4478
+ address: srcToken.address,
4479
+ decimals: srcToken.decimals,
4480
+ name: srcToken.name,
4481
+ iconUrl: getTokenIconUrl(srcToken.symbol)
4482
+ } : null;
4483
+ const sourceNetwork = sourceChain ? {
4484
+ chainKey: sourceChain.chainKey,
4485
+ name: sourceChain.name,
4486
+ chainId: sourceChain.chainId,
4487
+ chainType: sourceChain.chainType,
4488
+ iconUrl: getNetworkIconUrl(sourceChain.chainKey)
4489
+ } : null;
4490
+ const destinationNetwork = destinationChain ? {
4491
+ chainKey: destinationChain.chainKey,
4492
+ name: destinationChain.name,
4493
+ chainId: destinationChain.chainId,
4494
+ chainType: destinationChain.chainType,
4495
+ iconUrl: getNetworkIconUrl(destinationChain.chainKey)
4496
+ } : null;
4497
+ const gateway = {
4498
+ route: quote.route,
4499
+ routeType: parseRouteType(quote.route)
4500
+ };
4501
+ return {
4502
+ token,
4503
+ sourceNetwork,
4504
+ destinationNetwork,
4505
+ gateway,
4506
+ amounts: {
4507
+ input: quote.srcAmount,
4508
+ inputHuman: amounts.inputHuman,
4509
+ output: quote.dstAmount,
4510
+ outputHuman: amounts.outputHuman,
4511
+ outputRounded: amounts.outputHumanRounded,
4512
+ minimumReceived: minReceived
4513
+ },
4514
+ fees,
4515
+ estimatedTime,
4516
+ status,
4517
+ isReady: status === "success" && !!quote && !noRoute,
4518
+ error,
4519
+ noRoute
4520
+ };
4521
+ }, [
4522
+ quote,
4523
+ chains,
4524
+ tokens,
4525
+ selectedAssetSymbol,
4526
+ assetMatrix,
4527
+ slippageBps,
4528
+ status,
4529
+ error,
4530
+ noRoute
4531
+ ]);
4532
+ }
4375
4533
  const useTokens = () => {
4376
4534
  const { setTokens, setSelectedToken, setSelectedAssetSymbol } = useTokensStore();
4377
4535
  const query = useQuery({
@@ -25808,7 +25966,7 @@ class WalletConnectModal {
25808
25966
  }
25809
25967
  async initUi() {
25810
25968
  if (typeof window !== "undefined") {
25811
- await import("./index-Ciui5BKt.js");
25969
+ await import("./index-B_5fHaUO.js");
25812
25970
  const modal = document.createElement("wcm-modal");
25813
25971
  document.body.insertAdjacentElement("beforeend", modal);
25814
25972
  OptionsCtrl.setIsUiLoaded(true);
@@ -26295,12 +26453,21 @@ const EvaaBridgeContent = ({
26295
26453
  onUrlParamsChange,
26296
26454
  onInitialized,
26297
26455
  onAmountChange,
26298
- onChainChange
26456
+ onChainChange,
26457
+ onBridgeDataUpdate
26299
26458
  } = {}) => {
26300
26459
  const { t: t2 } = useBridgeTranslation();
26301
26460
  useTokens();
26302
26461
  useChains();
26303
26462
  const swap = useSwapModel();
26463
+ const bridgeData = useBridgeData();
26464
+ const callbackRef = useRef(onBridgeDataUpdate);
26465
+ callbackRef.current = onBridgeDataUpdate;
26466
+ useEffect(() => {
26467
+ if (callbackRef.current) {
26468
+ callbackRef.current(bridgeData);
26469
+ }
26470
+ }, [bridgeData]);
26304
26471
  const { handleAmountBlur } = useUrlSync({
26305
26472
  enabled: enableUrlSync,
26306
26473
  urlParams,
@@ -26501,44 +26668,45 @@ async function pollUntilDelivered(args) {
26501
26668
  }
26502
26669
  }
26503
26670
  export {
26504
- normalizeTickerSymbol$1 as $,
26505
- addTonNetworkFee as A,
26506
- estimateTronNetworkFee as B,
26671
+ sumFeeByTokenLD as $,
26672
+ estimateTonNetworkFee as A,
26673
+ addTonNetworkFee as B,
26507
26674
  ConfigCtrl as C,
26508
- addTronNetworkFee as D,
26675
+ estimateTronNetworkFee as D,
26509
26676
  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,
26677
+ addTronNetworkFee as F,
26678
+ estimateEvmNetworkFee as G,
26679
+ addEvmNetworkFee as H,
26680
+ getQuoteDetails as I,
26681
+ toLD as J,
26682
+ fromLD as K,
26683
+ buildAssetMatrix as L,
26517
26684
  ModalCtrl as M,
26518
- resolveTokenOnChain as N,
26685
+ listAssetsForSelect as N,
26519
26686
  OptionsCtrl as O,
26520
- resolveTokenOnChainFromMatrix$2 as P,
26521
- DEFAULT_SLIPPAGE_BPS as Q,
26687
+ resolveTokenOnChain as P,
26688
+ resolveTokenOnChainFromMatrix$2 as Q,
26522
26689
  RouterCtrl as R,
26523
- tonNorm as S,
26690
+ DEFAULT_SLIPPAGE_BPS as S,
26524
26691
  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 _,
26692
+ tonNorm as U,
26693
+ isZeroAddr as V,
26694
+ addrForApi as W,
26695
+ isNativeAddrEqual as X,
26696
+ findNativeMeta as Y,
26697
+ lookupTokenMeta as Z,
26698
+ computeFeesUsdFromArray as _,
26532
26699
  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,
26700
+ normalizeTickerSymbol$1 as a0,
26701
+ getChains as a1,
26702
+ getTokens as a2,
26703
+ getDestTokens as a3,
26704
+ getQuotesByPriority as a4,
26705
+ getEvmBalances as a5,
26706
+ getTonBalances as a6,
26707
+ getTronBalances as a7,
26708
+ getDeliveryStatus as a8,
26709
+ pollUntilDelivered as a9,
26542
26710
  ExplorerCtrl as b,
26543
26711
  CoreUtil as c,
26544
26712
  EvaaBridge as d,
@@ -26552,17 +26720,17 @@ export {
26552
26720
  useConnectedWalletsStore as l,
26553
26721
  useCustomAddressStore as m,
26554
26722
  useSwapModel as n,
26555
- formatTokenAmount as o,
26556
- formatUsd as p,
26557
- formatPercentage as q,
26558
- formatBalance as r,
26559
- formatHash as s,
26723
+ useBridgeData as o,
26724
+ formatTokenAmount as p,
26725
+ formatUsd as q,
26726
+ formatPercentage as r,
26727
+ formatBalance as s,
26560
26728
  truncateToDecimals as t,
26561
26729
  useChainsStore as u,
26562
- formatAddress as v,
26563
- getQuoteAmounts as w,
26564
- getQuoteFees as x,
26565
- calculateMinReceived as y,
26566
- estimateTonNetworkFee as z
26730
+ formatHash as v,
26731
+ formatAddress as w,
26732
+ getQuoteAmounts as x,
26733
+ getQuoteFees as y,
26734
+ calculateMinReceived as z
26567
26735
  };
26568
- //# sourceMappingURL=index-BXdYB1Ge.js.map
26736
+ //# sourceMappingURL=index-BZISqglL.js.map