@rabbitio/ui-kit 1.0.0-beta.110 → 1.0.0-beta.112

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 (212) hide show
  1. package/.env +1 -1
  2. package/.env.example +1 -1
  3. package/coverage/clover.xml +1411 -1410
  4. package/coverage/coverage-final.json +18 -18
  5. package/coverage/index.html +17 -17
  6. package/coverage/ui-kit/index.html +1 -1
  7. package/coverage/ui-kit/index.js.html +1 -1
  8. package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +1 -1
  9. package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +1 -1
  10. package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +1 -1
  11. package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +1 -1
  12. package/coverage/ui-kit/src/common-apis/adapters/axiosAdapter.js.html +1 -1
  13. package/coverage/ui-kit/src/common-apis/adapters/index.html +1 -1
  14. package/coverage/ui-kit/src/common-apis/adapters/qrUtils.js.html +1 -1
  15. package/coverage/ui-kit/src/common-apis/external-apis/apiGroups.js.html +1 -1
  16. package/coverage/ui-kit/src/common-apis/external-apis/emailAPI.js.html +1 -1
  17. package/coverage/ui-kit/src/common-apis/external-apis/index.html +1 -1
  18. package/coverage/ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +1 -1
  19. package/coverage/ui-kit/src/common-apis/globalConstants.jsx.html +1 -1
  20. package/coverage/ui-kit/src/common-apis/index.html +1 -1
  21. package/coverage/ui-kit/src/common-apis/models/blockchain.js.html +4 -4
  22. package/coverage/ui-kit/src/common-apis/models/coin.js.html +221 -221
  23. package/coverage/ui-kit/src/common-apis/models/index.html +1 -1
  24. package/coverage/ui-kit/src/common-apis/models/protocol.js.html +3 -3
  25. package/coverage/ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +1 -1
  26. package/coverage/ui-kit/src/common-apis/services/index.html +1 -1
  27. package/coverage/ui-kit/src/common-apis/utils/amountUtils.js.html +21 -21
  28. package/coverage/ui-kit/src/common-apis/utils/cache.js.html +6 -6
  29. package/coverage/ui-kit/src/common-apis/utils/errorUtils.js.html +13 -13
  30. package/coverage/ui-kit/src/common-apis/utils/index.html +1 -1
  31. package/coverage/ui-kit/src/common-apis/utils/logging/index.html +1 -1
  32. package/coverage/ui-kit/src/common-apis/utils/logging/logger.js.html +22 -22
  33. package/coverage/ui-kit/src/common-apis/utils/logging/logsStorage.js.html +3 -3
  34. package/coverage/ui-kit/src/common-apis/utils/postponeExecution.js.html +1 -1
  35. package/coverage/ui-kit/src/common-apis/utils/rabbitTicker.js.html +10 -10
  36. package/coverage/ui-kit/src/common-apis/utils/safeStringify.js.html +27 -27
  37. package/coverage/ui-kit/src/index.html +1 -1
  38. package/coverage/ui-kit/src/index.js.html +1 -1
  39. package/coverage/ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1 -1
  40. package/coverage/ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +1 -1
  41. package/coverage/ui-kit/src/robust-api-caller/cancelProcessing.js.html +1 -1
  42. package/coverage/ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +1 -1
  43. package/coverage/ui-kit/src/robust-api-caller/externalApiProvider.js.html +1 -1
  44. package/coverage/ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +1 -1
  45. package/coverage/ui-kit/src/robust-api-caller/index.html +1 -1
  46. package/coverage/ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +1 -1
  47. package/coverage/ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +66 -45
  48. package/coverage/ui-kit/src/swaps-lib/external-apis/goexmeSwapProvider.js.html +521 -545
  49. package/coverage/ui-kit/src/swaps-lib/external-apis/index.html +27 -27
  50. package/coverage/ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1 -1
  51. package/coverage/ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +328 -328
  52. package/coverage/ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +76 -52
  53. package/coverage/ui-kit/src/swaps-lib/external-apis/utils.js.html +14 -14
  54. package/coverage/ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +1 -1
  55. package/coverage/ui-kit/src/swaps-lib/models/existingSwap.js.html +141 -141
  56. package/coverage/ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +1 -1
  57. package/coverage/ui-kit/src/swaps-lib/models/index.html +1 -1
  58. package/coverage/ui-kit/src/swaps-lib/models/partner.js.html +1 -1
  59. package/coverage/ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +73 -73
  60. package/coverage/ui-kit/src/swaps-lib/services/index.html +1 -1
  61. package/coverage/ui-kit/src/swaps-lib/services/publicSwapService.js.html +1 -1
  62. package/coverage/ui-kit/src/swaps-lib/utils/index.html +1 -1
  63. package/coverage/ui-kit/src/swaps-lib/utils/swapUtils.js.html +1 -1
  64. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +1 -1
  65. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +1 -1
  66. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +1 -1
  67. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +1 -1
  68. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +1 -1
  69. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +1 -1
  70. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/index.html +1 -1
  71. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +1 -1
  72. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +1 -1
  73. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +1 -1
  74. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +1 -1
  75. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +1 -1
  76. package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +1 -1
  77. package/coverage/ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +1 -1
  78. package/coverage/ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +1 -1
  79. package/coverage/ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +1 -1
  80. package/coverage/ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +1 -1
  81. package/coverage/ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +1 -1
  82. package/coverage/ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +1 -1
  83. package/coverage/ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +1 -1
  84. package/coverage/ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +1 -1
  85. package/coverage/ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +1 -1
  86. package/coverage/ui-kit/src/ui-kit/components/atoms/Input/index.html +1 -1
  87. package/coverage/ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +1 -1
  88. package/coverage/ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +1 -1
  89. package/coverage/ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +1 -1
  90. package/coverage/ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +1 -1
  91. package/coverage/ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +7 -25
  92. package/coverage/ui-kit/src/ui-kit/components/atoms/QrCode/index.html +5 -5
  93. package/coverage/ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +1 -1
  94. package/coverage/ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +1 -1
  95. package/coverage/ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +1 -1
  96. package/coverage/ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +1 -1
  97. package/coverage/ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +1 -1
  98. package/coverage/ui-kit/src/ui-kit/components/atoms/Textarea/index.html +1 -1
  99. package/coverage/ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +1 -1
  100. package/coverage/ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +1 -1
  101. package/coverage/ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +1 -1
  102. package/coverage/ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +1 -1
  103. package/coverage/ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +1 -1
  104. package/coverage/ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +1 -1
  105. package/coverage/ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +1 -1
  106. package/coverage/ui-kit/src/ui-kit/components/atoms/Validation/index.html +1 -1
  107. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +1 -1
  108. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +1 -1
  109. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +1 -1
  110. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +1 -1
  111. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +1 -1
  112. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +1 -1
  113. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +1 -1
  114. package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +1 -1
  115. package/coverage/ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1 -1
  116. package/coverage/ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +1 -1
  117. package/coverage/ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1 -1
  118. package/coverage/ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +1 -1
  119. package/coverage/ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +1 -1
  120. package/coverage/ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +1 -1
  121. package/coverage/ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +1 -1
  122. package/coverage/ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +1 -1
  123. package/coverage/ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +1 -1
  124. package/coverage/ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +1 -1
  125. package/coverage/ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +1 -1
  126. package/coverage/ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +1 -1
  127. package/coverage/ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +1 -1
  128. package/coverage/ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +1 -1
  129. package/coverage/ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +1 -1
  130. package/coverage/ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +1 -1
  131. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1 -1
  132. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +1 -1
  133. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +1 -1
  134. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1 -1
  135. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +1 -1
  136. package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/index.html +1 -1
  137. package/coverage/ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +1 -1
  138. package/coverage/ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +1 -1
  139. package/coverage/ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +1 -1
  140. package/coverage/ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +1 -1
  141. package/coverage/ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +1 -1
  142. package/coverage/ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +1 -1
  143. package/coverage/ui-kit/src/ui-kit/hooks/index.html +1 -1
  144. package/coverage/ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +1 -1
  145. package/coverage/ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +1 -1
  146. package/coverage/ui-kit/src/ui-kit/hooks/useReferredState.js.html +1 -1
  147. package/coverage/ui-kit/src/ui-kit/utils/index.html +1 -1
  148. package/coverage/ui-kit/src/ui-kit/utils/inputValueProviders.js.html +1 -1
  149. package/coverage/ui-kit/src/ui-kit/utils/searchCoins.js.html +1 -1
  150. package/coverage/ui-kit/src/ui-kit/utils/textUtils.js.html +1 -1
  151. package/coverage/ui-kit/src/ui-kit/utils/uiUtils.js.html +1 -1
  152. package/coverage/ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +1 -1
  153. package/coverage/ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +1 -1
  154. package/coverage/ui-kit/stories/atoms/LinesOfText.stories.jsx.html +1 -1
  155. package/coverage/ui-kit/stories/atoms/LoadingDots.stories.jsx.html +1 -1
  156. package/coverage/ui-kit/stories/atoms/QrCode.stories.jsx.html +1 -1
  157. package/coverage/ui-kit/stories/atoms/RateSelector.stories.jsx.html +1 -1
  158. package/coverage/ui-kit/stories/atoms/Validation.stories.jsx.html +1 -1
  159. package/coverage/ui-kit/stories/atoms/buttons/Button.stories.jsx.html +1 -1
  160. package/coverage/ui-kit/stories/atoms/buttons/Close.stories.jsx.html +1 -1
  161. package/coverage/ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +1 -1
  162. package/coverage/ui-kit/stories/atoms/buttons/index.html +1 -1
  163. package/coverage/ui-kit/stories/atoms/index.html +1 -1
  164. package/coverage/ui-kit/stories/molecules/AmountInput.stories.jsx.html +1 -1
  165. package/coverage/ui-kit/stories/molecules/CoinPicker.stories.jsx.html +1 -1
  166. package/coverage/ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +1 -1
  167. package/coverage/ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +1 -1
  168. package/coverage/ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +1 -1
  169. package/coverage/ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +1 -1
  170. package/coverage/ui-kit/stories/molecules/index.html +1 -1
  171. package/coverage/ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +1 -1
  172. package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +1 -1
  173. package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/index.html +1 -1
  174. package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +1 -1
  175. package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/index.html +1 -1
  176. package/coverage/ui-kit/stories/organisms/Dialog/index.html +1 -1
  177. package/coverage/ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +1 -1
  178. package/coverage/ui-kit/stories/organisms/index.html +1 -1
  179. package/coverage/ui-kit/stories/stubs/coins.jsx.html +1 -1
  180. package/coverage/ui-kit/stories/stubs/exampleContent.jsx.html +1 -1
  181. package/coverage/ui-kit/stories/stubs/index.html +1 -1
  182. package/coverage/ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +1 -1
  183. package/coverage/ui-kit/stories/templates/index.html +1 -1
  184. package/dist/index.cjs +94 -92
  185. package/dist/index.cjs.map +1 -1
  186. package/dist/index.css +4 -12
  187. package/dist/index.css.map +1 -1
  188. package/dist/index.modern.js +82 -78
  189. package/dist/index.modern.js.map +1 -1
  190. package/dist/index.module.js +94 -92
  191. package/dist/index.module.js.map +1 -1
  192. package/dist/index.umd.js +94 -92
  193. package/dist/index.umd.js.map +1 -1
  194. package/package.json +1 -1
  195. package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +9 -5
  196. package/src/swaps-lib/external-apis/exolixSwapProvider.js +46 -39
  197. package/src/swaps-lib/external-apis/goexmeSwapProvider.js +29 -37
  198. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +54 -46
  199. package/src/swaps-lib/models/existingSwap.js +1 -1
  200. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_convertCurrencyMeta.test.js +80 -0
  201. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_ensurePairsLoaded.test.js +77 -0
  202. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +50 -123
  203. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/createSwap.test.js +184 -72
  204. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getExistingSwapsDetailsAndStatus.test.js +151 -0
  205. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getSwapInfo.test.js +155 -104
  206. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/helpers.test.js +26 -0
  207. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/PairSupport.int.test.js +57 -57
  208. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/_fetchSupportedCurrenciesIfNeeded.int.test.js +289 -126
  209. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/createSwap.int.test.js +320 -225
  210. package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/getSwapInfo.int.test.js +138 -127
  211. package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +2 -8
  212. package/src/ui-kit/components/atoms/QrCode/qr-code.module.scss +4 -11
@@ -1,7 +1,8 @@
1
1
  import sinon from "sinon";
2
2
  import axios from "axios";
3
- import { describe, it, beforeEach, afterEach, expect } from "vitest";
4
3
  import should from "should";
4
+ import { describe, it, beforeEach, afterEach } from "vitest";
5
+ import BigNumber from "bignumber.js";
5
6
 
6
7
  import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
7
8
  import { Cache } from "../../../../common-apis/utils/cache.js";
@@ -26,124 +27,174 @@ const ETH = new Coin(
26
27
  new Blockchain("Ethereum")
27
28
  );
28
29
 
29
- describe("goexmeSwapProvider::getSwapInfo", () => {
30
- const okRate = { result: true, rate: "15", minamount: "0.01", maxamount: "5" };
31
- let provider, axiosStub;
32
-
33
- beforeEach(() => {
34
- provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
35
- provider._supportedCoins = [
36
- { coin: BTC, code: "BTC", network: "BTC" },
37
- { coin: ETH, code: "ETH", network: "ETH" },
38
- ];
39
- provider._supportedCoinsLastUpdateTimestamp = Date.now();
40
- sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
41
- axiosStub = sinon.stub(axios, "get").callsFake(url => {
42
- if (url.includes("/pairs")) return Promise.resolve({ status: 200, data: { BTC: ["ETH"] } });
43
- if (url.includes("/rate")) return Promise.resolve({ status: 200, data: okRate });
44
- return Promise.resolve({ status: 200, data: {} });
30
+ describe("goexmeSwapProvider", function () {
31
+ describe("getSwapInfo", function () {
32
+ const okRate = { result: true, rate: "15", minamount: "0.01", maxamount: "5" };
33
+ let provider, axiosStub;
34
+
35
+ beforeEach(() => {
36
+ provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
37
+ provider._supportedCoins = [
38
+ { coin: BTC, code: "BTC", network: "BTC" },
39
+ { coin: ETH, code: "ETH", network: "ETH" },
40
+ ];
41
+ provider._supportedCoinsLastUpdateTimestamp = Date.now();
42
+ sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
43
+ axiosStub = sinon.stub(axios, "get").callsFake(url => {
44
+ if (url.includes("/pairs")) return Promise.resolve({ status: 200, data: { BTC: ["ETH"] } });
45
+ if (url.includes("/rate")) return Promise.resolve({ status: 200, data: okRate });
46
+ return Promise.resolve({ status: 200, data: {} });
47
+ });
45
48
  });
46
- });
47
49
 
48
- afterEach(() => sinon.restore());
50
+ afterEach(() => sinon.restore());
49
51
 
50
- it("returns NOT_SUPPORTED if pair absent", async () => {
51
- axiosStub.withArgs(sinon.match(/\/pairs/)).resolves({ status: 200, data: { BTC: ["USDT"] } });
52
- (await provider.getSwapInfo(BTC, ETH, "1")).reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
53
- });
52
+ it("Should return NOT_SUPPORTED if pair absent", async () => {
53
+ axiosStub.withArgs(sinon.match(/\/pairs/)).resolves({ status: 200, data: { BTC: ["USDT"] } });
54
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
55
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
56
+ });
54
57
 
55
- it("returns TOO_LOW / TOO_HIGH against min/max", async () => {
56
- (await provider.getSwapInfo(BTC, ETH, "0.001")).reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_LOW);
57
- (await provider.getSwapInfo(BTC, ETH, "10")).reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_HIGH);
58
- });
58
+ it("Should return TOO_LOW and TOO_HIGH against min/max", async () => {
59
+ let info = await provider.getSwapInfo(BTC, ETH, "0.001");
60
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_LOW);
61
+ info = await provider.getSwapInfo(BTC, ETH, "10");
62
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_HIGH);
63
+ });
59
64
 
60
- it("handles case with no min/max limits", async () => {
61
- axiosStub.withArgs(sinon.match(/\/rate/)).resolves({ status: 200, data: { result: true, rate: "15" } });
62
- const r = await provider.getSwapInfo(BTC, ETH, "1");
63
- r.result.should.be.true();
64
- });
65
+ it("Should handle case with no min/max limits", async () => {
66
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({ status: 200, data: { result: true, rate: "15" } });
67
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
68
+ info.result.should.be.true();
69
+ });
65
70
 
66
- it("maps 429 to REQUESTS_LIMIT_EXCEEDED", async () => {
67
- axiosStub.withArgs(sinon.match(/\/rate/)).rejects({ response: { status: 429 } });
68
- const r = await provider.getSwapInfo(BTC, ETH, "1");
69
- r.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
70
- });
71
+ it("Should map HTTP 429 to REQUESTS_LIMIT_EXCEEDED", async () => {
72
+ axiosStub.withArgs(sinon.match(/\/rate/)).rejects({ response: { status: 429 } });
73
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
74
+ info.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
75
+ });
71
76
 
72
- it("returns valid structure on success", async () => {
73
- const r = await provider.getSwapInfo(BTC, ETH, "1");
74
- r.result.should.be.true();
75
- parseFloat(r.rate).should.be.greaterThan(0);
76
- });
77
+ it("Should return valid structure on success", async () => {
78
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
79
+ info.result.should.be.true();
80
+ parseFloat(info.rate).should.be.greaterThan(0);
81
+ });
77
82
 
78
- it("sends proper params to /rate", async () => {
79
- await provider.getSwapInfo(BTC, ETH, "1");
80
- const p = axiosStub.args.find(a => a[0].includes("/rate"))[1].params;
81
- p.should.match({ from: "BTC", to: "ETH", amount: "1" });
82
- });
83
+ it("Should send proper params to /rate", async () => {
84
+ await provider.getSwapInfo(BTC, ETH, "1");
85
+ const call = axiosStub.args.find(a => a[0].includes("/rate"));
86
+ const params = call[1].params;
87
+ params.should.match({ from: "BTC", to: "ETH", amount: "1" });
88
+ });
83
89
 
84
- it("throws on non-Coin params", async () => {
85
- await expect(provider.getSwapInfo({}, {}, "1")).rejects.toThrow();
86
- });
87
- });
90
+ it("Should throw when amount ≤ 0", async () => {
91
+ await provider.getSwapInfo(BTC, ETH, "0").should.be.rejected();
92
+ });
88
93
 
89
- describe("goexmeSwapProvider::status mapping & existing swaps", () => {
90
- const raw = {
91
- status: "success",
92
- id: "swap1",
93
- date: "21-07-2023 04:17:30",
94
- from: "BTC",
95
- to: "ETH",
96
- depositAddress: "addr-in",
97
- destinationAddress: "addr-out",
98
- amountFrom: "1",
99
- amountTo: "0.01",
100
- result: true,
101
- };
102
- let provider, axiosStub;
103
-
104
- beforeEach(() => {
105
- provider = new GoexmeSwapProvider("/", new Cache(), () => null, false);
106
- provider._supportedCoins = [
107
- { coin: BTC, code: "BTC", network: "BTC" },
108
- { coin: ETH, code: "ETH", network: "ETH" },
109
- ];
110
- sinon.stub(provider, "_fetchSupportedCurrenciesIfNeeded").resolves();
111
- axiosStub = sinon.stub(axios, "get").resolves({ status: 200, data: raw });
112
- });
94
+ it("Should return valid result when amount is empty string", async () => {
95
+ const info = await provider.getSwapInfo(BTC, ETH, "");
96
+ info.result.should.be.true();
97
+ });
113
98
 
114
- afterEach(() => sinon.restore());
99
+ it("Should return valid result when amount is non-string", async () => {
100
+ const info = await provider.getSwapInfo(BTC, ETH, 1);
101
+ info.result.should.be.true();
102
+ });
115
103
 
116
- it("maps every status string", () => {
117
- provider._mapGoexmeStatus("time_expired").should.equal(SwapProvider.SWAP_STATUSES.EXPIRED);
118
- provider._mapGoexmeStatus("deposit_received").should.equal(SwapProvider.SWAP_STATUSES.PAYMENT_RECEIVED);
119
- provider._mapGoexmeStatus("failed").should.equal(SwapProvider.SWAP_STATUSES.FAILED);
120
- provider._mapGoexmeStatus("exchanging").should.equal(SwapProvider.SWAP_STATUSES.EXCHANGING);
121
- provider._mapGoexmeStatus("reverted").should.equal(SwapProvider.SWAP_STATUSES.REFUNDED);
122
- });
104
+ it("Should include fix=true only when fixed quote requested", async () => {
105
+ await provider.getSwapInfo(BTC, ETH, "1", false);
106
+ axiosStub.lastCall.args[1].params.should.not.have.property("fix");
123
107
 
124
- it("throws on unknown status", () => {
125
- (() => provider._mapGoexmeStatus("weird")).should.throw(/Unknown Goexme status/);
126
- });
108
+ await provider.getSwapInfo(BTC, ETH, "1", true);
109
+ axiosStub.lastCall.args[1].params.fix.should.be.true();
110
+ });
127
111
 
128
- it("skips 404 responses", async () => {
129
- axiosStub.onFirstCall().resolves({ status: 404 });
130
- axiosStub.onSecondCall().resolves({ status: 200, data: raw });
131
- const res = await provider.getExistingSwapsDetailsAndStatus(["x", "swap1"]);
132
- res.swaps.should.have.length(1);
133
- res.swaps[0].swapId.should.equal("swap1");
134
- });
112
+ it("Should propagate unexpected network error unchanged", async () => {
113
+ const boom = new Error("net-boom");
114
+ axiosStub.rejects(boom);
115
+ await provider.getSwapInfo(BTC, ETH, "1").should.be.rejectedWith(boom);
116
+ });
135
117
 
136
- it("filters out items when coins unsupported", async () => {
137
- axiosStub.resetBehavior();
138
- axiosStub.resolves({ status: 200, data: { ...raw, from: "LTC" } });
139
- const res = await provider.getExistingSwapsDetailsAndStatus(["swapX"]);
140
- res.swaps.should.eql([]);
141
- });
118
+ it("Should return NOT_SUPPORTED when provider responds { result:false } with 200", async () => {
119
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({ status: 200, data: { result: false } });
120
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
121
+ info.result.should.be.false();
122
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
123
+ });
124
+
125
+ it("Should throw when fromCoin/toCoin are not Coin instances", async () => {
126
+ await provider.getSwapInfo({}, {}, "1").should.be.rejected();
127
+ });
128
+
129
+ it("Should throw when amountIsToReceive = true", async () => {
130
+ await provider.getSwapInfo(BTC, ETH, "1", false, null, true).should.be.rejected();
131
+ });
142
132
 
143
- it("propagates 429", async () => {
144
- axiosStub.resetBehavior();
145
- axiosStub.rejects({ response: { status: 429 } });
146
- const r = await provider.getExistingSwapsDetailsAndStatus(["id"]);
147
- r.reason.should.equal(SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
133
+ it("Should set rate=null when provider omits the rate field", async () => {
134
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({
135
+ status: 200,
136
+ data: { result: true, minamount: "0.1" },
137
+ });
138
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
139
+ should(info.rate).be.null();
140
+ });
141
+
142
+ it("Should return NOT_SUPPORTED when either fromCoin or toCoin is unsupported", async () => {
143
+ const unsupported = new Coin(
144
+ "Unsupported",
145
+ "UNS",
146
+ "UNS",
147
+ 8,
148
+ null,
149
+ "unit",
150
+ null,
151
+ null,
152
+ 1,
153
+ null,
154
+ [],
155
+ null,
156
+ new Blockchain("Unsupported")
157
+ );
158
+ let info = await provider.getSwapInfo(unsupported, ETH, "1");
159
+ info.result.should.be.false();
160
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
161
+
162
+ info = await provider.getSwapInfo(BTC, unsupported, "1");
163
+ info.result.should.be.false();
164
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
165
+ });
166
+
167
+ it("Should return NOT_SUPPORTED when /rate responds with unexpected data shape", async () => {
168
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({ status: 200, data: {} });
169
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
170
+ info.result.should.be.false();
171
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.NOT_SUPPORTED);
172
+ });
173
+
174
+ it("Should copy provider .fix flag into info.fixed", async () => {
175
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({
176
+ status: 200,
177
+ data: { result: true, rate: "15", minamount: "0.01", maxamount: "5", fix: true },
178
+ });
179
+ const info = await provider.getSwapInfo(BTC, ETH, "1");
180
+ info.result.should.be.true();
181
+ info.fixed.should.be.true();
182
+ });
183
+
184
+ it("Should return TOO_LOW and TOO_HIGH with correct smallestMin and greatestMax", async () => {
185
+ axiosStub.withArgs(sinon.match(/\/rate/)).resolves({
186
+ status: 200,
187
+ data: { result: true, rate: "15", minamount: "0.5", maxamount: "5" },
188
+ });
189
+ let info = await provider.getSwapInfo(BTC, ETH, "0.1");
190
+ info.result.should.be.false();
191
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_LOW);
192
+ info.smallestMin.should.equal("0.50000000");
193
+
194
+ info = await provider.getSwapInfo(BTC, ETH, "10");
195
+ info.result.should.be.false();
196
+ info.reason.should.equal(SwapProvider.NO_SWAPS_REASONS.TOO_HIGH);
197
+ info.greatestMax.should.equal("5.00000000");
198
+ });
148
199
  });
149
200
  });
@@ -0,0 +1,26 @@
1
+ import should from "should";
2
+ import { describe, it } from "vitest";
3
+
4
+ import { GoexmeSwapProvider } from "../../../external-apis/goexmeSwapProvider.js";
5
+ import { Cache } from "../../../../common-apis/utils/cache.js";
6
+
7
+ describe("goexmeSwapProvider", function () {
8
+ describe("helpers", function () {
9
+ it("getSwapCreationInfoTtlMs should return 30000 ms", () => {
10
+ const provider = new GoexmeSwapProvider("/", new Cache());
11
+ provider.getSwapCreationInfoTtlMs().should.equal(30000);
12
+ });
13
+
14
+ it("_parseGoexmeDate should convert date string to epoch", () => {
15
+ const timestamp = GoexmeSwapProvider._parseGoexmeDate("01.02.2024 03:04:05");
16
+ timestamp.should.equal(Date.parse("2024-02-01T03:04:05Z"));
17
+ });
18
+
19
+ it("getPartnersList should return single partner", async () => {
20
+ const provider = new GoexmeSwapProvider("/", new Cache());
21
+ const partners = await provider.getPartnersList();
22
+ partners.should.have.length(1);
23
+ partners[0].should.have.property("name", "GoExme");
24
+ });
25
+ });
26
+ });
@@ -1,97 +1,97 @@
1
1
  import "dotenv/config";
2
- import { describe, it, beforeAll, expect } from "vitest";
2
+ import sinon from "sinon";
3
+ import should from "should";
4
+ import { describe, it, beforeAll, afterEach } from "vitest";
5
+ import axios from "axios";
6
+
3
7
  import { Cache } from "../../../../../common-apis/utils/cache.js";
4
8
  import { GoexmeSwapProvider } from "../../../../external-apis/goexmeSwapProvider.js";
5
9
 
6
10
  const GOEXME_API_KEY = process.env.GOEXME_API_KEY?.trim?.() || "";
7
11
  const maybeDescribe = GOEXME_API_KEY ? describe : describe.skip;
8
12
 
9
- /**
10
- * ------------------------------------------------------------------
11
- * Positive-case: every token below **must** be exchangable
12
- * against a major counterpart (BTC, or ETH for BTC)
13
- * ------------------------------------------------------------------
14
- */
15
13
  const ALLOWED_RABBIT_TICKERS = [
16
14
  "BNBBEP20",
17
15
  "BTC",
18
16
  "DOGE",
19
17
  "DOT",
20
18
  "ETH",
21
- // "GMTSOL",
22
19
  "LTC",
23
20
  "SOL",
24
21
  "TRX",
25
22
  "USDCERC20",
26
23
  "USDTERC20",
27
- // "USDTBEP20",
28
24
  "USDTSOL",
29
25
  "USDTTRC20",
30
26
  "XMR",
31
27
  "XRP",
32
28
  ];
33
29
 
34
- /**
35
- * ------------------------------------------------------------------
36
- * Negative-case: these tokens MUST NOT be supported by the adapter
37
- * ------------------------------------------------------------------
38
- */
39
30
  const FORBIDDEN_TICKERS = ["ADA", "1INCH", "TRUMP"];
40
31
 
41
- /**
42
- * ------------------------------------------------------------------
43
- * Helper treat “pair supported” broadly:
44
- * • response.result === true
45
- * • OR response.reason is TOO_LOW / TOO_HIGH
46
- * Any other outcome (NOT_SUPPORTED etc.) means the pair fails
47
- * ------------------------------------------------------------------
48
- */
49
- function isPairSupported(resp, provider) {
50
- const { TOO_LOW, TOO_HIGH } = provider.constructor.NO_SWAPS_REASONS;
51
- return resp.result === true || [TOO_LOW, TOO_HIGH].includes(resp.reason);
32
+ function checkPairSupported(response, providerInstance) {
33
+ const { TOO_LOW, TOO_HIGH } = providerInstance.constructor.NO_SWAPS_REASONS;
34
+ return response.result === true || [TOO_LOW, TOO_HIGH].includes(response.reason);
52
35
  }
53
36
 
54
- maybeDescribe("GoexmeSwapProvider – pairs availability (live)", () => {
55
- let provider;
37
+ maybeDescribe("external-apis/goexmeSwapProvider integration", function () {
38
+ describe("pair support (live)", function () {
39
+ let provider;
56
40
 
57
- beforeAll(async () => {
58
- provider = new GoexmeSwapProvider("/", new Cache(), () => null, false, GOEXME_API_KEY);
59
- await provider._fetchSupportedCurrenciesIfNeeded();
60
- await provider._ensurePairsLoaded();
61
- });
41
+ beforeAll(async function () {
42
+ provider = new GoexmeSwapProvider("/", new Cache(), () => null, false, GOEXME_API_KEY);
43
+ await provider._fetchSupportedCurrenciesIfNeeded();
44
+ await provider._ensurePairsLoaded();
45
+ });
62
46
 
63
- /* ------------------------------------------------------------------
64
- * Positive tests one per *allowed* Rabbit-ticker
65
- * ---------------------------------------------------------------- */
66
- ALLOWED_RABBIT_TICKERS.forEach(ticker => {
67
- const fromTicker = ticker;
68
- // Use BTC as the counterpart for every token except BTC itself.
69
- const toTicker = ticker === "BTC" ? "ETH" : "BTC";
47
+ ALLOWED_RABBIT_TICKERS.forEach(fromTicker => {
48
+ const toTicker = fromTicker === "BTC" ? "ETH" : "BTC";
70
49
 
71
- it(`supports swaps for ${fromTicker} → ${toTicker}`, async () => {
72
- const fromCoin = provider.getCoinByTickerIfPresent(fromTicker);
73
- const toCoin = provider.getCoinByTickerIfPresent(toTicker);
50
+ it(`Should support swaps for ${fromTicker}→${toTicker}`, async function () {
51
+ const fromCoin = provider.getCoinByTickerIfPresent(fromTicker);
52
+ const toCoin = provider.getCoinByTickerIfPresent(toTicker);
74
53
 
75
- // Sanity: both coins must be known to the adapter
76
- expect(fromCoin, "fromCoin missing").toBeTruthy();
77
- expect(toCoin, "toCoin missing").toBeTruthy();
54
+ should.exist(fromCoin);
55
+ should.exist(toCoin);
78
56
 
79
- const resp = await provider.getSwapInfo(fromCoin, toCoin, "1", false);
57
+ const response = await provider.getSwapInfo(fromCoin, toCoin, "1", false);
58
+ checkPairSupported(response, provider).should.be.true();
59
+ });
60
+ });
80
61
 
81
- expect(
82
- isPairSupported(resp, provider),
83
- `Pair ${fromTicker}/${toTicker} unexpectedly unsupported: ${JSON.stringify(resp)}`
84
- ).toBe(true);
62
+ FORBIDDEN_TICKERS.forEach(ticker => {
63
+ it(`Should not support swaps involving forbidden token ${ticker}`, function () {
64
+ const coin = provider.getCoinByTickerIfPresent(ticker);
65
+ should(coin).be.null();
66
+ });
85
67
  });
86
68
  });
87
69
 
88
- /* ------------------------------------------------------------------
89
- * Negative tests – one per *forbidden* ticker
90
- * ---------------------------------------------------------------- */
91
- FORBIDDEN_TICKERS.forEach(ticker => {
92
- it(`does NOT support swaps involving forbidden token ${ticker}`, async () => {
93
- const coin = provider.getCoinByTickerIfPresent(ticker);
94
- expect(coin).toBeNull();
70
+ describe("_ensurePairsLoaded error propagation (live)", function () {
71
+ let providerInstance;
72
+ let axiosOriginalGet;
73
+
74
+ beforeAll(function () {
75
+ providerInstance = new GoexmeSwapProvider("/", new Cache(), () => null, false, GOEXME_API_KEY);
76
+ axiosOriginalGet = axios.get;
77
+ });
78
+
79
+ afterEach(function () {
80
+ if (axios.get.restore) {
81
+ axios.get.restore();
82
+ } else {
83
+ axios.get = axiosOriginalGet;
84
+ }
85
+ });
86
+
87
+ it("Should propagate network error from /pairs", async function () {
88
+ const networkError = new Error("net-boom");
89
+ sinon.stub(axios, "get").callsFake((url, cfg = {}) => {
90
+ if (url.includes("/pairs")) return Promise.reject(networkError);
91
+ return axiosOriginalGet(url, cfg);
92
+ });
93
+
94
+ await providerInstance._ensurePairsLoaded().should.be.rejectedWith(networkError);
95
95
  });
96
96
  });
97
97
  });