@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.
- package/dist/common/index.d.ts +0 -5
- package/dist/common/index.js +0 -643
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -78
- package/dist/helpers/assert.helper.js +0 -78
- package/dist/helpers/atomic.helper.js +0 -78
- package/dist/helpers/balance.helper.js +0 -78
- package/dist/helpers/codex/common.helper.js +0 -78
- package/dist/helpers/codex/index.js +0 -78
- package/dist/helpers/codex/mbr.helper.js +0 -78
- package/dist/helpers/codex/mna.helper.js +0 -78
- package/dist/helpers/codex/order.helper.js +0 -78
- package/dist/helpers/codex/setGlobal.helper.js +0 -78
- package/dist/helpers/codex/transfer.helper.js +0 -78
- package/dist/helpers/codex/txn.helper.js +0 -78
- package/dist/helpers/codex.helper.js +0 -78
- package/dist/helpers/eth.helper.js +0 -78
- package/dist/helpers/vaa.helper.js +0 -78
- package/dist/helpers/withdraw.helper.js +0 -78
- package/package.json +3 -9
- package/dist/common/awsKms.d.ts +0 -2
- package/dist/common/awsKms.js +0 -255
- package/dist/common/indexer.helper.d.ts +0 -2
- package/dist/common/indexer.helper.js +0 -377
- package/dist/common/logger.d.ts +0 -32
- package/dist/common/logger.js +0 -178
- package/dist/common/migration.helpers.d.ts +0 -4
- package/dist/common/migration.helpers.js +0 -33
- package/dist/common/redis.helper.d.ts +0 -27
- package/dist/common/redis.helper.js +0 -249
- package/dist/constants/queue.d.ts +0 -39
- package/dist/helpers/hummingbots.helper.d.ts +0 -2
- package/dist/helpers/hummingbots.helper.js +0 -152
- package/dist/interfaces/controller.interface.d.ts +0 -6
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
/******/ var __webpack_modules__ = ({
|
|
4
|
-
|
|
5
|
-
/***/ 298:
|
|
6
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10
|
-
exports.Logger = void 0;
|
|
11
|
-
const node_process_1 = __webpack_require__(1708);
|
|
12
|
-
class Logger {
|
|
13
|
-
_timeLabels = new Map();
|
|
14
|
-
_prefix;
|
|
15
|
-
disabled;
|
|
16
|
-
constructor(prefix, disabled) {
|
|
17
|
-
this._prefix = prefix;
|
|
18
|
-
this.disabled = disabled;
|
|
19
|
-
}
|
|
20
|
-
log(...args) {
|
|
21
|
-
if (this.disabled) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
this._prefix
|
|
26
|
-
? console.log(this.prefixLabel(this._prefix), ...this.formatArgs(args))
|
|
27
|
-
: console.log(...this.formatArgs(args));
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.log('Error on formating args', error);
|
|
31
|
-
console.log('Args =>', ...args);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
logWarning(message) {
|
|
35
|
-
console.log(this.toYellow(message));
|
|
36
|
-
}
|
|
37
|
-
getUniqueTimeLabel(label) {
|
|
38
|
-
const timeLabel = `[${Math.random() * Math.pow(10, 18)}] ${label}`;
|
|
39
|
-
return timeLabel;
|
|
40
|
-
}
|
|
41
|
-
time(label) {
|
|
42
|
-
if (this._timeLabels.has(label)) {
|
|
43
|
-
console.warn(`Label '${label}' already exists for logger.time()`);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const start = node_process_1.hrtime.bigint();
|
|
47
|
-
this._timeLabels.set(label, start);
|
|
48
|
-
}
|
|
49
|
-
timeEnd(label) {
|
|
50
|
-
if (!this._timeLabels.has(label)) {
|
|
51
|
-
console.warn(`Label '${label}' does not exist for logger.time()`);
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
const start = this._timeLabels.get(label);
|
|
55
|
-
const end = node_process_1.hrtime.bigint();
|
|
56
|
-
const diff = +(Number(end - start) / 1000000).toFixed(2);
|
|
57
|
-
const color = process.env.LOGGING_OBJECT_INLINE !== "false"
|
|
58
|
-
? this.noColor
|
|
59
|
-
: (diff > 100 ? this.toRed : this.toYellow);
|
|
60
|
-
if (diff > 100 || (label.includes('update24hStat') && diff > 25)) {
|
|
61
|
-
this.log(`Benchmark took ${color(diff)} milliseconds for ${color(label)}`);
|
|
62
|
-
}
|
|
63
|
-
this._timeLabels.delete(label);
|
|
64
|
-
return +diff;
|
|
65
|
-
}
|
|
66
|
-
logRabbit(...args) {
|
|
67
|
-
this.log(...this.formatArgs(["[Rabbit]", ...args]));
|
|
68
|
-
}
|
|
69
|
-
logPair(...args) {
|
|
70
|
-
this.log(...this.formatArgs(args, "Pair"));
|
|
71
|
-
}
|
|
72
|
-
logPairTime(pair, label) {
|
|
73
|
-
this.time(`${this.prefixLabel("Pair", pair)} ${label}`);
|
|
74
|
-
}
|
|
75
|
-
logPairTimeEnd(pair, label) {
|
|
76
|
-
this.timeEnd(`${this.prefixLabel("Pair", pair)} ${label}`);
|
|
77
|
-
}
|
|
78
|
-
logOrder(...args) {
|
|
79
|
-
this.log(...this.formatArgs(args, "OrderID"));
|
|
80
|
-
}
|
|
81
|
-
logOrderTime(id, label) {
|
|
82
|
-
this.time(`${this.prefixLabel("OrderID", id)} ${label}`);
|
|
83
|
-
}
|
|
84
|
-
logOrderTimeEnd(id, label) {
|
|
85
|
-
this.timeEnd(`${this.prefixLabel("OrderID", id)} ${label}`);
|
|
86
|
-
}
|
|
87
|
-
logTrade(...args) {
|
|
88
|
-
this.log(...this.formatArgs(args, "TradeID"));
|
|
89
|
-
}
|
|
90
|
-
logCompany(...args) {
|
|
91
|
-
this.log(...this.formatArgs(args, "CompanyID"));
|
|
92
|
-
}
|
|
93
|
-
logTradeTime(id, label) {
|
|
94
|
-
this.time(`${this.prefixLabel("TradeID", id)} ${label}`);
|
|
95
|
-
}
|
|
96
|
-
logTradeTimeEnd(id, label) {
|
|
97
|
-
this.timeEnd(`${this.prefixLabel("TradeID", id)} ${label}`);
|
|
98
|
-
}
|
|
99
|
-
logOperation(...args) {
|
|
100
|
-
this.log(...this.formatArgs(args, "OperationID"));
|
|
101
|
-
}
|
|
102
|
-
logVaa(...args) {
|
|
103
|
-
this.log(...this.formatArgs(args, "VaaId"));
|
|
104
|
-
}
|
|
105
|
-
logRequest(event, maskFunction = (_, body) => body) {
|
|
106
|
-
const { httpMethod, path, queryStringParameters, body } = event;
|
|
107
|
-
this.log(httpMethod, path, { queryStringParameters, body: maskFunction(path, body) });
|
|
108
|
-
}
|
|
109
|
-
formatArgs(args, prefix = null) {
|
|
110
|
-
return args.map((value, index) => {
|
|
111
|
-
if (index === 0 && typeof value === "string" && prefix === "Pair") {
|
|
112
|
-
return `[${value}]`;
|
|
113
|
-
}
|
|
114
|
-
if (index === 0 && !!prefix) {
|
|
115
|
-
return this.prefixLabel(prefix, typeof value === "object" ? JSON.stringify(value) : value);
|
|
116
|
-
}
|
|
117
|
-
if (typeof value === "object" && process.env.LOGGING_OBJECT_INLINE !== "false") {
|
|
118
|
-
return JSON.stringify(value);
|
|
119
|
-
}
|
|
120
|
-
return value;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
prefixLabel(prefix, value) {
|
|
124
|
-
return value ? `[${prefix}: ${value}]` : `[${prefix}]`;
|
|
125
|
-
}
|
|
126
|
-
toYellow(value) {
|
|
127
|
-
return `\x1b[33m${value}\x1b[0m`;
|
|
128
|
-
}
|
|
129
|
-
toRed(value) {
|
|
130
|
-
return `\x1b[31m${value}\x1b[0m`;
|
|
131
|
-
}
|
|
132
|
-
noColor(value) {
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.Logger = Logger;
|
|
137
|
-
exports["default"] = new Logger();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/***/ }),
|
|
141
|
-
|
|
142
|
-
/***/ 1708:
|
|
143
|
-
/***/ ((module) => {
|
|
144
|
-
|
|
145
|
-
module.exports = require("node:process");
|
|
146
|
-
|
|
147
|
-
/***/ }),
|
|
148
|
-
|
|
149
|
-
/***/ 3450:
|
|
150
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
154
|
-
if (k2 === undefined) k2 = k;
|
|
155
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
156
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
157
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
158
|
-
}
|
|
159
|
-
Object.defineProperty(o, k2, desc);
|
|
160
|
-
}) : (function(o, m, k, k2) {
|
|
161
|
-
if (k2 === undefined) k2 = k;
|
|
162
|
-
o[k2] = m[k];
|
|
163
|
-
}));
|
|
164
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
165
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
166
|
-
}) : function(o, v) {
|
|
167
|
-
o["default"] = v;
|
|
168
|
-
});
|
|
169
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
170
|
-
var ownKeys = function(o) {
|
|
171
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
172
|
-
var ar = [];
|
|
173
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
174
|
-
return ar;
|
|
175
|
-
};
|
|
176
|
-
return ownKeys(o);
|
|
177
|
-
};
|
|
178
|
-
return function (mod) {
|
|
179
|
-
if (mod && mod.__esModule) return mod;
|
|
180
|
-
var result = {};
|
|
181
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
182
|
-
__setModuleDefault(result, mod);
|
|
183
|
-
return result;
|
|
184
|
-
};
|
|
185
|
-
})();
|
|
186
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
187
|
-
exports.printUnpackedLocalData = exports.getAccounInfoFormLocalStorage = void 0;
|
|
188
|
-
exports.unpackData = unpackData;
|
|
189
|
-
exports.decodeString = decodeString;
|
|
190
|
-
const algosdk_1 = __importStar(__webpack_require__(8115));
|
|
191
|
-
const orderByteSize = 28;
|
|
192
|
-
const getAccounInfoFormLocalStorage = (localState) => {
|
|
193
|
-
const uintArray = Buffer.from(localState, 'base64');
|
|
194
|
-
const unpackedData = unpackData(uintArray, {
|
|
195
|
-
"priceCoin_locked": {
|
|
196
|
-
type: "uint",
|
|
197
|
-
},
|
|
198
|
-
"priceCoin_available": {
|
|
199
|
-
type: "uint",
|
|
200
|
-
},
|
|
201
|
-
"baseCoin_locked": {
|
|
202
|
-
type: "uint",
|
|
203
|
-
},
|
|
204
|
-
"baseCoin_available": {
|
|
205
|
-
type: "uint",
|
|
206
|
-
},
|
|
207
|
-
"companyId": {
|
|
208
|
-
type: "uint",
|
|
209
|
-
},
|
|
210
|
-
"WLFeeShare": {
|
|
211
|
-
type: "uint",
|
|
212
|
-
},
|
|
213
|
-
"WLCustomFee": {
|
|
214
|
-
type: "uint",
|
|
215
|
-
},
|
|
216
|
-
"slotMap": {
|
|
217
|
-
type: "uint",
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
return unpackedData;
|
|
221
|
-
};
|
|
222
|
-
exports.getAccounInfoFormLocalStorage = getAccounInfoFormLocalStorage;
|
|
223
|
-
function unpackData(data, format) {
|
|
224
|
-
const result = new Map();
|
|
225
|
-
let index = 0;
|
|
226
|
-
for (const [name, type] of Object.entries(format)) {
|
|
227
|
-
if (index >= data.length) {
|
|
228
|
-
throw new Error('Array index out of bounds');
|
|
229
|
-
}
|
|
230
|
-
let value;
|
|
231
|
-
switch (type.type) {
|
|
232
|
-
case 'address':
|
|
233
|
-
value = (0, algosdk_1.encodeAddress)(data.slice(index, index + 32));
|
|
234
|
-
index += 32;
|
|
235
|
-
break;
|
|
236
|
-
case 'bytes':
|
|
237
|
-
value = data.slice(index, index + type.size);
|
|
238
|
-
value = algosdk_1.default.decodeUint64(value, "mixed");
|
|
239
|
-
index += type.size;
|
|
240
|
-
break;
|
|
241
|
-
case 'uint':
|
|
242
|
-
value = algosdk_1.default.decodeUint64(data.slice(index, index + 8), "mixed");
|
|
243
|
-
index += 8;
|
|
244
|
-
break;
|
|
245
|
-
case 'string':
|
|
246
|
-
value = decodeString(data.slice(index, index + type.size));
|
|
247
|
-
index += type.size;
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
result.set(name, value);
|
|
251
|
-
}
|
|
252
|
-
return Object.fromEntries(result);
|
|
253
|
-
}
|
|
254
|
-
function decodeString(value) {
|
|
255
|
-
return Buffer.from(value).toString('utf-8');
|
|
256
|
-
}
|
|
257
|
-
const printUnpackedLocalData = (localState) => {
|
|
258
|
-
const uintArray = Buffer.from(localState, 'base64');
|
|
259
|
-
const unpackedData = [];
|
|
260
|
-
for (let i = 0; i < 4; i++) {
|
|
261
|
-
let data = unpackData(uintArray.subarray(orderByteSize * i, orderByteSize * (i + 1)), {
|
|
262
|
-
"orderID": {
|
|
263
|
-
type: "uint",
|
|
264
|
-
},
|
|
265
|
-
"side": {
|
|
266
|
-
type: "string",
|
|
267
|
-
size: 1
|
|
268
|
-
},
|
|
269
|
-
"price": {
|
|
270
|
-
type: "uint",
|
|
271
|
-
},
|
|
272
|
-
"amount": {
|
|
273
|
-
type: "uint",
|
|
274
|
-
},
|
|
275
|
-
"type": {
|
|
276
|
-
type: "string",
|
|
277
|
-
size: 1
|
|
278
|
-
},
|
|
279
|
-
"directSettle": {
|
|
280
|
-
type: "string",
|
|
281
|
-
size: 1
|
|
282
|
-
},
|
|
283
|
-
"storageSlot": {
|
|
284
|
-
type: "bytes",
|
|
285
|
-
size: 1
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
unpackedData.push(data);
|
|
289
|
-
}
|
|
290
|
-
return unpackedData;
|
|
291
|
-
};
|
|
292
|
-
exports.printUnpackedLocalData = printUnpackedLocalData;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/***/ }),
|
|
296
|
-
|
|
297
|
-
/***/ 7413:
|
|
298
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
302
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
303
|
-
};
|
|
304
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
305
|
-
exports.extractAppOrders = extractAppOrders;
|
|
306
|
-
const decode_1 = __webpack_require__(3450);
|
|
307
|
-
const logger_1 = __importDefault(__webpack_require__(298));
|
|
308
|
-
function extractAppOrders(account, appId) {
|
|
309
|
-
logger_1.default.log('accountInfo', account);
|
|
310
|
-
if (!account?.hasOwnProperty('apps-local-state')) {
|
|
311
|
-
logger_1.default.log(`No apps-local-state at account`, account);
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
314
|
-
let localState = account['apps-local-state'];
|
|
315
|
-
if (!localState?.length) {
|
|
316
|
-
logger_1.default.log('apps-local-state', localState);
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
const ordersInApp = localState.filter((state) => !state.deleted && state.id === appId);
|
|
320
|
-
logger_1.default.log(`[App Id: ${appId}]`, ordersInApp);
|
|
321
|
-
return ordersInApp
|
|
322
|
-
.map(state => {
|
|
323
|
-
const balancesKey = state['key-value'].find((el) => (el.key === "YWNjb3VudEluZm8="));
|
|
324
|
-
const ordersKey = state['key-value'].filter((el) => (el.key !== "YWNjb3VudEluZm8="));
|
|
325
|
-
const decodedBalances = (0, decode_1.getAccounInfoFormLocalStorage)(balancesKey.value.bytes);
|
|
326
|
-
const decodedOrders = ordersKey.map((el) => (0, decode_1.printUnpackedLocalData)(el.value.bytes));
|
|
327
|
-
return decodedOrders.flat(Infinity);
|
|
328
|
-
})
|
|
329
|
-
.flat().filter((o) => o.orderID !== 0);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/***/ }),
|
|
334
|
-
|
|
335
|
-
/***/ 8115:
|
|
336
|
-
/***/ ((module) => {
|
|
337
|
-
|
|
338
|
-
module.exports = require("algosdk");
|
|
339
|
-
|
|
340
|
-
/***/ })
|
|
341
|
-
|
|
342
|
-
/******/ });
|
|
343
|
-
/************************************************************************/
|
|
344
|
-
/******/ // The module cache
|
|
345
|
-
/******/ var __webpack_module_cache__ = {};
|
|
346
|
-
/******/
|
|
347
|
-
/******/ // The require function
|
|
348
|
-
/******/ function __webpack_require__(moduleId) {
|
|
349
|
-
/******/ // Check if module is in cache
|
|
350
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
351
|
-
/******/ if (cachedModule !== undefined) {
|
|
352
|
-
/******/ return cachedModule.exports;
|
|
353
|
-
/******/ }
|
|
354
|
-
/******/ // Create a new module (and put it into the cache)
|
|
355
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
356
|
-
/******/ // no module.id needed
|
|
357
|
-
/******/ // no module.loaded needed
|
|
358
|
-
/******/ exports: {}
|
|
359
|
-
/******/ };
|
|
360
|
-
/******/
|
|
361
|
-
/******/ // Execute the module function
|
|
362
|
-
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
363
|
-
/******/
|
|
364
|
-
/******/ // Return the exports of the module
|
|
365
|
-
/******/ return module.exports;
|
|
366
|
-
/******/ }
|
|
367
|
-
/******/
|
|
368
|
-
/************************************************************************/
|
|
369
|
-
/******/
|
|
370
|
-
/******/ // startup
|
|
371
|
-
/******/ // Load entry module and return exports
|
|
372
|
-
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
373
|
-
/******/ var __webpack_exports__ = __webpack_require__(7413);
|
|
374
|
-
/******/ module.exports = __webpack_exports__;
|
|
375
|
-
/******/
|
|
376
|
-
/******/ })()
|
|
377
|
-
;
|
package/dist/common/logger.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export declare class Logger {
|
|
2
|
-
private _timeLabels;
|
|
3
|
-
private _prefix;
|
|
4
|
-
disabled: boolean;
|
|
5
|
-
constructor(prefix?: string, disabled?: boolean);
|
|
6
|
-
log(...args: any[]): void;
|
|
7
|
-
logWarning(message: string): void;
|
|
8
|
-
getUniqueTimeLabel(label: string): string;
|
|
9
|
-
time(label: string): void;
|
|
10
|
-
timeEnd(label: string): number;
|
|
11
|
-
logRabbit(...args: any[]): void;
|
|
12
|
-
logPair(...args: any[]): void;
|
|
13
|
-
logPairTime(pair: string | number, label?: string): void;
|
|
14
|
-
logPairTimeEnd(pair: string | number, label?: string): void;
|
|
15
|
-
logOrder(...args: any[]): void;
|
|
16
|
-
logOrderTime(id: number, label?: string): void;
|
|
17
|
-
logOrderTimeEnd(id: number, label?: string): void;
|
|
18
|
-
logTrade(...args: any[]): void;
|
|
19
|
-
logCompany(...args: any[]): void;
|
|
20
|
-
logTradeTime(id: number, label?: string): void;
|
|
21
|
-
logTradeTimeEnd(id: number, label?: string): void;
|
|
22
|
-
logOperation(...args: any[]): void;
|
|
23
|
-
logVaa(...args: any[]): void;
|
|
24
|
-
logRequest(event: any, maskFunction?: (path: string, body: any) => any): void;
|
|
25
|
-
private formatArgs;
|
|
26
|
-
private prefixLabel;
|
|
27
|
-
private toYellow;
|
|
28
|
-
private toRed;
|
|
29
|
-
private noColor;
|
|
30
|
-
}
|
|
31
|
-
declare const _default: Logger;
|
|
32
|
-
export default _default;
|
package/dist/common/logger.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
/******/ var __webpack_modules__ = ({
|
|
4
|
-
|
|
5
|
-
/***/ 1708:
|
|
6
|
-
/***/ ((module) => {
|
|
7
|
-
|
|
8
|
-
module.exports = require("node:process");
|
|
9
|
-
|
|
10
|
-
/***/ })
|
|
11
|
-
|
|
12
|
-
/******/ });
|
|
13
|
-
/************************************************************************/
|
|
14
|
-
/******/ // The module cache
|
|
15
|
-
/******/ var __webpack_module_cache__ = {};
|
|
16
|
-
/******/
|
|
17
|
-
/******/ // The require function
|
|
18
|
-
/******/ function __webpack_require__(moduleId) {
|
|
19
|
-
/******/ // Check if module is in cache
|
|
20
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
21
|
-
/******/ if (cachedModule !== undefined) {
|
|
22
|
-
/******/ return cachedModule.exports;
|
|
23
|
-
/******/ }
|
|
24
|
-
/******/ // Create a new module (and put it into the cache)
|
|
25
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
26
|
-
/******/ // no module.id needed
|
|
27
|
-
/******/ // no module.loaded needed
|
|
28
|
-
/******/ exports: {}
|
|
29
|
-
/******/ };
|
|
30
|
-
/******/
|
|
31
|
-
/******/ // Execute the module function
|
|
32
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
33
|
-
/******/
|
|
34
|
-
/******/ // Return the exports of the module
|
|
35
|
-
/******/ return module.exports;
|
|
36
|
-
/******/ }
|
|
37
|
-
/******/
|
|
38
|
-
/************************************************************************/
|
|
39
|
-
var __webpack_exports__ = {};
|
|
40
|
-
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
41
|
-
(() => {
|
|
42
|
-
var exports = __webpack_exports__;
|
|
43
|
-
|
|
44
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
45
|
-
exports.Logger = void 0;
|
|
46
|
-
const node_process_1 = __webpack_require__(1708);
|
|
47
|
-
class Logger {
|
|
48
|
-
_timeLabels = new Map();
|
|
49
|
-
_prefix;
|
|
50
|
-
disabled;
|
|
51
|
-
constructor(prefix, disabled) {
|
|
52
|
-
this._prefix = prefix;
|
|
53
|
-
this.disabled = disabled;
|
|
54
|
-
}
|
|
55
|
-
log(...args) {
|
|
56
|
-
if (this.disabled) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
this._prefix
|
|
61
|
-
? console.log(this.prefixLabel(this._prefix), ...this.formatArgs(args))
|
|
62
|
-
: console.log(...this.formatArgs(args));
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.log('Error on formating args', error);
|
|
66
|
-
console.log('Args =>', ...args);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
logWarning(message) {
|
|
70
|
-
console.log(this.toYellow(message));
|
|
71
|
-
}
|
|
72
|
-
getUniqueTimeLabel(label) {
|
|
73
|
-
const timeLabel = `[${Math.random() * Math.pow(10, 18)}] ${label}`;
|
|
74
|
-
return timeLabel;
|
|
75
|
-
}
|
|
76
|
-
time(label) {
|
|
77
|
-
if (this._timeLabels.has(label)) {
|
|
78
|
-
console.warn(`Label '${label}' already exists for logger.time()`);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const start = node_process_1.hrtime.bigint();
|
|
82
|
-
this._timeLabels.set(label, start);
|
|
83
|
-
}
|
|
84
|
-
timeEnd(label) {
|
|
85
|
-
if (!this._timeLabels.has(label)) {
|
|
86
|
-
console.warn(`Label '${label}' does not exist for logger.time()`);
|
|
87
|
-
return 0;
|
|
88
|
-
}
|
|
89
|
-
const start = this._timeLabels.get(label);
|
|
90
|
-
const end = node_process_1.hrtime.bigint();
|
|
91
|
-
const diff = +(Number(end - start) / 1000000).toFixed(2);
|
|
92
|
-
const color = process.env.LOGGING_OBJECT_INLINE !== "false"
|
|
93
|
-
? this.noColor
|
|
94
|
-
: (diff > 100 ? this.toRed : this.toYellow);
|
|
95
|
-
if (diff > 100 || (label.includes('update24hStat') && diff > 25)) {
|
|
96
|
-
this.log(`Benchmark took ${color(diff)} milliseconds for ${color(label)}`);
|
|
97
|
-
}
|
|
98
|
-
this._timeLabels.delete(label);
|
|
99
|
-
return +diff;
|
|
100
|
-
}
|
|
101
|
-
logRabbit(...args) {
|
|
102
|
-
this.log(...this.formatArgs(["[Rabbit]", ...args]));
|
|
103
|
-
}
|
|
104
|
-
logPair(...args) {
|
|
105
|
-
this.log(...this.formatArgs(args, "Pair"));
|
|
106
|
-
}
|
|
107
|
-
logPairTime(pair, label) {
|
|
108
|
-
this.time(`${this.prefixLabel("Pair", pair)} ${label}`);
|
|
109
|
-
}
|
|
110
|
-
logPairTimeEnd(pair, label) {
|
|
111
|
-
this.timeEnd(`${this.prefixLabel("Pair", pair)} ${label}`);
|
|
112
|
-
}
|
|
113
|
-
logOrder(...args) {
|
|
114
|
-
this.log(...this.formatArgs(args, "OrderID"));
|
|
115
|
-
}
|
|
116
|
-
logOrderTime(id, label) {
|
|
117
|
-
this.time(`${this.prefixLabel("OrderID", id)} ${label}`);
|
|
118
|
-
}
|
|
119
|
-
logOrderTimeEnd(id, label) {
|
|
120
|
-
this.timeEnd(`${this.prefixLabel("OrderID", id)} ${label}`);
|
|
121
|
-
}
|
|
122
|
-
logTrade(...args) {
|
|
123
|
-
this.log(...this.formatArgs(args, "TradeID"));
|
|
124
|
-
}
|
|
125
|
-
logCompany(...args) {
|
|
126
|
-
this.log(...this.formatArgs(args, "CompanyID"));
|
|
127
|
-
}
|
|
128
|
-
logTradeTime(id, label) {
|
|
129
|
-
this.time(`${this.prefixLabel("TradeID", id)} ${label}`);
|
|
130
|
-
}
|
|
131
|
-
logTradeTimeEnd(id, label) {
|
|
132
|
-
this.timeEnd(`${this.prefixLabel("TradeID", id)} ${label}`);
|
|
133
|
-
}
|
|
134
|
-
logOperation(...args) {
|
|
135
|
-
this.log(...this.formatArgs(args, "OperationID"));
|
|
136
|
-
}
|
|
137
|
-
logVaa(...args) {
|
|
138
|
-
this.log(...this.formatArgs(args, "VaaId"));
|
|
139
|
-
}
|
|
140
|
-
logRequest(event, maskFunction = (_, body) => body) {
|
|
141
|
-
const { httpMethod, path, queryStringParameters, body } = event;
|
|
142
|
-
this.log(httpMethod, path, { queryStringParameters, body: maskFunction(path, body) });
|
|
143
|
-
}
|
|
144
|
-
formatArgs(args, prefix = null) {
|
|
145
|
-
return args.map((value, index) => {
|
|
146
|
-
if (index === 0 && typeof value === "string" && prefix === "Pair") {
|
|
147
|
-
return `[${value}]`;
|
|
148
|
-
}
|
|
149
|
-
if (index === 0 && !!prefix) {
|
|
150
|
-
return this.prefixLabel(prefix, typeof value === "object" ? JSON.stringify(value) : value);
|
|
151
|
-
}
|
|
152
|
-
if (typeof value === "object" && process.env.LOGGING_OBJECT_INLINE !== "false") {
|
|
153
|
-
return JSON.stringify(value);
|
|
154
|
-
}
|
|
155
|
-
return value;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
prefixLabel(prefix, value) {
|
|
159
|
-
return value ? `[${prefix}: ${value}]` : `[${prefix}]`;
|
|
160
|
-
}
|
|
161
|
-
toYellow(value) {
|
|
162
|
-
return `\x1b[33m${value}\x1b[0m`;
|
|
163
|
-
}
|
|
164
|
-
toRed(value) {
|
|
165
|
-
return `\x1b[31m${value}\x1b[0m`;
|
|
166
|
-
}
|
|
167
|
-
noColor(value) {
|
|
168
|
-
return value;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.Logger = Logger;
|
|
172
|
-
exports["default"] = new Logger();
|
|
173
|
-
|
|
174
|
-
})();
|
|
175
|
-
|
|
176
|
-
module.exports = __webpack_exports__;
|
|
177
|
-
/******/ })()
|
|
178
|
-
;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { QueryRunner } from "typeorm";
|
|
2
|
-
export declare function dropIndexIfExists(queryRunner: QueryRunner, tableName: string, indexName: string): Promise<void>;
|
|
3
|
-
export declare function createIndexIfNotExists(queryRunner: QueryRunner, tableName: string, indexName: string, cols: string): Promise<void>;
|
|
4
|
-
export declare function checkIfExists(queryRunner: QueryRunner, tableName: string, indexName: string): Promise<boolean>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
var __webpack_exports__ = {};
|
|
4
|
-
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
5
|
-
(() => {
|
|
6
|
-
var exports = __webpack_exports__;
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9
|
-
exports.dropIndexIfExists = dropIndexIfExists;
|
|
10
|
-
exports.createIndexIfNotExists = createIndexIfNotExists;
|
|
11
|
-
exports.checkIfExists = checkIfExists;
|
|
12
|
-
async function dropIndexIfExists(queryRunner, tableName, indexName) {
|
|
13
|
-
if (await checkIfExists(queryRunner, tableName, indexName)) {
|
|
14
|
-
await queryRunner.query(`ALTER TABLE \`${tableName}\` DROP index \`${indexName}\``);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async function createIndexIfNotExists(queryRunner, tableName, indexName, cols) {
|
|
18
|
-
if (!(await checkIfExists(queryRunner, tableName, indexName))) {
|
|
19
|
-
await queryRunner.query(`CREATE INDEX \`${indexName}\` ON \`${tableName}\` (${cols});`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
async function checkIfExists(queryRunner, tableName, indexName) {
|
|
23
|
-
let result = await queryRunner.query(`SELECT EXISTS(SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = '${tableName}'
|
|
24
|
-
AND INDEX_NAME = '${indexName}' AND INDEX_SCHEMA='order_service') as existed`);
|
|
25
|
-
console.log(result);
|
|
26
|
-
return result.length > 0 && result[0].existed == 1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
})();
|
|
30
|
-
|
|
31
|
-
module.exports = __webpack_exports__;
|
|
32
|
-
/******/ })()
|
|
33
|
-
;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Redis from 'ioredis';
|
|
2
|
-
declare class RedisHelper {
|
|
3
|
-
private host;
|
|
4
|
-
private port;
|
|
5
|
-
client: Redis;
|
|
6
|
-
private operationQueue;
|
|
7
|
-
private runningOperations;
|
|
8
|
-
constructor();
|
|
9
|
-
private performPendingOperations;
|
|
10
|
-
setString(key: string, value: string, expires?: number, database?: string): Promise<void>;
|
|
11
|
-
incrementKey(key: string, expires?: number, database?: string): Promise<void>;
|
|
12
|
-
scanKeys(pattern: string, database?: string): Promise<string[]>;
|
|
13
|
-
getString(key: string, database?: string): Promise<string | null>;
|
|
14
|
-
deleteString(key: string, database?: string): Promise<void>;
|
|
15
|
-
deleteByKeyPattern(pattern: string, database?: string): Promise<void>;
|
|
16
|
-
destroyDb(dbKey: string): Promise<boolean>;
|
|
17
|
-
private performOperation;
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
createStream(key: string): Promise<void>;
|
|
20
|
-
writeToStream(key: string, message: object): Promise<void>;
|
|
21
|
-
readStream<T>(key: string, timeout: number): Promise<T>;
|
|
22
|
-
deleteStream(key: string): Promise<void>;
|
|
23
|
-
setTTL(key: string, ttlSeconds: number): Promise<void>;
|
|
24
|
-
streamExists(key: string): Promise<boolean>;
|
|
25
|
-
}
|
|
26
|
-
declare const _default: RedisHelper;
|
|
27
|
-
export default _default;
|