@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,61 @@
|
|
|
1
|
+
export class LogsStorage {
|
|
2
|
+
static _inMemoryStorage = [];
|
|
3
|
+
static _logsStorageId = "clietnLogs_j203fj2D0n-d1";
|
|
4
|
+
|
|
5
|
+
static saveLog(log) {
|
|
6
|
+
this._inMemoryStorage.push(log);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static getInMemoryLogs() {
|
|
10
|
+
return this._inMemoryStorage;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getAllLogs() {
|
|
14
|
+
let storedLogs = "";
|
|
15
|
+
if (typeof window !== "undefined") {
|
|
16
|
+
storedLogs = localStorage.getItem(this._logsStorageId);
|
|
17
|
+
}
|
|
18
|
+
return `${storedLogs}\n${this._inMemoryStorage.join("\n")}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param logger {Logger}
|
|
23
|
+
*/
|
|
24
|
+
static saveToTheDisk(logger) {
|
|
25
|
+
try {
|
|
26
|
+
const MAX_LOCAL_STORAGE_VOLUME_BYTES = 5 * 1024 * 1024;
|
|
27
|
+
const MAX_LOGS_STORAGE_BYTES = MAX_LOCAL_STORAGE_VOLUME_BYTES * 0.65;
|
|
28
|
+
if (typeof window !== "undefined") {
|
|
29
|
+
const existingLogs = localStorage.getItem(this._logsStorageId);
|
|
30
|
+
const logsString = `${existingLogs}\n${this._inMemoryStorage.join("\n")}`;
|
|
31
|
+
const lettersCountToRemove = logsString.length - Math.round(MAX_LOGS_STORAGE_BYTES / 2);
|
|
32
|
+
if (lettersCountToRemove > 0) {
|
|
33
|
+
localStorage.setItem(
|
|
34
|
+
this._logsStorageId,
|
|
35
|
+
logsString.slice(lettersCountToRemove, logsString.length)
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
localStorage.setItem(this._logsStorageId, logsString);
|
|
39
|
+
}
|
|
40
|
+
this._inMemoryStorage = [];
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
logger?.logError(e, "saveToTheDisk", "Failed to save logs to disk");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static removeAllClientLogs() {
|
|
48
|
+
if (typeof window !== "undefined") {
|
|
49
|
+
if (localStorage.getItem("doNotRemoveClientLogsWhenSignedOut") !== "true") {
|
|
50
|
+
localStorage.removeItem(this._logsStorageId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this._inMemoryStorage = [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static setDoNotRemoveClientLogsWhenSignedOut(value) {
|
|
57
|
+
if (typeof window !== "undefined") {
|
|
58
|
+
localStorage.setItem("doNotRemoveClientLogsWhenSignedOut", value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringify given object by use of JSON.stringify but handles circular structures and "response", "request" properties
|
|
3
|
+
* to avoid stringing redundant data when printing errors containing request/response objects.
|
|
4
|
+
*
|
|
5
|
+
* @param object - object to be stringed
|
|
6
|
+
* @param indent - custom indentation
|
|
7
|
+
* @return {string} - stringed object
|
|
8
|
+
*/
|
|
9
|
+
export function safeStringify(object, indent = 2) {
|
|
10
|
+
let cache = [];
|
|
11
|
+
if (
|
|
12
|
+
typeof object === "string" ||
|
|
13
|
+
typeof object === "function" ||
|
|
14
|
+
typeof object === "number" ||
|
|
15
|
+
typeof object === "undefined" ||
|
|
16
|
+
typeof object === "boolean"
|
|
17
|
+
) {
|
|
18
|
+
return String(object);
|
|
19
|
+
}
|
|
20
|
+
const retVal = JSON.stringify(
|
|
21
|
+
object,
|
|
22
|
+
(key, value) => {
|
|
23
|
+
if (key.toLowerCase().includes("request")) {
|
|
24
|
+
return JSON.stringify({
|
|
25
|
+
body: value?.body,
|
|
26
|
+
query: value?.query,
|
|
27
|
+
headers: value?.headers,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (key.toLowerCase().includes("response")) {
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
statusText: value?.statusText,
|
|
34
|
+
status: value?.status,
|
|
35
|
+
data: value?.data,
|
|
36
|
+
headers: value?.headers,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return typeof value === "object" && value !== null
|
|
41
|
+
? cache.includes(value)
|
|
42
|
+
? "duplicated reference" // Duplicated references were found, discarding this key
|
|
43
|
+
: cache.push(value) && value // Store value in our collection
|
|
44
|
+
: value;
|
|
45
|
+
},
|
|
46
|
+
indent
|
|
47
|
+
);
|
|
48
|
+
cache = null;
|
|
49
|
+
return retVal;
|
|
50
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
import s from "./asset-icon.module.scss";
|
|
5
|
+
|
|
6
|
+
export const AssetIcon = ({
|
|
7
|
+
assetIconSrc,
|
|
8
|
+
assetIconProtocolSrc = null,
|
|
9
|
+
fallbackSrc = null,
|
|
10
|
+
small = false,
|
|
11
|
+
}) => {
|
|
12
|
+
const handleFailedLoad = (e) => {
|
|
13
|
+
e.target.onerror = null;
|
|
14
|
+
e.target.src = fallbackSrc;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={s["asset-icon"] + (small ? " " + s["small"] : "")}>
|
|
19
|
+
<img
|
|
20
|
+
src={assetIconSrc}
|
|
21
|
+
className={
|
|
22
|
+
s["asset-icon-primary"] + (small ? " " + s["small"] : "")
|
|
23
|
+
}
|
|
24
|
+
alt={" "}
|
|
25
|
+
onError={handleFailedLoad}
|
|
26
|
+
/>
|
|
27
|
+
{assetIconProtocolSrc ? (
|
|
28
|
+
<img
|
|
29
|
+
src={assetIconProtocolSrc}
|
|
30
|
+
className={
|
|
31
|
+
s["asset-icon-secondary"] +
|
|
32
|
+
(small ? " " + s["small"] : "")
|
|
33
|
+
}
|
|
34
|
+
alt={" "}
|
|
35
|
+
onError={handleFailedLoad}
|
|
36
|
+
/>
|
|
37
|
+
) : (
|
|
38
|
+
""
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
AssetIcon.propTypes = {
|
|
45
|
+
assetIconSrc: PropTypes.string.isRequired,
|
|
46
|
+
assetIconProtocolSrc: PropTypes.string,
|
|
47
|
+
fallbackSrc: PropTypes.string,
|
|
48
|
+
small: PropTypes.bool,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
AssetIcon.defaultProps = {
|
|
52
|
+
assetIconProtocolSrc: null,
|
|
53
|
+
fallbackSrc: null,
|
|
54
|
+
small: false,
|
|
55
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import "../../../../styles/index";
|
|
2
|
+
|
|
3
|
+
.asset-icon {
|
|
4
|
+
width: 34px;
|
|
5
|
+
height: 34px;
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&.small {
|
|
9
|
+
width: 24px;
|
|
10
|
+
height: 24px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-primary {
|
|
14
|
+
height: 34px;
|
|
15
|
+
width: 34px;
|
|
16
|
+
|
|
17
|
+
&.small {
|
|
18
|
+
width: 24px;
|
|
19
|
+
height: 24px;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-secondary {
|
|
24
|
+
width: 17px;
|
|
25
|
+
height: 17px;
|
|
26
|
+
|
|
27
|
+
position: absolute;
|
|
28
|
+
right: -3px;
|
|
29
|
+
bottom: -3px;
|
|
30
|
+
box-shadow: -2px -2px 4px 1px rgba(SolidColor("dark"), 0.3);
|
|
31
|
+
border-radius: 100%;
|
|
32
|
+
|
|
33
|
+
&.small {
|
|
34
|
+
width: 12px;
|
|
35
|
+
height: 12px;
|
|
36
|
+
|
|
37
|
+
right: -2px;
|
|
38
|
+
bottom: -2px;
|
|
39
|
+
box-shadow: -1px -1px 8px 1px rgba(SolidColor("dark"), 0.3);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
|
|
4
|
+
export const SupportChat = ({ url, websiteToken, welcomeMessage = "" }) => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
window.chatwootSettings = {
|
|
7
|
+
position: "right",
|
|
8
|
+
type: "standard",
|
|
9
|
+
launcherTitle: welcomeMessage,
|
|
10
|
+
};
|
|
11
|
+
(function (d, t) {
|
|
12
|
+
var BASE_URL = url;
|
|
13
|
+
var g = d.createElement(t),
|
|
14
|
+
s = d.getElementsByTagName(t)[0];
|
|
15
|
+
g.src = BASE_URL + "/packs/js/sdk.js";
|
|
16
|
+
g.defer = true;
|
|
17
|
+
g.async = true;
|
|
18
|
+
s.parentNode.insertBefore(g, s);
|
|
19
|
+
g.onload = function () {
|
|
20
|
+
window.chatwootSDK.run({
|
|
21
|
+
websiteToken: websiteToken,
|
|
22
|
+
baseUrl: BASE_URL,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})(document, "script");
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
SupportChat.propTypes = {
|
|
33
|
+
url: PropTypes.string.isRequired,
|
|
34
|
+
websiteToken: PropTypes.string.isRequired,
|
|
35
|
+
welcomeMessage: PropTypes.string,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
SupportChat.defaultProps = {
|
|
39
|
+
welcomeMessage: "",
|
|
40
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Link } from "react-router-dom";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
4
3
|
|
|
5
4
|
import styles from "./Button.module.scss";
|
|
@@ -9,7 +8,7 @@ import { LoadingDots } from "../../LoadingDots/LoadingDots.jsx";
|
|
|
9
8
|
/**
|
|
10
9
|
* Button component - A versatile and customizable button for React applications.
|
|
11
10
|
* It supports various sizes, styles, and functionalities, including loaders, icons, and handling of click events.
|
|
12
|
-
* This component can also be used as a link
|
|
11
|
+
* This component can also be used as a link if "to" is provided.
|
|
13
12
|
*
|
|
14
13
|
* @component
|
|
15
14
|
* @param {Object} props
|
|
@@ -108,11 +107,11 @@ export const Button = ({
|
|
|
108
107
|
<>
|
|
109
108
|
{isFormSubmittingButton ? <input type="submit" hidden /> : null}
|
|
110
109
|
{to ? (
|
|
111
|
-
<
|
|
110
|
+
<a
|
|
112
111
|
className={classNames}
|
|
113
112
|
onClick={(e) => handleError(buttonClick, e)}
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
href={to}
|
|
114
|
+
ref={buttonRef}
|
|
116
115
|
>
|
|
117
116
|
{icon ? (
|
|
118
117
|
<div
|
|
@@ -129,7 +128,7 @@ export const Button = ({
|
|
|
129
128
|
) : (
|
|
130
129
|
content
|
|
131
130
|
)}
|
|
132
|
-
</
|
|
131
|
+
</a>
|
|
133
132
|
) : (
|
|
134
133
|
<div
|
|
135
134
|
className={classNames}
|
|
@@ -188,6 +187,7 @@ Button.propTypes = {
|
|
|
188
187
|
mode: PropTypes.oneOf([
|
|
189
188
|
"transparent",
|
|
190
189
|
"white",
|
|
190
|
+
"white-flat",
|
|
191
191
|
"primary",
|
|
192
192
|
"primary-bordered",
|
|
193
193
|
"primary-transparent",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import "
|
|
1
|
+
@import "../../../../../styles/index";
|
|
2
2
|
|
|
3
3
|
.button {
|
|
4
4
|
@extend %text-very-bold;
|
|
@@ -122,6 +122,11 @@
|
|
|
122
122
|
box-shadow: 0 20px 20px rgba(15, 24, 75, 0.2);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
&.white-flat {
|
|
126
|
+
background: $white;
|
|
127
|
+
color: SolidColor("dark");
|
|
128
|
+
}
|
|
129
|
+
|
|
125
130
|
&-primary-dots-wrapper {
|
|
126
131
|
position: absolute;
|
|
127
132
|
top: 50%;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { Logger } from "../../common/utils/logging/logger.js";
|
|
4
|
+
|
|
5
|
+
export function useCallHandlingErrors() {
|
|
6
|
+
const [, setState] = useState();
|
|
7
|
+
return useCallback(
|
|
8
|
+
async (functionToBeCalled, event) => {
|
|
9
|
+
try {
|
|
10
|
+
await functionToBeCalled(event);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
Logger.logError(
|
|
13
|
+
error,
|
|
14
|
+
functionToBeCalled?.name || "errorBoundaryTrigger",
|
|
15
|
+
"Caught by ErrorBoundary"
|
|
16
|
+
);
|
|
17
|
+
// Triggering ErrorBoundary
|
|
18
|
+
setState(() => {
|
|
19
|
+
throw error;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds reference to standard state variable. It is helpful to be able to use state variable value inside
|
|
5
|
+
* event handlers and other callbacks without the need to call setState(prev => { value = prev; return prev; }).
|
|
6
|
+
*
|
|
7
|
+
* @param initialValue {any} to be passed to useState
|
|
8
|
+
* @return {[React.Ref, function]} reference to state variable and its setter
|
|
9
|
+
*/
|
|
10
|
+
export function useReferredState(initialValue) {
|
|
11
|
+
const [state, setState] = React.useState(initialValue);
|
|
12
|
+
const reference = React.useRef(state);
|
|
13
|
+
|
|
14
|
+
const setReferredState = (value) => {
|
|
15
|
+
if (value && {}.toString.call(value) === "[object Function]") {
|
|
16
|
+
value = value(reference.current);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
reference.current = value;
|
|
20
|
+
setState(value);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return [reference, setReferredState];
|
|
24
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// UI-KIT components
|
|
2
|
+
export { Button } from "./components/atoms/buttons/Button/Button.jsx";
|
|
3
|
+
export { LoadingDots } from "./components/atoms/LoadingDots/LoadingDots.jsx";
|
|
4
|
+
export { SupportChat } from "./components/atoms/SupportChat/SupportChat.jsx";
|
|
5
|
+
export { AssetIcon } from "./components/atoms/AssetIcon/AssetIcon.jsx";
|
|
6
|
+
|
|
7
|
+
export { useCallHandlingErrors } from "./components/hooks/useCallHandlingErrors.js";
|
|
8
|
+
export { useReferredState } from "./components/hooks/useReferredState.js";
|
|
9
|
+
|
|
10
|
+
// Common code lib (to be extracted later to dedicated lib)
|
|
11
|
+
export { improveAndRethrow } from "./common/errorUtils.js";
|
|
12
|
+
export { FiatCurrenciesService } from "./common/fiatCurrenciesService.js";
|
|
13
|
+
export { AmountUtils } from "./common/amountUtils.js";
|
|
14
|
+
|
|
15
|
+
export { Blockchain } from "./common/models/blockchain.js";
|
|
16
|
+
export { Protocol } from "./common/models/protocol.js";
|
|
17
|
+
export { Coin } from "./common/models/coin.js";
|
|
18
|
+
|
|
19
|
+
export { Cache } from "./common/utils/cache.js";
|
|
20
|
+
export { safeStringify } from "./common/utils/safeStringify.js";
|
|
21
|
+
export { LogsStorage } from "./common/utils/logging/logsStorage.js";
|
|
22
|
+
export { Logger } from "./common/utils/logging/logger.js";
|
|
23
|
+
|
|
24
|
+
export { EmailsApi } from "./common/utils/emailAPI.js";
|
|
25
|
+
|
|
26
|
+
// Swaps lib (to be extracted later to dedicated lib)
|
|
27
|
+
export { ExistingSwap } from "./swaps-lib/models/existingSwap.js";
|
|
28
|
+
export { ExistingSwapWithFiatData } from "./swaps-lib/models/existingSwapWithFiatData.js";
|
|
29
|
+
export { BaseSwapCreationInfo } from "./swaps-lib/models/baseSwapCreationInfo.js";
|
|
30
|
+
export { SwapProvider } from "./swaps-lib/external-apis/swapProvider.js";
|
|
31
|
+
export { SwapspaceSwapProvider } from "./swaps-lib/external-apis/swapspaceSwapProvider.js";
|
|
32
|
+
export { SwapUtils } from "./swaps-lib/utils/swapUtils.js";
|
|
33
|
+
export { PublicSwapService } from "./swaps-lib/services/publicSwapService.js";
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export class SwapProvider {
|
|
2
|
+
static COMMON_ERRORS = {
|
|
3
|
+
REQUESTS_LIMIT_EXCEEDED: "requestsLimitExceeded",
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
static NO_SWAPS_REASONS = {
|
|
7
|
+
TOO_LOW: "tooLow",
|
|
8
|
+
TOO_HIGH: "tooHigh",
|
|
9
|
+
NOT_SUPPORTED: "notSupported",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static CREATION_FAIL_REASONS = {
|
|
13
|
+
RETRIABLE_FAIL: "retriableFail",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
static SWAP_STATUSES = {
|
|
17
|
+
WAITING_FOR_PAYMENT: "waiting_for_payment", // public +
|
|
18
|
+
CONFIRMING: "confirming",
|
|
19
|
+
PAYMENT_RECEIVED: "payment_received", // public +
|
|
20
|
+
EXCHANGING: "exchanging", // session full // public +
|
|
21
|
+
COMPLETED: "completed", // session full // public +
|
|
22
|
+
REFUNDED: "refunded", // session full // public +
|
|
23
|
+
EXPIRED: "expired", // public +
|
|
24
|
+
FAILED: "failed", // public +
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @return {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
async initialize() {
|
|
31
|
+
throw new Error("Not implemented in base");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @return {number} milliseconds TTL
|
|
36
|
+
*/
|
|
37
|
+
getSwapCreationInfoTtlMs() {
|
|
38
|
+
throw new Error("Not implemented in base");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves all deposit currencies supported by this swap provider.
|
|
43
|
+
* Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
|
|
44
|
+
*
|
|
45
|
+
* @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
|
|
46
|
+
*/
|
|
47
|
+
async getDepositCurrencies() {
|
|
48
|
+
throw new Error("Not implemented in base");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all withdrawable currencies supported by this swap provider.
|
|
53
|
+
* Returns one of SwapProvider.COMMON_ERRORS in case of processable fail.
|
|
54
|
+
*
|
|
55
|
+
* @param [exceptCurrency=null] {Coin|null}
|
|
56
|
+
* @return {Promise<({ result: true, coins: Coin[] }|{ result: false, reason: string })>}
|
|
57
|
+
*/
|
|
58
|
+
async getWithdrawalCurrencies(exceptCurrency = null) {
|
|
59
|
+
throw new Error("Not implemented in base");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves URL for coin icon or fallback if not found.
|
|
64
|
+
*
|
|
65
|
+
* @param coin {Coin|string} coin or rabbit-format of coin ticker
|
|
66
|
+
* @return {string}
|
|
67
|
+
*/
|
|
68
|
+
getIconUrl(coin) {
|
|
69
|
+
throw new Error("Not implemented in base");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves coin to USDT rate.
|
|
74
|
+
*
|
|
75
|
+
* @param coin {Coin}
|
|
76
|
+
* @return {{result: true, rate: string}|{result: false}}
|
|
77
|
+
*/
|
|
78
|
+
async getCoinToUSDTRate(coin) {
|
|
79
|
+
throw new Error("Not implemented in base");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves estimation for swapping giving coins amount.
|
|
84
|
+
* null min or max signals there is no corresponding limitation. undefined means that the limits were not retrieved.
|
|
85
|
+
* For fail result on of SwapProvider.NO_SWAPS_REASONS or SwapProvider.COMMON_ERRORS reasons will be returned.
|
|
86
|
+
*
|
|
87
|
+
* @param fromCoin {Coin}
|
|
88
|
+
* @param toCoin {Coin}
|
|
89
|
+
* @param amountCoins {string}
|
|
90
|
+
* @param [fromCoinToUsdRate=null] pass if you want to increase the min amount returned
|
|
91
|
+
* by provider with some fixed "insurance" amount to cover min amount fluctuations.
|
|
92
|
+
* @return {Promise<({
|
|
93
|
+
* result: false,
|
|
94
|
+
* reason: string,
|
|
95
|
+
* smallestMin: (string|null|undefined),
|
|
96
|
+
* greatestMax: (string|null|undefined),
|
|
97
|
+
* }|{
|
|
98
|
+
* result: true,
|
|
99
|
+
* min: (string|null),
|
|
100
|
+
* max: (string|null),
|
|
101
|
+
* smallestMin: (string|null),
|
|
102
|
+
* greatestMax: (string|null),
|
|
103
|
+
* rate: (string|null),
|
|
104
|
+
* durationMinutesRange: string,
|
|
105
|
+
* [rawSwapData]: Object
|
|
106
|
+
* })>}
|
|
107
|
+
*/
|
|
108
|
+
async getSwapInfo(fromCoin, toCoin, amountCoins, fromCoinToUsdRate = null) {
|
|
109
|
+
throw new Error("Not implemented in base");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* For fail result we return one of SwapProvider.CREATION_FAIL_REASONS or SwapProvider.COMMON_ERRORS.
|
|
114
|
+
*
|
|
115
|
+
* @param fromCoin {Coin}
|
|
116
|
+
* @param toCoin {Coin}
|
|
117
|
+
* @param amount {string}
|
|
118
|
+
* @param toAddress {string}
|
|
119
|
+
* @param refundAddress {string}
|
|
120
|
+
* @param rawSwapData {Object|null}
|
|
121
|
+
* @param clientIpAddress {string}
|
|
122
|
+
* @return {Promise<({
|
|
123
|
+
* result: true,
|
|
124
|
+
* swapId: string,
|
|
125
|
+
* fromCoin: Coin,
|
|
126
|
+
* fromAmount: string,
|
|
127
|
+
* fromAddress: string,
|
|
128
|
+
* toCoin: Coin,
|
|
129
|
+
* toAmount: string,
|
|
130
|
+
* toAddress: string,
|
|
131
|
+
* rate: string
|
|
132
|
+
* }|{
|
|
133
|
+
* result: false,
|
|
134
|
+
* reason: string,
|
|
135
|
+
* partner: string
|
|
136
|
+
* })>}
|
|
137
|
+
*/
|
|
138
|
+
async createSwap(fromCoin, toCoin, amount, toAddress, refundAddress, rawSwapData = null, clientIpAddress) {
|
|
139
|
+
throw new Error("Not implemented in base");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Retrieves details and status for swaps by given ids.
|
|
144
|
+
* If some swap is not found by id then there is no item in return list.
|
|
145
|
+
*
|
|
146
|
+
* @param swapIds {string[]}
|
|
147
|
+
* @return {Promise<{result: false, reason: string}|{result:true, swaps: ExistingSwap[]}>}
|
|
148
|
+
*/
|
|
149
|
+
async getExistingSwapsDetailsAndStatus(swapIds) {
|
|
150
|
+
throw new Error("Not implemented in base");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param ticker {string}
|
|
155
|
+
* @return {Coin|null}
|
|
156
|
+
*/
|
|
157
|
+
getCoinByTickerIfPresent(ticker) {
|
|
158
|
+
throw new Error("Not implemented in base");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param asset {Coin}
|
|
163
|
+
* @param address {string}
|
|
164
|
+
* @return {boolean}
|
|
165
|
+
*/
|
|
166
|
+
isAddressValidForAsset(asset, address) {
|
|
167
|
+
throw new Error("Not implemented in base");
|
|
168
|
+
}
|
|
169
|
+
}
|