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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/.gitlab-ci.yml +29 -0
  2. package/.husky/commit-msg +19 -0
  3. package/.husky/pre-push +1 -0
  4. package/CHANGELOG.md +0 -0
  5. package/README.md +27 -18
  6. package/coverage/base.css +224 -0
  7. package/coverage/block-navigation.js +87 -0
  8. package/coverage/clover.xml +16765 -0
  9. package/coverage/coverage-final.json +116 -0
  10. package/coverage/favicon.png +0 -0
  11. package/coverage/index.html +1001 -0
  12. package/coverage/prettify.css +1 -0
  13. package/coverage/prettify.js +2 -0
  14. package/coverage/rabbit-ui-kit/index.html +116 -0
  15. package/coverage/rabbit-ui-kit/index.js.html +88 -0
  16. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +148 -0
  17. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +146 -0
  18. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +169 -0
  19. package/coverage/rabbit-ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +199 -0
  20. package/coverage/rabbit-ui-kit/src/common-apis/adapters/axiosAdapter.js.html +190 -0
  21. package/coverage/rabbit-ui-kit/src/common-apis/adapters/index.html +131 -0
  22. package/coverage/rabbit-ui-kit/src/common-apis/adapters/qrUtils.js.html +139 -0
  23. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/apiGroups.js.html +250 -0
  24. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/emailAPI.js.html +133 -0
  25. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/index.html +146 -0
  26. package/coverage/rabbit-ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +352 -0
  27. package/coverage/rabbit-ui-kit/src/common-apis/globalConstants.jsx.html +94 -0
  28. package/coverage/rabbit-ui-kit/src/common-apis/index.html +116 -0
  29. package/coverage/rabbit-ui-kit/src/common-apis/models/blockchain.js.html +115 -0
  30. package/coverage/rabbit-ui-kit/src/common-apis/models/coin.js.html +829 -0
  31. package/coverage/rabbit-ui-kit/src/common-apis/models/index.html +146 -0
  32. package/coverage/rabbit-ui-kit/src/common-apis/models/protocol.js.html +100 -0
  33. package/coverage/rabbit-ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +544 -0
  34. package/coverage/rabbit-ui-kit/src/common-apis/services/index.html +116 -0
  35. package/coverage/rabbit-ui-kit/src/common-apis/utils/amountUtils.js.html +1162 -0
  36. package/coverage/rabbit-ui-kit/src/common-apis/utils/cache.js.html +811 -0
  37. package/coverage/rabbit-ui-kit/src/common-apis/utils/errorUtils.js.html +211 -0
  38. package/coverage/rabbit-ui-kit/src/common-apis/utils/index.html +191 -0
  39. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/index.html +131 -0
  40. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logger.js.html +208 -0
  41. package/coverage/rabbit-ui-kit/src/common-apis/utils/logging/logsStorage.js.html +268 -0
  42. package/coverage/rabbit-ui-kit/src/common-apis/utils/postponeExecution.js.html +118 -0
  43. package/coverage/rabbit-ui-kit/src/common-apis/utils/rabbitTicker.js.html +157 -0
  44. package/coverage/rabbit-ui-kit/src/common-apis/utils/safeStringify.js.html +235 -0
  45. package/coverage/rabbit-ui-kit/src/index.html +116 -0
  46. package/coverage/rabbit-ui-kit/src/index.js.html +376 -0
  47. package/coverage/rabbit-ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1570 -0
  48. package/coverage/rabbit-ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +526 -0
  49. package/coverage/rabbit-ui-kit/src/robust-api-caller/cancelProcessing.js.html +172 -0
  50. package/coverage/rabbit-ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +310 -0
  51. package/coverage/rabbit-ui-kit/src/robust-api-caller/externalApiProvider.js.html +553 -0
  52. package/coverage/rabbit-ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +319 -0
  53. package/coverage/rabbit-ui-kit/src/robust-api-caller/index.html +206 -0
  54. package/coverage/rabbit-ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +997 -0
  55. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +1825 -0
  56. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/index.html +161 -0
  57. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1618 -0
  58. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +1819 -0
  59. package/coverage/rabbit-ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +1861 -0
  60. package/coverage/rabbit-ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +319 -0
  61. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwap.js.html +514 -0
  62. package/coverage/rabbit-ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +529 -0
  63. package/coverage/rabbit-ui-kit/src/swaps-lib/models/index.html +176 -0
  64. package/coverage/rabbit-ui-kit/src/swaps-lib/models/partner.js.html +166 -0
  65. package/coverage/rabbit-ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +331 -0
  66. package/coverage/rabbit-ui-kit/src/swaps-lib/services/index.html +116 -0
  67. package/coverage/rabbit-ui-kit/src/swaps-lib/services/publicSwapService.js.html +1555 -0
  68. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/index.html +116 -0
  69. package/coverage/rabbit-ui-kit/src/swaps-lib/utils/swapUtils.js.html +670 -0
  70. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +124 -0
  71. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +127 -0
  72. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +127 -0
  73. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +106 -0
  74. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +439 -0
  75. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +202 -0
  76. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/index.html +281 -0
  77. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +133 -0
  78. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +346 -0
  79. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +247 -0
  80. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +163 -0
  81. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +268 -0
  82. package/coverage/rabbit-ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +151 -0
  83. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +256 -0
  84. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +116 -0
  85. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +289 -0
  86. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +116 -0
  87. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +187 -0
  88. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +116 -0
  89. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +238 -0
  90. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +116 -0
  91. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +634 -0
  92. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Input/index.html +116 -0
  93. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +196 -0
  94. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +116 -0
  95. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +277 -0
  96. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +116 -0
  97. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +217 -0
  98. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/QrCode/index.html +116 -0
  99. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +175 -0
  100. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +116 -0
  101. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +217 -0
  102. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +116 -0
  103. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +529 -0
  104. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Textarea/index.html +116 -0
  105. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +508 -0
  106. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +116 -0
  107. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +316 -0
  108. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +116 -0
  109. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +313 -0
  110. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +116 -0
  111. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +202 -0
  112. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/Validation/index.html +116 -0
  113. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +712 -0
  114. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +116 -0
  115. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +259 -0
  116. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +116 -0
  117. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +421 -0
  118. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +116 -0
  119. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +415 -0
  120. package/coverage/rabbit-ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +116 -0
  121. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1429 -0
  122. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +116 -0
  123. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1474 -0
  124. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +116 -0
  125. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +211 -0
  126. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +116 -0
  127. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +190 -0
  128. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +116 -0
  129. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +307 -0
  130. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +116 -0
  131. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +496 -0
  132. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +116 -0
  133. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +181 -0
  134. package/coverage/rabbit-ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +116 -0
  135. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +283 -0
  136. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +116 -0
  137. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1567 -0
  138. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +481 -0
  139. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +116 -0
  140. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1747 -0
  141. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +116 -0
  142. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/Dialog/index.html +116 -0
  143. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +4207 -0
  144. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +116 -0
  145. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +559 -0
  146. package/coverage/rabbit-ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +116 -0
  147. package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +316 -0
  148. package/coverage/rabbit-ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +116 -0
  149. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/index.html +146 -0
  150. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +151 -0
  151. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +121 -0
  152. package/coverage/rabbit-ui-kit/src/ui-kit/hooks/useReferredState.js.html +157 -0
  153. package/coverage/rabbit-ui-kit/src/ui-kit/utils/index.html +161 -0
  154. package/coverage/rabbit-ui-kit/src/ui-kit/utils/inputValueProviders.js.html +235 -0
  155. package/coverage/rabbit-ui-kit/src/ui-kit/utils/textUtils.js.html +139 -0
  156. package/coverage/rabbit-ui-kit/src/ui-kit/utils/uiUtils.js.html +121 -0
  157. package/coverage/rabbit-ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +271 -0
  158. package/coverage/rabbit-ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +202 -0
  159. package/coverage/rabbit-ui-kit/stories/atoms/LinesOfText.stories.jsx.html +283 -0
  160. package/coverage/rabbit-ui-kit/stories/atoms/LoadingDots.stories.jsx.html +226 -0
  161. package/coverage/rabbit-ui-kit/stories/atoms/QrCode.stories.jsx.html +175 -0
  162. package/coverage/rabbit-ui-kit/stories/atoms/RateSelector.stories.jsx.html +136 -0
  163. package/coverage/rabbit-ui-kit/stories/atoms/Validation.stories.jsx.html +178 -0
  164. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Button.stories.jsx.html +883 -0
  165. package/coverage/rabbit-ui-kit/stories/atoms/buttons/Close.stories.jsx.html +211 -0
  166. package/coverage/rabbit-ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +301 -0
  167. package/coverage/rabbit-ui-kit/stories/atoms/buttons/index.html +146 -0
  168. package/coverage/rabbit-ui-kit/stories/atoms/index.html +191 -0
  169. package/coverage/rabbit-ui-kit/stories/molecules/AmountInput.stories.jsx.html +289 -0
  170. package/coverage/rabbit-ui-kit/stories/molecules/CoinPicker.stories.jsx.html +322 -0
  171. package/coverage/rabbit-ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +178 -0
  172. package/coverage/rabbit-ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +154 -0
  173. package/coverage/rabbit-ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +235 -0
  174. package/coverage/rabbit-ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +160 -0
  175. package/coverage/rabbit-ui-kit/stories/molecules/index.html +191 -0
  176. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +523 -0
  177. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +328 -0
  178. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogButtons/index.html +116 -0
  179. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +337 -0
  180. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/DialogStep/index.html +116 -0
  181. package/coverage/rabbit-ui-kit/stories/organisms/Dialog/index.html +116 -0
  182. package/coverage/rabbit-ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +151 -0
  183. package/coverage/rabbit-ui-kit/stories/organisms/index.html +116 -0
  184. package/coverage/rabbit-ui-kit/stories/stubs/coins.jsx.html +6880 -0
  185. package/coverage/rabbit-ui-kit/stories/stubs/exampleContent.jsx.html +145 -0
  186. package/coverage/rabbit-ui-kit/stories/stubs/index.html +131 -0
  187. package/coverage/rabbit-ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +190 -0
  188. package/coverage/rabbit-ui-kit/stories/templates/index.html +116 -0
  189. package/coverage/sort-arrow-sprite.png +0 -0
  190. package/coverage/sorter.js +196 -0
  191. package/dist/global.css +197 -0
  192. package/dist/global.css.map +1 -0
  193. package/dist/index.cjs +12451 -25
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.css +2339 -8491
  196. package/dist/index.css.map +1 -1
  197. package/dist/index.modern.js +9597 -26
  198. package/dist/index.modern.js.map +1 -1
  199. package/dist/index.module.js +12357 -27
  200. package/dist/index.module.js.map +1 -1
  201. package/dist/index.umd.js +12442 -29
  202. package/dist/index.umd.js.map +1 -1
  203. package/package.json +35 -9
  204. package/raw +1000 -0
  205. package/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js +21 -0
  206. package/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js +28 -0
  207. package/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js +38 -0
  208. package/src/common-apis/adapters/axiosAdapter.js +35 -0
  209. package/src/common-apis/adapters/qrUtils.js +18 -0
  210. package/src/common-apis/external-apis/apiGroups.js +55 -0
  211. package/src/common-apis/external-apis/emailAPI.js +16 -0
  212. package/src/common-apis/external-apis/ipAddressProviders.js +89 -0
  213. package/src/common-apis/globalConstants.jsx +3 -0
  214. package/src/common-apis/models/blockchain.js +10 -0
  215. package/src/common-apis/models/coin.js +248 -0
  216. package/src/common-apis/models/protocol.js +5 -0
  217. package/src/{common → common-apis/services}/fiatCurrenciesService.js +4 -12
  218. package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +12 -0
  219. package/src/common-apis/tests/units/utils/amountUtils/composeRateText.test.js +152 -0
  220. package/src/{common → common-apis/utils}/amountUtils.js +72 -136
  221. package/src/common-apis/utils/cache.js +242 -0
  222. package/src/{common → common-apis/utils}/errorUtils.js +15 -0
  223. package/src/common-apis/utils/logging/logger.js +41 -0
  224. package/src/common-apis/utils/logging/logsStorage.js +61 -0
  225. package/src/common-apis/utils/postponeExecution.js +11 -0
  226. package/src/common-apis/utils/rabbitTicker.js +24 -0
  227. package/src/common-apis/utils/safeStringify.js +50 -0
  228. package/src/index.js +96 -9
  229. package/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js +495 -0
  230. package/src/robust-api-caller/cachedRobustExternalApiCallerService.js +147 -0
  231. package/src/robust-api-caller/cancelProcessing.js +29 -0
  232. package/src/robust-api-caller/concurrentCalculationsMetadataHolder.js +75 -0
  233. package/src/robust-api-caller/externalApiProvider.js +156 -0
  234. package/src/robust-api-caller/externalServicesStatsCollector.js +78 -0
  235. package/src/robust-api-caller/robustExternalAPICallerService.js +304 -0
  236. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +533 -0
  237. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +532 -0
  238. package/src/robust-api-caller/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +19 -0
  239. package/src/swaps-lib/external-apis/exolixSwapProvider.js +580 -0
  240. package/src/swaps-lib/external-apis/letsExchangeSwapProvider.js +511 -0
  241. package/src/swaps-lib/external-apis/swapProvider.js +578 -0
  242. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +592 -0
  243. package/src/swaps-lib/models/baseSwapCreationInfo.js +78 -0
  244. package/src/swaps-lib/models/existingSwap.js +143 -0
  245. package/src/swaps-lib/models/existingSwapWithFiatData.js +148 -0
  246. package/src/swaps-lib/models/partner.js +27 -0
  247. package/src/swaps-lib/models/swapProviderCoinInfo.js +82 -0
  248. package/src/swaps-lib/services/publicSwapService.js +490 -0
  249. package/src/swaps-lib/test/external-apis/exolixSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +34 -0
  250. package/src/swaps-lib/test/external-apis/exolixSwapProvider/createSwap.test.js +1043 -0
  251. package/src/swaps-lib/test/external-apis/exolixSwapProvider/getSwapInfo.test.js +611 -0
  252. package/src/swaps-lib/test/external-apis/swapProvider/getAllSupportedCurrencies.test.js +63 -0
  253. package/src/swaps-lib/test/external-apis/swapProvider/getDepositCurrencies.test.js +73 -0
  254. package/src/swaps-lib/test/external-apis/swapProvider/getWithdrawalCurrencies.test.js +102 -0
  255. package/src/swaps-lib/test/external-apis/swapProvider/removeProtocolNameFromCoinName.test.js +152 -0
  256. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +536 -0
  257. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1214 -0
  258. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1707 -0
  259. package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +80 -0
  260. package/src/swaps-lib/utils/swapUtils.js +195 -0
  261. package/{styles → src/ui-kit/assets/styles}/_functions.scss +5 -0
  262. package/{styles → src/ui-kit/assets/styles}/_mixins.scss +2 -2
  263. package/{styles → src/ui-kit/assets/styles}/_placeholder.scss +3 -3
  264. package/{styles → src/ui-kit/assets/styles}/_variables.scss +17 -15
  265. package/src/ui-kit/assets/styles/fonts/NunitoSans-Bold.ttf +0 -0
  266. package/src/ui-kit/assets/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  267. package/src/ui-kit/assets/styles/fonts/NunitoSans-Light.ttf +0 -0
  268. package/src/ui-kit/assets/styles/fonts/NunitoSans-Regular.ttf +0 -0
  269. package/src/ui-kit/assets/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  270. package/src/ui-kit/assets/styles/global.scss +171 -0
  271. package/src/ui-kit/assets/styles/index.scss +10 -0
  272. package/src/ui-kit/assets/wrappedImages/arrowIcon.jsx +13 -0
  273. package/src/ui-kit/assets/wrappedImages/arrowTosca.jsx +14 -0
  274. package/src/ui-kit/assets/wrappedImages/arrowWhite.jsx +14 -0
  275. package/src/ui-kit/assets/wrappedImages/darkRectangle.jsx +7 -0
  276. package/src/ui-kit/assets/wrappedImages/determinedError.jsx +118 -0
  277. package/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx +39 -0
  278. package/src/ui-kit/assets/wrappedImages/infoIcon.jsx +16 -0
  279. package/src/ui-kit/assets/wrappedImages/messageIcon.jsx +87 -0
  280. package/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx +54 -0
  281. package/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx +26 -0
  282. package/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx +61 -0
  283. package/src/ui-kit/assets/wrappedImages/walletIcon.jsx +22 -0
  284. package/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx +57 -0
  285. package/src/{components → ui-kit/components}/atoms/AssetIcon/asset-icon.module.scss +1 -1
  286. package/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx +68 -0
  287. package/src/ui-kit/components/atoms/AssetSelection/asset-selection.module.scss +56 -0
  288. package/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx +34 -0
  289. package/src/ui-kit/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
  290. package/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx +51 -0
  291. package/src/ui-kit/components/atoms/InformationMessage/information-message.module.scss +38 -0
  292. package/src/ui-kit/components/atoms/Input/Input.jsx +183 -0
  293. package/src/ui-kit/components/atoms/Input/input.module.scss +107 -0
  294. package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.jsx +8 -28
  295. package/src/{components → ui-kit/components}/atoms/LoadingDots/LoadingDots.module.scss +3 -2
  296. package/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx +64 -0
  297. package/src/ui-kit/components/atoms/NoticeIcon/notice-icon.module.scss +14 -0
  298. package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +44 -0
  299. package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +15 -0
  300. package/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx +30 -0
  301. package/src/ui-kit/components/atoms/RateSelector/rate-selector.module.scss +47 -0
  302. package/src/{components → ui-kit/components}/atoms/SupportChat/SupportChat.jsx +5 -1
  303. package/src/ui-kit/components/atoms/Textarea/Textarea.jsx +148 -0
  304. package/src/ui-kit/components/atoms/Textarea/textarea.module.scss +71 -0
  305. package/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx +141 -0
  306. package/src/ui-kit/components/atoms/TitleBox/title-box.module.scss +32 -0
  307. package/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx +77 -0
  308. package/src/ui-kit/components/atoms/Tooltip/tooltip.module.scss +237 -0
  309. package/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx +76 -0
  310. package/src/ui-kit/components/atoms/TwoLinesOfText/lines-of-text.module.scss +65 -0
  311. package/src/ui-kit/components/atoms/Validation/Validation.jsx +39 -0
  312. package/src/ui-kit/components/atoms/Validation/validation.module.scss +19 -0
  313. package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.jsx +24 -50
  314. package/src/{components → ui-kit/components}/atoms/buttons/Button/Button.module.scss +1 -1
  315. package/src/ui-kit/components/atoms/buttons/Close/Close.jsx +58 -0
  316. package/src/ui-kit/components/atoms/buttons/Close/close.module.scss +75 -0
  317. package/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx +112 -0
  318. package/src/ui-kit/components/atoms/buttons/LinkButton/link-button.module.scss +49 -0
  319. package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx +110 -0
  320. package/src/ui-kit/components/atoms/buttons/RadioButtonWithText/radio-button-with-text.module.scss +86 -0
  321. package/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx +448 -0
  322. package/src/ui-kit/components/molecules/AmountInput/amount-input.module.scss +233 -0
  323. package/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx +463 -0
  324. package/src/ui-kit/components/molecules/CoinPicker/coin-picker.module.scss +207 -0
  325. package/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx +42 -0
  326. package/src/ui-kit/components/molecules/ColoredNotice/colored-notice.module.scss +20 -0
  327. package/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx +35 -0
  328. package/src/ui-kit/components/molecules/LineWithIconLink/line-with-icon-link.module.scss +25 -0
  329. package/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx +74 -0
  330. package/src/ui-kit/components/molecules/LogoCarousel/logo-carousel.module.scss +106 -0
  331. package/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx +137 -0
  332. package/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx +32 -0
  333. package/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx +66 -0
  334. package/src/ui-kit/components/organisms/Dialog/Dialog.jsx +494 -0
  335. package/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +132 -0
  336. package/src/ui-kit/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
  337. package/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx +554 -0
  338. package/src/ui-kit/components/organisms/Dialog/DialogStep/dialog-step.module.scss +381 -0
  339. package/src/ui-kit/components/organisms/Dialog/dialog.module.scss +226 -0
  340. package/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx +1374 -0
  341. package/src/ui-kit/components/organisms/SwapForm/swap-form.module.scss +134 -0
  342. package/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx +158 -0
  343. package/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx +77 -0
  344. package/src/ui-kit/hooks/useCallHandlingErrors.js +22 -0
  345. package/src/ui-kit/hooks/useIsHydrated.js +12 -0
  346. package/src/ui-kit/hooks/useReferredState.js +24 -0
  347. package/src/ui-kit/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +146 -0
  348. package/src/ui-kit/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +65 -0
  349. package/src/ui-kit/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +104 -0
  350. package/src/ui-kit/utils/inputValueProviders.js +50 -0
  351. package/src/ui-kit/utils/textUtils.js +18 -0
  352. package/src/ui-kit/utils/uiUtils.js +12 -0
  353. package/src/ui-kit/utils/urlQueryUtils.js +62 -0
  354. package/stories/font.scss +40 -0
  355. package/stories/stubs/coins.jsx +2266 -0
  356. package/stories/stubs/exampleContent.jsx +20 -0
  357. package/src/components/atoms/AssetIcon/AssetIcon.jsx +0 -55
  358. package/styles/_global-classes.scss +0 -433
  359. package/styles/fonts/NunitoSans-Bold.ttf +0 -0
  360. package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
  361. package/styles/fonts/NunitoSans-Light.ttf +0 -0
  362. package/styles/fonts/NunitoSans-Regular.ttf +0 -0
  363. package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
  364. package/styles/global-styles-index.scss +0 -74
  365. package/styles/index.scss +0 -33
  366. /package/{styles → src/ui-kit/assets/styles}/colors/_light-colors.scss +0 -0
  367. /package/{styles → src/ui-kit/assets/styles}/colors/_solid-colors.scss +0 -0
  368. /package/{styles → src/ui-kit/assets/styles}/size/_margin-size.scss +0 -0
  369. /package/{styles → src/ui-kit/assets/styles}/size/_padding-size.scss +0 -0
@@ -0,0 +1,21 @@
1
+ import { Logger } from "../../utils/logging/logger.js";
2
+ import { safeStringify } from "../../utils/safeStringify.js";
3
+
4
+ export class GoogleAnalyticsAdapter {
5
+ static sendEvent(eventName, parameters) {
6
+ console.log("Sending ga event: ", parameters, ["event", eventName, parameters]);
7
+ this.doActionOnGTag(["event", eventName, parameters]);
8
+ }
9
+
10
+ static doActionOnGTag(parameters) {
11
+ try {
12
+ if (window.gtag) {
13
+ window.gtag(...parameters);
14
+ } else {
15
+ Logger.logError(null, "doActionOnGTag", "No gtag found");
16
+ }
17
+ } catch (e) {
18
+ Logger.logError(e, "doActionOnGTag", "Failed to do gtag action: " + safeStringify(parameters));
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,28 @@
1
+ import { Logger } from "../../utils/logging/logger.js";
2
+
3
+ export class MetrikaAdapter {
4
+ /**
5
+ * Sends reachGoal to Metrika
6
+ *
7
+ * @param METRIKA_ID {string}
8
+ * @param goalName {string}
9
+ * @param [usdPrice] {string|number}
10
+ */
11
+ static callMetrikaReachGoal(METRIKA_ID, goalName, usdPrice = null) {
12
+ try {
13
+ if (window.ym) {
14
+ console.log("Sending metrika goal reached: ", goalName, String(usdPrice));
15
+ window.ym(
16
+ METRIKA_ID,
17
+ "reachGoal",
18
+ goalName,
19
+ usdPrice != null ? { order_price: usdPrice, currency: "USD" } : {}
20
+ );
21
+ } else {
22
+ Logger.logError(null, "callMetrikaReachGoal", "No metrika found");
23
+ }
24
+ } catch (e) {
25
+ Logger.logError(e, "callMetrikaReachGoal", "Failed to call metrika: " + goalName + " " + usdPrice);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,38 @@
1
+ import { Logger } from "../../utils/logging/logger.js";
2
+ import { safeStringify } from "../../utils/safeStringify.js";
3
+
4
+ export class MixpanelAdapter {
5
+ static sendEvent(eventName, parameters) {
6
+ try {
7
+ if (window.mixpanel) {
8
+ const result = window.mixpanel.track(eventName, parameters);
9
+ // eslint-disable-next-line no-console
10
+ console.log("Mixpanel sendEvent result: " + result);
11
+ } else {
12
+ Logger.logError(null, "sendEvent", "No mixpanel found");
13
+ }
14
+ } catch (e) {
15
+ Logger.logError(
16
+ e,
17
+ "sendEvent",
18
+ "Failed to do mixpanel action: " + eventName + " - " + safeStringify(parameters)
19
+ );
20
+ }
21
+ }
22
+
23
+ static identify(uniqueId) {
24
+ try {
25
+ if (window.mixpanel) {
26
+ if (uniqueId) {
27
+ const result = window.mixpanel.identify(uniqueId);
28
+ // eslint-disable-next-line no-console
29
+ console.log("Mixpanel identify result: " + result);
30
+ }
31
+ } else {
32
+ Logger.logError(null, "identify", "No mixpanel found");
33
+ }
34
+ } catch (e) {
35
+ Logger.logError(e, "identify", "Failed to identify.");
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,35 @@
1
+ import axios from "axios";
2
+
3
+ export class AxiosAdapter {
4
+ static async call(method, ...args) {
5
+ return await axios[method](...args);
6
+ }
7
+
8
+ static async get(...args) {
9
+ return await axios.get(...args);
10
+ }
11
+
12
+ static async post(...args) {
13
+ return await axios.post(...args);
14
+ }
15
+
16
+ static async put(...args) {
17
+ return await axios.put(...args);
18
+ }
19
+
20
+ static async delete(...args) {
21
+ return await axios.delete(...args);
22
+ }
23
+
24
+ static async patch(...args) {
25
+ return await axios.patch(...args);
26
+ }
27
+
28
+ static async options(...args) {
29
+ return await axios.options(...args);
30
+ }
31
+
32
+ static async head(...args) {
33
+ return await axios.head(...args);
34
+ }
35
+ }
@@ -0,0 +1,18 @@
1
+ import QRCode from "qrcode";
2
+
3
+ import { improveAndRethrow } from "../utils/errorUtils.js";
4
+
5
+ /**
6
+ * Generates QR as svg xml string.
7
+ * Note that you should care about the element size by your self - the generated QR will just fill all available space
8
+ *
9
+ * @param encodingString {string} to be encoded as QR-code image
10
+ * @return {Promise<string>} xml string of generated svg image
11
+ */
12
+ export async function generateQrAndShowInCanvas(encodingString) {
13
+ try {
14
+ return await QRCode.toString(encodingString, { type: "svg" });
15
+ } catch (e) {
16
+ improveAndRethrow(e, "generateQrAndShowInCanvas");
17
+ }
18
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Models a group of APIs provided by the same owner and used for different services in our app.
3
+ * It means we need to mention RPS several times for each usage and also have some holder of last call timestamp per
4
+ * api group. So this concept allows to use it for exact ExternalApiProvider and make sure that you use the same
5
+ * RPS value and make decisions on base of the same timestamp of last call to the API group owner.
6
+ */
7
+ export class ApiGroup {
8
+ constructor(id, rps, backendProxyIdGenerator = null) {
9
+ this.id = id;
10
+ this.rps = rps;
11
+ this.lastCalledTimestamp = null;
12
+ this.backendProxyIdGenerator = backendProxyIdGenerator;
13
+ }
14
+
15
+ isRpsExceeded() {
16
+ return (this.lastCalledTimestamp ?? 0) + Math.floor(1000 / this.rps) > Date.now();
17
+ }
18
+
19
+ actualizeLastCalledTimestamp() {
20
+ this.lastCalledTimestamp = Date.now();
21
+ }
22
+ }
23
+
24
+ export const ApiGroups = {
25
+ /**
26
+ * Currently we use free version of etherscan provider with 0.2 RPS. But we have API key with 100k requests free
27
+ * per month. So we can add it if not enough current RPS.
28
+ */
29
+ ETHERSCAN: new ApiGroup("etherscan", 0.17), // Actually 0.2 but fails sometime, so we use smaller
30
+ ALCHEMY: new ApiGroup("alchemy", 0.3, networkKey => `alchemy-${networkKey}`),
31
+ BLOCKSTREAM: new ApiGroup("blockstream", 0.2),
32
+ BLOCKCHAIN_INFO: new ApiGroup("blockchain.info", 1),
33
+ BLOCKNATIVE: new ApiGroup("blocknative", 0.5),
34
+ ETHGASSTATION: new ApiGroup("ethgasstation", 0.5),
35
+ TRONGRID: new ApiGroup("trongrid", 0.3, networkKey => `trongrid-${networkKey}`),
36
+ TRONSCAN: new ApiGroup("tronscan", 0.3),
37
+ GETBLOCK: new ApiGroup("getblock", 0.3),
38
+ COINCAP: new ApiGroup("coincap", 0.5), // 200 per minute without API key
39
+ COINGECKO: new ApiGroup("coingecko", 0.9), // actually 0.13-0.5 according to the docs but we use smaller due to expirienced frequent abuses
40
+ MESSARI: new ApiGroup("messari", 0.2),
41
+ BTCCOM: new ApiGroup("btccom", 0.2),
42
+ BITAPS: new ApiGroup("bitaps", 0.25), // Docs say that RPS is 3 but using it causes frequent 429 HTTP errors
43
+ CEX: new ApiGroup("cex", 0.5), // Just assumption for RPS
44
+ BIGDATACLOUD: new ApiGroup("bigdatacloud", 1), // Just assumption for RPS
45
+ TRACKIP: new ApiGroup("trackip", 1), // Just assumption for RPS
46
+ IPIFY: new ApiGroup("ipify", 1), // Just assumption for RPS
47
+ WHATISMYIPADDRESS: new ApiGroup("whatismyipaddress", 1), // Just assumption for RPS
48
+ EXCHANGERATE: new ApiGroup("exchangerate", 1), // Just assumption for RPS
49
+ FRANKFURTER: new ApiGroup("frankfurter", 1), // Just assumption for RPS
50
+ BITGO: new ApiGroup("bitgo", 1), // Just assumption for RPS
51
+ BITCOINER: new ApiGroup("bitcoiner", 1), // Just assumption for RPS
52
+ BITCORE: new ApiGroup("bitcore", 1), // Just assumption for RPS
53
+ // BLOCKCHAIR: new ApiGroup("blockchair", 0.04), // this provider require API key for commercial use (10usd 10000 reqs), we will add it later
54
+ MEMPOOL: new ApiGroup("mempool", 0.2), // Just assumption for RPS
55
+ };
@@ -0,0 +1,16 @@
1
+ import axios from "axios";
2
+
3
+ import { improveAndRethrow } from "../utils/errorUtils.js";
4
+
5
+ export class EmailsApi {
6
+ static serverEndpointEntity = "emails";
7
+
8
+ static async sendEmail(subject, body) {
9
+ try {
10
+ const url = `${window.location.protocol + "//" + window.location.host}/api/v1/${this.serverEndpointEntity}`;
11
+ await axios.post(url, { subject, body });
12
+ } catch (e) {
13
+ improveAndRethrow(e, "sendEmail", subject + body);
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,89 @@
1
+ import EventBusInstance from "eventbusjs";
2
+ import { ExternalApiProvider } from "../../robust-api-caller/externalApiProvider.js";
3
+ import { ApiGroups } from "./apiGroups.js";
4
+ import { CachedRobustExternalApiCallerService } from "../../robust-api-caller/cachedRobustExternalApiCallerService.js";
5
+ import { Cache } from "../utils/cache.js";
6
+ import { improveAndRethrow } from "../utils/errorUtils.js";
7
+
8
+ class BigdatacloudIpAddressProvider extends ExternalApiProvider {
9
+ constructor() {
10
+ super("https://api.bigdatacloud.net/data/client-ip", "get", 15000, ApiGroups.BIGDATACLOUD);
11
+ }
12
+
13
+ getDataByResponse(response, params = [], subRequestIndex = 0, iterationsData = []) {
14
+ return response?.data && response.data?.ipString;
15
+ }
16
+ }
17
+
18
+ class TrackipIpAddressProvider extends ExternalApiProvider {
19
+ constructor() {
20
+ super("https://www.trackip.net/ip", "get", 15000, ApiGroups.TRACKIP);
21
+ }
22
+
23
+ getDataByResponse(response, params = [], subRequestIndex = 0, iterationsData = []) {
24
+ return response?.data;
25
+ }
26
+ }
27
+
28
+ class IpifyV6IpAddressProvider extends ExternalApiProvider {
29
+ constructor() {
30
+ super("https://api6.ipify.org/?format=json", "get", 15000, ApiGroups.IPIFY);
31
+ }
32
+
33
+ getDataByResponse(response, params = [], subRequestIndex = 0, iterationsData = []) {
34
+ return response?.data && response.data?.ip;
35
+ }
36
+ }
37
+
38
+ class IpifyIpAddressProvider extends ExternalApiProvider {
39
+ constructor() {
40
+ super("https://api.ipify.org/?format=json", "get", 15000, ApiGroups.IPIFY);
41
+ }
42
+
43
+ getDataByResponse(response, params = [], subRequestIndex = 0, iterationsData = []) {
44
+ return response?.data && response.data?.ip;
45
+ }
46
+ }
47
+
48
+ class WhatismyipaddressIpAddressProvider extends ExternalApiProvider {
49
+ constructor() {
50
+ super("http://bot.whatismyipaddress.com/", "get", 15000, ApiGroups.WHATISMYIPADDRESS);
51
+ }
52
+
53
+ getDataByResponse(response, params = [], subRequestIndex = 0, iterationsData = []) {
54
+ return response?.data;
55
+ }
56
+ }
57
+
58
+ export class IpAddressProvider {
59
+ static externalIPAddressAPICaller = new CachedRobustExternalApiCallerService(
60
+ "externalIPAddressAPICaller",
61
+ new Cache(EventBusInstance),
62
+ [
63
+ new BigdatacloudIpAddressProvider(),
64
+ new TrackipIpAddressProvider(),
65
+ new IpifyV6IpAddressProvider(),
66
+ new IpifyIpAddressProvider(),
67
+ new WhatismyipaddressIpAddressProvider(),
68
+ ],
69
+ 300_000
70
+ );
71
+
72
+ /**
73
+ * Returns current public IP address identified by one of external services.
74
+ *
75
+ * It is easier than manual identification and also (as ip needed for server side to check it) it saves us from
76
+ * issues related to changes of infrastructure configurations (like adding proxies etc.) so we should not configure
77
+ * anything on server side to get correct client's IP.
78
+ *
79
+ * @returns {Promise<String>} IP address
80
+ * @throws {Error} if fails to retrieve IP address from all the services
81
+ */
82
+ static async getClientIpAddress() {
83
+ try {
84
+ return await this.externalIPAddressAPICaller.callExternalAPICached([], 7000);
85
+ } catch (e) {
86
+ improveAndRethrow(e, "getClientIpAddress");
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,3 @@
1
+ export const FALLBACK_ASSET_ICON_URL = "https://rabbit.io/asset-icons/fallback.svg";
2
+
3
+ export const DEFAULT_CRYPTO_DECIMAL_COUNT = 8;
@@ -0,0 +1,10 @@
1
+ export class Blockchain {
2
+ /**
3
+ * @param name {string} latin printable name of blockchain
4
+ * @param supportedProtocols {Protocol[]}
5
+ */
6
+ constructor(name, supportedProtocols = []) {
7
+ this.name = name;
8
+ this.supportedProtocols = supportedProtocols;
9
+ }
10
+ }
@@ -0,0 +1,248 @@
1
+ import { improveAndRethrow } from "../utils/errorUtils.js";
2
+
3
+ /**
4
+ * The model for cryptocurrency coins.
5
+ *
6
+ * WARNING: this class should not be instantiated directly. Use only predefined singleton Coin (or descendants) instances.
7
+ */
8
+ export class Coin {
9
+ /**
10
+ * @type {string}
11
+ */
12
+ latinName;
13
+
14
+ /**
15
+ * @type {string}
16
+ */
17
+ ticker;
18
+
19
+ /**
20
+ * @type {string}
21
+ */
22
+ tickerPrintable;
23
+
24
+ /**
25
+ * @type {number}
26
+ */
27
+ digits;
28
+
29
+ /**
30
+ * @type {number|null}
31
+ */
32
+ maxValue;
33
+
34
+ /**
35
+ * @type {string}
36
+ */
37
+ atomName;
38
+
39
+ /**
40
+ * @type {Network}
41
+ */
42
+ mainnet;
43
+
44
+ /**
45
+ * @type {Network}
46
+ */
47
+ testnet;
48
+
49
+ /**
50
+ * @type {number}
51
+ */
52
+ minConfirmations;
53
+
54
+ /**
55
+ * @type {string|null}
56
+ */
57
+ payableEntityStringForFeeRate;
58
+
59
+ /**
60
+ * @type {string[]}
61
+ */
62
+ feeOptionsTimeStringsSortedDesc;
63
+
64
+ /**
65
+ * @type {number}
66
+ */
67
+ feeRatesExpirationTimeMs;
68
+
69
+ /**
70
+ * @type {Blockchain}
71
+ */
72
+ blockchain;
73
+
74
+ /**
75
+ * @type {Protocol|null}
76
+ */
77
+ protocol;
78
+
79
+ /**
80
+ * @type {string|null}
81
+ */
82
+ tokenAddress;
83
+
84
+ /**
85
+ * @type {boolean}
86
+ */
87
+ doesUseLowerCaseAddresses;
88
+
89
+ /**
90
+ * @type {boolean}
91
+ */
92
+ doesUseOutputs;
93
+
94
+ /**
95
+ * @type {Coin}
96
+ */
97
+ feeCoin;
98
+
99
+ /**
100
+ * @type {number}
101
+ */
102
+ _significantDigits;
103
+
104
+ /**
105
+ * Creates new coin
106
+ *
107
+ * @param latinName {string} the coin name in latin symbols like "Bitcoin"
108
+ * @param ticker {string} the coin symbol/ticker/code like 'BTC'. Always upper case. A unique coin identifier
109
+ * @param tickerPrintable {string} ticker but in printable format. Useful for tokens based on external blockchains
110
+ * like ERC20 or TRC20. It is not friendly to display USDTERC20 or BUSDTRC20 - more neat options are just
111
+ * USDT and BUSD. Note that you should always care about user's understanding of what coin he/she is working
112
+ * with as printable ticker for USDTERC20 and USDTTRC20 are the same.
113
+ * @param digitsCountAfterComma {number} count of digits after the comma. E.g. 8 for bitcoin
114
+ * @param maxValue {number|null} max possible value for cryptocurrency. Null means that the currency has no max possible value
115
+ * @param atomName {string} name of the coin's atomic value. Like 'satoshi' for bitcoin
116
+ * @param mainnet {Network} main network for this coin
117
+ * @param testnet {Network} test network for this coin
118
+ * @param minConfirmations {number} min confirmations count to treat the coin's transaction confirmed
119
+ * @param payableEntityStringForFeeRate {string|null} the payable fee entity like byte for bitcoin or gas for ether if present
120
+ * @param feeOptionsTimeStringsSortedDesc {string[]} array of 4 strings for fee options when sending coins. Should be sorted from the highest time to the smallest
121
+ * @param feeRatesExpirationTimeMs {number} number of milliseconds to treat the fee rates as expired
122
+ * @param blockchain {Blockchain} blockchain object
123
+ * @param [protocol] {Protocol|null} token/coin protocol if relevant
124
+ * @param [tokenAddress] {string|null} address of contract of this token (if the coin is token)
125
+ * @param [doesUseLowerCaseAddresses] {boolean} flag to clarify whether we can use lower case addresses to ensure more robust comparisons
126
+ * @param [doesUseOutputs=false] {boolean} true if this coin uses inputs/outputs concept and false if it uses just balances
127
+ */
128
+ constructor(
129
+ latinName,
130
+ ticker,
131
+ tickerPrintable,
132
+ digitsCountAfterComma,
133
+ maxValue,
134
+ atomName,
135
+ mainnet,
136
+ testnet,
137
+ minConfirmations,
138
+ payableEntityStringForFeeRate,
139
+ feeOptionsTimeStringsSortedDesc,
140
+ feeRatesExpirationTimeMs,
141
+ blockchain,
142
+ protocol = null,
143
+ tokenAddress = null,
144
+ doesUseLowerCaseAddresses = true,
145
+ doesUseOutputs = false
146
+ ) {
147
+ this.latinName = latinName;
148
+ this.ticker = ticker;
149
+ this.tickerPrintable = tickerPrintable;
150
+ this.digits = digitsCountAfterComma;
151
+ this.maxValue = maxValue;
152
+ this.atomName = atomName;
153
+ this.mainnet = mainnet;
154
+ this.testnet = testnet;
155
+ this.minConfirmations = minConfirmations;
156
+ this.payableEntityStringForFeeRate = payableEntityStringForFeeRate;
157
+ this.feeOptionsTimeStringsSortedDesc = feeOptionsTimeStringsSortedDesc;
158
+ this.feeRatesExpirationTimeMs = feeRatesExpirationTimeMs;
159
+ this.protocol = protocol;
160
+ this.blockchain = blockchain;
161
+ // TODO: [bug, critical] use testnet property for testnet contract address as it blocks the app work in testnets
162
+ this.tokenAddress = tokenAddress;
163
+ this.feeCoin = this;
164
+ this._significantDigits = 8;
165
+ this.doesUseLowerCaseAddresses = doesUseLowerCaseAddresses;
166
+ this.doesUseOutputs = doesUseOutputs;
167
+ }
168
+
169
+ /**
170
+ * Sets fee coin
171
+ *
172
+ * @param feeCoin {Coin} some tokens use another coin to charge transaction fee as they work on top of some external
173
+ * blockchain. So pass here the coin the token uses for fee charging. Like for ERC20 token the fee coin is ETH.
174
+ * By default, the creating coin will be set as a value for this field.
175
+ */
176
+ setFeeCoin(feeCoin) {
177
+ this.feeCoin = feeCoin;
178
+ }
179
+
180
+ /**
181
+ * Checks whether this coin uses another coin (blockchain) to charge fee for transactions (means works on base of
182
+ * some external blockchain).
183
+ *
184
+ * @return {boolean} true if this coin uses external blockchain to perform transactions and charge fee
185
+ */
186
+ doesUseDifferentCoinFee() {
187
+ return this.feeCoin !== this;
188
+ }
189
+
190
+ /**
191
+ * Converts the given atoms string/number to string representing the same amount in coin itself - floating point number
192
+ *
193
+ * @param atoms {string} atoms positive integer amount
194
+ * @return {string} coin amount floating point number as a string
195
+ */
196
+ atomsToCoinAmount(atoms) {
197
+ throw new Error("Not implemented in base Coin");
198
+ }
199
+
200
+ /**
201
+ * Converts the given coins amount string/number to string representing the same amount in coin atoms - integer number
202
+ *
203
+ * @param coinsAmount {string} coins positive floating point amount
204
+ * @return {string} coin atoms amount integer number as a string
205
+ */
206
+ coinAmountToAtoms(coinsAmount) {
207
+ throw new Error("Not implemented in base Coin");
208
+ }
209
+
210
+ /**
211
+ * Composes URL to view the tx with given id in the external blockchain explorer
212
+ *
213
+ * @param txId {string} id of transaction
214
+ * @return {string} URL string
215
+ */
216
+ composeUrlToTransactionExplorer(txId) {
217
+ throw new Error("Not implemented in base Coin");
218
+ }
219
+
220
+ /**
221
+ * Most of the cryptocurrencies has specific fee rate or fee price metric. This value usually has specific measure
222
+ * like satoshi/byte or gWei/gas. This function adds the described denomination string to the given amount
223
+ * as a suffix and returns the result string ready to be show to a user.
224
+ *
225
+ * @param coinAtomsString {string} coin atoms positive integer amount
226
+ * @return {string} string of coin amount and fee rate units
227
+ */
228
+ coinAtomsFeeRateToCommonlyUsedAmountFormatWithDenominationString(coinAtomsString) {
229
+ throw new Error("Not implemented in base Coin");
230
+ }
231
+
232
+ /**
233
+ * Check whether this coin support transaction prioritisation during the sending process.
234
+ *
235
+ * @return {boolean} true if support transaction prioritisation and false otherwise
236
+ */
237
+ doesSupportTransactionPrioritisation() {
238
+ return Array.isArray(this.feeOptionsTimeStringsSortedDesc);
239
+ }
240
+
241
+ tickerAndProtocol() {
242
+ try {
243
+ return `${this.tickerPrintable}${this.protocol ? " " + this.protocol.protocol ?? "" : ""}`;
244
+ } catch (e) {
245
+ improveAndRethrow(e, "tickerAndProtocol");
246
+ }
247
+ }
248
+ }
@@ -0,0 +1,5 @@
1
+ export class Protocol {
2
+ constructor(protocolName) {
3
+ this.protocol = protocolName;
4
+ }
5
+ }
@@ -1,15 +1,11 @@
1
1
  export class FiatCurrenciesService {
2
2
  static getFullCurrencyNameByCode(code = "") {
3
- const data = fiatCurrenciesList.find(
4
- (currencyData) => currencyData[0] === code.toUpperCase()
5
- );
3
+ const data = fiatCurrenciesList.find(currencyData => currencyData[0] === code.toUpperCase());
6
4
  return (data && data[2]) || null;
7
5
  }
8
6
 
9
7
  static isCodeValid(code) {
10
- return !!fiatCurrenciesList.find(
11
- (currenciesData) => currenciesData[0] === code
12
- );
8
+ return !!fiatCurrenciesList.find(currenciesData => currenciesData[0] === code);
13
9
  }
14
10
 
15
11
  /**
@@ -19,9 +15,7 @@ export class FiatCurrenciesService {
19
15
  * @return {string|null} code or null if there is no symbol for the currency
20
16
  */
21
17
  static getCurrencySymbolByCode(code = "") {
22
- const data = fiatCurrenciesList.find(
23
- (currencyData) => currencyData[0] === code.toUpperCase()
24
- );
18
+ const data = fiatCurrenciesList.find(currencyData => currencyData[0] === code.toUpperCase());
25
19
  return data?.[1] ?? null;
26
20
  }
27
21
 
@@ -30,9 +24,7 @@ export class FiatCurrenciesService {
30
24
  * @return {number|null}
31
25
  */
32
26
  static getCurrencyDecimalCountByCode(code = "") {
33
- const data = fiatCurrenciesList.find(
34
- (currencyData) => currencyData[0] === code.toUpperCase()
35
- );
27
+ const data = fiatCurrenciesList.find(currencyData => currencyData[0] === code.toUpperCase());
36
28
  return data?.[3] ?? null;
37
29
  }
38
30
  }
@@ -0,0 +1,12 @@
1
+ import should from "should";
2
+
3
+ import { describe, it } from "vitest";
4
+ import { IpAddressProvider } from "../../../../external-apis/ipAddressProviders.js";
5
+
6
+ describe("ipAddressProviders", function () {
7
+ describe("#getClientIpAddress", function () {
8
+ it("Should successfully retrieve IP address", async function () {
9
+ (await IpAddressProvider.getClientIpAddress()).should.not.be.empty();
10
+ });
11
+ });
12
+ });