@multiversx/sdk-dapp-liquidity 1.1.0-alpha.20 → 1.1.0-alpha.22

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
@@ -53,7 +53,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./reactjs/hooks/
53
53
  const reactjs_hooks_validation_useTestHasEnoughFunds = require("./reactjs/hooks/validation/useTestHasEnoughFunds.js");
54
54
  const reactjs_hooks_validation_useTestIsConnected = require("./reactjs/hooks/validation/useTestIsConnected.js");
55
55
  const reactjs_hooks_useAccount = require("./reactjs/hooks/useAccount.js");
56
- const reactjs_hooks_useBalances = require("./useBalances-Vfi3IkES.js");
56
+ const reactjs_hooks_useBalances = require("./useBalances-BwQplEkY.js");
57
57
  const reactjs_hooks_useBridgeFormik = require("./reactjs/hooks/useBridgeFormik.js");
58
58
  const reactjs_hooks_useDebounce = require("./reactjs/hooks/useDebounce.js");
59
59
  const reactjs_hooks_useFetchBridgeData = require("./reactjs/hooks/useFetchBridgeData.js");
package/index.mjs CHANGED
@@ -50,7 +50,7 @@ import { useSecondAmountSchema } from "./reactjs/hooks/validation/useSecondAmoun
50
50
  import { useTestHasEnoughFunds } from "./reactjs/hooks/validation/useTestHasEnoughFunds.mjs";
51
51
  import { useTestIsConnected } from "./reactjs/hooks/validation/useTestIsConnected.mjs";
52
52
  import { useAccount } from "./reactjs/hooks/useAccount.mjs";
53
- import { u } from "./useBalances-DTvWU9si.mjs";
53
+ import { u } from "./useBalances-BWufkhuy.mjs";
54
54
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./reactjs/hooks/useBridgeFormik.mjs";
55
55
  import { useDebounce } from "./reactjs/hooks/useDebounce.mjs";
56
56
  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.1.0-alpha.20",
31
+ "version": "1.1.0-alpha.22",
32
32
  "main": "index.js",
33
33
  "module": "index.mjs",
34
34
  "types": "index.d.ts",
@@ -4,6 +4,8 @@ interface BridgeFormProps {
4
4
  username?: string;
5
5
  nativeAuthToken?: string;
6
6
  callbackRoute?: string;
7
+ firstTokenIdentifier?: string;
8
+ secondTokenIdentifier?: string;
7
9
  refetchTrigger?: number;
8
10
  showHistory?: boolean;
9
11
  onSuccessfullySentTransaction?: (txHashes?: string[]) => void;
@@ -13,5 +15,5 @@ interface BridgeFormProps {
13
15
  onMvxDisconnect?: () => void;
14
16
  onNavigate?: (url: string, options?: object) => void;
15
17
  }
16
- export declare const BridgeForm: ({ mvxChainId, mvxAddress, username, nativeAuthToken, callbackRoute, refetchTrigger, showHistory, onSuccessfullySentTransaction, onFailedSentTransaction, onHistoryClose, onMvxConnect, onMvxDisconnect, onNavigate }: BridgeFormProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const BridgeForm: ({ mvxChainId, mvxAddress, username, nativeAuthToken, callbackRoute, firstTokenIdentifier, secondTokenIdentifier, refetchTrigger, showHistory, onSuccessfullySentTransaction, onFailedSentTransaction, onHistoryClose, onMvxConnect, onMvxDisconnect, onNavigate }: BridgeFormProps) => import("react/jsx-runtime").JSX.Element;
17
19
  export {};
@@ -44,7 +44,7 @@ const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAcco
44
44
  const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
45
45
  const viem = require("viem");
46
46
  const actions = require("viem/actions");
47
- const reactjs_hooks_useBalances = require("../../../useBalances-Vfi3IkES.js");
47
+ const reactjs_hooks_useBalances = require("../../../useBalances-BwQplEkY.js");
48
48
  function deepEqual(a, b) {
49
49
  if (a === b)
50
50
  return true;
@@ -123,6 +123,8 @@ const BridgeForm = ({
123
123
  username,
124
124
  nativeAuthToken,
125
125
  callbackRoute = "/",
126
+ firstTokenIdentifier,
127
+ secondTokenIdentifier,
126
128
  refetchTrigger,
127
129
  showHistory,
128
130
  onSuccessfullySentTransaction,
@@ -310,12 +312,6 @@ const BridgeForm = ({
310
312
  },
311
313
  [callbackRoute, isTokensLoading, onNavigate]
312
314
  );
313
- console.log("BridgeForm", {
314
- firstToken,
315
- secondToken,
316
- fromOptions,
317
- toOptions
318
- });
319
315
  const onChangeFirstSelect = React.useCallback(
320
316
  (option) => {
321
317
  if (!option) {
@@ -361,7 +357,10 @@ const BridgeForm = ({
361
357
  if (isTokensLoading || initializedInitialTokensRef.current) {
362
358
  return;
363
359
  }
364
- const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens();
360
+ const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens({
361
+ firstTokenId: firstTokenIdentifier,
362
+ secondTokenId: secondTokenIdentifier
363
+ });
365
364
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
366
365
  ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
367
366
  )) ?? fromOptions.find(
@@ -465,9 +464,6 @@ const BridgeForm = ({
465
464
  console.error("No bitcoin params");
466
465
  break;
467
466
  }
468
- console.log({
469
- transaction
470
- });
471
467
  const psbt = await bitcoin.signTransaction(
472
468
  transaction.bitcoinParams
473
469
  );
@@ -735,7 +731,7 @@ const BridgeForm = ({
735
731
  reactjs_components_Connect_MvxConnectButton.MvxConnectButton,
736
732
  {
737
733
  mvxAccountAddress: mvxAddress,
738
- chain: mvxChain,
734
+ icon: mvxChain == null ? void 0 : mvxChain.svgUrl,
739
735
  onClick: onMvxConnect
740
736
  }
741
737
  ),
@@ -41,7 +41,7 @@ import { MvxAccountDisplay } from "../Connect/MvxAccountDisplay.mjs";
41
41
  import { TokenSelector } from "../TokenSelector/TokenSelector.mjs";
42
42
  import { hexToString } from "viem";
43
43
  import { waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call } from "viem/actions";
44
- import { g as getAction } from "../../../useBalances-DTvWU9si.mjs";
44
+ import { g as getAction } from "../../../useBalances-BWufkhuy.mjs";
45
45
  function deepEqual(a, b) {
46
46
  if (a === b)
47
47
  return true;
@@ -120,6 +120,8 @@ const BridgeForm = ({
120
120
  username,
121
121
  nativeAuthToken,
122
122
  callbackRoute = "/",
123
+ firstTokenIdentifier,
124
+ secondTokenIdentifier,
123
125
  refetchTrigger,
124
126
  showHistory,
125
127
  onSuccessfullySentTransaction,
@@ -307,12 +309,6 @@ const BridgeForm = ({
307
309
  },
308
310
  [callbackRoute, isTokensLoading, onNavigate]
309
311
  );
310
- console.log("BridgeForm", {
311
- firstToken,
312
- secondToken,
313
- fromOptions,
314
- toOptions
315
- });
316
312
  const onChangeFirstSelect = useCallback(
317
313
  (option) => {
318
314
  if (!option) {
@@ -358,7 +354,10 @@ const BridgeForm = ({
358
354
  if (isTokensLoading || initializedInitialTokensRef.current) {
359
355
  return;
360
356
  }
361
- const initialTokens = getInitialTokens();
357
+ const initialTokens = getInitialTokens({
358
+ firstTokenId: firstTokenIdentifier,
359
+ secondTokenId: secondTokenIdentifier
360
+ });
362
361
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
363
362
  ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
364
363
  )) ?? fromOptions.find(
@@ -462,9 +461,6 @@ const BridgeForm = ({
462
461
  console.error("No bitcoin params");
463
462
  break;
464
463
  }
465
- console.log({
466
- transaction
467
- });
468
464
  const psbt = await bitcoin.signTransaction(
469
465
  transaction.bitcoinParams
470
466
  );
@@ -732,7 +728,7 @@ const BridgeForm = ({
732
728
  MvxConnectButton,
733
729
  {
734
730
  mvxAccountAddress: mvxAddress,
735
- chain: mvxChain,
731
+ icon: mvxChain == null ? void 0 : mvxChain.svgUrl,
736
732
  onClick: onMvxConnect
737
733
  }
738
734
  ),
@@ -179,7 +179,16 @@ const BridgeHistory = ({
179
179
  "liq-text-red-200": transaction.status === "failed"
180
180
  }),
181
181
  children: [
182
- transaction.statusIcon,
182
+ /* @__PURE__ */ jsxRuntime.jsx(
183
+ reactjs_components_base_MxTooltip_MxTooltip.MxTooltip,
184
+ {
185
+ placement: "top",
186
+ buttonText: transaction.statusIcon,
187
+ children: new Date(
188
+ transaction.depositTimestamp * 1e3
189
+ ).toLocaleString()
190
+ }
191
+ ),
183
192
  constants_index.MVX_CHAIN_IDS.includes(transaction.toChainId) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
184
193
  /* @__PURE__ */ jsxRuntime.jsx(
185
194
  reactjs_components_base_MxTooltip_MxTooltip.MxTooltip,
@@ -176,7 +176,16 @@ const BridgeHistory = ({
176
176
  "liq-text-red-200": transaction.status === "failed"
177
177
  }),
178
178
  children: [
179
- transaction.statusIcon,
179
+ /* @__PURE__ */ jsx(
180
+ MxTooltip,
181
+ {
182
+ placement: "top",
183
+ buttonText: transaction.statusIcon,
184
+ children: new Date(
185
+ transaction.depositTimestamp * 1e3
186
+ ).toLocaleString()
187
+ }
188
+ ),
180
189
  MVX_CHAIN_IDS.includes(transaction.toChainId) ? /* @__PURE__ */ jsxs(Fragment, { children: [
181
190
  /* @__PURE__ */ jsx(
182
191
  MxTooltip,
@@ -1,11 +1,9 @@
1
- import { ChainDTO } from '../../../dto/Chain.dto';
2
-
3
1
  interface ConnectButtonProps {
4
2
  mvxAccountAddress?: string;
5
- chain?: ChainDTO;
3
+ icon?: string;
6
4
  disabled?: boolean;
7
5
  className?: string;
8
6
  onClick?: () => void;
9
7
  }
10
- export declare const MvxConnectButton: ({ mvxAccountAddress, chain, disabled, className, onClick }: ConnectButtonProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ export declare const MvxConnectButton: ({ mvxAccountAddress, icon, disabled, className, onClick }: ConnectButtonProps) => import("react/jsx-runtime").JSX.Element | null;
11
9
  export {};
@@ -6,7 +6,7 @@ const reactjs_utils_mxClsx = require("../../utils/mxClsx.js");
6
6
  const reactjs_components_base_MxButton_MxButton = require("../base/MxButton/MxButton.js");
7
7
  const MvxConnectButton = ({
8
8
  mvxAccountAddress,
9
- chain,
9
+ icon,
10
10
  disabled,
11
11
  className = "",
12
12
  onClick
@@ -30,7 +30,7 @@ const MvxConnectButton = ({
30
30
  /* @__PURE__ */ jsxRuntime.jsx(
31
31
  "img",
32
32
  {
33
- src: (chain == null ? void 0 : chain.svgUrl) ?? "",
33
+ src: icon ?? "",
34
34
  alt: "",
35
35
  className: "liq-h-[1.5rem] liq-w-[1.5rem]"
36
36
  }
@@ -3,7 +3,7 @@ import { mxClsx } from "../../utils/mxClsx.mjs";
3
3
  import { MxButton } from "../base/MxButton/MxButton.mjs";
4
4
  const MvxConnectButton = ({
5
5
  mvxAccountAddress,
6
- chain,
6
+ icon,
7
7
  disabled,
8
8
  className = "",
9
9
  onClick
@@ -27,7 +27,7 @@ const MvxConnectButton = ({
27
27
  /* @__PURE__ */ jsx(
28
28
  "img",
29
29
  {
30
- src: (chain == null ? void 0 : chain.svgUrl) ?? "",
30
+ src: icon ?? "",
31
31
  alt: "",
32
32
  className: "liq-h-[1.5rem] liq-w-[1.5rem]"
33
33
  }
@@ -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-Vfi3IkES.js");
9
+ const reactjs_hooks_useBalances = require("../../useBalances-BwQplEkY.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-DTvWU9si.mjs";
6
+ import { u } from "../../useBalances-BWufkhuy.mjs";
7
7
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
8
8
  import { useDebounce } from "./useDebounce.mjs";
9
9
  import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
@@ -15,7 +15,7 @@ require("yup");
15
15
  require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
16
16
  require("../../bignumber-B8vjg9qn.js");
17
17
  require("wagmi");
18
- const reactjs_hooks_useBalances = require("../../useBalances-Vfi3IkES.js");
18
+ const reactjs_hooks_useBalances = require("../../useBalances-BwQplEkY.js");
19
19
  require("formik");
20
20
  require("../constants/index.js");
21
21
  require("@reown/appkit-adapter-solana/react");
@@ -12,7 +12,7 @@ import "yup";
12
12
  import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
13
13
  import "../../bignumber-CKZkoo0g.mjs";
14
14
  import "wagmi";
15
- import { u } from "../../useBalances-DTvWU9si.mjs";
15
+ import { u } from "../../useBalances-BWufkhuy.mjs";
16
16
  import "formik";
17
17
  import "../constants/index.mjs";
18
18
  import "@reown/appkit-adapter-solana/react";
package/reactjs/index.js CHANGED
@@ -36,7 +36,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./hooks/validati
36
36
  const reactjs_hooks_validation_useTestHasEnoughFunds = require("./hooks/validation/useTestHasEnoughFunds.js");
37
37
  const reactjs_hooks_validation_useTestIsConnected = require("./hooks/validation/useTestIsConnected.js");
38
38
  const reactjs_hooks_useAccount = require("./hooks/useAccount.js");
39
- const reactjs_hooks_useBalances = require("../useBalances-Vfi3IkES.js");
39
+ const reactjs_hooks_useBalances = require("../useBalances-BwQplEkY.js");
40
40
  const reactjs_hooks_useBridgeFormik = require("./hooks/useBridgeFormik.js");
41
41
  const reactjs_hooks_useDebounce = require("./hooks/useDebounce.js");
42
42
  const reactjs_hooks_useFetchBridgeData = require("./hooks/useFetchBridgeData.js");
package/reactjs/index.mjs CHANGED
@@ -33,7 +33,7 @@ import { useSecondAmountSchema } from "./hooks/validation/useSecondAmountSchema.
33
33
  import { useTestHasEnoughFunds } from "./hooks/validation/useTestHasEnoughFunds.mjs";
34
34
  import { useTestIsConnected } from "./hooks/validation/useTestIsConnected.mjs";
35
35
  import { useAccount } from "./hooks/useAccount.mjs";
36
- import { u } from "../useBalances-DTvWU9si.mjs";
36
+ import { u } from "../useBalances-BWufkhuy.mjs";
37
37
  import { BridgeFormikValuesEnum, useBridgeFormik } from "./hooks/useBridgeFormik.mjs";
38
38
  import { useDebounce } from "./hooks/useDebounce.mjs";
39
39
  import { useFetchBridgeData } from "./hooks/useFetchBridgeData.mjs";
@@ -9,7 +9,7 @@ require("react");
9
9
  require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
10
10
  require("../../bignumber-B8vjg9qn.js");
11
11
  require("wagmi");
12
- const reactjs_hooks_useBalances = require("../../useBalances-Vfi3IkES.js");
12
+ const reactjs_hooks_useBalances = require("../../useBalances-BwQplEkY.js");
13
13
  require("formik");
14
14
  require("axios");
15
15
  require("../context/Web3AppProvider.js");
@@ -6,7 +6,7 @@ import "react";
6
6
  import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
7
7
  import "../../bignumber-CKZkoo0g.mjs";
8
8
  import "wagmi";
9
- import { u as useBalances } from "../../useBalances-DTvWU9si.mjs";
9
+ import { u as useBalances } from "../../useBalances-BWufkhuy.mjs";
10
10
  import "formik";
11
11
  import "axios";
12
12
  import "../context/Web3AppProvider.mjs";
@@ -2,7 +2,10 @@ export interface InitialTokensType {
2
2
  firstTokenId?: string;
3
3
  secondTokenId?: string;
4
4
  }
5
- export declare const getInitialTokens: () => {
5
+ export declare const getInitialTokens: (initialTokens?: {
6
+ firstTokenId?: string;
7
+ secondTokenId?: string;
8
+ }) => {
6
9
  firstTokenId: string;
7
10
  secondTokenId: string;
8
11
  };
@@ -2,12 +2,12 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const reactjs_constants_index = require("../constants/index.js");
5
- const getInitialTokens = () => {
5
+ const getInitialTokens = (initialTokens) => {
6
6
  const urlParams = new URLSearchParams(reactjs_constants_index.safeWindow.location.search);
7
7
  const { firstToken, secondToken } = Object.fromEntries(urlParams);
8
8
  return {
9
- firstTokenId: firstToken,
10
- secondTokenId: secondToken
9
+ firstTokenId: (initialTokens == null ? void 0 : initialTokens.firstTokenId) || firstToken,
10
+ secondTokenId: (initialTokens == null ? void 0 : initialTokens.secondTokenId) || secondToken
11
11
  };
12
12
  };
13
13
  exports.getInitialTokens = getInitialTokens;
@@ -1,10 +1,10 @@
1
1
  import { safeWindow } from "../constants/index.mjs";
2
- const getInitialTokens = () => {
2
+ const getInitialTokens = (initialTokens) => {
3
3
  const urlParams = new URLSearchParams(safeWindow.location.search);
4
4
  const { firstToken, secondToken } = Object.fromEntries(urlParams);
5
5
  return {
6
- firstTokenId: firstToken,
7
- secondTokenId: secondToken
6
+ firstTokenId: (initialTokens == null ? void 0 : initialTokens.firstTokenId) || firstToken,
7
+ secondTokenId: (initialTokens == null ? void 0 : initialTokens.secondTokenId) || secondToken
8
8
  };
9
9
  };
10
10
  export {
@@ -214,13 +214,13 @@ const useBalances = () => {
214
214
  };
215
215
  }
216
216
  const chainType = (_a = chainsMap[token.chainId]) == null ? void 0 : _a.chainType;
217
- console.log("chainType", {
218
- chainType
219
- });
220
217
  try {
221
218
  let balance = BigInt(0);
222
219
  switch (chainType) {
223
220
  case ChainType.evm:
221
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== ChainType.evm) {
222
+ break;
223
+ }
224
224
  balance = (await getBalance(config, {
225
225
  address,
226
226
  chainId: Number(token.chainId),
@@ -229,6 +229,9 @@ const useBalances = () => {
229
229
  })).value;
230
230
  break;
231
231
  case ChainType.sol:
232
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== ChainType.sol) {
233
+ break;
234
+ }
232
235
  if (!(activeChain == null ? void 0 : activeChain.rpc)) {
233
236
  throw new Error(
234
237
  `RPC URL not found for chain ID: ${token.chainId}`
@@ -237,6 +240,9 @@ const useBalances = () => {
237
240
  balance = await getSolBalance(activeChain == null ? void 0 : activeChain.rpc, address);
238
241
  break;
239
242
  case ChainType.btc:
243
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== ChainType.btc) {
244
+ break;
245
+ }
240
246
  balance = await getBtcBalance();
241
247
  break;
242
248
  case ChainType.mvx:
@@ -216,13 +216,13 @@ const useBalances = () => {
216
216
  };
217
217
  }
218
218
  const chainType = (_a = chainsMap[token.chainId]) == null ? void 0 : _a.chainType;
219
- console.log("chainType", {
220
- chainType
221
- });
222
219
  try {
223
220
  let balance = BigInt(0);
224
221
  switch (chainType) {
225
222
  case types_chainType.ChainType.evm:
223
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== types_chainType.ChainType.evm) {
224
+ break;
225
+ }
226
226
  balance = (await getBalance(config, {
227
227
  address,
228
228
  chainId: Number(token.chainId),
@@ -231,6 +231,9 @@ const useBalances = () => {
231
231
  })).value;
232
232
  break;
233
233
  case types_chainType.ChainType.sol:
234
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== types_chainType.ChainType.sol) {
235
+ break;
236
+ }
234
237
  if (!(activeChain == null ? void 0 : activeChain.rpc)) {
235
238
  throw new Error(
236
239
  `RPC URL not found for chain ID: ${token.chainId}`
@@ -239,6 +242,9 @@ const useBalances = () => {
239
242
  balance = await getSolBalance(activeChain == null ? void 0 : activeChain.rpc, address);
240
243
  break;
241
244
  case types_chainType.ChainType.btc:
245
+ if ((activeChain == null ? void 0 : activeChain.chainType) !== types_chainType.ChainType.btc) {
246
+ break;
247
+ }
242
248
  balance = await getBtcBalance();
243
249
  break;
244
250
  case types_chainType.ChainType.mvx: