@multiversx/sdk-dapp-liquidity 2.0.0-alpha.1 → 2.0.0-alpha.2

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/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": "2.0.0-alpha.1",
31
+ "version": "2.0.0-alpha.2",
32
32
  "main": "index.js",
33
33
  "module": "index.mjs",
34
34
  "types": "index.d.ts",
@@ -10,10 +10,23 @@ const faClock = require("@fortawesome/free-solid-svg-icons/faClock");
10
10
  const faClose = require("@fortawesome/free-solid-svg-icons/faClose");
11
11
  const reactFontawesome = require("@fortawesome/react-fontawesome");
12
12
  const React = require("react");
13
- const constants_index = require("../../../constants/index.js");
14
- const types_providerType = require("../../../types/providerType.js");
13
+ require("yup");
14
+ require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
15
+ require("bignumber.js");
16
+ const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
17
+ require("@reown/appkit/react");
18
+ require("axios");
15
19
  const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
20
+ require("formik");
21
+ const types_providerType = require("../../../types/providerType.js");
16
22
  const reactjs_hooks_useFetchBridgeData = require("../../hooks/useFetchBridgeData.js");
23
+ const constants_index = require("../../../constants/index.js");
24
+ require("@tanstack/react-query");
25
+ require("../../constants/index.js");
26
+ require("@reown/appkit-adapter-solana/react");
27
+ require("@solana/web3.js");
28
+ require("wagmi");
29
+ require("@reown/appkit-controllers");
17
30
  const reactjs_queries_useGetHistory_query = require("../../queries/useGetHistory.query.js");
18
31
  const reactjs_utils_formatAmount = require("../../utils/formatAmount.js");
19
32
  const reactjs_utils_mxClsx = require("../../utils/mxClsx.js");
@@ -28,10 +41,25 @@ const BridgeHistory = ({
28
41
  mvxAddress,
29
42
  onClose
30
43
  }) => {
31
- const { options } = reactjs_context_useWeb3App.useWeb3App();
32
- const { data, isLoading, isError } = reactjs_queries_useGetHistory_query.useGetHistoryQuery({
44
+ const { options, bridgeOnly } = reactjs_context_useWeb3App.useWeb3App();
45
+ const bridgeAccount = reactjs_hooks_useAccount.useAccount();
46
+ const {
47
+ data: mvxTransactions,
48
+ isLoading,
49
+ isError
50
+ } = reactjs_queries_useGetHistory_query.useGetHistoryQuery({
33
51
  address: mvxAddress
34
52
  });
53
+ const { data: bridgeTransactions } = reactjs_queries_useGetHistory_query.useGetHistoryQuery({
54
+ address: bridgeAccount.address ?? ""
55
+ });
56
+ const mergedTransactions = React.useMemo(() => {
57
+ const mvxTxs = mvxTransactions ?? [];
58
+ const bridgeTxs = bridgeOnly && bridgeTransactions ? bridgeTransactions : [];
59
+ return [...mvxTxs, ...bridgeTxs].sort(
60
+ (a, b) => b.depositTimestamp - a.depositTimestamp
61
+ );
62
+ }, [bridgeOnly, bridgeTransactions, mvxTransactions]);
35
63
  const resolveTransactionIcon = React.useCallback((transaction) => {
36
64
  switch (transaction.status) {
37
65
  case "success":
@@ -64,7 +92,7 @@ const BridgeHistory = ({
64
92
  }
65
93
  }, []);
66
94
  const transactions = React.useMemo(
67
- () => data == null ? void 0 : data.map((transaction) => {
95
+ () => mergedTransactions == null ? void 0 : mergedTransactions.map((transaction) => {
68
96
  return {
69
97
  ...transaction,
70
98
  tokenDestination: transaction.tokenOut.toLowerCase(),
@@ -73,7 +101,7 @@ const BridgeHistory = ({
73
101
  statusIcon: resolveTransactionIcon(transaction)
74
102
  };
75
103
  }),
76
- [data, resolveTransactionIcon]
104
+ [mergedTransactions, resolveTransactionIcon]
77
105
  );
78
106
  const {
79
107
  evmTokensWithBalances,
@@ -6,11 +6,24 @@ import { faCircleXmark } from "@fortawesome/free-solid-svg-icons/faCircleXmark";
6
6
  import { faClock } from "@fortawesome/free-solid-svg-icons/faClock";
7
7
  import { faClose } from "@fortawesome/free-solid-svg-icons/faClose";
8
8
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
9
- import { useCallback, useMemo } from "react";
10
- import { MVX_CHAIN_IDS } from "../../../constants/index.mjs";
11
- import { ProviderType } from "../../../types/providerType.mjs";
9
+ import { useMemo, useCallback } from "react";
10
+ import "yup";
11
+ import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
12
+ import "bignumber.js";
13
+ import { useAccount } from "../../hooks/useAccount.mjs";
14
+ import "@reown/appkit/react";
15
+ import "axios";
12
16
  import { useWeb3App } from "../../context/useWeb3App.mjs";
17
+ import "formik";
18
+ import { ProviderType } from "../../../types/providerType.mjs";
13
19
  import { useFetchBridgeData } from "../../hooks/useFetchBridgeData.mjs";
20
+ import { MVX_CHAIN_IDS } from "../../../constants/index.mjs";
21
+ import "@tanstack/react-query";
22
+ import "../../constants/index.mjs";
23
+ import "@reown/appkit-adapter-solana/react";
24
+ import "@solana/web3.js";
25
+ import "wagmi";
26
+ import "@reown/appkit-controllers";
14
27
  import { useGetHistoryQuery } from "../../queries/useGetHistory.query.mjs";
15
28
  import { formatAmount } from "../../utils/formatAmount.mjs";
16
29
  import { mxClsx } from "../../utils/mxClsx.mjs";
@@ -25,10 +38,25 @@ const BridgeHistory = ({
25
38
  mvxAddress,
26
39
  onClose
27
40
  }) => {
28
- const { options } = useWeb3App();
29
- const { data, isLoading, isError } = useGetHistoryQuery({
41
+ const { options, bridgeOnly } = useWeb3App();
42
+ const bridgeAccount = useAccount();
43
+ const {
44
+ data: mvxTransactions,
45
+ isLoading,
46
+ isError
47
+ } = useGetHistoryQuery({
30
48
  address: mvxAddress
31
49
  });
50
+ const { data: bridgeTransactions } = useGetHistoryQuery({
51
+ address: bridgeAccount.address ?? ""
52
+ });
53
+ const mergedTransactions = useMemo(() => {
54
+ const mvxTxs = mvxTransactions ?? [];
55
+ const bridgeTxs = bridgeOnly && bridgeTransactions ? bridgeTransactions : [];
56
+ return [...mvxTxs, ...bridgeTxs].sort(
57
+ (a, b) => b.depositTimestamp - a.depositTimestamp
58
+ );
59
+ }, [bridgeOnly, bridgeTransactions, mvxTransactions]);
32
60
  const resolveTransactionIcon = useCallback((transaction) => {
33
61
  switch (transaction.status) {
34
62
  case "success":
@@ -61,7 +89,7 @@ const BridgeHistory = ({
61
89
  }
62
90
  }, []);
63
91
  const transactions = useMemo(
64
- () => data == null ? void 0 : data.map((transaction) => {
92
+ () => mergedTransactions == null ? void 0 : mergedTransactions.map((transaction) => {
65
93
  return {
66
94
  ...transaction,
67
95
  tokenDestination: transaction.tokenOut.toLowerCase(),
@@ -70,7 +98,7 @@ const BridgeHistory = ({
70
98
  statusIcon: resolveTransactionIcon(transaction)
71
99
  };
72
100
  }),
73
- [data, resolveTransactionIcon]
101
+ [mergedTransactions, resolveTransactionIcon]
74
102
  );
75
103
  const {
76
104
  evmTokensWithBalances,
@@ -2,8 +2,13 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
- const allNetworks = require("../../../../../../all-networks-NYACMyeN.js");
5
+ require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
6
+ require("@multiversx/sdk-dapp-utils/out/helpers/stringIsInteger");
7
+ require("bignumber.js");
6
8
  require("../../../../../constants/index.js");
9
+ require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
10
+ const reactjs_utils_mxClsx = require("../../../../../utils/mxClsx.js");
11
+ const allNetworks = require("../../../../../../all-networks-NYACMyeN.js");
7
12
  const reactjs_constants_chains = require("../../../../../constants/chains.js");
8
13
  const ChainOptionLabel = ({
9
14
  chain,
@@ -21,7 +26,9 @@ const ChainOptionLabel = ({
21
26
  src: chain.pngUrl ?? reactjs_constants_chains.chainIdentifier[chain.name],
22
27
  alt: "",
23
28
  loading: "lazy",
24
- className: "liq-h-full liq-w-full liq-rounded-lg"
29
+ className: reactjs_utils_mxClsx.mxClsx("liq-h-full liq-w-full", {
30
+ "liq-rounded-lg": chain.id !== reactjs_constants_chains.ALL_NETWORK_ID
31
+ })
25
32
  }
26
33
  ) : /* @__PURE__ */ jsxRuntime.jsx(
27
34
  "img",
@@ -1,7 +1,12 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { A as AllNetworks } from "../../../../../../all-networks-EJIVYZ_i.mjs";
2
+ import "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
3
+ import "@multiversx/sdk-dapp-utils/out/helpers/stringIsInteger";
4
+ import "bignumber.js";
3
5
  import "../../../../../constants/index.mjs";
4
- import { chainIdentifier } from "../../../../../constants/chains.mjs";
6
+ import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
7
+ import { mxClsx } from "../../../../../utils/mxClsx.mjs";
8
+ import { A as AllNetworks } from "../../../../../../all-networks-EJIVYZ_i.mjs";
9
+ import { chainIdentifier, ALL_NETWORK_ID } from "../../../../../constants/chains.mjs";
5
10
  const ChainOptionLabel = ({
6
11
  chain,
7
12
  inDropdown = false
@@ -18,7 +23,9 @@ const ChainOptionLabel = ({
18
23
  src: chain.pngUrl ?? chainIdentifier[chain.name],
19
24
  alt: "",
20
25
  loading: "lazy",
21
- className: "liq-h-full liq-w-full liq-rounded-lg"
26
+ className: mxClsx("liq-h-full liq-w-full", {
27
+ "liq-rounded-lg": chain.id !== ALL_NETWORK_ID
28
+ })
22
29
  }
23
30
  ) : /* @__PURE__ */ jsx(
24
31
  "img",
@@ -3,8 +3,13 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const Select = require("react-select");
6
- const allNetworks = require("../../../../../../all-networks-NYACMyeN.js");
6
+ require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
7
+ require("@multiversx/sdk-dapp-utils/out/helpers/stringIsInteger");
8
+ require("bignumber.js");
7
9
  require("../../../../../constants/index.js");
10
+ require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
11
+ const reactjs_utils_mxClsx = require("../../../../../utils/mxClsx.js");
12
+ const allNetworks = require("../../../../../../all-networks-NYACMyeN.js");
8
13
  const reactjs_constants_chains = require("../../../../../constants/chains.js");
9
14
  const SelectedChainOption = ({
10
15
  ...props
@@ -24,7 +29,9 @@ const SelectedChainOption = ({
24
29
  src: chain.pngUrl ?? reactjs_constants_chains.chainIdentifier[chain.name],
25
30
  alt: "",
26
31
  loading: "lazy",
27
- className: "liq-h-full liq-w-full liq-rounded-lg"
32
+ className: reactjs_utils_mxClsx.mxClsx("liq-h-full liq-w-full", {
33
+ "liq-rounded-lg": (chain == null ? void 0 : chain.id) !== reactjs_constants_chains.ALL_NETWORK_ID
34
+ })
28
35
  }
29
36
  ) : /* @__PURE__ */ jsxRuntime.jsx("img", { src: allNetworks.AllNetworks, alt: "", className: "liq-h-full liq-w-full" })
30
37
  }
@@ -1,8 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { components } from "react-select";
3
- import { A as AllNetworks } from "../../../../../../all-networks-EJIVYZ_i.mjs";
3
+ import "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
4
+ import "@multiversx/sdk-dapp-utils/out/helpers/stringIsInteger";
5
+ import "bignumber.js";
4
6
  import "../../../../../constants/index.mjs";
5
- import { chainIdentifier } from "../../../../../constants/chains.mjs";
7
+ import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
8
+ import { mxClsx } from "../../../../../utils/mxClsx.mjs";
9
+ import { A as AllNetworks } from "../../../../../../all-networks-EJIVYZ_i.mjs";
10
+ import { chainIdentifier, ALL_NETWORK_ID } from "../../../../../constants/chains.mjs";
6
11
  const SelectedChainOption = ({
7
12
  ...props
8
13
  }) => {
@@ -21,7 +26,9 @@ const SelectedChainOption = ({
21
26
  src: chain.pngUrl ?? chainIdentifier[chain.name],
22
27
  alt: "",
23
28
  loading: "lazy",
24
- className: "liq-h-full liq-w-full liq-rounded-lg"
29
+ className: mxClsx("liq-h-full liq-w-full", {
30
+ "liq-rounded-lg": (chain == null ? void 0 : chain.id) !== ALL_NETWORK_ID
31
+ })
25
32
  }
26
33
  ) : /* @__PURE__ */ jsx("img", { src: AllNetworks, alt: "", className: "liq-h-full liq-w-full" })
27
34
  }