@multiversx/sdk-dapp-liquidity 1.1.0-alpha.39 → 1.1.0-alpha.40

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,8 +1,9 @@
1
1
  import { TokenType } from '../types/token';
2
2
  import { AxiosResponse } from 'axios';
3
3
 
4
- export declare function getTokens({ url, chainId, nativeAuthToken }: {
4
+ export declare function getTokens({ url, chainId, nativeAuthToken, bridgeOnly }: {
5
5
  url: string;
6
6
  chainId?: number;
7
7
  nativeAuthToken: string;
8
+ bridgeOnly: boolean;
8
9
  }): Promise<AxiosResponse<TokenType[]>>;
package/api/getTokens.js CHANGED
@@ -5,7 +5,8 @@ const axios = require("axios");
5
5
  async function getTokens({
6
6
  url,
7
7
  chainId,
8
- nativeAuthToken
8
+ nativeAuthToken,
9
+ bridgeOnly
9
10
  }) {
10
11
  const config = {
11
12
  baseURL: url,
@@ -14,6 +15,9 @@ async function getTokens({
14
15
  }
15
16
  };
16
17
  const endpoint = chainId ? `/tokens/${chainId}` : "/tokens";
17
- return await axios.get(endpoint, config);
18
+ return await axios.get(
19
+ `${endpoint}?isBridge=${bridgeOnly}`,
20
+ config
21
+ );
18
22
  }
19
23
  exports.getTokens = getTokens;
package/api/getTokens.mjs CHANGED
@@ -2,7 +2,8 @@ import axios from "axios";
2
2
  async function getTokens({
3
3
  url,
4
4
  chainId,
5
- nativeAuthToken
5
+ nativeAuthToken,
6
+ bridgeOnly
6
7
  }) {
7
8
  const config = {
8
9
  baseURL: url,
@@ -11,7 +12,10 @@ async function getTokens({
11
12
  }
12
13
  };
13
14
  const endpoint = chainId ? `/tokens/${chainId}` : "/tokens";
14
- return await axios.get(endpoint, config);
15
+ return await axios.get(
16
+ `${endpoint}?isBridge=${bridgeOnly}`,
17
+ config
18
+ );
15
19
  }
16
20
  export {
17
21
  getTokens
@@ -24,7 +24,11 @@ describe("getTokens", () => {
24
24
  }
25
25
  ];
26
26
  mockedAxios.get.mockResolvedValue({ data: response });
27
- const result = await api_getTokens.getTokens({ url, nativeAuthToken: "" });
27
+ const result = await api_getTokens.getTokens({
28
+ url,
29
+ nativeAuthToken: "",
30
+ bridgeOnly: false
31
+ });
28
32
  expect(mockedAxios.get).toHaveBeenCalledWith("/tokens", { baseURL: url });
29
33
  expect(result.data).toEqual(response);
30
34
  });
@@ -47,7 +51,12 @@ describe("getTokens", () => {
47
51
  }
48
52
  ];
49
53
  mockedAxios.get.mockResolvedValue({ data: response });
50
- const result = await api_getTokens.getTokens({ url, chainId, nativeAuthToken: "" });
54
+ const result = await api_getTokens.getTokens({
55
+ url,
56
+ chainId,
57
+ nativeAuthToken: "",
58
+ bridgeOnly: false
59
+ });
51
60
  expect(mockedAxios.get).toHaveBeenCalledWith(`/tokens/${chainId}`, {
52
61
  baseURL: url
53
62
  });
@@ -55,8 +64,8 @@ describe("getTokens", () => {
55
64
  });
56
65
  it("handles error when fetching tokens", async () => {
57
66
  mockedAxios.get.mockRejectedValue(new Error("Network Error"));
58
- await expect(api_getTokens.getTokens({ url, nativeAuthToken: "" })).rejects.toThrow(
59
- "Network Error"
60
- );
67
+ await expect(
68
+ api_getTokens.getTokens({ url, nativeAuthToken: "", bridgeOnly: false })
69
+ ).rejects.toThrow("Network Error");
61
70
  });
62
71
  });
@@ -22,7 +22,11 @@ describe("getTokens", () => {
22
22
  }
23
23
  ];
24
24
  mockedAxios.get.mockResolvedValue({ data: response });
25
- const result = await getTokens({ url, nativeAuthToken: "" });
25
+ const result = await getTokens({
26
+ url,
27
+ nativeAuthToken: "",
28
+ bridgeOnly: false
29
+ });
26
30
  expect(mockedAxios.get).toHaveBeenCalledWith("/tokens", { baseURL: url });
27
31
  expect(result.data).toEqual(response);
28
32
  });
@@ -45,7 +49,12 @@ describe("getTokens", () => {
45
49
  }
46
50
  ];
47
51
  mockedAxios.get.mockResolvedValue({ data: response });
48
- const result = await getTokens({ url, chainId, nativeAuthToken: "" });
52
+ const result = await getTokens({
53
+ url,
54
+ chainId,
55
+ nativeAuthToken: "",
56
+ bridgeOnly: false
57
+ });
49
58
  expect(mockedAxios.get).toHaveBeenCalledWith(`/tokens/${chainId}`, {
50
59
  baseURL: url
51
60
  });
@@ -53,8 +62,8 @@ describe("getTokens", () => {
53
62
  });
54
63
  it("handles error when fetching tokens", async () => {
55
64
  mockedAxios.get.mockRejectedValue(new Error("Network Error"));
56
- await expect(getTokens({ url, nativeAuthToken: "" })).rejects.toThrow(
57
- "Network Error"
58
- );
65
+ await expect(
66
+ getTokens({ url, nativeAuthToken: "", bridgeOnly: false })
67
+ ).rejects.toThrow("Network Error");
59
68
  });
60
69
  });
package/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/multiversx/mx-sdk-dapp-liquidity#readme",
30
30
  "license": "MIT",
31
- "version": "1.1.0-alpha.39",
31
+ "version": "1.1.0-alpha.40",
32
32
  "main": "index.js",
33
33
  "module": "index.mjs",
34
34
  "types": "index.d.ts",
@@ -10,6 +10,7 @@ export type Web3AppContextProps = {
10
10
  options: InitOptions;
11
11
  supportedChains: AppKitNetwork[];
12
12
  nativeAuthToken: string;
13
+ bridgeOnly?: boolean;
13
14
  };
14
15
  export declare const Web3AppContext: import('react').Context<Web3AppContextProps | undefined>;
15
- export declare function Web3AppProvider({ children, config, appKit, options, supportedChains, nativeAuthToken }: PropsWithChildren<Web3AppContextProps>): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Web3AppProvider({ children, config, appKit, options, supportedChains, nativeAuthToken, bridgeOnly }: PropsWithChildren<Web3AppContextProps>): import("react/jsx-runtime").JSX.Element;
@@ -16,7 +16,8 @@ function Web3AppProvider({
16
16
  appKit,
17
17
  options,
18
18
  supportedChains,
19
- nativeAuthToken
19
+ nativeAuthToken,
20
+ bridgeOnly
20
21
  }) {
21
22
  const value = React.useMemo(() => {
22
23
  return {
@@ -24,7 +25,8 @@ function Web3AppProvider({
24
25
  appKit,
25
26
  options,
26
27
  supportedChains,
27
- nativeAuthToken
28
+ nativeAuthToken,
29
+ bridgeOnly
28
30
  };
29
31
  }, [config, appKit, options, nativeAuthToken]);
30
32
  return /* @__PURE__ */ jsxRuntime.jsx(Web3AppContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(wagmi.WagmiProvider, { config, children: /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children }) }) });
@@ -13,7 +13,8 @@ function Web3AppProvider({
13
13
  appKit,
14
14
  options,
15
15
  supportedChains,
16
- nativeAuthToken
16
+ nativeAuthToken,
17
+ bridgeOnly
17
18
  }) {
18
19
  const value = useMemo(() => {
19
20
  return {
@@ -21,7 +22,8 @@ function Web3AppProvider({
21
22
  appKit,
22
23
  options,
23
24
  supportedChains,
24
- nativeAuthToken
25
+ nativeAuthToken,
26
+ bridgeOnly
25
27
  };
26
28
  }, [config, appKit, options, nativeAuthToken]);
27
29
  return /* @__PURE__ */ jsx(Web3AppContext.Provider, { value, children: /* @__PURE__ */ jsx(WagmiProvider, { config, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) }) });
@@ -6,12 +6,13 @@ const api_getTokens = require("../../api/getTokens.js");
6
6
  const helpers_getApiURL = require("../../helpers/getApiURL.js");
7
7
  const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
8
8
  const useGetAllTokensQuery = () => {
9
- const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
9
+ const { nativeAuthToken, bridgeOnly } = reactjs_context_useWeb3App.useWeb3App();
10
10
  const queryFn = async () => {
11
11
  try {
12
12
  const { data } = await api_getTokens.getTokens({
13
13
  url: helpers_getApiURL.getApiURL(),
14
- nativeAuthToken
14
+ nativeAuthToken,
15
+ bridgeOnly: Boolean(bridgeOnly)
15
16
  });
16
17
  return data;
17
18
  } catch (error) {
@@ -3,12 +3,13 @@ import { getTokens } from "../../api/getTokens.mjs";
3
3
  import { getApiURL } from "../../helpers/getApiURL.mjs";
4
4
  import { useWeb3App } from "../context/useWeb3App.mjs";
5
5
  const useGetAllTokensQuery = () => {
6
- const { nativeAuthToken } = useWeb3App();
6
+ const { nativeAuthToken, bridgeOnly } = useWeb3App();
7
7
  const queryFn = async () => {
8
8
  try {
9
9
  const { data } = await getTokens({
10
10
  url: getApiURL(),
11
- nativeAuthToken
11
+ nativeAuthToken,
12
+ bridgeOnly: Boolean(bridgeOnly)
12
13
  });
13
14
  return data;
14
15
  } catch (error) {