@trustware/sdk-staging 1.1.8-staging.4 → 1.1.8-staging.5

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.
package/dist/widget.mjs CHANGED
@@ -571,7 +571,7 @@ var init_constants = __esm({
571
571
  "src/constants.ts"() {
572
572
  "use strict";
573
573
  SDK_NAME = "@trustware/sdk";
574
- SDK_VERSION = "1.1.8-staging.4";
574
+ SDK_VERSION = "1.1.8-staging.5";
575
575
  API_ROOT = "https://bv-staging-api.trustware.io";
576
576
  GTM_ID = "GTM-TZDGNCXB";
577
577
  API_PREFIX = "/api";
@@ -31649,6 +31649,7 @@ function SwapMode({
31649
31649
  );
31650
31650
  const settingsRef = useRef17(null);
31651
31651
  const currencyDropdownRef = useRef17(null);
31652
+ const { emitEvent } = useTrustware();
31652
31653
  const { features } = useTrustwareConfig();
31653
31654
  const defaultDestRef = features.swapDefaultDestToken;
31654
31655
  const lockDestToken = features.swapLockDestToken && !!defaultDestRef;
@@ -31789,8 +31790,16 @@ function SwapMode({
31789
31790
  setAmountInputMode("usd");
31790
31791
  }
31791
31792
  setStage("home");
31793
+ emitEvent?.({
31794
+ type: "swap_route_changed",
31795
+ fromChain: String(chain.chainId),
31796
+ fromToken: token.address,
31797
+ toChain: String(toChain?.chainId ?? ""),
31798
+ toToken: toToken?.address ?? "",
31799
+ ...amount ? { amount } : {}
31800
+ });
31792
31801
  },
31793
- [route]
31802
+ [route, emitEvent, toToken, toChain, amount]
31794
31803
  );
31795
31804
  const handleSelectToToken = useCallback22(
31796
31805
  (token, chain) => {
@@ -31798,18 +31807,35 @@ function SwapMode({
31798
31807
  setToChain(chain);
31799
31808
  route.clear();
31800
31809
  setStage("home");
31810
+ emitEvent?.({
31811
+ type: "swap_route_changed",
31812
+ fromChain: String(fromChain?.chainId ?? ""),
31813
+ fromToken: fromToken?.address ?? "",
31814
+ toChain: String(chain.chainId),
31815
+ toToken: token.address,
31816
+ ...amount ? { amount } : {}
31817
+ });
31801
31818
  },
31802
- [route]
31819
+ [route, emitEvent, fromToken, fromChain, amount]
31803
31820
  );
31804
31821
  const handleFlip = useCallback22(() => {
31805
31822
  if (lockDestToken) return;
31823
+ const newFrom = toToken ?? fromToken;
31824
+ const newFromChain = toChain ?? fromChain;
31806
31825
  setFromToken((prev) => toToken ?? prev);
31807
31826
  setFromChain((prev) => toChain ?? prev);
31808
31827
  setToToken(fromToken);
31809
31828
  setToChain(fromChain);
31810
31829
  setAmount("");
31811
31830
  route.clear();
31812
- }, [lockDestToken, fromToken, fromChain, toToken, toChain, route]);
31831
+ emitEvent?.({
31832
+ type: "swap_route_changed",
31833
+ fromChain: String(newFromChain?.chainId ?? ""),
31834
+ fromToken: newFrom?.address ?? "",
31835
+ toChain: String(fromChain?.chainId ?? ""),
31836
+ toToken: fromToken?.address ?? ""
31837
+ });
31838
+ }, [lockDestToken, fromToken, fromChain, toToken, toChain, route, emitEvent]);
31813
31839
  const fromChainType = normalizeChainType2(fromChain);
31814
31840
  const toChainType = normalizeChainType2(toChain);
31815
31841
  const needsDestAddress = !!fromChainType && !!toChainType && fromChainType !== toChainType;
@@ -35551,6 +35577,7 @@ var init_SwapMode = __esm({
35551
35577
  init_tokenAmount();
35552
35578
  init_chainHelpers();
35553
35579
  init_hooks();
35580
+ init_provider();
35554
35581
  init_useSwapRoute();
35555
35582
  init_useSwapExecution();
35556
35583
  init_useForex();