@rabbitio/ui-kit 1.0.0-beta.12 → 1.0.0-beta.13
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/dist/index.cjs +112 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +88 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +110 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +112 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/common/utils/emailAPI.js +18 -0
- package/src/index.js +4 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +115 -0
- package/src/swaps-lib/models/publicSwapCreationInfo.js +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabbitio/ui-kit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
4
|
"description": "Rabbit.io react.js components kit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"react-dom": ">=18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"axios": "1.6.7",
|
|
41
42
|
"bignumber.js": "9.1.2",
|
|
42
43
|
"react": ">=18.2.0",
|
|
43
44
|
"react-dom": ">=18.2.0"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
import { improveAndRethrow } from "../errorUtils.js";
|
|
4
|
+
|
|
5
|
+
export class EmailsApi {
|
|
6
|
+
static serverEndpointEntity = "emails";
|
|
7
|
+
|
|
8
|
+
static async sendEmail(subject, body) {
|
|
9
|
+
try {
|
|
10
|
+
const url = `${
|
|
11
|
+
window.location.protocol + "//" + window.location.host
|
|
12
|
+
}/api/v1/${this.serverEndpointEntity}`;
|
|
13
|
+
await axios.post(url, { subject, body });
|
|
14
|
+
} catch (e) {
|
|
15
|
+
improveAndRethrow(e, "sendEmail", subject + body);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,11 @@ export { safeStringify } from "./common/utils/safeStringify.js";
|
|
|
18
18
|
export { LogsStorage } from "./common/utils/logging/logsStorage.js";
|
|
19
19
|
export { Logger } from "./common/utils/logging/logger.js";
|
|
20
20
|
|
|
21
|
+
export { EmailsApi } from "./common/utils/emailAPI.js";
|
|
22
|
+
|
|
21
23
|
// Swaps lib (to be extracted later to dedicated lib)
|
|
22
24
|
export { ExistingSwap } from "./swaps-lib/models/existingSwap.js";
|
|
25
|
+
export { ExistingSwapWithFiatData } from "./swaps-lib/models/existingSwapWithFiatData.js";
|
|
26
|
+
export { PublicSwapCreationInfo } from "./swaps-lib/models/publicSwapCreationInfo.js";
|
|
23
27
|
export { SwapProvider } from "./swaps-lib/external-apis/swapProvider.js";
|
|
24
28
|
export { SwapspaceSwapProvider } from "./swaps-lib/external-apis/swapspaceSwapProvider.js";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ExistingSwap } from "./existingSwap.js";
|
|
2
|
+
|
|
3
|
+
export class ExistingSwapWithFiatData extends ExistingSwap {
|
|
4
|
+
/**
|
|
5
|
+
* @param swapId {string}
|
|
6
|
+
* @param status {SwapProvider.SWAP_STATUSES}
|
|
7
|
+
* @param createdAt {number}
|
|
8
|
+
* @param expiresAt {number}
|
|
9
|
+
* @param confirmations {number}
|
|
10
|
+
* @param rate {string}
|
|
11
|
+
* @param refundAddress {string}
|
|
12
|
+
* @param fromCoin {Coin}
|
|
13
|
+
* @param fromAmount {string}
|
|
14
|
+
* @param fromTransactionId {string}
|
|
15
|
+
* @param toCoin {Coin}
|
|
16
|
+
* @param toAmount {string}
|
|
17
|
+
* @param toTransactionId {string|null}
|
|
18
|
+
* @param toAddress {string}
|
|
19
|
+
* @param partner {string}
|
|
20
|
+
* @param fromAmountFiat {number}
|
|
21
|
+
* @param toAmountFiat {number}
|
|
22
|
+
* @param fiatCurrencyCode {string}
|
|
23
|
+
* @param fiatCurrencyDecimals {number}
|
|
24
|
+
*/
|
|
25
|
+
constructor(
|
|
26
|
+
swapId,
|
|
27
|
+
status,
|
|
28
|
+
createdAt,
|
|
29
|
+
expiresAt,
|
|
30
|
+
confirmations,
|
|
31
|
+
rate,
|
|
32
|
+
refundAddress,
|
|
33
|
+
payToAddress,
|
|
34
|
+
fromCoin,
|
|
35
|
+
fromAmount,
|
|
36
|
+
fromTransactionId,
|
|
37
|
+
fromTransactionLink,
|
|
38
|
+
toCoin,
|
|
39
|
+
toAmount,
|
|
40
|
+
toTransactionId,
|
|
41
|
+
toTransactionLink,
|
|
42
|
+
toAddress,
|
|
43
|
+
partner,
|
|
44
|
+
fromAmountFiat,
|
|
45
|
+
toAmountFiat,
|
|
46
|
+
fiatCurrencyCode,
|
|
47
|
+
fiatCurrencyDecimals
|
|
48
|
+
) {
|
|
49
|
+
super(
|
|
50
|
+
swapId,
|
|
51
|
+
status,
|
|
52
|
+
createdAt,
|
|
53
|
+
expiresAt,
|
|
54
|
+
confirmations,
|
|
55
|
+
rate,
|
|
56
|
+
refundAddress,
|
|
57
|
+
payToAddress,
|
|
58
|
+
fromCoin,
|
|
59
|
+
fromAmount,
|
|
60
|
+
fromTransactionId,
|
|
61
|
+
fromTransactionLink,
|
|
62
|
+
toCoin,
|
|
63
|
+
toAmount,
|
|
64
|
+
toTransactionId,
|
|
65
|
+
toTransactionLink,
|
|
66
|
+
toAddress,
|
|
67
|
+
partner
|
|
68
|
+
);
|
|
69
|
+
this.fromAmountFiat = fromAmountFiat;
|
|
70
|
+
this.toAmountFiat = toAmountFiat;
|
|
71
|
+
this.fiatCurrencyCode = fiatCurrencyCode;
|
|
72
|
+
this.fiatCurrencyDecimals = fiatCurrencyDecimals;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param existingSwap {ExistingSwap}
|
|
77
|
+
* @param fromAmountFiat {number}
|
|
78
|
+
* @param toAmountFiat {number}
|
|
79
|
+
* @param fiatCurrencyCode {string}
|
|
80
|
+
* @param fiatCurrencyDecimals {number}
|
|
81
|
+
* @return {ExistingSwapWithFiatData}
|
|
82
|
+
*/
|
|
83
|
+
static fromExistingSwap(
|
|
84
|
+
existingSwap,
|
|
85
|
+
fromAmountFiat,
|
|
86
|
+
toAmountFiat,
|
|
87
|
+
fiatCurrencyCode,
|
|
88
|
+
fiatCurrencyDecimals
|
|
89
|
+
) {
|
|
90
|
+
return new ExistingSwapWithFiatData(
|
|
91
|
+
existingSwap.swapId,
|
|
92
|
+
existingSwap.status,
|
|
93
|
+
existingSwap.createdAt,
|
|
94
|
+
existingSwap.expiresAt,
|
|
95
|
+
existingSwap.confirmations,
|
|
96
|
+
existingSwap.rate,
|
|
97
|
+
existingSwap.refundAddress,
|
|
98
|
+
existingSwap.payToAddress,
|
|
99
|
+
existingSwap.fromCoin,
|
|
100
|
+
existingSwap.fromAmount,
|
|
101
|
+
existingSwap.fromTransactionId,
|
|
102
|
+
existingSwap.fromTransactionLink,
|
|
103
|
+
existingSwap.toCoin,
|
|
104
|
+
existingSwap.toAmount,
|
|
105
|
+
existingSwap.toTransactionId,
|
|
106
|
+
existingSwap.toTransactionLink,
|
|
107
|
+
existingSwap.toAddress,
|
|
108
|
+
existingSwap.partner,
|
|
109
|
+
fromAmountFiat,
|
|
110
|
+
toAmountFiat,
|
|
111
|
+
fiatCurrencyCode,
|
|
112
|
+
fiatCurrencyDecimals
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class PublicSwapCreationInfo {
|
|
2
|
+
/**
|
|
3
|
+
* @param fromCoin {Coin}
|
|
4
|
+
* @param toCoin {Coin}
|
|
5
|
+
* @param fromAmountCoins {string}
|
|
6
|
+
* @param toAmountCoins {string}
|
|
7
|
+
* @param rate {string}
|
|
8
|
+
* @param rawSwapData {Object}
|
|
9
|
+
* @param min {string}
|
|
10
|
+
* @param fiatMin {number}
|
|
11
|
+
* @param max {string}
|
|
12
|
+
* @param fiatMax {number}
|
|
13
|
+
* @param durationMinutesRange {string}
|
|
14
|
+
*/
|
|
15
|
+
constructor(
|
|
16
|
+
fromCoin,
|
|
17
|
+
toCoin,
|
|
18
|
+
fromAmountCoins,
|
|
19
|
+
toAmountCoins,
|
|
20
|
+
rate,
|
|
21
|
+
rawSwapData,
|
|
22
|
+
min,
|
|
23
|
+
fiatMin,
|
|
24
|
+
max,
|
|
25
|
+
fiatMax,
|
|
26
|
+
durationMinutesRange
|
|
27
|
+
) {
|
|
28
|
+
this.fromCoin = fromCoin;
|
|
29
|
+
this.toCoin = toCoin;
|
|
30
|
+
this.fromAmountCoins = fromAmountCoins;
|
|
31
|
+
this.toAmountCoins = toAmountCoins;
|
|
32
|
+
this.rate = rate;
|
|
33
|
+
this.rawSwapData = rawSwapData;
|
|
34
|
+
this.min = min;
|
|
35
|
+
this.fiatMin = fiatMin;
|
|
36
|
+
this.max = max;
|
|
37
|
+
this.fiatMax = fiatMax;
|
|
38
|
+
this.durationMinutesRange = durationMinutesRange;
|
|
39
|
+
}
|
|
40
|
+
}
|