@multiversx/sdk-dapp-liquidity 1.1.0-alpha.1 → 1.1.0-alpha.10
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/README.md +6 -1
- package/api/getTransactions.d.ts +8 -2
- package/api/getTransactions.js +23 -3
- package/api/getTransactions.mjs +23 -3
- package/api/tests/getTokens.spec.js +2 -2
- package/api/tests/getTokens.spec.mjs +2 -2
- package/api/tests/getTransactions.spec.js +79 -69
- package/api/tests/getTransactions.spec.mjs +79 -69
- package/constants/index.d.ts +2 -1
- package/constants/index.js +11 -1
- package/constants/index.mjs +12 -2
- package/dto/Chain.dto.d.ts +3 -1
- package/dto/ConfirmRate.dto.d.ts +1 -0
- package/dto/Token.dto.d.ts +2 -1
- package/index.js +45 -16
- package/index.mjs +16 -17
- package/package.json +9 -5
- package/reactjs/components/BridgeForm/BridgeForm.js +44 -40
- package/reactjs/components/BridgeForm/BridgeForm.mjs +13 -9
- package/reactjs/components/BridgeHistory/BridgeHistory.js +63 -25
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +58 -20
- package/reactjs/components/Connect/BridgeAccountDisplay.js +2 -6
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +2 -6
- package/reactjs/components/Connect/CustomConnectButton.js +2 -6
- package/reactjs/components/Connect/CustomConnectButton.mjs +1 -5
- package/reactjs/components/Connect/SwitchChainButton.js +2 -7
- package/reactjs/components/Connect/SwitchChainButton.mjs +1 -6
- package/reactjs/components/CopyButton/CopyButton.js +2 -2
- package/reactjs/components/CopyButton/CopyButton.mjs +2 -2
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +5 -5
- package/reactjs/components/Error/Error.d.ts +6 -0
- package/reactjs/components/Error/Error.js +67 -0
- package/reactjs/components/Error/Error.mjs +66 -0
- package/reactjs/components/Error/index.d.ts +1 -0
- package/reactjs/components/Error/index.js +5 -0
- package/reactjs/components/Error/index.mjs +4 -0
- package/reactjs/components/TokenSelector/TokenSelector.js +10 -5
- package/reactjs/components/TokenSelector/TokenSelector.mjs +6 -1
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +3 -3
- package/reactjs/components/TokenSelector/components/SelectContent.js +8 -8
- package/reactjs/components/TokenSelector/components/TokenIcon.js +3 -3
- package/reactjs/components/TokenSelector/components/TokenItem.js +14 -9
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +11 -6
- package/reactjs/components/base/MxCard/MxCard.js +2 -2
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.d.ts +4 -0
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +29 -0
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +28 -0
- package/reactjs/components/base/MxCircleLoader/index.d.ts +1 -0
- package/reactjs/components/base/MxCircleLoader/index.js +5 -0
- package/reactjs/components/base/MxCircleLoader/index.mjs +4 -0
- package/reactjs/components/base/MxLink/MxLink.js +2 -2
- package/reactjs/components/base/MxSearch/MxSearch.js +4 -4
- package/reactjs/components/base/MxSlideover/MxSlideover.js +4 -4
- package/reactjs/components/base/MxTooltip/MxTooltip.js +9 -9
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +2 -2
- package/reactjs/components/index.d.ts +1 -0
- package/reactjs/components/index.js +2 -0
- package/reactjs/components/index.mjs +2 -0
- package/reactjs/context/Web3AppProvider.d.ts +3 -1
- package/reactjs/context/Web3AppProvider.js +7 -5
- package/reactjs/context/Web3AppProvider.mjs +4 -2
- package/reactjs/context/useWeb3App.js +2 -2
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +1 -1
- package/reactjs/hooks/useAccount.js +1 -6
- package/reactjs/hooks/useAccount.mjs +1 -6
- package/reactjs/hooks/useBalances.d.ts +4 -3
- package/reactjs/hooks/useBalances.js +13 -1
- package/reactjs/hooks/useBalances.mjs +13 -1
- package/reactjs/hooks/useBridgeFormik.js +9 -16
- package/reactjs/hooks/useBridgeFormik.mjs +0 -7
- package/reactjs/hooks/useDebounce.js +3 -3
- package/reactjs/hooks/useFetchBridgeData.d.ts +54 -5
- package/reactjs/hooks/useFetchTokens.d.ts +38 -4
- package/reactjs/hooks/useFetchTokens.js +9 -9
- package/reactjs/hooks/useFetchTokens.mjs +2 -2
- package/reactjs/hooks/useFiatData.d.ts +36 -3
- package/reactjs/hooks/useFiatData.js +6 -6
- package/reactjs/hooks/useFiatData.mjs +1 -1
- package/reactjs/hooks/useGetChainId.js +3 -3
- package/reactjs/hooks/useGetChainId.mjs +1 -1
- package/reactjs/hooks/useResolveTokenChain.d.ts +16 -1
- package/reactjs/hooks/useResolveTokenChain.js +2 -2
- package/reactjs/hooks/useSendTransactions.js +2 -2
- package/reactjs/hooks/validation/useTestHasEnoughFunds.js +3 -3
- package/reactjs/hooks/validation/useTestIsConnected.js +2 -2
- package/reactjs/index.js +44 -16
- package/reactjs/index.mjs +14 -16
- package/reactjs/init/init.d.ts +220 -1
- package/reactjs/init/init.js +44 -10
- package/reactjs/init/init.mjs +41 -7
- package/reactjs/init/tests/init.spec.js +5 -6
- package/reactjs/init/tests/init.spec.mjs +5 -6
- package/reactjs/queries/index.d.ts +0 -1
- package/reactjs/queries/index.js +0 -2
- package/reactjs/queries/index.mjs +1 -3
- package/reactjs/queries/useGetAllTokens.query.d.ts +17 -1
- package/reactjs/queries/useGetAllTokens.query.js +5 -1
- package/reactjs/queries/useGetAllTokens.query.mjs +5 -1
- package/reactjs/queries/useGetChains.query.d.ts +16 -1
- package/reactjs/queries/useGetChains.query.js +5 -1
- package/reactjs/queries/useGetChains.query.mjs +5 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.d.ts +3 -2
- package/reactjs/queries/useGetEvmTokensBalances.query.js +13 -18
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +13 -18
- package/reactjs/queries/useGetHistory.query.d.ts +9 -1
- package/reactjs/queries/useGetHistory.query.js +23 -5
- package/reactjs/queries/useGetHistory.query.mjs +23 -5
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +2 -1
- package/reactjs/queries/useGetMvxTokensBalances.query.js +2 -2
- package/reactjs/reexports.d.ts +2 -1
- package/reactjs/reexports.js +41 -13
- package/reactjs/reexports.mjs +11 -13
- package/style.css +33 -1730
- package/types/chainType.d.ts +6 -0
- package/types/chainType.js +11 -0
- package/types/chainType.mjs +10 -0
- package/{useBalances-C_69CFoa.mjs → useBalances-MNOkt0CT.mjs} +88 -22
- package/{useBalances-C4YhEYxy.js → useBalances-QuJwkRzs.js} +89 -23
- package/bitcoin-CC1UPyzF.mjs +0 -44057
- package/bitcoin-DgJtQpEP.js +0 -43978
- package/index-0HkMxaG8.js +0 -468
- package/index-CRpflwIF.js +0 -108
- package/index-CpW-TGUF.mjs +0 -108
- package/index-D6X1U8OY.mjs +0 -231
- package/modules/fiat/components/FiatForm/FiatForm.d.ts +0 -9
- package/modules/fiat/components/FiatForm/FiatForm.js +0 -315
- package/modules/fiat/components/FiatForm/FiatForm.mjs +0 -314
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.d.ts +0 -13
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.js +0 -118
- package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.mjs +0 -117
- package/modules/fiat/components/FiatForm/components/AmountInput/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/components/AmountInput/index.js +0 -5
- package/modules/fiat/components/FiatForm/components/AmountInput/index.mjs +0 -4
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.js +0 -74
- package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.mjs +0 -73
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.d.ts +0 -14
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.js +0 -94
- package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.mjs +0 -93
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.js +0 -83
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.mjs +0 -82
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.js +0 -92
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.mjs +0 -91
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.d.ts +0 -5
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.js +0 -30
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.mjs +0 -29
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.d.ts +0 -8
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.js +0 -104
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.mjs +0 -103
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.js +0 -33
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.mjs +0 -32
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.d.ts +0 -7
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.js +0 -21
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.mjs +0 -20
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.d.ts +0 -9
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.js +0 -26
- package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.mjs +0 -25
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.js +0 -5
- package/modules/fiat/components/FiatForm/components/TokenSelector/index.mjs +0 -4
- package/modules/fiat/components/FiatForm/index.d.ts +0 -1
- package/modules/fiat/components/FiatForm/index.js +0 -5
- package/modules/fiat/components/FiatForm/index.mjs +0 -4
- package/modules/fiat/components/index.d.ts +0 -1
- package/modules/fiat/components/index.js +0 -5
- package/modules/fiat/components/index.mjs +0 -4
- package/modules/fiat/context/FiatProvider.d.ts +0 -8
- package/modules/fiat/context/FiatProvider.js +0 -24
- package/modules/fiat/context/FiatProvider.mjs +0 -23
- package/modules/fiat/context/queryClient.d.ts +0 -3
- package/modules/fiat/context/queryClient.js +0 -12
- package/modules/fiat/context/queryClient.mjs +0 -11
- package/modules/fiat/context/useFiat.d.ts +0 -1
- package/modules/fiat/context/useFiat.js +0 -13
- package/modules/fiat/context/useFiat.mjs +0 -12
- package/modules/fiat/hooks/index.d.ts +0 -2
- package/modules/fiat/hooks/index.js +0 -7
- package/modules/fiat/hooks/index.mjs +0 -6
- package/modules/fiat/hooks/useFiatData.d.ts +0 -7
- package/modules/fiat/hooks/useFiatData.js +0 -76
- package/modules/fiat/hooks/useFiatData.mjs +0 -75
- package/modules/fiat/hooks/validation/index.d.ts +0 -1
- package/modules/fiat/hooks/validation/index.js +0 -5
- package/modules/fiat/hooks/validation/index.mjs +0 -4
- package/modules/fiat/hooks/validation/useAmountSchema.d.ts +0 -2
- package/modules/fiat/hooks/validation/useAmountSchema.js +0 -27
- package/modules/fiat/hooks/validation/useAmountSchema.mjs +0 -9
- package/modules/fiat/index.d.ts +0 -8
- package/modules/fiat/index.js +0 -22
- package/modules/fiat/index.mjs +0 -21
- package/modules/fiat/init/index.d.ts +0 -2
- package/modules/fiat/init/index.js +0 -5
- package/modules/fiat/init/index.mjs +0 -4
- package/modules/fiat/init/init.d.ts +0 -22
- package/modules/fiat/init/init.js +0 -15
- package/modules/fiat/init/init.mjs +0 -14
- package/modules/fiat/queries/index.d.ts +0 -2
- package/modules/fiat/queries/index.js +0 -7
- package/modules/fiat/queries/index.mjs +0 -6
- package/modules/fiat/queries/useGetRate.mutation.d.ts +0 -6
- package/modules/fiat/queries/useGetRate.mutation.js +0 -20
- package/modules/fiat/queries/useGetRate.mutation.mjs +0 -19
- package/modules/fiat/queries/useGetTokens.query.d.ts +0 -5
- package/modules/fiat/queries/useGetTokens.query.js +0 -33
- package/modules/fiat/queries/useGetTokens.query.mjs +0 -32
- package/react-B64ZbiKy.mjs +0 -254
- package/react-BozMPLkn.js +0 -3337
- package/react-CN9w_Rtw.mjs +0 -3337
- package/react-CZt9p-RK.mjs +0 -51
- package/react-DSg_4gdG.js +0 -51
- package/react-Wmrk3u2q.js +0 -254
- package/reactjs/queries/useGetTokens.query.d.ts +0 -3
- package/reactjs/queries/useGetTokens.query.js +0 -34
- package/reactjs/queries/useGetTokens.query.mjs +0 -33
- package/w3m-modal-D1GK9s5A.js +0 -356
- package/w3m-modal-DFePcJNd.mjs +0 -356
package/README.md
CHANGED
|
@@ -183,4 +183,9 @@ const App = () => {
|
|
|
183
183
|
</Web3AppProvider>
|
|
184
184
|
)
|
|
185
185
|
}
|
|
186
|
-
```
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Disclaimer
|
|
189
|
+
|
|
190
|
+
1. This package is in active development and is subject to change. We recommend to check the latest version and update your code accordingly.
|
|
191
|
+
2. This package is not fully supported on the Next.js framework. We are working on a solution to make it compatible with Next.js.
|
package/api/getTransactions.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { ProviderType } from 'types/providerType';
|
|
1
2
|
import { TransactionDTO } from 'dto/Transaction.dto';
|
|
2
3
|
import { AxiosResponse } from 'axios';
|
|
3
4
|
|
|
4
|
-
export declare function getTransactions({ url,
|
|
5
|
+
export declare function getTransactions({ url, address, sender, provider, status, tokenIn, tokenOut }: {
|
|
5
6
|
url: string;
|
|
6
|
-
|
|
7
|
+
address: string;
|
|
8
|
+
sender?: string;
|
|
9
|
+
provider?: ProviderType;
|
|
10
|
+
status?: string;
|
|
11
|
+
tokenIn?: string;
|
|
12
|
+
tokenOut?: string;
|
|
7
13
|
}): Promise<AxiosResponse<TransactionDTO[]>>;
|
package/api/getTransactions.js
CHANGED
|
@@ -4,10 +4,30 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
const axios = require("axios");
|
|
5
5
|
async function getTransactions({
|
|
6
6
|
url,
|
|
7
|
-
|
|
7
|
+
address,
|
|
8
|
+
sender,
|
|
9
|
+
provider,
|
|
10
|
+
status,
|
|
11
|
+
tokenIn,
|
|
12
|
+
tokenOut
|
|
8
13
|
}) {
|
|
9
|
-
const
|
|
10
|
-
|
|
14
|
+
const queryParams = new URLSearchParams({
|
|
15
|
+
receiver: address || "",
|
|
16
|
+
sender: sender || "",
|
|
17
|
+
provider: provider || "",
|
|
18
|
+
status: status || "",
|
|
19
|
+
tokenIn: tokenIn || "",
|
|
20
|
+
tokenOut: tokenOut || ""
|
|
21
|
+
});
|
|
22
|
+
const params = Object.entries(Object.fromEntries(queryParams.entries()));
|
|
23
|
+
for (const [key, value] of params) {
|
|
24
|
+
if (value === "") {
|
|
25
|
+
queryParams.delete(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const queryString = queryParams.toString();
|
|
29
|
+
const endpointWithParams = `/transactions?${queryString}`;
|
|
30
|
+
return await axios.get(endpointWithParams, {
|
|
11
31
|
baseURL: url
|
|
12
32
|
});
|
|
13
33
|
}
|
package/api/getTransactions.mjs
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
async function getTransactions({
|
|
3
3
|
url,
|
|
4
|
-
|
|
4
|
+
address,
|
|
5
|
+
sender,
|
|
6
|
+
provider,
|
|
7
|
+
status,
|
|
8
|
+
tokenIn,
|
|
9
|
+
tokenOut
|
|
5
10
|
}) {
|
|
6
|
-
const
|
|
7
|
-
|
|
11
|
+
const queryParams = new URLSearchParams({
|
|
12
|
+
receiver: address || "",
|
|
13
|
+
sender: sender || "",
|
|
14
|
+
provider: provider || "",
|
|
15
|
+
status: status || "",
|
|
16
|
+
tokenIn: tokenIn || "",
|
|
17
|
+
tokenOut: tokenOut || ""
|
|
18
|
+
});
|
|
19
|
+
const params = Object.entries(Object.fromEntries(queryParams.entries()));
|
|
20
|
+
for (const [key, value] of params) {
|
|
21
|
+
if (value === "") {
|
|
22
|
+
queryParams.delete(key);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const queryString = queryParams.toString();
|
|
26
|
+
const endpointWithParams = `/transactions?${queryString}`;
|
|
27
|
+
return await axios.get(endpointWithParams, {
|
|
8
28
|
baseURL: url
|
|
9
29
|
});
|
|
10
30
|
}
|
|
@@ -9,7 +9,7 @@ describe("getTokens", () => {
|
|
|
9
9
|
it("fetches tokens successfully without chainId", async () => {
|
|
10
10
|
const response = [
|
|
11
11
|
{
|
|
12
|
-
chainId: 1,
|
|
12
|
+
chainId: "1",
|
|
13
13
|
address: "0x123",
|
|
14
14
|
name: "Token One",
|
|
15
15
|
symbol: "T1",
|
|
@@ -32,7 +32,7 @@ describe("getTokens", () => {
|
|
|
32
32
|
const chainId = 1;
|
|
33
33
|
const response = [
|
|
34
34
|
{
|
|
35
|
-
chainId: 1,
|
|
35
|
+
chainId: "1",
|
|
36
36
|
address: "0x123",
|
|
37
37
|
name: "Token One",
|
|
38
38
|
symbol: "T1",
|
|
@@ -7,7 +7,7 @@ describe("getTokens", () => {
|
|
|
7
7
|
it("fetches tokens successfully without chainId", async () => {
|
|
8
8
|
const response = [
|
|
9
9
|
{
|
|
10
|
-
chainId: 1,
|
|
10
|
+
chainId: "1",
|
|
11
11
|
address: "0x123",
|
|
12
12
|
name: "Token One",
|
|
13
13
|
symbol: "T1",
|
|
@@ -30,7 +30,7 @@ describe("getTokens", () => {
|
|
|
30
30
|
const chainId = 1;
|
|
31
31
|
const response = [
|
|
32
32
|
{
|
|
33
|
-
chainId: 1,
|
|
33
|
+
chainId: "1",
|
|
34
34
|
address: "0x123",
|
|
35
35
|
name: "Token One",
|
|
36
36
|
symbol: "T1",
|
|
@@ -7,87 +7,97 @@ jest.mock("axios");
|
|
|
7
7
|
const mockedAxios = axios;
|
|
8
8
|
describe("getTransactions", () => {
|
|
9
9
|
const url = "https://api.example.com";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
mockedAxios.get.mockResolvedValue({ data:
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const mockResponse = [
|
|
11
|
+
{
|
|
12
|
+
fromChainId: "97",
|
|
13
|
+
toChainId: "44",
|
|
14
|
+
tokenIn: "0x063b637324e6115f8da67f761A99B7F00B7Fd908",
|
|
15
|
+
tokenOut: "USDT-58d5d0",
|
|
16
|
+
amountIn: "11000000",
|
|
17
|
+
amountOut: "11000000",
|
|
18
|
+
depositTimestamp: 1738054613,
|
|
19
|
+
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
20
|
+
status: "success",
|
|
21
|
+
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
22
|
+
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
23
|
+
fee: "0",
|
|
24
|
+
provider: types_providerType.ProviderType.MultiversxBridge
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
mockedAxios.get.mockClear();
|
|
29
|
+
mockedAxios.get.mockResolvedValue({ data: mockResponse });
|
|
30
|
+
});
|
|
31
|
+
it("fetches transactions with only address parameter", async () => {
|
|
32
|
+
const address = "0x123";
|
|
33
|
+
const result = await api_getTransactions.getTransactions({ url, address });
|
|
34
|
+
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
35
|
+
"/transactions?receiver=0x123",
|
|
36
|
+
{ baseURL: url }
|
|
37
|
+
);
|
|
38
|
+
expect(result.data).toEqual(mockResponse);
|
|
39
|
+
});
|
|
40
|
+
it("fetches transactions with empty address", async () => {
|
|
41
|
+
const address = "";
|
|
42
|
+
const result = await api_getTransactions.getTransactions({ url, address });
|
|
43
|
+
expect(mockedAxios.get).toHaveBeenCalledWith("/transactions?", {
|
|
32
44
|
baseURL: url
|
|
33
45
|
});
|
|
34
|
-
expect(result.data).toEqual(
|
|
46
|
+
expect(result.data).toEqual(mockResponse);
|
|
35
47
|
});
|
|
36
|
-
it("
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
depositTimestamp: 1738054613,
|
|
47
|
-
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
48
|
-
status: "success",
|
|
49
|
-
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
50
|
-
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
51
|
-
fee: "0",
|
|
52
|
-
provider: types_providerType.ProviderType.MultiversxBridge
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
mockedAxios.get.mockResolvedValue({ data: response });
|
|
56
|
-
const result = await api_getTransactions.getTransactions({ url, userWalletAddress });
|
|
48
|
+
it("includes all non-empty parameters in the query", async () => {
|
|
49
|
+
const result = await api_getTransactions.getTransactions({
|
|
50
|
+
url,
|
|
51
|
+
address: "0x123",
|
|
52
|
+
sender: "0xABC",
|
|
53
|
+
provider: types_providerType.ProviderType.MultiversxBridge,
|
|
54
|
+
status: "success",
|
|
55
|
+
tokenIn: "0xTOKEN",
|
|
56
|
+
tokenOut: "WEGLD-123456"
|
|
57
|
+
});
|
|
57
58
|
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
58
|
-
|
|
59
|
+
"/transactions?receiver=0x123&sender=0xABC&provider=multiversx-bridge&status=success&tokenIn=0xTOKEN&tokenOut=WEGLD-123456",
|
|
59
60
|
{ baseURL: url }
|
|
60
61
|
);
|
|
61
|
-
expect(result.data).toEqual(
|
|
62
|
+
expect(result.data).toEqual(mockResponse);
|
|
62
63
|
});
|
|
63
|
-
it("
|
|
64
|
-
const userWalletAddress = "0x123";
|
|
65
|
-
const response = [
|
|
66
|
-
{
|
|
67
|
-
fromChainId: "97",
|
|
68
|
-
toChainId: "44",
|
|
69
|
-
tokenIn: "0x063b637324e6115f8da67f761A99B7F00B7Fd908",
|
|
70
|
-
tokenOut: "USDT-58d5d0",
|
|
71
|
-
amountIn: "11000000",
|
|
72
|
-
amountOut: "11000000",
|
|
73
|
-
depositTimestamp: 1738054613,
|
|
74
|
-
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
75
|
-
status: "success",
|
|
76
|
-
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
77
|
-
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
78
|
-
fee: "0",
|
|
79
|
-
provider: types_providerType.ProviderType.MultiversxBridge
|
|
80
|
-
}
|
|
81
|
-
];
|
|
82
|
-
mockedAxios.get.mockResolvedValue({ data: response });
|
|
64
|
+
it("excludes empty parameters from the query", async () => {
|
|
83
65
|
const result = await api_getTransactions.getTransactions({
|
|
84
66
|
url,
|
|
85
|
-
|
|
67
|
+
address: "0x123",
|
|
68
|
+
sender: "",
|
|
69
|
+
provider: types_providerType.ProviderType.MultiversxBridge,
|
|
70
|
+
status: "",
|
|
71
|
+
tokenIn: "0xTOKEN",
|
|
72
|
+
tokenOut: ""
|
|
86
73
|
});
|
|
87
74
|
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
88
|
-
|
|
75
|
+
"/transactions?receiver=0x123&provider=multiversx-bridge&tokenIn=0xTOKEN",
|
|
89
76
|
{ baseURL: url }
|
|
90
77
|
);
|
|
91
|
-
expect(result.data).toEqual(
|
|
78
|
+
expect(result.data).toEqual(mockResponse);
|
|
79
|
+
});
|
|
80
|
+
it("handles axios error", async () => {
|
|
81
|
+
const error = new Error("Network error");
|
|
82
|
+
mockedAxios.get.mockRejectedValueOnce(error);
|
|
83
|
+
await expect(api_getTransactions.getTransactions({ url, address: "0x123" })).rejects.toThrow(
|
|
84
|
+
"Network error"
|
|
85
|
+
);
|
|
86
|
+
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
87
|
+
"/transactions?receiver=0x123",
|
|
88
|
+
{ baseURL: url }
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
it("passes through axios response", async () => {
|
|
92
|
+
const axiosResponse = {
|
|
93
|
+
data: mockResponse,
|
|
94
|
+
status: 200,
|
|
95
|
+
statusText: "OK",
|
|
96
|
+
headers: {},
|
|
97
|
+
config: {}
|
|
98
|
+
};
|
|
99
|
+
mockedAxios.get.mockResolvedValueOnce(axiosResponse);
|
|
100
|
+
const result = await api_getTransactions.getTransactions({ url, address: "0x123" });
|
|
101
|
+
expect(result).toEqual(axiosResponse);
|
|
92
102
|
});
|
|
93
103
|
});
|
|
@@ -5,87 +5,97 @@ jest.mock("axios");
|
|
|
5
5
|
const mockedAxios = axios;
|
|
6
6
|
describe("getTransactions", () => {
|
|
7
7
|
const url = "https://api.example.com";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mockedAxios.get.mockResolvedValue({ data:
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
const mockResponse = [
|
|
9
|
+
{
|
|
10
|
+
fromChainId: "97",
|
|
11
|
+
toChainId: "44",
|
|
12
|
+
tokenIn: "0x063b637324e6115f8da67f761A99B7F00B7Fd908",
|
|
13
|
+
tokenOut: "USDT-58d5d0",
|
|
14
|
+
amountIn: "11000000",
|
|
15
|
+
amountOut: "11000000",
|
|
16
|
+
depositTimestamp: 1738054613,
|
|
17
|
+
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
18
|
+
status: "success",
|
|
19
|
+
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
20
|
+
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
21
|
+
fee: "0",
|
|
22
|
+
provider: ProviderType.MultiversxBridge
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
mockedAxios.get.mockClear();
|
|
27
|
+
mockedAxios.get.mockResolvedValue({ data: mockResponse });
|
|
28
|
+
});
|
|
29
|
+
it("fetches transactions with only address parameter", async () => {
|
|
30
|
+
const address = "0x123";
|
|
31
|
+
const result = await getTransactions({ url, address });
|
|
32
|
+
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
33
|
+
"/transactions?receiver=0x123",
|
|
34
|
+
{ baseURL: url }
|
|
35
|
+
);
|
|
36
|
+
expect(result.data).toEqual(mockResponse);
|
|
37
|
+
});
|
|
38
|
+
it("fetches transactions with empty address", async () => {
|
|
39
|
+
const address = "";
|
|
40
|
+
const result = await getTransactions({ url, address });
|
|
41
|
+
expect(mockedAxios.get).toHaveBeenCalledWith("/transactions?", {
|
|
30
42
|
baseURL: url
|
|
31
43
|
});
|
|
32
|
-
expect(result.data).toEqual(
|
|
44
|
+
expect(result.data).toEqual(mockResponse);
|
|
33
45
|
});
|
|
34
|
-
it("
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
depositTimestamp: 1738054613,
|
|
45
|
-
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
46
|
-
status: "success",
|
|
47
|
-
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
48
|
-
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
49
|
-
fee: "0",
|
|
50
|
-
provider: ProviderType.MultiversxBridge
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
mockedAxios.get.mockResolvedValue({ data: response });
|
|
54
|
-
const result = await getTransactions({ url, userWalletAddress });
|
|
46
|
+
it("includes all non-empty parameters in the query", async () => {
|
|
47
|
+
const result = await getTransactions({
|
|
48
|
+
url,
|
|
49
|
+
address: "0x123",
|
|
50
|
+
sender: "0xABC",
|
|
51
|
+
provider: ProviderType.MultiversxBridge,
|
|
52
|
+
status: "success",
|
|
53
|
+
tokenIn: "0xTOKEN",
|
|
54
|
+
tokenOut: "WEGLD-123456"
|
|
55
|
+
});
|
|
55
56
|
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
56
|
-
|
|
57
|
+
"/transactions?receiver=0x123&sender=0xABC&provider=multiversx-bridge&status=success&tokenIn=0xTOKEN&tokenOut=WEGLD-123456",
|
|
57
58
|
{ baseURL: url }
|
|
58
59
|
);
|
|
59
|
-
expect(result.data).toEqual(
|
|
60
|
+
expect(result.data).toEqual(mockResponse);
|
|
60
61
|
});
|
|
61
|
-
it("
|
|
62
|
-
const userWalletAddress = "0x123";
|
|
63
|
-
const response = [
|
|
64
|
-
{
|
|
65
|
-
fromChainId: "97",
|
|
66
|
-
toChainId: "44",
|
|
67
|
-
tokenIn: "0x063b637324e6115f8da67f761A99B7F00B7Fd908",
|
|
68
|
-
tokenOut: "USDT-58d5d0",
|
|
69
|
-
amountIn: "11000000",
|
|
70
|
-
amountOut: "11000000",
|
|
71
|
-
depositTimestamp: 1738054613,
|
|
72
|
-
sender: "0x1009c2f59e03c383ca8f2766cfe305a1e79f4c8d",
|
|
73
|
-
status: "success",
|
|
74
|
-
receiver: "erd1sp0aaszznqnuvyvkmxkv2ultcvlf637c093sfc26dszks60jdqsqy2knqu",
|
|
75
|
-
txHash: "0xe7e706c1793d06a252a3f040f07732989e4a6466d804cae17105c09818bc2994",
|
|
76
|
-
fee: "0",
|
|
77
|
-
provider: ProviderType.MultiversxBridge
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
mockedAxios.get.mockResolvedValue({ data: response });
|
|
62
|
+
it("excludes empty parameters from the query", async () => {
|
|
81
63
|
const result = await getTransactions({
|
|
82
64
|
url,
|
|
83
|
-
|
|
65
|
+
address: "0x123",
|
|
66
|
+
sender: "",
|
|
67
|
+
provider: ProviderType.MultiversxBridge,
|
|
68
|
+
status: "",
|
|
69
|
+
tokenIn: "0xTOKEN",
|
|
70
|
+
tokenOut: ""
|
|
84
71
|
});
|
|
85
72
|
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
86
|
-
|
|
73
|
+
"/transactions?receiver=0x123&provider=multiversx-bridge&tokenIn=0xTOKEN",
|
|
87
74
|
{ baseURL: url }
|
|
88
75
|
);
|
|
89
|
-
expect(result.data).toEqual(
|
|
76
|
+
expect(result.data).toEqual(mockResponse);
|
|
77
|
+
});
|
|
78
|
+
it("handles axios error", async () => {
|
|
79
|
+
const error = new Error("Network error");
|
|
80
|
+
mockedAxios.get.mockRejectedValueOnce(error);
|
|
81
|
+
await expect(getTransactions({ url, address: "0x123" })).rejects.toThrow(
|
|
82
|
+
"Network error"
|
|
83
|
+
);
|
|
84
|
+
expect(mockedAxios.get).toHaveBeenCalledWith(
|
|
85
|
+
"/transactions?receiver=0x123",
|
|
86
|
+
{ baseURL: url }
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
it("passes through axios response", async () => {
|
|
90
|
+
const axiosResponse = {
|
|
91
|
+
data: mockResponse,
|
|
92
|
+
status: 200,
|
|
93
|
+
statusText: "OK",
|
|
94
|
+
headers: {},
|
|
95
|
+
config: {}
|
|
96
|
+
};
|
|
97
|
+
mockedAxios.get.mockResolvedValueOnce(axiosResponse);
|
|
98
|
+
const result = await getTransactions({ url, address: "0x123" });
|
|
99
|
+
expect(result).toEqual(axiosResponse);
|
|
90
100
|
});
|
|
91
101
|
});
|
package/constants/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const MVX_CHAIN_IDS:
|
|
1
|
+
export declare const MVX_CHAIN_IDS: string[];
|
|
2
|
+
export declare const NON_EVM_CHAIN_IDS_MAP: Record<string, string>;
|
package/constants/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const MVX_CHAIN_IDS = [31, 44, 54];
|
|
4
|
+
const MVX_CHAIN_IDS = ["31", "44", "54"];
|
|
5
|
+
const NON_EVM_CHAIN_IDS_MAP = {
|
|
6
|
+
"0": "000000000019d6689c085ae165831e93",
|
|
7
|
+
// Bitcoin
|
|
8
|
+
// TODO chain ID to be defined at the API level
|
|
9
|
+
"-1": "000000000933ea01ad0ee984209779ba",
|
|
10
|
+
// Bitcoin Testnet
|
|
11
|
+
"101": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
12
|
+
"103": "EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
|
|
13
|
+
};
|
|
5
14
|
exports.MVX_CHAIN_IDS = MVX_CHAIN_IDS;
|
|
15
|
+
exports.NON_EVM_CHAIN_IDS_MAP = NON_EVM_CHAIN_IDS_MAP;
|
package/constants/index.mjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
const MVX_CHAIN_IDS = [31, 44, 54];
|
|
1
|
+
const MVX_CHAIN_IDS = ["31", "44", "54"];
|
|
2
|
+
const NON_EVM_CHAIN_IDS_MAP = {
|
|
3
|
+
"0": "000000000019d6689c085ae165831e93",
|
|
4
|
+
// Bitcoin
|
|
5
|
+
// TODO chain ID to be defined at the API level
|
|
6
|
+
"-1": "000000000933ea01ad0ee984209779ba",
|
|
7
|
+
// Bitcoin Testnet
|
|
8
|
+
"101": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
9
|
+
"103": "EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
|
|
10
|
+
};
|
|
2
11
|
export {
|
|
3
|
-
MVX_CHAIN_IDS
|
|
12
|
+
MVX_CHAIN_IDS,
|
|
13
|
+
NON_EVM_CHAIN_IDS_MAP
|
|
4
14
|
};
|
package/dto/Chain.dto.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ChainType } from '../types/chainType';
|
|
2
|
+
|
|
1
3
|
export interface ChainDTO {
|
|
2
4
|
chainId: string;
|
|
3
5
|
chainName: string;
|
|
4
6
|
pngUrl: string;
|
|
5
7
|
svgUrl: string;
|
|
6
|
-
chainType:
|
|
8
|
+
chainType: ChainType;
|
|
7
9
|
rpc: string;
|
|
8
10
|
networkName: string;
|
|
9
11
|
nativeCurrency: {
|
package/dto/ConfirmRate.dto.d.ts
CHANGED
package/dto/Token.dto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface TokenDTO {
|
|
2
|
-
chainId:
|
|
2
|
+
chainId: string;
|
|
3
3
|
address: string;
|
|
4
4
|
name: string;
|
|
5
5
|
symbol: string;
|
|
@@ -12,4 +12,5 @@ export interface TokenDTO {
|
|
|
12
12
|
maxBridgeAmount: string;
|
|
13
13
|
};
|
|
14
14
|
availableTokens?: string[];
|
|
15
|
+
isNative?: boolean;
|
|
15
16
|
}
|