@riocrypto/common-server 1.0.1228 → 1.0.1229
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Quote, Fiat, Crypto, BitsoBankAccount } from "@riocrypto/common";
|
|
2
2
|
declare class ClusterClient {
|
|
3
|
-
private baseUrl;
|
|
4
3
|
private clusterApiKey;
|
|
5
4
|
private axios;
|
|
6
|
-
constructor(
|
|
5
|
+
constructor(clusterApiKey: string);
|
|
7
6
|
getNewQuote(orderId: string, quote: Quote, newAmountFiat?: number, newAmountCrypto?: number): Promise<Quote>;
|
|
8
7
|
createBitsoBankAccount(userId: string): Promise<BitsoBankAccount>;
|
|
9
8
|
getBalance(asset: Crypto | Fiat): Promise<number>;
|
|
@@ -17,21 +17,9 @@ const common_1 = require("@riocrypto/common");
|
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
19
19
|
class ClusterClient {
|
|
20
|
-
constructor(
|
|
21
|
-
this.baseUrl = baseUrl;
|
|
20
|
+
constructor(clusterApiKey) {
|
|
22
21
|
this.clusterApiKey = clusterApiKey;
|
|
23
|
-
this.axios = axios_1.default.create({
|
|
24
|
-
baseURL: baseUrl,
|
|
25
|
-
headers: {
|
|
26
|
-
Host: process.env.RIO_ENV === common_1.RioEnv.Development
|
|
27
|
-
? "dev.riotransfer.co"
|
|
28
|
-
: process.env.RIO_ENV === common_1.RioEnv.Staging
|
|
29
|
-
? "staging.riotransfer.co"
|
|
30
|
-
: process.env.RIO_ENV === common_1.RioEnv.Sandbox
|
|
31
|
-
? "sandbox.riotransfer.co"
|
|
32
|
-
: "www.riotransfer.co",
|
|
33
|
-
},
|
|
34
|
-
});
|
|
22
|
+
this.axios = axios_1.default.create({});
|
|
35
23
|
}
|
|
36
24
|
getNewQuote(orderId, quote, newAmountFiat, newAmountCrypto) {
|
|
37
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -55,7 +43,7 @@ class ClusterClient {
|
|
|
55
43
|
amountCrypto = undefined;
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
|
-
const response = yield this.axios.post(
|
|
46
|
+
const response = yield this.axios.post(`/api/quotes`, {
|
|
59
47
|
orderId,
|
|
60
48
|
userId: quote.userId,
|
|
61
49
|
side: quote.side,
|
|
@@ -77,7 +65,7 @@ class ClusterClient {
|
|
|
77
65
|
}
|
|
78
66
|
createBitsoBankAccount(userId) {
|
|
79
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const response = yield this.axios.post(
|
|
68
|
+
const response = yield this.axios.post(`/api/bank/accounts/bitso`, {
|
|
81
69
|
userId,
|
|
82
70
|
}, {
|
|
83
71
|
headers: {
|
|
@@ -89,7 +77,7 @@ class ClusterClient {
|
|
|
89
77
|
}
|
|
90
78
|
getBalance(asset) {
|
|
91
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const rioResponse = yield this.axios.get(
|
|
80
|
+
const rioResponse = yield this.axios.get(`/api/liquidity/${asset}`, {
|
|
93
81
|
headers: {
|
|
94
82
|
"x-cluster-api-key": this.clusterApiKey,
|
|
95
83
|
},
|
|
@@ -104,13 +92,6 @@ const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
104
92
|
if (!CLUSTER_API_KEY) {
|
|
105
93
|
throw new common_1.SecretManagerError();
|
|
106
94
|
}
|
|
107
|
-
|
|
108
|
-
? "https://dev.riotransfer.co"
|
|
109
|
-
: process.env.RIO_ENV === common_1.RioEnv.Production
|
|
110
|
-
? "https://www.riotransfer.co"
|
|
111
|
-
: process.env.RIO_ENV === common_1.RioEnv.Staging
|
|
112
|
-
? "https://staging.riotransfer.co"
|
|
113
|
-
: "https://sandbox.riotransfer.co";
|
|
114
|
-
return new ClusterClient(baseUrl, CLUSTER_API_KEY);
|
|
95
|
+
return new ClusterClient(CLUSTER_API_KEY);
|
|
115
96
|
});
|
|
116
97
|
exports.buildClusterClient = buildClusterClient;
|