@multiversx/sdk-dapp-liquidity 2.0.0 → 2.1.0-alpha.1

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 (375) hide show
  1. package/all-networks--dfVLHLJ.js +2 -0
  2. package/all-networks-Czd8zS1n.mjs +4 -0
  3. package/api/checkAccount.js +1 -21
  4. package/api/checkAccount.mjs +13 -13
  5. package/api/confirmRate.js +1 -29
  6. package/api/confirmRate.mjs +17 -22
  7. package/api/getChains.js +1 -17
  8. package/api/getChains.mjs +10 -10
  9. package/api/getRate.js +1 -27
  10. package/api/getRate.mjs +17 -20
  11. package/api/getTokens.js +1 -22
  12. package/api/getTokens.mjs +14 -15
  13. package/api/getTokensBalances.js +1 -21
  14. package/api/getTokensBalances.mjs +13 -13
  15. package/api/getTransactions.js +1 -38
  16. package/api/getTransactions.mjs +25 -31
  17. package/api/index.js +1 -18
  18. package/api/index.mjs +16 -16
  19. package/api/sendTransactions.js +1 -32
  20. package/api/sendTransactions.mjs +19 -19
  21. package/api/tests/confirmRate.spec.js +1 -130
  22. package/api/tests/confirmRate.spec.mjs +44 -58
  23. package/api/tests/getChains.spec.js +1 -43
  24. package/api/tests/getChains.spec.mjs +15 -18
  25. package/api/tests/getRate.spec.js +1 -87
  26. package/api/tests/getRate.spec.mjs +35 -49
  27. package/api/tests/getTokens.spec.js +1 -68
  28. package/api/tests/getTokens.spec.mjs +23 -29
  29. package/api/tests/getTransactions.spec.js +1 -94
  30. package/api/tests/getTransactions.spec.mjs +35 -51
  31. package/api/tests/sendTransactions.spec.js +1 -96
  32. package/api/tests/sendTransactions.spec.mjs +44 -52
  33. package/constants/index.js +1 -4
  34. package/constants/index.mjs +2 -2
  35. package/default-D0Jk5ROI.mjs +4 -0
  36. package/default-DbU6vPaB.js +2 -0
  37. package/helpers/assertRateConfirmationMatchesIntent.d.ts +8 -0
  38. package/helpers/assertRateConfirmationMatchesIntent.js +2 -0
  39. package/helpers/assertRateConfirmationMatchesIntent.mjs +20 -0
  40. package/helpers/base64Utils.js +1 -31
  41. package/helpers/base64Utils.mjs +14 -24
  42. package/helpers/decodeLoginToken.js +1 -27
  43. package/helpers/decodeLoginToken.mjs +13 -18
  44. package/helpers/decodeToken.js +1 -39
  45. package/helpers/decodeToken.mjs +20 -31
  46. package/helpers/getApiURL.js +1 -7
  47. package/helpers/getApiURL.mjs +3 -5
  48. package/helpers/getBridgeURL.js +1 -7
  49. package/helpers/getBridgeURL.mjs +3 -5
  50. package/helpers/getDisplayName.js +1 -11
  51. package/helpers/getDisplayName.mjs +3 -8
  52. package/helpers/getMvxApiURL.js +1 -7
  53. package/helpers/getMvxApiURL.mjs +3 -5
  54. package/helpers/getMvxChainId.js +1 -7
  55. package/helpers/getMvxChainId.mjs +3 -5
  56. package/helpers/getMvxExplorerAddress.js +1 -7
  57. package/helpers/getMvxExplorerAddress.mjs +3 -5
  58. package/helpers/index.d.ts +2 -0
  59. package/helpers/index.js +1 -22
  60. package/helpers/index.mjs +24 -20
  61. package/helpers/safeImageUrl.d.ts +1 -0
  62. package/helpers/safeImageUrl.js +2 -0
  63. package/helpers/safeImageUrl.mjs +13 -0
  64. package/helpers/serializeTransaction.js +1 -8
  65. package/helpers/serializeTransaction.mjs +3 -5
  66. package/helpers/tests/assertRateConfirmationMatchesIntent.spec.d.ts +1 -0
  67. package/helpers/tests/assertRateConfirmationMatchesIntent.spec.js +2 -0
  68. package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +52 -0
  69. package/helpers/tests/base64Utils.spec.js +1 -29
  70. package/helpers/tests/base64Utils.spec.mjs +11 -24
  71. package/helpers/tests/decodeLoginToken.spec.js +1 -34
  72. package/helpers/tests/decodeLoginToken.spec.mjs +13 -24
  73. package/helpers/tests/decodeToken.spec.js +1 -27
  74. package/helpers/tests/decodeToken.spec.mjs +7 -12
  75. package/helpers/tests/safeImageUrl.spec.d.ts +1 -0
  76. package/helpers/tests/safeImageUrl.spec.js +2 -0
  77. package/helpers/tests/safeImageUrl.spec.mjs +32 -0
  78. package/helpers/tests/serializeTransaction.spec.d.ts +1 -0
  79. package/helpers/tests/serializeTransaction.spec.js +2 -0
  80. package/helpers/tests/serializeTransaction.spec.mjs +24 -0
  81. package/index.js +1 -228
  82. package/index.mjs +196 -192
  83. package/package.json +14 -9
  84. package/react.esm-B0AMOHxa.js +73 -0
  85. package/react.esm-BxvJJ86Q.mjs +9949 -0
  86. package/reactjs/adapters/SuiAdapter.d.ts +14 -0
  87. package/reactjs/adapters/SuiAdapter.js +1 -349
  88. package/reactjs/adapters/SuiAdapter.mjs +171 -199
  89. package/reactjs/components/AccountAddress/AccountAddress.js +1 -31
  90. package/reactjs/components/AccountAddress/AccountAddress.mjs +16 -16
  91. package/reactjs/components/AccountAddress/index.js +1 -4
  92. package/reactjs/components/AccountAddress/index.mjs +2 -2
  93. package/reactjs/components/AmountCard/AmountCard.js +1 -33
  94. package/reactjs/components/AmountCard/AmountCard.mjs +19 -21
  95. package/reactjs/components/AmountCard/index.js +1 -4
  96. package/reactjs/components/AmountCard/index.mjs +2 -2
  97. package/reactjs/components/AmountInput/AmountInput.js +1 -71
  98. package/reactjs/components/AmountInput/AmountInput.mjs +42 -46
  99. package/reactjs/components/AmountInput/index.js +1 -4
  100. package/reactjs/components/AmountInput/index.mjs +2 -2
  101. package/reactjs/components/BridgeForm/BridgeForm.d.ts +9 -0
  102. package/reactjs/components/BridgeForm/BridgeForm.js +1 -89
  103. package/reactjs/components/BridgeForm/BridgeForm.mjs +72 -79
  104. package/reactjs/components/BridgeForm/Deposit.js +1 -673
  105. package/reactjs/components/BridgeForm/Deposit.mjs +381 -503
  106. package/reactjs/components/BridgeForm/Transfer.js +1 -559
  107. package/reactjs/components/BridgeForm/Transfer.mjs +316 -427
  108. package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.js +1 -78
  109. package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.mjs +47 -70
  110. package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.js +1 -58
  111. package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.mjs +36 -47
  112. package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +1 -266
  113. package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +163 -231
  114. package/reactjs/components/BridgeForm/index.js +1 -4
  115. package/reactjs/components/BridgeForm/index.mjs +2 -2
  116. package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +1 -76
  117. package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +35 -65
  118. package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -367
  119. package/reactjs/components/BridgeHistory/BridgeHistory.mjs +177 -193
  120. package/reactjs/components/BridgeHistory/index.js +1 -4
  121. package/reactjs/components/BridgeHistory/index.mjs +2 -2
  122. package/reactjs/components/Connect/BridgeAccountDisplay.js +1 -150
  123. package/reactjs/components/Connect/BridgeAccountDisplay.mjs +99 -115
  124. package/reactjs/components/Connect/BridgeConnectButton.js +1 -34
  125. package/reactjs/components/Connect/BridgeConnectButton.mjs +20 -19
  126. package/reactjs/components/Connect/ChainSelectConnect.js +1 -144
  127. package/reactjs/components/Connect/ChainSelectConnect.mjs +70 -83
  128. package/reactjs/components/Connect/CustomConnectButton.js +1 -40
  129. package/reactjs/components/Connect/CustomConnectButton.mjs +24 -30
  130. package/reactjs/components/Connect/MvxAccountDisplay.js +1 -97
  131. package/reactjs/components/Connect/MvxAccountDisplay.mjs +47 -50
  132. package/reactjs/components/Connect/MvxConnectButton.js +1 -43
  133. package/reactjs/components/Connect/MvxConnectButton.mjs +35 -40
  134. package/reactjs/components/Connect/SwitchChainButton.js +1 -29
  135. package/reactjs/components/Connect/SwitchChainButton.mjs +15 -18
  136. package/reactjs/components/Connect/index.js +1 -16
  137. package/reactjs/components/Connect/index.mjs +14 -14
  138. package/reactjs/components/CopyButton/CopyButton.js +1 -46
  139. package/reactjs/components/CopyButton/CopyButton.mjs +33 -36
  140. package/reactjs/components/CopyButton/index.js +1 -4
  141. package/reactjs/components/CopyButton/index.mjs +2 -2
  142. package/reactjs/components/CopyButton/utils/copyToClipboard.js +1 -38
  143. package/reactjs/components/CopyButton/utils/copyToClipboard.mjs +20 -32
  144. package/reactjs/components/CopyButton/utils/index.js +1 -4
  145. package/reactjs/components/CopyButton/utils/index.mjs +2 -2
  146. package/reactjs/components/DisplayAmount/DisplayAmount.js +1 -90
  147. package/reactjs/components/DisplayAmount/DisplayAmount.mjs +68 -75
  148. package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +1 -39
  149. package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.mjs +26 -33
  150. package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.js +1 -61
  151. package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.mjs +38 -46
  152. package/reactjs/components/DisplayAmount/index.js +1 -4
  153. package/reactjs/components/DisplayAmount/index.mjs +2 -2
  154. package/reactjs/components/DisplayAmount/utils/index.js +1 -4
  155. package/reactjs/components/DisplayAmount/utils/index.mjs +2 -2
  156. package/reactjs/components/DisplayAmount/utils/truncateAmount.js +1 -21
  157. package/reactjs/components/DisplayAmount/utils/truncateAmount.mjs +9 -13
  158. package/reactjs/components/Error/Error.js +1 -66
  159. package/reactjs/components/Error/Error.mjs +29 -29
  160. package/reactjs/components/Error/index.js +1 -4
  161. package/reactjs/components/Error/index.mjs +2 -2
  162. package/reactjs/components/SmallLoader/SmallLoader.js +1 -21
  163. package/reactjs/components/SmallLoader/SmallLoader.mjs +13 -18
  164. package/reactjs/components/SmallLoader/index.js +1 -4
  165. package/reactjs/components/SmallLoader/index.mjs +2 -2
  166. package/reactjs/components/ToggleDirection/ToggleDirection.js +1 -30
  167. package/reactjs/components/ToggleDirection/ToggleDirection.mjs +22 -28
  168. package/reactjs/components/TokenSelector/TokenSelector.js +1 -172
  169. package/reactjs/components/TokenSelector/TokenSelector.mjs +98 -118
  170. package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +1 -94
  171. package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +48 -57
  172. package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.js +1 -51
  173. package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +45 -44
  174. package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.js +1 -18
  175. package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.mjs +9 -14
  176. package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.js +1 -6
  177. package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.mjs +2 -4
  178. package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.js +1 -39
  179. package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +22 -18
  180. package/reactjs/components/TokenSelector/components/SelectContainer.js +1 -40
  181. package/reactjs/components/TokenSelector/components/SelectContainer.mjs +36 -38
  182. package/reactjs/components/TokenSelector/components/SelectContent.js +1 -136
  183. package/reactjs/components/TokenSelector/components/SelectContent.mjs +79 -103
  184. package/reactjs/components/TokenSelector/components/SelectedOption.js +1 -28
  185. package/reactjs/components/TokenSelector/components/SelectedOption.mjs +22 -24
  186. package/reactjs/components/TokenSelector/components/TokenIcon.js +1 -81
  187. package/reactjs/components/TokenSelector/components/TokenIcon.mjs +52 -57
  188. package/reactjs/components/TokenSelector/components/TokenItem.js +1 -80
  189. package/reactjs/components/TokenSelector/components/TokenItem.mjs +41 -54
  190. package/reactjs/components/TokenSelector/components/TokenList.js +1 -23
  191. package/reactjs/components/TokenSelector/components/TokenList.mjs +19 -21
  192. package/reactjs/components/TokenSelector/components/TokenSymbol.js +1 -25
  193. package/reactjs/components/TokenSelector/components/TokenSymbol.mjs +14 -15
  194. package/reactjs/components/TokenSelector/index.js +1 -4
  195. package/reactjs/components/TokenSelector/index.mjs +2 -2
  196. package/reactjs/components/TransactionToast/TransactionToast.js +1 -53
  197. package/reactjs/components/TransactionToast/TransactionToast.mjs +27 -28
  198. package/reactjs/components/TransactionToast/TransactionToastContainer.js +1 -20
  199. package/reactjs/components/TransactionToast/TransactionToastContainer.mjs +16 -18
  200. package/reactjs/components/TransactionToast/index.js +1 -6
  201. package/reactjs/components/TransactionToast/index.mjs +4 -4
  202. package/reactjs/components/TrimAddress/TrimAddress.js +1 -27
  203. package/reactjs/components/TrimAddress/TrimAddress.mjs +19 -24
  204. package/reactjs/components/TrimAddress/index.js +1 -4
  205. package/reactjs/components/TrimAddress/index.mjs +2 -2
  206. package/reactjs/components/base/MxButton/MxButton.js +1 -71
  207. package/reactjs/components/base/MxButton/MxButton.mjs +46 -46
  208. package/reactjs/components/base/MxButton/index.js +1 -4
  209. package/reactjs/components/base/MxButton/index.mjs +2 -2
  210. package/reactjs/components/base/MxCard/MxCard.js +1 -54
  211. package/reactjs/components/base/MxCard/MxCard.mjs +34 -34
  212. package/reactjs/components/base/MxCard/index.js +1 -4
  213. package/reactjs/components/base/MxCard/index.mjs +2 -2
  214. package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +1 -28
  215. package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +24 -26
  216. package/reactjs/components/base/MxCircleLoader/index.js +1 -4
  217. package/reactjs/components/base/MxCircleLoader/index.mjs +2 -2
  218. package/reactjs/components/base/MxLink/MxLink.js +1 -70
  219. package/reactjs/components/base/MxLink/MxLink.mjs +44 -46
  220. package/reactjs/components/base/MxLink/index.js +1 -4
  221. package/reactjs/components/base/MxLink/index.mjs +2 -2
  222. package/reactjs/components/base/MxSearch/MxSearch.js +1 -69
  223. package/reactjs/components/base/MxSearch/MxSearch.mjs +37 -41
  224. package/reactjs/components/base/MxSearch/index.js +1 -4
  225. package/reactjs/components/base/MxSearch/index.mjs +2 -2
  226. package/reactjs/components/base/MxSlideover/MxSlideover.js +1 -78
  227. package/reactjs/components/base/MxSlideover/MxSlideover.mjs +72 -74
  228. package/reactjs/components/base/MxSlideover/index.js +1 -4
  229. package/reactjs/components/base/MxSlideover/index.mjs +2 -2
  230. package/reactjs/components/base/MxTooltip/MxTooltip.js +1 -163
  231. package/reactjs/components/base/MxTooltip/MxTooltip.mjs +92 -135
  232. package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +1 -33
  233. package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs +29 -31
  234. package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.js +1 -4
  235. package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.mjs +2 -2
  236. package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.js +1 -27
  237. package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.mjs +23 -25
  238. package/reactjs/components/base/MxTooltip/components/TooltipContent/index.js +1 -4
  239. package/reactjs/components/base/MxTooltip/components/TooltipContent/index.mjs +2 -2
  240. package/reactjs/components/base/MxTooltip/components/index.js +1 -6
  241. package/reactjs/components/base/MxTooltip/components/index.mjs +4 -4
  242. package/reactjs/components/base/MxTooltip/index.js +1 -4
  243. package/reactjs/components/base/MxTooltip/index.mjs +2 -2
  244. package/reactjs/components/base/index.js +1 -14
  245. package/reactjs/components/base/index.mjs +12 -12
  246. package/reactjs/components/index.js +1 -54
  247. package/reactjs/components/index.mjs +52 -52
  248. package/reactjs/constants/chains.js +1 -54
  249. package/reactjs/constants/chains.mjs +33 -52
  250. package/reactjs/constants/index.js +1 -13
  251. package/reactjs/constants/index.mjs +9 -10
  252. package/reactjs/context/Web3AppProvider.js +1 -40
  253. package/reactjs/context/Web3AppProvider.mjs +34 -34
  254. package/reactjs/context/queryClient.js +1 -11
  255. package/reactjs/context/queryClient.mjs +5 -8
  256. package/reactjs/context/useWeb3App.js +1 -12
  257. package/reactjs/context/useWeb3App.mjs +7 -8
  258. package/reactjs/helpers/index.js +1 -6
  259. package/reactjs/helpers/index.mjs +4 -4
  260. package/reactjs/helpers/resolveBridgeApiChainId.js +1 -40
  261. package/reactjs/helpers/resolveBridgeApiChainId.mjs +21 -34
  262. package/reactjs/hooks/index.js +1 -35
  263. package/reactjs/hooks/index.mjs +33 -33
  264. package/reactjs/hooks/tests/useGenericSignMessage.spec.d.ts +1 -0
  265. package/reactjs/hooks/tests/useGenericSignMessage.spec.js +2 -0
  266. package/reactjs/hooks/tests/useGenericSignMessage.spec.mjs +52 -0
  267. package/reactjs/hooks/tests/useSignTransaction.spec.d.ts +1 -0
  268. package/reactjs/hooks/tests/useSignTransaction.spec.js +2 -0
  269. package/reactjs/hooks/tests/useSignTransaction.spec.mjs +156 -0
  270. package/reactjs/hooks/useAccount.js +1 -13
  271. package/reactjs/hooks/useAccount.mjs +7 -8
  272. package/reactjs/hooks/useBalances.js +1 -53
  273. package/reactjs/hooks/useBalances.mjs +28 -40
  274. package/reactjs/hooks/useBridgeApiChainId.js +1 -13
  275. package/reactjs/hooks/useBridgeApiChainId.mjs +9 -9
  276. package/reactjs/hooks/useBridgeFormik.js +1 -162
  277. package/reactjs/hooks/useBridgeFormik.mjs +110 -150
  278. package/reactjs/hooks/useDebounce.js +1 -13
  279. package/reactjs/hooks/useDebounce.mjs +8 -10
  280. package/reactjs/hooks/useFetchBridgeData.js +1 -45
  281. package/reactjs/hooks/useFetchBridgeData.mjs +37 -38
  282. package/reactjs/hooks/useFetchTokens.js +1 -113
  283. package/reactjs/hooks/useFetchTokens.mjs +80 -106
  284. package/reactjs/hooks/useGenericSignMessage.js +1 -55
  285. package/reactjs/hooks/useGenericSignMessage.mjs +47 -47
  286. package/reactjs/hooks/useGetChainId.js +1 -11
  287. package/reactjs/hooks/useGetChainId.mjs +7 -8
  288. package/reactjs/hooks/useResolveTokenChain.js +1 -20
  289. package/reactjs/hooks/useResolveTokenChain.mjs +11 -14
  290. package/reactjs/hooks/useSendTransactions.js +1 -25
  291. package/reactjs/hooks/useSendTransactions.mjs +19 -23
  292. package/reactjs/hooks/useSignTransaction.js +1 -86
  293. package/reactjs/hooks/useSignTransaction.mjs +59 -59
  294. package/reactjs/hooks/useSuiConnect.js +1 -86
  295. package/reactjs/hooks/useSuiConnect.mjs +52 -70
  296. package/reactjs/hooks/validation/index.js +1 -10
  297. package/reactjs/hooks/validation/index.mjs +8 -8
  298. package/reactjs/hooks/validation/useAmountSchema.js +1 -32
  299. package/reactjs/hooks/validation/useAmountSchema.mjs +8 -11
  300. package/reactjs/hooks/validation/useSecondAmountSchema.js +1 -26
  301. package/reactjs/hooks/validation/useSecondAmountSchema.mjs +5 -6
  302. package/reactjs/hooks/validation/useTestHasEnoughFunds.js +1 -37
  303. package/reactjs/hooks/validation/useTestHasEnoughFunds.mjs +20 -29
  304. package/reactjs/hooks/validation/useTestIsConnected.js +1 -27
  305. package/reactjs/hooks/validation/useTestIsConnected.mjs +13 -19
  306. package/reactjs/index.js +1 -190
  307. package/reactjs/index.mjs +154 -154
  308. package/reactjs/init/index.js +1 -5
  309. package/reactjs/init/index.mjs +3 -3
  310. package/reactjs/init/init.d.ts +1 -0
  311. package/reactjs/init/init.js +1 -139
  312. package/reactjs/init/init.mjs +59 -72
  313. package/reactjs/queries/index.js +1 -17
  314. package/reactjs/queries/index.mjs +15 -15
  315. package/reactjs/queries/useCheckAccount.query.js +1 -39
  316. package/reactjs/queries/useCheckAccount.query.mjs +29 -33
  317. package/reactjs/queries/useGetAllTokens.query.js +1 -35
  318. package/reactjs/queries/useGetAllTokens.query.mjs +26 -30
  319. package/reactjs/queries/useGetChains.query.js +1 -34
  320. package/reactjs/queries/useGetChains.query.mjs +26 -28
  321. package/reactjs/queries/useGetHistory.query.d.ts +1 -1
  322. package/reactjs/queries/useGetHistory.query.js +1 -68
  323. package/reactjs/queries/useGetHistory.query.mjs +55 -58
  324. package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +1 -1
  325. package/reactjs/queries/useGetMvxTokensBalances.query.js +1 -71
  326. package/reactjs/queries/useGetMvxTokensBalances.query.mjs +40 -53
  327. package/reactjs/queries/useGetNonMvxTokensBalances.query.d.ts +1 -1
  328. package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -81
  329. package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +51 -59
  330. package/reactjs/queries/useGetRate.mutation.js +1 -18
  331. package/reactjs/queries/useGetRate.mutation.mjs +12 -15
  332. package/reactjs/reexports.js +1 -48
  333. package/reactjs/reexports.mjs +13 -13
  334. package/reactjs/utils/delay.js +1 -6
  335. package/reactjs/utils/delay.mjs +3 -3
  336. package/reactjs/utils/formatAmount.js +1 -23
  337. package/reactjs/utils/formatAmount.mjs +16 -17
  338. package/reactjs/utils/getCleanStringAmount.js +1 -11
  339. package/reactjs/utils/getCleanStringAmount.mjs +6 -8
  340. package/reactjs/utils/getCompletePathname.js +1 -5
  341. package/reactjs/utils/getCompletePathname.mjs +3 -3
  342. package/reactjs/utils/getInitialTokens.js +1 -12
  343. package/reactjs/utils/getInitialTokens.mjs +6 -7
  344. package/reactjs/utils/hasEnoughFunds.js +1 -19
  345. package/reactjs/utils/hasEnoughFunds.mjs +11 -14
  346. package/reactjs/utils/index.js +1 -26
  347. package/reactjs/utils/index.mjs +24 -24
  348. package/reactjs/utils/isStringFloat.js +1 -21
  349. package/reactjs/utils/isStringFloat.mjs +11 -18
  350. package/reactjs/utils/mxClsx.js +1 -8
  351. package/reactjs/utils/mxClsx.mjs +4 -6
  352. package/reactjs/utils/pipe.js +1 -25
  353. package/reactjs/utils/pipe.mjs +13 -17
  354. package/reactjs/utils/removeCommas.js +1 -6
  355. package/reactjs/utils/removeCommas.mjs +2 -4
  356. package/reactjs/utils/roundAmount.js +1 -40
  357. package/reactjs/utils/roundAmount.mjs +16 -36
  358. package/reactjs/utils/testNumber.js +1 -4
  359. package/reactjs/utils/testNumber.mjs +2 -2
  360. package/store/inMemoryStore.js +1 -39
  361. package/store/inMemoryStore.mjs +17 -21
  362. package/style.css +1 -2274
  363. package/types/chainType.js +1 -11
  364. package/types/chainType.mjs +2 -9
  365. package/types/errors.d.ts +3 -0
  366. package/types/errors.js +2 -0
  367. package/types/errors.mjs +8 -0
  368. package/types/providerType.js +1 -9
  369. package/types/providerType.mjs +2 -7
  370. package/types/transaction.d.ts +2 -0
  371. package/all-networks-EJIVYZ_i.mjs +0 -4
  372. package/all-networks-NYACMyeN.js +0 -4
  373. package/default-BYtXv70Z.mjs +0 -4
  374. package/default-H3AbmzFV.js +0 -4
  375. package/reactjs/hooks/useSignTransaction.d.ts +0 -511
@@ -1,79 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
5
- const React = require("react");
6
- const reactjs_hooks_useBridgeFormik = require("../../../hooks/useBridgeFormik.js");
7
- const useBridgeAmounts = ({
8
- firstToken,
9
- firstTokenAmount,
10
- secondTokenAmount,
11
- rate,
12
- rateValidationError,
13
- formikSetFieldValue
14
- }) => {
15
- const [firstAmount, setFirstAmount] = React.useState(firstTokenAmount ?? "");
16
- const [secondAmount, setSecondAmount] = React.useState(secondTokenAmount ?? "");
17
- const handleOnChangeFirstAmount = React.useCallback((amount) => {
18
- setFirstAmount(amount);
19
- }, []);
20
- const handleOnChangeSecondAmount = React.useCallback((amount) => {
21
- setSecondAmount(amount);
22
- }, []);
23
- const handleOnFirstMaxBtnChange = React.useCallback(() => {
24
- const formattedBalance = formatAmount.formatAmount({
25
- decimals: firstToken == null ? void 0 : firstToken.decimals,
26
- input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
27
- addCommas: false,
28
- digits: 4
29
- });
30
- formikSetFieldValue("firstAmount", formattedBalance);
31
- handleOnChangeFirstAmount(formattedBalance);
32
- }, [
33
- firstToken == null ? void 0 : firstToken.balance,
34
- firstToken == null ? void 0 : firstToken.decimals,
35
- formikSetFieldValue,
36
- handleOnChangeFirstAmount
37
- ]);
38
- const clearAmounts = React.useCallback(() => {
39
- handleOnChangeFirstAmount("");
40
- handleOnChangeSecondAmount("");
41
- }, [handleOnChangeFirstAmount, handleOnChangeSecondAmount]);
42
- React.useEffect(() => {
43
- if (rate == null ? void 0 : rate.amountOut) {
44
- formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, rate.amountOut);
45
- setSecondAmount(rate.amountOut);
46
- }
47
- }, [rate == null ? void 0 : rate.amountOut, formikSetFieldValue]);
48
- React.useEffect(() => {
49
- if (rateValidationError) {
50
- formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, "0");
51
- setSecondAmount("0");
52
- }
53
- }, [rateValidationError, formikSetFieldValue]);
54
- React.useEffect(() => {
55
- if (firstTokenAmount) {
56
- formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount, firstTokenAmount);
57
- handleOnChangeFirstAmount(firstTokenAmount);
58
- }
59
- }, [firstTokenAmount, formikSetFieldValue, handleOnChangeFirstAmount]);
60
- React.useEffect(() => {
61
- if (secondTokenAmount) {
62
- formikSetFieldValue(
63
- reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount,
64
- secondTokenAmount
65
- );
66
- handleOnChangeSecondAmount(secondTokenAmount);
67
- }
68
- }, [secondTokenAmount, formikSetFieldValue, handleOnChangeSecondAmount]);
69
- return {
70
- firstAmount,
71
- secondAmount,
72
- handleOnChangeFirstAmount,
73
- handleOnChangeSecondAmount,
74
- handleOnFirstMaxBtnChange,
75
- clearAmounts,
76
- hasAmounts: firstAmount !== "" && secondAmount !== ""
77
- };
78
- };
79
- exports.useBridgeAmounts = useBridgeAmounts;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),s=require("react"),b=require("../../../hooks/useBridgeFormik.js"),q=({firstToken:u,firstTokenAmount:t,secondTokenAmount:g,rate:a,rateValidationError:B,formikSetFieldValue:c})=>{const[h,O]=s.useState(t??""),[C,A]=s.useState(g??""),m=s.useCallback(n=>{O(n)},[]),d=s.useCallback(n=>{A(n)},[]),l=s.useCallback(()=>{const n=o.formatAmount({decimals:u==null?void 0:u.decimals,input:(u==null?void 0:u.balance)??"0",addCommas:!1,digits:4});c("firstAmount",n),m(n)},[u==null?void 0:u.balance,u==null?void 0:u.decimals,c,m]),E=s.useCallback(()=>{m(""),d("")},[m,d]);return s.useEffect(()=>{a!=null&&a.amountOut&&(c(b.BridgeFormikValuesEnum.secondAmount,a.amountOut),A(a.amountOut))},[a==null?void 0:a.amountOut,c]),s.useEffect(()=>{B&&(c(b.BridgeFormikValuesEnum.secondAmount,"0"),A("0"))},[B,c]),s.useEffect(()=>{t&&(c(b.BridgeFormikValuesEnum.firstAmount,t),m(t))},[t,c,m]),s.useEffect(()=>{g&&(c(b.BridgeFormikValuesEnum.secondAmount,g),d(g))},[g,c,d]),{firstAmount:h,secondAmount:C,handleOnChangeFirstAmount:m,handleOnChangeSecondAmount:d,handleOnFirstMaxBtnChange:l,clearAmounts:E,hasAmounts:h!==""&&C!==""}};exports.useBridgeAmounts=q;
@@ -1,78 +1,55 @@
1
- import { formatAmount } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { BridgeFormikValuesEnum } from "../../../hooks/useBridgeFormik.mjs";
4
- const useBridgeAmounts = ({
5
- firstToken,
6
- firstTokenAmount,
7
- secondTokenAmount,
8
- rate,
9
- rateValidationError,
10
- formikSetFieldValue
1
+ import { formatAmount as q } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
2
+ import { useState as x, useCallback as O, useEffect as g } from "react";
3
+ import { BridgeFormikValuesEnum as p } from "../../../hooks/useBridgeFormik.mjs";
4
+ const y = ({
5
+ firstToken: c,
6
+ firstTokenAmount: s,
7
+ secondTokenAmount: h,
8
+ rate: u,
9
+ rateValidationError: d,
10
+ formikSetFieldValue: m
11
11
  }) => {
12
- const [firstAmount, setFirstAmount] = useState(firstTokenAmount ?? "");
13
- const [secondAmount, setSecondAmount] = useState(secondTokenAmount ?? "");
14
- const handleOnChangeFirstAmount = useCallback((amount) => {
15
- setFirstAmount(amount);
16
- }, []);
17
- const handleOnChangeSecondAmount = useCallback((amount) => {
18
- setSecondAmount(amount);
19
- }, []);
20
- const handleOnFirstMaxBtnChange = useCallback(() => {
21
- const formattedBalance = formatAmount({
22
- decimals: firstToken == null ? void 0 : firstToken.decimals,
23
- input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
24
- addCommas: false,
12
+ const [B, E] = x(s ?? ""), [b, C] = x(h ?? ""), n = O((a) => {
13
+ E(a);
14
+ }, []), A = O((a) => {
15
+ C(a);
16
+ }, []), M = O(() => {
17
+ const a = q({
18
+ decimals: c == null ? void 0 : c.decimals,
19
+ input: (c == null ? void 0 : c.balance) ?? "0",
20
+ addCommas: !1,
25
21
  digits: 4
26
22
  });
27
- formikSetFieldValue("firstAmount", formattedBalance);
28
- handleOnChangeFirstAmount(formattedBalance);
23
+ m("firstAmount", a), n(a);
29
24
  }, [
30
- firstToken == null ? void 0 : firstToken.balance,
31
- firstToken == null ? void 0 : firstToken.decimals,
32
- formikSetFieldValue,
33
- handleOnChangeFirstAmount
34
- ]);
35
- const clearAmounts = useCallback(() => {
36
- handleOnChangeFirstAmount("");
37
- handleOnChangeSecondAmount("");
38
- }, [handleOnChangeFirstAmount, handleOnChangeSecondAmount]);
39
- useEffect(() => {
40
- if (rate == null ? void 0 : rate.amountOut) {
41
- formikSetFieldValue(BridgeFormikValuesEnum.secondAmount, rate.amountOut);
42
- setSecondAmount(rate.amountOut);
43
- }
44
- }, [rate == null ? void 0 : rate.amountOut, formikSetFieldValue]);
45
- useEffect(() => {
46
- if (rateValidationError) {
47
- formikSetFieldValue(BridgeFormikValuesEnum.secondAmount, "0");
48
- setSecondAmount("0");
49
- }
50
- }, [rateValidationError, formikSetFieldValue]);
51
- useEffect(() => {
52
- if (firstTokenAmount) {
53
- formikSetFieldValue(BridgeFormikValuesEnum.firstAmount, firstTokenAmount);
54
- handleOnChangeFirstAmount(firstTokenAmount);
55
- }
56
- }, [firstTokenAmount, formikSetFieldValue, handleOnChangeFirstAmount]);
57
- useEffect(() => {
58
- if (secondTokenAmount) {
59
- formikSetFieldValue(
60
- BridgeFormikValuesEnum.secondAmount,
61
- secondTokenAmount
62
- );
63
- handleOnChangeSecondAmount(secondTokenAmount);
64
- }
65
- }, [secondTokenAmount, formikSetFieldValue, handleOnChangeSecondAmount]);
66
- return {
67
- firstAmount,
68
- secondAmount,
69
- handleOnChangeFirstAmount,
70
- handleOnChangeSecondAmount,
71
- handleOnFirstMaxBtnChange,
72
- clearAmounts,
73
- hasAmounts: firstAmount !== "" && secondAmount !== ""
25
+ c == null ? void 0 : c.balance,
26
+ c == null ? void 0 : c.decimals,
27
+ m,
28
+ n
29
+ ]), j = O(() => {
30
+ n(""), A("");
31
+ }, [n, A]);
32
+ return g(() => {
33
+ u != null && u.amountOut && (m(p.secondAmount, u.amountOut), C(u.amountOut));
34
+ }, [u == null ? void 0 : u.amountOut, m]), g(() => {
35
+ d && (m(p.secondAmount, "0"), C("0"));
36
+ }, [d, m]), g(() => {
37
+ s && (m(p.firstAmount, s), n(s));
38
+ }, [s, m, n]), g(() => {
39
+ h && (m(
40
+ p.secondAmount,
41
+ h
42
+ ), A(h));
43
+ }, [h, m, A]), {
44
+ firstAmount: B,
45
+ secondAmount: b,
46
+ handleOnChangeFirstAmount: n,
47
+ handleOnChangeSecondAmount: A,
48
+ handleOnFirstMaxBtnChange: M,
49
+ clearAmounts: j,
50
+ hasAmounts: B !== "" && b !== ""
74
51
  };
75
52
  };
76
53
  export {
77
- useBridgeAmounts
54
+ y as useBridgeAmounts
78
55
  };
@@ -1,59 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const debounce = require("lodash/debounce");
5
- const React = require("react");
6
- let fetchRateInterval;
7
- const useBridgeRateFetching = ({
8
- firstAmount,
9
- firstToken,
10
- secondToken,
11
- accountAddress,
12
- fromChainId,
13
- toChainId,
14
- nativeAuthToken,
15
- forceRefetchRate,
16
- getRate
17
- }) => {
18
- const fetchRateDebounced = React.useCallback(
19
- debounce(async (amount) => {
20
- if (!amount || !Number(amount) || !accountAddress || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !fromChainId) {
21
- return;
22
- }
23
- getRate({
24
- nativeAuthToken: nativeAuthToken ?? "",
25
- body: {
26
- tokenIn: firstToken.address,
27
- amountIn: amount,
28
- fromChainId,
29
- tokenOut: secondToken.address,
30
- toChainId
31
- }
32
- });
33
- }, 500),
34
- [
35
- accountAddress,
36
- firstToken == null ? void 0 : firstToken.address,
37
- secondToken == null ? void 0 : secondToken.address,
38
- fromChainId,
39
- toChainId,
40
- nativeAuthToken,
41
- getRate
42
- ]
43
- );
44
- React.useEffect(() => {
45
- if (!firstAmount) {
46
- return;
47
- }
48
- fetchRateDebounced(firstAmount);
49
- if (fetchRateInterval) {
50
- clearInterval(fetchRateInterval);
51
- }
52
- fetchRateInterval = setInterval(() => {
53
- fetchRateDebounced(firstAmount);
54
- }, 50 * 1e3);
55
- return () => clearInterval(fetchRateInterval);
56
- }, [firstAmount, forceRefetchRate, fetchRateDebounced]);
57
- return { fetchRateDebounced };
58
- };
59
- exports.useBridgeRateFetching = useBridgeRateFetching;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("lodash/debounce"),y=require("react");let l;const q=({firstAmount:r,firstToken:e,secondToken:a,accountAddress:c,fromChainId:t,toChainId:v,nativeAuthToken:d,forceRefetchRate:R,getRate:g})=>{const u=y.useCallback(I(async b=>{!b||!Number(b)||!c||!(e!=null&&e.address)||!(a!=null&&a.address)||!t||g({nativeAuthToken:d??"",body:{tokenIn:e.address,amountIn:b,fromChainId:t,tokenOut:a.address,toChainId:v}})},500),[c,e==null?void 0:e.address,a==null?void 0:a.address,t,v,d,g]);return y.useEffect(()=>{if(r)return u(r),l&&clearInterval(l),l=setInterval(()=>{u(r)},50*1e3),()=>clearInterval(l)},[r,R,u]),{fetchRateDebounced:u}};exports.useBridgeRateFetching=q;
@@ -1,58 +1,47 @@
1
- import debounce from "lodash/debounce";
2
- import { useCallback, useEffect } from "react";
3
- let fetchRateInterval;
4
- const useBridgeRateFetching = ({
5
- firstAmount,
6
- firstToken,
7
- secondToken,
8
- accountAddress,
9
- fromChainId,
10
- toChainId,
11
- nativeAuthToken,
12
- forceRefetchRate,
13
- getRate
1
+ import d from "lodash/debounce";
2
+ import { useCallback as g, useEffect as x } from "react";
3
+ let b;
4
+ const E = ({
5
+ firstAmount: l,
6
+ firstToken: a,
7
+ secondToken: r,
8
+ accountAddress: v,
9
+ fromChainId: e,
10
+ toChainId: p,
11
+ nativeAuthToken: I,
12
+ forceRefetchRate: R,
13
+ getRate: y
14
14
  }) => {
15
- const fetchRateDebounced = useCallback(
16
- debounce(async (amount) => {
17
- if (!amount || !Number(amount) || !accountAddress || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !fromChainId) {
18
- return;
19
- }
20
- getRate({
21
- nativeAuthToken: nativeAuthToken ?? "",
15
+ const u = g(
16
+ d(async (t) => {
17
+ !t || !Number(t) || !v || !(a != null && a.address) || !(r != null && r.address) || !e || y({
18
+ nativeAuthToken: I ?? "",
22
19
  body: {
23
- tokenIn: firstToken.address,
24
- amountIn: amount,
25
- fromChainId,
26
- tokenOut: secondToken.address,
27
- toChainId
20
+ tokenIn: a.address,
21
+ amountIn: t,
22
+ fromChainId: e,
23
+ tokenOut: r.address,
24
+ toChainId: p
28
25
  }
29
26
  });
30
27
  }, 500),
31
28
  [
32
- accountAddress,
33
- firstToken == null ? void 0 : firstToken.address,
34
- secondToken == null ? void 0 : secondToken.address,
35
- fromChainId,
36
- toChainId,
37
- nativeAuthToken,
38
- getRate
29
+ v,
30
+ a == null ? void 0 : a.address,
31
+ r == null ? void 0 : r.address,
32
+ e,
33
+ p,
34
+ I,
35
+ y
39
36
  ]
40
37
  );
41
- useEffect(() => {
42
- if (!firstAmount) {
43
- return;
44
- }
45
- fetchRateDebounced(firstAmount);
46
- if (fetchRateInterval) {
47
- clearInterval(fetchRateInterval);
48
- }
49
- fetchRateInterval = setInterval(() => {
50
- fetchRateDebounced(firstAmount);
51
- }, 50 * 1e3);
52
- return () => clearInterval(fetchRateInterval);
53
- }, [firstAmount, forceRefetchRate, fetchRateDebounced]);
54
- return { fetchRateDebounced };
38
+ return x(() => {
39
+ if (l)
40
+ return u(l), b && clearInterval(b), b = setInterval(() => {
41
+ u(l);
42
+ }, 50 * 1e3), () => clearInterval(b);
43
+ }, [l, R, u]), { fetchRateDebounced: u };
55
44
  };
56
45
  export {
57
- useBridgeRateFetching
46
+ E as useBridgeRateFetching
58
47
  };
@@ -1,267 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const React = require("react");
5
- const reactjs_helpers_resolveBridgeApiChainId = require("../../../helpers/resolveBridgeApiChainId.js");
6
- const reactjs_utils_getInitialTokens = require("../../../utils/getInitialTokens.js");
7
- const reactjs_components_BridgeForm_utils_bridgeFormHelpers = require("../utils/bridgeFormHelpers.js");
8
- const useBridgeTokenSelection = ({
9
- chains,
10
- firstTokenIdentifier,
11
- secondTokenIdentifier,
12
- fromTokens,
13
- toTokens,
14
- isTokensLoading,
15
- activeChainId,
16
- mvxChainId,
17
- callbackRoute,
18
- forcedDestinationTokenSymbol,
19
- onNavigate,
20
- switchNetwork,
21
- sdkChains,
22
- activeChain
23
- }) => {
24
- const initializedInitialTokensRef = React.useRef(false);
25
- const [firstToken, setFirstToken] = React.useState();
26
- const [secondToken, setSecondToken] = React.useState();
27
- const fromOptions = React.useMemo(
28
- () => (fromTokens == null ? void 0 : fromTokens.filter((token) => {
29
- if (mvxChainId) {
30
- return token.chainId.toString().toLowerCase() === mvxChainId.toString().toLowerCase();
31
- }
32
- return true;
33
- }).map((token) => ({
34
- ...token,
35
- identifier: token.address,
36
- ticker: token.symbol
37
- }))) ?? [],
38
- [fromTokens, mvxChainId]
39
- );
40
- const getAvailableTokens = React.useCallback(
41
- (option) => reactjs_components_BridgeForm_utils_bridgeFormHelpers.getAvailableTokens(
42
- option,
43
- toTokens,
44
- forcedDestinationTokenSymbol
45
- ),
46
- [toTokens, forcedDestinationTokenSymbol]
47
- );
48
- const toOptions = React.useMemo(() => {
49
- if (!firstToken) {
50
- return [];
51
- }
52
- return (toTokens == null ? void 0 : toTokens.filter(
53
- (token) => token.symbol.toLowerCase() === firstToken.symbol.toLowerCase()
54
- ).map((token) => ({
55
- ...token,
56
- identifier: token.address,
57
- ticker: token.symbol
58
- }))) ?? [];
59
- }, [firstToken == null ? void 0 : firstToken.symbol, toTokens]);
60
- const selectedChainOption = React.useMemo(() => {
61
- const anchorToken = mvxChainId ? secondToken : firstToken;
62
- const byAnchorToken = anchorToken && (chains == null ? void 0 : chains.find(
63
- (option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, anchorToken.chainId)
64
- ));
65
- if (byAnchorToken) {
66
- return byAnchorToken;
67
- }
68
- const byActiveChain = chains == null ? void 0 : chains.find(
69
- (option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, activeChain == null ? void 0 : activeChain.id)
70
- );
71
- if (byActiveChain) {
72
- return byActiveChain;
73
- }
74
- const byOtherToken = mvxChainId ? firstToken && (chains == null ? void 0 : chains.find(
75
- (option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, firstToken.chainId)
76
- )) : secondToken && (chains == null ? void 0 : chains.find(
77
- (option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, secondToken.chainId)
78
- ));
79
- return byOtherToken ?? (chains == null ? void 0 : chains[0]);
80
- }, [
81
- activeChain == null ? void 0 : activeChain.id,
82
- chains,
83
- firstToken == null ? void 0 : firstToken.chainId,
84
- mvxChainId,
85
- secondToken == null ? void 0 : secondToken.chainId
86
- ]);
87
- const getDefaultReceivingToken = React.useCallback(
88
- (values) => reactjs_components_BridgeForm_utils_bridgeFormHelpers.getDefaultReceivingToken(values, toTokens),
89
- [toTokens]
90
- );
91
- const updateUrlParams = React.useCallback(
92
- ({
93
- firstTokenId,
94
- secondTokenId
95
- }) => {
96
- reactjs_components_BridgeForm_utils_bridgeFormHelpers.updateUrlParams({
97
- firstTokenId,
98
- secondTokenId,
99
- callbackRoute,
100
- isTokensLoading,
101
- onNavigate
102
- });
103
- },
104
- [callbackRoute, isTokensLoading, onNavigate]
105
- );
106
- const onChangeFirstSelect = React.useCallback(
107
- (option) => {
108
- if (!option) {
109
- return;
110
- }
111
- setFirstToken(option);
112
- updateUrlParams({ firstTokenId: option.address });
113
- let secondOption = toTokens == null ? void 0 : toTokens.find(
114
- (x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
115
- );
116
- if (!secondOption) {
117
- const availableTokens = getAvailableTokens(option);
118
- secondOption = availableTokens.find(
119
- (x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
120
- ) ?? getDefaultReceivingToken(availableTokens);
121
- }
122
- if (secondOption) {
123
- setSecondToken(secondOption);
124
- updateUrlParams({ secondTokenId: secondOption.address });
125
- }
126
- },
127
- [getAvailableTokens, getDefaultReceivingToken, updateUrlParams, toTokens]
128
- );
129
- const onChangeSecondSelect = React.useCallback(
130
- (option) => {
131
- if (!option) {
132
- return;
133
- }
134
- setSecondToken(option);
135
- updateUrlParams({ secondTokenId: option.address });
136
- const firstOption = fromOptions.find(
137
- (x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
138
- );
139
- if (firstOption) {
140
- setFirstToken(firstOption);
141
- updateUrlParams({ firstTokenId: firstOption.address });
142
- }
143
- },
144
- [fromOptions, updateUrlParams]
145
- );
146
- const handleChangeDirection = React.useCallback(() => {
147
- if (!firstToken || !secondToken) {
148
- return;
149
- }
150
- setFirstToken(secondToken);
151
- setSecondToken(firstToken);
152
- updateUrlParams({
153
- firstTokenId: secondToken.address,
154
- secondTokenId: firstToken.address
155
- });
156
- const selectedOptionChain = sdkChains == null ? void 0 : sdkChains.find(
157
- (chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.id, secondToken.chainId)
158
- );
159
- if (selectedOptionChain && switchNetwork) {
160
- switchNetwork(selectedOptionChain);
161
- }
162
- }, [firstToken, secondToken, updateUrlParams, sdkChains, switchNetwork]);
163
- React.useEffect(() => {
164
- var _a, _b, _c, _d;
165
- if (isTokensLoading || initializedInitialTokensRef.current || !fromOptions.length) {
166
- return;
167
- }
168
- if (firstToken && secondToken) {
169
- initializedInitialTokensRef.current = true;
170
- return;
171
- }
172
- const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens({
173
- firstTokenId: firstTokenIdentifier,
174
- secondTokenId: secondTokenIdentifier
175
- });
176
- const firstOption = fromOptions.find(
177
- ({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
178
- ) ?? fromOptions.find(
179
- (option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, activeChainId)
180
- ) ?? fromOptions[0];
181
- let secondOption = toTokens == null ? void 0 : toTokens.find(
182
- (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
183
- );
184
- if (!secondOption) {
185
- const availableTokens = getAvailableTokens(firstOption);
186
- secondOption = (availableTokens == null ? void 0 : availableTokens.find(
187
- ({ address }) => {
188
- var _a2;
189
- return address.toLowerCase() === ((_a2 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a2.toLowerCase());
190
- }
191
- )) ?? availableTokens.find(
192
- (x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
193
- ) ?? getDefaultReceivingToken(availableTokens);
194
- }
195
- const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a.toLowerCase()) === ((_b = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b.toLowerCase()) && ((_c = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c.toLowerCase()) === ((_d = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d.toLowerCase());
196
- if (hasOptionsSelected) {
197
- return;
198
- }
199
- let initialized = false;
200
- if (firstOption) {
201
- setFirstToken(firstOption);
202
- updateUrlParams({ firstTokenId: firstOption.address });
203
- const selectedOptionChain = (sdkChains == null ? void 0 : sdkChains.find(
204
- (chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.id, firstOption.chainId)
205
- )) ?? activeChain;
206
- if (selectedOptionChain && switchNetwork) {
207
- switchNetwork(selectedOptionChain);
208
- }
209
- initialized = true;
210
- }
211
- if (secondOption) {
212
- setSecondToken(secondOption);
213
- updateUrlParams({ secondTokenId: secondOption.address });
214
- initialized = initialized && true;
215
- }
216
- initializedInitialTokensRef.current = initialized;
217
- }, [
218
- isTokensLoading,
219
- fromOptions,
220
- toTokens,
221
- firstTokenIdentifier,
222
- secondTokenIdentifier,
223
- activeChainId,
224
- getAvailableTokens,
225
- getDefaultReceivingToken,
226
- updateUrlParams,
227
- sdkChains,
228
- activeChain,
229
- switchNetwork,
230
- firstToken,
231
- secondToken
232
- ]);
233
- React.useEffect(() => {
234
- const selectedTokenOption = fromTokens == null ? void 0 : fromTokens.find(
235
- (x) => x.address === (firstToken == null ? void 0 : firstToken.address)
236
- );
237
- if (selectedTokenOption) {
238
- setFirstToken((prev) => {
239
- return prev ? { ...prev, balance: selectedTokenOption.balance } : prev;
240
- });
241
- }
242
- }, [fromTokens, firstToken == null ? void 0 : firstToken.address]);
243
- React.useEffect(() => {
244
- const selectedTokenOption = toTokens == null ? void 0 : toTokens.find(
245
- (x) => x.address === (secondToken == null ? void 0 : secondToken.address)
246
- );
247
- if (selectedTokenOption) {
248
- setSecondToken((prev) => {
249
- return prev ? { ...prev, balance: selectedTokenOption.balance } : prev;
250
- });
251
- }
252
- }, [toTokens, secondToken == null ? void 0 : secondToken.address]);
253
- return {
254
- firstToken,
255
- secondToken,
256
- fromOptions,
257
- toOptions,
258
- selectedChainOption,
259
- setFirstToken,
260
- setSecondToken,
261
- onChangeFirstSelect,
262
- onChangeSecondSelect,
263
- handleChangeDirection,
264
- updateUrlParams
265
- };
266
- };
267
- exports.useBridgeTokenSelection = useBridgeTokenSelection;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),n=require("../../../helpers/resolveBridgeApiChainId.js"),W=require("../../../utils/getInitialTokens.js"),O=require("../utils/bridgeFormHelpers.js"),X=({chains:a,firstTokenIdentifier:j,secondTokenIdentifier:q,fromTokens:I,toTokens:t,isTokensLoading:S,activeChainId:F,mvxChainId:m,callbackRoute:M,forcedDestinationTokenSymbol:R,onNavigate:E,switchNetwork:L,sdkChains:i,activeChain:g})=>{const _=u.useRef(!1),[d,o]=u.useState(),[l,B]=u.useState(),y=u.useMemo(()=>(I==null?void 0:I.filter(e=>m?e.chainId.toString().toLowerCase()===m.toString().toLowerCase():!0).map(e=>({...e,identifier:e.address,ticker:e.symbol})))??[],[I,m]),A=u.useCallback(e=>O.getAvailableTokens(e,t,R),[t,R]),G=u.useMemo(()=>d?(t==null?void 0:t.filter(e=>e.symbol.toLowerCase()===d.symbol.toLowerCase()).map(e=>({...e,identifier:e.address,ticker:e.symbol})))??[]:[],[d==null?void 0:d.symbol,t]),J=u.useMemo(()=>{const e=m?l:d,r=e&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,e.chainId)));if(r)return r;const s=a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,g==null?void 0:g.id));return s||((m?d&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,d.chainId))):l&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,l.chainId))))??(a==null?void 0:a[0]))},[g==null?void 0:g.id,a,d==null?void 0:d.chainId,m,l==null?void 0:l.chainId]),w=u.useCallback(e=>O.getDefaultReceivingToken(e,t),[t]),b=u.useCallback(({firstTokenId:e,secondTokenId:r})=>{O.updateUrlParams({firstTokenId:e,secondTokenId:r,callbackRoute:M,isTokensLoading:S,onNavigate:E})},[M,S,E]),K=u.useCallback(e=>{if(!e)return;o(e),b({firstTokenId:e.address});let r=t==null?void 0:t.find(s=>s.symbol.toLowerCase()===e.symbol.toLowerCase());if(!r){const s=A(e);r=s.find(p=>p.symbol.toLowerCase()===e.symbol.toLowerCase())??w(s)}r&&(B(r),b({secondTokenId:r.address}))},[A,w,b,t]),Q=u.useCallback(e=>{if(!e)return;B(e),b({secondTokenId:e.address});const r=y.find(s=>s.symbol.toLowerCase()===e.symbol.toLowerCase());r&&(o(r),b({firstTokenId:r.address}))},[y,b]),V=u.useCallback(()=>{if(!d||!l)return;o(l),B(d),b({firstTokenId:l.address,secondTokenId:d.address});const e=i==null?void 0:i.find(r=>n.sameBridgeApiChainId(r.id,l.chainId));e&&L&&L(e)},[d,l,b,i,L]);return u.useEffect(()=>{var P,z,D,U;if(S||_.current||!y.length)return;if(d&&l){_.current=!0;return}const e=W.getInitialTokens({firstTokenId:j,secondTokenId:q}),r=y.find(({identifier:c})=>(e==null?void 0:e.firstTokenId)===c)??y.find(c=>n.sameBridgeApiChainId(c.chainId,F))??y[0];let s=t==null?void 0:t.find(c=>c.symbol.toLowerCase()===(r==null?void 0:r.symbol.toLowerCase()));if(!s){const c=A(r);s=(c==null?void 0:c.find(({address:C})=>{var H;return C.toLowerCase()===((H=(r==null?void 0:r.symbol)??(e==null?void 0:e.secondTokenId))==null?void 0:H.toLowerCase())}))??c.find(C=>C.symbol.toLowerCase()===(r==null?void 0:r.symbol.toLowerCase()))??w(c)}if(!!d&&!!l&&((P=d==null?void 0:d.address)==null?void 0:P.toLowerCase())===((z=r==null?void 0:r.address)==null?void 0:z.toLowerCase())&&((D=l==null?void 0:l.address)==null?void 0:D.toLowerCase())===((U=s==null?void 0:s.address)==null?void 0:U.toLowerCase()))return;let f=!1;if(r){o(r),b({firstTokenId:r.address});const c=(i==null?void 0:i.find(C=>n.sameBridgeApiChainId(C.id,r.chainId)))??g;c&&L&&L(c),f=!0}s&&(B(s),b({secondTokenId:s.address}),f=f&&!0),_.current=f},[S,y,t,j,q,F,A,w,b,i,g,L]),u.useEffect(()=>{const e=I==null?void 0:I.find(r=>r.address===(d==null?void 0:d.address));e&&o(r=>r&&{...r,balance:e.balance})},[I,d==null?void 0:d.address]),u.useEffect(()=>{const e=t==null?void 0:t.find(r=>r.address===(l==null?void 0:l.address));e&&B(r=>r&&{...r,balance:e.balance})},[t,l==null?void 0:l.address]),{firstToken:d,secondToken:l,fromOptions:y,toOptions:G,selectedChainOption:J,setFirstToken:o,setSecondToken:B,onChangeFirstSelect:K,onChangeSecondSelect:Q,handleChangeDirection:V,updateUrlParams:b}};exports.useBridgeTokenSelection=X;