@multiversx/sdk-dapp-liquidity 1.0.10 → 1.0.12

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/index.js CHANGED
@@ -52,7 +52,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./reactjs/hooks/
52
52
  const reactjs_hooks_validation_useTestHasEnoughFunds = require("./reactjs/hooks/validation/useTestHasEnoughFunds.js");
53
53
  const reactjs_hooks_validation_useTestIsConnected = require("./reactjs/hooks/validation/useTestIsConnected.js");
54
54
  const reactjs_hooks_useAccount = require("./reactjs/hooks/useAccount.js");
55
- const reactjs_hooks_useBalances = require("./useBalances-Bxtc4GNK.js");
55
+ const reactjs_hooks_useBalances = require("./useBalances-C4YhEYxy.js");
56
56
  const reactjs_hooks_useBridgeFormik = require("./reactjs/hooks/useBridgeFormik.js");
57
57
  const reactjs_hooks_useDebounce = require("./reactjs/hooks/useDebounce.js");
58
58
  const reactjs_hooks_useFetchBridgeData = require("./reactjs/hooks/useFetchBridgeData.js");
package/index.mjs CHANGED
@@ -49,7 +49,7 @@ import { useSecondAmountSchema } from "./reactjs/hooks/validation/useSecondAmoun
49
49
  import { useTestHasEnoughFunds } from "./reactjs/hooks/validation/useTestHasEnoughFunds.mjs";
50
50
  import { useTestIsConnected } from "./reactjs/hooks/validation/useTestIsConnected.mjs";
51
51
  import { useAccount } from "./reactjs/hooks/useAccount.mjs";
52
- import { u } from "./useBalances-DA3zEruz.mjs";
52
+ import { u } from "./useBalances-C_69CFoa.mjs";
53
53
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./reactjs/hooks/useBridgeFormik.mjs";
54
54
  import { useDebounce } from "./reactjs/hooks/useDebounce.mjs";
55
55
  import { useFetchBridgeData } from "./reactjs/hooks/useFetchBridgeData.mjs";
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.0.10",
31
+ "version": "1.0.12",
32
32
  "main": "index.js",
33
33
  "module": "index.mjs",
34
34
  "types": "index.d.ts",
@@ -44,7 +44,7 @@ const reactjs_components_Connect_BridgeAccountDisplay = require("../Connect/Brid
44
44
  const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAccountDisplay.js");
45
45
  const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
46
46
  const actions = require("viem/actions");
47
- const reactjs_hooks_useBalances = require("../../../useBalances-Bxtc4GNK.js");
47
+ const reactjs_hooks_useBalances = require("../../../useBalances-C4YhEYxy.js");
48
48
  function deepEqual(a, b) {
49
49
  if (a === b)
50
50
  return true;
@@ -205,8 +205,9 @@ const BridgeForm = ({
205
205
  )) ?? (chains == null ? void 0 : chains[0]),
206
206
  [activeChain == null ? void 0 : activeChain.id, chains]
207
207
  );
208
- const defaultReceivingToken = toOptions.find(
209
- (x) => x.name.toLowerCase().includes("usdc")
208
+ const defaultReceivingToken = require$$0.useMemo(
209
+ () => toOptions.find((x) => x.symbol.toLowerCase().includes("usdc")),
210
+ [toOptions]
210
211
  );
211
212
  const hasAmounts = firstAmount !== "" && secondAmount !== "";
212
213
  const fetchRateDebounced = require$$0.useCallback(
@@ -295,7 +296,9 @@ const BridgeForm = ({
295
296
  }
296
297
  setFirstToken(() => option);
297
298
  updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
298
- const secondOption = toOptions.find((x) => x.name === (option == null ? void 0 : option.name)) ?? defaultReceivingToken;
299
+ const secondOption = toOptions.find(
300
+ (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
301
+ ) ?? defaultReceivingToken;
299
302
  if (!secondOption) {
300
303
  return;
301
304
  }
@@ -311,7 +314,9 @@ const BridgeForm = ({
311
314
  }
312
315
  setSecondToken(() => option);
313
316
  updateUrlParams({ secondTokenId: option == null ? void 0 : option.address });
314
- const firstOption = fromOptions.find((x) => x.name === (option == null ? void 0 : option.name));
317
+ const firstOption = fromOptions.find(
318
+ (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
319
+ );
315
320
  if (!firstOption) {
316
321
  return;
317
322
  }
@@ -327,7 +332,7 @@ const BridgeForm = ({
327
332
  }
328
333
  const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens();
329
334
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
330
- ({ identifier }) => [initialTokens == null ? void 0 : initialTokens.firstTokenId].includes(identifier)
335
+ ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
331
336
  )) ?? fromOptions.find(
332
337
  (option) => {
333
338
  var _a3;
@@ -335,8 +340,10 @@ const BridgeForm = ({
335
340
  }
336
341
  );
337
342
  const secondOption = (toOptions == null ? void 0 : toOptions.find(
338
- ({ address }) => address === ((firstOption == null ? void 0 : firstOption.name) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId))
339
- )) ?? toOptions.find((x) => x.name === (firstOption == null ? void 0 : firstOption.name)) ?? defaultReceivingToken;
343
+ ({ address }) => address.toLowerCase() === ((firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)).toLowerCase()
344
+ )) ?? toOptions.find(
345
+ (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
346
+ ) ?? defaultReceivingToken;
340
347
  const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a2 = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a2.toLowerCase()) === ((_b2 = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b2.toLowerCase()) && ((_c2 = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c2.toLowerCase()) === ((_d2 = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d2.toLowerCase());
341
348
  if (hasOptionsSelected) {
342
349
  return;
@@ -384,7 +391,7 @@ const BridgeForm = ({
384
391
  confirmations: 1,
385
392
  hash: txHash
386
393
  });
387
- console.log({
394
+ console.info({
388
395
  transactionReceipt,
389
396
  hash: txHash
390
397
  });
@@ -41,7 +41,7 @@ import { BridgeAccountDisplay } from "../Connect/BridgeAccountDisplay.mjs";
41
41
  import { MvxAccountDisplay } from "../Connect/MvxAccountDisplay.mjs";
42
42
  import { TokenSelector } from "../TokenSelector/TokenSelector.mjs";
43
43
  import { waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call } from "viem/actions";
44
- import { g as getAction } from "../../../useBalances-DA3zEruz.mjs";
44
+ import { g as getAction } from "../../../useBalances-C_69CFoa.mjs";
45
45
  function deepEqual(a, b) {
46
46
  if (a === b)
47
47
  return true;
@@ -202,8 +202,9 @@ const BridgeForm = ({
202
202
  )) ?? (chains == null ? void 0 : chains[0]),
203
203
  [activeChain == null ? void 0 : activeChain.id, chains]
204
204
  );
205
- const defaultReceivingToken = toOptions.find(
206
- (x) => x.name.toLowerCase().includes("usdc")
205
+ const defaultReceivingToken = useMemo(
206
+ () => toOptions.find((x) => x.symbol.toLowerCase().includes("usdc")),
207
+ [toOptions]
207
208
  );
208
209
  const hasAmounts = firstAmount !== "" && secondAmount !== "";
209
210
  const fetchRateDebounced = useCallback(
@@ -292,7 +293,9 @@ const BridgeForm = ({
292
293
  }
293
294
  setFirstToken(() => option);
294
295
  updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
295
- const secondOption = toOptions.find((x) => x.name === (option == null ? void 0 : option.name)) ?? defaultReceivingToken;
296
+ const secondOption = toOptions.find(
297
+ (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
298
+ ) ?? defaultReceivingToken;
296
299
  if (!secondOption) {
297
300
  return;
298
301
  }
@@ -308,7 +311,9 @@ const BridgeForm = ({
308
311
  }
309
312
  setSecondToken(() => option);
310
313
  updateUrlParams({ secondTokenId: option == null ? void 0 : option.address });
311
- const firstOption = fromOptions.find((x) => x.name === (option == null ? void 0 : option.name));
314
+ const firstOption = fromOptions.find(
315
+ (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
316
+ );
312
317
  if (!firstOption) {
313
318
  return;
314
319
  }
@@ -324,7 +329,7 @@ const BridgeForm = ({
324
329
  }
325
330
  const initialTokens = getInitialTokens();
326
331
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
327
- ({ identifier }) => [initialTokens == null ? void 0 : initialTokens.firstTokenId].includes(identifier)
332
+ ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
328
333
  )) ?? fromOptions.find(
329
334
  (option) => {
330
335
  var _a3;
@@ -332,8 +337,10 @@ const BridgeForm = ({
332
337
  }
333
338
  );
334
339
  const secondOption = (toOptions == null ? void 0 : toOptions.find(
335
- ({ address }) => address === ((firstOption == null ? void 0 : firstOption.name) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId))
336
- )) ?? toOptions.find((x) => x.name === (firstOption == null ? void 0 : firstOption.name)) ?? defaultReceivingToken;
340
+ ({ address }) => address.toLowerCase() === ((firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)).toLowerCase()
341
+ )) ?? toOptions.find(
342
+ (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
343
+ ) ?? defaultReceivingToken;
337
344
  const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a2 = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a2.toLowerCase()) === ((_b2 = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b2.toLowerCase()) && ((_c2 = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c2.toLowerCase()) === ((_d2 = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d2.toLowerCase());
338
345
  if (hasOptionsSelected) {
339
346
  return;
@@ -381,7 +388,7 @@ const BridgeForm = ({
381
388
  confirmations: 1,
382
389
  hash: txHash
383
390
  });
384
- console.log({
391
+ console.info({
385
392
  transactionReceipt,
386
393
  hash: txHash
387
394
  });
@@ -6,7 +6,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./validation/use
6
6
  const reactjs_hooks_validation_useTestHasEnoughFunds = require("./validation/useTestHasEnoughFunds.js");
7
7
  const reactjs_hooks_validation_useTestIsConnected = require("./validation/useTestIsConnected.js");
8
8
  const reactjs_hooks_useAccount = require("./useAccount.js");
9
- const reactjs_hooks_useBalances = require("../../useBalances-Bxtc4GNK.js");
9
+ const reactjs_hooks_useBalances = require("../../useBalances-C4YhEYxy.js");
10
10
  const reactjs_hooks_useBridgeFormik = require("./useBridgeFormik.js");
11
11
  const reactjs_hooks_useDebounce = require("./useDebounce.js");
12
12
  const reactjs_hooks_useFetchBridgeData = require("./useFetchBridgeData.js");
@@ -3,7 +3,7 @@ import { useSecondAmountSchema } from "./validation/useSecondAmountSchema.mjs";
3
3
  import { useTestHasEnoughFunds } from "./validation/useTestHasEnoughFunds.mjs";
4
4
  import { useTestIsConnected } from "./validation/useTestIsConnected.mjs";
5
5
  import { useAccount } from "./useAccount.mjs";
6
- import { u } from "../../useBalances-DA3zEruz.mjs";
6
+ import { u } from "../../useBalances-C_69CFoa.mjs";
7
7
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
8
8
  import { useDebounce } from "./useDebounce.mjs";
9
9
  import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("react");
5
5
  require("../context/useWeb3App.js");
6
- const reactjs_hooks_useBalances = require("../../useBalances-Bxtc4GNK.js");
6
+ const reactjs_hooks_useBalances = require("../../useBalances-C4YhEYxy.js");
7
7
  exports.useBalances = reactjs_hooks_useBalances.useBalances;
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../context/useWeb3App.mjs";
3
- import { u } from "../../useBalances-DA3zEruz.mjs";
3
+ import { u } from "../../useBalances-C_69CFoa.mjs";
4
4
  export {
5
5
  u as useBalances
6
6
  };
package/reactjs/index.js CHANGED
@@ -35,7 +35,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./hooks/validati
35
35
  const reactjs_hooks_validation_useTestHasEnoughFunds = require("./hooks/validation/useTestHasEnoughFunds.js");
36
36
  const reactjs_hooks_validation_useTestIsConnected = require("./hooks/validation/useTestIsConnected.js");
37
37
  const reactjs_hooks_useAccount = require("./hooks/useAccount.js");
38
- const reactjs_hooks_useBalances = require("../useBalances-Bxtc4GNK.js");
38
+ const reactjs_hooks_useBalances = require("../useBalances-C4YhEYxy.js");
39
39
  const reactjs_hooks_useBridgeFormik = require("./hooks/useBridgeFormik.js");
40
40
  const reactjs_hooks_useDebounce = require("./hooks/useDebounce.js");
41
41
  const reactjs_hooks_useFetchBridgeData = require("./hooks/useFetchBridgeData.js");
package/reactjs/index.mjs CHANGED
@@ -32,7 +32,7 @@ import { useSecondAmountSchema } from "./hooks/validation/useSecondAmountSchema.
32
32
  import { useTestHasEnoughFunds } from "./hooks/validation/useTestHasEnoughFunds.mjs";
33
33
  import { useTestIsConnected } from "./hooks/validation/useTestIsConnected.mjs";
34
34
  import { useAccount } from "./hooks/useAccount.mjs";
35
- import { u } from "../useBalances-DA3zEruz.mjs";
35
+ import { u } from "../useBalances-C_69CFoa.mjs";
36
36
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./hooks/useBridgeFormik.mjs";
37
37
  import { useDebounce } from "./hooks/useDebounce.mjs";
38
38
  import { useFetchBridgeData } from "./hooks/useFetchBridgeData.mjs";
@@ -8,7 +8,7 @@ require("viem/chains");
8
8
  const require$$0 = require("react");
9
9
  const reactQuery = require("@tanstack/react-query");
10
10
  const reactjs_context_queryClient = require("../context/queryClient.js");
11
- const reactjs_hooks_useBalances = require("../../useBalances-Bxtc4GNK.js");
11
+ const reactjs_hooks_useBalances = require("../../useBalances-C4YhEYxy.js");
12
12
  const useGetEvmTokensBalancesQuery = ({
13
13
  tokens,
14
14
  chainId
@@ -5,7 +5,7 @@ import "viem/chains";
5
5
  import { useMemo } from "react";
6
6
  import { useQuery } from "@tanstack/react-query";
7
7
  import { getQueryClient } from "../context/queryClient.mjs";
8
- import { u as useBalances } from "../../useBalances-DA3zEruz.mjs";
8
+ import { u as useBalances } from "../../useBalances-C_69CFoa.mjs";
9
9
  const useGetEvmTokensBalancesQuery = ({
10
10
  tokens,
11
11
  chainId
@@ -169,7 +169,9 @@ const useBalances = () => {
169
169
  const balance = await getBalance(config, {
170
170
  address,
171
171
  chainId: Number(chainId),
172
- token: tokenIdentifier
172
+ // TODO: fix this using the API support
173
+ // omit passing the token for fetching the native currency balance
174
+ token: tokenIdentifier.length > 10 ? tokenIdentifier : void 0
173
175
  });
174
176
  return {
175
177
  tokenId: tokenIdentifier,
@@ -167,7 +167,9 @@ const useBalances = () => {
167
167
  const balance = await getBalance(config, {
168
168
  address,
169
169
  chainId: Number(chainId),
170
- token: tokenIdentifier
170
+ // TODO: fix this using the API support
171
+ // omit passing the token for fetching the native currency balance
172
+ token: tokenIdentifier.length > 10 ? tokenIdentifier : void 0
171
173
  });
172
174
  return {
173
175
  tokenId: tokenIdentifier,