@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.
- package/.env +1 -1
- package/.env.example +1 -1
- package/coverage/clover.xml +1411 -1410
- package/coverage/coverage-final.json +18 -18
- package/coverage/index.html +17 -17
- package/coverage/ui-kit/index.html +1 -1
- package/coverage/ui-kit/index.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/googleAnalyticsAdapter.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/metrikaAdapter.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/analyticsAdapters/mixpanelAdapter.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/axiosAdapter.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/adapters/qrUtils.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/external-apis/apiGroups.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/external-apis/emailAPI.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/external-apis/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/external-apis/ipAddressProviders.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/globalConstants.jsx.html +1 -1
- package/coverage/ui-kit/src/common-apis/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/models/blockchain.js.html +4 -4
- package/coverage/ui-kit/src/common-apis/models/coin.js.html +221 -221
- package/coverage/ui-kit/src/common-apis/models/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/models/protocol.js.html +3 -3
- package/coverage/ui-kit/src/common-apis/services/fiatCurrenciesService.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/services/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/utils/amountUtils.js.html +21 -21
- package/coverage/ui-kit/src/common-apis/utils/cache.js.html +6 -6
- package/coverage/ui-kit/src/common-apis/utils/errorUtils.js.html +13 -13
- package/coverage/ui-kit/src/common-apis/utils/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/utils/logging/index.html +1 -1
- package/coverage/ui-kit/src/common-apis/utils/logging/logger.js.html +22 -22
- package/coverage/ui-kit/src/common-apis/utils/logging/logsStorage.js.html +3 -3
- package/coverage/ui-kit/src/common-apis/utils/postponeExecution.js.html +1 -1
- package/coverage/ui-kit/src/common-apis/utils/rabbitTicker.js.html +10 -10
- package/coverage/ui-kit/src/common-apis/utils/safeStringify.js.html +27 -27
- package/coverage/ui-kit/src/index.html +1 -1
- package/coverage/ui-kit/src/index.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/cacheAndConcurrentRequestsResolver.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/cachedRobustExternalApiCallerService.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/cancelProcessing.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/concurrentCalculationsMetadataHolder.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/externalApiProvider.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/externalServicesStatsCollector.js.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/index.html +1 -1
- package/coverage/ui-kit/src/robust-api-caller/robustExternalAPICallerService.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/external-apis/exolixSwapProvider.js.html +66 -45
- package/coverage/ui-kit/src/swaps-lib/external-apis/goexmeSwapProvider.js.html +521 -545
- package/coverage/ui-kit/src/swaps-lib/external-apis/index.html +27 -27
- package/coverage/ui-kit/src/swaps-lib/external-apis/letsExchangeSwapProvider.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/external-apis/swapProvider.js.html +328 -328
- package/coverage/ui-kit/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +76 -52
- package/coverage/ui-kit/src/swaps-lib/external-apis/utils.js.html +14 -14
- package/coverage/ui-kit/src/swaps-lib/models/baseSwapCreationInfo.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/models/existingSwap.js.html +141 -141
- package/coverage/ui-kit/src/swaps-lib/models/existingSwapWithFiatData.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/models/index.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/models/partner.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/models/swapProviderCoinInfo.js.html +73 -73
- package/coverage/ui-kit/src/swaps-lib/services/index.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/services/publicSwapService.js.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/utils/index.html +1 -1
- package/coverage/ui-kit/src/swaps-lib/utils/swapUtils.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowTosca.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/arrowWhite.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/darkRectangle.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/determinedError.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/failedValidationIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/infoIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/messageIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/noticeQuestionIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/successfulValidationIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/supportDialogImage.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/assets/wrappedImages/walletIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/AssetIcon/AssetIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/AssetIcon/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/AssetSelection/AssetSelection.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/AssetSelection/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/BackgroundTitle/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/InformationMessage/InformationMessage.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/InformationMessage/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Input/Input.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Input/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/LoadingDots/LoadingDots.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/LoadingDots/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/NoticeIcon/NoticeIcon.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/NoticeIcon/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/QrCode/QrCode.jsx.html +7 -25
- package/coverage/ui-kit/src/ui-kit/components/atoms/QrCode/index.html +5 -5
- package/coverage/ui-kit/src/ui-kit/components/atoms/RateSelector/RateSelector.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/RateSelector/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/SupportChat/SupportChat.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/SupportChat/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Textarea/Textarea.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Textarea/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/TitleBox/TitleBox.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/TitleBox/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Tooltip/Tooltip.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Tooltip/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/TwoLinesOfText/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Validation/Validation.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/Validation/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Button/Button.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Button/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Close/Close.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/Close/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/LinkButton.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/LinkButton/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/atoms/buttons/RadioButtonWithText/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/AmountInput/AmountInput.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/AmountInput/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/CoinPicker/CoinPicker.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/CoinPicker/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/ColoredNotice/ColoredNotice.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/ColoredNotice/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/LineWithIconLink/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/LogoCarousel/LogoCarousel.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/LogoCarousel/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/SearchableCoinsList.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/SearchableCoinsList/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/molecules/TitledLineWithIconLink/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/CoinPickerDialogStep/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/Dialog.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogButtons/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/DialogStep/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/Dialog/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/SwapForm/SwapForm.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/SwapForm/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/WaitlistSubscription.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/organisms/WaitlistSubscription/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +1 -1
- package/coverage/ui-kit/src/ui-kit/components/templates/DeterminedErrorDialogStep/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/hooks/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/hooks/useCallHandlingErrors.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/hooks/useIsHydrated.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/hooks/useReferredState.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/index.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/inputValueProviders.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/searchCoins.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/textUtils.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/uiUtils.js.html +1 -1
- package/coverage/ui-kit/src/ui-kit/utils/urlQueryUtils.js.html +1 -1
- package/coverage/ui-kit/stories/atoms/BackgroundTitle.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/LinesOfText.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/LoadingDots.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/QrCode.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/RateSelector.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/Validation.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/buttons/Button.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/buttons/Close.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/buttons/LinkButton.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/atoms/buttons/index.html +1 -1
- package/coverage/ui-kit/stories/atoms/index.html +1 -1
- package/coverage/ui-kit/stories/molecules/AmountInput.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/CoinPicker.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/ColoredNotice.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/LineWithIconLink.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/LogoCarousel.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/TitledLineWithIconLink.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/molecules/index.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/Dialog.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/DialogButtons/index.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/DialogStep/index.html +1 -1
- package/coverage/ui-kit/stories/organisms/Dialog/index.html +1 -1
- package/coverage/ui-kit/stories/organisms/WaitlistSubscription.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/organisms/index.html +1 -1
- package/coverage/ui-kit/stories/stubs/coins.jsx.html +1 -1
- package/coverage/ui-kit/stories/stubs/exampleContent.jsx.html +1 -1
- package/coverage/ui-kit/stories/stubs/index.html +1 -1
- package/coverage/ui-kit/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +1 -1
- package/coverage/ui-kit/stories/templates/index.html +1 -1
- package/dist/index.cjs +94 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -12
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +82 -78
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +94 -92
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +94 -92
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/common-apis/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +9 -5
- package/src/swaps-lib/external-apis/exolixSwapProvider.js +46 -39
- package/src/swaps-lib/external-apis/goexmeSwapProvider.js +29 -37
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +54 -46
- package/src/swaps-lib/models/existingSwap.js +1 -1
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_convertCurrencyMeta.test.js +80 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_ensurePairsLoaded.test.js +77 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +50 -123
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/createSwap.test.js +184 -72
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getExistingSwapsDetailsAndStatus.test.js +151 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/getSwapInfo.test.js +155 -104
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/helpers.test.js +26 -0
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/PairSupport.int.test.js +57 -57
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/_fetchSupportedCurrenciesIfNeeded.int.test.js +289 -126
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/createSwap.int.test.js +320 -225
- package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/getSwapInfo.int.test.js +138 -127
- package/src/ui-kit/components/atoms/QrCode/QrCode.jsx +2 -8
- 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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
50
|
+
afterEach(() => sinon.restore());
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
90
|
+
it("Should throw when amount ≤ 0", async () => {
|
|
91
|
+
await provider.getSwapInfo(BTC, ETH, "0").should.be.rejected();
|
|
92
|
+
});
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
await provider.getSwapInfo(BTC, ETH, "1", true);
|
|
109
|
+
axiosStub.lastCall.args[1].params.fix.should.be.true();
|
|
110
|
+
});
|
|
127
111
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
});
|
package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/PairSupport.int.test.js
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
|
-
import
|
|
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
|
-
|
|
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("
|
|
55
|
-
|
|
37
|
+
maybeDescribe("external-apis/goexmeSwapProvider integration", function () {
|
|
38
|
+
describe("pair support (live)", function () {
|
|
39
|
+
let provider;
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
expect(toCoin, "toCoin missing").toBeTruthy();
|
|
54
|
+
should.exist(fromCoin);
|
|
55
|
+
should.exist(toCoin);
|
|
78
56
|
|
|
79
|
-
|
|
57
|
+
const response = await provider.getSwapInfo(fromCoin, toCoin, "1", false);
|
|
58
|
+
checkPairSupported(response, provider).should.be.true();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
80
61
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
});
|