@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
@@ -1,4 +1,20 @@
1
+ import { Logger } from "../../common-apis/utils/logging/logger.js";
2
+ import { improveAndRethrow } from "../../common-apis/errorUtils.js";
3
+ import { Coin } from "../../common-apis/models/coin.js";
4
+ import { FALLBACK_ASSET_ICON_URL } from "../../common-apis/globalConstants.jsx";
5
+ import { BigNumber } from "bignumber.js";
6
+
7
+ // TODO: [refactoring, moderate] extract structure of _supportedCoins into model class
1
8
  export class SwapProvider {
9
+ constructor(cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
10
+ this._supportedCoins = [];
11
+ this._maxRateDigits = 20;
12
+ this.useRestrictedCoinsSet = useRestrictedCoinsSet;
13
+ this._customCoinBuilder = customCoinBuilder;
14
+ this._cache = cache;
15
+ this.isAggregator = false;
16
+ }
17
+
2
18
  static COMMON_ERRORS = {
3
19
  REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded",
4
20
  };
@@ -16,21 +32,21 @@ export class SwapProvider {
16
32
  };
17
33
 
18
34
  static SWAP_STATUSES = {
19
- WAITING_FOR_PAYMENT: "waiting_for_payment", // public +
35
+ WAITING_FOR_PAYMENT: "waiting_for_payment",
20
36
  CONFIRMING: "confirming",
21
- PAYMENT_RECEIVED: "payment_received", // public +
22
- EXCHANGING: "exchanging", // session full // public +
23
- COMPLETED: "completed", // session full // public +
24
- REFUNDED: "refunded", // session full // public +
25
- EXPIRED: "expired", // public +
26
- FAILED: "failed", // public +
37
+ PAYMENT_RECEIVED: "payment_received",
38
+ EXCHANGING: "exchanging",
39
+ COMPLETED: "completed",
40
+ REFUNDED: "refunded",
41
+ EXPIRED: "expired",
42
+ FAILED: "failed",
27
43
  };
28
44
 
29
45
  /**
30
46
  * @return {Promise<void>}
31
47
  */
32
48
  async initialize() {
33
- throw new Error("Not implemented in base");
49
+ await this._fetchSupportedCurrenciesIfNeeded();
34
50
  }
35
51
 
36
52
  /**
@@ -40,6 +56,33 @@ export class SwapProvider {
40
56
  throw new Error("Not implemented in base");
41
57
  }
42
58
 
59
+ /**
60
+ * This method sort internal list putting popular (as provider thinks) coins to the top.
61
+ * This is just for users of this API if they don't care about the sorting - we just improve a list a bit this way.
62
+ * @private
63
+ */
64
+ _putPopularCoinsFirst() {
65
+ this._supportedCoins.sort((i1, i2) => {
66
+ if (i1.isPopular !== i2.isPopular) return i2.isPopular - i1.isPopular;
67
+ return i1.coin.ticker.localeCompare(i2.coin.ticker);
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Should fill _supportedCoins with array of coins.
73
+ * Coin construction rules:
74
+ * 1. ticker should be CODEPROTOCOL_CODE e.g. USDTERC20
75
+ * 2. name should not contain (PROTOCOL_CODE) or just PROTOCOL_CODe
76
+ * 3. protocol should be null for coins major for their blockchains like BTC, ETH
77
+ * 4. isPopular should be a number
78
+ *
79
+ * @return {Promise<void>}
80
+ * @private
81
+ */
82
+ async _fetchSupportedCurrenciesIfNeeded() {
83
+ throw new Error("Not implemented in base - _fetchSupportedCurrenciesIfNeeded");
84
+ }
85
+
43
86
  /**
44
87
  * Retrieves all currencies supported by this swap provider.
45
88
  * Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
@@ -47,7 +90,23 @@ export class SwapProvider {
47
90
  * @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
48
91
  */
49
92
  async getAllSupportedCurrencies() {
50
- throw new Error("Not implemented in base");
93
+ const loggerSource = "getAllSupportedCurrencies";
94
+ try {
95
+ await this._fetchSupportedCurrenciesIfNeeded();
96
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins returning`, loggerSource);
97
+ return {
98
+ result: true,
99
+ coins: this._supportedCoins.map(item => item.coin),
100
+ };
101
+ } catch (e) {
102
+ if (e?.response?.status === 429) {
103
+ return {
104
+ result: false,
105
+ reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
106
+ };
107
+ }
108
+ improveAndRethrow(e, loggerSource);
109
+ }
51
110
  }
52
111
 
53
112
  /**
@@ -57,7 +116,23 @@ export class SwapProvider {
57
116
  * @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
58
117
  */
59
118
  async getDepositCurrencies() {
60
- throw new Error("Not implemented in base");
119
+ const loggerSource = "getDepositCurrencies";
120
+ try {
121
+ await this._fetchSupportedCurrenciesIfNeeded();
122
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting depositable`, loggerSource);
123
+ return {
124
+ result: true,
125
+ coins: this._supportedCoins.filter(item => item.deposit).map(item => item.coin),
126
+ };
127
+ } catch (e) {
128
+ if (e?.response?.status === 429) {
129
+ return {
130
+ result: false,
131
+ reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
132
+ };
133
+ }
134
+ improveAndRethrow(e, loggerSource);
135
+ }
61
136
  }
62
137
 
63
138
  /**
@@ -68,17 +143,49 @@ export class SwapProvider {
68
143
  * @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
69
144
  */
70
145
  async getWithdrawalCurrencies(exceptCurrency = null) {
71
- throw new Error("Not implemented in base");
146
+ const loggerSource = "getWithdrawalCurrencies";
147
+ try {
148
+ await this._fetchSupportedCurrenciesIfNeeded();
149
+ Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting withdrawable`, loggerSource);
150
+ return {
151
+ result: true,
152
+ coins: this._supportedCoins
153
+ .filter(
154
+ item => item.withdrawal && (!exceptCurrency || item.coin?.ticker !== exceptCurrency?.ticker)
155
+ )
156
+ .map(item => item.coin),
157
+ };
158
+ } catch (e) {
159
+ if (e?.response?.status === 429) {
160
+ return {
161
+ result: false,
162
+ reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
163
+ };
164
+ }
165
+ improveAndRethrow(e, loggerSource);
166
+ }
72
167
  }
73
168
 
74
169
  /**
75
170
  * Retrieves URL for coin icon or fallback if not found.
76
171
  *
77
- * @param coin {Coin|string} coin or rabbit-format of coin ticker
172
+ * @param coinOrTicker {Coin|string} coin or rabbit-format of coin ticker
78
173
  * @return {string}
79
174
  */
80
- getIconUrl(coin) {
81
- throw new Error("Not implemented in base");
175
+ getIconUrl(coinOrTicker) {
176
+ const loggerSource = "getIconUrl";
177
+ try {
178
+ let coin = coinOrTicker;
179
+ if (!(coinOrTicker instanceof Coin)) {
180
+ coin = this._supportedCoins.find(i => i.coin.ticker === coinOrTicker)?.coin;
181
+ }
182
+ return (
183
+ this._supportedCoins.find(item => item.coin?.ticker === coin?.ticker)?.iconURL ??
184
+ FALLBACK_ASSET_ICON_URL
185
+ );
186
+ } catch (e) {
187
+ improveAndRethrow(e, loggerSource);
188
+ }
82
189
  }
83
190
 
84
191
  /**
@@ -88,7 +195,46 @@ export class SwapProvider {
88
195
  * @return {{result: true, rate: string}|{result: false}}
89
196
  */
90
197
  async getCoinToUSDTRate(coin) {
91
- throw new Error("Not implemented in base");
198
+ const loggerSource = "getCoinToUSDTRate";
199
+ try {
200
+ if (!coin) return null;
201
+
202
+ await this._fetchSupportedCurrenciesIfNeeded();
203
+
204
+ // Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
205
+ const usdtTrc20 = this._supportedCoins.find(i => i.coin.ticker === "USDTTRC20")?.coin;
206
+ if (!usdtTrc20) {
207
+ return { result: false };
208
+ }
209
+ const cached = this._cache.get("swapspace_usdt_rate_" + coin.ticker);
210
+ if (cached != null) {
211
+ return {
212
+ result: true,
213
+ rate: cached,
214
+ };
215
+ }
216
+
217
+ Logger.log("Loading USDT->coin rate as not found in cache:", coin?.ticker);
218
+ const result = await this.getSwapInfo(usdtTrc20, coin, "5000", false);
219
+ if (!result.result) {
220
+ return { result: false };
221
+ }
222
+
223
+ // This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
224
+ const standardSwapspaceFeeMultiplier = 1.004; // fee is usually 0.4%
225
+ const rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
226
+ this._cache.put(
227
+ "swap_usdt_rate_" + coin.ticker,
228
+ rate,
229
+ 15 * 60000 // 15 minutes
230
+ );
231
+ return {
232
+ result: true,
233
+ rate: rate,
234
+ };
235
+ } catch (e) {
236
+ improveAndRethrow(e, loggerSource);
237
+ }
92
238
  }
93
239
 
94
240
  /**
@@ -103,6 +249,7 @@ export class SwapProvider {
103
249
  * @param [fixed=false] {boolean|null} null means fixed or float doesn't matter
104
250
  * @param [fromCoinToUsdRate=null] pass if you want to increase the min amount returned
105
251
  * by provider with some fixed "insurance" amount to cover min amount fluctuations.
252
+ * @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount. False means the amount is the sending amount.
106
253
  * @return {Promise<({
107
254
  * result: false,
108
255
  * reason: string,
@@ -121,7 +268,14 @@ export class SwapProvider {
121
268
  * [rawSwapData]: Object
122
269
  * })>}
123
270
  */
124
- async getSwapInfo(fromCoin, toCoin, amountCoins, fixed = false, fromCoinToUsdRate = null) {
271
+ async getSwapInfo(
272
+ fromCoin,
273
+ toCoin,
274
+ amountCoins,
275
+ fixed = false,
276
+ fromCoinToUsdRate = null,
277
+ amountIsToReceive = false
278
+ ) {
125
279
  throw new Error("Not implemented in base");
126
280
  }
127
281
 
@@ -138,6 +292,7 @@ export class SwapProvider {
138
292
  * @param fixed {boolean}
139
293
  * @param [toCurrencyExtraId=""] {string} optional extra ID
140
294
  * @param [refundExtraId=""] {string} optional extra ID for refund address
295
+ * @param [amountIsToReceive=false] {boolean} whether the given amount is receiving amount. False means the amount is the sending amount.
141
296
  * @return {Promise<({
142
297
  * result: true,
143
298
  * swapId: string,
@@ -166,7 +321,8 @@ export class SwapProvider {
166
321
  clientIpAddress,
167
322
  fixed,
168
323
  toCurrencyExtraId = "",
169
- refundExtraId = ""
324
+ refundExtraId = "",
325
+ amountIsToReceive = false
170
326
  ) {
171
327
  throw new Error("Not implemented in base");
172
328
  }
@@ -187,7 +343,12 @@ export class SwapProvider {
187
343
  * @return {Coin|null}
188
344
  */
189
345
  getCoinByTickerIfPresent(ticker) {
190
- throw new Error("Not implemented in base");
346
+ try {
347
+ const item = this._supportedCoins.find(i => i.coin.ticker === ticker);
348
+ return item?.coin ?? null;
349
+ } catch (e) {
350
+ improveAndRethrow(e, "getCoinByTickerIfPresent");
351
+ }
191
352
  }
192
353
 
193
354
  /**
@@ -196,7 +357,19 @@ export class SwapProvider {
196
357
  * @return {boolean}
197
358
  */
198
359
  isAddressValidForAsset(asset, address) {
199
- throw new Error("Not implemented in base");
360
+ try {
361
+ const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
362
+ if (assetData) {
363
+ let corrected = assetData.validationRegexp.trim();
364
+ corrected = corrected[0] === "/" ? corrected.slice(1) : corrected;
365
+ corrected =
366
+ corrected[corrected.length - 1] === "/" ? corrected.slice(0, corrected.length - 1) : corrected;
367
+ return address.match(corrected) != null;
368
+ }
369
+ } catch (e) {
370
+ Logger.logError(e, "isAddressValidForAsset");
371
+ }
372
+ return false;
200
373
  }
201
374
 
202
375
  /**
@@ -204,6 +377,59 @@ export class SwapProvider {
204
377
  * @return {string|null}
205
378
  */
206
379
  getExtraIdNameIfPresent(asset) {
207
- throw new Error("Not implemented in base");
380
+ try {
381
+ const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
382
+ if (assetData?.hasExtraId) {
383
+ if (assetData?.extraIdName == null || assetData?.extraIdName === "") {
384
+ // We return some default name if the extraIdName is empty
385
+ return "ID";
386
+ }
387
+ return assetData?.extraIdName;
388
+ }
389
+ return null;
390
+ } catch (e) {
391
+ improveAndRethrow(e, "getExtraIdNameIfPresent");
392
+ }
393
+ }
394
+
395
+ removeProtocolNameFromCoinName(coinName, tickerPrintable, protocolName) {
396
+ if (coinName) {
397
+ const originalName = coinName;
398
+ if (tickerPrintable) {
399
+ coinName = coinName.replaceAll(new RegExp(`\\(${tickerPrintable}\\)`, "gi"), "");
400
+ }
401
+ if (protocolName) {
402
+ coinName = coinName
403
+ .replaceAll(new RegExp(`\\(${protocolName}\\)`, "gi"), "")
404
+ .replaceAll(new RegExp(`(?<!on) ${protocolName}$`, "gi"), "")
405
+ .replaceAll(new RegExp(`^${protocolName} `, "gi"), "")
406
+ .replaceAll(new RegExp(`(?<!on) ${protocolName} `, "gi"), " ");
407
+ }
408
+ coinName = coinName.replaceAll(/ +/g, " ").trim();
409
+
410
+ const defaultNames = [
411
+ "token",
412
+ "network",
413
+ "protocol",
414
+ "coin",
415
+ "mainnet",
416
+ "chain",
417
+ "project",
418
+ "cash",
419
+ "finance",
420
+ "wrapped",
421
+ "blockchain",
422
+ "network",
423
+ ];
424
+ const lowerCoinName = coinName.toLowerCase();
425
+ const isBecameDefaultName = defaultNames.find(
426
+ defName => lowerCoinName === defName || lowerCoinName === `the ${defName}`
427
+ );
428
+ if (coinName === "" || isBecameDefaultName) {
429
+ // Rolling back to original name if our processing leads in empty name or one of the default words
430
+ coinName = originalName;
431
+ }
432
+ }
433
+ return coinName;
208
434
  }
209
435
  }
@@ -15,14 +15,10 @@ export const BANNED_PARTNERS = ["stealthex", "changee", "coincraddle"];
15
15
 
16
16
  export class SwapspaceSwapProvider extends SwapProvider {
17
17
  constructor(apiKeysProxyUrl, cache, customCoinBuilder = (coin, network) => null, useRestrictedCoinsSet = true) {
18
- super();
19
- this._supportedCoins = [];
18
+ super(cache, customCoinBuilder, useRestrictedCoinsSet);
20
19
  this._partners = [];
21
- this._URL = `${apiKeysProxyUrl}`;
22
- this._maxRateDigits = 20;
23
- this.useRestrictedCoinsSet = useRestrictedCoinsSet;
24
- this._customCoinBuilder = customCoinBuilder;
25
- this._cache = cache;
20
+ this._URL = `${apiKeysProxyUrl}/swapspace`;
21
+ this.isAggregator = true;
26
22
  }
27
23
 
28
24
  getSwapCreationInfoTtlMs() {
@@ -31,90 +27,6 @@ export class SwapspaceSwapProvider extends SwapProvider {
31
27
  return 110000;
32
28
  }
33
29
 
34
- async getDepositCurrencies() {
35
- const loggerSource = "getDepositCurrencies";
36
- try {
37
- await this._fetchSupportedCurrenciesIfNeeded();
38
- Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting depositable`, loggerSource);
39
- return {
40
- result: true,
41
- coins: this._supportedCoins.filter(item => item.deposit).map(item => item.coin),
42
- };
43
- } catch (e) {
44
- if (e?.response?.status === 429) {
45
- return {
46
- result: false,
47
- reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
48
- };
49
- }
50
- improveAndRethrow(e, loggerSource);
51
- }
52
- }
53
-
54
- async getAllSupportedCurrencies() {
55
- const loggerSource = "getAllSupportedCurrencies";
56
- try {
57
- await this._fetchSupportedCurrenciesIfNeeded();
58
- Logger.log(`We have ${this._supportedCoins?.length} supported coins returning`, loggerSource);
59
- return {
60
- result: true,
61
- coins: this._supportedCoins.map(item => item.coin),
62
- };
63
- } catch (e) {
64
- if (e?.response?.status === 429) {
65
- return {
66
- result: false,
67
- reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
68
- };
69
- }
70
- improveAndRethrow(e, loggerSource);
71
- }
72
- }
73
-
74
- async getWithdrawalCurrencies(exceptCurrency = null) {
75
- const loggerSource = "getWithdrawalCurrencies";
76
- try {
77
- await this._fetchSupportedCurrenciesIfNeeded();
78
- Logger.log(`We have ${this._supportedCoins?.length} supported coins, getting withdrawable`, loggerSource);
79
- return {
80
- result: true,
81
- coins: this._supportedCoins
82
- .filter(
83
- item => item.withdrawal && (!exceptCurrency || item.coin?.ticker !== exceptCurrency?.ticker)
84
- )
85
- .map(item => item.coin),
86
- };
87
- } catch (e) {
88
- if (e?.response?.status === 429) {
89
- return {
90
- result: false,
91
- reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
92
- };
93
- }
94
- improveAndRethrow(e, loggerSource);
95
- }
96
- }
97
-
98
- async initialize() {
99
- await this._fetchSupportedCurrenciesIfNeeded();
100
- }
101
-
102
- getIconUrl(coinOrTicker) {
103
- const loggerSource = "getIconUrl";
104
- try {
105
- let coin = coinOrTicker;
106
- if (!(coinOrTicker instanceof Coin)) {
107
- coin = this._supportedCoins.find(i => i.coin.ticker === coinOrTicker)?.coin;
108
- }
109
- return (
110
- this._supportedCoins.find(item => item.coin?.ticker === coin?.ticker)?.iconURL ??
111
- FALLBACK_ASSET_ICON_URL
112
- );
113
- } catch (e) {
114
- improveAndRethrow(e, loggerSource);
115
- }
116
- }
117
-
118
30
  async _fetchSupportedCurrenciesIfNeeded() {
119
31
  const loggerSource = "_fetchSupportedCurrenciesIfNeeded";
120
32
  try {
@@ -141,15 +53,7 @@ export class SwapspaceSwapProvider extends SwapProvider {
141
53
  /** Removing ticker and protocol name from coin name as we usually use them explicitly
142
54
  * from coin object rather than counting on having it in the coin name itself.
143
55
  * This processing is needed due to poor quality of swapspace coins names. */
144
- let name = (item.name ?? "")
145
- .replaceAll(`(${code})`, "")
146
- .replaceAll(`(${network})`, "")
147
- .replaceAll(/ +/g, " ")
148
- .trim();
149
- if (name === "") {
150
- // Rolling back to original name if our processing leads in empty name
151
- name = item.name;
152
- }
56
+ let name = this.removeProtocolNameFromCoinName(item.name, code, network);
153
57
  const ticker = `${code}${code === network ? "" : network}`;
154
58
  const defaultDecimalPlacesForCoinNotSupportedOOB = 8;
155
59
  const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
@@ -179,13 +83,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
179
83
  network: item.network,
180
84
  hasExtraId: item.hasExtraId,
181
85
  extraIdName: item.extraIdName,
182
- isPopular: !!item.popular,
86
+ isPopular: item.popular ? 1 : 0,
183
87
  iconURL: item.icon
184
88
  ? `https://storage.swapspace.co${item.icon}`
185
89
  : FALLBACK_ASSET_ICON_URL,
186
90
  deposit: item.deposit ?? false,
187
91
  withdrawal: item.withdrawal ?? false,
188
92
  validationRegexp: item.validationRegexp ?? null,
93
+ isAvailable: true,
189
94
  };
190
95
  }
191
96
 
@@ -212,74 +117,18 @@ export class SwapspaceSwapProvider extends SwapProvider {
212
117
  }
213
118
  }
214
119
 
215
- /**
216
- * This method sort internal list putting popular (as swapspace thinks) coins to the top.
217
- * This is just for users of this API if they don't care about the sorting - we just improve a list a bit this way.
218
- * @private
219
- */
220
- _putPopularCoinsFirst() {
221
- this._supportedCoins.sort((i1, i2) => {
222
- if (i1.isPopular && !i2.isPopular) return -1;
223
- if (i2.isPopular && !i1.isPopular) return 1;
224
- return i1.coin.ticker > i2.coin.ticker ? 1 : i1.coin.ticker < i2.coin.ticker ? -1 : 0;
225
- });
226
- }
227
-
228
- async getCoinToUSDTRate(coin) {
229
- const loggerSource = "getCoinToUSDTRate";
230
- try {
231
- if (!coin) return null;
232
-
233
- await this._fetchSupportedCurrenciesIfNeeded();
234
-
235
- // Using USDT TRC20 as usually fee in this network is smaller than ERC20 and this network is widely used for USDT
236
- const usdtTrc20 = this._supportedCoins.find(i => i.coin.ticker === "USDTTRC20")?.coin;
237
- if (!usdtTrc20) {
238
- return { result: false };
239
- }
240
- const cached = this._cache.get("swapspace_usdt_rate_" + coin.ticker);
241
- if (cached != null) {
242
- return {
243
- result: true,
244
- rate: cached,
245
- };
246
- }
247
-
248
- Logger.log("Loading USDT->coin rate as not found in cache:", coin?.ticker);
249
- const result = await this.getSwapInfo(usdtTrc20, coin, "5000", false);
250
- if (!result.result) {
251
- return { result: false };
252
- }
253
-
254
- // This calculation is not precise as we cannot recognize the actual fee and network fee. Just approximate.
255
- const standardSwapspaceFeeMultiplier = 1.004; // fee is usually 0.4%
256
- const rate = BigNumber(1).div(BigNumber(result.rate).times(standardSwapspaceFeeMultiplier)).toString();
257
- this._cache.put(
258
- "swapspace_usdt_rate_" + coin.ticker,
259
- rate,
260
- 15 * 60000 // 15 minutes
261
- );
262
- return {
263
- result: true,
264
- rate: rate,
265
- };
266
- } catch (e) {
267
- improveAndRethrow(e, loggerSource);
268
- }
269
- }
270
-
271
- getCoinByTickerIfPresent(ticker) {
272
- try {
273
- const item = this._supportedCoins.find(i => i.coin.ticker === ticker);
274
- return item?.coin ?? null;
275
- } catch (e) {
276
- improveAndRethrow(e, "getCoinByTickerIfPresent");
277
- }
278
- }
279
-
280
- async getSwapInfo(fromCoin, toCoin, amountCoins, fixed = false, fromCoinToUsdRate = null) {
120
+ async getSwapInfo(
121
+ fromCoin,
122
+ toCoin,
123
+ amountCoins,
124
+ fixed = false,
125
+ fromCoinToUsdRate = null,
126
+ amountIsToReceive = false
127
+ ) {
281
128
  const loggerSource = "getSwapInfo";
282
129
  try {
130
+ if (amountIsToReceive)
131
+ throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
283
132
  if (
284
133
  !(fromCoin instanceof Coin) ||
285
134
  !(toCoin instanceof Coin) ||
@@ -454,11 +303,14 @@ export class SwapspaceSwapProvider extends SwapProvider {
454
303
  clientIpAddress,
455
304
  fixed,
456
305
  toCurrencyExtraId = "",
457
- refundExtraId = ""
306
+ refundExtraId = "",
307
+ amountIsToReceive = false
458
308
  ) {
459
309
  const loggerSource = "createSwap";
460
310
  const partner = rawSwapData?.partner;
461
311
  try {
312
+ if (amountIsToReceive)
313
+ throw new Error("Swapspace doesn't support exchanging to get the exact receiving amount");
462
314
  if (
463
315
  !(fromCoin instanceof Coin) ||
464
316
  !(toCoin instanceof Coin) ||
@@ -689,36 +541,4 @@ export class SwapspaceSwapProvider extends SwapProvider {
689
541
  improveAndRethrow(e, loggerSource);
690
542
  }
691
543
  }
692
-
693
- isAddressValidForAsset(asset, address) {
694
- try {
695
- const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
696
- if (assetData) {
697
- let corrected = assetData.validationRegexp.trim();
698
- corrected = corrected[0] === "/" ? corrected.slice(1) : corrected;
699
- corrected =
700
- corrected[corrected.length - 1] === "/" ? corrected.slice(0, corrected.length - 1) : corrected;
701
- return address.match(corrected) != null;
702
- }
703
- } catch (e) {
704
- Logger.logError(e, "isAddressValidForAsset");
705
- }
706
- return false;
707
- }
708
-
709
- getExtraIdNameIfPresent(asset) {
710
- try {
711
- const assetData = this._supportedCoins.find(i => i.coin?.ticker === asset?.ticker);
712
- if (assetData?.hasExtraId) {
713
- if (assetData?.extraIdName == null || assetData?.extraIdName === "") {
714
- // We return some default name if the extraIdName is empty
715
- return "ID";
716
- }
717
- return assetData?.extraIdName;
718
- }
719
- return null;
720
- } catch (e) {
721
- improveAndRethrow(e, "getExtraIdNameIfPresent");
722
- }
723
- }
724
544
  }