@fileverse-dev/formulajs 4.4.11-mod-21-patch-2 → 4.4.11-mod-21-patch-4

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.11-mod-21-patch-2 */
1
+ /* @fileverse-dev/formulajs v4.4.11-mod-21-patch-4 */
2
2
  var _excluded = [ "confirmations", "dataDecoded" ];
3
3
 
4
4
  function _objectWithoutProperties(e, t) {
@@ -10826,11 +10826,6 @@ function _typeof(o) {
10826
10826
  }
10827
10827
  return result;
10828
10828
  }
10829
- var SERVICE_API_KEY = {
10830
- Etherscan: "ETHERSCAN_API_KEY",
10831
- Coingecko: "COINGECKO_API_KEY",
10832
- Safe: "SAFE_API_KEY"
10833
- };
10834
10829
  var CHAIN_ID_MAP = {
10835
10830
  ethereum: 1,
10836
10831
  gnosis: 100,
@@ -10841,9 +10836,15 @@ function _typeof(o) {
10841
10836
  gnosis: "gno"
10842
10837
  };
10843
10838
  var ERROR_MESSAGES_FLAG = {
10844
- INVALID_API_KEY: "_MISSING",
10839
+ INVALID_API_KEY: "_INVALID_KEY",
10845
10840
  RATE_LIMIT: "_RATE_LIMIT_REACHED",
10846
- DEFAULT: "FETCH_ERROR"
10841
+ DEFAULT: "FETCH_ERROR",
10842
+ MISSING_KEY: "_MISSING"
10843
+ };
10844
+ var SERVICE_API_KEY = {
10845
+ Etherscan: "ETHERSCAN_API_KEY",
10846
+ Coingecko: "COINGECKO_API_KEY",
10847
+ Safe: "SAFE_API_KEY"
10847
10848
  };
10848
10849
  var fromTimeStampToBlock = function() {
10849
10850
  var _ref = _asyncToGenerator(_regeneratorRuntime().mark((function _callee(timestamp, chain, apiKey) {
@@ -10887,16 +10888,70 @@ function _typeof(o) {
10887
10888
  }
10888
10889
  function _ETHERSCAN() {
10889
10890
  _ETHERSCAN = _asyncToGenerator(_regeneratorRuntime().mark((function _callee2(address, page, offset) {
10891
+ var API_KEY, url, response, json;
10890
10892
  return _regeneratorRuntime().wrap((function _callee2$(_context2) {
10891
10893
  while (1) switch (_context2.prev = _context2.next) {
10892
10894
  case 0:
10895
+ API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
10896
+ if (API_KEY) {
10897
+ _context2.next = 3;
10898
+ break;
10899
+ }
10900
+ return _context2.abrupt("return", "".concat(SERVICE_API_KEY.Etherscan).concat(ERROR_MESSAGES_FLAG.MISSING_KEY));
10901
+
10902
+ case 3:
10903
+ if (!(API_KEY === "xxxx")) {
10904
+ _context2.next = 5;
10905
+ break;
10906
+ }
10893
10907
  return _context2.abrupt("return", "".concat(SERVICE_API_KEY.Etherscan).concat(ERROR_MESSAGES_FLAG.RATE_LIMIT));
10894
10908
 
10895
- case 1:
10909
+ case 5:
10910
+ url = "https://api.etherscan.io/v2/api?chainid=1&module=account&action=txlist&address=".concat(address, "&startblock=0&endblock=99999999&page=").concat(page || 1, "&offset=").concat(offset || 10, "&sort=asc&apikey=").concat(API_KEY);
10911
+ _context2.prev = 6;
10912
+ _context2.next = 9;
10913
+ return fetch(url);
10914
+
10915
+ case 9:
10916
+ response = _context2.sent;
10917
+ if (response.ok) {
10918
+ _context2.next = 12;
10919
+ break;
10920
+ }
10921
+ throw new Error("HTTP error! Status: ".concat(response.status));
10922
+
10923
+ case 12:
10924
+ _context2.next = 14;
10925
+ return response.json();
10926
+
10927
+ case 14:
10928
+ json = _context2.sent;
10929
+ if (!json.result.includes("Invalid API Key")) {
10930
+ _context2.next = 17;
10931
+ break;
10932
+ }
10933
+ return _context2.abrupt("return", "".concat(SERVICE_API_KEY.Etherscan).concat(ERROR_MESSAGES_FLAG.INVALID_API_KEY));
10934
+
10935
+ case 17:
10936
+ if (!json.result.includes("Max rate limit reached")) {
10937
+ _context2.next = 19;
10938
+ break;
10939
+ }
10940
+ return _context2.abrupt("return", "".concat(SERVICE_API_KEY.Etherscan).concat(ERROR_MESSAGES_FLAG.RATE_LIMIT));
10941
+
10942
+ case 19:
10943
+ return _context2.abrupt("return", json.result);
10944
+
10945
+ case 22:
10946
+ _context2.prev = 22;
10947
+ _context2.t0 = _context2["catch"](6);
10948
+ return _context2.abrupt("return", ERROR_MESSAGES_FLAG.DEFAULT);
10949
+
10950
+ case 25:
10896
10951
  case "end":
10897
10952
  return _context2.stop();
10898
10953
  }
10899
- }), _callee2);
10954
+ }), _callee2, null, [ [ 6, 22 ] ]);
10900
10955
  })));
10901
10956
  return _ETHERSCAN.apply(this, arguments);
10902
10957
  }