@riocrypto/common-server 1.0.1897 → 1.0.1898
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/bridge-client.js +0 -1
- package/build/clients/currency-api-client.js +3 -2
- package/build/clients/fireblocks-client.js +0 -3
- package/build/clients/slack-client.js +3 -1
- package/build/helpers/get-network-fees.js +0 -31
- package/build/middlewares/authorize.js +1 -3
- package/build/services/logger.js +7 -4
- package/package.json +1 -1
|
@@ -179,7 +179,6 @@ class BridgeClient {
|
|
|
179
179
|
}
|
|
180
180
|
getExternalAccount(bridgeCustomerId, externalAccountId) {
|
|
181
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
console.log("getting external account", `${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts/${externalAccountId}`);
|
|
183
182
|
const { data } = yield axios_with_logging_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/external_accounts/${externalAccountId}`, {
|
|
184
183
|
headers: {
|
|
185
184
|
"Api-Key": this.apiKey,
|
|
@@ -17,12 +17,14 @@ const common_1 = require("@riocrypto/common");
|
|
|
17
17
|
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
18
18
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
19
19
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
20
|
+
const logger_1 = __importDefault(require("../services/logger"));
|
|
20
21
|
const cache = new node_cache_1.default({ stdTTL: 10 });
|
|
21
22
|
class CurrencyAPIClient {
|
|
22
23
|
constructor(apiKey) {
|
|
23
24
|
this.apiKey = apiKey;
|
|
24
25
|
}
|
|
25
26
|
convert(from, to) {
|
|
27
|
+
var _a;
|
|
26
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
29
|
let exchangeRate = 0;
|
|
28
30
|
try {
|
|
@@ -44,7 +46,7 @@ class CurrencyAPIClient {
|
|
|
44
46
|
const exchangeRate = cachedResponse.data[to].value;
|
|
45
47
|
}
|
|
46
48
|
if (!exchangeRate) {
|
|
47
|
-
|
|
49
|
+
(_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.error("Unable to get exchange rate");
|
|
48
50
|
throw new common_1.GenericInternalError("Unable to get exchange rate");
|
|
49
51
|
}
|
|
50
52
|
return exchangeRate;
|
|
@@ -68,7 +70,6 @@ class CurrencyAPIClient {
|
|
|
68
70
|
catch (e) {
|
|
69
71
|
const cachedResponse = cache.get(`v3/range?apikey=${this.apiKey}&datetime_start=${start}&datetime_end=${end}&accuracy=minute¤cies=${to}&base_currency=${from}`);
|
|
70
72
|
if (!cachedResponse) {
|
|
71
|
-
console.log(`Unable to get hsitorical exchange rates from currencyAPI for ${from} to ${to}`);
|
|
72
73
|
throw new common_1.GenericInternalError(`Unable to get hsitorical exchange rates from currencyAPI for ${from} to ${to}`);
|
|
73
74
|
}
|
|
74
75
|
const exchangeRates = cachedResponse.data;
|
|
@@ -224,14 +224,11 @@ class FireblocksClient {
|
|
|
224
224
|
common_1.Crypto.USDTTron,
|
|
225
225
|
];
|
|
226
226
|
if (filterList.includes(asset.id)) {
|
|
227
|
-
console.log(asset.id);
|
|
228
|
-
console.log(asset.available);
|
|
229
227
|
balance += Number(asset.available);
|
|
230
228
|
}
|
|
231
229
|
});
|
|
232
230
|
}
|
|
233
231
|
});
|
|
234
|
-
console.log(assets);
|
|
235
232
|
return balance;
|
|
236
233
|
});
|
|
237
234
|
}
|
|
@@ -13,10 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.slackClient = void 0;
|
|
16
|
+
const logger_1 = __importDefault(require("../services/logger"));
|
|
16
17
|
const axios_with_logging_1 = __importDefault(require("./axios-with-logging"));
|
|
17
18
|
class SlackClient {
|
|
18
19
|
constructor() { }
|
|
19
20
|
sendMessageWithWebhook(message, webhookUrl) {
|
|
21
|
+
var _a;
|
|
20
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
23
|
try {
|
|
22
24
|
yield axios_with_logging_1.default.post(webhookUrl, {
|
|
@@ -24,7 +26,7 @@ class SlackClient {
|
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
catch (error) {
|
|
27
|
-
|
|
29
|
+
(_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.error(error);
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
}
|
|
@@ -3,37 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNetworkFees = void 0;
|
|
4
4
|
const common_1 = require("@riocrypto/common");
|
|
5
5
|
const getNetworkFees = (crypto, conversionRateToUSD) => {
|
|
6
|
-
// const address =
|
|
7
|
-
// crypto === Crypto.USDCSolana
|
|
8
|
-
// ? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
|
|
9
|
-
// : "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
10
|
-
// const fireblocksClient = await buildFireblocksClient();
|
|
11
|
-
// // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
|
|
12
|
-
// const cryptoToWithdraw =
|
|
13
|
-
// crypto === Crypto.USDTTron ? Crypto.USDCPolygon : crypto;
|
|
14
|
-
// const withdrawFee = await fireblocksClient.estimateWithdrawFee(
|
|
15
|
-
// cryptoToWithdraw,
|
|
16
|
-
// address,
|
|
17
|
-
// 100
|
|
18
|
-
// );
|
|
19
|
-
// if (!withdrawFee) {
|
|
20
|
-
// console.log("No withdraw fee");
|
|
21
|
-
// throw new GenericInternalError();
|
|
22
|
-
// }
|
|
23
|
-
// // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
|
|
24
|
-
// const gasSymbol =
|
|
25
|
-
// crypto === Crypto.USDTTron
|
|
26
|
-
// ? "MATIC"
|
|
27
|
-
// : new CryptoAsset(crypto).getGasSymbol();
|
|
28
|
-
// const withdrawFeeUSDResponse = await ccxtWrapper.getSellQuote(
|
|
29
|
-
// gasSymbol as Crypto,
|
|
30
|
-
// Fiat.USD,
|
|
31
|
-
// undefined,
|
|
32
|
-
// Number(withdrawFee)
|
|
33
|
-
// );
|
|
34
|
-
// const withdrawFeeInBaseCrypto = withdrawFeeUSDResponse.amountFiat;
|
|
35
|
-
// const withdrawFeeInBaseFiat =
|
|
36
|
-
// Number(withdrawFeeUSDResponse.amountFiat) * (1 / conversionRateToUSD);
|
|
37
6
|
let withdrawFeeInUSD = 0;
|
|
38
7
|
if (crypto === common_1.Crypto.USDTTron) {
|
|
39
8
|
withdrawFeeInUSD = 3;
|
|
@@ -55,9 +55,7 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
55
55
|
req.adminAuth = adminAuth;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
58
|
+
catch (err) { }
|
|
61
59
|
}
|
|
62
60
|
else if ((_a = req.cookies) === null || _a === void 0 ? void 0 : _a.adminAccessToken) {
|
|
63
61
|
try {
|
package/build/services/logger.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const common_1 = require("@riocrypto/common");
|
|
12
13
|
const winston_1 = require("winston");
|
|
13
14
|
class LoggerService {
|
|
14
15
|
constructor() {
|
|
@@ -97,10 +98,12 @@ class LoggerService {
|
|
|
97
98
|
const logLevel = "info";
|
|
98
99
|
const transportsArray = [new winston_1.transports.Console()];
|
|
99
100
|
const { getWinsonTransport } = yield require("@hyperdx/node-opentelemetry");
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (process.env.RIO_ENV !== common_1.RioEnv.Local) {
|
|
102
|
+
transportsArray.push(getWinsonTransport("info", {
|
|
103
|
+
apiKey: process.env.HYPERDX_API_KEY,
|
|
104
|
+
service: process.env.OTEL_SERVICE_NAME,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
104
107
|
this.logger = (0, winston_1.createLogger)({
|
|
105
108
|
level: logLevel,
|
|
106
109
|
format: winston_1.format.combine(winston_1.format.timestamp(), this.maskSensitiveData(), this.requestMethodFilter(), // Add the request method filter
|