@multiversx/sdk-dapp-liquidity 1.1.1-alpha.6 → 1.1.2-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/api/tests/getChains.spec.js +1 -1
- package/api/tests/getChains.spec.mjs +1 -1
- package/api/tests/getTokens.spec.js +2 -4
- package/api/tests/getTokens.spec.mjs +2 -4
- package/api/tests/getTransactions.spec.js +5 -19
- package/api/tests/getTransactions.spec.mjs +5 -19
- package/package.json +17 -10
- package/reactjs/components/BridgeForm/BridgeForm.js +11 -4
- package/reactjs/components/BridgeForm/BridgeForm.mjs +11 -4
- package/reactjs/components/BridgeForm/Deposit.js +62 -266
- package/reactjs/components/BridgeForm/Deposit.mjs +59 -263
- package/reactjs/components/BridgeForm/Transfer.js +68 -247
- package/reactjs/components/BridgeForm/Transfer.mjs +66 -245
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.d.ts +22 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.js +79 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.mjs +78 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.d.ts +26 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.js +59 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.mjs +58 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.d.ts +87 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +245 -0
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +244 -0
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.d.ts +16 -0
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +59 -0
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +58 -0
- package/reactjs/components/Connect/BridgeAccountDisplay.js +2 -1
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +2 -1
- package/reactjs/components/DisplayAmount/DisplayAmount.js +5 -5
- package/reactjs/components/DisplayAmount/DisplayAmount.mjs +1 -1
- package/reactjs/components/Error/Error.js +1 -1
- package/reactjs/components/Error/Error.mjs +1 -1
- package/reactjs/components/TokenSelector/TokenSelector.js +2 -1
- package/reactjs/components/TokenSelector/TokenSelector.mjs +2 -1
- package/reactjs/components/TokenSelector/components/SelectContent.js +38 -8
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +38 -8
- package/reactjs/context/Web3AppProvider.d.ts +2 -2
- package/reactjs/hooks/useAccount.d.ts +19 -19
- package/reactjs/init/init.d.ts +4 -221
- package/reactjs/queries/useCheckAccount.query.js +1 -1
- package/reactjs/queries/useCheckAccount.query.mjs +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +1 -1
- package/reactjs/utils/getCleanStringAmount.js +2 -2
- package/reactjs/utils/getCleanStringAmount.mjs +1 -1
- package/reactjs/utils/hasEnoughFunds.js +3 -3
- package/reactjs/utils/hasEnoughFunds.mjs +1 -1
- package/reactjs/utils/isStringFloat.js +2 -2
- package/reactjs/utils/isStringFloat.mjs +1 -1
- package/reactjs/utils/mxClsx.js +2 -12
- package/reactjs/utils/mxClsx.mjs +1 -11
- package/reactjs/utils/roundAmount.js +4 -4
- package/reactjs/utils/roundAmount.mjs +1 -1
- package/types/transaction.d.ts +2 -2
- package/bignumber-DYhUzmvI.mjs +0 -1334
- package/bignumber-lN9qPw6T.js +0 -1334
- package/getConnections-DQnXNzbL.mjs +0 -50
- package/getConnections-kO4Pfo50.js +0 -50
- package/reactjs/init/tests/init.spec.d.ts +0 -1
- package/reactjs/init/tests/init.spec.js +0 -107
- package/reactjs/init/tests/init.spec.mjs +0 -105
|
@@ -32,7 +32,7 @@ describe("getChains", () => {
|
|
|
32
32
|
nativeAuthToken: "ZKssadass",
|
|
33
33
|
bridgeOnly: false
|
|
34
34
|
});
|
|
35
|
-
expect(mockedAxios.get).
|
|
35
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
36
36
|
expect(result.data).toEqual(response);
|
|
37
37
|
});
|
|
38
38
|
it("handles error when fetching chains", async () => {
|
|
@@ -30,7 +30,7 @@ describe("getChains", () => {
|
|
|
30
30
|
nativeAuthToken: "ZKssadass",
|
|
31
31
|
bridgeOnly: false
|
|
32
32
|
});
|
|
33
|
-
expect(mockedAxios.get).
|
|
33
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
34
34
|
expect(result.data).toEqual(response);
|
|
35
35
|
});
|
|
36
36
|
it("handles error when fetching chains", async () => {
|
|
@@ -29,7 +29,7 @@ describe("getTokens", () => {
|
|
|
29
29
|
nativeAuthToken: "",
|
|
30
30
|
bridgeOnly: false
|
|
31
31
|
});
|
|
32
|
-
expect(mockedAxios.get).
|
|
32
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
33
33
|
expect(result.data).toEqual(response);
|
|
34
34
|
});
|
|
35
35
|
it("fetches tokens successfully with chainId", async () => {
|
|
@@ -57,9 +57,7 @@ describe("getTokens", () => {
|
|
|
57
57
|
nativeAuthToken: "",
|
|
58
58
|
bridgeOnly: false
|
|
59
59
|
});
|
|
60
|
-
expect(mockedAxios.get).
|
|
61
|
-
baseURL: url
|
|
62
|
-
});
|
|
60
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
63
61
|
expect(result.data).toEqual(response);
|
|
64
62
|
});
|
|
65
63
|
it("handles error when fetching tokens", async () => {
|
|
@@ -27,7 +27,7 @@ describe("getTokens", () => {
|
|
|
27
27
|
nativeAuthToken: "",
|
|
28
28
|
bridgeOnly: false
|
|
29
29
|
});
|
|
30
|
-
expect(mockedAxios.get).
|
|
30
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
31
31
|
expect(result.data).toEqual(response);
|
|
32
32
|
});
|
|
33
33
|
it("fetches tokens successfully with chainId", async () => {
|
|
@@ -55,9 +55,7 @@ describe("getTokens", () => {
|
|
|
55
55
|
nativeAuthToken: "",
|
|
56
56
|
bridgeOnly: false
|
|
57
57
|
});
|
|
58
|
-
expect(mockedAxios.get).
|
|
59
|
-
baseURL: url
|
|
60
|
-
});
|
|
58
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
61
59
|
expect(result.data).toEqual(response);
|
|
62
60
|
});
|
|
63
61
|
it("handles error when fetching tokens", async () => {
|
|
@@ -31,18 +31,13 @@ describe("getTransactions", () => {
|
|
|
31
31
|
it("fetches transactions with only address parameter", async () => {
|
|
32
32
|
const address = "0x123";
|
|
33
33
|
const result = await api_getTransactions.getTransactions({ url, address, nativeAuthToken: "" });
|
|
34
|
-
expect(mockedAxios.get).
|
|
35
|
-
"/transactions?receiver=0x123",
|
|
36
|
-
{ baseURL: url }
|
|
37
|
-
);
|
|
34
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
38
35
|
expect(result.data).toEqual(mockResponse);
|
|
39
36
|
});
|
|
40
37
|
it("fetches transactions with empty address", async () => {
|
|
41
38
|
const address = "";
|
|
42
39
|
const result = await api_getTransactions.getTransactions({ url, address, nativeAuthToken: "" });
|
|
43
|
-
expect(mockedAxios.get).
|
|
44
|
-
baseURL: url
|
|
45
|
-
});
|
|
40
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
46
41
|
expect(result.data).toEqual(mockResponse);
|
|
47
42
|
});
|
|
48
43
|
it("includes all non-empty parameters in the query", async () => {
|
|
@@ -56,10 +51,7 @@ describe("getTransactions", () => {
|
|
|
56
51
|
tokenOut: "WEGLD-123456",
|
|
57
52
|
nativeAuthToken: ""
|
|
58
53
|
});
|
|
59
|
-
expect(mockedAxios.get).
|
|
60
|
-
"/transactions?receiver=0x123&sender=0xABC&provider=multiversxBridge&status=success&tokenIn=0xTOKEN&tokenOut=WEGLD-123456",
|
|
61
|
-
{ baseURL: url }
|
|
62
|
-
);
|
|
54
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
63
55
|
expect(result.data).toEqual(mockResponse);
|
|
64
56
|
});
|
|
65
57
|
it("excludes empty parameters from the query", async () => {
|
|
@@ -73,10 +65,7 @@ describe("getTransactions", () => {
|
|
|
73
65
|
tokenOut: "",
|
|
74
66
|
nativeAuthToken: ""
|
|
75
67
|
});
|
|
76
|
-
expect(mockedAxios.get).
|
|
77
|
-
"/transactions?receiver=0x123&provider=multiversxBridge&tokenIn=0xTOKEN",
|
|
78
|
-
{ baseURL: url }
|
|
79
|
-
);
|
|
68
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
80
69
|
expect(result.data).toEqual(mockResponse);
|
|
81
70
|
});
|
|
82
71
|
it("handles axios error", async () => {
|
|
@@ -85,10 +74,7 @@ describe("getTransactions", () => {
|
|
|
85
74
|
await expect(
|
|
86
75
|
api_getTransactions.getTransactions({ url, address: "0x123", nativeAuthToken: "" })
|
|
87
76
|
).rejects.toThrow("Network error");
|
|
88
|
-
expect(mockedAxios.get).
|
|
89
|
-
"/transactions?receiver=0x123",
|
|
90
|
-
{ baseURL: url }
|
|
91
|
-
);
|
|
77
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
92
78
|
});
|
|
93
79
|
it("passes through axios response", async () => {
|
|
94
80
|
const axiosResponse = {
|
|
@@ -29,18 +29,13 @@ describe("getTransactions", () => {
|
|
|
29
29
|
it("fetches transactions with only address parameter", async () => {
|
|
30
30
|
const address = "0x123";
|
|
31
31
|
const result = await getTransactions({ url, address, nativeAuthToken: "" });
|
|
32
|
-
expect(mockedAxios.get).
|
|
33
|
-
"/transactions?receiver=0x123",
|
|
34
|
-
{ baseURL: url }
|
|
35
|
-
);
|
|
32
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
36
33
|
expect(result.data).toEqual(mockResponse);
|
|
37
34
|
});
|
|
38
35
|
it("fetches transactions with empty address", async () => {
|
|
39
36
|
const address = "";
|
|
40
37
|
const result = await getTransactions({ url, address, nativeAuthToken: "" });
|
|
41
|
-
expect(mockedAxios.get).
|
|
42
|
-
baseURL: url
|
|
43
|
-
});
|
|
38
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
44
39
|
expect(result.data).toEqual(mockResponse);
|
|
45
40
|
});
|
|
46
41
|
it("includes all non-empty parameters in the query", async () => {
|
|
@@ -54,10 +49,7 @@ describe("getTransactions", () => {
|
|
|
54
49
|
tokenOut: "WEGLD-123456",
|
|
55
50
|
nativeAuthToken: ""
|
|
56
51
|
});
|
|
57
|
-
expect(mockedAxios.get).
|
|
58
|
-
"/transactions?receiver=0x123&sender=0xABC&provider=multiversxBridge&status=success&tokenIn=0xTOKEN&tokenOut=WEGLD-123456",
|
|
59
|
-
{ baseURL: url }
|
|
60
|
-
);
|
|
52
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
61
53
|
expect(result.data).toEqual(mockResponse);
|
|
62
54
|
});
|
|
63
55
|
it("excludes empty parameters from the query", async () => {
|
|
@@ -71,10 +63,7 @@ describe("getTransactions", () => {
|
|
|
71
63
|
tokenOut: "",
|
|
72
64
|
nativeAuthToken: ""
|
|
73
65
|
});
|
|
74
|
-
expect(mockedAxios.get).
|
|
75
|
-
"/transactions?receiver=0x123&provider=multiversxBridge&tokenIn=0xTOKEN",
|
|
76
|
-
{ baseURL: url }
|
|
77
|
-
);
|
|
66
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
78
67
|
expect(result.data).toEqual(mockResponse);
|
|
79
68
|
});
|
|
80
69
|
it("handles axios error", async () => {
|
|
@@ -83,10 +72,7 @@ describe("getTransactions", () => {
|
|
|
83
72
|
await expect(
|
|
84
73
|
getTransactions({ url, address: "0x123", nativeAuthToken: "" })
|
|
85
74
|
).rejects.toThrow("Network error");
|
|
86
|
-
expect(mockedAxios.get).
|
|
87
|
-
"/transactions?receiver=0x123",
|
|
88
|
-
{ baseURL: url }
|
|
89
|
-
);
|
|
75
|
+
expect(mockedAxios.get).toHaveBeenCalled();
|
|
90
76
|
});
|
|
91
77
|
it("passes through axios response", async () => {
|
|
92
78
|
const axiosResponse = {
|
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.
|
|
31
|
+
"version": "1.1.2-alpha.2",
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"module": "index.mjs",
|
|
34
34
|
"types": "index.d.ts",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"publish-package": "yarn build && cd dist && npm publish",
|
|
40
40
|
"publish-package-next": "yarn build && cd dist && npm publish --tag next",
|
|
41
41
|
"publish-yalc": "yarn build && cd dist && yalc publish --push",
|
|
42
|
+
"publish-verdaccio": "yarn run build && cd dist && npm publish --registry http://localhost:4873/",
|
|
42
43
|
"start": "vite",
|
|
43
44
|
"test": "jest",
|
|
44
45
|
"lint": "eslint src --ext .ts,.js"
|
|
@@ -50,13 +51,15 @@
|
|
|
50
51
|
"@fortawesome/free-solid-svg-icons": "6.5.1",
|
|
51
52
|
"@fortawesome/react-fontawesome": "0.2.0",
|
|
52
53
|
"@headlessui/react": "2.2.0",
|
|
53
|
-
"@multiversx/sdk-dapp-utils": "
|
|
54
|
+
"@multiversx/sdk-dapp-utils": "3.0.2",
|
|
54
55
|
"@popperjs/core": "2.11.8",
|
|
55
|
-
"@reown/appkit": "1.
|
|
56
|
-
"@
|
|
57
|
-
"@reown/appkit-
|
|
58
|
-
"@reown/appkit-adapter-
|
|
59
|
-
"@solana
|
|
56
|
+
"@reown/appkit": "1.8.13",
|
|
57
|
+
"@wagmi/core": "2.22.1",
|
|
58
|
+
"@reown/appkit-common": "1.8.13",
|
|
59
|
+
"@reown/appkit-adapter-bitcoin": "1.8.13",
|
|
60
|
+
"@reown/appkit-adapter-solana": "1.8.13",
|
|
61
|
+
"@reown/appkit-adapter-wagmi": "1.8.13",
|
|
62
|
+
"@solana/web3.js": "1.98.4",
|
|
60
63
|
"@tanstack/react-query": "5.71.3",
|
|
61
64
|
"animated-number-react": "0.1.2",
|
|
62
65
|
"axios": "1.7.4",
|
|
@@ -74,13 +77,17 @@
|
|
|
74
77
|
"yup": "1.4.0"
|
|
75
78
|
},
|
|
76
79
|
"peerDependencies": {
|
|
77
|
-
"@multiversx/sdk-core": ">=
|
|
80
|
+
"@multiversx/sdk-core": ">= 15.x",
|
|
78
81
|
"react": ">= 18",
|
|
79
82
|
"react-dom": ">= 18",
|
|
80
|
-
"tailwindcss": ">= 3"
|
|
83
|
+
"tailwindcss": ">= 3",
|
|
84
|
+
"bignumber.js": ">= 9.x",
|
|
85
|
+
"clsx": ">= 2.x"
|
|
81
86
|
},
|
|
82
87
|
"devDependencies": {
|
|
83
|
-
"
|
|
88
|
+
"clsx": "2.0.0",
|
|
89
|
+
"bignumber.js": "9.0.1",
|
|
90
|
+
"@multiversx/sdk-core": "15.3.0",
|
|
84
91
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
85
92
|
"@swc-node/jest": "1.6.6",
|
|
86
93
|
"@swc/core": "1.5.24",
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const reactjs_components_BridgeForm_Deposit = require("./Deposit.js");
|
|
7
7
|
const reactjs_components_BridgeForm_Transfer = require("./Transfer.js");
|
|
8
|
+
const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
|
|
8
9
|
const BridgeForm = ({
|
|
9
10
|
mvxChainId,
|
|
10
11
|
mvxAddress,
|
|
@@ -26,11 +27,17 @@ const BridgeForm = ({
|
|
|
26
27
|
onHistoryClose,
|
|
27
28
|
onNavigate
|
|
28
29
|
}) => {
|
|
29
|
-
const
|
|
30
|
+
const { bridgeOnly } = reactjs_context_useWeb3App.useWeb3App();
|
|
31
|
+
const [direction, setDirection] = React.useState(
|
|
32
|
+
bridgeOnly === false ? "deposit" : "deposit"
|
|
33
|
+
);
|
|
30
34
|
const handleChangeDirection = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
if (bridgeOnly === false) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
setDirection((prevState) => {
|
|
39
|
+
return prevState === "deposit" ? "withdraw" : "deposit";
|
|
40
|
+
});
|
|
34
41
|
};
|
|
35
42
|
return direction === "deposit" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
43
|
reactjs_components_BridgeForm_Deposit.Deposit,
|
|
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Deposit } from "./Deposit.mjs";
|
|
4
4
|
import { Transfer } from "./Transfer.mjs";
|
|
5
|
+
import { useWeb3App } from "../../context/useWeb3App.mjs";
|
|
5
6
|
const BridgeForm = ({
|
|
6
7
|
mvxChainId,
|
|
7
8
|
mvxAddress,
|
|
@@ -23,11 +24,17 @@ const BridgeForm = ({
|
|
|
23
24
|
onHistoryClose,
|
|
24
25
|
onNavigate
|
|
25
26
|
}) => {
|
|
26
|
-
const
|
|
27
|
+
const { bridgeOnly } = useWeb3App();
|
|
28
|
+
const [direction, setDirection] = useState(
|
|
29
|
+
bridgeOnly === false ? "deposit" : "deposit"
|
|
30
|
+
);
|
|
27
31
|
const handleChangeDirection = () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
if (bridgeOnly === false) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setDirection((prevState) => {
|
|
36
|
+
return prevState === "deposit" ? "withdraw" : "deposit";
|
|
37
|
+
});
|
|
31
38
|
};
|
|
32
39
|
return direction === "deposit" ? /* @__PURE__ */ jsx(
|
|
33
40
|
Deposit,
|