@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/getWithdrawalCurrencies.test.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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("getWithdrawalCurrencies", 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.getWithdrawalCurrencies();
|
|
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 withdrawal == 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.withdrawal)
|
|
53
|
+
.map((item) => item.coin);
|
|
54
|
+
|
|
55
|
+
const result = await swapspaceProvider.getWithdrawalCurrencies();
|
|
56
|
+
|
|
57
|
+
result.should.deepEqual({ result: true, coins: expectedCoins });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("Should return an object with 'result' set to true and an array of supported coins having withdrawal == true except the passed coin ticker", async () => {
|
|
61
|
+
swapspaceProvider._supportedCoins = [
|
|
62
|
+
{
|
|
63
|
+
coin: { ticker: "BTC" },
|
|
64
|
+
extraId: "",
|
|
65
|
+
withdrawal: true,
|
|
66
|
+
deposit: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
coin: { ticker: "ALGO" },
|
|
70
|
+
extraId: "",
|
|
71
|
+
withdrawal: true,
|
|
72
|
+
deposit: true,
|
|
73
|
+
},
|
|
74
|
+
{ coin: 1, withdrawal: false, deposit: null },
|
|
75
|
+
{ coin: "4", withdrawal: true, deposit: true },
|
|
76
|
+
{ coin: "-12312", withdrawal: null, deposit: false },
|
|
77
|
+
];
|
|
78
|
+
const expectedCoins = swapspaceProvider._supportedCoins
|
|
79
|
+
.filter((i) => i.withdrawal && i.coin.ticker !== "ALGO")
|
|
80
|
+
.map((item) => item.coin);
|
|
81
|
+
|
|
82
|
+
const result = await swapspaceProvider.getWithdrawalCurrencies({
|
|
83
|
+
ticker: "ALGO",
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
result.should.deepEqual({ result: true, coins: expectedCoins });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("Should always call _fetchSupportedCurrenciesIfNeeded ones", async () => {
|
|
90
|
+
await swapspaceProvider.getWithdrawalCurrencies();
|
|
91
|
+
|
|
92
|
+
_fetchSupportedCurrenciesIfNeededStub.calledOnce.should.be.true();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("Should throw an error if an error occurs while fetching supported currencies", async () => {
|
|
96
|
+
_fetchSupportedCurrenciesIfNeededStub.throws(
|
|
97
|
+
new Error("Error fetching supported currencies")
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
await swapspaceProvider.getWithdrawalCurrencies();
|
|
102
|
+
should.fail("Expected an error to be thrown");
|
|
103
|
+
} catch (error) {
|
|
104
|
+
error.should.be.instanceOf(Error);
|
|
105
|
+
error.message.should.containEql(
|
|
106
|
+
"Error fetching supported currencies"
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import should from "should";
|
|
3
|
+
|
|
4
|
+
import { beforeEach, afterEach, describe, it } from "vitest";
|
|
5
|
+
import { Logger } from "../../../../common/utils/logging/logger.js";
|
|
6
|
+
import { EmailsApi } from "../../../../common/utils/emailAPI.js";
|
|
7
|
+
import { SwapUtils } from "../../../utils/swapUtils.js";
|
|
8
|
+
|
|
9
|
+
describe("SwapUtils", function () {
|
|
10
|
+
let sendEmailStub;
|
|
11
|
+
|
|
12
|
+
beforeEach(function () {
|
|
13
|
+
sendEmailStub = sinon.stub(EmailsApi, "sendEmail").resolves();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(function () {
|
|
17
|
+
sendEmailStub.restore();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("safeHandleRequestsLimitExceeding", function () {
|
|
21
|
+
it("Should ensure that sendEmail is called when safeHandleRequestsLimitExceeding is invoked", function () {
|
|
22
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
23
|
+
|
|
24
|
+
sendEmailStub.called.should.be.true();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("Should verify that sendEmail is called once", function () {
|
|
28
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
29
|
+
|
|
30
|
+
sendEmailStub.callCount.should.equal(1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Should ensure that sendEmail is called with the correct subject: "AUTOMATIC EMAIL - SWAPSPACE REQUESTS LIMIT EXCEEDED"', function () {
|
|
34
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
35
|
+
|
|
36
|
+
sendEmailStub
|
|
37
|
+
.calledWith(
|
|
38
|
+
"AUTOMATIC EMAIL - SWAPSPACE REQUESTS LIMIT EXCEEDED"
|
|
39
|
+
)
|
|
40
|
+
.should.be.true();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('Should ensure that sendEmail is called with the correct body: "Requests limit exceeded. Urgently ask swapspace support for limit increasing"', function () {
|
|
44
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
45
|
+
|
|
46
|
+
sendEmailStub
|
|
47
|
+
.calledWith(
|
|
48
|
+
sinon.match.any,
|
|
49
|
+
"Requests limit exceeded. Urgently ask swaps provider support for limit increasing"
|
|
50
|
+
)
|
|
51
|
+
.should.be.true();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("Should handle an error thrown by the sendEmail function without crashing", function (done) {
|
|
55
|
+
sendEmailStub.rejects(new Error("Fake error for testing purposes"));
|
|
56
|
+
|
|
57
|
+
let error;
|
|
58
|
+
try {
|
|
59
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
60
|
+
} catch (e) {
|
|
61
|
+
error = e;
|
|
62
|
+
}
|
|
63
|
+
(error === undefined).should.be.true();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("Should ensure that safeHandleRequestsLimitExceeding does not return a value", function () {
|
|
67
|
+
const result = SwapUtils.safeHandleRequestsLimitExceeding();
|
|
68
|
+
|
|
69
|
+
(!result).should.be.true();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("Should log a descriptive error message when a failure occurs", function (done) {
|
|
73
|
+
sendEmailStub.rejects(new Error("Fake error for testing purposes"));
|
|
74
|
+
const logStub = sinon.stub(Logger, "log");
|
|
75
|
+
|
|
76
|
+
SwapUtils.safeHandleRequestsLimitExceeding();
|
|
77
|
+
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
logStub
|
|
80
|
+
.calledWithMatch(
|
|
81
|
+
sinon.match("Failed to handle limit exceeding")
|
|
82
|
+
)
|
|
83
|
+
.should.be.true();
|
|
84
|
+
logStub.restore();
|
|
85
|
+
}, 10);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const exampleContent = (
|
|
4
|
+
<div
|
|
5
|
+
style={{
|
|
6
|
+
width: "100%",
|
|
7
|
+
height: "300px",
|
|
8
|
+
borderRadius: "16px",
|
|
9
|
+
background: "#eee",
|
|
10
|
+
color: "#bbb",
|
|
11
|
+
display: "flex",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
fontSize: "12px",
|
|
15
|
+
fontFamily: "monospace",
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
Example content
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/styles/index.scss
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
@import "variables";
|
|
2
2
|
@import "global-classes";
|
|
3
3
|
@import "placeholder";
|
|
4
|
+
@import "_mixins";
|
|
4
5
|
|
|
5
6
|
@font-face {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
src: url("fonts/NunitoSans-ExtraBold.ttf");
|
|
8
|
+
font-family: "NunitoSans";
|
|
8
9
|
font-weight: $extra-bold;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
@font-face {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
src: url("fonts/NunitoSans-Bold.ttf");
|
|
14
|
+
font-family: "NunitoSans";
|
|
14
15
|
font-weight: $bold;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
@font-face {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
font-weight:
|
|
19
|
+
src: url("fonts/NunitoSans-SemiBold.ttf");
|
|
20
|
+
font-family: "NunitoSans";
|
|
21
|
+
font-weight: $semi-bold;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
@font-face {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
font-weight:
|
|
25
|
+
src: url("fonts/NunitoSans-Regular.ttf");
|
|
26
|
+
font-family: "NunitoSans";
|
|
27
|
+
font-weight: $medium;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
@font-face {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
font-weight:
|
|
31
|
+
src: url("fonts/NunitoSans-Light.ttf");
|
|
32
|
+
font-family: "NunitoSans";
|
|
33
|
+
font-weight: $regular;
|
|
33
34
|
}
|