@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
@@ -0,0 +1,156 @@
1
+ import { useAppKitProvider as f, useAppKitAccount as m } from "@reown/appkit/react";
2
+ import { r as a } from "../../../react.esm-BxvJJ86Q.mjs";
3
+ import { useSendTransaction as g } from "wagmi";
4
+ import { useSignTransaction as i } from "../useSignTransaction.mjs";
5
+ jest.mock("@reown/appkit-adapter-solana/react", () => ({
6
+ useAppKitConnection: jest.fn(() => ({ connection: null }))
7
+ }));
8
+ jest.mock("@solana/web3.js", () => ({
9
+ PublicKey: jest.fn(),
10
+ Transaction: jest.fn(() => ({ add: jest.fn().mockReturnThis() })),
11
+ TransactionInstruction: jest.fn()
12
+ }));
13
+ const d = jest.mocked(f), b = jest.mocked(m), u = jest.mocked(g);
14
+ beforeEach(() => {
15
+ u.mockReturnValue({
16
+ data: void 0,
17
+ sendTransactionAsync: jest.fn(),
18
+ error: null,
19
+ isError: !1,
20
+ isIdle: !0,
21
+ isPending: !1,
22
+ isSuccess: !1,
23
+ reset: jest.fn(),
24
+ sendTransaction: jest.fn(),
25
+ status: "idle",
26
+ variables: void 0,
27
+ context: void 0,
28
+ failureCount: 0,
29
+ failureReason: null,
30
+ isPaused: !1,
31
+ submittedAt: 0,
32
+ mutate: jest.fn(),
33
+ mutateAsync: jest.fn()
34
+ });
35
+ });
36
+ const o = "0xabc123def456aaa000111222333444555666777888999aaabbbcccdddeeefff00";
37
+ function r(s) {
38
+ d.mockImplementation((e) => e === "sui" ? { walletProvider: { request: s } } : { walletProvider: void 0 }), b.mockImplementation((e) => (e == null ? void 0 : e.namespace) === "sui" ? {
39
+ address: o,
40
+ isConnected: !0,
41
+ status: "connected"
42
+ } : {
43
+ address: void 0,
44
+ isConnected: !1,
45
+ status: "disconnected"
46
+ });
47
+ }
48
+ describe("useSignTransaction — signSuiTransaction", () => {
49
+ const s = btoa("valid transaction bytes");
50
+ beforeEach(() => {
51
+ u.mockReturnValue({
52
+ data: void 0,
53
+ sendTransactionAsync: jest.fn(),
54
+ error: null,
55
+ isError: !1,
56
+ isIdle: !0,
57
+ isPending: !1,
58
+ isSuccess: !1,
59
+ reset: jest.fn(),
60
+ sendTransaction: jest.fn(),
61
+ status: "idle",
62
+ variables: void 0,
63
+ context: void 0,
64
+ failureCount: 0,
65
+ failureReason: null,
66
+ isPaused: !1,
67
+ submittedAt: 0,
68
+ mutate: jest.fn(),
69
+ mutateAsync: jest.fn()
70
+ });
71
+ }), it("succeeds with valid base64 payload", async () => {
72
+ const e = jest.fn().mockResolvedValue({ signature: "sui-sig-ok" });
73
+ r(e);
74
+ const { result: t } = a(() => i()), n = await t.current.sui.signTransaction({
75
+ transaction: s,
76
+ address: o
77
+ });
78
+ expect(n).toBe("sui-sig-ok"), expect(e).toHaveBeenCalledWith(
79
+ expect.objectContaining({ method: "sui_signTransaction" })
80
+ );
81
+ }), it("throws when payload is not valid base64", async () => {
82
+ const e = jest.fn();
83
+ r(e);
84
+ const { result: t } = a(() => i());
85
+ await expect(
86
+ t.current.sui.signTransaction({
87
+ transaction: "not-valid-base64!!!",
88
+ address: o
89
+ })
90
+ ).rejects.toThrow("not valid base64"), expect(e).not.toHaveBeenCalled();
91
+ }), it("throws when payload exceeds 32 KiB", async () => {
92
+ const e = jest.fn();
93
+ r(e);
94
+ const t = new Uint8Array(32 * 1024 + 1), n = btoa(String.fromCharCode(...t)), { result: c } = a(() => i());
95
+ await expect(
96
+ c.current.sui.signTransaction({
97
+ transaction: n,
98
+ address: o
99
+ })
100
+ ).rejects.toThrow("maximum size"), expect(e).not.toHaveBeenCalled();
101
+ }), it("throws when payload is an empty string", async () => {
102
+ const e = jest.fn();
103
+ r(e);
104
+ const { result: t } = a(() => i());
105
+ await expect(
106
+ t.current.sui.signTransaction({
107
+ transaction: "",
108
+ address: o
109
+ })
110
+ ).rejects.toThrow("No Sui transaction bytes provided"), expect(e).not.toHaveBeenCalled();
111
+ });
112
+ });
113
+ describe("useSignTransaction — signPSBT", () => {
114
+ it("forwards signInputs verbatim to btcWalletProvider.signPSBT", async () => {
115
+ const s = jest.fn().mockResolvedValue({ psbt: "signed-psbt" });
116
+ d.mockImplementation((p) => p === "bip122" ? { walletProvider: { signPSBT: s } } : { walletProvider: void 0 });
117
+ const { result: e } = a(() => i()), t = [
118
+ {
119
+ address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
120
+ index: 0,
121
+ sighashTypes: [1]
122
+ }
123
+ ], n = {
124
+ psbt: "base64psbt==",
125
+ signInputs: [...t],
126
+ broadcast: !1
127
+ }, c = n.signInputs, l = await e.current.bitcoin.signTransaction(n);
128
+ expect(s).toHaveBeenCalledWith(
129
+ expect.objectContaining({
130
+ signInputs: [
131
+ {
132
+ address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
133
+ index: 0,
134
+ sighashTypes: [1]
135
+ }
136
+ ]
137
+ })
138
+ ), expect(s).not.toHaveBeenCalledWith(
139
+ expect.objectContaining({ signInputs: [] })
140
+ ), expect(n.signInputs).toBe(c), expect(n.signInputs).toEqual(t), expect(l).toBe("signed-psbt");
141
+ }), it("throws when btcWalletProvider is not available", async () => {
142
+ d.mockImplementation(
143
+ () => ({
144
+ walletProvider: void 0
145
+ })
146
+ );
147
+ const { result: s } = a(() => i());
148
+ await expect(
149
+ s.current.bitcoin.signTransaction({
150
+ psbt: "base64psbt==",
151
+ signInputs: [],
152
+ broadcast: !1
153
+ })
154
+ ).rejects.toThrow("user is disconnected");
155
+ });
156
+ });
@@ -1,14 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const react = require("@reown/appkit/react");
5
- const wagmi = require("wagmi");
6
- const useAccount = () => {
7
- const appkitAccount = react.useAppKitAccount();
8
- const wagmiAccount = wagmi.useAccount();
9
- return {
10
- ...wagmiAccount,
11
- ...appkitAccount
12
- };
13
- };
14
- exports.useAccount = useAccount;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@reown/appkit/react"),e=require("wagmi"),n=()=>{const c=t.useAppKitAccount();return{...e.useAccount(),...c}};exports.useAccount=n;
@@ -1,13 +1,12 @@
1
- import { useAppKitAccount } from "@reown/appkit/react";
2
- import { useAccount as useAccount$1 } from "wagmi";
3
- const useAccount = () => {
4
- const appkitAccount = useAppKitAccount();
5
- const wagmiAccount = useAccount$1();
1
+ import { useAppKitAccount as t } from "@reown/appkit/react";
2
+ import { useAccount as o } from "wagmi";
3
+ const A = () => {
4
+ const c = t();
6
5
  return {
7
- ...wagmiAccount,
8
- ...appkitAccount
6
+ ...o(),
7
+ ...c
9
8
  };
10
9
  };
11
10
  export {
12
- useAccount
11
+ A as useAccount
13
12
  };
@@ -1,54 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const react = require("@reown/appkit/react");
5
- const axios = require("axios");
6
- const React = require("react");
7
- const helpers_getApiURL = require("../../helpers/getApiURL.js");
8
- const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
9
- const useBalances = () => {
10
- const { config } = reactjs_context_useWeb3App.useWeb3App();
11
- const { address, isConnected } = react.useAppKitAccount();
12
- const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
13
- const fetchBalances = async (chainId) => {
14
- const url = `${helpers_getApiURL.getApiURL()}/user/balance/${address}?chainId=${chainId}`;
15
- try {
16
- const { data } = await axios.get(url, {
17
- headers: {
18
- Authorization: `Bearer ${nativeAuthToken}`
19
- }
20
- });
21
- return data.reduce(
22
- (acc, cur) => {
23
- acc[cur.tokenAddress] = cur.balance;
24
- return acc;
25
- },
26
- {}
27
- );
28
- } catch (error) {
29
- throw new Error(`Error fetching balances: ${error}`);
30
- }
31
- };
32
- const getBalances = React.useCallback(
33
- async ({ tokens, chainId }) => {
34
- const tokensBalances = await fetchBalances(chainId);
35
- return tokens.map((token) => {
36
- if (!isConnected || !address || !token.chainId) {
37
- return {
38
- tokenId: token.address,
39
- balance: "0"
40
- };
41
- }
42
- return {
43
- tokenId: token.address,
44
- balance: tokensBalances[token.address] ?? "0"
45
- };
46
- });
47
- },
48
- [config, isConnected, address]
49
- );
50
- return {
51
- getBalances
52
- };
53
- };
54
- exports.useBalances = useBalances;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@reown/appkit/react"),p=require("axios"),b=require("react"),h=require("../../helpers/getApiURL.js"),o=require("../context/useWeb3App.js"),A=()=>{const{config:u}=o.useWeb3App(),{address:t,isConnected:a}=l.useAppKitAccount(),{nativeAuthToken:i}=o.useWeb3App(),d=async n=>{const s=`${h.getApiURL()}/user/balance/${t}?chainId=${n}`;try{const{data:r}=await p.get(s,{headers:{Authorization:`Bearer ${i}`}});return r.reduce((e,c)=>(e[c.tokenAddress]=c.balance,e),{})}catch(r){throw new Error(`Error fetching balances: ${r}`)}};return{getBalances:b.useCallback(async({tokens:n,chainId:s})=>{const r=await d(s);return n.map(e=>!a||!t||!e.chainId?{tokenId:e.address,balance:"0"}:{tokenId:e.address,balance:r[e.address]??"0"})},[u,a,t])}};exports.useBalances=A;
@@ -1,53 +1,41 @@
1
- import { useAppKitAccount } from "@reown/appkit/react";
2
- import axios from "axios";
3
- import { useCallback } from "react";
4
- import { getApiURL } from "../../helpers/getApiURL.mjs";
5
- import { useWeb3App } from "../context/useWeb3App.mjs";
6
- const useBalances = () => {
7
- const { config } = useWeb3App();
8
- const { address, isConnected } = useAppKitAccount();
9
- const { nativeAuthToken } = useWeb3App();
10
- const fetchBalances = async (chainId) => {
11
- const url = `${getApiURL()}/user/balance/${address}?chainId=${chainId}`;
1
+ import { useAppKitAccount as l } from "@reown/appkit/react";
2
+ import p from "axios";
3
+ import { useCallback as m } from "react";
4
+ import { getApiURL as f } from "../../helpers/getApiURL.mjs";
5
+ import { useWeb3App as c } from "../context/useWeb3App.mjs";
6
+ const w = () => {
7
+ const { config: i } = c(), { address: a, isConnected: s } = l(), { nativeAuthToken: d } = c(), u = async (t) => {
8
+ const n = `${f()}/user/balance/${a}?chainId=${t}`;
12
9
  try {
13
- const { data } = await axios.get(url, {
10
+ const { data: r } = await p.get(n, {
14
11
  headers: {
15
- Authorization: `Bearer ${nativeAuthToken}`
12
+ Authorization: `Bearer ${d}`
16
13
  }
17
14
  });
18
- return data.reduce(
19
- (acc, cur) => {
20
- acc[cur.tokenAddress] = cur.balance;
21
- return acc;
22
- },
15
+ return r.reduce(
16
+ (e, o) => (e[o.tokenAddress] = o.balance, e),
23
17
  {}
24
18
  );
25
- } catch (error) {
26
- throw new Error(`Error fetching balances: ${error}`);
19
+ } catch (r) {
20
+ throw new Error(`Error fetching balances: ${r}`);
27
21
  }
28
22
  };
29
- const getBalances = useCallback(
30
- async ({ tokens, chainId }) => {
31
- const tokensBalances = await fetchBalances(chainId);
32
- return tokens.map((token) => {
33
- if (!isConnected || !address || !token.chainId) {
34
- return {
35
- tokenId: token.address,
36
- balance: "0"
37
- };
38
- }
39
- return {
40
- tokenId: token.address,
41
- balance: tokensBalances[token.address] ?? "0"
42
- };
43
- });
44
- },
45
- [config, isConnected, address]
46
- );
47
23
  return {
48
- getBalances
24
+ getBalances: m(
25
+ async ({ tokens: t, chainId: n }) => {
26
+ const r = await u(n);
27
+ return t.map((e) => !s || !a || !e.chainId ? {
28
+ tokenId: e.address,
29
+ balance: "0"
30
+ } : {
31
+ tokenId: e.address,
32
+ balance: r[e.address] ?? "0"
33
+ });
34
+ },
35
+ [i, s, a]
36
+ )
49
37
  };
50
38
  };
51
39
  export {
52
- useBalances
40
+ w as useBalances
53
41
  };
@@ -1,14 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const react = require("@reown/appkit/react");
5
- const React = require("react");
6
- const reactjs_helpers_resolveBridgeApiChainId = require("../helpers/resolveBridgeApiChainId.js");
7
- function useBridgeApiChainId() {
8
- const { chainId, caipNetwork } = react.useAppKitNetwork();
9
- return React.useMemo(
10
- () => reactjs_helpers_resolveBridgeApiChainId.toBridgeApiChainId(chainId, caipNetwork),
11
- [chainId, caipNetwork]
12
- );
13
- }
14
- exports.useBridgeApiChainId = useBridgeApiChainId;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@reown/appkit/react"),t=require("react"),n=require("../helpers/resolveBridgeApiChainId.js");function o(){const{chainId:e,caipNetwork:i}=r.useAppKitNetwork();return t.useMemo(()=>n.toBridgeApiChainId(e,i),[e,i])}exports.useBridgeApiChainId=o;
@@ -1,13 +1,13 @@
1
- import { useAppKitNetwork } from "@reown/appkit/react";
2
- import { useMemo } from "react";
3
- import { toBridgeApiChainId } from "../helpers/resolveBridgeApiChainId.mjs";
4
- function useBridgeApiChainId() {
5
- const { chainId, caipNetwork } = useAppKitNetwork();
6
- return useMemo(
7
- () => toBridgeApiChainId(chainId, caipNetwork),
8
- [chainId, caipNetwork]
1
+ import { useAppKitNetwork as r } from "@reown/appkit/react";
2
+ import { useMemo as t } from "react";
3
+ import { toBridgeApiChainId as e } from "../helpers/resolveBridgeApiChainId.mjs";
4
+ function d() {
5
+ const { chainId: i, caipNetwork: o } = r();
6
+ return t(
7
+ () => e(i, o),
8
+ [i, o]
9
9
  );
10
10
  }
11
11
  export {
12
- useBridgeApiChainId
12
+ d as useBridgeApiChainId
13
13
  };
@@ -1,163 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const formik = require("formik");
5
- const React = require("react");
6
- const yup = require("yup");
7
- const reactjs_hooks_validation_useAmountSchema = require("./validation/useAmountSchema.js");
8
- const reactjs_hooks_validation_useSecondAmountSchema = require("./validation/useSecondAmountSchema.js");
9
- const api_confirmRate = require("../../api/confirmRate.js");
10
- const helpers_getApiURL = require("../../helpers/getApiURL.js");
11
- const types_providerType = require("../../types/providerType.js");
12
- const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
13
- var BridgeFormikValuesEnum = /* @__PURE__ */ ((BridgeFormikValuesEnum2) => {
14
- BridgeFormikValuesEnum2["firstToken"] = "firstToken";
15
- BridgeFormikValuesEnum2["firstAmount"] = "firstAmount";
16
- BridgeFormikValuesEnum2["secondToken"] = "secondToken";
17
- BridgeFormikValuesEnum2["secondAmount"] = "secondAmount";
18
- BridgeFormikValuesEnum2["fromChainId"] = "fromChainId";
19
- BridgeFormikValuesEnum2["toChainId"] = "toChainId";
20
- return BridgeFormikValuesEnum2;
21
- })(BridgeFormikValuesEnum || {});
22
- const useBridgeFormik = ({
23
- sender,
24
- receiver,
25
- firstToken,
26
- firstAmount,
27
- secondToken,
28
- secondAmount,
29
- fromChainId,
30
- toChainId,
31
- setForceRefetchRate,
32
- rate,
33
- onSubmit,
34
- isMvxConnected
35
- }) => {
36
- const pendingSigningRef = React.useRef();
37
- const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
38
- const initialValues = {
39
- firstAmount: "",
40
- secondAmount: "",
41
- fromChainId: fromChainId ?? "",
42
- toChainId: toChainId ?? ""
43
- };
44
- const resetSwapForm = () => {
45
- formik$1.setTouched({}, false);
46
- formik$1.setErrors({});
47
- setFieldValue("firstAmount", "");
48
- setFieldValue("secondAmount", "");
49
- };
50
- const onSubmitFormik = async (values) => {
51
- var _a, _b;
52
- if (pendingSigningRef.current) {
53
- return;
54
- }
55
- pendingSigningRef.current = true;
56
- try {
57
- const { data } = await api_confirmRate.confirmRate({
58
- url: helpers_getApiURL.getApiURL(),
59
- nativeAuthToken: nativeAuthToken ?? "",
60
- body: {
61
- tokenIn: ((_a = values.firstToken) == null ? void 0 : _a.address) ?? "",
62
- amountIn: (firstAmount == null ? void 0 : firstAmount.toString()) ?? "",
63
- fromChainId: values.fromChainId ?? "",
64
- tokenOut: ((_b = values.secondToken) == null ? void 0 : _b.address) ?? "",
65
- toChainId: values.toChainId ?? "",
66
- amountOut: (secondAmount == null ? void 0 : secondAmount.toString()) ?? "",
67
- sender: sender ?? "",
68
- receiver: receiver ?? "",
69
- fee: (rate == null ? void 0 : rate.fee) ?? "0",
70
- provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None,
71
- orderId: (rate == null ? void 0 : rate.orderId) ?? ""
72
- }
73
- });
74
- const transactions = data;
75
- if (!transactions || transactions.length === 0) {
76
- pendingSigningRef.current = false;
77
- return;
78
- }
79
- resetSwapForm();
80
- onSubmit({
81
- transactions,
82
- provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None
83
- });
84
- } catch (error) {
85
- console.error("Error confirming rate:", error);
86
- setForceRefetchRate == null ? void 0 : setForceRefetchRate((prevState) => prevState + 1);
87
- } finally {
88
- pendingSigningRef.current = false;
89
- }
90
- };
91
- const formik$1 = formik.useFormik({
92
- initialValues,
93
- validationSchema: yup.object().shape({
94
- [
95
- "firstAmount"
96
- /* firstAmount */
97
- ]: reactjs_hooks_validation_useAmountSchema.useAmountSchema({ isMvxConnected }),
98
- [
99
- "firstToken"
100
- /* firstToken */
101
- ]: yup.object().required(),
102
- [
103
- "secondAmount"
104
- /* secondAmount */
105
- ]: reactjs_hooks_validation_useSecondAmountSchema.useSecondAmountSchema(),
106
- [
107
- "secondToken"
108
- /* secondToken */
109
- ]: yup.object().required(),
110
- [
111
- "fromChainId"
112
- /* fromChainId */
113
- ]: yup.string().required(),
114
- [
115
- "toChainId"
116
- /* toChainId */
117
- ]: yup.string().required()
118
- }),
119
- onSubmit: onSubmitFormik
120
- });
121
- const {
122
- errors,
123
- touched,
124
- handleBlur,
125
- handleSubmit,
126
- handleChange,
127
- setFieldValue,
128
- setFieldTouched
129
- } = formik$1;
130
- React.useEffect(() => {
131
- setFieldValue("firstToken", firstToken, true);
132
- }, [firstToken]);
133
- React.useEffect(() => {
134
- setFieldValue("secondToken", secondToken, true);
135
- }, [secondToken]);
136
- React.useEffect(() => {
137
- setFieldValue("fromChainId", fromChainId, true);
138
- }, [fromChainId]);
139
- React.useEffect(() => {
140
- setFieldValue("toChainId", toChainId, true);
141
- }, [toChainId]);
142
- const secondAmountError = "secondAmount" in errors && "secondAmount" in touched ? errors.secondAmount : void 0;
143
- const firstAmountError = "firstAmount" in errors && "firstAmount" in touched ? errors.firstAmount : void 0;
144
- const fromChainError = "fromChainId" in errors && "fromChainId" in touched ? errors.fromChainId : void 0;
145
- return {
146
- formik: formik$1,
147
- errors,
148
- touched,
149
- firstToken,
150
- secondToken,
151
- firstAmountError,
152
- secondAmountError,
153
- fromChainError,
154
- handleBlur,
155
- handleChange,
156
- handleSubmit,
157
- setFieldValue,
158
- resetSwapForm,
159
- setFieldTouched
160
- };
161
- };
162
- exports.BridgeFormikValuesEnum = BridgeFormikValuesEnum;
163
- exports.useBridgeFormik = useBridgeFormik;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("formik"),s=require("react"),u=require("yup"),x=require("./validation/useAmountSchema.js"),R=require("./validation/useSecondAmountSchema.js"),$=require("../../api/confirmRate.js"),z=require("../../helpers/assertRateConfirmationMatchesIntent.js"),D=require("../../helpers/getApiURL.js"),q=require("../../types/providerType.js"),G=require("../context/useWeb3App.js");var T=(o=>(o.firstToken="firstToken",o.firstAmount="firstAmount",o.secondToken="secondToken",o.secondAmount="secondAmount",o.fromChainId="fromChainId",o.toChainId="toChainId",o))(T||{});const H=({sender:o,receiver:b,firstToken:f,firstAmount:m,secondToken:h,secondAmount:p,fromChainId:I,toChainId:A,setForceRefetchRate:C,rate:n,onSubmit:g,isMvxConnected:_})=>{const d=s.useRef(),{nativeAuthToken:y}=G.useWeb3App(),j={firstAmount:"",secondAmount:"",fromChainId:I??"",toChainId:A??""},S=()=>{c.setTouched({},!1),c.setErrors({}),r("firstAmount",""),r("secondAmount","")},E=async i=>{var k,v;if(!d.current){d.current=!0;try{const{data:l}=await $.confirmRate({url:D.getApiURL(),nativeAuthToken:y??"",body:{tokenIn:((k=i.firstToken)==null?void 0:k.address)??"",amountIn:(m==null?void 0:m.toString())??"",fromChainId:i.fromChainId??"",tokenOut:((v=i.secondToken)==null?void 0:v.address)??"",toChainId:i.toChainId??"",amountOut:(p==null?void 0:p.toString())??"",sender:o??"",receiver:b??"",fee:(n==null?void 0:n.fee)??"0",provider:(n==null?void 0:n.provider)??q.ProviderType.None,orderId:(n==null?void 0:n.orderId)??""}}),t=l;if(!t||t.length===0){d.current=!1;return}z.assertRateConfirmationMatchesIntent({fromChainId:i.fromChainId??"",sender:o??""},t),S(),g({transactions:t,provider:(n==null?void 0:n.provider)??q.ProviderType.None})}catch(l){console.error("Error confirming rate:",l),C==null||C(t=>t+1)}finally{d.current=!1}}},c=W.useFormik({initialValues:j,validationSchema:u.object().shape({firstAmount:x.useAmountSchema({isMvxConnected:_}),firstToken:u.object().required(),secondAmount:R.useSecondAmountSchema(),secondToken:u.object().required(),fromChainId:u.string().required(),toChainId:u.string().required()}),onSubmit:E}),{errors:e,touched:a,handleBlur:M,handleSubmit:O,handleChange:P,setFieldValue:r,setFieldTouched:w}=c;s.useEffect(()=>{r("firstToken",f,!0)},[f]),s.useEffect(()=>{r("secondToken",h,!0)},[h]),s.useEffect(()=>{r("fromChainId",I,!0)},[I]),s.useEffect(()=>{r("toChainId",A,!0)},[A]);const L="secondAmount"in e&&"secondAmount"in a?e.secondAmount:void 0,N="firstAmount"in e&&"firstAmount"in a?e.firstAmount:void 0,U="fromChainId"in e&&"fromChainId"in a?e.fromChainId:void 0;return{formik:c,errors:e,touched:a,firstToken:f,secondToken:h,firstAmountError:N,secondAmountError:L,fromChainError:U,handleBlur:M,handleChange:P,handleSubmit:O,setFieldValue:r,resetSwapForm:S,setFieldTouched:w}};exports.BridgeFormikValuesEnum=T;exports.useBridgeFormik=H;