@rabbitio/ui-kit 1.0.0-beta.2 → 1.0.0-beta.21
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/CHANGELOG.md +0 -0
- package/README.md +23 -16
- package/dist/index.cjs +4404 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +8757 -1
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +3692 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +4375 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +4406 -1
- package/dist/index.umd.js.map +1 -1
- package/index.js +1 -1
- package/package.json +17 -24
- package/src/common/amountUtils.js +423 -0
- package/src/common/errorUtils.js +27 -0
- package/src/common/fiatCurrenciesService.js +161 -0
- package/src/common/models/blockchain.js +10 -0
- package/src/common/models/coin.js +157 -0
- package/src/common/models/protocol.js +5 -0
- package/src/common/utils/cache.js +268 -0
- package/src/common/utils/emailAPI.js +18 -0
- package/src/common/utils/logging/logger.js +48 -0
- package/src/common/utils/logging/logsStorage.js +61 -0
- package/src/common/utils/safeStringify.js +50 -0
- package/src/components/atoms/AssetIcon/AssetIcon.jsx +55 -0
- package/src/components/atoms/AssetIcon/asset-icon.module.scss +42 -0
- package/{stories → src/components}/atoms/LoadingDots/LoadingDots.module.scss +1 -1
- package/src/components/atoms/SupportChat/SupportChat.jsx +40 -0
- package/{stories → src/components}/atoms/buttons/Button/Button.jsx +6 -6
- package/{stories → src/components}/atoms/buttons/Button/Button.module.scss +6 -1
- package/src/components/hooks/useCallHandlingErrors.js +26 -0
- package/src/components/hooks/useReferredState.js +24 -0
- package/src/index.js +33 -0
- package/src/swaps-lib/external-apis/swapProvider.js +169 -0
- package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +812 -0
- package/src/swaps-lib/models/baseSwapCreationInfo.js +40 -0
- package/src/swaps-lib/models/existingSwap.js +58 -0
- package/src/swaps-lib/models/existingSwapWithFiatData.js +115 -0
- package/src/swaps-lib/services/publicSwapService.js +602 -0
- package/src/swaps-lib/utils/swapUtils.js +209 -0
- package/stories/index.js +0 -2
- /package/{stories → src/components}/atoms/LoadingDots/LoadingDots.jsx +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class BaseSwapCreationInfo {
|
|
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
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export class ExistingSwap {
|
|
2
|
+
/**
|
|
3
|
+
* @param swapId {string}
|
|
4
|
+
* @param status {SwapProvider.SWAP_STATUSES}
|
|
5
|
+
* @param createdAt {number}
|
|
6
|
+
* @param expiresAt {number}
|
|
7
|
+
* @param confirmations {number}
|
|
8
|
+
* @param rate {string}
|
|
9
|
+
* @param refundAddress {string}
|
|
10
|
+
* @param fromCoin {Coin}
|
|
11
|
+
* @param fromAmount {string}
|
|
12
|
+
* @param fromTransactionId {string}
|
|
13
|
+
* @param toCoin {Coin}
|
|
14
|
+
* @param toAmount {string}
|
|
15
|
+
* @param toTransactionId {string|null}
|
|
16
|
+
* @param toAddress {string}
|
|
17
|
+
* @param partner {string}
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
swapId,
|
|
21
|
+
status,
|
|
22
|
+
createdAt,
|
|
23
|
+
expiresAt,
|
|
24
|
+
confirmations,
|
|
25
|
+
rate,
|
|
26
|
+
refundAddress,
|
|
27
|
+
payToAddress,
|
|
28
|
+
fromCoin,
|
|
29
|
+
fromAmount,
|
|
30
|
+
fromTransactionId,
|
|
31
|
+
fromTransactionLink,
|
|
32
|
+
toCoin,
|
|
33
|
+
toAmount,
|
|
34
|
+
toTransactionId,
|
|
35
|
+
toTransactionLink,
|
|
36
|
+
toAddress, // TODO: [refactoring, moderate] toAddress is not quite clear. How about recipientAddress? task_id=0815a111c99543b78d374217eadbde4f
|
|
37
|
+
partner
|
|
38
|
+
) {
|
|
39
|
+
this.swapId = swapId;
|
|
40
|
+
this.status = status;
|
|
41
|
+
this.createdAt = createdAt;
|
|
42
|
+
this.expiresAt = expiresAt;
|
|
43
|
+
this.confirmations = confirmations;
|
|
44
|
+
this.rate = rate;
|
|
45
|
+
this.refundAddress = refundAddress;
|
|
46
|
+
this.payToAddress = payToAddress;
|
|
47
|
+
this.fromCoin = fromCoin;
|
|
48
|
+
this.fromTransactionId = fromTransactionId;
|
|
49
|
+
this.fromAmount = fromAmount;
|
|
50
|
+
this.fromTransactionLink = fromTransactionLink;
|
|
51
|
+
this.toCoin = toCoin;
|
|
52
|
+
this.toTransactionId = toTransactionId;
|
|
53
|
+
this.toTransactionLink = toTransactionLink;
|
|
54
|
+
this.toAmount = toAmount;
|
|
55
|
+
this.toAddress = toAddress;
|
|
56
|
+
this.partner = partner;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -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
|
+
}
|