@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,11 +1,6 @@
1
1
  export * from './mappers';
2
2
  export * from './utils';
3
3
  export * from './auth.helper';
4
- export * from './awsKms';
5
4
  export * from './big-number.helper';
6
- export * from './indexer.helper';
7
- export * from './logger';
8
- export * from './migration.helpers';
9
- export * from './redis.helper';
10
5
  export * from './secret.helper';
11
6
  export * from './timestamp.helper';
@@ -49,150 +49,6 @@ function mapToCodexAssetDto(o, isArchived) {
49
49
  }
50
50
 
51
51
 
52
- /***/ }),
53
-
54
- /***/ 298:
55
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
56
-
57
-
58
- Object.defineProperty(exports, "__esModule", ({ value: true }));
59
- exports.Logger = void 0;
60
- const node_process_1 = __webpack_require__(1708);
61
- class Logger {
62
- _timeLabels = new Map();
63
- _prefix;
64
- disabled;
65
- constructor(prefix, disabled) {
66
- this._prefix = prefix;
67
- this.disabled = disabled;
68
- }
69
- log(...args) {
70
- if (this.disabled) {
71
- return;
72
- }
73
- try {
74
- this._prefix
75
- ? console.log(this.prefixLabel(this._prefix), ...this.formatArgs(args))
76
- : console.log(...this.formatArgs(args));
77
- }
78
- catch (error) {
79
- console.log('Error on formating args', error);
80
- console.log('Args =>', ...args);
81
- }
82
- }
83
- logWarning(message) {
84
- console.log(this.toYellow(message));
85
- }
86
- getUniqueTimeLabel(label) {
87
- const timeLabel = `[${Math.random() * Math.pow(10, 18)}] ${label}`;
88
- return timeLabel;
89
- }
90
- time(label) {
91
- if (this._timeLabels.has(label)) {
92
- console.warn(`Label '${label}' already exists for logger.time()`);
93
- return;
94
- }
95
- const start = node_process_1.hrtime.bigint();
96
- this._timeLabels.set(label, start);
97
- }
98
- timeEnd(label) {
99
- if (!this._timeLabels.has(label)) {
100
- console.warn(`Label '${label}' does not exist for logger.time()`);
101
- return 0;
102
- }
103
- const start = this._timeLabels.get(label);
104
- const end = node_process_1.hrtime.bigint();
105
- const diff = +(Number(end - start) / 1000000).toFixed(2);
106
- const color = process.env.LOGGING_OBJECT_INLINE !== "false"
107
- ? this.noColor
108
- : (diff > 100 ? this.toRed : this.toYellow);
109
- if (diff > 100 || (label.includes('update24hStat') && diff > 25)) {
110
- this.log(`Benchmark took ${color(diff)} milliseconds for ${color(label)}`);
111
- }
112
- this._timeLabels.delete(label);
113
- return +diff;
114
- }
115
- logRabbit(...args) {
116
- this.log(...this.formatArgs(["[Rabbit]", ...args]));
117
- }
118
- logPair(...args) {
119
- this.log(...this.formatArgs(args, "Pair"));
120
- }
121
- logPairTime(pair, label) {
122
- this.time(`${this.prefixLabel("Pair", pair)} ${label}`);
123
- }
124
- logPairTimeEnd(pair, label) {
125
- this.timeEnd(`${this.prefixLabel("Pair", pair)} ${label}`);
126
- }
127
- logOrder(...args) {
128
- this.log(...this.formatArgs(args, "OrderID"));
129
- }
130
- logOrderTime(id, label) {
131
- this.time(`${this.prefixLabel("OrderID", id)} ${label}`);
132
- }
133
- logOrderTimeEnd(id, label) {
134
- this.timeEnd(`${this.prefixLabel("OrderID", id)} ${label}`);
135
- }
136
- logTrade(...args) {
137
- this.log(...this.formatArgs(args, "TradeID"));
138
- }
139
- logCompany(...args) {
140
- this.log(...this.formatArgs(args, "CompanyID"));
141
- }
142
- logTradeTime(id, label) {
143
- this.time(`${this.prefixLabel("TradeID", id)} ${label}`);
144
- }
145
- logTradeTimeEnd(id, label) {
146
- this.timeEnd(`${this.prefixLabel("TradeID", id)} ${label}`);
147
- }
148
- logOperation(...args) {
149
- this.log(...this.formatArgs(args, "OperationID"));
150
- }
151
- logVaa(...args) {
152
- this.log(...this.formatArgs(args, "VaaId"));
153
- }
154
- logRequest(event, maskFunction = (_, body) => body) {
155
- const { httpMethod, path, queryStringParameters, body } = event;
156
- this.log(httpMethod, path, { queryStringParameters, body: maskFunction(path, body) });
157
- }
158
- formatArgs(args, prefix = null) {
159
- return args.map((value, index) => {
160
- if (index === 0 && typeof value === "string" && prefix === "Pair") {
161
- return `[${value}]`;
162
- }
163
- if (index === 0 && !!prefix) {
164
- return this.prefixLabel(prefix, typeof value === "object" ? JSON.stringify(value) : value);
165
- }
166
- if (typeof value === "object" && process.env.LOGGING_OBJECT_INLINE !== "false") {
167
- return JSON.stringify(value);
168
- }
169
- return value;
170
- });
171
- }
172
- prefixLabel(prefix, value) {
173
- return value ? `[${prefix}: ${value}]` : `[${prefix}]`;
174
- }
175
- toYellow(value) {
176
- return `\x1b[33m${value}\x1b[0m`;
177
- }
178
- toRed(value) {
179
- return `\x1b[31m${value}\x1b[0m`;
180
- }
181
- noColor(value) {
182
- return value;
183
- }
184
- }
185
- exports.Logger = Logger;
186
- exports["default"] = new Logger();
187
-
188
-
189
- /***/ }),
190
-
191
- /***/ 657:
192
- /***/ ((module) => {
193
-
194
- module.exports = require("ioredis");
195
-
196
52
  /***/ }),
197
53
 
198
54
  /***/ 696:
@@ -624,13 +480,6 @@ var SettingTypeColumn;
624
480
  })(SettingTypeColumn || (exports.SettingTypeColumn = SettingTypeColumn = {}));
625
481
 
626
482
 
627
- /***/ }),
628
-
629
- /***/ 1708:
630
- /***/ ((module) => {
631
-
632
- module.exports = require("node:process");
633
-
634
483
  /***/ }),
635
484
 
636
485
  /***/ 2137:
@@ -1168,154 +1017,6 @@ var TweetType;
1168
1017
  })(TweetType || (exports.TweetType = TweetType = {}));
1169
1018
 
1170
1019
 
1171
- /***/ }),
1172
-
1173
- /***/ 3450:
1174
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1175
-
1176
-
1177
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1178
- if (k2 === undefined) k2 = k;
1179
- var desc = Object.getOwnPropertyDescriptor(m, k);
1180
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1181
- desc = { enumerable: true, get: function() { return m[k]; } };
1182
- }
1183
- Object.defineProperty(o, k2, desc);
1184
- }) : (function(o, m, k, k2) {
1185
- if (k2 === undefined) k2 = k;
1186
- o[k2] = m[k];
1187
- }));
1188
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
1189
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1190
- }) : function(o, v) {
1191
- o["default"] = v;
1192
- });
1193
- var __importStar = (this && this.__importStar) || (function () {
1194
- var ownKeys = function(o) {
1195
- ownKeys = Object.getOwnPropertyNames || function (o) {
1196
- var ar = [];
1197
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
1198
- return ar;
1199
- };
1200
- return ownKeys(o);
1201
- };
1202
- return function (mod) {
1203
- if (mod && mod.__esModule) return mod;
1204
- var result = {};
1205
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1206
- __setModuleDefault(result, mod);
1207
- return result;
1208
- };
1209
- })();
1210
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1211
- exports.printUnpackedLocalData = exports.getAccounInfoFormLocalStorage = void 0;
1212
- exports.unpackData = unpackData;
1213
- exports.decodeString = decodeString;
1214
- const algosdk_1 = __importStar(__webpack_require__(8115));
1215
- const orderByteSize = 28;
1216
- const getAccounInfoFormLocalStorage = (localState) => {
1217
- const uintArray = Buffer.from(localState, 'base64');
1218
- const unpackedData = unpackData(uintArray, {
1219
- "priceCoin_locked": {
1220
- type: "uint",
1221
- },
1222
- "priceCoin_available": {
1223
- type: "uint",
1224
- },
1225
- "baseCoin_locked": {
1226
- type: "uint",
1227
- },
1228
- "baseCoin_available": {
1229
- type: "uint",
1230
- },
1231
- "companyId": {
1232
- type: "uint",
1233
- },
1234
- "WLFeeShare": {
1235
- type: "uint",
1236
- },
1237
- "WLCustomFee": {
1238
- type: "uint",
1239
- },
1240
- "slotMap": {
1241
- type: "uint",
1242
- },
1243
- });
1244
- return unpackedData;
1245
- };
1246
- exports.getAccounInfoFormLocalStorage = getAccounInfoFormLocalStorage;
1247
- function unpackData(data, format) {
1248
- const result = new Map();
1249
- let index = 0;
1250
- for (const [name, type] of Object.entries(format)) {
1251
- if (index >= data.length) {
1252
- throw new Error('Array index out of bounds');
1253
- }
1254
- let value;
1255
- switch (type.type) {
1256
- case 'address':
1257
- value = (0, algosdk_1.encodeAddress)(data.slice(index, index + 32));
1258
- index += 32;
1259
- break;
1260
- case 'bytes':
1261
- value = data.slice(index, index + type.size);
1262
- value = algosdk_1.default.decodeUint64(value, "mixed");
1263
- index += type.size;
1264
- break;
1265
- case 'uint':
1266
- value = algosdk_1.default.decodeUint64(data.slice(index, index + 8), "mixed");
1267
- index += 8;
1268
- break;
1269
- case 'string':
1270
- value = decodeString(data.slice(index, index + type.size));
1271
- index += type.size;
1272
- break;
1273
- }
1274
- result.set(name, value);
1275
- }
1276
- return Object.fromEntries(result);
1277
- }
1278
- function decodeString(value) {
1279
- return Buffer.from(value).toString('utf-8');
1280
- }
1281
- const printUnpackedLocalData = (localState) => {
1282
- const uintArray = Buffer.from(localState, 'base64');
1283
- const unpackedData = [];
1284
- for (let i = 0; i < 4; i++) {
1285
- let data = unpackData(uintArray.subarray(orderByteSize * i, orderByteSize * (i + 1)), {
1286
- "orderID": {
1287
- type: "uint",
1288
- },
1289
- "side": {
1290
- type: "string",
1291
- size: 1
1292
- },
1293
- "price": {
1294
- type: "uint",
1295
- },
1296
- "amount": {
1297
- type: "uint",
1298
- },
1299
- "type": {
1300
- type: "string",
1301
- size: 1
1302
- },
1303
- "directSettle": {
1304
- type: "string",
1305
- size: 1
1306
- },
1307
- "storageSlot": {
1308
- type: "bytes",
1309
- size: 1
1310
- }
1311
- });
1312
- unpackedData.push(data);
1313
- }
1314
- return unpackedData;
1315
- };
1316
- exports.printUnpackedLocalData = printUnpackedLocalData;
1317
-
1318
-
1319
1020
  /***/ }),
1320
1021
 
1321
1022
  /***/ 3487:
@@ -1370,23 +1071,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1370
1071
  __exportStar(__webpack_require__(9321), exports);
1371
1072
  __exportStar(__webpack_require__(8398), exports);
1372
1073
  __exportStar(__webpack_require__(696), exports);
1373
- __exportStar(__webpack_require__(8980), exports);
1374
1074
  __exportStar(__webpack_require__(1174), exports);
1375
- __exportStar(__webpack_require__(7413), exports);
1376
- __exportStar(__webpack_require__(298), exports);
1377
- __exportStar(__webpack_require__(7639), exports);
1378
- __exportStar(__webpack_require__(5281), exports);
1379
1075
  __exportStar(__webpack_require__(3298), exports);
1380
1076
  __exportStar(__webpack_require__(180), exports);
1381
1077
 
1382
1078
 
1383
- /***/ }),
1384
-
1385
- /***/ 3780:
1386
- /***/ ((module) => {
1387
-
1388
- module.exports = require("@aws-sdk/client-kms");
1389
-
1390
1079
  /***/ }),
1391
1080
 
1392
1081
  /***/ 3854:
@@ -1503,208 +1192,6 @@ var UpgradeStatus;
1503
1192
  })(UpgradeStatus || (exports.UpgradeStatus = UpgradeStatus = {}));
1504
1193
 
1505
1194
 
1506
- /***/ }),
1507
-
1508
- /***/ 5281:
1509
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1510
-
1511
-
1512
- var __importDefault = (this && this.__importDefault) || function (mod) {
1513
- return (mod && mod.__esModule) ? mod : { "default": mod };
1514
- };
1515
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1516
- const ioredis_1 = __importDefault(__webpack_require__(657));
1517
- class RedisHelper {
1518
- host = process.env.REDIS_HOSTNAME;
1519
- port = process.env.REDIS_PORT;
1520
- client = new ioredis_1.default({
1521
- host: this.host,
1522
- port: Number(this.port),
1523
- lazyConnect: true,
1524
- });
1525
- operationQueue = [];
1526
- runningOperations = false;
1527
- constructor() {
1528
- this.client.on('connect', () => {
1529
- });
1530
- this.client.on('ready', () => {
1531
- this.performPendingOperations();
1532
- });
1533
- this.client.on('error', (err) => {
1534
- console.error('Redis error:', err.message);
1535
- });
1536
- this.client.on('close', () => {
1537
- console.log('Redis connection closed');
1538
- });
1539
- }
1540
- async performPendingOperations() {
1541
- this.runningOperations = true;
1542
- while (this.operationQueue.length > 0) {
1543
- const operation = this.operationQueue.shift();
1544
- if (operation) {
1545
- try {
1546
- await operation();
1547
- }
1548
- catch (err) {
1549
- console.error('Error performing Redis operation:', err);
1550
- }
1551
- }
1552
- }
1553
- this.runningOperations = false;
1554
- }
1555
- async setString(key, value, expires = 0, database = '') {
1556
- const operation = async () => {
1557
- if (database !== '') {
1558
- this.client.select(Number(database));
1559
- }
1560
- await this.client.set(key, value);
1561
- if (expires !== 0) {
1562
- await this.client.expire(key, expires * 60);
1563
- }
1564
- };
1565
- await this.performOperation(operation);
1566
- }
1567
- async incrementKey(key, expires = 0, database = '') {
1568
- const operation = async () => {
1569
- if (database !== '') {
1570
- this.client.select(Number(database));
1571
- }
1572
- await this.client.incr(key);
1573
- if (expires !== 0) {
1574
- const ttl = await this.client.ttl(key);
1575
- if (ttl === -1) {
1576
- await this.client.expire(key, expires * 60);
1577
- }
1578
- }
1579
- };
1580
- await this.performOperation(operation);
1581
- }
1582
- async scanKeys(pattern, database = '') {
1583
- const matchedKeys = [];
1584
- const operation = async () => {
1585
- if (database !== '') {
1586
- this.client.select(Number(database));
1587
- }
1588
- let cursor = '0';
1589
- do {
1590
- const [nextCursor, keys] = await this.client.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
1591
- cursor = nextCursor;
1592
- matchedKeys.push(...keys);
1593
- } while (cursor !== '0');
1594
- };
1595
- await this.performOperation(operation);
1596
- return matchedKeys;
1597
- }
1598
- getString(key, database = '') {
1599
- return new Promise(async (resolve, reject) => {
1600
- const operation = async () => {
1601
- try {
1602
- if (database !== '') {
1603
- await this.client.select(Number(database));
1604
- }
1605
- const value = await this.client.get(key);
1606
- resolve(value);
1607
- }
1608
- catch (err) {
1609
- reject(err);
1610
- }
1611
- };
1612
- this.performOperation(operation);
1613
- });
1614
- }
1615
- async deleteString(key, database = '') {
1616
- const operation = async () => {
1617
- if (database !== '') {
1618
- this.client.select(Number(database));
1619
- }
1620
- await this.client.del(key);
1621
- };
1622
- await this.performOperation(operation);
1623
- }
1624
- async deleteByKeyPattern(pattern, database = '') {
1625
- const operation = async () => {
1626
- if (database !== '') {
1627
- this.client.select(Number(database));
1628
- }
1629
- const keys = await this.client.keys(pattern);
1630
- if (keys.length > 0) {
1631
- await this.client.unlink(keys);
1632
- console.log(`Deleted ${keys.length} keys`);
1633
- }
1634
- else {
1635
- console.log('No keys for delete');
1636
- }
1637
- };
1638
- await this.performOperation(operation);
1639
- }
1640
- async destroyDb(dbKey) {
1641
- const response = await this.client.del(dbKey);
1642
- return response === 1;
1643
- }
1644
- async performOperation(operation) {
1645
- this.operationQueue.push(operation);
1646
- if (!this.runningOperations) {
1647
- try {
1648
- await this.performPendingOperations();
1649
- }
1650
- catch (error) {
1651
- console.error('Error during performing Redis operation', error);
1652
- }
1653
- }
1654
- }
1655
- async close() {
1656
- console.log('Closing Redis client for graceful shutdown...');
1657
- try {
1658
- while (this.operationQueue.length > 0 || this.runningOperations) {
1659
- await new Promise((resolve) => setTimeout(resolve, 100));
1660
- }
1661
- await this.client.quit();
1662
- console.log('Redis client closed successfully');
1663
- }
1664
- catch (error) {
1665
- console.error('Error during Redis client shutdown:', error);
1666
- }
1667
- }
1668
- async createStream(key) {
1669
- await this.client.xgroup('CREATE', key, 'group', '$', 'MKSTREAM');
1670
- }
1671
- async writeToStream(key, message) {
1672
- try {
1673
- if (await this.streamExists(key)) {
1674
- await this.client.xadd(key, '*', 'message', JSON.stringify(message));
1675
- }
1676
- }
1677
- catch (error) {
1678
- console.log(`[Stream '${key}']`, 'Error while writing to stream', error);
1679
- }
1680
- }
1681
- async readStream(key, timeout) {
1682
- const results = await this.client.xreadgroup('GROUP', 'group', 'consumer', 'COUNT', 1, 'BLOCK', timeout * 1000, 'STREAMS', key, '>');
1683
- if (results && results.length > 0) {
1684
- const [, entries] = results[0];
1685
- if (entries && entries.length > 0) {
1686
- const [, [, message]] = entries[0];
1687
- return JSON.parse(message);
1688
- }
1689
- }
1690
- return null;
1691
- }
1692
- async deleteStream(key) {
1693
- if (await this.streamExists(key)) {
1694
- await this.client.del(key);
1695
- }
1696
- }
1697
- async setTTL(key, ttlSeconds) {
1698
- await this.client.expire(key, ttlSeconds);
1699
- }
1700
- async streamExists(key) {
1701
- const exists = await this.client.exists(key);
1702
- return exists === 1;
1703
- }
1704
- }
1705
- exports["default"] = new RedisHelper();
1706
-
1707
-
1708
1195
  /***/ }),
1709
1196
 
1710
1197
  /***/ 5320:
@@ -1853,44 +1340,6 @@ var MaintenanceMode;
1853
1340
  })(MaintenanceMode || (exports.MaintenanceMode = MaintenanceMode = {}));
1854
1341
 
1855
1342
 
1856
- /***/ }),
1857
-
1858
- /***/ 7413:
1859
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1860
-
1861
-
1862
- var __importDefault = (this && this.__importDefault) || function (mod) {
1863
- return (mod && mod.__esModule) ? mod : { "default": mod };
1864
- };
1865
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1866
- exports.extractAppOrders = extractAppOrders;
1867
- const decode_1 = __webpack_require__(3450);
1868
- const logger_1 = __importDefault(__webpack_require__(298));
1869
- function extractAppOrders(account, appId) {
1870
- logger_1.default.log('accountInfo', account);
1871
- if (!account?.hasOwnProperty('apps-local-state')) {
1872
- logger_1.default.log(`No apps-local-state at account`, account);
1873
- return [];
1874
- }
1875
- let localState = account['apps-local-state'];
1876
- if (!localState?.length) {
1877
- logger_1.default.log('apps-local-state', localState);
1878
- return [];
1879
- }
1880
- const ordersInApp = localState.filter((state) => !state.deleted && state.id === appId);
1881
- logger_1.default.log(`[App Id: ${appId}]`, ordersInApp);
1882
- return ordersInApp
1883
- .map(state => {
1884
- const balancesKey = state['key-value'].find((el) => (el.key === "YWNjb3VudEluZm8="));
1885
- const ordersKey = state['key-value'].filter((el) => (el.key !== "YWNjb3VudEluZm8="));
1886
- const decodedBalances = (0, decode_1.getAccounInfoFormLocalStorage)(balancesKey.value.bytes);
1887
- const decodedOrders = ordersKey.map((el) => (0, decode_1.printUnpackedLocalData)(el.value.bytes));
1888
- return decodedOrders.flat(Infinity);
1889
- })
1890
- .flat().filter((o) => o.orderID !== 0);
1891
- }
1892
-
1893
-
1894
1343
  /***/ }),
1895
1344
 
1896
1345
  /***/ 7542:
@@ -1950,34 +1399,6 @@ function mapOrderTypeShortToLong(value) {
1950
1399
  }
1951
1400
 
1952
1401
 
1953
- /***/ }),
1954
-
1955
- /***/ 7639:
1956
- /***/ ((__unused_webpack_module, exports) => {
1957
-
1958
-
1959
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1960
- exports.dropIndexIfExists = dropIndexIfExists;
1961
- exports.createIndexIfNotExists = createIndexIfNotExists;
1962
- exports.checkIfExists = checkIfExists;
1963
- async function dropIndexIfExists(queryRunner, tableName, indexName) {
1964
- if (await checkIfExists(queryRunner, tableName, indexName)) {
1965
- await queryRunner.query(`ALTER TABLE \`${tableName}\` DROP index \`${indexName}\``);
1966
- }
1967
- }
1968
- async function createIndexIfNotExists(queryRunner, tableName, indexName, cols) {
1969
- if (!(await checkIfExists(queryRunner, tableName, indexName))) {
1970
- await queryRunner.query(`CREATE INDEX \`${indexName}\` ON \`${tableName}\` (${cols});`);
1971
- }
1972
- }
1973
- async function checkIfExists(queryRunner, tableName, indexName) {
1974
- let result = await queryRunner.query(`SELECT EXISTS(SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = '${tableName}'
1975
- AND INDEX_NAME = '${indexName}' AND INDEX_SCHEMA='order_service') as existed`);
1976
- console.log(result);
1977
- return result.length > 0 && result[0].existed == 1;
1978
- }
1979
-
1980
-
1981
1402
  /***/ }),
1982
1403
 
1983
1404
  /***/ 8115:
@@ -2334,70 +1755,6 @@ Object.defineProperty(exports, "encodeAddress", ({ enumerable: true, get: functi
2334
1755
  Object.defineProperty(exports, "decodeAddress", ({ enumerable: true, get: function () { return algosdk_2.decodeAddress; } }));
2335
1756
 
2336
1757
 
2337
- /***/ }),
2338
-
2339
- /***/ 8980:
2340
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2341
-
2342
-
2343
- var __importDefault = (this && this.__importDefault) || function (mod) {
2344
- return (mod && mod.__esModule) ? mod : { "default": mod };
2345
- };
2346
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2347
- exports.decrypt = exports.encrypt = void 0;
2348
- const client_kms_1 = __webpack_require__(3780);
2349
- const logger_1 = __importDefault(__webpack_require__(298));
2350
- const encrypt = async (string) => {
2351
- if (process.env.ENVIRONMENT === 'LOCAL') {
2352
- logger_1.default.logWarning('WARNING: AWS KMS encryption is bypassed in local environment.');
2353
- return string;
2354
- }
2355
- const input = {
2356
- KeyId: process.env.SOCIAL_SECRET_KEY_ID,
2357
- Plaintext: Buffer.from(string),
2358
- };
2359
- const command = new client_kms_1.EncryptCommand(input);
2360
- const result = await sendKmsCommand(command);
2361
- return Buffer.from(result.CiphertextBlob).toString('base64');
2362
- };
2363
- exports.encrypt = encrypt;
2364
- const decrypt = async (encryptedString) => {
2365
- if (process.env.ENVIRONMENT === 'LOCAL') {
2366
- logger_1.default.logWarning('WARNING: AWS KMS decryption is bypassed in local environment.');
2367
- return encryptedString;
2368
- }
2369
- const input = {
2370
- KeyId: process.env.SOCIAL_SECRET_KEY_ID,
2371
- CiphertextBlob: Buffer.from(encryptedString, 'base64'),
2372
- };
2373
- const command = new client_kms_1.DecryptCommand(input);
2374
- const result = await sendKmsCommand(command);
2375
- return new TextDecoder().decode(result.Plaintext);
2376
- };
2377
- exports.decrypt = decrypt;
2378
- const sendKmsCommand = async (command) => {
2379
- return new Promise((resolve, reject) => {
2380
- try {
2381
- const client = new client_kms_1.KMSClient({ region: 'us-east-1' });
2382
- client.send(command, (err, data) => {
2383
- if (err) {
2384
- console.log('-----error in KMS operation---------', err);
2385
- reject(err);
2386
- }
2387
- else {
2388
- console.log('KMS command was successfully sent');
2389
- resolve(data);
2390
- }
2391
- });
2392
- }
2393
- catch (error) {
2394
- console.log('KMSClient error', error);
2395
- reject(error);
2396
- }
2397
- });
2398
- };
2399
-
2400
-
2401
1758
  /***/ }),
2402
1759
 
2403
1760
  /***/ 9321: