@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
package/src/swaps-lib/test/external-apis/goexmeSwapProvider/integration/getSwapInfo.int.test.js
CHANGED
|
@@ -1,141 +1,152 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
|
-
import
|
|
2
|
+
import sinon from "sinon";
|
|
3
|
+
import should from "should";
|
|
4
|
+
import { describe, it, beforeEach, afterEach } from "vitest";
|
|
3
5
|
import axios from "axios";
|
|
4
6
|
import BigNumber from "bignumber.js";
|
|
7
|
+
|
|
5
8
|
import { Cache } from "../../../../../common-apis/utils/cache.js";
|
|
6
9
|
import { GoexmeSwapProvider } from "../../../../external-apis/goexmeSwapProvider.js";
|
|
7
10
|
|
|
8
11
|
const GOEXME_API_KEY = process.env.GOEXME_API_KEY?.trim?.() || "";
|
|
9
12
|
const maybeDescribe = GOEXME_API_KEY ? describe : describe.skip;
|
|
10
13
|
|
|
11
|
-
maybeDescribe("
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expect(info.result).toBe(true);
|
|
41
|
-
expect(parseFloat(info.rate)).toBeGreaterThan(0);
|
|
42
|
-
expect(Number(info.min)).toBeLessThanOrEqual(Number(amount));
|
|
43
|
-
expect(Number(info.max)).toBeGreaterThan(Number(amount));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("pair not supported JOE → TRX", async () => {
|
|
47
|
-
const JOE = byCode("JOE");
|
|
48
|
-
const TRX = byCode("TRX");
|
|
49
|
-
if (!JOE || !TRX) return;
|
|
50
|
-
const info = await provider.getSwapInfo(JOE, TRX, "50");
|
|
51
|
-
expect(info.result).toBe(false);
|
|
52
|
-
expect(info.reason).toBe(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("too low amount", async () => {
|
|
56
|
-
const BTC = byCode("BTC");
|
|
57
|
-
const ETH = byCode("ETH");
|
|
58
|
-
const minInfo = await provider.getSwapInfo(BTC, ETH, "0.001");
|
|
59
|
-
const low = new BigNumber(minInfo.min || "0.0001").div(10).toFixed(BTC.digits);
|
|
60
|
-
const info = await provider.getSwapInfo(BTC, ETH, low);
|
|
61
|
-
expect(info.result).toBe(false);
|
|
62
|
-
expect(info.reason).toBe(provider.constructor.NO_SWAPS_REASONS.TOO_LOW);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("too high amount", async () => {
|
|
66
|
-
const BTC = byCode("BTC");
|
|
67
|
-
const ETH = byCode("ETH");
|
|
68
|
-
const base = await provider.getSwapInfo(BTC, ETH, "0.001");
|
|
69
|
-
const high = new BigNumber(base.max || "1").times(50).toFixed(BTC.digits);
|
|
70
|
-
const info = await provider.getSwapInfo(BTC, ETH, high);
|
|
71
|
-
expect(info.result).toBe(false);
|
|
72
|
-
expect(info.reason).toBe(provider.constructor.NO_SWAPS_REASONS.TOO_HIGH);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("rate limit", async () => {
|
|
76
|
-
axios.get = vi.fn((url, cfg) =>
|
|
77
|
-
url.endsWith("/rate") ? Promise.reject({ response: { status: 429 } }) : axiosOriginalGet(url, cfg)
|
|
78
|
-
);
|
|
79
|
-
const BTC = byCode("BTC");
|
|
80
|
-
const ETH = byCode("ETH");
|
|
81
|
-
const info = await provider.getSwapInfo(BTC, ETH, "0.1");
|
|
82
|
-
expect(info.result).toBe(false);
|
|
83
|
-
expect(info.reason).toBe(provider.constructor.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("amount param equals passed amount when amountIsToReceive=false", async () => {
|
|
87
|
-
let captured = null;
|
|
88
|
-
axios.get = async (url, cfg = {}) => {
|
|
89
|
-
if (url.endsWith("/rate")) captured = cfg.params.amount;
|
|
90
|
-
return axiosOriginalGet(url, cfg);
|
|
91
|
-
};
|
|
92
|
-
const BTC = byCode("BTC");
|
|
93
|
-
const ETH = byCode("ETH");
|
|
94
|
-
await provider.getSwapInfo(BTC, ETH, "0.5");
|
|
95
|
-
expect(captured).toBe("0.5");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("includes fix=true when fixed quote requested", async () => {
|
|
99
|
-
let captured = null;
|
|
100
|
-
axios.get = async (url, cfg = {}) => {
|
|
101
|
-
if (url.endsWith("/rate")) captured = cfg.params.fix;
|
|
102
|
-
return axiosOriginalGet(url, cfg);
|
|
14
|
+
maybeDescribe("external-apis/goexmeSwapProvider integration", function () {
|
|
15
|
+
describe("getSwapInfo (live)", function () {
|
|
16
|
+
let provider;
|
|
17
|
+
let axiosOriginalGet;
|
|
18
|
+
|
|
19
|
+
beforeEach(async function () {
|
|
20
|
+
provider = new GoexmeSwapProvider("/", new Cache(), () => null, false, GOEXME_API_KEY);
|
|
21
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
22
|
+
await provider._ensurePairsLoaded();
|
|
23
|
+
axiosOriginalGet = axios.get;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(function () {
|
|
27
|
+
if (axios.get.restore) {
|
|
28
|
+
axios.get.restore();
|
|
29
|
+
} else {
|
|
30
|
+
axios.get = axiosOriginalGet;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const getCoinByCode = code => provider._supportedCoins.find(c => c.code === code)?.coin || null;
|
|
35
|
+
|
|
36
|
+
const pickValidAmount = async (fromCoin, toCoin, fallbackAmount) => {
|
|
37
|
+
const info = await provider.getSwapInfo(fromCoin, toCoin, fallbackAmount);
|
|
38
|
+
if (info.result) return fallbackAmount;
|
|
39
|
+
if (info.reason === provider.constructor.NO_SWAPS_REASONS.TOO_LOW && info.smallestMin) {
|
|
40
|
+
return new BigNumber(info.smallestMin).times(1.1).toFixed(fromCoin.digits);
|
|
41
|
+
}
|
|
42
|
+
throw new Error();
|
|
103
43
|
};
|
|
104
|
-
const BTC = byCode("BTC");
|
|
105
|
-
const ETH = byCode("ETH");
|
|
106
|
-
await provider.getSwapInfo(BTC, ETH, "0.2", true);
|
|
107
|
-
expect(captured).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("handles duplicated tickers", async () => {
|
|
111
|
-
const DUP = byCode("USDTTRC20TRC20");
|
|
112
|
-
const BTC = byCode("BTC");
|
|
113
|
-
if (!DUP) return;
|
|
114
|
-
const info = await provider.getSwapInfo(DUP, BTC, "50");
|
|
115
|
-
expect(info.result).toBe(true);
|
|
116
|
-
});
|
|
117
44
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
45
|
+
it("Should return valid info for BTC→ETH", async function () {
|
|
46
|
+
const btcCoin = getCoinByCode("BTC");
|
|
47
|
+
const ethCoin = getCoinByCode("ETH");
|
|
48
|
+
const amount = await pickValidAmount(btcCoin, ethCoin, "0.001");
|
|
49
|
+
const info = await provider.getSwapInfo(btcCoin, ethCoin, amount);
|
|
50
|
+
info.result.should.be.true();
|
|
51
|
+
parseFloat(info.rate).should.be.above(0);
|
|
52
|
+
(Number(info.min) <= Number(amount)).should.be.true();
|
|
53
|
+
(Number(info.max) > Number(amount)).should.be.true();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("Should report NOT_SUPPORTED for unsupported pair JOE→TRX", async function () {
|
|
57
|
+
const joeCoin = getCoinByCode("JOE");
|
|
58
|
+
const trxCoin = getCoinByCode("TRX");
|
|
59
|
+
if (!joeCoin || !trxCoin) return;
|
|
60
|
+
const info = await provider.getSwapInfo(joeCoin, trxCoin, "50");
|
|
61
|
+
info.result.should.be.false();
|
|
62
|
+
info.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("Should return TOO_LOW for amounts below minimum", async function () {
|
|
66
|
+
const btcCoin = getCoinByCode("BTC");
|
|
67
|
+
const ethCoin = getCoinByCode("ETH");
|
|
68
|
+
const minInfo = await provider.getSwapInfo(btcCoin, ethCoin, "0.001");
|
|
69
|
+
const lowAmount = new BigNumber(minInfo.min || "0.0001").div(10).toFixed(btcCoin.digits);
|
|
70
|
+
const info = await provider.getSwapInfo(btcCoin, ethCoin, lowAmount);
|
|
71
|
+
info.result.should.be.false();
|
|
72
|
+
info.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.TOO_LOW);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("Should return TOO_HIGH for amounts above maximum", async function () {
|
|
76
|
+
const btcCoin = getCoinByCode("BTC");
|
|
77
|
+
const ethCoin = getCoinByCode("ETH");
|
|
78
|
+
const base = await provider.getSwapInfo(btcCoin, ethCoin, "0.001");
|
|
79
|
+
const highAmount = new BigNumber(base.max || "1").times(50).toFixed(btcCoin.digits);
|
|
80
|
+
const info = await provider.getSwapInfo(btcCoin, ethCoin, highAmount);
|
|
81
|
+
info.result.should.be.false();
|
|
82
|
+
info.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.TOO_HIGH);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("Should map HTTP 429 to REQUESTS_LIMIT_EXCEEDED", async function () {
|
|
86
|
+
sinon.stub(axios, "get").callsFake((url, cfg) => {
|
|
87
|
+
if (url.endsWith("/rate")) return Promise.reject({ response: { status: 429 } });
|
|
88
|
+
return axiosOriginalGet(url, cfg);
|
|
89
|
+
});
|
|
90
|
+
const btcCoin = getCoinByCode("BTC");
|
|
91
|
+
const ethCoin = getCoinByCode("ETH");
|
|
92
|
+
const info = await provider.getSwapInfo(btcCoin, ethCoin, "0.1");
|
|
93
|
+
info.result.should.be.false();
|
|
94
|
+
info.reason.should.equal(provider.constructor.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("Should send amount param equal to passed amount when amountIsToReceive=false", async function () {
|
|
98
|
+
let capturedAmount = null;
|
|
99
|
+
sinon.stub(axios, "get").callsFake((url, cfg = {}) => {
|
|
100
|
+
if (url.endsWith("/rate")) capturedAmount = cfg.params.amount;
|
|
101
|
+
return axiosOriginalGet(url, cfg);
|
|
102
|
+
});
|
|
103
|
+
const btcCoin = getCoinByCode("BTC");
|
|
104
|
+
const ethCoin = getCoinByCode("ETH");
|
|
105
|
+
await provider.getSwapInfo(btcCoin, ethCoin, "0.5");
|
|
106
|
+
capturedAmount.should.equal("0.5");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("Should return NOT_SUPPORTED when /rate responds with status 400", async function () {
|
|
110
|
+
sinon.stub(axios, "get").callsFake((url, cfg = {}) => {
|
|
111
|
+
if (url.endsWith("/rate")) return Promise.resolve({ status: 400, data: {} });
|
|
112
|
+
return axiosOriginalGet(url, cfg);
|
|
139
113
|
});
|
|
114
|
+
const btcCoin = getCoinByCode("BTC");
|
|
115
|
+
const ethCoin = getCoinByCode("ETH");
|
|
116
|
+
const info = await provider.getSwapInfo(btcCoin, ethCoin, "0.3");
|
|
117
|
+
info.result.should.be.false();
|
|
118
|
+
info.reason.should.equal(provider.constructor.NO_SWAPS_REASONS.NOT_SUPPORTED);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("Should handle duplicated tickers", async function () {
|
|
122
|
+
const dupCoin = getCoinByCode("USDTTRC20TRC20");
|
|
123
|
+
const btcCoin = getCoinByCode("BTC");
|
|
124
|
+
if (!dupCoin) return;
|
|
125
|
+
const info = await provider.getSwapInfo(dupCoin, btcCoin, "50");
|
|
126
|
+
info.result.should.be.true();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("Should validate hasExtraId and extraIdName for every allowed coin", async function () {
|
|
130
|
+
const rawData = await axiosOriginalGet(`${provider._URL}/currencies`, {
|
|
131
|
+
params: { key: GOEXME_API_KEY },
|
|
132
|
+
}).then(r => r.data);
|
|
133
|
+
|
|
134
|
+
await provider._fetchSupportedCurrenciesIfNeeded();
|
|
135
|
+
|
|
136
|
+
Object.entries(rawData)
|
|
137
|
+
.filter(([, meta]) => meta?.available === true)
|
|
138
|
+
.forEach(([code, meta]) => {
|
|
139
|
+
const coinInfo = provider._supportedCoins.find(c => c.code === code.toUpperCase());
|
|
140
|
+
if (!coinInfo) return;
|
|
141
|
+
const tagRaw = (meta.tagname ?? "").trim();
|
|
142
|
+
const expectsExtra = tagRaw.length > 0;
|
|
143
|
+
coinInfo.hasExtraId.should.equal(expectsExtra);
|
|
144
|
+
if (expectsExtra) {
|
|
145
|
+
coinInfo.extraIdName.should.equal(tagRaw);
|
|
146
|
+
} else {
|
|
147
|
+
should(coinInfo.extraIdName).be.null();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
140
151
|
});
|
|
141
152
|
});
|
|
@@ -12,11 +12,10 @@ import s from "./qr-code.module.scss";
|
|
|
12
12
|
* @component
|
|
13
13
|
* @param {Object} props - The props for the component.
|
|
14
14
|
* @param {string} props.address - The crypto address to generate the QR code for.
|
|
15
|
-
* @param {boolean} [props.fill=false] - If true, applies additional CSS class to fill the container.
|
|
16
15
|
*
|
|
17
16
|
* @returns {JSX.Element} A div containing the generated QR code.
|
|
18
17
|
*/
|
|
19
|
-
export const QrCode = ({ address
|
|
18
|
+
export const QrCode = ({ address }) => {
|
|
20
19
|
const canvasRef = useRef();
|
|
21
20
|
|
|
22
21
|
useEffect(() => {
|
|
@@ -31,14 +30,9 @@ export const QrCode = ({ address, fill = false }) => {
|
|
|
31
30
|
})();
|
|
32
31
|
}, [address]);
|
|
33
32
|
|
|
34
|
-
return <div className={s["qr-code"]
|
|
33
|
+
return <div className={s["qr-code"]} ref={canvasRef} />;
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
QrCode.propTypes = {
|
|
38
37
|
address: PropTypes.string.isRequired,
|
|
39
|
-
fill: PropTypes.bool,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
QrCode.defaultProps = {
|
|
43
|
-
fill: false,
|
|
44
38
|
};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
@use "../../../assets/styles/index" as *;
|
|
2
2
|
|
|
3
3
|
.qr-code {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&.fill {
|
|
11
|
-
position: absolute;
|
|
12
|
-
width: 100% !important;
|
|
13
|
-
height: 100% !important;
|
|
14
|
-
}
|
|
4
|
+
position: relative;
|
|
5
|
+
aspect-ratio: 1/1;
|
|
6
|
+
width: 100%;
|
|
7
|
+
margin: 0 auto;
|
|
15
8
|
}
|