@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
@@ -6,10 +6,10 @@ const faSpinner = require("@fortawesome/free-solid-svg-icons/faSpinner");
6
6
  const reactFontawesome = require("@fortawesome/react-fontawesome");
7
7
  const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
8
8
  const debounce = require("lodash/debounce");
9
- const require$$0 = require("react");
9
+ const React = require("react");
10
10
  const reactToastify = require("react-toastify");
11
- const wagmi = require("wagmi");
12
11
  const helpers_getApiURL = require("../../../helpers/getApiURL.js");
12
+ const types_chainType = require("../../../types/chainType.js");
13
13
  const reactjs_constants_index = require("../../constants/index.js");
14
14
  const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
15
15
  const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
@@ -36,15 +36,15 @@ require("react-popper");
36
36
  require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");
37
37
  const reactjs_components_BridgeHistory_BridgeHistory = require("../BridgeHistory/BridgeHistory.js");
38
38
  const reactjs_components_Connect_BridgeConnectButton = require("../Connect/BridgeConnectButton.js");
39
- require("../../../index-Ben8n3bd.js");
40
- const viem = require("viem");
41
- require("viem/chains");
39
+ require("@reown/appkit/react");
40
+ require("wagmi");
42
41
  const reactjs_components_Connect_MvxConnectButton = require("../Connect/MvxConnectButton.js");
43
42
  const reactjs_components_Connect_BridgeAccountDisplay = require("../Connect/BridgeAccountDisplay.js");
44
43
  const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAccountDisplay.js");
45
44
  const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
45
+ const viem = require("viem");
46
46
  const actions = require("viem/actions");
47
- const reactjs_hooks_useBalances = require("../../../useBalances-C4YhEYxy.js");
47
+ const reactjs_hooks_useBalances = require("../../../useBalances-gZTsFZHe.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,
@@ -133,13 +135,13 @@ const BridgeForm = ({
133
135
  onNavigate
134
136
  }) => {
135
137
  var _a, _b, _c, _d, _e, _f;
136
- const ref = require$$0.useRef(null);
137
- const [isTokenSelectorVisible, setIsTokenSelectorVisible] = require$$0.useState(false);
138
- const [pendingSigning, setPendingSigning] = require$$0.useState(false);
139
- const [siginingTransactionsCount, setSigningTransactionsCount] = require$$0.useState(0);
138
+ const ref = React.useRef(null);
139
+ const initializedInitialTokensRef = React.useRef(false);
140
+ const [isTokenSelectorVisible, setIsTokenSelectorVisible] = React.useState(false);
141
+ const [pendingSigning, setPendingSigning] = React.useState(false);
142
+ const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
140
143
  const account = reactjs_hooks_useAccount.useAccount();
141
- const { chains: sdkChains } = wagmi.useSwitchChain();
142
- const { config, options } = reactjs_context_useWeb3App.useWeb3App();
144
+ const { config, options, supportedChains: sdkChains } = reactjs_context_useWeb3App.useWeb3App();
143
145
  const chainId = reactjs_hooks_useGetChainId.useGetChainId();
144
146
  const {
145
147
  evmTokensWithBalances,
@@ -155,17 +157,17 @@ const BridgeForm = ({
155
157
  mvxApiURL: options.mvxApiURL
156
158
  });
157
159
  const isTokensLoading = tokensLoading || isLoadingEvmTokensBalances || isLoadingMvxTokensBalances || isChainsLoading;
158
- const activeChain = require$$0.useMemo(() => {
160
+ const activeChain = React.useMemo(() => {
159
161
  return sdkChains.find(
160
162
  (chain) => chain.id.toString() === (chainId == null ? void 0 : chainId.toString())
161
163
  );
162
164
  }, [chainId, sdkChains]);
163
- const mvxChain = require$$0.useMemo(() => {
165
+ const mvxChain = React.useMemo(() => {
164
166
  return chains.find(
165
167
  (chain) => chain.chainId.toString() === mvxChainId.toString()
166
168
  );
167
169
  }, [chainId, chains]);
168
- const { signTransaction } = reactjs_hooks_useSignTransaction.useSignTransaction();
170
+ const { evm, solana, bitcoin } = reactjs_hooks_useSignTransaction.useSignTransaction();
169
171
  const sendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions();
170
172
  const {
171
173
  mutate: getRate,
@@ -174,13 +176,13 @@ const BridgeForm = ({
174
176
  error: rateError
175
177
  } = reactjs_queries_useGetRate_mutation.useGetRateMutation();
176
178
  const rateValidationError = ((_a = rateError == null ? void 0 : rateError.response) == null ? void 0 : _a.status) === 400 ? (_b = rateError == null ? void 0 : rateError.response) == null ? void 0 : _b.data.message : void 0;
177
- const [firstToken, setFirstToken] = require$$0.useState();
178
- const [firstAmount, setFirstAmount] = require$$0.useState("");
179
- const [secondToken, setSecondToken] = require$$0.useState();
180
- const [secondAmount, setSecondAmount] = require$$0.useState("");
179
+ const [firstToken, setFirstToken] = React.useState();
180
+ const [firstAmount, setFirstAmount] = React.useState("");
181
+ const [secondToken, setSecondToken] = React.useState();
182
+ const [secondAmount, setSecondAmount] = React.useState("");
181
183
  const bridgeAddress = account.address;
182
184
  const isAuthenticated = account.isConnected && Boolean(bridgeAddress);
183
- const fromOptions = require$$0.useMemo(
185
+ const fromOptions = React.useMemo(
184
186
  () => (evmTokensWithBalances && evmTokensWithBalances.map((token) => {
185
187
  return {
186
188
  ...token,
@@ -190,28 +192,48 @@ const BridgeForm = ({
190
192
  })) ?? [],
191
193
  [evmTokensWithBalances]
192
194
  );
193
- const toOptions = require$$0.useMemo(
194
- () => (mvxTokensWithBalances && mvxTokensWithBalances.map((token) => {
195
+ const getAvailableTokens = React.useCallback(
196
+ (option) => {
197
+ if (!(option == null ? void 0 : option.availableTokens)) {
198
+ return [];
199
+ }
200
+ const foundTokens = [];
201
+ for (const availableToken of option.availableTokens) {
202
+ const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
203
+ (mvxToken) => mvxToken.address === availableToken.address
204
+ );
205
+ if (foundToken) {
206
+ foundTokens.push(foundToken);
207
+ }
208
+ }
209
+ return foundTokens;
210
+ },
211
+ [mvxTokensWithBalances]
212
+ );
213
+ const toOptions = React.useMemo(
214
+ () => ((firstToken == null ? void 0 : firstToken.availableTokens) && getAvailableTokens(firstToken).map((token) => {
195
215
  return {
196
216
  ...token,
197
217
  identifier: token.address,
198
218
  ticker: token.symbol
199
219
  };
200
220
  })) ?? [],
201
- [mvxTokensWithBalances]
221
+ [firstToken == null ? void 0 : firstToken.availableTokens]
202
222
  );
203
- const selectedChainOption = require$$0.useMemo(
223
+ const selectedChainOption = React.useMemo(
204
224
  () => (chains == null ? void 0 : chains.find(
205
225
  (option) => option.chainId.toString() === (activeChain == null ? void 0 : activeChain.id.toString())
206
226
  )) ?? (chains == null ? void 0 : chains[0]),
207
227
  [activeChain == null ? void 0 : activeChain.id, chains]
208
228
  );
209
- const defaultReceivingToken = require$$0.useMemo(
210
- () => toOptions.find((x) => x.symbol.toLowerCase().includes("usdc")),
211
- [toOptions]
229
+ const getDefaultReceivingToken = React.useCallback(
230
+ (values) => values.find((x) => x.symbol.toLowerCase().includes("usdc")) ?? (mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
231
+ (x) => x.symbol.toLowerCase().includes("usdc")
232
+ )),
233
+ [mvxTokensWithBalances]
212
234
  );
213
235
  const hasAmounts = firstAmount !== "" && secondAmount !== "";
214
- const fetchRateDebounced = require$$0.useCallback(
236
+ const fetchRateDebounced = React.useCallback(
215
237
  debounce(async (amount) => {
216
238
  if (!amount || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
217
239
  return;
@@ -234,18 +256,18 @@ const BridgeForm = ({
234
256
  selectedChainOption
235
257
  ]
236
258
  );
237
- const handleOnChangeFirstAmount = require$$0.useCallback((amount) => {
259
+ const handleOnChangeFirstAmount = React.useCallback((amount) => {
238
260
  setFirstAmount(() => amount);
239
261
  setLastChangedField(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount);
240
262
  }, []);
241
- const handleOnChangeSecondAmount = require$$0.useCallback((amount) => {
263
+ const handleOnChangeSecondAmount = React.useCallback((amount) => {
242
264
  setSecondAmount(() => amount);
243
265
  setLastChangedField(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount);
244
266
  }, []);
245
- const handleHistoryClose = require$$0.useCallback(() => {
267
+ const handleHistoryClose = React.useCallback(() => {
246
268
  onHistoryClose == null ? void 0 : onHistoryClose();
247
269
  }, [onHistoryClose]);
248
- const handleOnFirstMaxBtnChange = require$$0.useCallback(() => {
270
+ const handleOnFirstMaxBtnChange = React.useCallback(() => {
249
271
  const formattedBalance = formatAmount.formatAmount({
250
272
  decimals: firstToken == null ? void 0 : firstToken.decimals,
251
273
  input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
@@ -255,7 +277,7 @@ const BridgeForm = ({
255
277
  formik.setFieldValue("firstAmount", formattedBalance);
256
278
  handleOnChangeFirstAmount(formattedBalance);
257
279
  }, [firstToken == null ? void 0 : firstToken.balance, firstToken == null ? void 0 : firstToken.decimals, handleOnChangeFirstAmount]);
258
- const onSuccess = require$$0.useCallback(
280
+ const onSuccess = React.useCallback(
259
281
  async (txHashes) => {
260
282
  handleOnChangeFirstAmount("");
261
283
  handleOnChangeSecondAmount("");
@@ -269,9 +291,9 @@ const BridgeForm = ({
269
291
  onSuccessfullySentTransaction
270
292
  ]
271
293
  );
272
- const updateUrlParams = require$$0.useCallback(
294
+ const updateUrlParams = React.useCallback(
273
295
  ({ firstTokenId, secondTokenId }) => {
274
- if (isTokensLoading || !bridgeAddress) {
296
+ if (isTokensLoading) {
275
297
  return;
276
298
  }
277
299
  const currentUrl = reactjs_utils_getCompletePathname.getCompletePathname();
@@ -288,18 +310,28 @@ const BridgeForm = ({
288
310
  }
289
311
  onNavigate == null ? void 0 : onNavigate(newUrl, { replace: true });
290
312
  },
291
- [bridgeAddress, callbackRoute, isTokensLoading, onNavigate]
313
+ [callbackRoute, isTokensLoading, onNavigate]
292
314
  );
293
- const onChangeFirstSelect = require$$0.useCallback(
315
+ console.log("BridgeForm", {
316
+ firstToken,
317
+ secondToken,
318
+ fromOptions,
319
+ toOptions
320
+ });
321
+ const onChangeFirstSelect = React.useCallback(
294
322
  (option) => {
295
323
  if (!option) {
296
324
  return;
297
325
  }
298
326
  setFirstToken(() => option);
299
327
  updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
300
- const secondOption = toOptions.find(
301
- (x) => x.symbol.toLowerCase() === (option == null ? void 0 : option.symbol.toLowerCase())
302
- ) ?? defaultReceivingToken;
328
+ const availableTokens = getAvailableTokens(option);
329
+ const secondOption = availableTokens.find(
330
+ (x) => {
331
+ var _a2;
332
+ return x.symbol.toLowerCase() === ((_a2 = availableTokens == null ? void 0 : availableTokens[0]) == null ? void 0 : _a2.symbol.toLowerCase());
333
+ }
334
+ ) ?? getDefaultReceivingToken(availableTokens);
303
335
  if (!secondOption) {
304
336
  return;
305
337
  }
@@ -308,7 +340,7 @@ const BridgeForm = ({
308
340
  },
309
341
  [toOptions, updateUrlParams]
310
342
  );
311
- const onChangeSecondSelect = require$$0.useCallback(
343
+ const onChangeSecondSelect = React.useCallback(
312
344
  (option) => {
313
345
  if (!option) {
314
346
  return;
@@ -328,10 +360,13 @@ const BridgeForm = ({
328
360
  );
329
361
  const setInitialSelectedTokens = () => {
330
362
  var _a2, _b2, _c2, _d2;
331
- if (isTokensLoading) {
363
+ if (isTokensLoading || initializedInitialTokensRef.current) {
332
364
  return;
333
365
  }
334
- const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens();
366
+ const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens({
367
+ firstTokenId: firstTokenIdentifier,
368
+ secondTokenId: secondTokenIdentifier
369
+ });
335
370
  const firstOption = (fromOptions == null ? void 0 : fromOptions.find(
336
371
  ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
337
372
  )) ?? fromOptions.find(
@@ -339,27 +374,39 @@ const BridgeForm = ({
339
374
  var _a3;
340
375
  return option.chainId.toString() === ((_a3 = activeChain == null ? void 0 : activeChain.id) == null ? void 0 : _a3.toString());
341
376
  }
342
- );
343
- const secondOption = (toOptions == null ? void 0 : toOptions.find(
344
- ({ address }) => address.toLowerCase() === ((firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)).toLowerCase()
345
- )) ?? toOptions.find(
377
+ ) ?? (fromOptions == null ? void 0 : fromOptions[0]);
378
+ const availableTokens = getAvailableTokens(firstOption);
379
+ const secondOption = (availableTokens == null ? void 0 : availableTokens.find(
380
+ ({ address }) => {
381
+ var _a3;
382
+ return address.toLowerCase() === ((_a3 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a3.toLowerCase());
383
+ }
384
+ )) ?? availableTokens.find(
346
385
  (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
347
- ) ?? defaultReceivingToken;
386
+ ) ?? getDefaultReceivingToken(availableTokens);
348
387
  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());
349
388
  if (hasOptionsSelected) {
350
389
  return;
351
390
  }
352
- if (!firstOption || !secondOption) {
353
- return;
391
+ let initializedFirstToken = false;
392
+ if (firstOption) {
393
+ setFirstToken(firstOption);
394
+ updateUrlParams({
395
+ firstTokenId: firstOption == null ? void 0 : firstOption.address
396
+ });
397
+ initializedFirstToken = true;
354
398
  }
355
- setFirstToken(firstOption);
356
- setSecondToken(secondOption);
357
- updateUrlParams({
358
- firstTokenId: firstOption == null ? void 0 : firstOption.address,
359
- secondTokenId: secondOption == null ? void 0 : secondOption.address
360
- });
399
+ let initializedSecondToken = false;
400
+ if (secondOption) {
401
+ setSecondToken(secondOption);
402
+ updateUrlParams({
403
+ secondTokenId: secondOption == null ? void 0 : secondOption.address
404
+ });
405
+ initializedSecondToken = true;
406
+ }
407
+ initializedInitialTokensRef.current = initializedFirstToken && initializedSecondToken;
361
408
  };
362
- const onSubmit = require$$0.useCallback(
409
+ const onSubmit = React.useCallback(
363
410
  async ({
364
411
  transactions,
365
412
  provider
@@ -372,30 +419,76 @@ const BridgeForm = ({
372
419
  for (const transaction of transactions) {
373
420
  ++txIndex;
374
421
  try {
375
- const txHash = await signTransaction({
376
- ...transaction,
377
- value: BigInt(transaction.value),
378
- gas: BigInt(transaction.gasLimit),
379
- account: bridgeAddress
380
- });
381
- signedTransactions.push({
382
- ...transaction,
383
- txHash
384
- });
422
+ switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
423
+ case types_chainType.ChainType.evm:
424
+ const hash = await evm.signTransaction({
425
+ ...transaction,
426
+ value: BigInt(transaction.value),
427
+ gas: BigInt(transaction.gasLimit),
428
+ account: bridgeAddress
429
+ });
430
+ if (!hash) {
431
+ break;
432
+ }
433
+ signedTransactions.push({
434
+ ...transaction,
435
+ txHash: hash
436
+ });
437
+ if (txIndex === transactions.length - 1 || !hash) {
438
+ break;
439
+ }
440
+ const transactionReceipt = await waitForTransactionReceipt(
441
+ config,
442
+ {
443
+ confirmations: 1,
444
+ hash
445
+ }
446
+ );
447
+ console.info({
448
+ transactionReceipt,
449
+ hash
450
+ });
451
+ break;
452
+ case types_chainType.ChainType.sol:
453
+ if (!transaction.instructions || !transaction.feePayer) {
454
+ break;
455
+ }
456
+ const txHash = await solana.signTransaction({
457
+ feePayer: transaction.feePayer,
458
+ instructions: transaction.instructions
459
+ });
460
+ if (!txHash) {
461
+ break;
462
+ }
463
+ signedTransactions.push({
464
+ ...transaction,
465
+ txHash
466
+ });
467
+ break;
468
+ case types_chainType.ChainType.btc:
469
+ if (!transaction.bitcoinParams) {
470
+ console.error("No bitcoin params");
471
+ break;
472
+ }
473
+ console.log({
474
+ transaction
475
+ });
476
+ const psbt = await bitcoin.signTransaction(
477
+ transaction.bitcoinParams
478
+ );
479
+ signedTransactions.push({
480
+ ...transaction,
481
+ txHash: psbt
482
+ });
483
+ break;
484
+ default:
485
+ reactToastify.toast.error("Provider not supported");
486
+ setPendingSigning(false);
487
+ return;
488
+ }
385
489
  setSigningTransactionsCount(
386
490
  () => transactions.length - 1 - txIndex
387
491
  );
388
- if (txIndex === transactions.length - 1) {
389
- continue;
390
- }
391
- const transactionReceipt = await waitForTransactionReceipt(config, {
392
- confirmations: 1,
393
- hash: txHash
394
- });
395
- console.info({
396
- transactionReceipt,
397
- hash: txHash
398
- });
399
492
  } catch (e) {
400
493
  reactToastify.toast.dismiss();
401
494
  reactToastify.toast.error("Transaction aborted");
@@ -432,7 +525,7 @@ const BridgeForm = ({
432
525
  nativeAuthToken,
433
526
  onSuccess,
434
527
  sendTransactions,
435
- signTransaction
528
+ evm.signTransaction
436
529
  ]
437
530
  );
438
531
  const {
@@ -460,7 +553,7 @@ const BridgeForm = ({
460
553
  const hasError = Boolean(
461
554
  firstAmountError || secondAmountError || fromChainError || rateValidationError
462
555
  );
463
- require$$0.useEffect(() => {
556
+ React.useEffect(() => {
464
557
  if (!firstAmount) {
465
558
  setSecondAmount("");
466
559
  }
@@ -473,21 +566,21 @@ const BridgeForm = ({
473
566
  }, 60 * 1e3);
474
567
  return () => clearInterval(fetchRateInterval);
475
568
  }, [firstAmount, fetchRateDebounced]);
476
- require$$0.useEffect(() => {
569
+ React.useEffect(() => {
477
570
  if (!(rate == null ? void 0 : rate.amountOut)) {
478
571
  return;
479
572
  }
480
573
  formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, rate.amountOut);
481
574
  setSecondAmount(rate.amountOut);
482
575
  }, [rate == null ? void 0 : rate.amountOut]);
483
- require$$0.useEffect(() => {
576
+ React.useEffect(() => {
484
577
  if (rateValidationError) {
485
578
  formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, "0");
486
579
  setSecondAmount("0");
487
580
  }
488
581
  }, [rateValidationError]);
489
- require$$0.useEffect(setInitialSelectedTokens, [isTokensLoading, chainId]);
490
- require$$0.useEffect(() => {
582
+ React.useEffect(setInitialSelectedTokens, [isTokensLoading, fromOptions]);
583
+ React.useEffect(() => {
491
584
  const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
492
585
  (x) => x.address === (firstToken == null ? void 0 : firstToken.address)
493
586
  );
@@ -504,7 +597,7 @@ const BridgeForm = ({
504
597
  };
505
598
  });
506
599
  }, [evmTokensWithBalances, firstToken == null ? void 0 : firstToken.address]);
507
- require$$0.useEffect(() => {
600
+ React.useEffect(() => {
508
601
  const selectedTokenOption = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
509
602
  (x) => x.address === (secondToken == null ? void 0 : secondToken.address)
510
603
  );
@@ -572,6 +665,7 @@ const BridgeForm = ({
572
665
  disabled: isPendingRate,
573
666
  options: fromOptions,
574
667
  areOptionsLoading: isTokensLoading,
668
+ isMvxSelector: false,
575
669
  color: "neutral-850",
576
670
  onChange: onChangeFirstSelect,
577
671
  onBlur: handleBlur,
@@ -626,10 +720,11 @@ const BridgeForm = ({
626
720
  reactjs_components_TokenSelector_TokenSelector.TokenSelector,
627
721
  {
628
722
  name: "secondToken",
629
- disabled: true,
723
+ disabled: isPendingRate,
630
724
  omitDisableClass: true,
631
725
  options: toOptions,
632
726
  areOptionsLoading: isTokensLoading,
727
+ isMvxSelector: true,
633
728
  color: "neutral-850",
634
729
  onChange: onChangeSecondSelect,
635
730
  onBlur: handleBlur,
@@ -645,7 +740,7 @@ const BridgeForm = ({
645
740
  reactjs_components_Connect_MvxConnectButton.MvxConnectButton,
646
741
  {
647
742
  mvxAccountAddress: mvxAddress,
648
- chain: mvxChain,
743
+ icon: mvxChain == null ? void 0 : mvxChain.svgUrl,
649
744
  onClick: onMvxConnect
650
745
  }
651
746
  ),