@rabbitio/ui-kit 1.0.0-beta.64 → 1.0.0-beta.66

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 (255) hide show
  1. package/coverage/clover.xml +6325 -4201
  2. package/coverage/coverage-final.json +160 -99
  3. package/coverage/index.html +444 -189
  4. package/coverage/{rabbit-ui-kit → ui-kit}/index.html +3 -3
  5. package/coverage/{rabbit-ui-kit → ui-kit}/index.js.html +3 -3
  6. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/arrowTosca.jsx.html → ui-kit/src/assets/wrappedImages/arrowIcon.jsx.html} +8 -29
  7. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/arrowIcon.jsx.html → ui-kit/src/assets/wrappedImages/arrowTosca.jsx.html} +9 -24
  8. package/coverage/{rabbit-ui-kit → ui-kit}/src/assets/wrappedImages/arrowWhite.jsx.html +7 -25
  9. package/coverage/ui-kit/src/assets/wrappedImages/darkRectangle.jsx.html +106 -0
  10. package/coverage/{rabbit-ui-kit → ui-kit}/src/assets/wrappedImages/determinedError.jsx.html +9 -42
  11. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/successfulValidationIcon.jsx.html → ui-kit/src/assets/wrappedImages/failedValidationIcon.jsx.html} +28 -31
  12. package/coverage/{rabbit-ui-kit → ui-kit}/src/assets/wrappedImages/index.html +25 -25
  13. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/darkRectangle.jsx.html → ui-kit/src/assets/wrappedImages/infoIcon.jsx.html} +13 -19
  14. package/coverage/{rabbit-ui-kit → ui-kit}/src/assets/wrappedImages/noticeQuestionIcon.jsx.html +7 -25
  15. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/walletIcon.jsx.html → ui-kit/src/assets/wrappedImages/successfulValidationIcon.jsx.html} +23 -59
  16. package/coverage/{rabbit-ui-kit/src/assets/wrappedImages/infoIcon.jsx.html → ui-kit/src/assets/wrappedImages/walletIcon.jsx.html} +16 -16
  17. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/adapters/axiosAdapter.js.html +3 -3
  18. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/adapters/index.html +3 -3
  19. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/adapters/qrUtils.js.html +3 -3
  20. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/amountUtils.js.html +44 -308
  21. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/errorUtils.js.html +3 -3
  22. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/external-apis/apiGroups.js.html +3 -3
  23. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/external-apis/index.html +14 -14
  24. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/external-apis/ipAddressProviders.js.html +31 -178
  25. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/fiatCurrenciesService.js.html +12 -36
  26. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/index.html +20 -20
  27. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/models/blockchain.js.html +3 -3
  28. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/models/coin.js.html +10 -22
  29. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/models/index.html +13 -13
  30. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/models/protocol.js.html +3 -3
  31. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/cache.js.html +23 -101
  32. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/emailAPI.js.html +9 -15
  33. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/index.html +19 -19
  34. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/logging/index.html +9 -9
  35. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/logging/logger.js.html +14 -35
  36. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/logging/logsStorage.js.html +5 -5
  37. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/postponeExecution.js.html +3 -3
  38. package/coverage/{rabbit-ui-kit → ui-kit}/src/common/utils/safeStringify.js.html +29 -29
  39. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/AssetIcon/AssetIcon.jsx.html +11 -41
  40. package/coverage/ui-kit/src/components/atoms/AssetIcon/index.html +116 -0
  41. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/AssetSelection/AssetSelection.jsx.html +9 -33
  42. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/AssetSelection/index.html +7 -7
  43. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +8 -38
  44. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/BackgroundTitle/index.html +7 -7
  45. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/InformationMessage/InformationMessage.jsx.html +8 -38
  46. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/InformationMessage/index.html +7 -7
  47. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Input/Input.jsx.html +15 -63
  48. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Input/index.html +7 -7
  49. package/coverage/ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +196 -0
  50. package/coverage/{rabbit-ui-kit/src/components/atoms/RateSelector → ui-kit/src/components/atoms/LoadingDots}/index.html +4 -4
  51. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/NoticeIcon/NoticeIcon.jsx.html +10 -40
  52. package/coverage/{rabbit-ui-kit/src/components/atoms/AssetIcon → ui-kit/src/components/atoms/NoticeIcon}/index.html +4 -4
  53. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/QrCode/QrCode.jsx.html +8 -26
  54. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/QrCode/index.html +7 -7
  55. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/RateSelector/RateSelector.jsx.html +10 -34
  56. package/coverage/ui-kit/src/components/atoms/RateSelector/index.html +116 -0
  57. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/SupportChat/SupportChat.jsx.html +7 -22
  58. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/SupportChat/index.html +7 -7
  59. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Textarea/Textarea.jsx.html +17 -53
  60. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Textarea/index.html +7 -7
  61. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/TitleBox/TitleBox.jsx.html +13 -82
  62. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/TitleBox/index.html +7 -7
  63. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Tooltip/Tooltip.jsx.html +12 -18
  64. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Tooltip/index.html +7 -7
  65. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +12 -30
  66. package/coverage/{rabbit-ui-kit/src/components/atoms/NoticeIcon → ui-kit/src/components/atoms/TwoLinesOfText}/index.html +4 -4
  67. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Validation/Validation.jsx.html +19 -13
  68. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/Validation/index.html +7 -7
  69. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/Button/Button.jsx.html +23 -113
  70. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/Button/index.html +7 -7
  71. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/Close/Close.jsx.html +9 -27
  72. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/Close/index.html +7 -7
  73. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/LinkButton/LinkButton.jsx.html +11 -38
  74. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/LinkButton/index.html +7 -7
  75. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +13 -67
  76. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/atoms/buttons/RadioButtonWithText/index.html +7 -7
  77. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/hooks/index.html +7 -7
  78. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/hooks/useCallHandlingErrors.js.html +7 -19
  79. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/hooks/useReferredState.js.html +4 -4
  80. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/AmountInput/AmountInput.jsx.html +56 -407
  81. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/AmountInput/index.html +7 -7
  82. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/CoinPicker/CoinPicker.jsx.html +67 -466
  83. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/CoinPicker/index.html +7 -7
  84. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +7 -22
  85. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/LineWithIconLink/index.html +7 -7
  86. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +3 -3
  87. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/molecules/TitledLineWithIconLink/index.html +3 -3
  88. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +9 -15
  89. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/CoinPickerDialogStep/index.html +7 -7
  90. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/Dialog.jsx.html +44 -194
  91. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +3 -3
  92. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/DialogButtons/index.html +3 -3
  93. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +63 -525
  94. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/DialogStep/index.html +7 -7
  95. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/Dialog/index.html +7 -7
  96. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/SwapForm/SwapForm.jsx.html +145 -670
  97. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/organisms/SwapForm/index.html +7 -7
  98. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +3 -3
  99. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/templates/DeterminedErrorDialogStep/index.html +3 -3
  100. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/utils/index.html +20 -20
  101. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/utils/inputValueProviders.js.html +11 -35
  102. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/utils/textUtils.js.html +3 -3
  103. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/utils/uiUtils.js.html +7 -13
  104. package/coverage/{rabbit-ui-kit → ui-kit}/src/components/utils/urlQueryUtils.js.html +18 -93
  105. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/Close/close.jsx.html +3 -3
  106. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/Close/index.html +3 -3
  107. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/LinkButton/index.html +3 -3
  108. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/LinkButton/linkButton.jsx.html +3 -3
  109. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/Tooltip/index.html +3 -3
  110. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/atoms/Tooltip/tooltip.jsx.html +3 -3
  111. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/globalConstants.jsx.html +7 -10
  112. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/index.html +7 -7
  113. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/organisms/dialog/DialogStep/dialogStep.js.html +3 -3
  114. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/organisms/dialog/DialogStep/index.html +3 -3
  115. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/organisms/dialog/dialog.js.html +3 -3
  116. package/coverage/{rabbit-ui-kit → ui-kit}/src/constants/organisms/dialog/index.html +3 -3
  117. package/coverage/{rabbit-ui-kit → ui-kit}/src/index.html +7 -7
  118. package/coverage/{rabbit-ui-kit → ui-kit}/src/index.js.html +8 -26
  119. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +30 -222
  120. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +24 -147
  121. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/cancelProcessing.js.html +3 -3
  122. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +19 -103
  123. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/externalApiProvider.js.html +3 -3
  124. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +11 -23
  125. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/index.html +38 -38
  126. package/coverage/{rabbit-ui-kit → ui-kit}/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +53 -305
  127. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/index.html +24 -24
  128. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapProvider.js.html +10 -28
  129. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +277 -1009
  130. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/baseSwapCreationInfo.js.html +3 -3
  131. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwap.js.html +3 -3
  132. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwapWithFiatData.js.html +9 -27
  133. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/index.html +13 -13
  134. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/index.html +7 -7
  135. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/publicSwapService.js.html +53 -374
  136. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/index.html +13 -13
  137. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/swapUtils.js.html +32 -179
  138. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/BackgroundTitle.stories.jsx.html +3 -3
  139. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LinesOfText.stories.jsx.html +3 -3
  140. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LoadingDots.stories.jsx.html +3 -3
  141. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/QrCode.stories.jsx.html +3 -3
  142. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/RateSelector.stories.jsx.html +3 -3
  143. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/Validation.stories.jsx.html +3 -3
  144. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Button.stories.jsx.html +3 -3
  145. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Close.stories.jsx.html +3 -3
  146. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/LinkButton.stories.jsx.html +3 -3
  147. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/index.html +3 -3
  148. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/index.html +3 -3
  149. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/LineWithIconLink.stories.jsx.html +3 -3
  150. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/TitledLineWithIconLink.stories.jsx.html +3 -3
  151. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/index.html +3 -3
  152. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/Dialog.stories.jsx.html +3 -3
  153. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +3 -3
  154. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/index.html +3 -3
  155. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +3 -3
  156. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/index.html +3 -3
  157. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/index.html +3 -3
  158. package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/exampleContent.jsx.html +3 -3
  159. package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/index.html +3 -3
  160. package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +3 -3
  161. package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/index.html +3 -3
  162. package/dist/index.cjs +65 -49
  163. package/dist/index.cjs.map +1 -1
  164. package/dist/index.css +5 -2
  165. package/dist/index.css.map +1 -1
  166. package/dist/index.modern.js +43 -28
  167. package/dist/index.modern.js.map +1 -1
  168. package/dist/index.module.js +65 -49
  169. package/dist/index.module.js.map +1 -1
  170. package/dist/index.umd.js +65 -49
  171. package/dist/index.umd.js.map +1 -1
  172. package/package.json +5 -3
  173. package/src/assets/wrappedImages/arrowIcon.jsx +1 -7
  174. package/src/assets/wrappedImages/arrowTosca.jsx +1 -7
  175. package/src/assets/wrappedImages/arrowWhite.jsx +1 -7
  176. package/src/assets/wrappedImages/darkRectangle.jsx +2 -13
  177. package/src/assets/wrappedImages/determinedError.jsx +2 -13
  178. package/src/assets/wrappedImages/failedValidationIcon.jsx +2 -16
  179. package/src/assets/wrappedImages/infoIcon.jsx +1 -7
  180. package/src/assets/wrappedImages/noticeQuestionIcon.jsx +1 -7
  181. package/src/assets/wrappedImages/successfulValidationIcon.jsx +2 -16
  182. package/src/assets/wrappedImages/walletIcon.jsx +3 -19
  183. package/src/common/amountUtils.js +36 -124
  184. package/src/common/external-apis/ipAddressProviders.js +22 -71
  185. package/src/common/fiatCurrenciesService.js +4 -12
  186. package/src/common/models/coin.js +2 -6
  187. package/src/common/tests/amountUtils/composeRateText.test.js +12 -69
  188. package/src/common/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +1 -3
  189. package/src/common/utils/cache.js +10 -36
  190. package/src/common/utils/emailAPI.js +1 -3
  191. package/src/common/utils/logging/logger.js +5 -12
  192. package/src/components/atoms/AssetIcon/AssetIcon.jsx +4 -14
  193. package/src/components/atoms/AssetSelection/AssetSelection.jsx +3 -11
  194. package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +2 -12
  195. package/src/components/atoms/InformationMessage/InformationMessage.jsx +2 -12
  196. package/src/components/atoms/InformationMessage/information-message.module.scss +4 -2
  197. package/src/components/atoms/Input/Input.jsx +9 -25
  198. package/src/components/atoms/LoadingDots/LoadingDots.jsx +8 -28
  199. package/src/components/atoms/NoticeIcon/NoticeIcon.jsx +4 -14
  200. package/src/components/atoms/QrCode/QrCode.jsx +2 -8
  201. package/src/components/atoms/RateSelector/RateSelector.jsx +4 -12
  202. package/src/components/atoms/SupportChat/SupportChat.jsx +1 -6
  203. package/src/components/atoms/Textarea/Textarea.jsx +11 -23
  204. package/src/components/atoms/TitleBox/TitleBox.jsx +7 -30
  205. package/src/components/atoms/TitleBox/title-box.module.scss +2 -0
  206. package/src/components/atoms/Tooltip/Tooltip.jsx +6 -8
  207. package/src/components/atoms/TwoLinesOfText/LinesOfText.jsx +5 -11
  208. package/src/components/atoms/Validation/Validation.jsx +9 -7
  209. package/src/components/atoms/buttons/Button/Button.jsx +17 -47
  210. package/src/components/atoms/buttons/Close/Close.jsx +3 -9
  211. package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +5 -14
  212. package/src/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +7 -25
  213. package/src/components/hooks/useCallHandlingErrors.js +1 -5
  214. package/src/components/hooks/useReferredState.js +1 -1
  215. package/src/components/molecules/AmountInput/AmountInput.jsx +50 -167
  216. package/src/components/molecules/CoinPicker/CoinPicker.jsx +61 -194
  217. package/src/components/molecules/CoinPicker/coin-picker.module.scss +1 -4
  218. package/src/components/molecules/LineWithIconLink/LineWithIconLink.jsx +1 -6
  219. package/src/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +3 -5
  220. package/src/components/organisms/Dialog/Dialog.jsx +38 -88
  221. package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +57 -211
  222. package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +2 -4
  223. package/src/components/organisms/SwapForm/SwapForm.jsx +139 -314
  224. package/src/components/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +5 -12
  225. package/src/components/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +3 -9
  226. package/src/components/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +11 -51
  227. package/src/components/utils/inputValueProviders.js +3 -11
  228. package/src/components/utils/uiUtils.js +1 -3
  229. package/src/components/utils/urlQueryUtils.js +10 -35
  230. package/src/constants/globalConstants.jsx +1 -2
  231. package/src/index.js +2 -8
  232. package/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js +22 -86
  233. package/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js +15 -56
  234. package/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js +11 -39
  235. package/src/robustExteranlApiCallerService/externalServicesStatsCollector.js +3 -7
  236. package/src/robustExteranlApiCallerService/robustExternalAPICallerService.js +45 -129
  237. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +76 -330
  238. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +57 -270
  239. package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +3 -15
  240. package/src/swaps-lib/external-apis/swapProvider.js +1 -7
  241. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +117 -361
  242. package/src/swaps-lib/models/existingSwapWithFiatData.js +1 -7
  243. package/src/swaps-lib/services/publicSwapService.js +47 -154
  244. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +33 -118
  245. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +23 -85
  246. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getAllSupportedCurrencies.test.js +4 -14
  247. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getDepositCurrencies.test.js +3 -9
  248. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +148 -460
  249. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getWithdrawalCurrencies.test.js +5 -11
  250. package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +2 -10
  251. package/src/swaps-lib/utils/swapUtils.js +24 -73
  252. package/coverage/rabbit-ui-kit/src/assets/wrappedImages/failedValidationIcon.jsx.html +0 -244
  253. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/LoadingDots.jsx.html +0 -256
  254. package/coverage/rabbit-ui-kit/src/components/atoms/LoadingDots/index.html +0 -116
  255. package/coverage/rabbit-ui-kit/src/components/atoms/TwoLinesOfText/index.html +0 -116
@@ -14,12 +14,7 @@ import { FALLBACK_ASSET_ICON_URL } from "../../constants/globalConstants.jsx";
14
14
  export const BANNED_PARTNERS = ["stealthex", "changee", "coincraddle"];
15
15
 
16
16
  export class SwapspaceSwapProvider extends SwapProvider {
17
- constructor(
18
- apiKeysProxyUrl,
19
- cache,
20
- customCoinBuilder = (coin, network) => null,
21
- useRestrictedCoinsSet = true
22
- ) {
17
+ constructor(apiKeysProxyUrl, cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
23
18
  super();
24
19
  this._supportedCoins = [];
25
20
  this._URL = `${apiKeysProxyUrl}`;
@@ -39,15 +34,10 @@ export class SwapspaceSwapProvider extends SwapProvider {
39
34
  const loggerSource = "getDepositCurrencies";
40
35
  try {
41
36
  await this._fetchSupportedCurrenciesIfNeeded();
42
- Logger.log(
43
- `We have ${this._supportedCoins?.length} supported coins, getting depositable`,
44
- loggerSource
45
- );
37
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting depositable`, loggerSource);
46
38
  return {
47
39
  result: true,
48
- coins: this._supportedCoins
49
- .filter((item) => item.deposit)
50
- .map((item) => item.coin),
40
+ coins: this._supportedCoins.filter(item => item.deposit).map(item => item.coin),
51
41
  };
52
42
  } catch (e) {
53
43
  if (e?.response?.status === 429) {
@@ -64,13 +54,10 @@ export class SwapspaceSwapProvider extends SwapProvider {
64
54
  const loggerSource = "getAllSupportedCurrencies";
65
55
  try {
66
56
  await this._fetchSupportedCurrenciesIfNeeded();
67
- Logger.log(
68
- `We have ${this._supportedCoins?.length} supported coins returning`,
69
- loggerSource
70
- );
57
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins returning`, loggerSource);
71
58
  return {
72
59
  result: true,
73
- coins: this._supportedCoins.map((item) => item.coin),
60
+ coins: this._supportedCoins.map(item => item.coin),
74
61
  };
75
62
  } catch (e) {
76
63
  if (e?.response?.status === 429) {
@@ -87,20 +74,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
87
74
  const loggerSource = "getWithdrawalCurrencies";
88
75
  try {
89
76
  await this._fetchSupportedCurrenciesIfNeeded();
90
- Logger.log(
91
- `We have ${this._supportedCoins?.length} supported coins, getting withdrawable`,
92
- loggerSource
93
- );
77
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting withdrawable`, loggerSource);
94
78
  return {
95
79
  result: true,
96
80
  coins: this._supportedCoins
97
81
  .filter(
98
- (item) =>
99
- item.withdrawal &&
100
- (!exceptCurrency ||
101
- item.coin?.ticker !== exceptCurrency?.ticker)
82
+ item => item.withdrawal && (!exceptCurrency || item.coin?.ticker !== exceptCurrency?.ticker)
102
83
  )
103
- .map((item) => item.coin),
84
+ .map(item => item.coin),
104
85
  };
105
86
  } catch (e) {
106
87
  if (e?.response?.status === 429) {
@@ -122,14 +103,11 @@ export class SwapspaceSwapProvider extends SwapProvider {
122
103
  try {
123
104
  let coin = coinOrTicker;
124
105
  if (!(coinOrTicker instanceof Coin)) {
125
- coin = this._supportedCoins.find(
126
- (i) => i.coin.ticker === coinOrTicker
127
- )?.coin;
106
+ coin = this._supportedCoins.find(i => i.coin.ticker === coinOrTicker)?.coin;
128
107
  }
129
108
  return (
130
- this._supportedCoins.find(
131
- (item) => item.coin?.ticker === coin?.ticker
132
- )?.iconURL ?? FALLBACK_ASSET_ICON_URL
109
+ this._supportedCoins.find(item => item.coin?.ticker === coin?.ticker)?.iconURL ??
110
+ FALLBACK_ASSET_ICON_URL
133
111
  );
134
112
  } catch (e) {
135
113
  improveAndRethrow(e, loggerSource);
@@ -140,22 +118,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
140
118
  const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
141
119
  try {
142
120
  if (!this._supportedCoins?.length) {
143
- const rawResponse = await axios.get(
144
- `${this._URL}/api/v2/currencies`
145
- );
146
- Logger.log(
147
- `Retrieved ${rawResponse?.data?.length}`,
148
- loggerSource
149
- );
121
+ const rawResponse = await axios.get(`${this._URL}/api/v2/currencies`);
122
+ Logger.log(`Retrieved ${rawResponse?.data?.length}`, loggerSource);
150
123
  let allowedCoins = rawResponse?.data ?? [];
151
124
  Logger.log(`Allowed cnt ${allowedCoins.length}`, loggerSource);
152
125
 
153
126
  this._supportedCoins = allowedCoins
154
- .map((item) => {
155
- let coin = this._customCoinBuilder(
156
- item.code,
157
- item.network
158
- );
127
+ .map(item => {
128
+ let coin = this._customCoinBuilder(item.code, item.network);
159
129
  if (!coin && !this.useRestrictedCoinsSet) {
160
130
  /** Building coin object for coin that isn't supported OOB in Rabbit.
161
131
  * We are doing this way to be able to use extended coins set for swaps.
@@ -179,9 +149,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
179
149
  // Rolling back to original name if our processing leads in empty name
180
150
  name = item.name;
181
151
  }
182
- const ticker = `${code}${
183
- code === network ? "" : network
184
- }`;
152
+ const ticker = `${code}${code === network ? "" : network}`;
185
153
  const defaultDecimalPlacesForCoinNotSupportedOOB = 8;
186
154
  const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
187
155
  coin = new Coin(
@@ -239,11 +207,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
239
207
  this._supportedCoins.sort((i1, i2) => {
240
208
  if (i1.isPopular && !i2.isPopular) return -1;
241
209
  if (i2.isPopular && !i1.isPopular) return 1;
242
- return i1.coin.ticker > i2.coin.ticker
243
- ? 1
244
- : i1.coin.ticker < i2.coin.ticker
245
- ? -1
246
- : 0;
210
+ return i1.coin.ticker > i2.coin.ticker ? 1 : i1.coin.ticker < i2.coin.ticker ? -1 : 0;
247
211
  });
248
212
  }
249
213
 
@@ -255,15 +219,11 @@ export class SwapspaceSwapProvider extends SwapProvider {
255
219
  await this._fetchSupportedCurrenciesIfNeeded();
256
220
 
257
221
  // Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
258
- const usdtTrc20 = this._supportedCoins.find(
259
- (i) => i.coin.ticker === "USDTTRC20"
260
- )?.coin;
222
+ const usdtTrc20 = this._supportedCoins.find(i => i.coin.ticker === "USDTTRC20")?.coin;
261
223
  if (!usdtTrc20) {
262
224
  return { result: false };
263
225
  }
264
- const cached = this._cache.get(
265
- "swapspace_usdt_rate_" + coin.ticker
266
- );
226
+ const cached = this._cache.get("swapspace_usdt_rate_" + coin.ticker);
267
227
  if (cached != null) {
268
228
  return {
269
229
  result: true,
@@ -271,27 +231,15 @@ export class SwapspaceSwapProvider extends SwapProvider {
271
231
  };
272
232
  }
273
233
 
274
- Logger.log(
275
- "Loading USDT->coin rate as not found in cache:",
276
- coin?.ticker
277
- );
278
- const result = await this.getSwapInfo(
279
- usdtTrc20,
280
- coin,
281
- "5000",
282
- false
283
- );
234
+ Logger.log("Loading USDT->coin rate as not found in cache:", coin?.ticker);
235
+ const result = await this.getSwapInfo(usdtTrc20, coin, "5000", false);
284
236
  if (!result.result) {
285
237
  return { result: false };
286
238
  }
287
239
 
288
240
  // This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
289
241
  const standardSwapspaceFeeMultiplier = 1.004; // fee is usually 0.4%
290
- const rate = BigNumber(1)
291
- .div(
292
- BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)
293
- )
294
- .toString();
242
+ const rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
295
243
  this._cache.put(
296
244
  "swapspace_usdt_rate_" + coin.ticker,
297
245
  rate,
@@ -308,22 +256,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
308
256
 
309
257
  getCoinByTickerIfPresent(ticker) {
310
258
  try {
311
- const item = this._supportedCoins.find(
312
- (i) => i.coin.ticker === ticker
313
- );
259
+ const item = this._supportedCoins.find(i => i.coin.ticker === ticker);
314
260
  return item?.coin ?? null;
315
261
  } catch (e) {
316
262
  improveAndRethrow(e, "getCoinByTickerIfPresent");
317
263
  }
318
264
  }
319
265
 
320
- async getSwapInfo(
321
- fromCoin,
322
- toCoin,
323
- amountCoins,
324
- fixed = false,
325
- fromCoinToUsdRate = null
326
- ) {
266
+ async getSwapInfo(fromCoin, toCoin, amountCoins, fixed = false, fromCoinToUsdRate = null) {
327
267
  const loggerSource = "getSwapInfo";
328
268
  try {
329
269
  if (
@@ -334,31 +274,19 @@ export class SwapspaceSwapProvider extends SwapProvider {
334
274
  (fixed !== null && typeof fixed !== "boolean")
335
275
  ) {
336
276
  throw new Error(
337
- `Wrong input params: ${amountCoins} ${fromCoin.ticker} -> ${
338
- toCoin.ticker
339
- }, ${fromCoin instanceof Coin}, ${
340
- toCoin instanceof Coin
341
- }, ${typeof fixed} ${fixed}`
277
+ `Wrong input params: ${amountCoins} ${fromCoin.ticker} -> ${toCoin.ticker}, ${
278
+ fromCoin instanceof Coin
279
+ }, ${toCoin instanceof Coin}, ${typeof fixed} ${fixed}`
342
280
  );
343
281
  }
344
- const fromCoinSwapspaceDetails = this._supportedCoins.find(
345
- (i) => i.coin?.ticker === fromCoin?.ticker
346
- );
347
- const toCoinSwapspaceDetails = this._supportedCoins.find(
348
- (i) => i.coin?.ticker === toCoin?.ticker
349
- );
282
+ const fromCoinSwapspaceDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
283
+ const toCoinSwapspaceDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
350
284
  if (!fromCoinSwapspaceDetails || !toCoinSwapspaceDetails) {
351
285
  throw new Error(
352
- "Failed to find swapspace coin details for: " +
353
- fromCoin.ticker +
354
- " -> " +
355
- toCoin.ticker
286
+ "Failed to find swapspace coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker
356
287
  );
357
288
  }
358
- if (
359
- !fromCoinSwapspaceDetails.deposit ||
360
- !toCoinSwapspaceDetails.withdrawal
361
- ) {
289
+ if (!fromCoinSwapspaceDetails.deposit || !toCoinSwapspaceDetails.withdrawal) {
362
290
  return {
363
291
  result: false,
364
292
  reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
@@ -371,53 +299,34 @@ export class SwapspaceSwapProvider extends SwapProvider {
371
299
  const response = await axios.get(
372
300
  `${this._URL}/api/v2/amounts?fromCurrency=${fromCoinSwapspaceDetails.code}&fromNetwork=${fromCoinSwapspaceDetails.network}&toNetwork=${toCoinSwapspaceDetails.network}&toCurrency=${toCoinSwapspaceDetails.code}&amount=${amountCoins}&estimated=false`
373
301
  );
374
- Logger.log(
375
- `Retrieved ${response?.data?.length} options`,
376
- loggerSource
377
- );
302
+ Logger.log(`Retrieved ${response?.data?.length} options`, loggerSource);
378
303
  const options = Array.isArray(response.data) ? response.data : [];
379
- let exchangesSupportingThePairDespiteFixedOrFloating =
380
- options.filter(
381
- (exchange) =>
382
- exchange?.exists &&
383
- !BANNED_PARTNERS.find(
384
- (bannedPartner) =>
385
- bannedPartner === exchange?.partner
386
- ) &&
387
- (exchange?.fixed === false ||
388
- exchange?.fixed === true) &&
389
- (exchange.min === 0 ||
390
- exchange.max === 0 ||
391
- exchange.max > exchange.min ||
392
- ((typeof exchange.min !== "number" ||
393
- typeof exchange.max !== "number") &&
394
- exchange.toAmount > 0))
395
- );
396
- let exchangesSupportingThePair =
397
- exchangesSupportingThePairDespiteFixedOrFloating;
304
+ // TODO: [feature, high] remove if possible over-engineering about toAmount = 0 options treating as supported but not available. task_id=404ae30d9a7743238af3cc0d3bae9239
305
+ let exchangesSupportingThePairDespiteFixedOrFloating = options.filter(
306
+ exchange =>
307
+ exchange?.exists &&
308
+ !BANNED_PARTNERS.find(bannedPartner => bannedPartner === exchange?.partner) &&
309
+ (exchange?.fixed === false || exchange?.fixed === true) &&
310
+ typeof exchange.min === "number" &&
311
+ typeof exchange.max === "number" &&
312
+ typeof exchange.toAmount === "number" &&
313
+ exchange.toAmount > 0 &&
314
+ (exchange.min === 0 || exchange.max === 0 || exchange.max > exchange.min)
315
+ );
316
+ let exchangesSupportingThePair = exchangesSupportingThePairDespiteFixedOrFloating;
398
317
  if (fixed != null) {
399
- exchangesSupportingThePair =
400
- exchangesSupportingThePairDespiteFixedOrFloating.filter(
401
- (option) => option.fixed === fixed
402
- );
318
+ exchangesSupportingThePair = exchangesSupportingThePairDespiteFixedOrFloating.filter(
319
+ option => option.fixed === fixed
320
+ );
403
321
  }
404
- Logger.log(
405
- `${exchangesSupportingThePair?.length} of them have exist=true`,
406
- loggerSource
407
- );
322
+ Logger.log(`${exchangesSupportingThePair?.length} of them have exist=true`, loggerSource);
408
323
  if (exchangesSupportingThePair.length === 0) {
409
- if (
410
- exchangesSupportingThePairDespiteFixedOrFloating.length >
411
- 0 &&
412
- fixed !== null
413
- ) {
324
+ if (exchangesSupportingThePairDespiteFixedOrFloating.length > 0 && fixed !== null) {
414
325
  return {
415
326
  result: false,
416
327
  reason: fixed
417
- ? SwapProvider.NO_SWAPS_REASONS
418
- .NO_FIXED_BUT_HAVE_FLOATING
419
- : SwapProvider.NO_SWAPS_REASONS
420
- .NO_FLOATING_BUT_HAVE_FIXED,
328
+ ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING
329
+ : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED,
421
330
  };
422
331
  }
423
332
  return {
@@ -426,120 +335,67 @@ export class SwapspaceSwapProvider extends SwapProvider {
426
335
  };
427
336
  }
428
337
  const availableExchanges = exchangesSupportingThePair.filter(
429
- (exchange) =>
430
- typeof exchange?.toAmount === "number" &&
431
- exchange.toAmount > 0
432
- );
433
- Logger.log(
434
- `Available (having amountTo): ${safeStringify(
435
- availableExchanges
436
- )}`,
437
- loggerSource
338
+ exchange => typeof exchange?.toAmount === "number" && exchange.toAmount > 0
438
339
  );
340
+ Logger.log(`Available (having amountTo): ${safeStringify(availableExchanges)}`, loggerSource);
439
341
  // min=0 or max=0 means there is no limit for the partner
440
342
  let smallestMin = null;
441
- if (
442
- exchangesSupportingThePair.find((ex) =>
443
- BigNumber(ex.min).isZero()
444
- ) == null
445
- ) {
343
+ if (exchangesSupportingThePair.find(ex => BigNumber(ex.min).isZero()) == null) {
446
344
  smallestMin = exchangesSupportingThePair.reduce((prev, cur) => {
447
- if (
448
- typeof cur.min === "number" &&
449
- (prev === null || BigNumber(cur.min).lt(prev))
450
- )
345
+ if (typeof cur.min === "number" && (prev === null || BigNumber(cur.min).lt(prev)))
451
346
  return BigNumber(cur.min);
452
347
  return prev;
453
348
  }, null);
454
349
  }
455
350
  let greatestMax = null;
456
- if (
457
- exchangesSupportingThePair.find((ex) =>
458
- BigNumber(ex.max).isZero()
459
- ) == null
460
- ) {
351
+ if (exchangesSupportingThePair.find(ex => BigNumber(ex.max).isZero()) == null) {
461
352
  greatestMax = exchangesSupportingThePair.reduce((prev, cur) => {
462
- if (
463
- typeof cur.max === "number" &&
464
- (prev === null || BigNumber(cur.max).gt(prev))
465
- )
353
+ if (typeof cur.max === "number" && (prev === null || BigNumber(cur.max).gt(prev)))
466
354
  return BigNumber(cur.max);
467
355
  return prev;
468
356
  }, null);
469
357
  }
470
358
  let extraCoinsToFitMinMax = "0";
471
- if (
472
- typeof fromCoinToUsdRate === "string" &&
473
- BigNumber(fromCoinToUsdRate).gt("0")
474
- ) {
359
+ if (typeof fromCoinToUsdRate === "string" && BigNumber(fromCoinToUsdRate).gt("0")) {
475
360
  const extraUsdToFitMinMax = BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
476
- extraCoinsToFitMinMax = AmountUtils.trim(
477
- extraUsdToFitMinMax.div(fromCoinToUsdRate),
478
- fromCoin.digits
479
- );
361
+ extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
480
362
  }
481
363
  if (smallestMin instanceof BigNumber) {
482
- smallestMin = AmountUtils.trim(
483
- smallestMin.plus(extraCoinsToFitMinMax),
484
- fromCoin.digits
485
- );
364
+ smallestMin = AmountUtils.trim(smallestMin.plus(extraCoinsToFitMinMax), fromCoin.digits);
486
365
  }
487
366
  if (greatestMax instanceof BigNumber) {
488
367
  if (greatestMax > extraCoinsToFitMinMax) {
489
- greatestMax = AmountUtils.trim(
490
- greatestMax.minus(extraCoinsToFitMinMax),
491
- fromCoin.digits
492
- );
368
+ greatestMax = AmountUtils.trim(greatestMax.minus(extraCoinsToFitMinMax), fromCoin.digits);
493
369
  } else {
494
370
  greatestMax = "0";
495
371
  }
496
372
  }
497
373
 
498
374
  if (availableExchanges.length) {
499
- const sorted = availableExchanges.sort(
500
- (op1, op2) => op2.toAmount - op1.toAmount
501
- );
375
+ const sorted = availableExchanges.sort((op1, op2) => op2.toAmount - op1.toAmount);
502
376
  const bestOpt = sorted[0];
503
- Logger.log(
504
- `Returning first option after sorting: ${safeStringify(
505
- bestOpt
506
- )}`,
507
- loggerSource
508
- );
377
+ Logger.log(`Returning first option after sorting: ${safeStringify(bestOpt)}`, loggerSource);
509
378
  let max = null;
510
379
  let min = null;
511
380
  if (extraCoinsToFitMinMax != null) {
512
381
  if (typeof bestOpt.max === "number" && bestOpt.max !== 0) {
513
- max = BigNumber(bestOpt.max).minus(
514
- extraCoinsToFitMinMax
515
- );
516
- max = AmountUtils.trim(
517
- max.lt(0) ? "0" : max,
518
- fromCoin.digits
519
- );
382
+ max = BigNumber(bestOpt.max).minus(extraCoinsToFitMinMax);
383
+ max = AmountUtils.trim(max.lt(0) ? "0" : max, fromCoin.digits);
520
384
  }
521
385
  if (typeof bestOpt.min === "number" && bestOpt.min !== 0) {
522
- min = AmountUtils.trim(
523
- BigNumber(bestOpt.min).plus(extraCoinsToFitMinMax),
524
- fromCoin.digits
525
- );
386
+ min = AmountUtils.trim(BigNumber(bestOpt.min).plus(extraCoinsToFitMinMax), fromCoin.digits);
526
387
  }
527
388
  }
528
389
 
529
390
  const rate =
530
- bestOpt.toAmount && bestOpt.fromAmount
531
- ? BigNumber(bestOpt.toAmount).div(bestOpt.fromAmount)
532
- : null;
391
+ bestOpt.toAmount && bestOpt.fromAmount ? BigNumber(bestOpt.toAmount).div(bestOpt.fromAmount) : null;
533
392
  return {
534
393
  result: true,
535
394
  min: min,
536
395
  max: max,
537
396
  smallestMin: smallestMin,
538
397
  greatestMax: greatestMax,
539
- rate:
540
- rate != null
541
- ? AmountUtils.trim(rate, this._maxRateDigits)
542
- : null,
398
+ rate: rate != null ? AmountUtils.trim(rate, this._maxRateDigits) : null,
543
399
  durationMinutesRange: bestOpt.duration ?? null,
544
400
  fixed: bestOpt.fixed,
545
401
  rawSwapData: bestOpt,
@@ -556,10 +412,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
556
412
  smallestMin: smallestMin,
557
413
  greatestMax: greatestMax,
558
414
  };
559
- Logger.log(
560
- `Returning result ${safeStringify(result)}`,
561
- loggerSource
562
- );
415
+ Logger.log(`Returning result ${safeStringify(result)}`, loggerSource);
563
416
  return result;
564
417
  } catch (e) {
565
418
  if (e?.response?.status === 429) {
@@ -568,12 +421,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
568
421
  reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
569
422
  };
570
423
  }
571
- Logger.log(
572
- `Internal swapspace/rabbit error when getting swap options ${safeStringify(
573
- e
574
- )}`,
575
- loggerSource
576
- );
424
+ Logger.log(`Internal swapspace/rabbit error when getting swap options ${safeStringify(e)}`, loggerSource);
577
425
  improveAndRethrow(e, loggerSource);
578
426
  }
579
427
  }
@@ -615,23 +463,16 @@ export class SwapspaceSwapProvider extends SwapProvider {
615
463
  typeof rawSwapData?.toNetwork !== "string" ||
616
464
  typeof rawSwapData?.id !== "string" // can be just empty
617
465
  ) {
618
- throw new Error(
619
- `Invalid raw swap data: ${safeStringify(rawSwapData)}`
620
- );
466
+ throw new Error(`Invalid raw swap data: ${safeStringify(rawSwapData)}`);
621
467
  }
622
468
 
623
- const [fromCurrencyHasExtraId, toCurrencyHasExtraId] =
624
- this._supportedCoins.reduce(
625
- (prev, coinData) => [
626
- coinData.coin.ticker === fromCoin.ticker
627
- ? coinData.hasExtraId
628
- : prev[0],
629
- coinData.coin.ticker === toCoin.ticker
630
- ? coinData.hasExtraId
631
- : prev[1],
632
- ],
633
- [false, false]
634
- );
469
+ const [fromCurrencyHasExtraId, toCurrencyHasExtraId] = this._supportedCoins.reduce(
470
+ (prev, coinData) => [
471
+ coinData.coin.ticker === fromCoin.ticker ? coinData.hasExtraId : prev[0],
472
+ coinData.coin.ticker === toCoin.ticker ? coinData.hasExtraId : prev[1],
473
+ ],
474
+ [false, false]
475
+ );
635
476
  await this._fetchSupportedCurrenciesIfNeeded();
636
477
  const requestData = {
637
478
  partner: partner,
@@ -644,27 +485,16 @@ export class SwapspaceSwapProvider extends SwapProvider {
644
485
  fixed: fixed,
645
486
  extraId: toCurrencyHasExtraId ? toCurrencyExtraId ?? "" : "",
646
487
  // This param is not documented. But the refund is usually manual so this is not critical.
647
- refundExtraId: fromCurrencyHasExtraId
648
- ? refundExtraId ?? ""
649
- : "",
488
+ refundExtraId: fromCurrencyHasExtraId ? refundExtraId ?? "" : "",
650
489
  rateId: rawSwapData?.id,
651
490
  userIp: clientIpAddress,
652
491
  refund: refundAddress,
653
492
  };
654
493
 
655
- Logger.log(
656
- `Sending create request: ${safeStringify(requestData)}`,
657
- loggerSource
658
- );
659
- const response = await axios.post(
660
- `${this._URL}/api/v2/exchange`,
661
- requestData
662
- );
494
+ Logger.log(`Sending create request: ${safeStringify(requestData)}`, loggerSource);
495
+ const response = await axios.post(`${this._URL}/api/v2/exchange`, requestData);
663
496
  const result = response.data;
664
- Logger.log(
665
- `Creation result ${safeStringify(result)}`,
666
- loggerSource
667
- );
497
+ Logger.log(`Creation result ${safeStringify(result)}`, loggerSource);
668
498
 
669
499
  if (result?.id) {
670
500
  if (
@@ -679,9 +509,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
679
509
  * rate 0/null/undefined we calculate it manually */
680
510
  let rate = result.rate;
681
511
  if (typeof rate !== "number" || BigNumber(rate).isZero()) {
682
- rate = BigNumber(result?.to?.amount).div(
683
- result?.from?.amount
684
- );
512
+ rate = BigNumber(result?.to?.amount).div(result?.from?.amount);
685
513
  } else {
686
514
  rate = BigNumber(rate);
687
515
  }
@@ -690,34 +518,22 @@ export class SwapspaceSwapProvider extends SwapProvider {
690
518
  result: true,
691
519
  swapId: result?.id,
692
520
  fromCoin: fromCoin,
693
- fromAmount: AmountUtils.trim(
694
- result?.from?.amount,
695
- fromCoin.digits
696
- ),
521
+ fromAmount: AmountUtils.trim(result?.from?.amount, fromCoin.digits),
697
522
  fromAddress: result?.from?.address,
698
523
  toCoin: toCoin,
699
- toAmount: AmountUtils.trim(
700
- result?.to?.amount,
701
- toCoin.digits
702
- ),
524
+ toAmount: AmountUtils.trim(result?.to?.amount, toCoin.digits),
703
525
  toAddress: result?.to?.address,
704
526
  fromCurrencyExtraId: result?.from?.extraId ?? "",
705
527
  rate: AmountUtils.trim(rate, this._maxRateDigits),
706
528
  fixed: result.fixed,
707
529
  };
708
530
  }
709
- const errorMessage = `Swap creation succeeded but the response is wrong: ${safeStringify(
710
- response
711
- )}`;
531
+ const errorMessage = `Swap creation succeeded but the response is wrong: ${safeStringify(response)}`;
712
532
  Logger.log(errorMessage, loggerSource);
713
533
  throw new Error(errorMessage);
714
534
  } catch (e) {
715
- Logger.logError(
716
- e,
717
- loggerSource,
718
- `Failed to create swap. Error is: ${safeStringify(e)}`
719
- );
720
- const composeFailResult = (reason) => ({
535
+ Logger.logError(e, loggerSource, `Failed to create swap. Error is: ${safeStringify(e)}`);
536
+ const composeFailResult = reason => ({
721
537
  result: false,
722
538
  reason: reason,
723
539
  partner: partner,
@@ -725,13 +541,8 @@ export class SwapspaceSwapProvider extends SwapProvider {
725
541
  const status = e?.response?.status;
726
542
  const data = e?.response?.data;
727
543
  if (status === 429) {
728
- Logger.log(
729
- `Returning fail - RPS limit exceeded ${data}`,
730
- loggerSource
731
- );
732
- return composeFailResult(
733
- SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
734
- );
544
+ Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
545
+ return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
735
546
  }
736
547
  const texts422 = [
737
548
  "Pair cannot be processed by",
@@ -743,23 +554,12 @@ export class SwapspaceSwapProvider extends SwapProvider {
743
554
  if (
744
555
  typeof data === "string" &&
745
556
  ((status === 403 && data.includes(text403)) ||
746
- (status === 422 &&
747
- texts422.find((text) => data.includes(text))))
557
+ (status === 422 && texts422.find(text => data.includes(text))))
748
558
  ) {
749
- Logger.log(
750
- `Returning retriable fail: ${status} - ${data}, ${partner}`,
751
- loggerSource
752
- );
753
- return composeFailResult(
754
- SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL
755
- );
559
+ Logger.log(`Returning retriable fail: ${status} - ${data}, ${partner}`, loggerSource);
560
+ return composeFailResult(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
756
561
  }
757
- Logger.log(
758
- `Internal swapspace/rabbit error for ${partner}: ${safeStringify(
759
- e
760
- )}`,
761
- loggerSource
762
- );
562
+ Logger.log(`Internal swapspace/rabbit error for ${partner}: ${safeStringify(e)}`, loggerSource);
763
563
  improveAndRethrow(e, loggerSource);
764
564
  }
765
565
  }
@@ -795,60 +595,38 @@ export class SwapspaceSwapProvider extends SwapProvider {
795
595
  async getExistingSwapsDetailsAndStatus(swapIds) {
796
596
  const loggerSource = "getExistingSwapsDetailsAndStatus";
797
597
  try {
798
- if (swapIds.find((id) => typeof id !== "string")) {
799
- throw new Error(
800
- "Swap id is not string: " + safeStringify(swapIds)
801
- );
598
+ if (swapIds.find(id => typeof id !== "string")) {
599
+ throw new Error("Swap id is not string: " + safeStringify(swapIds));
802
600
  }
803
- const getNotFailingOn404 = async (swapId) => {
601
+ const getNotFailingOn404 = async swapId => {
804
602
  try {
805
- return await axios.get(
806
- `${this._URL}/api/v2/exchange/${swapId}`
807
- );
603
+ return await axios.get(`${this._URL}/api/v2/exchange/${swapId}`);
808
604
  } catch (error) {
809
605
  if (error?.response?.status === 404) return [];
810
606
  throw error;
811
607
  }
812
608
  };
813
- const responses = await Promise.all(
814
- swapIds.map((swapId) => getNotFailingOn404(swapId))
815
- );
609
+ const responses = await Promise.all(swapIds.map(swapId => getNotFailingOn404(swapId)));
816
610
  const wo404 = responses.flat();
817
- Logger.log(
818
- "All swaps RAW: " + JSON.stringify(wo404.map((r) => r.data)),
819
- loggerSource
820
- );
611
+ Logger.log("All swaps RAW: " + JSON.stringify(wo404.map(r => r.data)), loggerSource);
821
612
  const swaps = wo404
822
- .map((r) => r.data)
613
+ .map(r => r.data)
823
614
  .map((swap, index) => {
824
615
  const fromCoin = this._supportedCoins.find(
825
- (i) =>
826
- i.code === swap.from.code &&
827
- i.network === swap.from.network
616
+ i => i.code === swap.from.code && i.network === swap.from.network
828
617
  )?.coin;
829
618
  const toCoin = this._supportedCoins.find(
830
- (i) =>
831
- i.code === swap.to.code &&
832
- i.network === swap.to.network
619
+ i => i.code === swap.to.code && i.network === swap.to.network
833
620
  )?.coin;
834
621
  if (!fromCoin || !toCoin) {
835
622
  return []; // We skip swaps with not supported coins for now
836
623
  }
837
624
 
838
- const toUtcTimestamp = (timeStr) =>
839
- Date.parse(
840
- timeStr.match(/.+[Zz]$/) ? timeStr : `${timeStr}Z`
841
- );
625
+ const toUtcTimestamp = timeStr => Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : `${timeStr}Z`);
842
626
  const expiresAt = toUtcTimestamp(swap.timestamps.expiresAt);
843
627
  const isExpiredByTime = expiresAt < Date.now();
844
- const status = this._mapSwapspaceStatusToRabbitStatus(
845
- swap.status,
846
- isExpiredByTime
847
- );
848
- const toDigits =
849
- status === SwapProvider.SWAP_STATUSES.REFUNDED
850
- ? fromCoin.digits
851
- : toCoin.digits;
628
+ const status = this._mapSwapspaceStatusToRabbitStatus(swap.status, isExpiredByTime);
629
+ const toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
852
630
  const addressToSendCoinsToSwapspace = swap.from.address;
853
631
  return new ExistingSwap(
854
632
  swapIds[index],
@@ -876,31 +654,19 @@ export class SwapspaceSwapProvider extends SwapProvider {
876
654
  );
877
655
  })
878
656
  .flat();
879
- Logger.log(
880
- `Swap details result ${safeStringify(swaps)}`,
881
- loggerSource
882
- );
657
+ Logger.log(`Swap details result ${safeStringify(swaps)}`, loggerSource);
883
658
  return { result: true, swaps: swaps };
884
659
  } catch (e) {
885
- Logger.logError(
886
- e,
887
- loggerSource,
888
- `Failed to get swap details. Error is: ${safeStringify(e)}`
889
- );
890
- const composeFailResult = (reason) => ({
660
+ Logger.logError(e, loggerSource, `Failed to get swap details. Error is: ${safeStringify(e)}`);
661
+ const composeFailResult = reason => ({
891
662
  result: false,
892
663
  reason: reason,
893
664
  });
894
665
  const status = e?.response?.status;
895
666
  const data = e?.response?.data;
896
667
  if (status === 429) {
897
- Logger.log(
898
- `Returning fail - RPS limit exceeded ${data}`,
899
- loggerSource
900
- );
901
- return composeFailResult(
902
- SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED
903
- );
668
+ Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
669
+ return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
904
670
  }
905
671
  improveAndRethrow(e, loggerSource);
906
672
  }
@@ -908,17 +674,12 @@ export class SwapspaceSwapProvider extends SwapProvider {
908
674
 
909
675
  isAddressValidForAsset(asset, address) {
910
676
  try {
911
- const assetData = this._supportedCoins.find(
912
- (i) => i.coin?.ticker === asset?.ticker
913
- );
677
+ const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
914
678
  if (assetData) {
915
679
  let corrected = assetData.validationRegexp.trim();
680
+ corrected = corrected[0] === "/" ? corrected.slice(1) : corrected;
916
681
  corrected =
917
- corrected[0] === "/" ? corrected.slice(1) : corrected;
918
- corrected =
919
- corrected[corrected.length - 1] === "/"
920
- ? corrected.slice(0, corrected.length - 1)
921
- : corrected;
682
+ corrected[corrected.length - 1] === "/" ? corrected.slice(0, corrected.length - 1) : corrected;
922
683
  return address.match(corrected) != null;
923
684
  }
924
685
  } catch (e) {
@@ -929,14 +690,9 @@ export class SwapspaceSwapProvider extends SwapProvider {
929
690
 
930
691
  getExtraIdNameIfPresent(asset) {
931
692
  try {
932
- const assetData = this._supportedCoins.find(
933
- (i) => i.coin?.ticker === asset?.ticker
934
- );
693
+ const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
935
694
  if (assetData?.hasExtraId) {
936
- if (
937
- assetData?.extraIdName == null ||
938
- assetData?.extraIdName === ""
939
- ) {
695
+ if (assetData?.extraIdName == null || assetData?.extraIdName === "") {
940
696
  // We return some default name if the extraIdName is empty
941
697
  return "ID";
942
698
  }