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