@rabbitio/ui-kit 1.0.0-beta.9 → 1.0.0-beta.91

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 (369) hide show
  1. package/.gitlab-ci.yml +29 -0
  2. package/.husky/commit-msg +19 -0
  3. package/.husky/pre-push +1 -0
  4. package/CHANGELOG.md +0 -0
  5. package/README.md +27 -18
  6. package/coverage/base.css +224 -0
  7. package/coverage/block-navigation.js +87 -0
  8. package/coverage/clover.xml +16765 -0
  9. package/coverage/coverage-final.json +116 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +1001 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/rabbit-ui-kit/index.html +116 -0
  15. package/coverage/rabbit-ui-kit/index.js.html +88 -0
  16. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +148 -0
  17. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +146 -0
  18. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +169 -0
  19. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +199 -0
  20. package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +190 -0
  21. package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +131 -0
  22. package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +139 -0
  23. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +250 -0
  24. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/emailAPI.js.html +133 -0
  25. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +146 -0
  26. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +352 -0
  27. package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +94 -0
  28. package/coverage/rabbit-ui-kit/src/common-apis/index.html +116 -0
  29. package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +115 -0
  30. package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +829 -0
  31. package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +146 -0
  32. package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +100 -0
  33. package/coverage/rabbit-ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +544 -0
  34. package/coverage/rabbit-ui-kit/src/common-apis/services/index.html +116 -0
  35. package/coverage/rabbit-ui-kit/src/common-apis/utils/amountUtils.js.html +1162 -0
  36. package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +811 -0
  37. package/coverage/rabbit-ui-kit/src/common-apis/utils/errorUtils.js.html +211 -0
  38. package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +191 -0
  39. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +131 -0
  40. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +208 -0
  41. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +268 -0
  42. package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +118 -0
  43. package/coverage/rabbit-ui-kit/src/common-apis/utils/rabbitTicker.js.html +157 -0
  44. package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +235 -0
  45. package/coverage/rabbit-ui-kit/src/index.html +116 -0
  46. package/coverage/rabbit-ui-kit/src/index.js.html +376 -0
  47. package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1570 -0
  48. package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +526 -0
  49. package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +172 -0
  50. package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +310 -0
  51. package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +553 -0
  52. package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +319 -0
  53. package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +206 -0
  54. package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +997 -0
  55. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1825 -0
  56. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +161 -0
  57. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1618 -0
  58. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1819 -0
  59. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1861 -0
  60. package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +319 -0
  61. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +514 -0
  62. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +529 -0
  63. package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +176 -0
  64. package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +166 -0
  65. package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +331 -0
  66. package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +116 -0
  67. package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +1555 -0
  68. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +116 -0
  69. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +670 -0
  70. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +124 -0
  71. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +127 -0
  72. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +127 -0
  73. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +106 -0
  74. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +439 -0
  75. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +202 -0
  76. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +281 -0
  77. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +133 -0
  78. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +346 -0
  79. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +247 -0
  80. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +163 -0
  81. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +268 -0
  82. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +151 -0
  83. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +256 -0
  84. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +116 -0
  85. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +289 -0
  86. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +116 -0
  87. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +187 -0
  88. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +116 -0
  89. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +238 -0
  90. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +116 -0
  91. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +634 -0
  92. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +116 -0
  93. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +196 -0
  94. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +116 -0
  95. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +277 -0
  96. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +116 -0
  97. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +217 -0
  98. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +116 -0
  99. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +175 -0
  100. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +116 -0
  101. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +217 -0
  102. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +116 -0
  103. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +529 -0
  104. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +116 -0
  105. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +508 -0
  106. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +116 -0
  107. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +316 -0
  108. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +116 -0
  109. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +313 -0
  110. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +116 -0
  111. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +202 -0
  112. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +116 -0
  113. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +712 -0
  114. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +116 -0
  115. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +259 -0
  116. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +116 -0
  117. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +421 -0
  118. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +116 -0
  119. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +415 -0
  120. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +116 -0
  121. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1429 -0
  122. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +116 -0
  123. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1474 -0
  124. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +116 -0
  125. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +211 -0
  126. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +116 -0
  127. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +190 -0
  128. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +116 -0
  129. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +307 -0
  130. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +116 -0
  131. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +496 -0
  132. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +116 -0
  133. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +181 -0
  134. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +116 -0
  135. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +283 -0
  136. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +116 -0
  137. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1567 -0
  138. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +481 -0
  139. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +116 -0
  140. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1747 -0
  141. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +116 -0
  142. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +116 -0
  143. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +4207 -0
  144. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +116 -0
  145. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +559 -0
  146. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +116 -0
  147. package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +316 -0
  148. package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +116 -0
  149. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +146 -0
  150. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +151 -0
  151. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +121 -0
  152. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +157 -0
  153. package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +161 -0
  154. package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +235 -0
  155. package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +139 -0
  156. package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +121 -0
  157. package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +271 -0
  158. package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
  159. package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +283 -0
  160. package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
  161. package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +175 -0
  162. package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +136 -0
  163. package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
  164. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +883 -0
  165. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
  166. package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +301 -0
  167. package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +146 -0
  168. package/coverage/rabbit-ui-kit/stories/atoms/index.html +191 -0
  169. package/coverage/rabbit-ui-kit/stories/molecules/AmountInput.stories.jsx.html +289 -0
  170. package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +322 -0
  171. package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +178 -0
  172. package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +154 -0
  173. package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +235 -0
  174. package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +160 -0
  175. package/coverage/rabbit-ui-kit/stories/molecules/index.html +191 -0
  176. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +523 -0
  177. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
  178. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
  179. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +337 -0
  180. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
  181. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
  182. package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +151 -0
  183. package/coverage/rabbit-ui-kit/stories/organisms/index.html +116 -0
  184. package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +6880 -0
  185. package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
  186. package/coverage/rabbit-ui-kit/stories/stubs/index.html +131 -0
  187. package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +190 -0
  188. package/coverage/rabbit-ui-kit/stories/templates/index.html +116 -0
  189. package/coverage/sort-arrow-sprite.png +0 -0
  190. package/coverage/sorter.js +196 -0
  191. package/dist/global.css +197 -0
  192. package/dist/global.css.map +1 -0
  193. package/dist/index.cjs +12451 -25
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.css +2339 -8491
  196. package/dist/index.css.map +1 -1
  197. package/dist/index.modern.js +9597 -26
  198. package/dist/index.modern.js.map +1 -1
  199. package/dist/index.module.js +12357 -27
  200. package/dist/index.module.js.map +1 -1
  201. package/dist/index.umd.js +12442 -29
  202. package/dist/index.umd.js.map +1 -1
  203. package/package.json +35 -9
  204. package/raw +1000 -0
  205. package/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js +21 -0
  206. package/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js +28 -0
  207. package/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js +38 -0
  208. package/src/common-apis/adapters/axiosAdapter.js +35 -0
  209. package/src/common-apis/adapters/qrUtils.js +18 -0
  210. package/src/common-apis/external-apis/apiGroups.js +55 -0
  211. package/src/common-apis/external-apis/emailAPI.js +16 -0
  212. package/src/common-apis/external-apis/ipAddressProviders.js +89 -0
  213. package/src/common-apis/globalConstants.jsx +3 -0
  214. package/src/common-apis/models/blockchain.js +10 -0
  215. package/src/common-apis/models/coin.js +248 -0
  216. package/src/common-apis/models/protocol.js +5 -0
  217. package/src/{common → common-apis/services}/fiatCurrenciesService.js +4 -12
  218. package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +12 -0
  219. package/src/common-apis/tests/units/utils/amountUtils/composeRateText.test.js +152 -0
  220. package/src/{common → common-apis/utils}/amountUtils.js +72 -136
  221. package/src/common-apis/utils/cache.js +242 -0
  222. package/src/{common → common-apis/utils}/errorUtils.js +15 -0
  223. package/src/common-apis/utils/logging/logger.js +41 -0
  224. package/src/common-apis/utils/logging/logsStorage.js +61 -0
  225. package/src/common-apis/utils/postponeExecution.js +11 -0
  226. package/src/common-apis/utils/rabbitTicker.js +24 -0
  227. package/src/common-apis/utils/safeStringify.js +50 -0
  228. package/src/index.js +96 -9
  229. package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +495 -0
  230. package/src/robust-api-caller/cachedRobustExternalApiCallerService.js +147 -0
  231. package/src/robust-api-caller/cancelProcessing.js +29 -0
  232. package/src/robust-api-caller/concurrentCalculationsMetadataHolder.js +75 -0
  233. package/src/robust-api-caller/externalApiProvider.js +156 -0
  234. package/src/robust-api-caller/externalServicesStatsCollector.js +78 -0
  235. package/src/robust-api-caller/robustExternalAPICallerService.js +304 -0
  236. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +533 -0
  237. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +532 -0
  238. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +19 -0
  239. package/src/swaps-lib/external-apis/exolixSwapProvider.js +580 -0
  240. package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +511 -0
  241. package/src/swaps-lib/external-apis/swapProvider.js +578 -0
  242. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +592 -0
  243. package/src/swaps-lib/models/baseSwapCreationInfo.js +78 -0
  244. package/src/swaps-lib/models/existingSwap.js +143 -0
  245. package/src/swaps-lib/models/existingSwapWithFiatData.js +148 -0
  246. package/src/swaps-lib/models/partner.js +27 -0
  247. package/src/swaps-lib/models/swapProviderCoinInfo.js +82 -0
  248. package/src/swaps-lib/services/publicSwapService.js +490 -0
  249. package/src/swaps-lib/test/external-apis/exolixSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +34 -0
  250. package/src/swaps-lib/test/external-apis/exolixSwapProvider/createSwap.test.js +1043 -0
  251. package/src/swaps-lib/test/external-apis/exolixSwapProvider/getSwapInfo.test.js +611 -0
  252. package/src/swaps-lib/test/external-apis/swapProvider/getAllSupportedCurrencies.test.js +63 -0
  253. package/src/swaps-lib/test/external-apis/swapProvider/getDepositCurrencies.test.js +73 -0
  254. package/src/swaps-lib/test/external-apis/swapProvider/getWithdrawalCurrencies.test.js +102 -0
  255. package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +152 -0
  256. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +536 -0
  257. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1214 -0
  258. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1707 -0
  259. package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +80 -0
  260. package/src/swaps-lib/utils/swapUtils.js +195 -0
  261. package/{styles → src/ui-kit/assets/styles}/_functions.scss +5 -0
  262. package/{styles → src/ui-kit/assets/styles}/_mixins.scss +2 -2
  263. package/{styles → src/ui-kit/assets/styles}/_placeholder.scss +3 -3
  264. package/{styles → src/ui-kit/assets/styles}/_variables.scss +17 -15
  265. package/src/ui-kit/assets/styles/fonts/NunitoSans-Bold.ttf +0 -0
  266. package/src/ui-kit/assets/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  267. package/src/ui-kit/assets/styles/fonts/NunitoSans-Light.ttf +0 -0
  268. package/src/ui-kit/assets/styles/fonts/NunitoSans-Regular.ttf +0 -0
  269. package/src/ui-kit/assets/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  270. package/src/ui-kit/assets/styles/global.scss +171 -0
  271. package/src/ui-kit/assets/styles/index.scss +10 -0
  272. package/src/ui-kit/assets/wrappedImages/arrowIcon.jsx +13 -0
  273. package/src/ui-kit/assets/wrappedImages/arrowTosca.jsx +14 -0
  274. package/src/ui-kit/assets/wrappedImages/arrowWhite.jsx +14 -0
  275. package/src/ui-kit/assets/wrappedImages/darkRectangle.jsx +7 -0
  276. package/src/ui-kit/assets/wrappedImages/determinedError.jsx +118 -0
  277. package/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx +39 -0
  278. package/src/ui-kit/assets/wrappedImages/infoIcon.jsx +16 -0
  279. package/src/ui-kit/assets/wrappedImages/messageIcon.jsx +87 -0
  280. package/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx +54 -0
  281. package/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx +26 -0
  282. package/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx +61 -0
  283. package/src/ui-kit/assets/wrappedImages/walletIcon.jsx +22 -0
  284. package/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx +57 -0
  285. package/src/{components → ui-kit/components}/atoms/AssetIcon/asset-icon.module.scss +1 -1
  286. package/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx +68 -0
  287. package/src/ui-kit/components/atoms/AssetSelection/asset-selection.module.scss +56 -0
  288. package/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx +34 -0
  289. package/src/ui-kit/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
  290. package/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx +51 -0
  291. package/src/ui-kit/components/atoms/InformationMessage/information-message.module.scss +38 -0
  292. package/src/ui-kit/components/atoms/Input/Input.jsx +183 -0
  293. package/src/ui-kit/components/atoms/Input/input.module.scss +107 -0
  294. package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.jsx +8 -28
  295. package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.module.scss +3 -2
  296. package/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx +64 -0
  297. package/src/ui-kit/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
  298. package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +44 -0
  299. package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +15 -0
  300. package/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx +30 -0
  301. package/src/ui-kit/components/atoms/RateSelector/rate-selector.module.scss +47 -0
  302. package/src/{components → ui-kit/components}/atoms/SupportChat/SupportChat.jsx +5 -1
  303. package/src/ui-kit/components/atoms/Textarea/Textarea.jsx +148 -0
  304. package/src/ui-kit/components/atoms/Textarea/textarea.module.scss +71 -0
  305. package/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx +141 -0
  306. package/src/ui-kit/components/atoms/TitleBox/title-box.module.scss +32 -0
  307. package/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx +77 -0
  308. package/src/ui-kit/components/atoms/Tooltip/tooltip.module.scss +237 -0
  309. package/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx +76 -0
  310. package/src/ui-kit/components/atoms/TwoLinesOfText/lines-of-text.module.scss +65 -0
  311. package/src/ui-kit/components/atoms/Validation/Validation.jsx +39 -0
  312. package/src/ui-kit/components/atoms/Validation/validation.module.scss +19 -0
  313. package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.jsx +24 -50
  314. package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.module.scss +1 -1
  315. package/src/ui-kit/components/atoms/buttons/Close/Close.jsx +58 -0
  316. package/src/ui-kit/components/atoms/buttons/Close/close.module.scss +75 -0
  317. package/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx +112 -0
  318. package/src/ui-kit/components/atoms/buttons/LinkButton/link-button.module.scss +49 -0
  319. package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +110 -0
  320. package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/radio-button-with-text.module.scss +86 -0
  321. package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +448 -0
  322. package/src/ui-kit/components/molecules/AmountInput/amount-input.module.scss +233 -0
  323. package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +463 -0
  324. package/src/ui-kit/components/molecules/CoinPicker/coin-picker.module.scss +207 -0
  325. package/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx +42 -0
  326. package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +20 -0
  327. package/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx +35 -0
  328. package/src/ui-kit/components/molecules/LineWithIconLink/line-with-icon-link.module.scss +25 -0
  329. package/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx +74 -0
  330. package/src/ui-kit/components/molecules/LogoCarousel/logo-carousel.module.scss +106 -0
  331. package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +137 -0
  332. package/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx +32 -0
  333. package/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +66 -0
  334. package/src/ui-kit/components/organisms/Dialog/Dialog.jsx +494 -0
  335. package/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +132 -0
  336. package/src/ui-kit/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
  337. package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +554 -0
  338. package/src/ui-kit/components/organisms/Dialog/DialogStep/dialog-step.module.scss +381 -0
  339. package/src/ui-kit/components/organisms/Dialog/dialog.module.scss +226 -0
  340. package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +1374 -0
  341. package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +134 -0
  342. package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +158 -0
  343. package/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx +77 -0
  344. package/src/ui-kit/hooks/useCallHandlingErrors.js +22 -0
  345. package/src/ui-kit/hooks/useIsHydrated.js +12 -0
  346. package/src/ui-kit/hooks/useReferredState.js +24 -0
  347. package/src/ui-kit/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +146 -0
  348. package/src/ui-kit/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +65 -0
  349. package/src/ui-kit/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +104 -0
  350. package/src/ui-kit/utils/inputValueProviders.js +50 -0
  351. package/src/ui-kit/utils/textUtils.js +18 -0
  352. package/src/ui-kit/utils/uiUtils.js +12 -0
  353. package/src/ui-kit/utils/urlQueryUtils.js +62 -0
  354. package/stories/font.scss +40 -0
  355. package/stories/stubs/coins.jsx +2266 -0
  356. package/stories/stubs/exampleContent.jsx +20 -0
  357. package/src/components/atoms/AssetIcon/AssetIcon.jsx +0 -55
  358. package/styles/_global-classes.scss +0 -433
  359. package/styles/fonts/NunitoSans-Bold.ttf +0 -0
  360. package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  361. package/styles/fonts/NunitoSans-Light.ttf +0 -0
  362. package/styles/fonts/NunitoSans-Regular.ttf +0 -0
  363. package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  364. package/styles/global-styles-index.scss +0 -74
  365. package/styles/index.scss +0 -33
  366. /package/{styles → src/ui-kit/assets/styles}/colors/_light-colors.scss +0 -0
  367. /package/{styles → src/ui-kit/assets/styles}/colors/_solid-colors.scss +0 -0
  368. /package/{styles → src/ui-kit/assets/styles}/size/_margin-size.scss +0 -0
  369. /package/{styles → src/ui-kit/assets/styles}/size/_padding-size.scss +0 -0
@@ -0,0 +1,1043 @@
1
+ import sinon from "sinon";
2
+ import axios from "axios";
3
+ import should from "should";
4
+
5
+ import { beforeEach, afterEach, describe, it } from "vitest";
6
+
7
+ import { ExolixSwapProvider } from "../../../external-apis/exolixSwapProvider.js";
8
+ import { SwapProvider } from "../../../external-apis/swapProvider.js";
9
+ import { Coin } from "../../../../common-apis/models/coin.js";
10
+ import { Blockchain } from "../../../../common-apis/models/blockchain.js";
11
+ import { Cache } from "../../../../common-apis/utils/cache.js";
12
+
13
+ describe("exolixSwapProvider", function () {
14
+ describe("createSwap", function () {
15
+ const anyReceivingAddress = "any addr";
16
+ const anyRefundAddress = "any refund addr";
17
+ const anyAmount = "100.1319";
18
+ const anyValidRawSwapData = {
19
+ fromCurrency: "any currency from",
20
+ fromNetwork: "any network from",
21
+ toCurrency: "any currency to",
22
+ toNetwork: "any network to",
23
+ id: "any id",
24
+ partner: "any partner",
25
+ };
26
+
27
+ const BTC = new Coin(
28
+ "Bitcoin",
29
+ "BTC",
30
+ "BTC",
31
+ 8,
32
+ null,
33
+ "sat",
34
+ null,
35
+ null,
36
+ 1,
37
+ null,
38
+ [],
39
+ null,
40
+ new Blockchain("Bitcoin")
41
+ );
42
+ const ETH = new Coin(
43
+ "Ethereum",
44
+ "ETH",
45
+ "ETH",
46
+ 18,
47
+ null,
48
+ "wei",
49
+ null,
50
+ null,
51
+ 1,
52
+ null,
53
+ [],
54
+ null,
55
+ new Blockchain("Ethereum")
56
+ );
57
+ const USDCTRC20 = new Coin(
58
+ "USDCTRC20",
59
+ "USDCTRC20",
60
+ "USDC",
61
+ 6,
62
+ null,
63
+ "millicents",
64
+ null,
65
+ null,
66
+ 1,
67
+ null,
68
+ [],
69
+ null,
70
+ new Blockchain("Tron")
71
+ );
72
+ let exolixSwapProvider;
73
+ let fetchSupportedCurrenciesStub;
74
+ let axiosPostStub;
75
+
76
+ beforeEach(() => {
77
+ exolixSwapProvider = new ExolixSwapProvider("/", new Cache());
78
+ exolixSwapProvider._supportedCoins = [
79
+ { coin: BTC, extraId: "" },
80
+ { coin: ETH, extraId: "" },
81
+ { coin: USDCTRC20, extraId: "" },
82
+ ];
83
+
84
+ fetchSupportedCurrenciesStub = sinon.stub(exolixSwapProvider, "_fetchSupportedCurrenciesIfNeeded");
85
+ fetchSupportedCurrenciesStub.resolves();
86
+
87
+ axiosPostStub = sinon.stub(axios, "post");
88
+ axiosPostStub.resolves({
89
+ data: {
90
+ id: "test-id",
91
+ amount: 1,
92
+ amountTo: 2,
93
+ coinFrom: {
94
+ memoName: "",
95
+ },
96
+ coinTo: {
97
+ memoName: "",
98
+ },
99
+ depositAddress: "from-address",
100
+ withdrawalAddress: "to-address",
101
+ refundAddress: "refund-address",
102
+ rate: 2,
103
+ rateType: "float",
104
+ },
105
+ status: 200,
106
+ });
107
+ });
108
+
109
+ afterEach(() => {
110
+ fetchSupportedCurrenciesStub.restore();
111
+ axiosPostStub.restore();
112
+ });
113
+
114
+ it("Should fetch supported currencies", async () => {
115
+ await exolixSwapProvider.createSwap(
116
+ USDCTRC20,
117
+ ETH,
118
+ anyAmount,
119
+ anyReceivingAddress,
120
+ anyRefundAddress,
121
+ anyValidRawSwapData,
122
+ null,
123
+ false
124
+ );
125
+ fetchSupportedCurrenciesStub.calledOnce.should.be.true();
126
+ });
127
+
128
+ it("Should send an axios POST request", async () => {
129
+ await exolixSwapProvider.createSwap(
130
+ USDCTRC20,
131
+ ETH,
132
+ anyAmount,
133
+ anyReceivingAddress,
134
+ anyRefundAddress,
135
+ anyValidRawSwapData,
136
+ null,
137
+ false
138
+ );
139
+ axiosPostStub.calledOnce.should.be.true();
140
+ });
141
+
142
+ it("Should send the request to the correct URL", async () => {
143
+ await exolixSwapProvider.createSwap(
144
+ USDCTRC20,
145
+ ETH,
146
+ anyAmount,
147
+ anyReceivingAddress,
148
+ anyRefundAddress,
149
+ anyValidRawSwapData,
150
+ null,
151
+ false
152
+ );
153
+ axiosPostStub.args[0][0].should.equal(`${exolixSwapProvider._URL}/transactions`);
154
+ });
155
+
156
+ it("Should pass provided refund address in request data", async () => {
157
+ await exolixSwapProvider.createSwap(
158
+ USDCTRC20,
159
+ ETH,
160
+ anyAmount,
161
+ anyReceivingAddress,
162
+ anyRefundAddress,
163
+ anyValidRawSwapData,
164
+ null,
165
+ false
166
+ );
167
+
168
+ axiosPostStub.args[0][1].should.have.property("refundAddress", anyRefundAddress);
169
+ });
170
+
171
+ it('Should send the correct "withdrawalExtraId" passed if toCoin has hasExtraId===true', async () => {
172
+ const someExtraId = "extra123";
173
+ exolixSwapProvider._supportedCoins = [{ coin: USDCTRC20 }, { coin: ETH, hasExtraId: true }];
174
+
175
+ await exolixSwapProvider.createSwap(
176
+ USDCTRC20,
177
+ ETH,
178
+ anyAmount,
179
+ anyReceivingAddress,
180
+ anyRefundAddress,
181
+ anyValidRawSwapData,
182
+ null,
183
+ false,
184
+ someExtraId
185
+ );
186
+
187
+ axiosPostStub.args[0][1].should.have.property("withdrawalExtraId", someExtraId);
188
+ });
189
+
190
+ it('Should send the correct "refundExtraId" when refund extraId passed and fromCoin has hasExtraId===true ', async () => {
191
+ const someExtraId = "extra123";
192
+ exolixSwapProvider._supportedCoins = [
193
+ {
194
+ coin: USDCTRC20,
195
+ hasExtraId: true,
196
+ code: "usdt",
197
+ network: "trc20",
198
+ },
199
+ { coin: ETH },
200
+ ];
201
+
202
+ await exolixSwapProvider.createSwap(
203
+ USDCTRC20,
204
+ ETH,
205
+ anyAmount,
206
+ anyReceivingAddress,
207
+ anyRefundAddress,
208
+ anyValidRawSwapData,
209
+ null,
210
+ false,
211
+ null,
212
+ someExtraId
213
+ );
214
+
215
+ axiosPostStub.args[0][1].should.have.property("refundExtraId", someExtraId);
216
+ });
217
+
218
+ it('Should omit passed "extraId" or "refundExtraId" when matching coins have hasExtraId false', async () => {
219
+ const someExtraId = "extra123";
220
+ exolixSwapProvider._supportedCoins = [
221
+ { coin: USDCTRC20, hasExtraId: false },
222
+ { coin: ETH, hasExtraId: false },
223
+ ];
224
+
225
+ await exolixSwapProvider.createSwap(
226
+ USDCTRC20,
227
+ ETH,
228
+ anyAmount,
229
+ anyReceivingAddress,
230
+ anyRefundAddress,
231
+ anyValidRawSwapData,
232
+ null,
233
+ false,
234
+ someExtraId,
235
+ someExtraId
236
+ );
237
+
238
+ axiosPostStub.args[0][1]["withdrawalExtraId"].should.be.equal("");
239
+ axiosPostStub.args[0][1]["refundExtraId"].should.be.equal("");
240
+ });
241
+
242
+ [false, true].forEach(fixed => {
243
+ it("Should ensure that fixed is always set to passed fixed value in the request data", async () => {
244
+ await exolixSwapProvider.createSwap(
245
+ USDCTRC20,
246
+ ETH,
247
+ anyAmount,
248
+ anyReceivingAddress,
249
+ anyRefundAddress,
250
+ anyValidRawSwapData,
251
+ null,
252
+ fixed
253
+ );
254
+
255
+ axiosPostStub.args[0][1].rateType.should.equal(fixed ? "fixed" : "float");
256
+ });
257
+ });
258
+
259
+ it("Should ensure all required parameters are passed to axios", async () => {
260
+ await exolixSwapProvider.createSwap(
261
+ USDCTRC20,
262
+ ETH,
263
+ anyAmount,
264
+ anyReceivingAddress,
265
+ anyRefundAddress,
266
+ anyValidRawSwapData,
267
+ null,
268
+ false
269
+ );
270
+
271
+ const requestData = axiosPostStub.args[0][1];
272
+ requestData.should.have.properties([
273
+ "coinFrom",
274
+ "networkFrom",
275
+ "coinTo",
276
+ "networkTo",
277
+ "amount",
278
+ "withdrawalAmount",
279
+ "withdrawalAddress",
280
+ "withdrawalExtraId",
281
+ "refundAddress",
282
+ "refundExtraId",
283
+ "rateType",
284
+ ]);
285
+ });
286
+
287
+ it("Should handle cases where toCurrencyExtraId is not found for the coin", async () => {
288
+ exolixSwapProvider._supportedCoins = [{ coin: USDCTRC20, extraId: "" }, { coin: ETH }];
289
+ await exolixSwapProvider.createSwap(
290
+ USDCTRC20,
291
+ ETH,
292
+ anyAmount,
293
+ anyReceivingAddress,
294
+ anyRefundAddress,
295
+ anyValidRawSwapData,
296
+ null,
297
+ false
298
+ );
299
+ axiosPostStub.args[0][1]["withdrawalExtraId"].should.be.equal("");
300
+ });
301
+
302
+ it("Should throw an error if swap creation response is invalid", async () => {
303
+ axiosPostStub.resolves({ data: {} });
304
+
305
+ await exolixSwapProvider
306
+ .createSwap(
307
+ USDCTRC20,
308
+ ETH,
309
+ anyAmount,
310
+ anyReceivingAddress,
311
+ anyRefundAddress,
312
+ anyValidRawSwapData,
313
+ null,
314
+ false
315
+ )
316
+ .should.be.rejected();
317
+ });
318
+
319
+ it("Should handle status 429 and return requests limit exceeded", async () => {
320
+ axiosPostStub.rejects({ response: { status: 429 } });
321
+
322
+ const result = await exolixSwapProvider.createSwap(
323
+ USDCTRC20,
324
+ ETH,
325
+ anyAmount,
326
+ anyReceivingAddress,
327
+ anyRefundAddress,
328
+ anyValidRawSwapData,
329
+ null,
330
+ false
331
+ );
332
+
333
+ result.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
334
+ });
335
+
336
+ it('Should return retriable fail for status 400 and specific "Amount to exchange is higher" error text', async () => {
337
+ axiosPostStub.rejects({
338
+ response: {
339
+ status: 400,
340
+ data: {
341
+ fromAmount: 1,
342
+ message: "Amount to exchange is higher the possible max amount to exchange",
343
+ maxAmount: 1000,
344
+ toAmount: 0,
345
+ },
346
+ },
347
+ });
348
+
349
+ const result = await exolixSwapProvider.createSwap(
350
+ USDCTRC20,
351
+ ETH,
352
+ anyAmount,
353
+ anyReceivingAddress,
354
+ anyRefundAddress,
355
+ anyValidRawSwapData,
356
+ null,
357
+ false
358
+ );
359
+
360
+ result.reason.should.equal(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
361
+ });
362
+
363
+ it('Should return retriable fail for status 400 and specific "Amount to exchange is below" error text', async () => {
364
+ axiosPostStub.rejects({
365
+ response: {
366
+ status: 400,
367
+ data: {
368
+ fromAmount: 1,
369
+ message: "Amount to exchange is below the possible min amount to exchange",
370
+ minAmount: 10,
371
+ toAmount: 0,
372
+ },
373
+ },
374
+ });
375
+
376
+ const result = await exolixSwapProvider.createSwap(
377
+ USDCTRC20,
378
+ ETH,
379
+ anyAmount,
380
+ anyReceivingAddress,
381
+ anyRefundAddress,
382
+ anyValidRawSwapData,
383
+ null,
384
+ false
385
+ );
386
+
387
+ result.reason.should.equal(SwapProvider.CREATION_FAIL_REASONS.RETRIABLE_FAIL);
388
+ });
389
+
390
+ it('Should return retriable fail for status 422 and specific "Currency not found" error text', async () => {
391
+ axiosPostStub.rejects({
392
+ response: {
393
+ status: 422,
394
+ data: {
395
+ error: "Such exchange pair is not available",
396
+ },
397
+ },
398
+ });
399
+
400
+ const result = await exolixSwapProvider.createSwap(
401
+ USDCTRC20,
402
+ ETH,
403
+ anyAmount,
404
+ anyReceivingAddress,
405
+ anyRefundAddress,
406
+ anyValidRawSwapData,
407
+ null,
408
+ false
409
+ );
410
+
411
+ // In swapspace this was "retriable fail", but here the not supported fits
412
+ // better, because this means that there is no such coin in the system
413
+
414
+ result.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
415
+ });
416
+
417
+ it("Should return the correct swap details if response is valid", async () => {
418
+ axiosPostStub.resolves({
419
+ data: {
420
+ id: "test-id",
421
+ amount: 1,
422
+ amountTo: 2,
423
+ rate: 2,
424
+ depositAddress: "from-address",
425
+ withdrawalAddress: "to-address",
426
+ rateType: "float",
427
+ },
428
+ });
429
+
430
+ const result = await exolixSwapProvider.createSwap(
431
+ USDCTRC20,
432
+ ETH,
433
+ anyAmount,
434
+ anyReceivingAddress,
435
+ anyRefundAddress,
436
+ anyValidRawSwapData,
437
+ null,
438
+ false
439
+ );
440
+
441
+ result.should.have.property("swapId", "test-id");
442
+ });
443
+
444
+ it("Should return true in the result property when successful", async () => {
445
+ axiosPostStub.resolves({
446
+ data: {
447
+ id: "test-id",
448
+ amount: 1,
449
+ amountTo: 2,
450
+ rate: 2,
451
+ depositAddress: "from-address",
452
+ withdrawalAddress: "to-address",
453
+ rateType: "float",
454
+ },
455
+ });
456
+
457
+ const result = await exolixSwapProvider.createSwap(
458
+ USDCTRC20,
459
+ ETH,
460
+ anyAmount,
461
+ anyReceivingAddress,
462
+ anyRefundAddress,
463
+ anyValidRawSwapData,
464
+ null,
465
+ false
466
+ );
467
+
468
+ result.should.have.property("result", true);
469
+ });
470
+
471
+ it("Should return a proper structure for a successful swap creation", async () => {
472
+ axiosPostStub.resolves({
473
+ data: {
474
+ id: "test-id",
475
+ amount: 1,
476
+ amountTo: 2,
477
+ rate: 2,
478
+ depositAddress: "from-address",
479
+ withdrawalAddress: "to-address",
480
+ rateType: "float",
481
+ },
482
+ });
483
+
484
+ const result = await exolixSwapProvider.createSwap(
485
+ USDCTRC20,
486
+ ETH,
487
+ anyAmount,
488
+ anyReceivingAddress,
489
+ anyRefundAddress,
490
+ anyValidRawSwapData,
491
+ null,
492
+ false
493
+ );
494
+
495
+ result.result.should.be.Boolean();
496
+ result.swapId.should.be.String();
497
+ result.fromCoin.should.be.instanceOf(Coin);
498
+ result.fromAmount.should.be.String();
499
+ result.fromAddress.should.be.String();
500
+ result.toCoin.should.be.instanceOf(Coin);
501
+ result.toAmount.should.be.String();
502
+ result.toAddress.should.be.String();
503
+ result.rate.should.be.String();
504
+ result.fixed.should.be.Boolean();
505
+ });
506
+
507
+ it("Should calculate rate if not provided in the response", async () => {
508
+ axiosPostStub.resolves({
509
+ data: {
510
+ id: "test-id",
511
+ amount: 1,
512
+ amountTo: 2,
513
+ depositAddress: "from-address",
514
+ withdrawalAddress: "to-address",
515
+ rateType: "float",
516
+ },
517
+ });
518
+
519
+ const result = await exolixSwapProvider.createSwap(
520
+ USDCTRC20,
521
+ ETH,
522
+ anyAmount,
523
+ anyReceivingAddress,
524
+ anyRefundAddress,
525
+ anyValidRawSwapData,
526
+ null,
527
+ false
528
+ );
529
+
530
+ result.rate.should.equal("2.00000000000000000000");
531
+ });
532
+
533
+ it("Should calculate rate if the provided in the response is 0", async () => {
534
+ axiosPostStub.resolves({
535
+ data: {
536
+ id: "test-id",
537
+ amount: 1,
538
+ amountTo: 2,
539
+ rate: 0,
540
+ depositAddress: "from-address",
541
+ withdrawalAddress: "to-address",
542
+ rateType: "float",
543
+ },
544
+ });
545
+
546
+ const result = await exolixSwapProvider.createSwap(
547
+ USDCTRC20,
548
+ ETH,
549
+ anyAmount,
550
+ anyReceivingAddress,
551
+ anyRefundAddress,
552
+ anyValidRawSwapData,
553
+ null,
554
+ false
555
+ );
556
+
557
+ result.rate.should.equal("2.00000000000000000000");
558
+ });
559
+
560
+ it("Should return address details correctly as returned by provider", async () => {
561
+ axiosPostStub.resolves({
562
+ data: {
563
+ id: "test-id",
564
+ amount: 4,
565
+ amountTo: 2,
566
+ rate: 0.5,
567
+ depositAddress: "from-addr",
568
+ withdrawalAddress: "to-addr",
569
+ rateType: "float",
570
+ },
571
+ });
572
+
573
+ const result = await exolixSwapProvider.createSwap(
574
+ USDCTRC20,
575
+ ETH,
576
+ anyAmount,
577
+ anyReceivingAddress,
578
+ anyRefundAddress,
579
+ anyValidRawSwapData,
580
+ null,
581
+ false
582
+ );
583
+
584
+ result.should.have.property("fromAddress", "from-addr");
585
+ result.should.have.property("toAddress", "to-addr");
586
+ });
587
+
588
+ it("Should return proper fromAmount from the response", async () => {
589
+ axiosPostStub.resolves({
590
+ data: {
591
+ id: "test-id",
592
+ amount: 1131.0931,
593
+ amountTo: 2,
594
+ rate: 0.5,
595
+ depositAddress: "from-addr",
596
+ withdrawalAddress: "to-addr",
597
+ rateType: "float",
598
+ },
599
+ });
600
+
601
+ const result = await exolixSwapProvider.createSwap(
602
+ USDCTRC20,
603
+ ETH,
604
+ anyAmount,
605
+ anyReceivingAddress,
606
+ anyRefundAddress,
607
+ anyValidRawSwapData,
608
+ null,
609
+ false
610
+ );
611
+
612
+ result.should.have.property("fromAmount", "1131.093100");
613
+ });
614
+
615
+ it("Should throw an error if from coin is not Coin", async () => {
616
+ let error;
617
+ try {
618
+ await exolixSwapProvider.createSwap(
619
+ {},
620
+ ETH,
621
+ anyAmount,
622
+ anyReceivingAddress,
623
+ anyRefundAddress,
624
+ anyValidRawSwapData,
625
+ null,
626
+ false
627
+ );
628
+ } catch (e) {
629
+ error = e;
630
+ }
631
+
632
+ error.message.should.match(/.*Invalid input: .*/);
633
+ });
634
+
635
+ it("Should throw an error if to coin is not Coin", async () => {
636
+ let error;
637
+ try {
638
+ await exolixSwapProvider.createSwap(
639
+ ETH,
640
+ {},
641
+ anyAmount,
642
+ anyReceivingAddress,
643
+ anyRefundAddress,
644
+ anyValidRawSwapData,
645
+ null,
646
+ false
647
+ );
648
+ } catch (e) {
649
+ error = e;
650
+ }
651
+
652
+ error.message.should.match(/.*Invalid input: .*/);
653
+ });
654
+
655
+ it("Should throw an error if amount is not string", async () => {
656
+ let error;
657
+ try {
658
+ await exolixSwapProvider.createSwap(
659
+ BTC,
660
+ ETH,
661
+ 1,
662
+ anyReceivingAddress,
663
+ anyRefundAddress,
664
+ anyValidRawSwapData,
665
+ null,
666
+ false
667
+ );
668
+ } catch (e) {
669
+ error = e;
670
+ }
671
+
672
+ error.message.should.match(/.*Invalid input: .*/);
673
+ });
674
+
675
+ it("Should throw an error if address is not string", async () => {
676
+ let error;
677
+ try {
678
+ await exolixSwapProvider.createSwap(
679
+ BTC,
680
+ ETH,
681
+ anyAmount,
682
+ 999,
683
+ anyRefundAddress,
684
+ anyValidRawSwapData,
685
+ null,
686
+ false
687
+ );
688
+ } catch (e) {
689
+ error = e;
690
+ }
691
+
692
+ error.message.should.match(/.*Invalid input: .*/);
693
+ });
694
+
695
+ it("Should throw an error if refund address is not string", async () => {
696
+ let error;
697
+ try {
698
+ await exolixSwapProvider.createSwap(
699
+ BTC,
700
+ ETH,
701
+ anyAmount,
702
+ anyReceivingAddress,
703
+ null,
704
+ anyValidRawSwapData,
705
+ null,
706
+ false
707
+ );
708
+ } catch (e) {
709
+ error = e;
710
+ }
711
+
712
+ error.message.should.match(/.*Invalid input: .*/);
713
+ });
714
+
715
+ it("Should throw an error if fixed is not boolean", async () => {
716
+ let error;
717
+ try {
718
+ await exolixSwapProvider.createSwap(
719
+ BTC,
720
+ ETH,
721
+ anyAmount,
722
+ anyReceivingAddress,
723
+ anyRefundAddress,
724
+ anyValidRawSwapData,
725
+ null
726
+ );
727
+ } catch (e) {
728
+ error = e;
729
+ }
730
+
731
+ error.message.should.match(/.*Invalid input: .*/);
732
+ });
733
+
734
+ it("Should return proper toAmount from the response", async () => {
735
+ axiosPostStub.resolves({
736
+ data: {
737
+ id: "test-id",
738
+ amount: 1131.0931,
739
+ amountTo: 2091.92301,
740
+ rate: 0.5,
741
+ depositAddress: "from-addr",
742
+ withdrawalAddress: "to-addr",
743
+ rateType: "float",
744
+ },
745
+ });
746
+
747
+ const result = await exolixSwapProvider.createSwap(
748
+ USDCTRC20,
749
+ ETH,
750
+ anyAmount,
751
+ anyReceivingAddress,
752
+ anyRefundAddress,
753
+ anyValidRawSwapData,
754
+ null,
755
+ false
756
+ );
757
+
758
+ result.should.have.property("toAmount", "2091.923010000000000000");
759
+ });
760
+
761
+ it("Should handle scenario when amounts or addresses in the response are null", async () => {
762
+ axiosPostStub.resolves({
763
+ data: {
764
+ id: "test-id",
765
+ amount: null,
766
+ amountTo: null,
767
+ rate: 0.5,
768
+ depositAddress: null,
769
+ withdrawalAddress: null,
770
+ rateType: "float",
771
+ },
772
+ });
773
+
774
+ await exolixSwapProvider
775
+ .createSwap(
776
+ USDCTRC20,
777
+ ETH,
778
+ anyAmount,
779
+ anyReceivingAddress,
780
+ anyRefundAddress,
781
+ anyValidRawSwapData,
782
+ null,
783
+ false
784
+ )
785
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect.*/);
786
+ });
787
+
788
+ it("Should handle non-200 HTTP status codes", async () => {
789
+ axiosPostStub.rejects({
790
+ response: { status: 500, data: "Server Error" },
791
+ });
792
+
793
+ let error;
794
+ try {
795
+ await exolixSwapProvider.createSwap(
796
+ USDCTRC20,
797
+ ETH,
798
+ anyAmount,
799
+ anyReceivingAddress,
800
+ anyRefundAddress,
801
+ anyValidRawSwapData,
802
+ null,
803
+ false
804
+ );
805
+ } catch (e) {
806
+ error = e;
807
+ }
808
+
809
+ error.response.status.should.be.equal(500);
810
+ error.response.data.should.be.equal("Server Error");
811
+ });
812
+
813
+ it("Should handle network errors without response data", async () => {
814
+ axiosPostStub.rejects(new Error("Network Error"));
815
+
816
+ await exolixSwapProvider
817
+ .createSwap(
818
+ USDCTRC20,
819
+ ETH,
820
+ anyAmount,
821
+ anyReceivingAddress,
822
+ anyRefundAddress,
823
+ anyValidRawSwapData,
824
+ null,
825
+ false
826
+ )
827
+ .should.be.rejectedWith(/.*Network Error.*/);
828
+ });
829
+
830
+ it("Should handle cases when provided rate in the response is non-numeric", async () => {
831
+ axiosPostStub.resolves({
832
+ data: {
833
+ id: "test-id",
834
+ amount: 1,
835
+ amountTo: 2,
836
+ rate: 2,
837
+ depositAddress: "from-addr",
838
+ withdrawalAddress: "to-addr",
839
+ rateType: "float",
840
+ },
841
+ });
842
+
843
+ const result = await exolixSwapProvider.createSwap(
844
+ USDCTRC20,
845
+ ETH,
846
+ anyAmount,
847
+ anyReceivingAddress,
848
+ anyRefundAddress,
849
+ anyValidRawSwapData,
850
+ null,
851
+ false
852
+ );
853
+
854
+ result.rate.should.equal("2.00000000000000000000");
855
+ });
856
+
857
+ it("Should reject when _fetchSupportedCurrenciesIfNeeded throws an error", async () => {
858
+ fetchSupportedCurrenciesStub.rejects(new Error("Fetching Error"));
859
+
860
+ await exolixSwapProvider
861
+ .createSwap(
862
+ USDCTRC20,
863
+ ETH,
864
+ anyAmount,
865
+ anyReceivingAddress,
866
+ anyRefundAddress,
867
+ anyValidRawSwapData,
868
+ null,
869
+ false
870
+ )
871
+ .should.be.rejectedWith(/.*Fetching Error.*/);
872
+ });
873
+
874
+ it("Should handle the scenario when axios.post throws an error with no response object", async () => {
875
+ axiosPostStub.rejects(new Error("Network Error"));
876
+
877
+ await exolixSwapProvider
878
+ .createSwap(
879
+ USDCTRC20,
880
+ ETH,
881
+ anyAmount,
882
+ anyReceivingAddress,
883
+ anyRefundAddress,
884
+ anyValidRawSwapData,
885
+ null,
886
+ false
887
+ )
888
+ .should.be.rejectedWith(/.*Network Error.*/);
889
+ });
890
+
891
+ it('Should handle axios.post returning a response with no "id"', async () => {
892
+ axiosPostStub.resolves({ data: {} });
893
+
894
+ await exolixSwapProvider
895
+ .createSwap(
896
+ USDCTRC20,
897
+ ETH,
898
+ anyAmount,
899
+ anyReceivingAddress,
900
+ anyRefundAddress,
901
+ anyValidRawSwapData,
902
+ null,
903
+ false
904
+ )
905
+ .should.be.rejectedWith(/.*Swap creation failed, API response*/);
906
+ });
907
+
908
+ it("Should handle axios.post returning a response with from amount in string type", async () => {
909
+ axiosPostStub.resolves({
910
+ data: {
911
+ id: "test-id",
912
+ amount: "1",
913
+ amountTo: 2,
914
+ rate: 2,
915
+ depositAddress: "from-addr",
916
+ withdrawalAddress: "to-addr",
917
+ rateType: "float",
918
+ },
919
+ });
920
+
921
+ await exolixSwapProvider
922
+ .createSwap(
923
+ USDCTRC20,
924
+ ETH,
925
+ anyAmount,
926
+ anyReceivingAddress,
927
+ anyRefundAddress,
928
+ anyValidRawSwapData,
929
+ null,
930
+ false
931
+ )
932
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect*/);
933
+ });
934
+
935
+ it("Should handle axios.post returning a response with to amount in string type", async () => {
936
+ axiosPostStub.resolves({
937
+ data: {
938
+ id: "test-id",
939
+ amount: 1,
940
+ amountTo: "2",
941
+ rate: 2,
942
+ depositAddress: "from-addr",
943
+ withdrawalAddress: "to-addr",
944
+ rateType: "float",
945
+ },
946
+ });
947
+
948
+ await exolixSwapProvider
949
+ .createSwap(
950
+ USDCTRC20,
951
+ ETH,
952
+ anyAmount,
953
+ anyReceivingAddress,
954
+ anyRefundAddress,
955
+ anyValidRawSwapData,
956
+ null,
957
+ false
958
+ )
959
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect*/);
960
+ });
961
+
962
+ it("Should handle axios.post returning a response with no from address or invalid", async () => {
963
+ axiosPostStub.resolves({
964
+ data: {
965
+ id: "test-id",
966
+ amount: 1,
967
+ amountTo: 2,
968
+ rate: 2,
969
+ depositAddress: null,
970
+ withdrawalAddress: "to-addr",
971
+ rateType: "float",
972
+ },
973
+ });
974
+
975
+ await exolixSwapProvider
976
+ .createSwap(
977
+ USDCTRC20,
978
+ ETH,
979
+ anyAmount,
980
+ anyReceivingAddress,
981
+ anyRefundAddress,
982
+ anyValidRawSwapData,
983
+ null,
984
+ false
985
+ )
986
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect*/);
987
+ });
988
+
989
+ it("Should handle axios.post returning a response with no to address or invalid", async () => {
990
+ axiosPostStub.resolves({
991
+ data: {
992
+ id: "test-id",
993
+ amount: 1,
994
+ amountTo: 2,
995
+ rate: 2,
996
+ depositAddress: "from-addr",
997
+ withdrawalAddress: null,
998
+ rateType: "float",
999
+ },
1000
+ });
1001
+
1002
+ await exolixSwapProvider
1003
+ .createSwap(
1004
+ USDCTRC20,
1005
+ ETH,
1006
+ anyAmount,
1007
+ anyReceivingAddress,
1008
+ anyRefundAddress,
1009
+ anyValidRawSwapData,
1010
+ null,
1011
+ false
1012
+ )
1013
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect*/);
1014
+ });
1015
+
1016
+ it("Should handle axios.post returning a response with non-boolean fixed", async () => {
1017
+ axiosPostStub.resolves({
1018
+ data: {
1019
+ id: "test-id",
1020
+ amount: 1,
1021
+ amountTo: 2,
1022
+ rate: 2,
1023
+ depositAddress: "from-addr",
1024
+ withdrawalAddress: "to-addr",
1025
+ rateType: 123,
1026
+ },
1027
+ });
1028
+
1029
+ await exolixSwapProvider
1030
+ .createSwap(
1031
+ USDCTRC20,
1032
+ ETH,
1033
+ anyAmount,
1034
+ anyReceivingAddress,
1035
+ anyRefundAddress,
1036
+ anyValidRawSwapData,
1037
+ null,
1038
+ false
1039
+ )
1040
+ .should.be.rejectedWith(/.*Swap was created but the data was incorrect*/);
1041
+ });
1042
+ });
1043
+ });