@riocrypto/common-server 1.0.1037 → 1.0.1039
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/build/clients/cluster-client.d.ts +11 -0
- package/build/clients/cluster-client.js +76 -0
- package/build/clients/fireblocks-client.d.ts +1 -0
- package/build/clients/fireblocks-client.js +16 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/models/quote.d.ts +2 -0
- package/build/models/quote.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Quote, Fiat } from "@riocrypto/common";
|
|
2
|
+
declare class ClusterClient {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
private clusterApiKey;
|
|
5
|
+
private axios;
|
|
6
|
+
constructor(baseUrl: string, clusterApiKey: string);
|
|
7
|
+
getNewQuote(orderId: string, quote: Quote): Promise<Quote>;
|
|
8
|
+
getBalance(asset: Crypto | Fiat): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
export declare const buildClusterClient: () => Promise<ClusterClient>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.buildClusterClient = void 0;
|
|
16
|
+
const common_1 = require("@riocrypto/common");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const secret_manager_client_1 = require("./secret-manager-client");
|
|
19
|
+
class ClusterClient {
|
|
20
|
+
constructor(baseUrl, clusterApiKey) {
|
|
21
|
+
this.baseUrl = baseUrl;
|
|
22
|
+
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.riocrypto.com"
|
|
28
|
+
: process.env.RIO_ENV === common_1.RioEnv.Staging
|
|
29
|
+
? "staging.riocrypto.com"
|
|
30
|
+
: process.env.RIO_ENV === common_1.RioEnv.Sandbox
|
|
31
|
+
? "sandbox.riocrypto.com"
|
|
32
|
+
: "www.riocrypto.com",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getNewQuote(orderId, quote) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const response = yield this.axios.post(`${this.baseUrl}/api/quotes`, {
|
|
39
|
+
orderId,
|
|
40
|
+
userId: quote.userId,
|
|
41
|
+
side: quote.side,
|
|
42
|
+
crypto: quote.crypto,
|
|
43
|
+
fiat: quote.fiat,
|
|
44
|
+
amountFiat: !quote.quoteInCrypto ? quote.amountFiat : undefined,
|
|
45
|
+
amountCrypto: quote.quoteInCrypto ? quote.amountCrypto : undefined,
|
|
46
|
+
country: quote.country,
|
|
47
|
+
discount: quote.discount,
|
|
48
|
+
markup: quote.markup,
|
|
49
|
+
noMarkups: quote.noMarkups,
|
|
50
|
+
});
|
|
51
|
+
return response.data.balance;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getBalance(asset) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const rioResponse = yield this.axios.get(`${this.baseUrl}/api/wallet/balances/${asset}`);
|
|
57
|
+
return rioResponse.data.balance;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
// Retrieve secrets asynchronously
|
|
63
|
+
const CLUSTER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CLUSTER_API_KEY");
|
|
64
|
+
if (!CLUSTER_API_KEY) {
|
|
65
|
+
throw new common_1.SecretManagerError();
|
|
66
|
+
}
|
|
67
|
+
const baseUrl = process.env.RIO_ENV === common_1.RioEnv.Development
|
|
68
|
+
? "https://dev.riotransfer.co"
|
|
69
|
+
: process.env.RIO_ENV === common_1.RioEnv.Production
|
|
70
|
+
? "https://www.riotransfer.co"
|
|
71
|
+
: process.env.RIO_ENV === common_1.RioEnv.Staging
|
|
72
|
+
? "https://staging.riotransfer.co"
|
|
73
|
+
: "https://sandbox.riotransfer.co";
|
|
74
|
+
return new ClusterClient(baseUrl, CLUSTER_API_KEY);
|
|
75
|
+
});
|
|
76
|
+
exports.buildClusterClient = buildClusterClient;
|
|
@@ -13,6 +13,7 @@ declare class FireblocksClient {
|
|
|
13
13
|
getDepositAddress(vaultId: string, crypto: Crypto): Promise<string>;
|
|
14
14
|
createVault(userId: string, name: string): Promise<string>;
|
|
15
15
|
createWallet(vaultId: string, crypto: Crypto): Promise<string>;
|
|
16
|
+
sweep(vaultId: string, assetId: string, amount: number): Promise<void>;
|
|
16
17
|
}
|
|
17
18
|
export declare const buildFireblocksClient: () => Promise<FireblocksClient>;
|
|
18
19
|
export {};
|
|
@@ -138,6 +138,22 @@ class FireblocksClient {
|
|
|
138
138
|
return wallet.address;
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
sweep(vaultId, assetId, amount) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
yield this.fireblocks.createTransaction({
|
|
144
|
+
assetId: assetId,
|
|
145
|
+
source: {
|
|
146
|
+
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
147
|
+
id: vaultId,
|
|
148
|
+
},
|
|
149
|
+
destination: {
|
|
150
|
+
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
151
|
+
id: String(2),
|
|
152
|
+
},
|
|
153
|
+
amount: amount.toFixed(4),
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
141
157
|
}
|
|
142
158
|
const buildFireblocksClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
159
|
const FIREBLOCKS_PRIVATE_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIREBLOCKS_PRIVATE_KEY");
|
package/build/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export * from "./clients/aiprise-client";
|
|
|
53
53
|
export * from "./clients/bridge-client";
|
|
54
54
|
export * from "./clients/google-sheets-api-client";
|
|
55
55
|
export * from "./clients/invopop-client";
|
|
56
|
+
export * from "./clients/cluster-client";
|
|
56
57
|
export * from "./helpers/get-user-helper";
|
|
57
58
|
export * from "./helpers/get-platform-fees";
|
|
58
59
|
export * from "./helpers/get-processor-fees";
|
package/build/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __exportStar(require("./clients/aiprise-client"), exports);
|
|
|
69
69
|
__exportStar(require("./clients/bridge-client"), exports);
|
|
70
70
|
__exportStar(require("./clients/google-sheets-api-client"), exports);
|
|
71
71
|
__exportStar(require("./clients/invopop-client"), exports);
|
|
72
|
+
__exportStar(require("./clients/cluster-client"), exports);
|
|
72
73
|
__exportStar(require("./helpers/get-user-helper"), exports);
|
|
73
74
|
__exportStar(require("./helpers/get-platform-fees"), exports);
|
|
74
75
|
__exportStar(require("./helpers/get-processor-fees"), exports);
|
package/build/models/quote.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ interface QuoteAttrs {
|
|
|
18
18
|
price: number;
|
|
19
19
|
createdAt: Date;
|
|
20
20
|
noMarkups: boolean;
|
|
21
|
+
quoteInCrypto: boolean;
|
|
21
22
|
depositAddress?: string;
|
|
22
23
|
brokerId?: string;
|
|
23
24
|
conversionRateUSD: number;
|
|
@@ -42,6 +43,7 @@ interface QuoteDoc extends Document {
|
|
|
42
43
|
createdAt: Date;
|
|
43
44
|
fees: Fees;
|
|
44
45
|
price: number;
|
|
46
|
+
quoteInCrypto: boolean;
|
|
45
47
|
noMarkups: boolean;
|
|
46
48
|
depositAddress?: string;
|
|
47
49
|
brokerId?: string;
|
package/build/models/quote.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1039",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
25
25
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
26
26
|
"@google-cloud/storage": "^6.9.5",
|
|
27
|
-
"@riocrypto/common": "^1.0.
|
|
27
|
+
"@riocrypto/common": "^1.0.896",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|