@rash2x/bridge-widget 0.6.81 → 0.6.83

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.
@@ -1132,7 +1132,7 @@ function useBridgeQuote() {
1132
1132
  const { assetMatrix, selectedAssetSymbol } = useTokensStore();
1133
1133
  const { fromChain, toChain, chains } = useChainsStore();
1134
1134
  const { srcAddress, dstAddress } = useAddresses();
1135
- const { slippageBps, routePriority, getDstNativeAmount, getSlippageDecimal } = useSettingsStore();
1135
+ const { slippageBps, routePriority, gasPreset, getDstNativeAmount, getSlippageDecimal } = useSettingsStore();
1136
1136
  const {
1137
1137
  inputAmount,
1138
1138
  refetchTrigger,
@@ -1269,6 +1269,7 @@ function useBridgeQuote() {
1269
1269
  setQError,
1270
1270
  slippageBps,
1271
1271
  routePriority,
1272
+ gasPreset,
1272
1273
  refetchTrigger,
1273
1274
  chainRegistry,
1274
1275
  chains,
@@ -2848,7 +2849,7 @@ const Tip = (props) => {
2848
2849
  const { children, text } = props;
2849
2850
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
2850
2851
  /* @__PURE__ */ jsx(TooltipTrigger, { className: "w-4 h-4 rounded-full bg-muted text-muted-foreground", children }),
2851
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-64", children: /* @__PURE__ */ jsx("p", { children: text }) })
2852
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-64", children: text })
2852
2853
  ] });
2853
2854
  };
2854
2855
  const BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
@@ -3443,26 +3444,6 @@ async function waitForLayerZeroCompletion(txHash, timeoutMs = 6e5, pollIntervalM
3443
3444
  status: "TIMEOUT"
3444
3445
  };
3445
3446
  }
3446
- const useBridgeReportStore = create((set2) => ({
3447
- config: {
3448
- enabled: false,
3449
- authToken: void 0,
3450
- baseUrl: void 0
3451
- },
3452
- setConfig: (config) => {
3453
- set2({ config });
3454
- },
3455
- setAuthToken: (token) => {
3456
- set2((state2) => ({
3457
- config: { ...state2.config, authToken: token }
3458
- }));
3459
- },
3460
- setEnabled: (enabled) => {
3461
- set2((state2) => ({
3462
- config: { ...state2.config, enabled }
3463
- }));
3464
- }
3465
- }));
3466
3447
  async function tryFetch(url) {
3467
3448
  try {
3468
3449
  const res = await fetch(url);
@@ -3559,7 +3540,6 @@ function useBridgeTransaction() {
3559
3540
  const { assetMatrix, selectedAssetSymbol, allTokens } = useTokensStore();
3560
3541
  const { chains } = useChainsStore();
3561
3542
  const txStore = useTransactionStore();
3562
- const { config: bridgeReportConfig } = useBridgeReportStore();
3563
3543
  const gas = useGasEstimate();
3564
3544
  const srcToken = useMemo(
3565
3545
  () => resolveTokenOnChainFromMatrix$2(
@@ -3577,7 +3557,7 @@ function useBridgeTransaction() {
3577
3557
  ),
3578
3558
  [assetMatrix, selectedAssetSymbol, quote?.dstChainKey]
3579
3559
  );
3580
- const executeTransaction = async () => {
3560
+ const executeTransaction = async (callbacks, bridgeReportConfig) => {
3581
3561
  if (!quote) {
3582
3562
  throw new InvalidStepsError("bridge", "No quote available");
3583
3563
  }
@@ -3594,8 +3574,16 @@ function useBridgeTransaction() {
3594
3574
  dstTokenSymbol: dstToken?.symbol || quote.dstToken,
3595
3575
  srcAmountHuman: amounts.inputHuman,
3596
3576
  dstAmountHuman: amounts.outputHuman
3597
- // Actual fee will be updated when transaction completes
3598
3577
  };
3578
+ const shouldStart = await callbacks?.onSwapStart?.({
3579
+ fromChain: metadata.srcChainName,
3580
+ toChain: metadata.dstChainName,
3581
+ amount: amounts.inputHuman.toString(),
3582
+ tokenSymbol: metadata.srcTokenSymbol
3583
+ });
3584
+ if (shouldStart === false) {
3585
+ return { hash: void 0 };
3586
+ }
3599
3587
  txStore.setTransaction(quote, "executing", metadata);
3600
3588
  try {
3601
3589
  const steps = quote.steps || [];
@@ -3658,7 +3646,7 @@ function useBridgeTransaction() {
3658
3646
  console.warn("Failed to convert TON message hash to tx hash");
3659
3647
  }
3660
3648
  }
3661
- if (bridgeReportConfig.enabled) {
3649
+ if (bridgeReportConfig?.enabled) {
3662
3650
  reportBridgeTransaction(
3663
3651
  {
3664
3652
  lz_tx_hash: hashForLayerZero,
@@ -3681,6 +3669,13 @@ function useBridgeTransaction() {
3681
3669
  6e5,
3682
3670
  1e4
3683
3671
  );
3672
+ const successData = {
3673
+ fromChain: metadata.srcChainName,
3674
+ toChain: metadata.dstChainName,
3675
+ amount: amounts.inputHuman.toString(),
3676
+ tokenSymbol: metadata.srcTokenSymbol,
3677
+ transactionHash: txResult.hash
3678
+ };
3684
3679
  if (lzResult.completed) {
3685
3680
  if (lzResult.dstTxHash) {
3686
3681
  txStore.setDstHash(lzResult.dstTxHash);
@@ -3706,12 +3701,21 @@ function useBridgeTransaction() {
3706
3701
  console.warn("Failed to compute source cost:", error);
3707
3702
  }
3708
3703
  }
3704
+ callbacks?.onSwapSuccess?.(successData);
3709
3705
  txStore.updateStatus("completed");
3710
3706
  } else {
3711
3707
  if (lzResult.status === "FAILED") {
3708
+ callbacks?.onSwapError?.({
3709
+ error: "TRANSACTION_FAILED_TO_COMPLETE",
3710
+ fromChain: metadata.srcChainName,
3711
+ toChain: metadata.dstChainName,
3712
+ amount: amounts.inputHuman.toString(),
3713
+ tokenSymbol: metadata.srcTokenSymbol
3714
+ });
3712
3715
  txStore.setError("TRANSACTION_FAILED_TO_COMPLETE");
3713
3716
  console.error("LayerZero delivery failed");
3714
3717
  } else {
3718
+ callbacks?.onSwapSuccess?.(successData);
3715
3719
  txStore.updateStatus("completed");
3716
3720
  console.warn(
3717
3721
  "LayerZero tracking timed out, marking as completed"
@@ -3720,6 +3724,14 @@ function useBridgeTransaction() {
3720
3724
  }
3721
3725
  };
3722
3726
  trackWithLayerZero().catch((err) => {
3727
+ const errorData = {
3728
+ error: isUserRejection(err) ? "TRANSACTION_REJECTED" : ChainStrategyError.isChainStrategyError(err) ? err.code : "COMPLETION_TRACKING_FAILED",
3729
+ fromChain: metadata.srcChainName,
3730
+ toChain: metadata.dstChainName,
3731
+ amount: amounts.inputHuman.toString(),
3732
+ tokenSymbol: metadata.srcTokenSymbol
3733
+ };
3734
+ callbacks?.onSwapError?.(errorData);
3723
3735
  if (isUserRejection(err)) {
3724
3736
  txStore.setError("TRANSACTION_REJECTED");
3725
3737
  } else if (ChainStrategyError.isChainStrategyError(err)) {
@@ -3737,6 +3749,14 @@ function useBridgeTransaction() {
3737
3749
  );
3738
3750
  }
3739
3751
  } catch (err) {
3752
+ const errorCode = isUserRejection(err) ? "TRANSACTION_REJECTED" : ChainStrategyError.isChainStrategyError(err) ? err.code : "UNKNOWN_ERROR";
3753
+ callbacks?.onSwapError?.({
3754
+ error: errorCode,
3755
+ fromChain: metadata.srcChainName,
3756
+ toChain: metadata.dstChainName,
3757
+ amount: amounts.inputHuman.toString(),
3758
+ tokenSymbol: metadata.srcTokenSymbol
3759
+ });
3740
3760
  if (isUserRejection(err)) {
3741
3761
  txStore.setError("TRANSACTION_REJECTED");
3742
3762
  throw new TransactionFailedError(
@@ -3913,7 +3933,10 @@ function useTelegramRestriction() {
3913
3933
  }, [fromChain?.chainKey, toChain?.chainKey]);
3914
3934
  return restriction;
3915
3935
  }
3916
- const MainButton = () => {
3936
+ const MainButton = ({
3937
+ swapCallbacks,
3938
+ bridgeReport
3939
+ }) => {
3917
3940
  const { t: t2 } = useBridgeTranslation();
3918
3941
  const { chainRegistry } = useChainStrategies();
3919
3942
  const { srcAddress, dstAddress, isCustomAddressEnabled } = useAddresses();
@@ -4010,7 +4033,7 @@ const MainButton = () => {
4010
4033
  }
4011
4034
  if (canTransfer) {
4012
4035
  try {
4013
- await executeTransaction();
4036
+ await executeTransaction(swapCallbacks, bridgeReport);
4014
4037
  } catch (error) {
4015
4038
  console.warn(error);
4016
4039
  }
@@ -25854,7 +25877,7 @@ class WalletConnectModal {
25854
25877
  }
25855
25878
  async initUi() {
25856
25879
  if (typeof window !== "undefined") {
25857
- await import("./index-88BW4a4g.js");
25880
+ await import("./index-CJeHQDmm.js");
25858
25881
  const modal = document.createElement("wcm-modal");
25859
25882
  document.body.insertAdjacentElement("beforeend", modal);
25860
25883
  OptionsCtrl.setIsUiLoaded(true);
@@ -26296,14 +26319,6 @@ function useUrlSync(options) {
26296
26319
  const EvaaBridgeWithProviders = (props) => {
26297
26320
  const [tonConnectUI] = useTonConnectUI();
26298
26321
  const tonAddress = useTonAddress();
26299
- const { setConfig: setBridgeReportConfig } = useBridgeReportStore();
26300
- useEffect(() => {
26301
- if (props.bridgeReport) {
26302
- setBridgeReportConfig(props.bridgeReport);
26303
- } else {
26304
- setBridgeReportConfig({ enabled: false });
26305
- }
26306
- }, [props.bridgeReport, setBridgeReportConfig]);
26307
26322
  const { address: evmAddress, isConnected: evmIsConnected } = useAccount();
26308
26323
  const { disconnect: evmDisconnect } = useDisconnect();
26309
26324
  const { data: walletClient } = useWalletClient();
@@ -26393,7 +26408,11 @@ const EvaaBridgeContent = ({
26393
26408
  urlParams,
26394
26409
  onUrlParamsChange,
26395
26410
  onInitialized,
26396
- onDataUpdate
26411
+ onSwapStart,
26412
+ onSwapSuccess,
26413
+ onSwapError,
26414
+ onDataUpdate,
26415
+ bridgeReport
26397
26416
  } = {}) => {
26398
26417
  const { t: t2 } = useBridgeTranslation();
26399
26418
  useTokens();
@@ -26528,7 +26547,13 @@ const EvaaBridgeContent = ({
26528
26547
  }
26529
26548
  ),
26530
26549
  /* @__PURE__ */ jsx(AnotherAddress, {}),
26531
- /* @__PURE__ */ jsx(MainButton, {})
26550
+ /* @__PURE__ */ jsx(
26551
+ MainButton,
26552
+ {
26553
+ swapCallbacks: { onSwapStart, onSwapSuccess, onSwapError },
26554
+ bridgeReport
26555
+ }
26556
+ )
26532
26557
  ] }),
26533
26558
  /* @__PURE__ */ jsx(CardFooter, { className: "p-0", children: /* @__PURE__ */ jsx(Details, {}) })
26534
26559
  ]
@@ -26541,44 +26566,43 @@ const EvaaBridgeContent = ({
26541
26566
  };
26542
26567
  const EvaaBridge = EvaaBridgeWithProviders;
26543
26568
  export {
26544
- getTokens as $,
26545
- calculateMinReceived as A,
26546
- getQuoteDetails as B,
26569
+ getDestTokens as $,
26570
+ getQuoteDetails as A,
26571
+ getRouteDisplayName as B,
26547
26572
  ConfigCtrl as C,
26548
- getRouteDisplayName as D,
26573
+ addNetworkFeesToQuote as D,
26549
26574
  EventsCtrl as E,
26550
- addNetworkFeesToQuote as F,
26551
- toLD as G,
26552
- fromLD as H,
26553
- buildAssetMatrix as I,
26554
- listAssetsForSelect as J,
26555
- resolveTokenOnChain as K,
26556
- resolveTokenOnChainFromMatrix$2 as L,
26575
+ toLD as F,
26576
+ fromLD as G,
26577
+ buildAssetMatrix as H,
26578
+ listAssetsForSelect as I,
26579
+ resolveTokenOnChain as J,
26580
+ resolveTokenOnChainFromMatrix$2 as K,
26581
+ DEFAULT_SLIPPAGE_BPS as L,
26557
26582
  ModalCtrl as M,
26558
- DEFAULT_SLIPPAGE_BPS as N,
26583
+ tonNorm as N,
26559
26584
  OptionsCtrl as O,
26560
- tonNorm as P,
26561
- isZeroAddr as Q,
26585
+ isZeroAddr as P,
26586
+ addrForApi as Q,
26562
26587
  RouterCtrl as R,
26563
- addrForApi as S,
26588
+ isNativeAddrEqual as S,
26564
26589
  ToastCtrl as T,
26565
- isNativeAddrEqual as U,
26566
- findNativeMeta as V,
26567
- lookupTokenMeta as W,
26568
- computeFeesUsdFromArray as X,
26569
- sumFeeByTokenLD as Y,
26570
- normalizeTickerSymbol$1 as Z,
26571
- getChains as _,
26590
+ findNativeMeta as U,
26591
+ lookupTokenMeta as V,
26592
+ computeFeesUsdFromArray as W,
26593
+ sumFeeByTokenLD as X,
26594
+ normalizeTickerSymbol$1 as Y,
26595
+ getChains as Z,
26596
+ getTokens as _,
26572
26597
  ThemeCtrl as a,
26573
- getDestTokens as a0,
26574
- getQuotesByPriority as a1,
26575
- isNativeAddress as a2,
26576
- getEvmBalances as a3,
26577
- getTonBalances as a4,
26578
- getTronBalances as a5,
26579
- getDeliveryStatus as a6,
26580
- pollUntilDelivered as a7,
26581
- reportBridgeTransaction as a8,
26598
+ getQuotesByPriority as a0,
26599
+ isNativeAddress as a1,
26600
+ getEvmBalances as a2,
26601
+ getTonBalances as a3,
26602
+ getTronBalances as a4,
26603
+ getDeliveryStatus as a5,
26604
+ pollUntilDelivered as a6,
26605
+ reportBridgeTransaction as a7,
26582
26606
  ExplorerCtrl as b,
26583
26607
  CoreUtil as c,
26584
26608
  EvaaBridge as d,
@@ -26591,18 +26615,18 @@ export {
26591
26615
  useTransactionStore as k,
26592
26616
  useConnectedWalletsStore as l,
26593
26617
  useCustomAddressStore as m,
26594
- useBridgeReportStore as n,
26595
- useSwapModel as o,
26596
- useBridgeExternalData as p,
26597
- formatTokenAmount as q,
26598
- formatUsd as r,
26599
- formatPercentage as s,
26618
+ useSwapModel as n,
26619
+ useBridgeExternalData as o,
26620
+ formatTokenAmount as p,
26621
+ formatUsd as q,
26622
+ formatPercentage as r,
26623
+ formatBalance as s,
26600
26624
  truncateToDecimals as t,
26601
26625
  useChainsStore as u,
26602
- formatBalance as v,
26603
- formatHash as w,
26604
- formatAddress as x,
26605
- getQuoteAmounts as y,
26606
- getQuoteFees as z
26626
+ formatHash as v,
26627
+ formatAddress as w,
26628
+ getQuoteAmounts as x,
26629
+ getQuoteFees as y,
26630
+ calculateMinReceived as z
26607
26631
  };
26608
- //# sourceMappingURL=index-DJSauetI.js.map
26632
+ //# sourceMappingURL=index-7Rh1biLW.js.map