@rabbitio/ui-kit 1.0.0-beta.42 → 1.0.0-beta.45
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/.gitlab-ci.yml +29 -0
- package/.husky/commit-msg +8 -0
- package/.husky/pre-push +1 -0
- package/README.md +13 -4
- package/dist/index.cjs +1545 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +23630 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +1318 -103
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1534 -149
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1544 -152
- package/dist/index.umd.js.map +1 -1
- package/package.json +16 -3
- package/src/assets/image/icons/arrow-tosca.svg +3 -0
- package/src/assets/image/icons/arrow-white.svg +14 -0
- package/src/assets/image/icons/failed-validation-icon.svg +15 -0
- package/src/assets/image/icons/successful-validation-icon.svg +10 -0
- package/src/common/amountUtils.js +4 -2
- package/src/common/tests/integration/external-apis/ipAddressProviders/getClientIpAddress.test.js +14 -0
- package/src/common/utils/cache.js +4 -4
- package/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx +44 -0
- package/src/components/atoms/BackgroundTitle/background-title.module.scss +52 -0
- package/src/components/atoms/Validation/Validation.jsx +130 -0
- package/src/components/atoms/Validation/validation.module.scss +15 -0
- package/src/components/atoms/buttons/Close/Close.jsx +64 -0
- package/src/components/atoms/buttons/Close/close.module.scss +75 -0
- package/src/components/atoms/buttons/LinkButton/LinkButton.jsx +121 -0
- package/src/components/atoms/buttons/LinkButton/link-button.module.scss +45 -0
- package/src/components/organisms/Dialog/Dialog.jsx +515 -0
- package/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx +122 -0
- package/src/components/organisms/Dialog/DialogButtons/dialog-buttons.module.scss +25 -0
- package/src/components/organisms/Dialog/DialogStep/DialogStep.jsx +664 -0
- package/src/components/organisms/Dialog/DialogStep/dialog-step.module.scss +362 -0
- package/src/components/organisms/Dialog/dialog.module.scss +223 -0
- package/src/components/tests/utils/inputValueProviders/provideFormatOfFloatValueByInputString.test.js +139 -0
- package/src/components/tests/utils/urlQueryUtils/getQueryParameterValues.test.js +71 -0
- package/src/components/tests/utils/urlQueryUtils/saveQueryParameterAndValues.test.js +144 -0
- package/src/components/utils/inputValueProviders.js +58 -0
- package/src/constants/organisms/dialog/DialogStep/dialogStep.js +1 -0
- package/src/constants/organisms/dialog/dialog.js +29 -0
- package/src/index.js +11 -0
- package/src/robustExteranlApiCallerService/robustExternalAPICallerService.js +3 -1
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/_performCallAttempt.test.js +787 -0
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/callExternalAPI/callExternalAPI.test.js +745 -0
- package/src/robustExteranlApiCallerService/tests/robustExternalAPICallerService/robustExternalAPICallerService/constructor.test.js +31 -0
- package/src/swaps-lib/external-apis/swapProvider.js +17 -4
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +91 -30
- package/src/swaps-lib/models/baseSwapCreationInfo.js +4 -1
- package/src/swaps-lib/models/existingSwap.js +3 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +4 -0
- package/src/swaps-lib/services/publicSwapService.js +32 -4
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +506 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/createSwap.test.js +1311 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getAllSupportedCurrencies.test.js +76 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getDepositCurrencies.test.js +82 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getSwapInfo.test.js +1892 -0
- package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getWithdrawalCurrencies.test.js +111 -0
- package/src/swaps-lib/test/utils/swapUtils/safeHandleRequestsLimitExceeding.test.js +88 -0
- package/stories/stubs/exampleContent.jsx +20 -0
- package/styles/fonts/NunitoSans-Bold.ttf +0 -0
- package/styles/fonts/NunitoSans-ExtraBold.ttf +0 -0
- package/styles/fonts/NunitoSans-Light.ttf +0 -0
- package/styles/fonts/NunitoSans-Regular.ttf +0 -0
- package/styles/fonts/NunitoSans-SemiBold.ttf +0 -0
- package/styles/index.scss +14 -13
package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/getAllSupportedCurrencies.test.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
|
|
5
|
+
import { beforeEach, afterEach, describe, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { SwapProvider } from "../../../external-apis/swapProvider.js";
|
|
8
|
+
import { SwapspaceSwapProvider } from "../../../external-apis/swapspaceSwapProvider.js";
|
|
9
|
+
import { Cache } from "../../../../common/utils/cache.js";
|
|
10
|
+
|
|
11
|
+
describe("swapspaceSwapProvider", function () {
|
|
12
|
+
describe("getAllSupportedCurrencies", function () {
|
|
13
|
+
const swapspaceProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
14
|
+
|
|
15
|
+
let _fetchSupportedCurrenciesIfNeededStub;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
_fetchSupportedCurrenciesIfNeededStub = sinon.stub(axios, "get");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
_fetchSupportedCurrenciesIfNeededStub.restore();
|
|
22
|
+
swapspaceProvider._supportedCoins = [];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Should return an error if the response status is 429", async () => {
|
|
26
|
+
_fetchSupportedCurrenciesIfNeededStub.resetBehavior();
|
|
27
|
+
_fetchSupportedCurrenciesIfNeededStub.rejects({
|
|
28
|
+
response: { status: 429 },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const swapProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
32
|
+
const result = await swapProvider.getAllSupportedCurrencies();
|
|
33
|
+
result.should.deepEqual({
|
|
34
|
+
result: false,
|
|
35
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("Should return an object with 'result' set to true and an array of supported coins if there is initialized list", async () => {
|
|
40
|
+
swapspaceProvider._supportedCoins = [
|
|
41
|
+
{ coin: { t: "BTC" }, extraId: "" },
|
|
42
|
+
{ coin: 1 },
|
|
43
|
+
{ coin: "4" },
|
|
44
|
+
];
|
|
45
|
+
const expectedCoins = swapspaceProvider._supportedCoins.map(
|
|
46
|
+
(item) => item.coin
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const result = await swapspaceProvider.getAllSupportedCurrencies();
|
|
50
|
+
|
|
51
|
+
result.should.deepEqual({ result: true, coins: expectedCoins });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("Should always call _fetchSupportedCurrenciesIfNeeded ones", async () => {
|
|
55
|
+
await swapspaceProvider.getAllSupportedCurrencies();
|
|
56
|
+
|
|
57
|
+
_fetchSupportedCurrenciesIfNeededStub.calledOnce.should.be.true();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("Should throw an error if an error occurs while fetching supported currencies", async () => {
|
|
61
|
+
_fetchSupportedCurrenciesIfNeededStub.throws(
|
|
62
|
+
new Error("Error fetching supported currencies")
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
await swapspaceProvider.getAllSupportedCurrencies();
|
|
67
|
+
should.fail("Expected an error to be thrown");
|
|
68
|
+
} catch (error) {
|
|
69
|
+
error.should.be.instanceOf(Error);
|
|
70
|
+
error.message.should.containEql(
|
|
71
|
+
"Error fetching supported currencies"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import should from "should";
|
|
4
|
+
|
|
5
|
+
import { beforeEach, afterEach, describe, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { SwapProvider } from "../../../external-apis/swapProvider.js";
|
|
8
|
+
import { SwapspaceSwapProvider } from "../../../external-apis/swapspaceSwapProvider.js";
|
|
9
|
+
import { Cache } from "../../../../common/utils/cache.js";
|
|
10
|
+
|
|
11
|
+
describe("swapspaceSwapProvider", function () {
|
|
12
|
+
describe("getDepositCurrencies", function () {
|
|
13
|
+
const swapspaceProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
14
|
+
|
|
15
|
+
let _fetchSupportedCurrenciesIfNeededStub;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
_fetchSupportedCurrenciesIfNeededStub = sinon.stub(axios, "get");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
_fetchSupportedCurrenciesIfNeededStub.restore();
|
|
22
|
+
swapspaceProvider._supportedCoins = [];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Should return an error if the response status is 429", async () => {
|
|
26
|
+
_fetchSupportedCurrenciesIfNeededStub.resetBehavior();
|
|
27
|
+
_fetchSupportedCurrenciesIfNeededStub.rejects({
|
|
28
|
+
response: { status: 429 },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const swapProvider = new SwapspaceSwapProvider("/", new Cache());
|
|
32
|
+
const result = await swapProvider.getDepositCurrencies();
|
|
33
|
+
result.should.deepEqual({
|
|
34
|
+
result: false,
|
|
35
|
+
reason: SwapProvider.COMMON_ERRORS.REQUESTS_LIMIT_EXCEEDED,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("Should return an object with 'result' set to true and an array of supported coins having deposit == true", async () => {
|
|
40
|
+
swapspaceProvider._supportedCoins = [
|
|
41
|
+
{
|
|
42
|
+
coin: { t: "BTC" },
|
|
43
|
+
extraId: "",
|
|
44
|
+
withdrawal: true,
|
|
45
|
+
deposit: true,
|
|
46
|
+
},
|
|
47
|
+
{ coin: 1, withdrawal: false, deposit: true },
|
|
48
|
+
{ coin: "4", withdrawal: true, deposit: null },
|
|
49
|
+
{ coin: "-12312", withdrawal: null, deposit: false },
|
|
50
|
+
];
|
|
51
|
+
const expectedCoins = swapspaceProvider._supportedCoins
|
|
52
|
+
.filter((i) => i.deposit)
|
|
53
|
+
.map((item) => item.coin);
|
|
54
|
+
|
|
55
|
+
const result = await swapspaceProvider.getDepositCurrencies();
|
|
56
|
+
|
|
57
|
+
result.should.deepEqual({ result: true, coins: expectedCoins });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("Should always call _fetchSupportedCurrenciesIfNeeded ones", async () => {
|
|
61
|
+
await swapspaceProvider.getDepositCurrencies();
|
|
62
|
+
|
|
63
|
+
_fetchSupportedCurrenciesIfNeededStub.calledOnce.should.be.true();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("Should throw an error if an error occurs while fetching supported currencies", async () => {
|
|
67
|
+
_fetchSupportedCurrenciesIfNeededStub.throws(
|
|
68
|
+
new Error("Error fetching supported currencies")
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await swapspaceProvider.getDepositCurrencies();
|
|
73
|
+
should.fail("Expected an error to be thrown");
|
|
74
|
+
} catch (error) {
|
|
75
|
+
error.should.be.instanceOf(Error);
|
|
76
|
+
error.message.should.containEql(
|
|
77
|
+
"Error fetching supported currencies"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|