@ultrade/shared 1.0.1 → 1.0.3

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.
Files changed (34) hide show
  1. package/dist/common/index.d.ts +0 -5
  2. package/dist/common/index.js +0 -643
  3. package/dist/constants/index.d.ts +0 -1
  4. package/dist/constants/index.js +0 -78
  5. package/dist/helpers/assert.helper.js +0 -78
  6. package/dist/helpers/atomic.helper.js +0 -78
  7. package/dist/helpers/balance.helper.js +0 -78
  8. package/dist/helpers/codex/common.helper.js +0 -78
  9. package/dist/helpers/codex/index.js +0 -78
  10. package/dist/helpers/codex/mbr.helper.js +0 -78
  11. package/dist/helpers/codex/mna.helper.js +0 -78
  12. package/dist/helpers/codex/order.helper.js +0 -78
  13. package/dist/helpers/codex/setGlobal.helper.js +0 -78
  14. package/dist/helpers/codex/transfer.helper.js +0 -78
  15. package/dist/helpers/codex/txn.helper.js +0 -78
  16. package/dist/helpers/codex.helper.js +0 -78
  17. package/dist/helpers/eth.helper.js +0 -78
  18. package/dist/helpers/vaa.helper.js +0 -78
  19. package/dist/helpers/withdraw.helper.js +0 -78
  20. package/package.json +3 -9
  21. package/dist/common/awsKms.d.ts +0 -2
  22. package/dist/common/awsKms.js +0 -255
  23. package/dist/common/indexer.helper.d.ts +0 -2
  24. package/dist/common/indexer.helper.js +0 -377
  25. package/dist/common/logger.d.ts +0 -32
  26. package/dist/common/logger.js +0 -178
  27. package/dist/common/migration.helpers.d.ts +0 -4
  28. package/dist/common/migration.helpers.js +0 -33
  29. package/dist/common/redis.helper.d.ts +0 -27
  30. package/dist/common/redis.helper.js +0 -249
  31. package/dist/constants/queue.d.ts +0 -39
  32. package/dist/helpers/hummingbots.helper.d.ts +0 -2
  33. package/dist/helpers/hummingbots.helper.js +0 -152
  34. package/dist/interfaces/controller.interface.d.ts +0 -6
@@ -1,249 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ 657:
6
- /***/ ((module) => {
7
-
8
- module.exports = require("ioredis");
9
-
10
- /***/ }),
11
-
12
- /***/ 5281:
13
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
14
-
15
-
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", ({ value: true }));
20
- const ioredis_1 = __importDefault(__webpack_require__(657));
21
- class RedisHelper {
22
- host = process.env.REDIS_HOSTNAME;
23
- port = process.env.REDIS_PORT;
24
- client = new ioredis_1.default({
25
- host: this.host,
26
- port: Number(this.port),
27
- lazyConnect: true,
28
- });
29
- operationQueue = [];
30
- runningOperations = false;
31
- constructor() {
32
- this.client.on('connect', () => {
33
- });
34
- this.client.on('ready', () => {
35
- this.performPendingOperations();
36
- });
37
- this.client.on('error', (err) => {
38
- console.error('Redis error:', err.message);
39
- });
40
- this.client.on('close', () => {
41
- console.log('Redis connection closed');
42
- });
43
- }
44
- async performPendingOperations() {
45
- this.runningOperations = true;
46
- while (this.operationQueue.length > 0) {
47
- const operation = this.operationQueue.shift();
48
- if (operation) {
49
- try {
50
- await operation();
51
- }
52
- catch (err) {
53
- console.error('Error performing Redis operation:', err);
54
- }
55
- }
56
- }
57
- this.runningOperations = false;
58
- }
59
- async setString(key, value, expires = 0, database = '') {
60
- const operation = async () => {
61
- if (database !== '') {
62
- this.client.select(Number(database));
63
- }
64
- await this.client.set(key, value);
65
- if (expires !== 0) {
66
- await this.client.expire(key, expires * 60);
67
- }
68
- };
69
- await this.performOperation(operation);
70
- }
71
- async incrementKey(key, expires = 0, database = '') {
72
- const operation = async () => {
73
- if (database !== '') {
74
- this.client.select(Number(database));
75
- }
76
- await this.client.incr(key);
77
- if (expires !== 0) {
78
- const ttl = await this.client.ttl(key);
79
- if (ttl === -1) {
80
- await this.client.expire(key, expires * 60);
81
- }
82
- }
83
- };
84
- await this.performOperation(operation);
85
- }
86
- async scanKeys(pattern, database = '') {
87
- const matchedKeys = [];
88
- const operation = async () => {
89
- if (database !== '') {
90
- this.client.select(Number(database));
91
- }
92
- let cursor = '0';
93
- do {
94
- const [nextCursor, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
95
- cursor = nextCursor;
96
- matchedKeys.push(...keys);
97
- } while (cursor !== '0');
98
- };
99
- await this.performOperation(operation);
100
- return matchedKeys;
101
- }
102
- getString(key, database = '') {
103
- return new Promise(async (resolve, reject) => {
104
- const operation = async () => {
105
- try {
106
- if (database !== '') {
107
- await this.client.select(Number(database));
108
- }
109
- const value = await this.client.get(key);
110
- resolve(value);
111
- }
112
- catch (err) {
113
- reject(err);
114
- }
115
- };
116
- this.performOperation(operation);
117
- });
118
- }
119
- async deleteString(key, database = '') {
120
- const operation = async () => {
121
- if (database !== '') {
122
- this.client.select(Number(database));
123
- }
124
- await this.client.del(key);
125
- };
126
- await this.performOperation(operation);
127
- }
128
- async deleteByKeyPattern(pattern, database = '') {
129
- const operation = async () => {
130
- if (database !== '') {
131
- this.client.select(Number(database));
132
- }
133
- const keys = await this.client.keys(pattern);
134
- if (keys.length > 0) {
135
- await this.client.unlink(keys);
136
- console.log(`Deleted ${keys.length} keys`);
137
- }
138
- else {
139
- console.log('No keys for delete');
140
- }
141
- };
142
- await this.performOperation(operation);
143
- }
144
- async destroyDb(dbKey) {
145
- const response = await this.client.del(dbKey);
146
- return response === 1;
147
- }
148
- async performOperation(operation) {
149
- this.operationQueue.push(operation);
150
- if (!this.runningOperations) {
151
- try {
152
- await this.performPendingOperations();
153
- }
154
- catch (error) {
155
- console.error('Error during performing Redis operation', error);
156
- }
157
- }
158
- }
159
- async close() {
160
- console.log('Closing Redis client for graceful shutdown...');
161
- try {
162
- while (this.operationQueue.length > 0 || this.runningOperations) {
163
- await new Promise((resolve) => setTimeout(resolve, 100));
164
- }
165
- await this.client.quit();
166
- console.log('Redis client closed successfully');
167
- }
168
- catch (error) {
169
- console.error('Error during Redis client shutdown:', error);
170
- }
171
- }
172
- async createStream(key) {
173
- await this.client.xgroup('CREATE', key, 'group', '$', 'MKSTREAM');
174
- }
175
- async writeToStream(key, message) {
176
- try {
177
- if (await this.streamExists(key)) {
178
- await this.client.xadd(key, '*', 'message', JSON.stringify(message));
179
- }
180
- }
181
- catch (error) {
182
- console.log(`[Stream '${key}']`, 'Error while writing to stream', error);
183
- }
184
- }
185
- async readStream(key, timeout) {
186
- const results = await this.client.xreadgroup('GROUP', 'group', 'consumer', 'COUNT', 1, 'BLOCK', timeout * 1000, 'STREAMS', key, '>');
187
- if (results && results.length > 0) {
188
- const [, entries] = results[0];
189
- if (entries && entries.length > 0) {
190
- const [, [, message]] = entries[0];
191
- return JSON.parse(message);
192
- }
193
- }
194
- return null;
195
- }
196
- async deleteStream(key) {
197
- if (await this.streamExists(key)) {
198
- await this.client.del(key);
199
- }
200
- }
201
- async setTTL(key, ttlSeconds) {
202
- await this.client.expire(key, ttlSeconds);
203
- }
204
- async streamExists(key) {
205
- const exists = await this.client.exists(key);
206
- return exists === 1;
207
- }
208
- }
209
- exports["default"] = new RedisHelper();
210
-
211
-
212
- /***/ })
213
-
214
- /******/ });
215
- /************************************************************************/
216
- /******/ // The module cache
217
- /******/ var __webpack_module_cache__ = {};
218
- /******/
219
- /******/ // The require function
220
- /******/ function __webpack_require__(moduleId) {
221
- /******/ // Check if module is in cache
222
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
223
- /******/ if (cachedModule !== undefined) {
224
- /******/ return cachedModule.exports;
225
- /******/ }
226
- /******/ // Create a new module (and put it into the cache)
227
- /******/ var module = __webpack_module_cache__[moduleId] = {
228
- /******/ // no module.id needed
229
- /******/ // no module.loaded needed
230
- /******/ exports: {}
231
- /******/ };
232
- /******/
233
- /******/ // Execute the module function
234
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
235
- /******/
236
- /******/ // Return the exports of the module
237
- /******/ return module.exports;
238
- /******/ }
239
- /******/
240
- /************************************************************************/
241
- /******/
242
- /******/ // startup
243
- /******/ // Load entry module and return exports
244
- /******/ // This entry module is referenced by other modules so it can't be inlined
245
- /******/ var __webpack_exports__ = __webpack_require__(5281);
246
- /******/ module.exports = __webpack_exports__;
247
- /******/
248
- /******/ })()
249
- ;
@@ -1,39 +0,0 @@
1
- import { Options } from 'amqplib';
2
- export declare enum QueueNames {
3
- CANCELLATION_TRADE = "cancellation_trade",
4
- CANCEL_ORDER = "cancelOrder",
5
- MAINTENANCE = "maintenance",
6
- SYSTEM = "system",
7
- NEW_ORDER = "newOrder",
8
- PROCESS_WALLET_TRANSACTION = "wallet_transaction",
9
- LAST_LOOK_TRADE = "last_look_trade",
10
- SEND_TRADE_TO_SETTLE = "send_trade_to_settle",
11
- TRADE_FIRE = "trade_fire",
12
- TRADE_CONFIRMED = "trade_confirmed",
13
- ORDER_OPERATION = "order_operation",
14
- ORDER_RESULT = "order_result",
15
- TRADES_QUEUE = "trades_q",
16
- OPEN_ORDER_BOOK = "open_order_book",
17
- SOCKET_WALLET_TRANSACTION = "socket_wallet_transaction",
18
- STREAM_UPDATE_QUOTE = "stream_update_quote",
19
- STREAM_UPDATE_LAST_PRICE = "stream_update_last_price",
20
- STREAM_UPDATE_DEPTH = "stream_update_depth",
21
- STREAM_UPDATE_LAST_CANDLESTICK = "stream_update_last_candlestick",
22
- STREAM_UPDATE_ORDERS = "stream_update_orders",
23
- STREAM_UPDATE_TRADES = "stream_update_trades",
24
- STREAM_UPDATE_ORDER_BOOK = "stream_update_order_book",
25
- CODEX_DEPOSIT = "codex_deposit",
26
- CODEX_TRANSFER = "codex_transfer",
27
- CODEX_WITHDRAWAL = "codex_withdrawal",
28
- CODEX_BALANCES = "codex_balances",
29
- CODEX_TRADE = "codex_trade",
30
- VAA_LOG = "vaa_log",
31
- SETTINGS_UPDATE = "settings_update",
32
- POINT_SYSTEM_SETTINGS_UPDATE = "point_system_settings_update",
33
- NEW_NOTIFICATION = "new_notification"
34
- }
35
- export declare const QueueOptions: {
36
- [key in QueueNames]: {
37
- options?: Options.AssertQueue;
38
- };
39
- };
@@ -1,2 +0,0 @@
1
- export declare function encryptSecretValue(password: string, value: string): string;
2
- export declare function createStrategyHash(partnerId: number, yamlString: string): string;
@@ -1,152 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ 913:
6
- /***/ ((module) => {
7
-
8
- module.exports = require("yaml");
9
-
10
- /***/ }),
11
-
12
- /***/ 3089:
13
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
14
-
15
-
16
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- var desc = Object.getOwnPropertyDescriptor(m, k);
19
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
- desc = { enumerable: true, get: function() { return m[k]; } };
21
- }
22
- Object.defineProperty(o, k2, desc);
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || (function () {
33
- var ownKeys = function(o) {
34
- ownKeys = Object.getOwnPropertyNames || function (o) {
35
- var ar = [];
36
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
- return ar;
38
- };
39
- return ownKeys(o);
40
- };
41
- return function (mod) {
42
- if (mod && mod.__esModule) return mod;
43
- var result = {};
44
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
- __setModuleDefault(result, mod);
46
- return result;
47
- };
48
- })();
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", ({ value: true }));
53
- exports.encryptSecretValue = encryptSecretValue;
54
- exports.createStrategyHash = createStrategyHash;
55
- const crypto_1 = __importDefault(__webpack_require__(6982));
56
- const ethUtil = __importStar(__webpack_require__(7835));
57
- const yaml_1 = __webpack_require__(913);
58
- function encryptSecretValue(password, value) {
59
- const passwordBytes = Buffer.from(password, 'utf-8');
60
- const kdf = 'pbkdf2';
61
- const dklen = 32;
62
- const salt = crypto_1.default.randomBytes(16);
63
- const iterations = 1000000;
64
- const hashFunction = 'hmac-sha256';
65
- const derivedKey = crypto_1.default.pbkdf2Sync(passwordBytes, salt, iterations, dklen, 'sha256');
66
- const iv = crypto_1.default.randomBytes(16);
67
- const encryptKey = derivedKey.slice(0, 16);
68
- const cipher = crypto_1.default.createCipheriv('aes-128-ctr', encryptKey, iv);
69
- const ciphertext = Buffer.concat([cipher.update(Buffer.from(value, 'utf-8')), cipher.final()]);
70
- const mac = ethUtil.keccak256(Buffer.concat([derivedKey.slice(16, 32), ciphertext]));
71
- const keyfileJson = {
72
- crypto: {
73
- cipher: 'aes-128-ctr',
74
- cipherparams: {
75
- iv: iv.toString('hex'),
76
- },
77
- ciphertext: ciphertext.toString('hex'),
78
- kdf: kdf,
79
- kdfparams: {
80
- c: iterations,
81
- dklen: dklen,
82
- prf: hashFunction,
83
- salt: salt.toString('hex'),
84
- },
85
- mac: mac.toString(),
86
- },
87
- version: 3,
88
- };
89
- const jsonStr = JSON.stringify(keyfileJson);
90
- const encryptedValue = Buffer.from(jsonStr).toString('hex');
91
- return encryptedValue;
92
- }
93
- function createStrategyHash(partnerId, yamlString) {
94
- const yamlAsJson = JSON.stringify((0, yaml_1.parse)(yamlString));
95
- const combinedString = `${partnerId}:${yamlAsJson}`;
96
- const hash = crypto_1.default.createHash('sha256').update(combinedString).digest('hex');
97
- return hash;
98
- }
99
-
100
-
101
- /***/ }),
102
-
103
- /***/ 6982:
104
- /***/ ((module) => {
105
-
106
- module.exports = require("crypto");
107
-
108
- /***/ }),
109
-
110
- /***/ 7835:
111
- /***/ ((module) => {
112
-
113
- module.exports = require("ethereumjs-util");
114
-
115
- /***/ })
116
-
117
- /******/ });
118
- /************************************************************************/
119
- /******/ // The module cache
120
- /******/ var __webpack_module_cache__ = {};
121
- /******/
122
- /******/ // The require function
123
- /******/ function __webpack_require__(moduleId) {
124
- /******/ // Check if module is in cache
125
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
126
- /******/ if (cachedModule !== undefined) {
127
- /******/ return cachedModule.exports;
128
- /******/ }
129
- /******/ // Create a new module (and put it into the cache)
130
- /******/ var module = __webpack_module_cache__[moduleId] = {
131
- /******/ // no module.id needed
132
- /******/ // no module.loaded needed
133
- /******/ exports: {}
134
- /******/ };
135
- /******/
136
- /******/ // Execute the module function
137
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
138
- /******/
139
- /******/ // Return the exports of the module
140
- /******/ return module.exports;
141
- /******/ }
142
- /******/
143
- /************************************************************************/
144
- /******/
145
- /******/ // startup
146
- /******/ // Load entry module and return exports
147
- /******/ // This entry module is referenced by other modules so it can't be inlined
148
- /******/ var __webpack_exports__ = __webpack_require__(3089);
149
- /******/ module.exports = __webpack_exports__;
150
- /******/
151
- /******/ })()
152
- ;
@@ -1,6 +0,0 @@
1
- import { Router } from 'express';
2
- interface Controller {
3
- path: string;
4
- router: Router;
5
- }
6
- export default Controller;