@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.
@@ -4373,6 +4373,164 @@ const StatusStepsDialog = ({
4373
4373
  }
4374
4374
  return /* @__PURE__ */ jsxRuntime.jsx(dialog.Dialog, { open: true, onOpenChange: () => reset(), children: step });
4375
4375
  };
4376
+ const TOKEN_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
4377
+ const NETWORK_ICON_BASE_URL = "https://icons-ckg.pages.dev/stargate-light/networks";
4378
+ function getTokenIconUrl(symbol) {
4379
+ const normalizedSymbol = normalizeTickerSymbol$1(symbol).toLowerCase();
4380
+ return `${TOKEN_ICON_BASE_URL}/${normalizedSymbol}.svg`;
4381
+ }
4382
+ function getNetworkIconUrl(chainKey) {
4383
+ const normalizedChainKey = chainKey.toLowerCase();
4384
+ return `${NETWORK_ICON_BASE_URL}/${normalizedChainKey}.svg`;
4385
+ }
4386
+ function formatEstimatedTime(seconds) {
4387
+ if (seconds < 60) {
4388
+ return `~${seconds}s`;
4389
+ }
4390
+ const minutes = Math.round(seconds / 60);
4391
+ if (minutes === 1) {
4392
+ return "~1 min";
4393
+ }
4394
+ if (minutes < 60) {
4395
+ return `~${minutes} min`;
4396
+ }
4397
+ const hours = Math.round(minutes / 60);
4398
+ return `~${hours}h`;
4399
+ }
4400
+ function parseRouteType(route) {
4401
+ if (!route) return "STARGATE_V2_FAST";
4402
+ const routeUpper = route.toUpperCase();
4403
+ if (routeUpper.includes("STARGATE_V2") || routeUpper.includes("STARGATEV2")) {
4404
+ return "STARGATE_V2_FAST";
4405
+ }
4406
+ if (routeUpper.includes("OFT")) {
4407
+ return "OFT";
4408
+ }
4409
+ if (routeUpper.includes("STARGATE_V1") || routeUpper.includes("STARGATEV1")) {
4410
+ return "STARGATE_V1";
4411
+ }
4412
+ return "STARGATE_V2_FAST";
4413
+ }
4414
+ function useBridgeData() {
4415
+ const { quote, status, error, noRoute } = useBridgeQuoteStore();
4416
+ const { selectedAssetSymbol, assetMatrix, tokens } = useTokensStore();
4417
+ const { chains } = useChainsStore();
4418
+ const { slippageBps } = useSettingsStore();
4419
+ return react.useMemo(() => {
4420
+ if (!quote || !chains || !tokens) {
4421
+ return {
4422
+ token: null,
4423
+ sourceNetwork: null,
4424
+ destinationNetwork: null,
4425
+ gateway: null,
4426
+ amounts: null,
4427
+ fees: null,
4428
+ estimatedTime: null,
4429
+ status,
4430
+ isReady: false,
4431
+ error,
4432
+ noRoute
4433
+ };
4434
+ }
4435
+ const sourceChain = chains.find(
4436
+ (c2) => c2.chainKey.toLowerCase() === quote.srcChainKey.toLowerCase()
4437
+ );
4438
+ const destinationChain = chains.find(
4439
+ (c2) => c2.chainKey.toLowerCase() === quote.dstChainKey.toLowerCase()
4440
+ );
4441
+ const srcToken = resolveTokenOnChainFromMatrix$2(
4442
+ assetMatrix,
4443
+ selectedAssetSymbol,
4444
+ quote.srcChainKey
4445
+ );
4446
+ const dstToken = resolveTokenOnChainFromMatrix$2(
4447
+ assetMatrix,
4448
+ selectedAssetSymbol,
4449
+ quote.dstChainKey
4450
+ );
4451
+ const amounts = getQuoteAmounts(quote, srcToken, dstToken);
4452
+ const minReceived = calculateMinReceived(quote, slippageBps, dstToken);
4453
+ const feeData = getQuoteFees(quote, tokens, chains, srcToken, dstToken);
4454
+ const fees = {
4455
+ source: feeData.inSrcToken && srcToken ? {
4456
+ amount: feeData.inSrcToken,
4457
+ symbol: srcToken.symbol,
4458
+ usd: feeData.inSrcToken * (srcToken.price?.usd || 0)
4459
+ } : null,
4460
+ destination: feeData.inDstToken && dstToken ? {
4461
+ amount: feeData.inDstToken,
4462
+ symbol: dstToken.symbol,
4463
+ usd: feeData.inDstToken * (dstToken.price?.usd || 0)
4464
+ } : null,
4465
+ protocol: feeData.protocolFeeUsd ? { usd: feeData.protocolFeeUsd } : null,
4466
+ message: feeData.messageFeeUsd ? { usd: feeData.messageFeeUsd } : null,
4467
+ service: feeData.serviceUsd ? { usd: feeData.serviceUsd } : null,
4468
+ blockchain: feeData.blockchainUsd ? { usd: feeData.blockchainUsd } : null,
4469
+ total: {
4470
+ usd: feeData.totalUsd
4471
+ }
4472
+ };
4473
+ const estimatedTime = quote.duration?.estimated ? {
4474
+ seconds: quote.duration.estimated,
4475
+ formatted: formatEstimatedTime(quote.duration.estimated)
4476
+ } : null;
4477
+ const token = srcToken ? {
4478
+ symbol: srcToken.symbol,
4479
+ address: srcToken.address,
4480
+ decimals: srcToken.decimals,
4481
+ name: srcToken.name,
4482
+ iconUrl: getTokenIconUrl(srcToken.symbol)
4483
+ } : null;
4484
+ const sourceNetwork = sourceChain ? {
4485
+ chainKey: sourceChain.chainKey,
4486
+ name: sourceChain.name,
4487
+ chainId: sourceChain.chainId,
4488
+ chainType: sourceChain.chainType,
4489
+ iconUrl: getNetworkIconUrl(sourceChain.chainKey)
4490
+ } : null;
4491
+ const destinationNetwork = destinationChain ? {
4492
+ chainKey: destinationChain.chainKey,
4493
+ name: destinationChain.name,
4494
+ chainId: destinationChain.chainId,
4495
+ chainType: destinationChain.chainType,
4496
+ iconUrl: getNetworkIconUrl(destinationChain.chainKey)
4497
+ } : null;
4498
+ const gateway = {
4499
+ route: quote.route,
4500
+ routeType: parseRouteType(quote.route)
4501
+ };
4502
+ return {
4503
+ token,
4504
+ sourceNetwork,
4505
+ destinationNetwork,
4506
+ gateway,
4507
+ amounts: {
4508
+ input: quote.srcAmount,
4509
+ inputHuman: amounts.inputHuman,
4510
+ output: quote.dstAmount,
4511
+ outputHuman: amounts.outputHuman,
4512
+ outputRounded: amounts.outputHumanRounded,
4513
+ minimumReceived: minReceived
4514
+ },
4515
+ fees,
4516
+ estimatedTime,
4517
+ status,
4518
+ isReady: status === "success" && !!quote && !noRoute,
4519
+ error,
4520
+ noRoute
4521
+ };
4522
+ }, [
4523
+ quote,
4524
+ chains,
4525
+ tokens,
4526
+ selectedAssetSymbol,
4527
+ assetMatrix,
4528
+ slippageBps,
4529
+ status,
4530
+ error,
4531
+ noRoute
4532
+ ]);
4533
+ }
4376
4534
  const useTokens = () => {
4377
4535
  const { setTokens, setSelectedToken, setSelectedAssetSymbol } = useTokensStore();
4378
4536
  const query = reactQuery.useQuery({
@@ -25809,7 +25967,7 @@ class WalletConnectModal {
25809
25967
  }
25810
25968
  async initUi() {
25811
25969
  if (typeof window !== "undefined") {
25812
- await Promise.resolve().then(() => require("./index-Bdh_cEEE.cjs"));
25970
+ await Promise.resolve().then(() => require("./index-Gy63MKy2.cjs"));
25813
25971
  const modal = document.createElement("wcm-modal");
25814
25972
  document.body.insertAdjacentElement("beforeend", modal);
25815
25973
  OptionsCtrl.setIsUiLoaded(true);
@@ -26296,12 +26454,21 @@ const EvaaBridgeContent = ({
26296
26454
  onUrlParamsChange,
26297
26455
  onInitialized,
26298
26456
  onAmountChange,
26299
- onChainChange
26457
+ onChainChange,
26458
+ onBridgeDataUpdate
26300
26459
  } = {}) => {
26301
26460
  const { t: t2 } = useBridgeTranslation();
26302
26461
  useTokens();
26303
26462
  useChains();
26304
26463
  const swap = useSwapModel();
26464
+ const bridgeData = useBridgeData();
26465
+ const callbackRef = react.useRef(onBridgeDataUpdate);
26466
+ callbackRef.current = onBridgeDataUpdate;
26467
+ react.useEffect(() => {
26468
+ if (callbackRef.current) {
26469
+ callbackRef.current(bridgeData);
26470
+ }
26471
+ }, [bridgeData]);
26305
26472
  const { handleAmountBlur } = useUrlSync({
26306
26473
  enabled: enableUrlSync,
26307
26474
  urlParams,
@@ -26556,6 +26723,7 @@ exports.sumFeeByTokenLD = sumFeeByTokenLD;
26556
26723
  exports.toLD = toLD;
26557
26724
  exports.tonNorm = tonNorm;
26558
26725
  exports.truncateToDecimals = truncateToDecimals;
26726
+ exports.useBridgeData = useBridgeData;
26559
26727
  exports.useBridgeQuoteStore = useBridgeQuoteStore;
26560
26728
  exports.useChainsStore = useChainsStore;
26561
26729
  exports.useConnectedWalletsStore = useConnectedWalletsStore;
@@ -26564,4 +26732,4 @@ exports.useSettingsStore = useSettingsStore;
26564
26732
  exports.useSwapModel = useSwapModel;
26565
26733
  exports.useTokensStore = useTokensStore;
26566
26734
  exports.useTransactionStore = useTransactionStore;
26567
- //# sourceMappingURL=index-CphEQoZi.cjs.map
26735
+ //# sourceMappingURL=index-DJobWPVa.cjs.map