@multiversx/sdk-dapp-liquidity 1.1.0-alpha.2 → 1.1.0-alpha.21

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.
Files changed (234) hide show
  1. package/README.md +6 -1
  2. package/api/getTransactions.d.ts +8 -2
  3. package/api/getTransactions.js +23 -3
  4. package/api/getTransactions.mjs +23 -3
  5. package/api/tests/getChains.spec.js +2 -1
  6. package/api/tests/getChains.spec.mjs +2 -1
  7. package/api/tests/getTokens.spec.js +2 -2
  8. package/api/tests/getTokens.spec.mjs +2 -2
  9. package/api/tests/getTransactions.spec.js +79 -69
  10. package/api/tests/getTransactions.spec.mjs +79 -69
  11. package/constants/index.d.ts +1 -1
  12. package/constants/index.js +1 -1
  13. package/constants/index.mjs +1 -1
  14. package/dto/Chain.dto.d.ts +3 -1
  15. package/dto/ConfirmRate.dto.d.ts +1 -0
  16. package/dto/Token.dto.d.ts +7 -2
  17. package/index.js +44 -16
  18. package/index.mjs +14 -16
  19. package/package.json +10 -6
  20. package/reactjs/components/BridgeForm/BridgeForm.d.ts +3 -1
  21. package/reactjs/components/BridgeForm/BridgeForm.js +182 -87
  22. package/reactjs/components/BridgeForm/BridgeForm.mjs +153 -58
  23. package/reactjs/components/BridgeHistory/BridgeHistory.js +73 -26
  24. package/reactjs/components/BridgeHistory/BridgeHistory.mjs +68 -21
  25. package/reactjs/components/Connect/BridgeAccountDisplay.js +2 -5
  26. package/reactjs/components/Connect/BridgeAccountDisplay.mjs +2 -5
  27. package/reactjs/components/Connect/CustomConnectButton.js +2 -5
  28. package/reactjs/components/Connect/CustomConnectButton.mjs +1 -4
  29. package/reactjs/components/Connect/MvxConnectButton.d.ts +2 -4
  30. package/reactjs/components/Connect/MvxConnectButton.js +2 -2
  31. package/reactjs/components/Connect/MvxConnectButton.mjs +2 -2
  32. package/reactjs/components/Connect/SwitchChainButton.js +2 -6
  33. package/reactjs/components/Connect/SwitchChainButton.mjs +1 -5
  34. package/reactjs/components/CopyButton/CopyButton.js +2 -2
  35. package/reactjs/components/CopyButton/CopyButton.mjs +2 -2
  36. package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +5 -5
  37. package/reactjs/components/Error/Error.d.ts +6 -0
  38. package/reactjs/components/Error/Error.js +67 -0
  39. package/reactjs/components/Error/Error.mjs +66 -0
  40. package/reactjs/components/Error/index.d.ts +1 -0
  41. package/reactjs/components/Error/index.js +5 -0
  42. package/reactjs/components/Error/index.mjs +4 -0
  43. package/reactjs/components/TokenSelector/TokenSelector.d.ts +2 -1
  44. package/reactjs/components/TokenSelector/TokenSelector.js +17 -9
  45. package/reactjs/components/TokenSelector/TokenSelector.mjs +13 -5
  46. package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.d.ts +2 -1
  47. package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +7 -3
  48. package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +4 -0
  49. package/reactjs/components/TokenSelector/components/SelectContent.d.ts +2 -1
  50. package/reactjs/components/TokenSelector/components/SelectContent.js +12 -9
  51. package/reactjs/components/TokenSelector/components/SelectContent.mjs +4 -1
  52. package/reactjs/components/TokenSelector/components/TokenIcon.js +3 -3
  53. package/reactjs/components/TokenSelector/components/TokenItem.js +9 -9
  54. package/reactjs/components/TokenSelector/components/TokenItem.mjs +6 -6
  55. package/reactjs/components/base/MxCard/MxCard.js +2 -2
  56. package/reactjs/components/base/MxCircleLoader/MxCircleLoader.d.ts +4 -0
  57. package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +29 -0
  58. package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +28 -0
  59. package/reactjs/components/base/MxCircleLoader/index.d.ts +1 -0
  60. package/reactjs/components/base/MxCircleLoader/index.js +5 -0
  61. package/reactjs/components/base/MxCircleLoader/index.mjs +4 -0
  62. package/reactjs/components/base/MxLink/MxLink.js +2 -2
  63. package/reactjs/components/base/MxSearch/MxSearch.js +4 -4
  64. package/reactjs/components/base/MxSlideover/MxSlideover.js +4 -4
  65. package/reactjs/components/base/MxTooltip/MxTooltip.js +9 -9
  66. package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +2 -2
  67. package/reactjs/components/index.d.ts +1 -0
  68. package/reactjs/components/index.js +2 -0
  69. package/reactjs/components/index.mjs +2 -0
  70. package/reactjs/context/Web3AppProvider.d.ts +3 -1
  71. package/reactjs/context/Web3AppProvider.js +7 -5
  72. package/reactjs/context/Web3AppProvider.mjs +4 -2
  73. package/reactjs/context/useWeb3App.js +2 -2
  74. package/reactjs/hooks/index.js +1 -1
  75. package/reactjs/hooks/index.mjs +1 -1
  76. package/reactjs/hooks/useAccount.js +1 -5
  77. package/reactjs/hooks/useAccount.mjs +1 -5
  78. package/reactjs/hooks/useBalances.d.ts +4 -4
  79. package/reactjs/hooks/useBalances.js +16 -1
  80. package/reactjs/hooks/useBalances.mjs +16 -1
  81. package/reactjs/hooks/useBridgeFormik.js +9 -16
  82. package/reactjs/hooks/useBridgeFormik.mjs +0 -7
  83. package/reactjs/hooks/useDebounce.js +3 -3
  84. package/reactjs/hooks/useFetchBridgeData.d.ts +14 -4
  85. package/reactjs/hooks/useFetchTokens.d.ts +14 -4
  86. package/reactjs/hooks/useFetchTokens.js +9 -9
  87. package/reactjs/hooks/useFetchTokens.mjs +2 -2
  88. package/reactjs/hooks/useFiatData.d.ts +7 -2
  89. package/reactjs/hooks/useFiatData.js +6 -6
  90. package/reactjs/hooks/useFiatData.mjs +1 -1
  91. package/reactjs/hooks/useGetChainId.js +3 -3
  92. package/reactjs/hooks/useGetChainId.mjs +1 -1
  93. package/reactjs/hooks/useResolveTokenChain.js +2 -2
  94. package/reactjs/hooks/useSendTransactions.js +2 -2
  95. package/reactjs/hooks/useSignTransaction.d.ts +93 -67
  96. package/reactjs/hooks/useSignTransaction.js +53 -4
  97. package/reactjs/hooks/useSignTransaction.mjs +53 -4
  98. package/reactjs/hooks/validation/useTestHasEnoughFunds.js +3 -3
  99. package/reactjs/hooks/validation/useTestIsConnected.js +2 -2
  100. package/reactjs/index.js +44 -16
  101. package/reactjs/index.mjs +14 -16
  102. package/reactjs/init/init.d.ts +220 -1
  103. package/reactjs/init/init.js +34 -10
  104. package/reactjs/init/init.mjs +31 -7
  105. package/reactjs/init/tests/init.spec.js +5 -6
  106. package/reactjs/init/tests/init.spec.mjs +5 -6
  107. package/reactjs/queries/index.d.ts +0 -1
  108. package/reactjs/queries/index.js +0 -2
  109. package/reactjs/queries/index.mjs +1 -3
  110. package/reactjs/queries/useGetEvmTokensBalances.query.d.ts +8 -3
  111. package/reactjs/queries/useGetEvmTokensBalances.query.js +15 -18
  112. package/reactjs/queries/useGetEvmTokensBalances.query.mjs +15 -18
  113. package/reactjs/queries/useGetHistory.query.d.ts +9 -1
  114. package/reactjs/queries/useGetHistory.query.js +23 -5
  115. package/reactjs/queries/useGetHistory.query.mjs +23 -5
  116. package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +7 -2
  117. package/reactjs/queries/useGetMvxTokensBalances.query.js +2 -2
  118. package/reactjs/reexports.d.ts +2 -1
  119. package/reactjs/reexports.js +41 -13
  120. package/reactjs/reexports.mjs +11 -13
  121. package/reactjs/utils/getInitialTokens.d.ts +4 -1
  122. package/reactjs/utils/getInitialTokens.js +3 -3
  123. package/reactjs/utils/getInitialTokens.mjs +3 -3
  124. package/style.css +33 -1730
  125. package/types/chainType.d.ts +6 -0
  126. package/types/chainType.js +11 -0
  127. package/types/chainType.mjs +10 -0
  128. package/types/transaction.d.ts +28 -0
  129. package/types/utxo.d.ts +11 -0
  130. package/types/utxo.js +2 -0
  131. package/types/utxo.mjs +1 -0
  132. package/{useBalances-C_69CFoa.mjs → useBalances-Bom1mw1J.mjs} +101 -23
  133. package/{useBalances-C4YhEYxy.js → useBalances-gZTsFZHe.js} +102 -24
  134. package/index-BIVnypNe.mjs +0 -108
  135. package/index-Ben8n3bd.js +0 -58656
  136. package/index-CnKr4rL1.mjs +0 -91
  137. package/index-CnuruJNu.js +0 -329
  138. package/index-DsBh-EBw.js +0 -108
  139. package/index-iN9APQ6x.mjs +0 -58735
  140. package/modules/fiat/components/FiatForm/FiatForm.d.ts +0 -9
  141. package/modules/fiat/components/FiatForm/FiatForm.js +0 -314
  142. package/modules/fiat/components/FiatForm/FiatForm.mjs +0 -313
  143. package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.d.ts +0 -13
  144. package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.js +0 -117
  145. package/modules/fiat/components/FiatForm/components/AmountInput/AmountInput.mjs +0 -116
  146. package/modules/fiat/components/FiatForm/components/AmountInput/index.d.ts +0 -1
  147. package/modules/fiat/components/FiatForm/components/AmountInput/index.js +0 -5
  148. package/modules/fiat/components/FiatForm/components/AmountInput/index.mjs +0 -4
  149. package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.d.ts +0 -7
  150. package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.js +0 -74
  151. package/modules/fiat/components/FiatForm/components/RateReloading/RateReloading.mjs +0 -73
  152. package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.d.ts +0 -14
  153. package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.js +0 -94
  154. package/modules/fiat/components/FiatForm/components/TokenSelector/TokenSelector.mjs +0 -93
  155. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.d.ts +0 -7
  156. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.js +0 -82
  157. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContainer.mjs +0 -81
  158. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.d.ts +0 -7
  159. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.js +0 -91
  160. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectContent.mjs +0 -90
  161. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.d.ts +0 -5
  162. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.js +0 -30
  163. package/modules/fiat/components/FiatForm/components/TokenSelector/components/SelectedOption.mjs +0 -29
  164. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.d.ts +0 -8
  165. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.js +0 -103
  166. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenIcon.mjs +0 -102
  167. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.d.ts +0 -7
  168. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.js +0 -33
  169. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenItem.mjs +0 -32
  170. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.d.ts +0 -7
  171. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.js +0 -21
  172. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenList.mjs +0 -20
  173. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.d.ts +0 -9
  174. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.js +0 -26
  175. package/modules/fiat/components/FiatForm/components/TokenSelector/components/TokenSymbol.mjs +0 -25
  176. package/modules/fiat/components/FiatForm/components/TokenSelector/index.d.ts +0 -1
  177. package/modules/fiat/components/FiatForm/components/TokenSelector/index.js +0 -5
  178. package/modules/fiat/components/FiatForm/components/TokenSelector/index.mjs +0 -4
  179. package/modules/fiat/components/FiatForm/index.d.ts +0 -1
  180. package/modules/fiat/components/FiatForm/index.js +0 -5
  181. package/modules/fiat/components/FiatForm/index.mjs +0 -4
  182. package/modules/fiat/components/index.d.ts +0 -1
  183. package/modules/fiat/components/index.js +0 -5
  184. package/modules/fiat/components/index.mjs +0 -4
  185. package/modules/fiat/context/FiatProvider.d.ts +0 -8
  186. package/modules/fiat/context/FiatProvider.js +0 -24
  187. package/modules/fiat/context/FiatProvider.mjs +0 -23
  188. package/modules/fiat/context/queryClient.d.ts +0 -3
  189. package/modules/fiat/context/queryClient.js +0 -12
  190. package/modules/fiat/context/queryClient.mjs +0 -11
  191. package/modules/fiat/context/useFiat.d.ts +0 -1
  192. package/modules/fiat/context/useFiat.js +0 -13
  193. package/modules/fiat/context/useFiat.mjs +0 -12
  194. package/modules/fiat/hooks/index.d.ts +0 -2
  195. package/modules/fiat/hooks/index.js +0 -7
  196. package/modules/fiat/hooks/index.mjs +0 -6
  197. package/modules/fiat/hooks/useFiatData.d.ts +0 -7
  198. package/modules/fiat/hooks/useFiatData.js +0 -75
  199. package/modules/fiat/hooks/useFiatData.mjs +0 -74
  200. package/modules/fiat/hooks/validation/index.d.ts +0 -1
  201. package/modules/fiat/hooks/validation/index.js +0 -5
  202. package/modules/fiat/hooks/validation/index.mjs +0 -4
  203. package/modules/fiat/hooks/validation/useAmountSchema.d.ts +0 -2
  204. package/modules/fiat/hooks/validation/useAmountSchema.js +0 -27
  205. package/modules/fiat/hooks/validation/useAmountSchema.mjs +0 -9
  206. package/modules/fiat/index.d.ts +0 -8
  207. package/modules/fiat/index.js +0 -22
  208. package/modules/fiat/index.mjs +0 -21
  209. package/modules/fiat/init/index.d.ts +0 -2
  210. package/modules/fiat/init/index.js +0 -5
  211. package/modules/fiat/init/index.mjs +0 -4
  212. package/modules/fiat/init/init.d.ts +0 -22
  213. package/modules/fiat/init/init.js +0 -15
  214. package/modules/fiat/init/init.mjs +0 -14
  215. package/modules/fiat/queries/index.d.ts +0 -2
  216. package/modules/fiat/queries/index.js +0 -7
  217. package/modules/fiat/queries/index.mjs +0 -6
  218. package/modules/fiat/queries/useGetRate.mutation.d.ts +0 -6
  219. package/modules/fiat/queries/useGetRate.mutation.js +0 -20
  220. package/modules/fiat/queries/useGetRate.mutation.mjs +0 -19
  221. package/modules/fiat/queries/useGetTokens.query.d.ts +0 -5
  222. package/modules/fiat/queries/useGetTokens.query.js +0 -33
  223. package/modules/fiat/queries/useGetTokens.query.mjs +0 -32
  224. package/react-47kZTyAT.mjs +0 -51
  225. package/react-B_iI3-1z.mjs +0 -3133
  226. package/react-BomcNL1v.js +0 -254
  227. package/react-CqKlu0W0.js +0 -51
  228. package/react-R_xxu7fN.js +0 -3133
  229. package/react-cXurUY4Z.mjs +0 -254
  230. package/reactjs/queries/useGetTokens.query.d.ts +0 -3
  231. package/reactjs/queries/useGetTokens.query.js +0 -34
  232. package/reactjs/queries/useGetTokens.query.mjs +0 -33
  233. package/w3m-modal-Bhg44d6I.js +0 -356
  234. package/w3m-modal-Br2Ec3MM.mjs +0 -356
@@ -5,8 +5,8 @@ import { formatAmount } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmoun
5
5
  import debounce from "lodash/debounce";
6
6
  import { useRef, useState, useMemo, useCallback, useEffect } from "react";
7
7
  import { toast } from "react-toastify";
8
- import { useSwitchChain } from "wagmi";
9
8
  import { getApiURL } from "../../../helpers/getApiURL.mjs";
9
+ import { ChainType } from "../../../types/chainType.mjs";
10
10
  import { safeWindow } from "../../constants/index.mjs";
11
11
  import { useWeb3App } from "../../context/useWeb3App.mjs";
12
12
  import { useAccount } from "../../hooks/useAccount.mjs";
@@ -33,15 +33,15 @@ import "react-popper";
33
33
  import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
34
34
  import { BridgeHistory } from "../BridgeHistory/BridgeHistory.mjs";
35
35
  import { BridgeConnectButton } from "../Connect/BridgeConnectButton.mjs";
36
- import "../../../index-iN9APQ6x.mjs";
37
- import { hexToString } from "viem";
38
- import "viem/chains";
36
+ import "@reown/appkit/react";
37
+ import "wagmi";
39
38
  import { MvxConnectButton } from "../Connect/MvxConnectButton.mjs";
40
39
  import { BridgeAccountDisplay } from "../Connect/BridgeAccountDisplay.mjs";
41
40
  import { MvxAccountDisplay } from "../Connect/MvxAccountDisplay.mjs";
42
41
  import { TokenSelector } from "../TokenSelector/TokenSelector.mjs";
42
+ import { hexToString } from "viem";
43
43
  import { waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call } from "viem/actions";
44
- import { g as getAction } from "../../../useBalances-C_69CFoa.mjs";
44
+ import { g as getAction } from "../../../useBalances-Bom1mw1J.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,
@@ -131,12 +133,12 @@ const BridgeForm = ({
131
133
  }) => {
132
134
  var _a, _b, _c, _d, _e, _f;
133
135
  const ref = useRef(null);
136
+ const initializedInitialTokensRef = useRef(false);
134
137
  const [isTokenSelectorVisible, setIsTokenSelectorVisible] = useState(false);
135
138
  const [pendingSigning, setPendingSigning] = useState(false);
136
139
  const [siginingTransactionsCount, setSigningTransactionsCount] = useState(0);
137
140
  const account = useAccount();
138
- const { chains: sdkChains } = useSwitchChain();
139
- const { config, options } = useWeb3App();
141
+ const { config, options, supportedChains: sdkChains } = useWeb3App();
140
142
  const chainId = useGetChainId();
141
143
  const {
142
144
  evmTokensWithBalances,
@@ -162,7 +164,7 @@ const BridgeForm = ({
162
164
  (chain) => chain.chainId.toString() === mvxChainId.toString()
163
165
  );
164
166
  }, [chainId, chains]);
165
- const { signTransaction } = useSignTransaction();
167
+ const { evm, solana, bitcoin } = useSignTransaction();
166
168
  const sendTransactions = useSendTransactions();
167
169
  const {
168
170
  mutate: getRate,
@@ -187,15 +189,33 @@ const BridgeForm = ({
187
189
  })) ?? [],
188
190
  [evmTokensWithBalances]
189
191
  );
192
+ const getAvailableTokens = useCallback(
193
+ (option) => {
194
+ if (!(option == null ? void 0 : option.availableTokens)) {
195
+ return [];
196
+ }
197
+ const foundTokens = [];
198
+ for (const availableToken of option.availableTokens) {
199
+ const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
200
+ (mvxToken) => mvxToken.address === availableToken.address
201
+ );
202
+ if (foundToken) {
203
+ foundTokens.push(foundToken);
204
+ }
205
+ }
206
+ return foundTokens;
207
+ },
208
+ [mvxTokensWithBalances]
209
+ );
190
210
  const toOptions = useMemo(
191
- () => (mvxTokensWithBalances && mvxTokensWithBalances.map((token) => {
211
+ () => ((firstToken == null ? void 0 : firstToken.availableTokens) && getAvailableTokens(firstToken).map((token) => {
192
212
  return {
193
213
  ...token,
194
214
  identifier: token.address,
195
215
  ticker: token.symbol
196
216
  };
197
217
  })) ?? [],
198
- [mvxTokensWithBalances]
218
+ [firstToken == null ? void 0 : firstToken.availableTokens]
199
219
  );
200
220
  const selectedChainOption = useMemo(
201
221
  () => (chains == null ? void 0 : chains.find(
@@ -203,9 +223,11 @@ const BridgeForm = ({
203
223
  )) ?? (chains == null ? void 0 : chains[0]),
204
224
  [activeChain == null ? void 0 : activeChain.id, chains]
205
225
  );
206
- const defaultReceivingToken = useMemo(
207
- () => toOptions.find((x) => x.symbol.toLowerCase().includes("usdc")),
208
- [toOptions]
226
+ const getDefaultReceivingToken = useCallback(
227
+ (values) => values.find((x) => x.symbol.toLowerCase().includes("usdc")) ?? (mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
228
+ (x) => x.symbol.toLowerCase().includes("usdc")
229
+ )),
230
+ [mvxTokensWithBalances]
209
231
  );
210
232
  const hasAmounts = firstAmount !== "" && secondAmount !== "";
211
233
  const fetchRateDebounced = useCallback(
@@ -268,7 +290,7 @@ const BridgeForm = ({
268
290
  );
269
291
  const updateUrlParams = useCallback(
270
292
  ({ firstTokenId, secondTokenId }) => {
271
- if (isTokensLoading || !bridgeAddress) {
293
+ if (isTokensLoading) {
272
294
  return;
273
295
  }
274
296
  const currentUrl = getCompletePathname();
@@ -285,8 +307,14 @@ const BridgeForm = ({
285
307
  }
286
308
  onNavigate == null ? void 0 : onNavigate(newUrl, { replace: true });
287
309
  },
288
- [bridgeAddress, callbackRoute, isTokensLoading, onNavigate]
310
+ [callbackRoute, isTokensLoading, onNavigate]
289
311
  );
312
+ console.log("BridgeForm", {
313
+ firstToken,
314
+ secondToken,
315
+ fromOptions,
316
+ toOptions
317
+ });
290
318
  const onChangeFirstSelect = useCallback(
291
319
  (option) => {
292
320
  if (!option) {
@@ -294,9 +322,13 @@ const BridgeForm = ({
294
322
  }
295
323
  setFirstToken(() => option);
296
324
  updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
297
- const secondOption = toOptions.find(
298
- (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
299
- ) ?? defaultReceivingToken;
325
+ const availableTokens = getAvailableTokens(option);
326
+ const secondOption = availableTokens.find(
327
+ (x) => {
328
+ var _a2;
329
+ return x.symbol.toLowerCase() === ((_a2 = availableTokens == null ? void 0 : availableTokens[0]) == null ? void 0 : _a2.symbol.toLowerCase());
330
+ }
331
+ ) ?? getDefaultReceivingToken(availableTokens);
300
332
  if (!secondOption) {
301
333
  return;
302
334
  }
@@ -325,10 +357,13 @@ const BridgeForm = ({
325
357
  );
326
358
  const setInitialSelectedTokens = () => {
327
359
  var _a2, _b2, _c2, _d2;
328
- if (isTokensLoading) {
360
+ if (isTokensLoading || initializedInitialTokensRef.current) {
329
361
  return;
330
362
  }
331
- const initialTokens = getInitialTokens();
363
+ const initialTokens = getInitialTokens({
364
+ firstTokenId: firstTokenIdentifier,
365
+ secondTokenId: secondTokenIdentifier
366
+ });
332
367
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
333
368
  ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
334
369
  )) ?? fromOptions.find(
@@ -336,25 +371,37 @@ const BridgeForm = ({
336
371
  var _a3;
337
372
  return option.chainId.toString() === ((_a3 = activeChain == null ? void 0 : activeChain.id) == null ? void 0 : _a3.toString());
338
373
  }
339
- );
340
- const secondOption = (toOptions == null ? void 0 : toOptions.find(
341
- ({ address }) => address.toLowerCase() === ((firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)).toLowerCase()
342
- )) ?? toOptions.find(
374
+ ) ?? (fromOptions == null ? void 0 : fromOptions[0]);
375
+ const availableTokens = getAvailableTokens(firstOption);
376
+ const secondOption = (availableTokens == null ? void 0 : availableTokens.find(
377
+ ({ address }) => {
378
+ var _a3;
379
+ return address.toLowerCase() === ((_a3 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a3.toLowerCase());
380
+ }
381
+ )) ?? availableTokens.find(
343
382
  (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
344
- ) ?? defaultReceivingToken;
383
+ ) ?? getDefaultReceivingToken(availableTokens);
345
384
  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());
346
385
  if (hasOptionsSelected) {
347
386
  return;
348
387
  }
349
- if (!firstOption || !secondOption) {
350
- return;
388
+ let initializedFirstToken = false;
389
+ if (firstOption) {
390
+ setFirstToken(firstOption);
391
+ updateUrlParams({
392
+ firstTokenId: firstOption == null ? void 0 : firstOption.address
393
+ });
394
+ initializedFirstToken = true;
351
395
  }
352
- setFirstToken(firstOption);
353
- setSecondToken(secondOption);
354
- updateUrlParams({
355
- firstTokenId: firstOption == null ? void 0 : firstOption.address,
356
- secondTokenId: secondOption == null ? void 0 : secondOption.address
357
- });
396
+ let initializedSecondToken = false;
397
+ if (secondOption) {
398
+ setSecondToken(secondOption);
399
+ updateUrlParams({
400
+ secondTokenId: secondOption == null ? void 0 : secondOption.address
401
+ });
402
+ initializedSecondToken = true;
403
+ }
404
+ initializedInitialTokensRef.current = initializedFirstToken && initializedSecondToken;
358
405
  };
359
406
  const onSubmit = useCallback(
360
407
  async ({
@@ -369,30 +416,76 @@ const BridgeForm = ({
369
416
  for (const transaction of transactions) {
370
417
  ++txIndex;
371
418
  try {
372
- const txHash = await signTransaction({
373
- ...transaction,
374
- value: BigInt(transaction.value),
375
- gas: BigInt(transaction.gasLimit),
376
- account: bridgeAddress
377
- });
378
- signedTransactions.push({
379
- ...transaction,
380
- txHash
381
- });
419
+ switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
420
+ case ChainType.evm:
421
+ const hash = await evm.signTransaction({
422
+ ...transaction,
423
+ value: BigInt(transaction.value),
424
+ gas: BigInt(transaction.gasLimit),
425
+ account: bridgeAddress
426
+ });
427
+ if (!hash) {
428
+ break;
429
+ }
430
+ signedTransactions.push({
431
+ ...transaction,
432
+ txHash: hash
433
+ });
434
+ if (txIndex === transactions.length - 1 || !hash) {
435
+ break;
436
+ }
437
+ const transactionReceipt = await waitForTransactionReceipt(
438
+ config,
439
+ {
440
+ confirmations: 1,
441
+ hash
442
+ }
443
+ );
444
+ console.info({
445
+ transactionReceipt,
446
+ hash
447
+ });
448
+ break;
449
+ case ChainType.sol:
450
+ if (!transaction.instructions || !transaction.feePayer) {
451
+ break;
452
+ }
453
+ const txHash = await solana.signTransaction({
454
+ feePayer: transaction.feePayer,
455
+ instructions: transaction.instructions
456
+ });
457
+ if (!txHash) {
458
+ break;
459
+ }
460
+ signedTransactions.push({
461
+ ...transaction,
462
+ txHash
463
+ });
464
+ break;
465
+ case ChainType.btc:
466
+ if (!transaction.bitcoinParams) {
467
+ console.error("No bitcoin params");
468
+ break;
469
+ }
470
+ console.log({
471
+ transaction
472
+ });
473
+ const psbt = await bitcoin.signTransaction(
474
+ transaction.bitcoinParams
475
+ );
476
+ signedTransactions.push({
477
+ ...transaction,
478
+ txHash: psbt
479
+ });
480
+ break;
481
+ default:
482
+ toast.error("Provider not supported");
483
+ setPendingSigning(false);
484
+ return;
485
+ }
382
486
  setSigningTransactionsCount(
383
487
  () => transactions.length - 1 - txIndex
384
488
  );
385
- if (txIndex === transactions.length - 1) {
386
- continue;
387
- }
388
- const transactionReceipt = await waitForTransactionReceipt(config, {
389
- confirmations: 1,
390
- hash: txHash
391
- });
392
- console.info({
393
- transactionReceipt,
394
- hash: txHash
395
- });
396
489
  } catch (e) {
397
490
  toast.dismiss();
398
491
  toast.error("Transaction aborted");
@@ -429,7 +522,7 @@ const BridgeForm = ({
429
522
  nativeAuthToken,
430
523
  onSuccess,
431
524
  sendTransactions,
432
- signTransaction
525
+ evm.signTransaction
433
526
  ]
434
527
  );
435
528
  const {
@@ -483,7 +576,7 @@ const BridgeForm = ({
483
576
  setSecondAmount("0");
484
577
  }
485
578
  }, [rateValidationError]);
486
- useEffect(setInitialSelectedTokens, [isTokensLoading, chainId]);
579
+ useEffect(setInitialSelectedTokens, [isTokensLoading, fromOptions]);
487
580
  useEffect(() => {
488
581
  const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
489
582
  (x) => x.address === (firstToken == null ? void 0 : firstToken.address)
@@ -569,6 +662,7 @@ const BridgeForm = ({
569
662
  disabled: isPendingRate,
570
663
  options: fromOptions,
571
664
  areOptionsLoading: isTokensLoading,
665
+ isMvxSelector: false,
572
666
  color: "neutral-850",
573
667
  onChange: onChangeFirstSelect,
574
668
  onBlur: handleBlur,
@@ -623,10 +717,11 @@ const BridgeForm = ({
623
717
  TokenSelector,
624
718
  {
625
719
  name: "secondToken",
626
- disabled: true,
720
+ disabled: isPendingRate,
627
721
  omitDisableClass: true,
628
722
  options: toOptions,
629
723
  areOptionsLoading: isTokensLoading,
724
+ isMvxSelector: true,
630
725
  color: "neutral-850",
631
726
  onChange: onChangeSecondSelect,
632
727
  onBlur: handleBlur,
@@ -642,7 +737,7 @@ const BridgeForm = ({
642
737
  MvxConnectButton,
643
738
  {
644
739
  mvxAccountAddress: mvxAddress,
645
- chain: mvxChain,
740
+ icon: mvxChain == null ? void 0 : mvxChain.svgUrl,
646
741
  onClick: onMvxConnect
647
742
  }
648
743
  ),
@@ -2,12 +2,14 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
+ const faArrowDownShortWide = require("@fortawesome/free-solid-svg-icons/faArrowDownShortWide");
6
+ const faArrowUpShortWide = require("@fortawesome/free-solid-svg-icons/faArrowUpShortWide");
5
7
  const faCircleCheck = require("@fortawesome/free-solid-svg-icons/faCircleCheck");
6
8
  const faCircleXmark = require("@fortawesome/free-solid-svg-icons/faCircleXmark");
7
9
  const faClock = require("@fortawesome/free-solid-svg-icons/faClock");
8
10
  const faClose = require("@fortawesome/free-solid-svg-icons/faClose");
9
11
  const reactFontawesome = require("@fortawesome/react-fontawesome");
10
- const require$$0 = require("react");
12
+ const React = require("react");
11
13
  const constants_index = require("../../../constants/index.js");
12
14
  const types_providerType = require("../../../types/providerType.js");
13
15
  const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
@@ -18,14 +20,19 @@ const reactjs_utils_mxClsx = require("../../utils/mxClsx.js");
18
20
  const reactjs_components_base_MxButton_MxButton = require("../base/MxButton/MxButton.js");
19
21
  const reactjs_components_base_MxCard_MxCard = require("../base/MxCard/MxCard.js");
20
22
  const reactjs_components_base_MxLink_MxLink = require("../base/MxLink/MxLink.js");
23
+ require("../base/MxSearch/MxSearch.js");
24
+ require("@headlessui/react");
25
+ const reactjs_components_base_MxTooltip_MxTooltip = require("../base/MxTooltip/MxTooltip.js");
21
26
  const ArrowUpRight = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e";
22
27
  const BridgeHistory = ({
23
28
  mvxAddress,
24
29
  onClose
25
30
  }) => {
26
31
  const { options } = reactjs_context_useWeb3App.useWeb3App();
27
- const { data, isLoading, isError } = reactjs_queries_useGetHistory_query.useGetHistoryQuery();
28
- const resolveTransactionIcon = require$$0.useCallback((transaction) => {
32
+ const { data, isLoading, isError } = reactjs_queries_useGetHistory_query.useGetHistoryQuery({
33
+ address: mvxAddress
34
+ });
35
+ const resolveTransactionIcon = React.useCallback((transaction) => {
29
36
  switch (transaction.status) {
30
37
  case "success":
31
38
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -56,7 +63,7 @@ const BridgeHistory = ({
56
63
  );
57
64
  }
58
65
  }, []);
59
- const transactions = require$$0.useMemo(
66
+ const transactions = React.useMemo(
60
67
  () => data == null ? void 0 : data.map((transaction) => {
61
68
  return {
62
69
  ...transaction,
@@ -78,7 +85,7 @@ const BridgeHistory = ({
78
85
  mvxAddress,
79
86
  mvxApiURL: options.mvxApiURL
80
87
  });
81
- const tokensMap = require$$0.useMemo(() => {
88
+ const tokensMap = React.useMemo(() => {
82
89
  return [
83
90
  ...evmTokensWithBalances ?? [],
84
91
  ...mvxTokensWithBalances ?? []
@@ -90,7 +97,7 @@ const BridgeHistory = ({
90
97
  {}
91
98
  );
92
99
  }, [evmTokensWithBalances, mvxTokensWithBalances]);
93
- const chainsMap = require$$0.useMemo(() => {
100
+ const chainsMap = React.useMemo(() => {
94
101
  return (chains ?? []).reduce(
95
102
  (acc, chain) => {
96
103
  acc[chain.chainId.toString()] = chain;
@@ -172,10 +179,32 @@ const BridgeHistory = ({
172
179
  "liq-text-red-200": transaction.status === "failed"
173
180
  }),
174
181
  children: [
175
- transaction.statusIcon,
176
- constants_index.MVX_CHAIN_IDS.includes(Number(transaction.toChainId)) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
177
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Deposit " }),
178
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap liq-overflow-hidden liq-text-ellipsis", children: reactjs_utils_formatAmount.formatAmount({
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
+ ),
192
+ constants_index.MVX_CHAIN_IDS.includes(transaction.toChainId) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
193
+ /* @__PURE__ */ jsxRuntime.jsx(
194
+ reactjs_components_base_MxTooltip_MxTooltip.MxTooltip,
195
+ {
196
+ placement: "top",
197
+ buttonText: /* @__PURE__ */ jsxRuntime.jsx(
198
+ reactFontawesome.FontAwesomeIcon,
199
+ {
200
+ icon: faArrowDownShortWide.faArrowDownShortWide,
201
+ className: "liq-mx-1 liq-flex liq-items-center"
202
+ }
203
+ ),
204
+ children: "Deposit"
205
+ }
206
+ ),
207
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-text-wrap", children: reactjs_utils_formatAmount.formatAmount({
179
208
  decimals: (_a = tokensMap[transaction.tokenDestination]) == null ? void 0 : _a.decimals,
180
209
  amount: transaction.amountOut,
181
210
  addCommas: false,
@@ -191,7 +220,7 @@ const BridgeHistory = ({
191
220
  }
192
221
  ),
193
222
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap", children: "from" }),
194
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap liq-overflow-hidden liq-text-ellipsis", children: reactjs_utils_formatAmount.formatAmount({
223
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-text-wrap", children: reactjs_utils_formatAmount.formatAmount({
195
224
  decimals: (_d = tokensMap[transaction.tokenSource]) == null ? void 0 : _d.decimals,
196
225
  amount: transaction.amountIn,
197
226
  addCommas: false,
@@ -217,8 +246,22 @@ const BridgeHistory = ({
217
246
  )
218
247
  ] })
219
248
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
220
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Transfer " }),
221
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap liq-overflow-hidden liq-text-ellipsis", children: reactjs_utils_formatAmount.formatAmount({
249
+ /* @__PURE__ */ jsxRuntime.jsx(
250
+ reactjs_components_base_MxTooltip_MxTooltip.MxTooltip,
251
+ {
252
+ placement: "top",
253
+ buttonText: /* @__PURE__ */ jsxRuntime.jsx(
254
+ reactFontawesome.FontAwesomeIcon,
255
+ {
256
+ icon: faArrowUpShortWide.faArrowUpShortWide,
257
+ spin: true,
258
+ className: "liq-mx-1 liq-flex liq-items-center"
259
+ }
260
+ ),
261
+ children: "Transfer"
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-text-wrap", children: reactjs_utils_formatAmount.formatAmount({
222
265
  decimals: (_h = tokensMap[transaction.tokenSource]) == null ? void 0 : _h.decimals,
223
266
  amount: transaction.amountIn,
224
267
  addCommas: false,
@@ -234,7 +277,7 @@ const BridgeHistory = ({
234
277
  }
235
278
  ),
236
279
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap", children: "to" }),
237
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-whitespace-nowrap liq-overflow-hidden liq-text-ellipsis", children: reactjs_utils_formatAmount.formatAmount({
280
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-text-wrap", children: reactjs_utils_formatAmount.formatAmount({
238
281
  decimals: (_k = tokensMap[transaction.tokenDestination]) == null ? void 0 : _k.decimals,
239
282
  amount: transaction.amountOut,
240
283
  addCommas: false,
@@ -263,24 +306,28 @@ const BridgeHistory = ({
263
306
  ]
264
307
  }
265
308
  ),
266
- transaction.provider === types_providerType.ProviderType.MultiversxBridge && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "liq-ml-auto liq-mr-0 liq-flex liq-items-center liq-gap-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
309
+ transaction.provider === types_providerType.ProviderType.MultiversxBridge && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "liq-ml-auto liq-mr-0 liq-flex liq-items-center liq-gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(
267
310
  reactjs_components_base_MxLink_MxLink.MxLink,
268
311
  {
269
312
  to: `${options.bridgeURL}/status/${transaction.txHash}`,
270
313
  target: "_blank",
271
314
  showExternalIcon: false,
272
315
  className: "liq-flex",
273
- children: [
274
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-sm:liq-hidden", children: "View" }),
275
- /* @__PURE__ */ jsxRuntime.jsx(
276
- "img",
277
- {
278
- src: ArrowUpRight,
279
- alt: "",
280
- className: "liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-neutral-200"
281
- }
282
- )
283
- ]
316
+ children: /* @__PURE__ */ jsxRuntime.jsx(
317
+ reactjs_components_base_MxTooltip_MxTooltip.MxTooltip,
318
+ {
319
+ placement: "top",
320
+ buttonText: /* @__PURE__ */ jsxRuntime.jsx(
321
+ "img",
322
+ {
323
+ src: ArrowUpRight,
324
+ alt: "",
325
+ className: "liq-flex liq-items-center liq-justify-center liq-rounded-full liq-text-neutral-200"
326
+ }
327
+ ),
328
+ children: "View"
329
+ }
330
+ )
284
331
  }
285
332
  ) })
286
333
  ] })