@rabbitio/ui-kit 1.0.0-beta.72 → 1.0.0-beta.74

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 (253) hide show
  1. package/coverage/clover.xml +6441 -1864
  2. package/coverage/coverage-final.json +157 -95
  3. package/coverage/index.html +339 -84
  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 → ui-kit}/src/common-apis/adapters/axiosAdapter.js.html +3 -3
  7. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/index.html +3 -3
  8. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/adapters/qrUtils.js.html +3 -3
  9. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/amountUtils.js.html +3 -3
  10. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/errorUtils.js.html +3 -3
  11. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/apiGroups.js.html +3 -3
  12. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/index.html +3 -3
  13. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/external-apis/ipAddressProviders.js.html +3 -3
  14. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/fiatCurrenciesService.js.html +3 -3
  15. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/globalConstants.jsx.html +3 -3
  16. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/index.html +3 -3
  17. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/blockchain.js.html +3 -3
  18. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/coin.js.html +3 -3
  19. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/index.html +3 -3
  20. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/models/protocol.js.html +3 -3
  21. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/cache.js.html +8 -8
  22. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/emailAPI.js.html +3 -3
  23. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/index.html +3 -3
  24. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/index.html +3 -3
  25. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logger.js.html +3 -3
  26. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/logging/logsStorage.js.html +3 -3
  27. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/postponeExecution.js.html +3 -3
  28. package/coverage/{rabbit-ui-kit → ui-kit}/src/common-apis/utils/safeStringify.js.html +3 -3
  29. package/coverage/{rabbit-ui-kit → ui-kit}/src/index.html +3 -3
  30. package/coverage/{rabbit-ui-kit → ui-kit}/src/index.js.html +3 -3
  31. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +3 -3
  32. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +3 -3
  33. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/cancelProcessing.js.html +3 -3
  34. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +3 -3
  35. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalApiProvider.js.html +3 -3
  36. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/externalServicesStatsCollector.js.html +3 -3
  37. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/index.html +3 -3
  38. package/coverage/{rabbit-ui-kit → ui-kit}/src/robust-api-caller/robustExternalAPICallerService.js.html +3 -3
  39. package/coverage/ui-kit/src/swaps-lib/external-apis/index.html +146 -0
  40. package/coverage/ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1456 -0
  41. package/coverage/ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1390 -0
  42. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +45 -585
  43. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/baseSwapCreationInfo.js.html +3 -3
  44. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwap.js.html +3 -3
  45. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/existingSwapWithFiatData.js.html +3 -3
  46. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/models/index.html +3 -3
  47. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/index.html +7 -7
  48. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/services/publicSwapService.js.html +233 -50
  49. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/index.html +13 -13
  50. package/coverage/{rabbit-ui-kit → ui-kit}/src/swaps-lib/utils/swapUtils.js.html +121 -46
  51. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +3 -3
  52. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +3 -3
  53. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +3 -3
  54. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +3 -3
  55. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +3 -3
  56. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +3 -3
  57. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/index.html +3 -3
  58. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +3 -3
  59. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +3 -3
  60. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +3 -3
  61. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +3 -3
  62. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +3 -3
  63. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetIcon/index.html +3 -3
  64. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +3 -3
  65. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/AssetSelection/index.html +3 -3
  66. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +3 -3
  67. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/BackgroundTitle/index.html +3 -3
  68. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +3 -3
  69. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/InformationMessage/index.html +3 -3
  70. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/Input.jsx.html +3 -3
  71. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Input/index.html +3 -3
  72. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +3 -3
  73. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/LoadingDots/index.html +3 -3
  74. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +3 -3
  75. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/NoticeIcon/index.html +3 -3
  76. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +52 -7
  77. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/QrCode/index.html +7 -7
  78. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +3 -3
  79. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/RateSelector/index.html +3 -3
  80. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +3 -3
  81. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/SupportChat/index.html +3 -3
  82. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +3 -3
  83. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Textarea/index.html +3 -3
  84. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +3 -3
  85. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TitleBox/index.html +3 -3
  86. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +3 -3
  87. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Tooltip/index.html +3 -3
  88. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +3 -3
  89. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/TwoLinesOfText/index.html +3 -3
  90. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/Validation.jsx.html +3 -3
  91. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/Validation/index.html +3 -3
  92. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +3 -3
  93. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Button/index.html +3 -3
  94. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +3 -3
  95. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/Close/index.html +3 -3
  96. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +3 -3
  97. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/LinkButton/index.html +3 -3
  98. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +3 -3
  99. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +3 -3
  100. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +3 -3
  101. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/AmountInput/index.html +3 -3
  102. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +3 -3
  103. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/CoinPicker/index.html +3 -3
  104. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +3 -3
  105. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/LineWithIconLink/index.html +3 -3
  106. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +3 -3
  107. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +3 -3
  108. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +3 -3
  109. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +3 -3
  110. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +3 -3
  111. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +3 -3
  112. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +3 -3
  113. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +3 -3
  114. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +3 -3
  115. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/Dialog/index.html +3 -3
  116. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +171 -39
  117. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/organisms/SwapForm/index.html +7 -7
  118. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +3 -3
  119. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +3 -3
  120. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/index.html +3 -3
  121. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useCallHandlingErrors.js.html +3 -3
  122. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useIsHydrated.js.html +3 -3
  123. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/hooks/useReferredState.js.html +3 -3
  124. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/index.html +3 -3
  125. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/inputValueProviders.js.html +3 -3
  126. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/textUtils.js.html +3 -3
  127. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/uiUtils.js.html +3 -3
  128. package/coverage/{rabbit-ui-kit → ui-kit}/src/ui-kit/utils/urlQueryUtils.js.html +3 -3
  129. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/BackgroundTitle.stories.jsx.html +3 -3
  130. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LinesOfText.stories.jsx.html +3 -3
  131. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/LoadingDots.stories.jsx.html +3 -3
  132. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/QrCode.stories.jsx.html +3 -3
  133. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/RateSelector.stories.jsx.html +3 -3
  134. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/Validation.stories.jsx.html +3 -3
  135. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Button.stories.jsx.html +3 -3
  136. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/Close.stories.jsx.html +3 -3
  137. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/LinkButton.stories.jsx.html +3 -3
  138. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/buttons/index.html +3 -3
  139. package/coverage/{rabbit-ui-kit → ui-kit}/stories/atoms/index.html +3 -3
  140. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/LineWithIconLink.stories.jsx.html +3 -3
  141. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/TitledLineWithIconLink.stories.jsx.html +3 -3
  142. package/coverage/{rabbit-ui-kit → ui-kit}/stories/molecules/index.html +3 -3
  143. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/Dialog.stories.jsx.html +3 -3
  144. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +3 -3
  145. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogButtons/index.html +3 -3
  146. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +3 -3
  147. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/DialogStep/index.html +3 -3
  148. package/coverage/{rabbit-ui-kit → ui-kit}/stories/organisms/Dialog/index.html +3 -3
  149. package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/exampleContent.jsx.html +3 -3
  150. package/coverage/{rabbit-ui-kit → ui-kit}/stories/stubs/index.html +3 -3
  151. package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +3 -3
  152. package/coverage/{rabbit-ui-kit → ui-kit}/stories/templates/index.html +3 -3
  153. package/coverage/ui-kit/storybook-static/124.c2d01e5e.iframe.bundle.js.html +85 -0
  154. package/coverage/ui-kit/storybook-static/138.56b7edc4.iframe.bundle.js.html +85 -0
  155. package/coverage/ui-kit/storybook-static/312.6f62bbd9.iframe.bundle.js.html +85 -0
  156. package/coverage/ui-kit/storybook-static/341.57a15f57.iframe.bundle.js.html +85 -0
  157. package/coverage/ui-kit/storybook-static/370.73bb343e.iframe.bundle.js.html +85 -0
  158. package/coverage/ui-kit/storybook-static/595.2e40d981.iframe.bundle.js.html +85 -0
  159. package/coverage/ui-kit/storybook-static/607.3ea32459.iframe.bundle.js.html +85 -0
  160. package/coverage/ui-kit/storybook-static/609.8c79ec77.iframe.bundle.js.html +85 -0
  161. package/coverage/ui-kit/storybook-static/666.09fdc1d7.iframe.bundle.js.html +85 -0
  162. package/coverage/ui-kit/storybook-static/797.c87cdf19.iframe.bundle.js.html +85 -0
  163. package/coverage/ui-kit/storybook-static/822.4bc0ebce.iframe.bundle.js.html +85 -0
  164. package/coverage/ui-kit/storybook-static/833.08e3ebb6.iframe.bundle.js.html +85 -0
  165. package/coverage/ui-kit/storybook-static/862.bf6bfe62.iframe.bundle.js.html +85 -0
  166. package/coverage/ui-kit/storybook-static/87.0a1bfeb1.iframe.bundle.js.html +85 -0
  167. package/coverage/ui-kit/storybook-static/893.4b09f929.iframe.bundle.js.html +85 -0
  168. package/coverage/ui-kit/storybook-static/996.846a677b.iframe.bundle.js.html +85 -0
  169. package/coverage/ui-kit/storybook-static/atoms-BackgroundTitle-stories.1a5386a1.iframe.bundle.js.html +85 -0
  170. package/coverage/ui-kit/storybook-static/atoms-LinesOfText-stories.7043a48b.iframe.bundle.js.html +85 -0
  171. package/coverage/ui-kit/storybook-static/atoms-LoadingDots-stories.091245c7.iframe.bundle.js.html +85 -0
  172. package/coverage/ui-kit/storybook-static/atoms-QrCode-stories.e10363b6.iframe.bundle.js.html +85 -0
  173. package/coverage/ui-kit/storybook-static/atoms-RateSelector-stories.af208e9a.iframe.bundle.js.html +85 -0
  174. package/coverage/ui-kit/storybook-static/atoms-Validation-stories.d561b311.iframe.bundle.js.html +85 -0
  175. package/coverage/ui-kit/storybook-static/atoms-buttons-Button-stories.e8e6b930.iframe.bundle.js.html +85 -0
  176. package/coverage/ui-kit/storybook-static/atoms-buttons-Close-stories.0a902a7c.iframe.bundle.js.html +85 -0
  177. package/coverage/ui-kit/storybook-static/atoms-buttons-LinkButton-stories.ca93ab6b.iframe.bundle.js.html +85 -0
  178. package/coverage/ui-kit/storybook-static/index.html +596 -0
  179. package/coverage/ui-kit/storybook-static/main.41f410f2.iframe.bundle.js.html +85 -0
  180. package/coverage/ui-kit/storybook-static/molecules-LineWithIconLink-stories.9721a18c.iframe.bundle.js.html +85 -0
  181. package/coverage/ui-kit/storybook-static/molecules-TitledLineWithIconLink-stories.1383fe3f.iframe.bundle.js.html +85 -0
  182. package/coverage/ui-kit/storybook-static/organisms-Dialog-Dialog-stories.4e6da717.iframe.bundle.js.html +85 -0
  183. package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogButtons-DialogButtons-stories.6f45ae6e.iframe.bundle.js.html +85 -0
  184. package/coverage/ui-kit/storybook-static/organisms-Dialog-DialogStep-DialogStep-stories.74896048.iframe.bundle.js.html +85 -0
  185. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/index.html +116 -0
  186. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/addon-backgrounds/dist/preview.js.html +118 -0
  187. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/formatter-SWP5E3XI.mjs.html +118 -0
  188. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/@storybook/components/dist/index.html +116 -0
  189. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.html +116 -0
  190. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/buffer/index.js.html +118 -0
  191. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.html +116 -0
  192. package/coverage/ui-kit/storybook-static/rabbitio/ui-kit/node_modules/markdown-to-jsx/dist/index.modern.js.html +118 -0
  193. package/coverage/ui-kit/storybook-static/runtime~main.ad918f38.iframe.bundle.js.html +85 -0
  194. package/coverage/ui-kit/storybook-static/sb-addons/actions-9/index.html +116 -0
  195. package/coverage/ui-kit/storybook-static/sb-addons/actions-9/manager-bundle.js.html +94 -0
  196. package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/index.html +116 -0
  197. package/coverage/ui-kit/storybook-static/sb-addons/essentials-backgrounds-2/manager-bundle.js.html +121 -0
  198. package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/index.html +116 -0
  199. package/coverage/ui-kit/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.html +274 -0
  200. package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/index.html +116 -0
  201. package/coverage/ui-kit/storybook-static/sb-addons/essentials-measure-4/manager-bundle.js.html +94 -0
  202. package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/index.html +116 -0
  203. package/coverage/ui-kit/storybook-static/sb-addons/essentials-outline-5/manager-bundle.js.html +94 -0
  204. package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/index.html +116 -0
  205. package/coverage/ui-kit/storybook-static/sb-addons/essentials-toolbars-3/manager-bundle.js.html +94 -0
  206. package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/index.html +116 -0
  207. package/coverage/ui-kit/storybook-static/sb-addons/interactions-7/manager-bundle.js.html +121 -0
  208. package/coverage/ui-kit/storybook-static/sb-addons/links-0/index.html +116 -0
  209. package/coverage/ui-kit/storybook-static/sb-addons/links-0/manager-bundle.js.html +94 -0
  210. package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/index.html +116 -0
  211. package/coverage/ui-kit/storybook-static/sb-addons/onboarding-6/manager-bundle.js.html +1588 -0
  212. package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/index.html +116 -0
  213. package/coverage/ui-kit/storybook-static/sb-addons/viewport-8/manager-bundle.js.html +94 -0
  214. package/coverage/ui-kit/storybook-static/sb-manager/WithTooltip-V3YHNWJZ-LVYLGZW2.js.html +88 -0
  215. package/coverage/ui-kit/storybook-static/sb-manager/chunk-2IXBUOFS.js.html +106 -0
  216. package/coverage/ui-kit/storybook-static/sb-manager/chunk-INSKDKQB.js.html +1129 -0
  217. package/coverage/ui-kit/storybook-static/sb-manager/chunk-NGTUFCUO.js.html +112 -0
  218. package/coverage/ui-kit/storybook-static/sb-manager/chunk-UUEAOBSN.js.html +1303 -0
  219. package/coverage/ui-kit/storybook-static/sb-manager/chunk-ZEU7PDD3.js.html +88 -0
  220. package/coverage/ui-kit/storybook-static/sb-manager/formatter-SWP5E3XI-7BGIK6BL.js.html +553 -0
  221. package/coverage/ui-kit/storybook-static/sb-manager/globals-module-info.js.html +88 -0
  222. package/coverage/ui-kit/storybook-static/sb-manager/globals.js.html +88 -0
  223. package/coverage/ui-kit/storybook-static/sb-manager/index.html +281 -0
  224. package/coverage/ui-kit/storybook-static/sb-manager/index.js.html +88 -0
  225. package/coverage/ui-kit/storybook-static/sb-manager/runtime.js.html +88 -0
  226. package/coverage/ui-kit/storybook-static/sb-manager/syntaxhighlighter-V7JZZA35-DXZCI2WR.js.html +88 -0
  227. package/coverage/ui-kit/storybook-static/sb-preview/globals.js.html +88 -0
  228. package/coverage/ui-kit/storybook-static/sb-preview/index.html +131 -0
  229. package/coverage/ui-kit/storybook-static/sb-preview/runtime.js.html +421 -0
  230. package/coverage/ui-kit/storybook-static/templates-DeterminedErrorDialogStep-stories.3cc14214.iframe.bundle.js.html +85 -0
  231. package/dist/index.cjs +1201 -605
  232. package/dist/index.cjs.map +1 -1
  233. package/dist/index.css +1 -1
  234. package/dist/index.css.map +1 -1
  235. package/dist/index.modern.js +786 -330
  236. package/dist/index.modern.js.map +1 -1
  237. package/dist/index.module.js +1201 -605
  238. package/dist/index.module.js.map +1 -1
  239. package/dist/index.umd.js +1201 -605
  240. package/dist/index.umd.js.map +1 -1
  241. package/package.json +1 -1
  242. package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +457 -0
  243. package/src/swaps-lib/external-apis/swapProvider.js +246 -20
  244. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +20 -200
  245. package/src/swaps-lib/services/publicSwapService.js +105 -44
  246. package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +142 -0
  247. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +2 -2
  248. package/src/swaps-lib/utils/swapUtils.js +63 -38
  249. package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +16 -1
  250. package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +77 -33
  251. package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +1 -1
  252. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +0 -131
  253. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +0 -712
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbitio/ui-kit",
3
- "version": "1.0.0-beta.72",
3
+ "version": "1.0.0-beta.74",
4
4
  "description": "Rabbit.io react.js components kit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -0,0 +1,457 @@
1
+ import axios from "axios";
2
+ import { BigNumber } from "bignumber.js";
3
+ import { AmountUtils } from "../../common-apis/amountUtils.js";
4
+ import { improveAndRethrow } from "../../common-apis/errorUtils.js";
5
+ import { SwapProvider } from "./swapProvider.js";
6
+ import { ExistingSwap } from "../models/existingSwap.js";
7
+ import { Coin } from "../../common-apis/models/coin.js";
8
+ import { Protocol } from "../../common-apis/models/protocol.js";
9
+ import { safeStringify } from "../../common-apis/utils/safeStringify.js";
10
+ import { Logger } from "../../common-apis/utils/logging/logger.js";
11
+ import { DEFAULT_CRYPTO_DECIMAL_COUNT, FALLBACK_ASSET_ICON_URL } from "../../common-apis/globalConstants.jsx";
12
+
13
+ export class LetsExchangeSwapProvider extends SwapProvider {
14
+ constructor(apiKeysProxyUrl, cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
15
+ super(cache, customCoinBuilder, useRestrictedCoinsSet);
16
+ this._partners = [];
17
+ this._URL = `${apiKeysProxyUrl}/letsexchange`;
18
+ this.isAggregator = false;
19
+ this.COINS_EXPIRATION_TIME_MS = 5 * 60 * 1000;
20
+ this.coinsLastUpdateTimestamp = null;
21
+ }
22
+
23
+ static AFFILIATE_ID = "0zbj9hf7xg7jgdgv";
24
+
25
+ getSwapCreationInfoTtlMs() {
26
+ return 110000;
27
+ }
28
+
29
+ async _fetchSupportedCurrenciesIfNeeded() {
30
+ const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
31
+ try {
32
+ if (
33
+ !this._supportedCoins?.length ||
34
+ !this.coinsLastUpdateTimestamp ||
35
+ this.coinsLastUpdateTimestamp + this.COINS_EXPIRATION_TIME_MS < Date.now()
36
+ ) {
37
+ const rawResponse = await axios.get(`${this._URL}/v2/coins`);
38
+ Logger.log(`Retrieved ${rawResponse?.data?.length}`, loggerSource);
39
+ let allowedCoins = rawResponse?.data ?? [];
40
+ Logger.log(`Allowed cnt ${allowedCoins.length}`, loggerSource);
41
+
42
+ this._supportedCoins = allowedCoins
43
+ .map(item => {
44
+ const code = item.code.toUpperCase();
45
+
46
+ if (!Array.isArray(item.networks)) return [];
47
+
48
+ return item.networks.map(networkDetails => {
49
+ const network = networkDetails.code.toUpperCase();
50
+ let coin = this._customCoinBuilder(code, network);
51
+ if (!coin && !this.useRestrictedCoinsSet) {
52
+ let name = this.removeProtocolNameFromCoinName(item.name, code, network);
53
+ const ticker = `${code}${code === network ? "" : network}`;
54
+ const defaultDecimalPlacesForCoinNotSupportedOOB = DEFAULT_CRYPTO_DECIMAL_COUNT;
55
+ const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
56
+ coin = new Coin(
57
+ name,
58
+ ticker,
59
+ code,
60
+ defaultDecimalPlacesForCoinNotSupportedOOB,
61
+ null,
62
+ "",
63
+ null,
64
+ null,
65
+ defaultMinConfirmationsForCoinNotSupportedOOB,
66
+ null,
67
+ [],
68
+ 60000,
69
+ null,
70
+ code !== network ? new Protocol(network) : null,
71
+ item.contract_address || null,
72
+ false
73
+ );
74
+ }
75
+ if (coin) {
76
+ return {
77
+ coin: coin,
78
+ code: item.code,
79
+ network: networkDetails.code,
80
+ hasExtraId: !!networkDetails.has_extra,
81
+ extraIdName: networkDetails.extra_name ?? null,
82
+ isPopular: item.rating || 0,
83
+ iconURL: item.icon ? item.icon : FALLBACK_ASSET_ICON_URL,
84
+ deposit: true, // Letsexchange provide no such details
85
+ withdrawal: true, // Letsexchange provide no such details
86
+ validationRegexp: networkDetails.validation_address_regex ?? null,
87
+ isAvailable:
88
+ (typeof item.is_active !== "number" || item.is_active === 1) &&
89
+ (typeof item.disabled !== "number" || item.disabled === 0) &&
90
+ (typeof networkDetails.is_active !== "number" ||
91
+ networkDetails.is_active === 1),
92
+ };
93
+ }
94
+ return [];
95
+ });
96
+ })
97
+ .flat();
98
+ this.coinsLastUpdateTimestamp = Date.now();
99
+ this._putPopularCoinsFirst();
100
+ }
101
+ } catch (e) {
102
+ improveAndRethrow(e, loggerSource);
103
+ }
104
+ }
105
+
106
+ async getSwapInfo(
107
+ fromCoin,
108
+ toCoin,
109
+ amountCoins,
110
+ fixed = false,
111
+ fromCoinToUsdRate = null,
112
+ amountIsToReceive = false
113
+ ) {
114
+ const loggerSource = "getSwapInfo";
115
+ try {
116
+ if (
117
+ !(fromCoin instanceof Coin) ||
118
+ !(toCoin instanceof Coin) ||
119
+ typeof amountCoins !== "string" ||
120
+ BigNumber(amountCoins).lt("0") ||
121
+ (fixed !== null && typeof fixed !== "boolean") ||
122
+ (amountIsToReceive && !fixed)
123
+ ) {
124
+ throw new Error(
125
+ `Wrong input params: ${amountCoins} ${fromCoin.ticker} -> ${toCoin.ticker}, ${
126
+ fromCoin instanceof Coin
127
+ }, ${toCoin instanceof Coin}, ${typeof fixed} ${fixed}, ${amountIsToReceive}`
128
+ );
129
+ }
130
+ const fromCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
131
+ const toCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
132
+ if (!fromCoinDetails || !toCoinDetails) {
133
+ throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
134
+ }
135
+ if (
136
+ !fromCoinDetails.deposit ||
137
+ !fromCoinDetails.isAvailable ||
138
+ !toCoinDetails.withdrawal ||
139
+ !toCoinDetails.isAvailable
140
+ ) {
141
+ return {
142
+ result: false,
143
+ reason: SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED,
144
+ };
145
+ }
146
+
147
+ const pathAndQuery = `/v1/info${amountIsToReceive ? "-revert" : `?float=${!fixed}`}`;
148
+ const response = await axios.post(`${this._URL}${pathAndQuery}`, {
149
+ from: fromCoinDetails.code,
150
+ to: toCoinDetails.code,
151
+ network_from: fromCoinDetails.network,
152
+ network_to: toCoinDetails.network,
153
+ amount: amountCoins,
154
+ affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID,
155
+ });
156
+ Logger.log(`Retrieved ${response?.data}`, loggerSource);
157
+ const data = response.data;
158
+
159
+ // TODO: [dev] add SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING - request alternative rate. task_id=
160
+
161
+ // TODO: [feature, low] implement extra coins to fit min/max if there are frequent errors due to min/max exceeding
162
+ // let extraCoinsToFitMinMax = "0";
163
+ // if (typeof fromCoinToUsdRate === "string" && BigNumber(fromCoinToUsdRate).gt("0")) {
164
+ // const extraUsdToFitMinMax = BigNumber("1"); // We correct the limits as the exact limit can fluctuate and cause failed swap creation
165
+ // extraCoinsToFitMinMax = AmountUtils.trim(extraUsdToFitMinMax.div(fromCoinToUsdRate), fromCoin.digits);
166
+ // }
167
+ let min = null;
168
+ if (data?.min_amount) {
169
+ min = AmountUtils.trim(data?.min_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
170
+ }
171
+ let max = null;
172
+ if (data?.max_amount) {
173
+ max = AmountUtils.trim(data?.max_amount, amountIsToReceive ? toCoin.digits : fromCoin.digits);
174
+ }
175
+
176
+ if (data.success === false && data.error) {
177
+ // TODO: [dev] waiting for response from letsexchange about their not-documented responses
178
+ // {
179
+ // "success": false,
180
+ // "error": "Internal error"
181
+ // }
182
+ throw new Error("Failed to estimate swap letsexchange");
183
+ }
184
+
185
+ if (BigNumber(data.rate).eq("0") || BigNumber(data.amount).eq("0")) {
186
+ // TODO actualize according to letsexchage clarification - decide, can we count on min/max abcense? task_id=76512110797f4eab8b37f1bb789825cb
187
+ // amount: "0", rate: "0", rate_id: ""
188
+ let reason = SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED;
189
+ if (min && BigNumber(amountCoins).lt(min)) {
190
+ reason = SwapProvider.NO_SWAPS_REASONS.TOO_LOW;
191
+ } else if (max && BigNumber(amountCoins).gt(max)) {
192
+ reason = SwapProvider.NO_SWAPS_REASONS.TOO_HIGH;
193
+ } else if (!amountIsToReceive) {
194
+ // If we are not requesting receiving amount (it cannot be floating-rate)
195
+ // todo [feature, moderate] request alternative rate. task_id=31884db5392f49738c20a86115c90e1f
196
+ // const alternativeRate = 1;
197
+ // const alternativeRateAvailable = alternativeRate;
198
+ // if (alternativeRateAvailable) {
199
+ // reason = fixed
200
+ // ? SwapProvider.NO_SWAPS_REASONS.NO_FIXED_BUT_HAVE_FLOATING
201
+ // : SwapProvider.NO_SWAPS_REASONS.NO_FLOATING_BUT_HAVE_FIXED;
202
+ // }
203
+ }
204
+ return {
205
+ result: false,
206
+ reason: reason,
207
+ smallestMin: min,
208
+ greatestMax: max,
209
+ };
210
+ }
211
+ const rate = amountIsToReceive
212
+ ? BigNumber(amountCoins).div(data.amount)
213
+ : BigNumber(data.amount).div(amountCoins);
214
+ return {
215
+ result: true,
216
+ min: min,
217
+ max: max,
218
+ smallestMin: min,
219
+ greatestMax: max,
220
+ rate: AmountUtils.trim(rate, this._maxRateDigits),
221
+ durationMinutesRange: null,
222
+ fixed: fixed,
223
+ rawSwapData: data,
224
+ isRefundAddressRequired: false,
225
+ };
226
+ } catch (e) {
227
+ if (e?.response?.status === 429) {
228
+ return {
229
+ result: false,
230
+ reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
231
+ };
232
+ }
233
+ Logger.log(`Internal error when getting swap options ${safeStringify(e)}`, loggerSource);
234
+ improveAndRethrow(e, loggerSource);
235
+ }
236
+ }
237
+
238
+ async createSwap(
239
+ fromCoin,
240
+ toCoin,
241
+ amount,
242
+ toAddress,
243
+ refundAddress,
244
+ rawSwapData,
245
+ clientIpAddress,
246
+ fixed,
247
+ toCurrencyExtraId = "",
248
+ refundExtraId = "",
249
+ amountIsToReceive = false
250
+ ) {
251
+ const loggerSource = "createSwap";
252
+ try {
253
+ if (
254
+ !(fromCoin instanceof Coin) ||
255
+ !(toCoin instanceof Coin) ||
256
+ typeof amount !== "string" ||
257
+ typeof toAddress !== "string" ||
258
+ typeof refundAddress !== "string" ||
259
+ typeof clientIpAddress != "string" ||
260
+ typeof fixed != "boolean"
261
+ ) {
262
+ throw new Error(
263
+ `Invalid input: ${fromCoin} ${toCoin} ${amount} ${toAddress} ${refundAddress} ${fixed}`
264
+ );
265
+ }
266
+ if (typeof rawSwapData !== "object" || (fixed && !rawSwapData.rate_id)) {
267
+ throw new Error(`Invalid raw swap data: ${safeStringify(rawSwapData)}`);
268
+ }
269
+ const fromCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === fromCoin?.ticker);
270
+ const toCoinDetails = this._supportedCoins.find(i => i.coin?.ticker === toCoin?.ticker);
271
+ if (!fromCoinDetails || !toCoinDetails) {
272
+ throw new Error("Failed to find coin details for: " + fromCoin.ticker + " -> " + toCoin.ticker);
273
+ }
274
+ const requestBody = {
275
+ coin_from: fromCoinDetails.code,
276
+ network_from: fromCoinDetails.network,
277
+ coin_to: toCoinDetails.code,
278
+ network_to: toCoinDetails.network,
279
+ withdrawal: toAddress,
280
+ withdrawal_extra_id: toCurrencyExtraId,
281
+ return: refundAddress,
282
+ return_extra_id: refundExtraId,
283
+ affiliate_id: LetsExchangeSwapProvider.AFFILIATE_ID,
284
+ };
285
+ if (amountIsToReceive) {
286
+ requestBody.withdrawal_amount = amount;
287
+ } else {
288
+ requestBody.deposit_amount = amount;
289
+ }
290
+ if (fixed) {
291
+ requestBody.rate_id = rawSwapData.rate_id;
292
+ }
293
+ const response = await axios.post(
294
+ `${this._URL}/v1/transaction${amountIsToReceive ? "-revert" : `?float=${!fixed}`}`,
295
+ requestBody
296
+ );
297
+ const result = response.data;
298
+ Logger.log(`Creation result ${safeStringify(result)}`, loggerSource);
299
+
300
+ if (result?.transaction_id) {
301
+ const rate = BigNumber(result.rate ?? 0).isZero()
302
+ ? BigNumber(result.withdrawal_amount).div(result.deposit_amount)
303
+ : BigNumber(result.rate);
304
+
305
+ return {
306
+ result: true,
307
+ swapId: result.transaction_id,
308
+ fromCoin: fromCoin,
309
+ fromAmount: AmountUtils.trim(result.deposit_amount, fromCoin.digits),
310
+ fromAddress: result.deposit,
311
+ toCoin: toCoin,
312
+ toAmount: AmountUtils.trim(result.withdrawal_amount, toCoin.digits),
313
+ toAddress: result.withdrawal,
314
+ fromCurrencyExtraId: result.deposit_extra_id ?? "",
315
+ rate: AmountUtils.trim(rate, this._maxRateDigits),
316
+ fixed: !result.is_float,
317
+ };
318
+ }
319
+
320
+ const errorMessage = `Swap creation succeeded but the response is wrong: ${safeStringify(response)}`;
321
+ Logger.log(errorMessage, loggerSource);
322
+ throw new Error(errorMessage);
323
+ } catch (e) {
324
+ Logger.logError(e, loggerSource, `Failed to create swap. Error is: ${safeStringify(e)}`);
325
+ const composeFailResult = reason => ({
326
+ result: false,
327
+ reason: reason,
328
+ });
329
+ const status = e?.response?.status;
330
+ const data = e?.response?.data;
331
+ if (status === 429) {
332
+ Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
333
+ return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
334
+ }
335
+ // TODO: [feature, low] add custom errors handling - waiting for response from letsexchange. task_id=00d2e435f6df4fb99af912135bd9ee27
336
+ // 422 - missing params
337
+ Logger.log(`Internal error for swap: ${safeStringify(e)}`, loggerSource);
338
+ improveAndRethrow(e, loggerSource);
339
+ }
340
+ }
341
+
342
+ async getExistingSwapsDetailsAndStatus(swapIds) {
343
+ const loggerSource = "getExistingSwapsDetailsAndStatus";
344
+ try {
345
+ if (swapIds.find(id => typeof id !== "string")) {
346
+ throw new Error("Swap id is not string: " + safeStringify(swapIds));
347
+ }
348
+ const response = await axios.get(`${this._URL}/v1/transactions-list?ids[]=${swapIds.join("&ids[]=")}`);
349
+
350
+ Logger.log("All swaps RAW: " + safeStringify(response.data), loggerSource);
351
+ const swaps = response.data
352
+ .map((swap, index) => {
353
+ const fromCoin = this._supportedCoins.find(
354
+ i => i.code === swap.coin_from && i.network === swap.coin_from_network
355
+ )?.coin;
356
+ const toCoin = this._supportedCoins.find(
357
+ i => i.code === swap.coin_to && i.network === swap.coin_to_network
358
+ )?.coin;
359
+ if (!fromCoin || !toCoin) {
360
+ return []; // We skip swaps with not supported coins for now
361
+ }
362
+
363
+ const toUtcTimestamp = timeStr => Date.parse(timeStr.match(/.+[Zz]$/) ? timeStr : `${timeStr}Z`);
364
+ const expiresAt = swap.expired_at ? swap.expired_at * 1000 : null;
365
+ const createdAt = swap.created_at ? toUtcTimestamp(`${swap.created_at}`) : null;
366
+ const isExpiredByTime = expiresAt && expiresAt < Date.now();
367
+ const status = this._mapLetsExchangeStatusToRabbitStatus(swap.status, isExpiredByTime);
368
+ const toDigits = status === SwapProvider.SWAP_STATUSES.REFUNDED ? fromCoin.digits : toCoin.digits;
369
+ return new ExistingSwap(
370
+ swapIds[index],
371
+ status,
372
+ createdAt,
373
+ expiresAt,
374
+ swap.confirmations,
375
+ AmountUtils.trim(swap.rate, this._maxRateDigits),
376
+ swap.is_float != null ? !swap.is_float : false,
377
+ swap.return,
378
+ swap.deposit,
379
+ fromCoin,
380
+ AmountUtils.trim(swap.deposit_amount, fromCoin.digits),
381
+ swap.hash_in,
382
+ swap.hash_in ? `${swap.coin_from_explorer_url}${swap.hash_in}` : null,
383
+ toCoin,
384
+ AmountUtils.trim(swap.withdrawal_amount, toDigits),
385
+ swap.hash_out,
386
+ swap.hash_out ? `${swap.coin_to_explorer_url}${swap.hash_out}` : null,
387
+ swap.withdrawal,
388
+ "letsexchange",
389
+ swap.deposit_extra_id ?? null,
390
+ swap.withdrawal_extra_id ?? null,
391
+ swap.return_extra_id ?? null
392
+ );
393
+ })
394
+ .flat();
395
+ Logger.log(`Swap details result ${safeStringify(swaps)}`, loggerSource);
396
+ return { result: true, swaps: swaps };
397
+ } catch (e) {
398
+ Logger.logError(e, loggerSource, `Failed to get swap details. Error is: ${safeStringify(e)}`);
399
+ const composeFailResult = reason => ({
400
+ result: false,
401
+ reason: reason,
402
+ });
403
+ const status = e?.response?.status;
404
+ const data = e?.response?.data;
405
+ if (status === 429) {
406
+ Logger.log(`Returning fail - RPS limit exceeded ${data}`, loggerSource);
407
+ return composeFailResult(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
408
+ }
409
+ improveAndRethrow(e, loggerSource);
410
+ }
411
+ }
412
+
413
+ // TODO: [dev] Serg, please check this during the review to make sure I did no mistakes in statuses mapping.
414
+ // I will remove these comments after the review. https://api.letsexchange.io/doc
415
+ // wait The exchange has just been created and it’s waiting for coins to reach the deposit wallet
416
+ // confirmation The transaction appears in mempool and now it is waiting for necessary network confirmations to start.
417
+ // confirmed The user’s payment is confirmed, the exchange process is about to start.
418
+ // exchanging The exchange process is running.
419
+ // sending Funds are being sent to the recipient`s address.
420
+ // sending_confirmation The outgoing transaction is waiting for network confirmations.
421
+ // success The exchange is completed and the funds are successfully sent to the recipient’s address.
422
+ // aml_check_failed The deposit was marked as risky by AML check service.
423
+ // overdue The deposit receiving time for this transaction has expired.
424
+ // error The transaction has failed. In most cases, the amount that was sent differs from the amount that was specified when creating the transaction.
425
+ // refund The exchange failed and the coins were refunded to the user's wallet.
426
+ _mapLetsExchangeStatusToRabbitStatus(status, isExpiredByTime) {
427
+ switch (status) {
428
+ case "wait":
429
+ if (isExpiredByTime) {
430
+ return SwapProvider.SWAP_STATUSES.EXPIRED;
431
+ }
432
+ return SwapProvider.SWAP_STATUSES.WAITING_FOR_PAYMENT;
433
+ case "confirmation":
434
+ return SwapProvider.SWAP_STATUSES.CONFIRMING;
435
+ case "confirmed":
436
+ return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
437
+ case "exchanging":
438
+ return SwapProvider.SWAP_STATUSES.EXCHANGING;
439
+ case "sending":
440
+ return SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED;
441
+ case "sending_confirmation":
442
+ return SwapProvider.SWAP_STATUSES.EXCHANGING;
443
+ case "success":
444
+ return SwapProvider.SWAP_STATUSES.COMPLETED;
445
+ case "refund":
446
+ return SwapProvider.SWAP_STATUSES.REFUNDED;
447
+ case "overdue":
448
+ return SwapProvider.SWAP_STATUSES.EXPIRED;
449
+ case "aml_check_failed":
450
+ return SwapProvider.SWAP_STATUSES.EXCHANGING;
451
+ case "error":
452
+ return SwapProvider.SWAP_STATUSES.FAILED;
453
+ default:
454
+ throw new Error(`Unknown LetsExchange status: ${status}`);
455
+ }
456
+ }
457
+ }