@riocrypto/common-server 1.0.1281 → 1.0.1283

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.
@@ -7,6 +7,10 @@ declare class ClusterClient {
7
7
  getNewQuote(orderId: string, quote: Quote, newAmountFiat?: number, newAmountCrypto?: number): Promise<Quote>;
8
8
  createBitsoBankAccount(userId: string): Promise<BitsoBankAccount>;
9
9
  getBalance(asset: Crypto | Fiat): Promise<number>;
10
+ getTransactionLimits(userId: string): Promise<{
11
+ limit: number;
12
+ used: number;
13
+ }>;
10
14
  }
11
15
  export declare const buildClusterClient: () => Promise<ClusterClient>;
12
16
  export {};
@@ -97,6 +97,16 @@ class ClusterClient {
97
97
  return rioResponse.data.balance;
98
98
  });
99
99
  }
100
+ getTransactionLimits(userId) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ const response = yield this.axios.get(`${this.baseUrl}/api/users/${userId}/limits`, {
103
+ headers: {
104
+ "x-cluster-api-key": this.clusterApiKey,
105
+ },
106
+ });
107
+ return response.data;
108
+ });
109
+ }
100
110
  }
101
111
  const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* () {
102
112
  // Retrieve secrets asynchronously
@@ -39,11 +39,13 @@ class CurrencyAPIClient {
39
39
  catch (e) {
40
40
  const cachedResponse = cache.get(`v3/latest?apikey=${this.apiKey}&base_currency=${from}&currencies=${to}`);
41
41
  if (!cachedResponse) {
42
+ console.log(`Unable to get exchange rate from currencyAPI for ${from} to ${to}`);
42
43
  throw new common_1.GenericInternalError(`Unable to get exchange rate from currencyAPI for ${from} to ${to}`);
43
44
  }
44
45
  const exchangeRate = cachedResponse.data[to].value;
45
46
  }
46
47
  if (!exchangeRate) {
48
+ console.log("Unable to get exchange rate");
47
49
  throw new common_1.GenericInternalError("Unable to get exchange rate");
48
50
  }
49
51
  return exchangeRate;
@@ -67,6 +69,7 @@ class CurrencyAPIClient {
67
69
  catch (e) {
68
70
  const cachedResponse = cache.get(`v3/range?apikey=${this.apiKey}&datetime_start=${start}&datetime_end=${end}&accuracy=minute&currencies=${to}&base_currency=${from}`);
69
71
  if (!cachedResponse) {
72
+ console.log(`Unable to get hsitorical exchange rates from currencyAPI for ${from} to ${to}`);
70
73
  throw new common_1.GenericInternalError(`Unable to get hsitorical exchange rates from currencyAPI for ${from} to ${to}`);
71
74
  }
72
75
  const exchangeRates = cachedResponse.data;
@@ -22,6 +22,7 @@ const getNetworkFees = (crypto, conversionRateToUSD) => __awaiter(void 0, void 0
22
22
  const cryptoToWithdraw = crypto === common_1.Crypto.USDTTron ? common_1.Crypto.USDCPolygon : crypto;
23
23
  const withdrawFee = yield fireblocksClient.estimateWithdrawFee(cryptoToWithdraw, address, 100);
24
24
  if (!withdrawFee) {
25
+ console.log("No withdraw fee");
25
26
  throw new common_1.GenericInternalError();
26
27
  }
27
28
  // Hacky way bc ccxt doesn't support TRON, so quote in MATIC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1281",
3
+ "version": "1.0.1283",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
- "@riocrypto/common": "^1.0.1155",
30
+ "@riocrypto/common": "^1.0.1157",
31
31
  "@types/express": "^4.17.13",
32
32
  "axios": "^0.27.2",
33
33
  "ccxt": "^3.0.30",