@ultrade/shared 1.0.0 → 1.0.2

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 (58) hide show
  1. package/dist/common/auth.helper.js +16 -37
  2. package/dist/common/awsKms.js +9 -19
  3. package/dist/common/big-number.helper.d.ts +0 -3
  4. package/dist/common/big-number.helper.js +7 -26
  5. package/dist/common/index.js +65 -107
  6. package/dist/common/indexer.helper.js +9 -19
  7. package/dist/common/logger.js +6 -16
  8. package/dist/common/mappers/codexAsset.mapper.js +3 -14
  9. package/dist/common/mappers/codexBalance.mapper.js +3 -14
  10. package/dist/common/mappers/index.js +15 -35
  11. package/dist/common/mappers/trade.mapper.js +15 -35
  12. package/dist/common/migration.helpers.js +3 -14
  13. package/dist/common/redis.helper.js +20 -40
  14. package/dist/common/secret.helper.js +11 -26
  15. package/dist/common/timestamp.helper.js +3 -14
  16. package/dist/common/utils/assert.js +3 -14
  17. package/dist/common/utils/decode.js +6 -17
  18. package/dist/common/utils/index.js +4 -15
  19. package/dist/common/utils/social.js +3 -14
  20. package/dist/common/utils/stat.js +7 -26
  21. package/dist/constants/index.js +3 -14
  22. package/dist/enums/index.js +3 -14
  23. package/dist/helpers/Encoding.js +10 -31
  24. package/dist/helpers/algo.helper.js +44 -82
  25. package/dist/helpers/assert.helper.js +13 -34
  26. package/dist/helpers/atomic.helper.d.ts +0 -17
  27. package/dist/helpers/atomic.helper.js +7 -43
  28. package/dist/helpers/balance.helper.js +71 -166
  29. package/dist/helpers/codex/common.helper.js +71 -149
  30. package/dist/helpers/codex/index.js +71 -149
  31. package/dist/helpers/codex/mbr.helper.js +71 -149
  32. package/dist/helpers/codex/mna.helper.js +71 -149
  33. package/dist/helpers/codex/order.helper.js +71 -149
  34. package/dist/helpers/codex/setGlobal.helper.js +73 -151
  35. package/dist/helpers/codex/transfer.helper.js +71 -149
  36. package/dist/helpers/codex/txn.helper.js +71 -149
  37. package/dist/helpers/codex.helper.js +71 -149
  38. package/dist/helpers/email.helper.js +6 -17
  39. package/dist/helpers/eth.helper.js +71 -149
  40. package/dist/helpers/hummingbots.helper.js +11 -22
  41. package/dist/helpers/index.js +31 -58
  42. package/dist/helpers/interval.helpers.js +10 -21
  43. package/dist/helpers/liquidity.helper.js +6 -17
  44. package/dist/helpers/order.helper.js +3 -14
  45. package/dist/helpers/pair.helper.js +3 -14
  46. package/dist/helpers/pointSystem.helper.js +15 -33
  47. package/dist/helpers/ticker.helpers.js +7 -27
  48. package/dist/helpers/vaa.helper.js +97 -175
  49. package/dist/helpers/withdraw.helper.js +97 -167
  50. package/dist/interfaces/db/market/index.d.ts +34 -6
  51. package/dist/interfaces/db/white_label/index.d.ts +3 -3
  52. package/dist/interfaces/index.js +11 -14
  53. package/dist/types/index.js +15 -33
  54. package/package.json +16 -8
  55. package/dist/baseModel/base.model.d.ts +0 -26
  56. package/dist/baseModel/index.d.ts +0 -2
  57. package/dist/helpers/api.helper.d.ts +0 -16
  58. package/dist/helpers/api.helper.js +0 -1652
@@ -1,24 +1,7 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("buffer"), require("ethereumjs-util"), require("bs58"), require("bignumber.js"), require("algosdk"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["buffer", "ethereumjs-util", "bs58", "bignumber.js", "algosdk"], factory);
6
- else {
7
- var a = typeof exports === 'object' ? factory(require("buffer"), require("ethereumjs-util"), require("bs58"), require("bignumber.js"), require("algosdk")) : factory(root["buffer"], root["ethereumjs-util"], root["bs58"], root["bignumber.js"], root["algosdk"]);
8
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
- }
10
- })(global, (__WEBPACK_EXTERNAL_MODULE__18__, __WEBPACK_EXTERNAL_MODULE__1297__, __WEBPACK_EXTERNAL_MODULE__4578__, __WEBPACK_EXTERNAL_MODULE__6168__, __WEBPACK_EXTERNAL_MODULE__9709__) => {
11
- return /******/ (() => { // webpackBootstrap
1
+ /******/ (() => { // webpackBootstrap
12
2
  /******/ "use strict";
13
3
  /******/ var __webpack_modules__ = ({
14
4
 
15
- /***/ 18:
16
- /***/ ((module) => {
17
-
18
- module.exports = __WEBPACK_EXTERNAL_MODULE__18__;
19
-
20
- /***/ }),
21
-
22
5
  /***/ 223:
23
6
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
24
7
 
@@ -63,8 +46,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
63
46
  exports.unified_CCTP_ChainID = exports.unified_CCTP_token = exports.encodeAddress = exports.getProviderChainId = exports.getPrefixedMessage = exports.getPublicKey = exports.decodeSignature = exports.getMsgArgs = exports.getDataBytesFromMsg = exports.getAppArgs = exports.getBoxKeyFromHash = exports.getBoxKey = exports.generateHash = void 0;
64
47
  exports.getUnifiedUSDC = getUnifiedUSDC;
65
48
  exports.getUnifiedUSDCToken = getUnifiedUSDCToken;
66
- const algosdk_1 = __importDefault(__webpack_require__(9709));
67
- const bs58 = __importStar(__webpack_require__(4578));
49
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
50
+ const bs58 = __importStar(__webpack_require__(5316));
68
51
  const algoHelper = __importStar(__webpack_require__(6897));
69
52
  const ethHelper = __importStar(__webpack_require__(9019));
70
53
  const codex_helper_1 = __webpack_require__(3955);
@@ -100,8 +83,6 @@ const getAppArgs = (methodSignature, args) => {
100
83
  txnArgsLog[`txnArgs${index}`] = Array.apply([], Array.from(v)).join(", ");
101
84
  return v;
102
85
  });
103
- // console.log('getAppArgs', methodSignature, JSON.stringify(txnArgsLog));
104
- // console.log('TOTAL TXN ARGS BYTES', txnArgs.reduce((prev, curr: Uint8Array | Buffer) => curr.length + prev, 0));
105
86
  return [selector, ...txnArgs];
106
87
  };
107
88
  exports.getAppArgs = getAppArgs;
@@ -119,7 +100,6 @@ const getMsgArgs = (message, signature, signerAddress, signerChainId, encoding =
119
100
  (0, exports.decodeSignature)(signature, signerChainId),
120
101
  (0, exports.getPublicKey)(signerAddress, signerChainId, message, signature, encoding),
121
102
  ];
122
- // console.log('MSG ARGS', msgArgs)
123
103
  return msgArgs;
124
104
  };
125
105
  exports.getMsgArgs = getMsgArgs;
@@ -317,7 +297,6 @@ function groupTickersByInterval(tickers, newIntervalInSec, endTimeInSec) {
317
297
  const newGroupedTickers = [];
318
298
  let timestamp = endTimeInSec - newIntervalInSec;
319
299
  let slot = null;
320
- // desc direction by timestamp
321
300
  const sortedTickers = tickers.sort((a, b) => b.t - a.t);
322
301
  for (let i = 0; i < sortedTickers.length; i++) {
323
302
  const element = sortedTickers[i];
@@ -629,7 +608,7 @@ exports.bn_operation = bn_operation;
629
608
  exports.roundNumber = roundNumber;
630
609
  exports.convertFromBaseUnits = convertFromBaseUnits;
631
610
  exports.convertToBaseUnits = convertToBaseUnits;
632
- const bignumber_js_1 = __importDefault(__webpack_require__(6168));
611
+ const bignumber_js_1 = __importDefault(__webpack_require__(4978));
633
612
  bignumber_js_1.default.config({ DECIMAL_PLACES: 40, EXPONENTIAL_AT: 45 });
634
613
  var Operations;
635
614
  (function (Operations) {
@@ -647,7 +626,6 @@ var Operations;
647
626
  function absolute(value) {
648
627
  let x = new bignumber_js_1.default(value);
649
628
  const res = x.abs().toString();
650
- // console.log('Absolute value', { value, res })
651
629
  return res;
652
630
  }
653
631
  function ceil(value) {
@@ -787,17 +765,10 @@ function roundNumber({ decimalPlaces = 0 }, x) {
787
765
  }
788
766
  function convertFromBaseUnits(assetDecimals, quantity) {
789
767
  const decimals = Number(assetDecimals);
790
- return roundNumber({ decimalPlaces: decimals },
791
- // eslint-disable-next-line no-magic-numbers
792
- Math.pow(10, -decimals) * Number(quantity));
768
+ return roundNumber({ decimalPlaces: decimals }, Math.pow(10, -decimals) * Number(quantity));
793
769
  }
794
- /**
795
- * Computs quantity * 10^(assetDecimals) and rounds the result
796
- */
797
770
  function convertToBaseUnits(assetDecimals, quantity) {
798
- // eslint-disable-next-line no-magic-numbers
799
771
  const baseAmount = Math.pow(10, Number(assetDecimals)) * Number(quantity);
800
- // make sure the final value is an integer. This prevents this kind of computation errors: 0.0012 * 100000 = 119.99999999999999 and rounds this result into 120
801
772
  return roundNumber({ decimalPlaces: 0 }, baseAmount);
802
773
  }
803
774
 
@@ -822,13 +793,6 @@ var StateType;
822
793
  })(StateType || (exports.StateType = StateType = {}));
823
794
 
824
795
 
825
- /***/ }),
826
-
827
- /***/ 1297:
828
- /***/ ((module) => {
829
-
830
- module.exports = __WEBPACK_EXTERNAL_MODULE__1297__;
831
-
832
796
  /***/ }),
833
797
 
834
798
  /***/ 1492:
@@ -1318,7 +1282,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1318
1282
  };
1319
1283
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1320
1284
  exports.makeTransferTxn = exports.makeTransferMsg = exports.decodeTransferMsg = exports.makeDtwMsg = exports.decodeDtwMsg = exports.getTransferBytesFromMsg = exports.calcTransferHash = exports.getTransferBoxKeyFromHash = exports.getTransferBoxKey = exports.TRANSFER_DATA_BYTES_LENGTH = exports.DTW_DATA_BYTES_LENGTH = void 0;
1321
- const algosdk_1 = __importDefault(__webpack_require__(9709));
1285
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
1322
1286
  const enums_1 = __webpack_require__(9965);
1323
1287
  const codex_helper_1 = __webpack_require__(3955);
1324
1288
  const Encoding_1 = __webpack_require__(8593);
@@ -1370,7 +1334,6 @@ const makeDtwMsg = (data) => {
1370
1334
  const bs64OrderBytes = (0, codex_helper_1.getBase64EncodedData)(dataBytes);
1371
1335
  console.log(`Dtw data should be ${exports.DTW_DATA_BYTES_LENGTH} bytes`, bs64OrderBytes.length, bs64OrderBytes);
1372
1336
  return bs64OrderBytes;
1373
- // return makeSigningMessage(JSON.stringify(data), dataBytes);
1374
1337
  };
1375
1338
  exports.makeDtwMsg = makeDtwMsg;
1376
1339
  const decodeTransferMsg = (message, encoding = 'hex') => {
@@ -1407,7 +1370,6 @@ const makeTransferMsg = (data) => {
1407
1370
  const bs64OrderBytes = (0, codex_helper_1.getBase64EncodedData)(dataBytes);
1408
1371
  console.log(`Transfer data should be ${exports.TRANSFER_DATA_BYTES_LENGTH} bytes`, bs64OrderBytes.length, bs64OrderBytes);
1409
1372
  return bs64OrderBytes;
1410
- // return makeSigningMessage(JSON.stringify(data), dataBytes);
1411
1373
  };
1412
1374
  exports.makeTransferMsg = makeTransferMsg;
1413
1375
  const makeTransferTxn = async ({ data, message, signature }, dtw, options) => {
@@ -1457,7 +1419,6 @@ const makeTransferTxn = async ({ data, message, signature }, dtw, options) => {
1457
1419
  foreignApps,
1458
1420
  boxes: allBoxes,
1459
1421
  });
1460
- // console.log('directTransfer txn', appCallTxn);
1461
1422
  return appCallTxn;
1462
1423
  };
1463
1424
  exports.makeTransferTxn = makeTransferTxn;
@@ -1631,8 +1592,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1631
1592
  exports.createBoxes = exports.getTokenBoxKey = exports.getPairBoxKey = exports.decodeCreateOrderMsg = exports.getCancelOrderDataJsonBytes = exports.makeCreateOrderMsg = exports.makeDepositMsg = exports.makeDepositTxns = exports.makeAssetOptInTxn = exports.getTokenBoxValue = exports.getOrderBoxValue = exports.getPairBoxValue = exports.getCompanyBoxValue = exports.getCompanyBoxName = exports.getAccountBoxByHash = exports.getAccountBoxValue = exports.getAccountBalanceBoxValue = exports.getBoxes = exports.getAssetBalancesByAppAddress = exports.getAssetBalancesByAppIndex = exports.getTradingKeyBoxValue = exports.getTradingKeyBoxName = exports.getTmcBoxValue = exports.getTmcBoxName = exports.getRebalanceBoxName = exports.getCCTPBalancesBoxValue = exports.getCCTPBalanceBoxValue = exports.getCCTPBalanceBoxName = exports.getAccountBalanceBoxName = exports.getAccountBalanceBoxNameHash = exports.getCodexAccountInfo = exports.getCodexStateValue = exports.encodeToken = exports.checkIfAddressIsNormalized = exports.normalizeAddress = exports.decodeToken = exports.decodeAddress = exports.extractUint256 = exports.extractUint64 = exports.extractUint32 = exports.extractUint16 = exports.extractStr = exports.extractDouble = exports.extractToken = exports.extractAddress = exports.decode = exports.encode = exports.getAddressFromNormalized = exports.getAddressChainFromNormalized = exports.encodeAddress = void 0;
1632
1593
  exports.getUpgradeImpMsg = exports.makeUpdatePairInfoTxn = exports.makeUpdateTokenInfoTxns = exports.makeSetCompanyFeeTxn = exports.makeSetSuperAppTxns = exports.makeSetSuperCollectionWalletTxns = exports.makeSetCollectionWalletTxn = exports.makeWithdrawTxns = exports.getBase64EncodedData = exports.getUtf8EncodedData = exports.makeSigningMessage = exports.makeSetCollectionWalletMsg = exports.makeRevokeTradingKeyTxn = exports.makeAddTradingKeyTxn = exports.decodeTradingKeyMsg = exports.makeTradingKeyMsg = exports.makeLoginMsg = exports.makeMatchTxns = void 0;
1633
1594
  exports.getTokenFromNormalized = getTokenFromNormalized;
1634
- const algosdk_1 = __importDefault(__webpack_require__(9709));
1635
- const bs58 = __importStar(__webpack_require__(4578));
1595
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
1596
+ const bs58 = __importStar(__webpack_require__(5316));
1636
1597
  const big_number_helper_1 = __webpack_require__(1174);
1637
1598
  const utils_1 = __webpack_require__(8398);
1638
1599
  const codex_1 = __webpack_require__(430);
@@ -1676,7 +1637,6 @@ function getTokenFromNormalized(token, chainId) {
1676
1637
  return (0, exports.getAddressFromNormalized)(token, Number(chainId));
1677
1638
  }
1678
1639
  const encode = (value, type, chain) => {
1679
- // console.log('encode', JSON.stringify({ value: typeof value === "bigint" ? `${value}n` : value, type, chain }));
1680
1640
  switch (type) {
1681
1641
  case '8B': return algosdk_1.default.encodeUint64(Number(value));
1682
1642
  case '32B': return (0, eth_helper_1.encode32Bytes)(value);
@@ -1779,13 +1739,6 @@ const encodeToken = (token, chain) => {
1779
1739
  exports.encodeToken = encodeToken;
1780
1740
  const getCodexStateValue = async (algoClient, appId) => {
1781
1741
  const globalState = await (0, algo_helper_1.getAppGlobalState)(algoClient, appId);
1782
- // console.log('codexState', appId, globalState);
1783
- // if (globalState["MNA"]) {
1784
- // console.log('MNA', decodeAddress(Buffer.from(globalState["MNA"]), 8));
1785
- // }
1786
- // if (globalState["BKA"]) {
1787
- // console.log('BKA', decodeAddress(Buffer.from(globalState["BKA"]), 8));
1788
- // }
1789
1742
  const msgProcId = globalState["MSG_PROCESSOR"];
1790
1743
  const superAppId = globalState["UL_SUPERADMIN_APP"];
1791
1744
  let superWallet = globalState["UL_SUPERADMIN_WALLET"];
@@ -1915,7 +1868,6 @@ const getAccountBalanceBoxValue = async (algoClient, appId, login, token) => {
1915
1868
  };
1916
1869
  exports.getAccountBalanceBoxValue = getAccountBalanceBoxValue;
1917
1870
  const getAccountBoxValue = async (algoClient, appId, loginAddress, loginChainId, tokenAddress, tokenChainId) => {
1918
- // console.log('getAccountBoxValue', { loginAddress, loginChainId, tokenAddress, tokenChainId });
1919
1871
  const boxName = (0, eth_helper_1.keccak256)((0, exports.getAccountBalanceBoxName)(loginAddress, loginChainId, tokenAddress, tokenChainId));
1920
1872
  const boxValue = await getAccountBox(algoClient, appId, boxName);
1921
1873
  console.log('Box account value', loginAddress.substring(0, 8), tokenAddress, boxValue, Buffer.from(boxName).toString('hex'));
@@ -2111,7 +2063,7 @@ const makeCreateOrderMsg = (data) => {
2111
2063
  (0, exports.encode)(data.companyId, '2B'),
2112
2064
  (0, exports.encode)(data.random, '8B'),
2113
2065
  (0, exports.encode)(data.decimalPrice, 'float'),
2114
- Buffer.alloc(50), // extra 50 zero bytes
2066
+ Buffer.alloc(50),
2115
2067
  ]);
2116
2068
  const bs64OrderBytes = new Uint8Array(Buffer.from((0, Encoding_1.encodeBase64)(orderBytes)));
2117
2069
  const messageBytes = new Uint8Array([
@@ -2192,14 +2144,13 @@ const decodeCreateOrderMsg = (message, encoding = 'hex') => {
2192
2144
  return {
2193
2145
  ...orderData,
2194
2146
  expiredDate: String(orderData.expiredTime).length > 10
2195
- ? new Date(orderData.expiredTime) // TODO: fix pysdk to send time in sec
2147
+ ? new Date(orderData.expiredTime)
2196
2148
  : new Date(orderData.expiredTime * 1000)
2197
2149
  };
2198
2150
  };
2199
2151
  exports.decodeCreateOrderMsg = decodeCreateOrderMsg;
2200
2152
  const getMatchOrderArgs = (order) => {
2201
2153
  const { id, address, chain, message, encoding, signature, tradingKey } = order;
2202
- // console.log('getMatchOrderArgs', JSON.stringify(order));
2203
2154
  const signAddress = tradingKey || address;
2204
2155
  const signChain = tradingKey ? enums_1.Chains.Algorand : chain;
2205
2156
  return [
@@ -2228,8 +2179,6 @@ const createBoxes = (appIndex, boxNames, encode = eth_helper_1.keccak256) => {
2228
2179
  appIndex,
2229
2180
  name: encode(boxName)
2230
2181
  }));
2231
- // console.log('createBoxes', boxes.map(b => Buffer.from(b.name).toString('hex')))
2232
- // console.log(`createBoxesBytes`, boxes.map(b => Array.apply([], Array.from(b.name)).join(", ")));
2233
2182
  return boxes;
2234
2183
  };
2235
2184
  exports.createBoxes = createBoxes;
@@ -2323,7 +2272,7 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2323
2272
  getShareWalletBoxKey(afTaker, baseAsset),
2324
2273
  getShareWalletBoxKey(afTaker, priceAsset),
2325
2274
  ]
2326
- .filter(Boolean) // filter possible undefined args
2275
+ .filter(Boolean)
2327
2276
  .map(o => Buffer.from(o).toString('hex')))
2328
2277
  ].map(o => Buffer.from(o, 'hex'));
2329
2278
  const allBoxes = [
@@ -2337,7 +2286,6 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2337
2286
  ];
2338
2287
  const allBoxesUnique = [...new Set(allBoxes.map(o => Buffer.from(o.name).toString('hex')))];
2339
2288
  console.log(`[TradeID: ${id}] All boxes`, JSON.stringify(allBoxesUnique));
2340
- // allBoxes = allBoxesUnique.map(o => Buffer.from(o.name))
2341
2289
  const foreignApps = [superAppId];
2342
2290
  const MAX_REFS = 8;
2343
2291
  const mainTxnBoxes = allBoxes.slice(0, MAX_REFS - foreignApps.length);
@@ -2362,12 +2310,6 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2362
2310
  };
2363
2311
  exports.makeMatchTxns = makeMatchTxns;
2364
2312
  const makeLoginMsg = (data, signingMessage) => {
2365
- // const dataBytes = concatArrays([
2366
- // encode(data.address, 'address', data.chainId),
2367
- // encode(data.chainId, '8B'),
2368
- // encode(data.provider, 'str'),
2369
- // ]);
2370
- // return makeSigningMessage(data.signingMessage, dataBytes);
2371
2313
  const { address, technology } = data;
2372
2314
  return (0, exports.getUtf8EncodedData)(signingMessage || JSON.stringify({ address, technology }));
2373
2315
  };
@@ -2401,9 +2343,7 @@ const decodeTradingKeyMsg = (message, encoding = 'hex') => {
2401
2343
  };
2402
2344
  };
2403
2345
  exports.decodeTradingKeyMsg = decodeTradingKeyMsg;
2404
- const makeAddTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message,
2405
- // encoding: BufferEncoding | undefined,
2406
- signature) => {
2346
+ const makeAddTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message, signature) => {
2407
2347
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2408
2348
  const appArgs = (0, codex_1.getAppArgs)("manageTradingKey(byte[],byte[],byte[],byte[])uint64", [
2409
2349
  (0, exports.encode)('add', 'str'),
@@ -2424,9 +2364,7 @@ signature) => {
2424
2364
  return txn;
2425
2365
  };
2426
2366
  exports.makeAddTradingKeyTxn = makeAddTradingKeyTxn;
2427
- const makeRevokeTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message,
2428
- // encoding: BufferEncoding | undefined,
2429
- signature) => {
2367
+ const makeRevokeTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message, signature) => {
2430
2368
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2431
2369
  const appArgs = (0, codex_1.getAppArgs)("manageTradingKey(byte[],byte[],byte[],byte[])uint64", [
2432
2370
  (0, exports.encode)('delete', 'str'),
@@ -2451,7 +2389,6 @@ const makeSetCollectionWalletMsg = (data) => {
2451
2389
  const chainIdBytes = algosdk_1.default.encodeUint64(loginChainId);
2452
2390
  const dataBytes = (0, Encoding_1.concatArrays)([senderBytes, chainIdBytes, companyIdBytes]);
2453
2391
  const messageBytes = new Uint8Array([
2454
- // ...getUtf8EncodedData(JSON.stringify(data)),
2455
2392
  ...(0, exports.getBase64EncodedData)(dataBytes),
2456
2393
  ]);
2457
2394
  console.log('MESSAGE LENGTH: ', messageBytes);
@@ -2466,14 +2403,10 @@ const getUtf8EncodedData = (jsonData) => new Uint8Array(Buffer.from((jsonData +
2466
2403
  exports.getUtf8EncodedData = getUtf8EncodedData;
2467
2404
  const getBase64EncodedData = (data) => new Uint8Array(Buffer.from((0, Encoding_1.encodeBase64)(data)));
2468
2405
  exports.getBase64EncodedData = getBase64EncodedData;
2469
- const makeWithdrawTxns = async (algoClient, { loginAddress, loginChainId, tokenIndex, recipient, recipientChainId }, message, signature,
2470
- // encoding: BufferEncoding | undefined,
2471
- sender, options) => {
2406
+ const makeWithdrawTxns = async (algoClient, { loginAddress, loginChainId, tokenIndex, recipient, recipientChainId }, message, signature, sender, options) => {
2472
2407
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2473
2408
  const appArgs = (0, codex_1.getAppArgs)("withdraw(byte[],byte[],byte[])uint64", msgArgs);
2474
2409
  const isAlgoChain = recipientChainId === enums_1.Chains.Algorand;
2475
- // TODO: calc actual txn fee
2476
- // const params = await getTxnParams(algoClient, 7);
2477
2410
  const params = await (0, algo_helper_1.getTxnParams)(algoClient, isAlgoChain ? 6 : 2);
2478
2411
  params.fee = params.fee + (algosdk_1.default.ALGORAND_MIN_TX_FEE * 5);
2479
2412
  const { appId, coreId, lsaAddress, msgProcessorId, unifiedChainId, cctpSupportedChains, superWallet } = options;
@@ -2724,10 +2657,10 @@ exports.messageForSigning = messageForSigning;
2724
2657
 
2725
2658
  /***/ }),
2726
2659
 
2727
- /***/ 4578:
2660
+ /***/ 4978:
2728
2661
  /***/ ((module) => {
2729
2662
 
2730
- module.exports = __WEBPACK_EXTERNAL_MODULE__4578__;
2663
+ module.exports = require("bignumber.js");
2731
2664
 
2732
2665
  /***/ }),
2733
2666
 
@@ -2745,6 +2678,13 @@ var UpgradeStatus;
2745
2678
  })(UpgradeStatus || (exports.UpgradeStatus = UpgradeStatus = {}));
2746
2679
 
2747
2680
 
2681
+ /***/ }),
2682
+
2683
+ /***/ 5316:
2684
+ /***/ ((module) => {
2685
+
2686
+ module.exports = require("bs58");
2687
+
2748
2688
  /***/ }),
2749
2689
 
2750
2690
  /***/ 5386:
@@ -2765,7 +2705,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2765
2705
  };
2766
2706
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2767
2707
  exports.makeRemoveExpiredOrderTxn = exports.calcOrderHash = exports.getOrderBoxKeyFromHash = exports.getOrderBoxKey = exports.getOrderBytesFromMsg = void 0;
2768
- const algosdk_1 = __importDefault(__webpack_require__(9709));
2708
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
2769
2709
  const common_helper_1 = __webpack_require__(223);
2770
2710
  const Encoding_1 = __webpack_require__(8593);
2771
2711
  const constants_1 = __webpack_require__(6450);
@@ -2829,25 +2769,25 @@ function getDatepartValue(value) {
2829
2769
  if (!units) {
2830
2770
  return mapWithTimeframe(datepart, 1);
2831
2771
  }
2832
- if (datepart === 'minute' && units % (7 * 24 * 60) === 0) { // week
2772
+ if (datepart === 'minute' && units % (7 * 24 * 60) === 0) {
2833
2773
  return mapWithTimeframe('week', units / (7 * 24 * 60));
2834
2774
  }
2835
- if (datepart === 'minute' && units % (24 * 60) === 0) { // day
2775
+ if (datepart === 'minute' && units % (24 * 60) === 0) {
2836
2776
  return mapWithTimeframe('day', units / (24 * 60));
2837
2777
  }
2838
- if (datepart === 'minute' && units % 60 === 0) { // hour
2778
+ if (datepart === 'minute' && units % 60 === 0) {
2839
2779
  return mapWithTimeframe('hour', units / 60);
2840
2780
  }
2841
- if (datepart === 'hour' && units % (7 * 24) === 0) { // week
2781
+ if (datepart === 'hour' && units % (7 * 24) === 0) {
2842
2782
  return mapWithTimeframe('week', units / (7 * 24));
2843
2783
  }
2844
- if (datepart === 'hour' && units % 24 === 0) { // day
2784
+ if (datepart === 'hour' && units % 24 === 0) {
2845
2785
  return mapWithTimeframe(units === 24 ? 'hour' : 'day', units === 24 ? 24 : units / 24);
2846
2786
  }
2847
- if (datepart === 'day' && units % 7 === 0) { // week
2787
+ if (datepart === 'day' && units % 7 === 0) {
2848
2788
  return mapWithTimeframe('week', units / 7);
2849
2789
  }
2850
- if (datepart === 'month' && units % 12 === 0) { // year
2790
+ if (datepart === 'month' && units % 12 === 0) {
2851
2791
  return mapWithTimeframe('year', units / 12);
2852
2792
  }
2853
2793
  return mapWithTimeframe(datepart, units);
@@ -2917,13 +2857,6 @@ var TwitterAccessScopeEnum;
2917
2857
  })(TwitterAccessScopeEnum || (exports.TwitterAccessScopeEnum = TwitterAccessScopeEnum = {}));
2918
2858
 
2919
2859
 
2920
- /***/ }),
2921
-
2922
- /***/ 6168:
2923
- /***/ ((module) => {
2924
-
2925
- module.exports = __WEBPACK_EXTERNAL_MODULE__6168__;
2926
-
2927
2860
  /***/ }),
2928
2861
 
2929
2862
  /***/ 6450:
@@ -2998,7 +2931,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2998
2931
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2999
2932
  exports.verifySignature = exports.decodeAndNormalizeAddress = exports.isAssetOptedIn = exports.getTxnParams = exports.getBoxByName = exports.getAppBoxes = exports.getAppGlobalState = exports.getAccountAssetBalances = exports.createBoxes = void 0;
3000
2933
  exports.decodeStateArray = decodeStateArray;
3001
- const algosdk_1 = __importDefault(__webpack_require__(9709));
2934
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
3002
2935
  const Encoding_1 = __webpack_require__(8593);
3003
2936
  const helpers_1 = __webpack_require__(9730);
3004
2937
  const createBoxes = (appIndex, foreignApps) => {
@@ -3058,7 +2991,6 @@ const getAppBoxes = async (algodClient, appId) => {
3058
2991
  exports.getAppBoxes = getAppBoxes;
3059
2992
  const getBoxByName = async (algoClient, appId, boxName) => {
3060
2993
  try {
3061
- // console.log('Get box by name', boxName);
3062
2994
  const { value } = await algoClient.getApplicationBoxByName(appId, boxName).do();
3063
2995
  const box = value;
3064
2996
  return box;
@@ -3258,23 +3190,19 @@ var SmallTimeframeEnum;
3258
3190
  SmallTimeframeEnum["last_year"] = "last_year";
3259
3191
  })(SmallTimeframeEnum || (exports.SmallTimeframeEnum = SmallTimeframeEnum = {}));
3260
3192
  class PairsQueryDto {
3261
- constructor() {
3262
- this.timeRange = SmallTimeframeEnum.last_30_days;
3263
- this.sortBy = 'volume_usd';
3264
- this.order = 'desc';
3265
- this.limit = 20;
3266
- this.page = 1;
3267
- }
3193
+ timeRange = SmallTimeframeEnum.last_30_days;
3194
+ sortBy = 'volume_usd';
3195
+ order = 'desc';
3196
+ limit = 20;
3197
+ page = 1;
3268
3198
  }
3269
3199
  exports.PairsQueryDto = PairsQueryDto;
3270
3200
  class UsersQueryDto {
3271
- constructor() {
3272
- this.timeRange = SmallTimeframeEnum.last_30_days;
3273
- this.sortBy = 'volume_usd';
3274
- this.order = 'desc';
3275
- this.limit = 20;
3276
- this.page = 1;
3277
- }
3201
+ timeRange = SmallTimeframeEnum.last_30_days;
3202
+ sortBy = 'volume_usd';
3203
+ order = 'desc';
3204
+ limit = 20;
3205
+ page = 1;
3278
3206
  }
3279
3207
  exports.UsersQueryDto = UsersQueryDto;
3280
3208
  var StatisticTypeQuery;
@@ -3285,10 +3213,8 @@ var StatisticTypeQuery;
3285
3213
  StatisticTypeQuery["dau"] = "dau";
3286
3214
  })(StatisticTypeQuery || (exports.StatisticTypeQuery = StatisticTypeQuery = {}));
3287
3215
  class ChartQueryDto {
3288
- constructor() {
3289
- this.type = StatisticTypeQuery.volume;
3290
- this.timeRange = SmallTimeframeEnum.last_7_days;
3291
- }
3216
+ type = StatisticTypeQuery.volume;
3217
+ timeRange = SmallTimeframeEnum.last_7_days;
3292
3218
  }
3293
3219
  exports.ChartQueryDto = ChartQueryDto;
3294
3220
 
@@ -3429,6 +3355,13 @@ exports.QueueOptions = {
3429
3355
  };
3430
3356
 
3431
3357
 
3358
+ /***/ }),
3359
+
3360
+ /***/ 7835:
3361
+ /***/ ((module) => {
3362
+
3363
+ module.exports = require("ethereumjs-util");
3364
+
3432
3365
  /***/ }),
3433
3366
 
3434
3367
  /***/ 8060:
@@ -3440,7 +3373,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3440
3373
  };
3441
3374
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3442
3375
  exports.makeGroupTxnsWithDummy = exports.makeDummyTxn = void 0;
3443
- const algosdk_1 = __importDefault(__webpack_require__(9709));
3376
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
3444
3377
  const common_helper_1 = __webpack_require__(223);
3445
3378
  const makeDummyTxn = (appIndex, sender, params, boxes, note, foreignApps) => {
3446
3379
  const appArgs = (0, common_helper_1.getAppArgs)("dummy(uint64)void", [1]);
@@ -3480,8 +3413,6 @@ const makeGroupTxnsWithDummy = (id, mainTxnBody) => {
3480
3413
  dummyTxnIndex++;
3481
3414
  }
3482
3415
  }
3483
- // TODO: check this dummy txn
3484
- // additional dummy txn for withdrawal
3485
3416
  dummyTxns2.push((0, exports.makeDummyTxn)(appIndex, from, suggestedParams, [], `${id}_${++dummyTxnIndex}`, foreignApps));
3486
3417
  console.log("dummy count", dummyTxns2.length);
3487
3418
  return [mainTxn, ...dummyTxns2];
@@ -3489,6 +3420,13 @@ const makeGroupTxnsWithDummy = (id, mainTxnBody) => {
3489
3420
  exports.makeGroupTxnsWithDummy = makeGroupTxnsWithDummy;
3490
3421
 
3491
3422
 
3423
+ /***/ }),
3424
+
3425
+ /***/ 8115:
3426
+ /***/ ((module) => {
3427
+
3428
+ module.exports = require("algosdk");
3429
+
3492
3430
  /***/ }),
3493
3431
 
3494
3432
  /***/ 8398:
@@ -3588,7 +3526,7 @@ function removeField(obj, fieldToRemove) {
3588
3526
  .filter(([key]) => key !== fieldToRemove)
3589
3527
  .map(([key, value]) => [key, removeField(value, fieldToRemove)]));
3590
3528
  }
3591
- return obj; // Return primitives as-is
3529
+ return obj;
3592
3530
  }
3593
3531
  function removeUndefined(obj) {
3594
3532
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
@@ -3652,9 +3590,8 @@ exports.getDeltaUint = getDeltaUint;
3652
3590
  exports.getDeltaBytes = getDeltaBytes;
3653
3591
  exports.toUnix = toUnix;
3654
3592
  exports.fromUnix = fromUnix;
3655
- const algosdk_1 = __importStar(__webpack_require__(9709));
3656
- // import sha512 from "js-sha512"
3657
- const buffer_1 = __webpack_require__(18);
3593
+ const algosdk_1 = __importStar(__webpack_require__(8115));
3594
+ const buffer_1 = __webpack_require__(9428);
3658
3595
  function concatArrays(arrays) {
3659
3596
  return arrays.reduce((a, b) => Uint8Array.from([...a, ...b]));
3660
3597
  }
@@ -3807,15 +3744,6 @@ function encodeBase64(value) {
3807
3744
  function decodeBase64(value) {
3808
3745
  return buffer_1.Buffer.from(value, 'base64');
3809
3746
  }
3810
- // export const sha256HashLength = 32
3811
- // export function sha256Hash(arr: sha512.Message): Uint8Array {
3812
- // return new Uint8Array(sha512.sha512_256.arrayBuffer(arr))
3813
- // }
3814
- // export function encodeApplicationAddress(id: number): Address {
3815
- // const APP_ID_PREFIX = Buffer.from('appID');
3816
- // const toBeSigned = concatArrays([APP_ID_PREFIX, encodeUint64(BigInt(id))]);
3817
- // return encodeAddress(sha256Hash(toBeSigned));
3818
- // }
3819
3747
  function compareArrays(a, b) {
3820
3748
  return a.length === b.length && a.reduce((equal, item, index) => equal && item === b[index], true);
3821
3749
  }
@@ -3843,7 +3771,7 @@ function toUnix(date) {
3843
3771
  function fromUnix(timestamp) {
3844
3772
  return new Date(timestamp * 1000);
3845
3773
  }
3846
- var algosdk_2 = __webpack_require__(9709);
3774
+ var algosdk_2 = __webpack_require__(8115);
3847
3775
  Object.defineProperty(exports, "encodeAddress", ({ enumerable: true, get: function () { return algosdk_2.encodeAddress; } }));
3848
3776
  Object.defineProperty(exports, "decodeAddress", ({ enumerable: true, get: function () { return algosdk_2.decodeAddress; } }));
3849
3777
 
@@ -3892,11 +3820,10 @@ exports.keccak256 = exports.verifyMessage = exports.verifySignature = exports.re
3892
3820
  exports.decode32Bytes = decode32Bytes;
3893
3821
  exports.encodeBigNumber = encodeBigNumber;
3894
3822
  exports.encode32Bytes = encode32Bytes;
3895
- const ethUtil = __importStar(__webpack_require__(1297));
3823
+ const ethUtil = __importStar(__webpack_require__(7835));
3896
3824
  const common_helper_1 = __webpack_require__(223);
3897
3825
  function decode32Bytes(value) {
3898
3826
  const bnValue = ethUtil.fromSigned(Buffer.from(value));
3899
- // console.log('bnValue', value, bnValue, bnValue.toString())
3900
3827
  return BigInt(bnValue.toString());
3901
3828
  }
3902
3829
  function encodeBigNumber(value) {
@@ -3940,9 +3867,8 @@ exports.unpadHexPrefix = unpadHexPrefix;
3940
3867
  const isAddress = (address) => ethUtil.isValidAddress(address);
3941
3868
  exports.isAddress = isAddress;
3942
3869
  const recoverPublicKey = (message, signature) => {
3943
- const messageHash = ethUtil.keccak256(message); // Ensure message is correctly formatted
3870
+ const messageHash = ethUtil.keccak256(message);
3944
3871
  const { r, s, v } = ethUtil.fromRpcSig(signature);
3945
- // Recover the public key
3946
3872
  return ethUtil.ecrecover(messageHash, v, r, s);
3947
3873
  };
3948
3874
  exports.recoverPublicKey = recoverPublicKey;
@@ -3973,7 +3899,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3973
3899
  };
3974
3900
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3975
3901
  exports.makeSetManagerKeyTxn = void 0;
3976
- const algosdk_1 = __importDefault(__webpack_require__(9709));
3902
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
3977
3903
  const algo_helper_1 = __webpack_require__(6897);
3978
3904
  const codex_helper_1 = __webpack_require__(3955);
3979
3905
  const common_helper_1 = __webpack_require__(223);
@@ -3985,14 +3911,12 @@ const makeSetManagerKeyTxn = async (algoClient, superAppId, sender, mnaKey) => {
3985
3911
  console.log("new MNA key:", mnaKey);
3986
3912
  console.log("sender:", sender);
3987
3913
  console.log("superAppId:", superAppId);
3988
- // return makeSetGlobalTxn(algoClient, superAppId, sender, AppGlobalParamName.MNA, mnaKey, AppGlobalParamType.STRING);
3989
3914
  const txn = algosdk_1.default.makeApplicationNoOpTxnFromObject({
3990
3915
  appIndex: superAppId,
3991
3916
  from: sender,
3992
3917
  suggestedParams: params,
3993
3918
  appArgs: (0, common_helper_1.getAppArgs)("set_global(byte[],byte[],byte[])void", [
3994
3919
  (0, codex_helper_1.encode)("MNA", 'str'),
3995
- // encode(mnaKey, 'str'),
3996
3920
  algosdk_1.default.decodeAddress(mnaKey).publicKey,
3997
3921
  (0, codex_helper_1.encode)('S', 'str')
3998
3922
  ]),
@@ -4008,7 +3932,6 @@ exports.makeSetManagerKeyTxn = makeSetManagerKeyTxn;
4008
3932
  /***/ ((__unused_webpack_module, exports) => {
4009
3933
 
4010
3934
 
4011
- //--import { Asset } from "@ultrade/shared/db/entities/market/asset.entity";
4012
3935
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4013
3936
  exports.AmmBucketKeys = exports.VALIDATOR_APP_ID = exports.CONTRACT_VERSION = exports.AmmForeignResources = exports.AmmChars = exports.AmmIds = exports.PoolType = void 0;
4014
3937
  var PoolType;
@@ -4075,7 +3998,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4075
3998
  };
4076
3999
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4077
4000
  exports.makeUpdateMbrTxn = exports.getMbrBoxValue = void 0;
4078
- const algosdk_1 = __importDefault(__webpack_require__(9709));
4001
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
4079
4002
  const algo_helper_1 = __webpack_require__(6897);
4080
4003
  const common_helper_1 = __webpack_require__(223);
4081
4004
  const Encoding_1 = __webpack_require__(8593);
@@ -4127,10 +4050,10 @@ exports.makeUpdateMbrTxn = makeUpdateMbrTxn;
4127
4050
 
4128
4051
  /***/ }),
4129
4052
 
4130
- /***/ 9709:
4053
+ /***/ 9428:
4131
4054
  /***/ ((module) => {
4132
4055
 
4133
- module.exports = __WEBPACK_EXTERNAL_MODULE__9709__;
4056
+ module.exports = require("buffer");
4134
4057
 
4135
4058
  /***/ }),
4136
4059
 
@@ -4239,8 +4162,7 @@ __exportStar(__webpack_require__(3004), exports);
4239
4162
  /******/ // Load entry module and return exports
4240
4163
  /******/ // This entry module is referenced by other modules so it can't be inlined
4241
4164
  /******/ var __webpack_exports__ = __webpack_require__(9367);
4165
+ /******/ module.exports = __webpack_exports__;
4242
4166
  /******/
4243
- /******/ return __webpack_exports__;
4244
4167
  /******/ })()
4245
- ;
4246
- });
4168
+ ;