@fileverse-dev/formulajs 4.4.30 → 4.4.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* @fileverse-dev/formulajs v4.4.30 */
1
+ /* @fileverse-dev/formulajs v4.4.31 */
2
2
  var _excluded = [ "confirmations", "dataDecoded" ];
3
3
 
4
4
  function _objectWithoutProperties(e, t) {
@@ -17271,7 +17271,7 @@ function _typeof(o) {
17271
17271
  }
17272
17272
  function _handleScanRequest() {
17273
17273
  _handleScanRequest = _asyncToGenerator(_regeneratorRuntime().mark((function _callee15(_ref13) {
17274
- var type, address, startDate, endDate, _ref13$page, page, _ref13$offset, offset, apiKey, functionName, chainId, network, API_INFO_MAP, apiInfo, baseUrl, ACTION_MAP, action, module, url, _yield$Promise$all, _yield$Promise$all2, startBlock, endBlock, _getUrlAndHeaders4, finalUrl, HEADERS, res, json;
17274
+ var type, address, startDate, endDate, _ref13$page, page, _ref13$offset, offset, apiKey, functionName, chainId, network, apiInfo, baseUrl, ACTION_MAP, action, module, url, _yield$Promise$all, _yield$Promise$all2, startBlock, endBlock, _getUrlAndHeaders4, finalUrl, HEADERS, res, json;
17275
17275
  return _regeneratorRuntime().wrap((function _callee15$(_context18) {
17276
17276
  while (1) switch (_context18.prev = _context18.next) {
17277
17277
  case 0:
@@ -17279,40 +17279,22 @@ function _typeof(o) {
17279
17279
  _ref13$page = _ref13.page, page = _ref13$page === void 0 ? 1 : _ref13$page, _ref13$offset = _ref13.offset,
17280
17280
  offset = _ref13$offset === void 0 ? 10 : _ref13$offset, apiKey = _ref13.apiKey,
17281
17281
  functionName = _ref13.functionName, chainId = _ref13.chainId, network = _ref13.network;
17282
- API_INFO_MAP = {
17283
- BASE: {
17284
- url: "https://api.basescan.org/api",
17285
- apiKeyName: SERVICES_API_KEY.Basescan
17286
- },
17287
- ETHERSCAN: {
17288
- url: "https://api.etherscan.io/v2/api",
17289
- apiKeyName: SERVICES_API_KEY.Etherscan
17290
- },
17291
- GNOSIS: {
17292
- url: "https://api.gnosisscan.io/api",
17293
- apiKeyName: SERVICES_API_KEY.Gnosisscan
17294
- }
17295
- };
17296
17282
  if (!(type !== "gas")) {
17297
- _context18.next = 6;
17283
+ _context18.next = 5;
17298
17284
  break;
17299
17285
  }
17300
- _context18.next = 5;
17286
+ _context18.next = 4;
17301
17287
  return fromEnsNameToAddress$1.validateAndGetAddress(address);
17302
17288
 
17303
- case 5:
17289
+ case 4:
17304
17290
  address = _context18.sent;
17305
17291
 
17306
- case 6:
17307
- apiInfo = API_INFO_MAP[functionName];
17292
+ case 5:
17293
+ apiInfo = {
17294
+ url: "https://api.etherscan.io/v2/api",
17295
+ apiKeyName: SERVICES_API_KEY.Etherscan
17296
+ };
17308
17297
  baseUrl = apiInfo === null || apiInfo === void 0 ? void 0 : apiInfo.url;
17309
- if (baseUrl) {
17310
- _context18.next = 10;
17311
- break;
17312
- }
17313
- throw new ValidationError("Api not found for: ".concat(functionName));
17314
-
17315
- case 10:
17316
17298
  ACTION_MAP = {
17317
17299
  "all-txns": "txlist",
17318
17300
  "token-txns": "tokentx",
@@ -17321,83 +17303,83 @@ function _typeof(o) {
17321
17303
  };
17322
17304
  action = ACTION_MAP[type];
17323
17305
  if (action) {
17324
- _context18.next = 14;
17306
+ _context18.next = 11;
17325
17307
  break;
17326
17308
  }
17327
17309
  throw new ValidationError("Invalid type: ".concat(type));
17328
17310
 
17329
- case 14:
17311
+ case 11:
17330
17312
  module = action === "gasoracle" ? "gastracker" : "account";
17331
17313
  url = "".concat(baseUrl, "?chainid=").concat(chainId, "&module=").concat(module, "&action=").concat(action, "&apikey=").concat(apiKey);
17332
17314
  if (![ "all-txns", "token-txns", "nft-txns" ].includes(type)) {
17333
- _context18.next = 27;
17315
+ _context18.next = 24;
17334
17316
  break;
17335
17317
  }
17336
17318
  url += "&address=".concat(address, "&startblock=0&endblock=99999999&sort=asc");
17337
17319
  if (!(!isNaN(startDate) && !isNaN(endDate))) {
17338
- _context18.next = 26;
17320
+ _context18.next = 23;
17339
17321
  break;
17340
17322
  }
17341
- _context18.next = 21;
17323
+ _context18.next = 18;
17342
17324
  return Promise.all([ fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startDate), network, apiKey), fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endDate), network, apiKey) ]);
17343
17325
 
17344
- case 21:
17326
+ case 18:
17345
17327
  _yield$Promise$all = _context18.sent;
17346
17328
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
17347
17329
  startBlock = _yield$Promise$all2[0];
17348
17330
  endBlock = _yield$Promise$all2[1];
17349
17331
  url += "&startblock=".concat(startBlock || "0", "&endblock=").concat(endBlock || "99999999");
17350
17332
 
17351
- case 26:
17333
+ case 23:
17352
17334
  url += "&page=".concat(page, "&offset=").concat(offset);
17353
17335
 
17354
- case 27:
17336
+ case 24:
17355
17337
  _getUrlAndHeaders4 = getUrlAndHeaders({
17356
17338
  url: url,
17357
17339
  serviceName: apiInfo.apiKeyName,
17358
17340
  headers: {}
17359
17341
  }), finalUrl = _getUrlAndHeaders4.URL, HEADERS = _getUrlAndHeaders4.HEADERS;
17360
- _context18.next = 30;
17342
+ _context18.next = 27;
17361
17343
  return fetch(finalUrl, {
17362
17344
  method: "GET",
17363
17345
  headers: HEADERS
17364
17346
  });
17365
17347
 
17366
- case 30:
17348
+ case 27:
17367
17349
  res = _context18.sent;
17368
17350
  if (res.ok) {
17369
- _context18.next = 33;
17351
+ _context18.next = 30;
17370
17352
  break;
17371
17353
  }
17372
17354
  throw new NetworkError(apiInfo.apiKeyName, res.status);
17373
17355
 
17374
- case 33:
17375
- _context18.next = 35;
17356
+ case 30:
17357
+ _context18.next = 32;
17376
17358
  return res.json();
17377
17359
 
17378
- case 35:
17360
+ case 32:
17379
17361
  json = _context18.sent;
17380
17362
  if (!(typeof json.result === "string")) {
17381
- _context18.next = 41;
17363
+ _context18.next = 38;
17382
17364
  break;
17383
17365
  }
17384
17366
  if (!json.result.includes("Invalid API Key")) {
17385
- _context18.next = 39;
17367
+ _context18.next = 36;
17386
17368
  break;
17387
17369
  }
17388
17370
  throw new InvalidApiKeyError(apiInfo.apiKeyName);
17389
17371
 
17390
- case 39:
17372
+ case 36:
17391
17373
  if (!json.result.includes("Max rate limit reached")) {
17392
- _context18.next = 41;
17374
+ _context18.next = 38;
17393
17375
  break;
17394
17376
  }
17395
17377
  throw new RateLimitError(apiInfo.apiKeyName);
17396
17378
 
17397
- case 41:
17379
+ case 38:
17398
17380
  return _context18.abrupt("return", type === "gas" && !Array.isArray(json.result) ? [ json.result ] : json.result);
17399
17381
 
17400
- case 42:
17382
+ case 39:
17401
17383
  case "end":
17402
17384
  return _context18.stop();
17403
17385
  }