@riocrypto/common-server 1.0.2628 → 1.0.2630

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,5 +1,25 @@
1
1
  import { ExchangeResponse, FireblocksSDK, VaultAccountResponse } from "fireblocks-sdk";
2
2
  import { Crypto } from "@riocrypto/common";
3
+ export declare class FireblocksApiError extends Error {
4
+ readonly endpoint: string;
5
+ readonly method: string;
6
+ readonly statusCode: number | undefined;
7
+ readonly requestData: unknown;
8
+ readonly responseData: unknown;
9
+ readonly requestId: string | undefined;
10
+ readonly fireblocksCode: string | undefined;
11
+ constructor(endpoint: string, method: string, statusCode: number | undefined, requestData: unknown, responseData: unknown, requestId: string | undefined, fireblocksCode: string | undefined);
12
+ toJSON(): {
13
+ name: string;
14
+ endpoint: string;
15
+ method: string;
16
+ statusCode: number | undefined;
17
+ requestData: unknown;
18
+ responseData: unknown;
19
+ requestId: string | undefined;
20
+ fireblocksCode: string | undefined;
21
+ };
22
+ }
3
23
  declare class FireblocksClient {
4
24
  fireblocks: FireblocksSDK;
5
25
  constructor(privateKey: string, apiKey: string);
@@ -12,16 +12,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildFireblocksClient = void 0;
15
+ exports.buildFireblocksClient = exports.FireblocksApiError = void 0;
16
16
  const fireblocks_sdk_1 = require("fireblocks-sdk");
17
17
  const common_1 = require("@riocrypto/common");
18
18
  const secret_manager_client_1 = require("./secret-manager-client");
19
19
  const node_cache_1 = __importDefault(require("node-cache"));
20
20
  const cache = new node_cache_1.default({ stdTTL: 60 });
21
21
  const cache2 = new node_cache_1.default({ stdTTL: 10000 });
22
+ class FireblocksApiError extends Error {
23
+ constructor(endpoint, method, statusCode, requestData, responseData, requestId, fireblocksCode) {
24
+ const message = `Fireblocks API Error: ${method} ${endpoint} - Status: ${statusCode !== null && statusCode !== void 0 ? statusCode : "unknown"} - Code: ${fireblocksCode !== null && fireblocksCode !== void 0 ? fireblocksCode : "unknown"} - RequestId: ${requestId !== null && requestId !== void 0 ? requestId : "unknown"}`;
25
+ super(message);
26
+ this.endpoint = endpoint;
27
+ this.method = method;
28
+ this.statusCode = statusCode;
29
+ this.requestData = requestData;
30
+ this.responseData = responseData;
31
+ this.requestId = requestId;
32
+ this.fireblocksCode = fireblocksCode;
33
+ this.name = "FireblocksApiError";
34
+ }
35
+ toJSON() {
36
+ return {
37
+ name: this.name,
38
+ endpoint: this.endpoint,
39
+ method: this.method,
40
+ statusCode: this.statusCode,
41
+ requestData: this.requestData,
42
+ responseData: this.responseData,
43
+ requestId: this.requestId,
44
+ fireblocksCode: this.fireblocksCode,
45
+ };
46
+ }
47
+ }
48
+ exports.FireblocksApiError = FireblocksApiError;
22
49
  class FireblocksClient {
23
50
  constructor(privateKey, apiKey) {
24
- this.fireblocks = new fireblocks_sdk_1.FireblocksSDK(privateKey, apiKey, "https://api.fireblocks.io");
51
+ this.fireblocks = new fireblocks_sdk_1.FireblocksSDK(privateKey, apiKey, "https://api.fireblocks.io", undefined, {
52
+ customAxiosOptions: {
53
+ interceptors: {
54
+ response: {
55
+ onFulfilled: (response) => response,
56
+ onRejected: (error) => {
57
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
58
+ const endpoint = (_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : "unknown";
59
+ const method = (_e = (_d = (_c = error.config) === null || _c === void 0 ? void 0 : _c.method) === null || _d === void 0 ? void 0 : _d.toUpperCase()) !== null && _e !== void 0 ? _e : "unknown";
60
+ const statusCode = (_f = error.response) === null || _f === void 0 ? void 0 : _f.status;
61
+ const requestData = ((_g = error.config) === null || _g === void 0 ? void 0 : _g.data)
62
+ ? JSON.parse(error.config.data)
63
+ : undefined;
64
+ const responseData = (_h = error.response) === null || _h === void 0 ? void 0 : _h.data;
65
+ const requestId = (_l = (_k = (_j = error.response) === null || _j === void 0 ? void 0 : _j.headers) === null || _k === void 0 ? void 0 : _k["x-request-id"]) !== null && _l !== void 0 ? _l : undefined;
66
+ const fireblocksCode = (_p = (_o = (_m = error.response) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.code) !== null && _p !== void 0 ? _p : undefined;
67
+ throw new FireblocksApiError(endpoint, method, statusCode, requestData, responseData, requestId, fireblocksCode);
68
+ },
69
+ },
70
+ },
71
+ },
72
+ });
25
73
  }
26
74
  estimateWithdrawFee(crypto, address, amountCrypto) {
27
75
  return __awaiter(this, void 0, void 0, function* () {
@@ -296,6 +296,9 @@ const buildOrder = (mongoose) => {
296
296
  blockchainAddress: {
297
297
  type: String,
298
298
  },
299
+ blockchainMemo: {
300
+ type: String,
301
+ },
299
302
  accountHolderName: {
300
303
  type: String,
301
304
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2628",
3
+ "version": "1.0.2630",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.2427",
31
+ "@riocrypto/common": "^1.0.2428",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",