@rash2x/bridge-widget 0.6.29 → 0.6.31

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.
@@ -454,6 +454,7 @@ function resolveTokenOnChain(tokens, assetSymbol, chainKey) {
454
454
  }
455
455
  const initialState = {
456
456
  tokens: void 0,
457
+ allTokens: void 0,
457
458
  selectedToken: void 0,
458
459
  selectedAssetSymbol: void 0
459
460
  };
@@ -462,6 +463,9 @@ const useTokensStore = create((set2) => ({
462
463
  setTokens: (data) => {
463
464
  set2({ tokens: data, assetMatrix: buildAssetMatrix(data) });
464
465
  },
466
+ setAllTokens: (data) => {
467
+ set2({ allTokens: data });
468
+ },
465
469
  setSelectedToken: (data) => {
466
470
  set2({ selectedToken: data });
467
471
  },
@@ -4426,7 +4430,7 @@ const ProgressStep = ({
4426
4430
  ];
4427
4431
  return /* @__PURE__ */ jsx(DialogContent, { showCloseButton: false, className: "overflow-hidden md:max-w-[420px] p-10", children: /* @__PURE__ */ jsxs("div", { className: "flex relative flex-col gap-6 flex-1 items-center justify-start text-center bg-background p-6", children: [
4428
4432
  icon,
4429
- /* @__PURE__ */ jsx(DialogHeader, { className: "pr-0 !sm:text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.inProgress") }) }),
4433
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 pb-2 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.inProgress") }) }),
4430
4434
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
4431
4435
  /* @__PURE__ */ jsx("div", { className: "absolute left-5 top-5 bottom-5 border-l border-dashed border-foreground/50" }),
4432
4436
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6 relative z-10", children: steps.map((step) => /* @__PURE__ */ jsxs(
@@ -4454,7 +4458,7 @@ const FailedStep = ({
4454
4458
  return /* @__PURE__ */ jsxs(DialogContent, { showCloseButton: true, className: "overflow-hidden md:max-w-[420px] p-10", children: [
4455
4459
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-start text-center", children: [
4456
4460
  icon,
4457
- /* @__PURE__ */ jsxs(DialogHeader, { className: "pr-0 !sm:text-center", children: [
4461
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pb-2 text-center", children: [
4458
4462
  /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.failed") }),
4459
4463
  current?.errorCode && /* @__PURE__ */ jsx(DialogDescription$1, { children: t2(
4460
4464
  `errors.${current.errorCode}`,
@@ -4569,7 +4573,7 @@ const SuccessStep = ({
4569
4573
  return /* @__PURE__ */ jsxs(DialogContent, { showCloseButton: true, className: "overflow-hidden md:max-w-[420px] p-10", children: [
4570
4574
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 flex-1 justify-start items-center text-center bg-background", children: [
4571
4575
  icon,
4572
- /* @__PURE__ */ jsx(DialogHeader, { className: "pr-0 !sm:text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.success") }) }),
4576
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 pb-2 text-center", children: /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.success") }) }),
4573
4577
  /* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 mt-4 relative z-10 pb-14", children: [
4574
4578
  metadata?.srcAmountHuman && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
4575
4579
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.bridged") }),
@@ -4644,7 +4648,7 @@ const ConfirmStep = ({
4644
4648
  const { formatTime } = useCountdown(90);
4645
4649
  return /* @__PURE__ */ jsx(DialogContent, { showCloseButton: false, className: "overflow-hidden md:max-w-[420px] p-10", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col relative gap-4 flex-1 items-center justify-start text-center", children: [
4646
4650
  icon,
4647
- /* @__PURE__ */ jsxs(DialogHeader, { className: "pr-0 !sm:text-center", children: [
4651
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 pb-2 text-center", children: [
4648
4652
  /* @__PURE__ */ jsx(DialogTitle, { children: t2("transaction.confirm") }),
4649
4653
  /* @__PURE__ */ jsx(DialogDescription, { children: t2("transaction.signTransaction") })
4650
4654
  ] }),
@@ -4673,7 +4677,7 @@ const StatusStepsDialog = ({
4673
4677
  return /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: () => reset(), children: step });
4674
4678
  };
4675
4679
  const useTokens = () => {
4676
- const { setTokens, setSelectedToken, setSelectedAssetSymbol } = useTokensStore();
4680
+ const { setTokens, setAllTokens, setSelectedToken, setSelectedAssetSymbol } = useTokensStore();
4677
4681
  const query = useQuery({
4678
4682
  queryKey: ["tokens"],
4679
4683
  queryFn: () => getTokens(),
@@ -4683,20 +4687,24 @@ const useTokens = () => {
4683
4687
  // 30 минут
4684
4688
  gcTime: 60 * 6e4,
4685
4689
  // 1 час хранения в кэше
4686
- refetchOnWindowFocus: false,
4687
- select: (list) => list.filter((t2) => t2.isBridgeable === true)
4690
+ refetchOnWindowFocus: false
4688
4691
  });
4689
4692
  useEffect(() => {
4690
4693
  if (query.isSuccess && query.data?.length) {
4691
- setTokens(query.data);
4692
- const firstAsset = listAssetsForSelect(query.data)[0];
4694
+ setAllTokens(query.data);
4695
+ const bridgeableTokens = query.data.filter(
4696
+ (t2) => t2.isBridgeable === true
4697
+ );
4698
+ setTokens(bridgeableTokens);
4699
+ const firstAsset = listAssetsForSelect(bridgeableTokens)[0];
4693
4700
  setSelectedAssetSymbol(firstAsset?.symbol);
4694
- setSelectedToken(query.data[0]);
4701
+ setSelectedToken(bridgeableTokens[0]);
4695
4702
  }
4696
4703
  }, [
4697
4704
  query.isSuccess,
4698
4705
  query.data,
4699
4706
  setTokens,
4707
+ setAllTokens,
4700
4708
  setSelectedToken,
4701
4709
  setSelectedAssetSymbol
4702
4710
  ]);
@@ -6568,7 +6576,7 @@ const useConnectedWalletsStore = create((set2, get2) => ({
6568
6576
  }
6569
6577
  }));
6570
6578
  const gasPresets = ["auto", "none", "medium", "max"];
6571
- const slippagePresets = ["0.5%", "1.0%", "5.0%"];
6579
+ const slippagePresets = ["0.5%", "1%", "5%"];
6572
6580
  const routePresets = [
6573
6581
  RoutePriority.FASTEST,
6574
6582
  RoutePriority.CHEAPEST,
@@ -6577,7 +6585,7 @@ const routePresets = [
6577
6585
  const SettingsModal = ({ isOpen, onClose }) => {
6578
6586
  const { t: t2 } = useBridgeTranslation();
6579
6587
  const { toChain } = useChainsStore();
6580
- const { tokens } = useTokensStore();
6588
+ const { allTokens } = useTokensStore();
6581
6589
  const {
6582
6590
  slippageBps,
6583
6591
  routePriority,
@@ -6591,9 +6599,14 @@ const SettingsModal = ({ isOpen, onClose }) => {
6591
6599
  (preset) => parseFloat(preset.replace("%", "")) === slippageBps / 100
6592
6600
  );
6593
6601
  const dstNativeToken = toChain?.nativeCurrency;
6594
- const nativeTokenPrice = tokens?.find(
6595
- (t22) => t22.chainKey === toChain?.chainKey && t22.symbol?.toLowerCase() === dstNativeToken?.symbol?.toLowerCase()
6596
- )?.price?.usd || 0;
6602
+ const nativeTokenPrice = (() => {
6603
+ if (!allTokens || !dstNativeToken?.symbol || !toChain?.chainKey) return 0;
6604
+ const token = allTokens.find(
6605
+ (t22) => t22.chainKey === toChain.chainKey && t22.symbol?.toUpperCase() === dstNativeToken.symbol.toUpperCase()
6606
+ );
6607
+ const price = token?.price?.usd;
6608
+ return typeof price === "number" && isFinite(price) && price > 0 ? price : 0;
6609
+ })();
6597
6610
  const gasDisplayAmount = gasPresetToDisplayAmount(
6598
6611
  gasPreset,
6599
6612
  toChain?.chainKey,
@@ -6607,96 +6620,103 @@ const SettingsModal = ({ isOpen, onClose }) => {
6607
6620
  );
6608
6621
  const activeBtn = "bg-primary hover:bg-primary/80 text-primary-foreground transition-colors";
6609
6622
  const notActiveBtn = "bg-accent hover:bg-accent/80 text-accent-foreground transition-colors";
6610
- return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { onOpenAutoFocus: (e2) => e2.preventDefault(), className: "p-10 pt-7", children: [
6611
- /* @__PURE__ */ jsx(DialogHeader, { className: "text-left", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("settings.title") }) }),
6612
- /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
6613
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6614
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
6615
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6616
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.gasOnDestination") }),
6617
- /* @__PURE__ */ jsx(Tip, { text: t2("settings.gasOnDestinationDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6618
- ] }),
6619
- /* @__PURE__ */ jsx("p", { className: "text-foreground text-sm font-medium leading-4", children: formatUsd(gasUsdValue) })
6620
- ] }),
6621
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
6622
- /* @__PURE__ */ jsxs("div", { className: "flex items-center w-1/3 gap-2 shrink-0", children: [
6623
- /* @__PURE__ */ jsx(
6624
- TokenSymbol,
6625
- {
6626
- symbol: dstNativeToken?.symbol || "eth",
6627
- className: "h-4 w-4 rounded-full",
6628
- alt: dstNativeToken?.symbol || t2("common.nativeToken", { defaultValue: "Native Token" })
6629
- }
6630
- ),
6631
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("p", { className: "text-lg text-foreground leading-5 font-semibold h-5", children: gasDisplayAmount % 1 === 0 ? gasDisplayAmount.toFixed(0) : gasDisplayAmount.toFixed(
6632
- gasDisplayAmount < 1e-3 ? 6 : 3
6633
- ) }) })
6623
+ return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(
6624
+ DialogContent,
6625
+ {
6626
+ onOpenAutoFocus: (e2) => e2.preventDefault(),
6627
+ className: "p-10 pt-7",
6628
+ children: [
6629
+ /* @__PURE__ */ jsx(DialogHeader, { className: "text-left", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl leading-8", children: t2("settings.title") }) }),
6630
+ /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
6631
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6632
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
6633
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6634
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.gasOnDestination") }),
6635
+ /* @__PURE__ */ jsx(Tip, { text: t2("settings.gasOnDestinationDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6636
+ ] }),
6637
+ /* @__PURE__ */ jsx("p", { className: "text-foreground text-sm font-medium leading-4", children: formatUsd(gasUsdValue) })
6638
+ ] }),
6639
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
6640
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center w-1/3 gap-2 shrink-0", children: [
6641
+ /* @__PURE__ */ jsx(
6642
+ TokenSymbol,
6643
+ {
6644
+ symbol: dstNativeToken?.symbol || "eth",
6645
+ className: "h-4 w-4 rounded-full",
6646
+ alt: dstNativeToken?.symbol || t2("common.nativeToken", { defaultValue: "Native Token" })
6647
+ }
6648
+ ),
6649
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("p", { className: "text-lg text-foreground leading-5 font-semibold h-5", children: gasDisplayAmount % 1 === 0 ? gasDisplayAmount.toFixed(0) : gasDisplayAmount.toFixed(
6650
+ gasDisplayAmount < 1e-3 ? 6 : 3
6651
+ ) }) })
6652
+ ] }),
6653
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: gasPresets.map((g2) => /* @__PURE__ */ jsx(
6654
+ Badge,
6655
+ {
6656
+ onClick: () => setGasPreset(g2),
6657
+ className: cn$2(
6658
+ "cursor-pointer h-7 rounded px-2",
6659
+ gasPreset === g2 ? activeBtn : notActiveBtn
6660
+ ),
6661
+ children: t2(`settings.gasPresets.${g2}`)
6662
+ },
6663
+ g2
6664
+ )) })
6665
+ ] })
6634
6666
  ] }),
6635
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: gasPresets.map((g2) => /* @__PURE__ */ jsx(
6636
- Badge,
6637
- {
6638
- onClick: () => setGasPreset(g2),
6639
- className: cn$2(
6640
- "cursor-pointer h-7 rounded px-2",
6641
- gasPreset === g2 ? activeBtn : notActiveBtn
6642
- ),
6643
- children: t2(`settings.gasPresets.${g2}`)
6644
- },
6645
- g2
6646
- )) })
6647
- ] })
6648
- ] }),
6649
- /* @__PURE__ */ jsx("hr", {}),
6650
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6651
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
6652
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6653
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.slippageTolerance") }),
6654
- /* @__PURE__ */ jsx(Tip, { text: t2("settings.slippageToleranceDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6667
+ /* @__PURE__ */ jsx("hr", {}),
6668
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6669
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
6670
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6671
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.slippageTolerance") }),
6672
+ /* @__PURE__ */ jsx(Tip, { text: t2("settings.slippageToleranceDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6673
+ ] }),
6674
+ slippageBps >= 500 && /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs font-medium", children: t2("settings.highSlippageWarning", {
6675
+ defaultValue: "High slippage warning"
6676
+ }) })
6677
+ ] }),
6678
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-6", children: [
6679
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("p", { className: "text-lg text-foreground leading-5 font-semibold h-5", children: slippagePercent }) }),
6680
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: slippagePresets.map((p2) => /* @__PURE__ */ jsx(
6681
+ Badge,
6682
+ {
6683
+ onClick: () => {
6684
+ const bps = parseFloat(p2.replace("%", "")) * 100;
6685
+ setSlippageBps(bps);
6686
+ },
6687
+ className: cn$2(
6688
+ "cursor-pointer h-7 rounded px-2",
6689
+ activeSlippagePreset === p2 ? activeBtn : notActiveBtn
6690
+ ),
6691
+ children: p2
6692
+ },
6693
+ p2
6694
+ )) })
6695
+ ] })
6655
6696
  ] }),
6656
- slippageBps >= 500 && /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs font-medium", children: t2("settings.highSlippageWarning", {
6657
- defaultValue: "High slippage warning"
6658
- }) })
6659
- ] }),
6660
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-6", children: [
6661
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("p", { className: "text-lg text-foreground leading-5 font-semibold h-5", children: slippagePercent }) }),
6662
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: slippagePresets.map((p2) => /* @__PURE__ */ jsx(
6663
- Badge,
6664
- {
6665
- onClick: () => {
6666
- const bps = parseFloat(p2.replace("%", "")) * 100;
6667
- setSlippageBps(bps);
6697
+ /* @__PURE__ */ jsx("hr", {}),
6698
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6699
+ /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6700
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.routePriority") }),
6701
+ /* @__PURE__ */ jsx(Tip, { text: t2("settings.routePriorityDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6702
+ ] }) }),
6703
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end gap-2", children: routePresets.map((r2) => /* @__PURE__ */ jsx(
6704
+ Badge,
6705
+ {
6706
+ onClick: () => setRoutePriority(r2),
6707
+ className: cn$2(
6708
+ "cursor-pointer h-7 rounded px-2",
6709
+ routePriority === r2 ? activeBtn : notActiveBtn
6710
+ ),
6711
+ children: t2(`settings.routePresets.${r2}`)
6668
6712
  },
6669
- className: cn$2(
6670
- "cursor-pointer h-7 rounded px-2",
6671
- activeSlippagePreset === p2 ? activeBtn : notActiveBtn
6672
- ),
6673
- children: p2
6674
- },
6675
- p2
6676
- )) })
6713
+ r2
6714
+ )) })
6715
+ ] })
6677
6716
  ] })
6678
- ] }),
6679
- /* @__PURE__ */ jsx("hr", {}),
6680
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
6681
- /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
6682
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium leading-4", children: t2("settings.routePriority") }),
6683
- /* @__PURE__ */ jsx(Tip, { text: t2("settings.routePriorityDescription"), children: /* @__PURE__ */ jsx(InfoIcon, { className: "w-4 h-4 text-muted-foreground" }) })
6684
- ] }) }),
6685
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end gap-2", children: routePresets.map((r2) => /* @__PURE__ */ jsx(
6686
- Badge,
6687
- {
6688
- onClick: () => setRoutePriority(r2),
6689
- className: cn$2(
6690
- "cursor-pointer h-7 rounded px-2",
6691
- routePriority === r2 ? activeBtn : notActiveBtn
6692
- ),
6693
- children: t2(`settings.routePresets.${r2}`)
6694
- },
6695
- r2
6696
- )) })
6697
- ] })
6698
- ] })
6699
- ] }) });
6717
+ ]
6718
+ }
6719
+ ) });
6700
6720
  };
6701
6721
  const TokenRow = ({
6702
6722
  symbol,
@@ -26117,7 +26137,7 @@ class WalletConnectModal {
26117
26137
  }
26118
26138
  async initUi() {
26119
26139
  if (typeof window !== "undefined") {
26120
- await import("./index-ieIpvYrV.js");
26140
+ await import("./index-CWy9GAOY.js");
26121
26141
  const modal = document.createElement("wcm-modal");
26122
26142
  document.body.insertAdjacentElement("beforeend", modal);
26123
26143
  OptionsCtrl.setIsUiLoaded(true);
@@ -26837,11 +26857,12 @@ export {
26837
26857
  getTokens as a3,
26838
26858
  getDestTokens as a4,
26839
26859
  getQuotesByPriority as a5,
26840
- getEvmBalances as a6,
26841
- getTonBalances as a7,
26842
- getTronBalances as a8,
26843
- getDeliveryStatus as a9,
26844
- pollUntilDelivered as aa,
26860
+ isNativeAddress as a6,
26861
+ getEvmBalances as a7,
26862
+ getTonBalances as a8,
26863
+ getTronBalances as a9,
26864
+ getDeliveryStatus as aa,
26865
+ pollUntilDelivered as ab,
26845
26866
  ExplorerCtrl as b,
26846
26867
  CoreUtil as c,
26847
26868
  EvaaBridge as d,
@@ -26868,4 +26889,4 @@ export {
26868
26889
  getQuoteFees as y,
26869
26890
  calculateMinReceived as z
26870
26891
  };
26871
- //# sourceMappingURL=index-BqFCsB_A.js.map
26892
+ //# sourceMappingURL=index-LQOauLrq.js.map