@fileverse-dev/formulajs 4.4.11-mod-82 → 4.4.11-mod-83-patch-1

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-82 */
1
+ /* @fileverse-dev/formulajs v4.4.11-mod-84 */
2
2
  var _excluded = [ "confirmations", "dataDecoded" ];
3
3
 
4
4
  function _objectWithoutProperties(e, t) {
@@ -21,52 +21,6 @@ function _objectWithoutPropertiesLoose(r, e) {
21
21
  return t;
22
22
  }
23
23
 
24
- function _createForOfIteratorHelper(r, e) {
25
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
26
- if (!t) {
27
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
28
- t && (r = t);
29
- var _n = 0, F = function F() {};
30
- return {
31
- s: F,
32
- n: function n() {
33
- return _n >= r.length ? {
34
- done: !0
35
- } : {
36
- done: !1,
37
- value: r[_n++]
38
- };
39
- },
40
- e: function e(r) {
41
- throw r;
42
- },
43
- f: F
44
- };
45
- }
46
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
- }
48
- var o, a = !0, u = !1;
49
- return {
50
- s: function s() {
51
- t = t.call(r);
52
- },
53
- n: function n() {
54
- var r = t.next();
55
- return a = r.done, r;
56
- },
57
- e: function e(r) {
58
- u = !0, o = r;
59
- },
60
- f: function f() {
61
- try {
62
- a || null == t["return"] || t["return"]();
63
- } finally {
64
- if (u) throw o;
65
- }
66
- }
67
- };
68
- }
69
-
70
24
  function _regeneratorRuntime() {
71
25
  "use strict";
72
26
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() {
@@ -389,6 +343,52 @@ function _defineProperty(e, r, t) {
389
343
  }) : e[r] = t, e;
390
344
  }
391
345
 
346
+ function _createForOfIteratorHelper(r, e) {
347
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
348
+ if (!t) {
349
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
350
+ t && (r = t);
351
+ var _n = 0, F = function F() {};
352
+ return {
353
+ s: F,
354
+ n: function n() {
355
+ return _n >= r.length ? {
356
+ done: !0
357
+ } : {
358
+ done: !1,
359
+ value: r[_n++]
360
+ };
361
+ },
362
+ e: function e(r) {
363
+ throw r;
364
+ },
365
+ f: F
366
+ };
367
+ }
368
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
369
+ }
370
+ var o, a = !0, u = !1;
371
+ return {
372
+ s: function s() {
373
+ t = t.call(r);
374
+ },
375
+ n: function n() {
376
+ var r = t.next();
377
+ return a = r.done, r;
378
+ },
379
+ e: function e(r) {
380
+ u = !0, o = r;
381
+ },
382
+ f: function f() {
383
+ try {
384
+ a || null == t["return"] || t["return"]();
385
+ } finally {
386
+ if (u) throw o;
387
+ }
388
+ }
389
+ };
390
+ }
391
+
392
392
  function _defineProperties(e, r) {
393
393
  for (var t = 0; t < r.length; t++) {
394
394
  var o = r[t];
@@ -11126,502 +11126,72 @@ function _typeof(o) {
11126
11126
  _inherits(InvalidApiKeyError, _Error6);
11127
11127
  return _createClass(InvalidApiKeyError);
11128
11128
  }(_wrapNativeSuper(Error));
11129
- var PROXY_MAP;
11130
- function initializeProxyMap() {
11131
- console.log("initializeProxyMap", window.NEXT_PUBLIC_PROXY_BASE_URL);
11132
- if (!PROXY_MAP) {
11133
- var fileverseProxyUrl = "".concat(window.NEXT_PUBLIC_PROXY_BASE_URL, "/proxy");
11134
- PROXY_MAP = {
11135
- Etherscan: {
11136
- url: "".concat(fileverseProxyUrl, "/proxy"),
11137
- removeParams: [ "apikey" ]
11138
- },
11139
- Basescan: {
11140
- url: "".concat(fileverseProxyUrl, "/proxy"),
11141
- removeParams: [ "apikey" ]
11142
- },
11143
- Gnosisscan: {
11144
- url: "".concat(fileverseProxyUrl, "/proxy"),
11145
- removeParams: [ "apikey" ]
11146
- },
11147
- Coingecko: {
11148
- url: "".concat(fileverseProxyUrl, "/proxy"),
11149
- removeParams: [ "apikey" ]
11150
- },
11151
- Firefly: {
11152
- url: "".concat(fileverseProxyUrl, "/proxy"),
11153
- removeParams: [ "apikey" ]
11154
- },
11155
- Neynar: {
11156
- url: "".concat(fileverseProxyUrl, "/proxy"),
11157
- removeParams: [ "api_key" ]
11158
- },
11159
- Safe: {
11160
- url: "".concat(fileverseProxyUrl, "/proxy"),
11161
- removeParams: [ "api_key" ]
11162
- },
11163
- Defillama: {
11164
- url: "".concat(fileverseProxyUrl, "/proxy"),
11165
- removeParams: [ "api_key" ]
11166
- },
11167
- GnosisPay: {
11168
- url: "".concat(fileverseProxyUrl, "/proxy"),
11169
- removeParams: [ "api_key" ]
11170
- }
11171
- };
11172
- }
11173
- return PROXY_MAP;
11174
- }
11175
- function removeUrlParams(url, paramsToRemove) {
11176
- if (!paramsToRemove || paramsToRemove.length === 0) {
11177
- return url;
11178
- }
11179
- var urlObj = new URL(url);
11180
- paramsToRemove.forEach((function(param) {
11181
- if (urlObj.searchParams.has(param)) {
11182
- urlObj.searchParams["delete"](param);
11129
+ var errorMessageHandler = function errorMessageHandler(err, functionName) {
11130
+ switch (true) {
11131
+ case err instanceof ValidationError:
11132
+ {
11133
+ return {
11134
+ message: err.message,
11135
+ functionName: functionName,
11136
+ type: ERROR_MESSAGES_FLAG.INVALID_PARAM
11137
+ };
11183
11138
  }
11184
- }));
11185
- return urlObj.toString();
11186
- }
11187
- function getUrlAndHeaders(_ref) {
11188
- var url = _ref.url, serviceName = _ref.serviceName, _ref$headers = _ref.headers, headers = _ref$headers === void 0 ? {} : _ref$headers;
11189
- var proxyMap = initializeProxyMap();
11190
- var apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
11191
- var isProxyModeEnabledValue = apiKeyLS === "DEFAULT_PROXY_MODE";
11192
- var proxyConfig = proxyMap[serviceName];
11193
- if (!proxyConfig && SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === "")) {
11194
- throw new MissingApiKeyError(SERVICES_API_KEY[serviceName]);
11195
- }
11196
- if ((isProxyModeEnabledValue || !apiKeyLS || apiKeyLS === "") && proxyConfig) {
11197
- var cleanedUrl = removeUrlParams(url, proxyConfig.removeParams);
11139
+
11140
+ case err instanceof MissingApiKeyError:
11198
11141
  return {
11199
- URL: proxyConfig.url,
11200
- HEADERS: {
11201
- "target-url": cleanedUrl,
11202
- method: "GET",
11203
- "Content-Type": "application/json"
11204
- }
11142
+ message: err.message,
11143
+ functionName: functionName,
11144
+ type: ERROR_MESSAGES_FLAG.MISSING_KEY
11205
11145
  };
11206
- }
11207
- return {
11208
- URL: url,
11209
- HEADERS: _objectSpread({}, headers)
11210
- };
11211
- }
11212
- var fromTimeStampToBlock = function() {
11213
- var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee(timestamp, chain, apiKey) {
11214
- var chainId, url, _getUrlAndHeaders, finalUrl, HEADERS, res, json;
11215
- return _regeneratorRuntime().wrap((function _callee$(_context) {
11216
- while (1) switch (_context.prev = _context.next) {
11217
- case 0:
11218
- if (!(!timestamp || !chain)) {
11219
- _context.next = 2;
11220
- break;
11221
- }
11222
- return _context.abrupt("return");
11223
11146
 
11224
- case 2:
11225
- chainId = CHAIN_ID_MAP[chain];
11226
- url = "https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=".concat(timestamp, "&closest=before&apikey=").concat(apiKey, "&chainId=").concat(chainId);
11227
- _getUrlAndHeaders = getUrlAndHeaders({
11228
- url: url,
11229
- serviceName: "Etherscan",
11230
- headers: {}
11231
- }), finalUrl = _getUrlAndHeaders.URL, HEADERS = _getUrlAndHeaders.HEADERS;
11232
- _context.next = 7;
11233
- return fetch(finalUrl, {
11234
- method: "GET",
11235
- headers: HEADERS
11236
- });
11147
+ case err instanceof RateLimitError:
11148
+ return {
11149
+ message: err.message,
11150
+ functionName: functionName,
11151
+ type: ERROR_MESSAGES_FLAG.RATE_LIMIT,
11152
+ apiKeyName: err.api
11153
+ };
11237
11154
 
11238
- case 7:
11239
- res = _context.sent;
11240
- _context.next = 10;
11241
- return res.json();
11155
+ case err instanceof NetworkError:
11156
+ if (err.status === 429) {
11157
+ return {
11158
+ message: err.message,
11159
+ functionName: functionName,
11160
+ type: ERROR_MESSAGES_FLAG.RATE_LIMIT,
11161
+ apiKeyName: err.api
11162
+ };
11163
+ } else {
11164
+ return {
11165
+ message: err.message,
11166
+ functionName: functionName,
11167
+ type: ERROR_MESSAGES_FLAG.NETWORK_ERROR,
11168
+ apiKeyName: err.api
11169
+ };
11170
+ }
11242
11171
 
11243
- case 10:
11244
- json = _context.sent;
11245
- return _context.abrupt("return", parseInt(json.result));
11172
+ case err instanceof EnsError:
11173
+ return {
11174
+ message: err.message,
11175
+ functionName: functionName,
11176
+ type: ERROR_MESSAGES_FLAG.ENS
11177
+ };
11246
11178
 
11247
- case 12:
11248
- case "end":
11249
- return _context.stop();
11250
- }
11251
- }), _callee);
11252
- })));
11253
- return function fromTimeStampToBlock(_x2, _x3, _x4) {
11254
- return _ref2.apply(this, arguments);
11255
- };
11256
- }();
11257
- var fromTimestampToBlock = {
11258
- fromTimeStampToBlock: fromTimeStampToBlock
11259
- };
11260
- function toTimestamp(dateStr) {
11261
- var _dateStr$split$map = dateStr.split("/").map(Number), _dateStr$split$map2 = _slicedToArray(_dateStr$split$map, 3), day = _dateStr$split$map2[0], month = _dateStr$split$map2[1], year = _dateStr$split$map2[2];
11262
- var date = new Date(year, month - 1, day);
11263
- return Math.floor(date.getTime() / 1e3);
11264
- }
11265
- var isAddress = function isAddress(input) {
11266
- return /^0x[a-fA-F0-9]{40}$/.test(input);
11267
- };
11268
- var isAddress$1 = {
11269
- isAddress: isAddress
11270
- };
11271
- function fromEnsNameToAddress(_x5) {
11272
- return _fromEnsNameToAddress.apply(this, arguments);
11273
- }
11274
- function _fromEnsNameToAddress() {
11275
- _fromEnsNameToAddress = _asyncToGenerator(_regeneratorRuntime().mark((function _callee10(name) {
11276
- var ALCHEMY_KEY, provider, resolved;
11277
- return _regeneratorRuntime().wrap((function _callee10$(_context10) {
11278
- while (1) switch (_context10.prev = _context10.next) {
11279
- case 0:
11280
- if (!(typeof ethers === "undefined")) {
11281
- _context10.next = 3;
11282
- break;
11283
- }
11284
- _context10.next = 3;
11285
- return new Promise((function(resolve, reject) {
11286
- var script = document.createElement("script");
11287
- script.src = "https://cdn.jsdelivr.net/npm/ethers@6.10.0/dist/ethers.umd.min.js";
11288
- script.onload = resolve;
11289
- script.onerror = reject;
11290
- document.head.appendChild(script);
11291
- }));
11292
-
11293
- case 3:
11294
- ALCHEMY_KEY = window.localStorage.getItem(UTILITY.ALCHEMY_API_KEY);
11295
- if (ALCHEMY_KEY) {
11296
- _context10.next = 7;
11297
- break;
11298
- }
11299
- console.error("alchemy api key missing");
11300
- return _context10.abrupt("return", null);
11301
-
11302
- case 7:
11303
- provider = new ethers.AlchemyProvider("mainnet", ALCHEMY_KEY);
11304
- _context10.prev = 8;
11305
- _context10.next = 11;
11306
- return provider.resolveName(name);
11307
-
11308
- case 11:
11309
- resolved = _context10.sent;
11310
- return _context10.abrupt("return", resolved || null);
11311
-
11312
- case 15:
11313
- _context10.prev = 15;
11314
- _context10.t0 = _context10["catch"](8);
11315
- console.error("ENS resolution failed:", _context10.t0.message);
11316
- return _context10.abrupt("return", null);
11317
-
11318
- case 19:
11319
- case "end":
11320
- return _context10.stop();
11321
- }
11322
- }), _callee10, null, [ [ 8, 15 ] ]);
11323
- })));
11324
- return _fromEnsNameToAddress.apply(this, arguments);
11325
- }
11326
- var validateAndGetAddress = function() {
11327
- var _ref3 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee2(address) {
11328
- var resolvedAddress;
11329
- return _regeneratorRuntime().wrap((function _callee2$(_context2) {
11330
- while (1) switch (_context2.prev = _context2.next) {
11331
- case 0:
11332
- if (!isAddress$1.isAddress(address)) {
11333
- _context2.next = 2;
11334
- break;
11335
- }
11336
- return _context2.abrupt("return", address);
11337
-
11338
- case 2:
11339
- _context2.next = 4;
11340
- return fromEnsNameToAddress(address);
11341
-
11342
- case 4:
11343
- resolvedAddress = _context2.sent;
11344
- if (!resolvedAddress) {
11345
- _context2.next = 7;
11346
- break;
11347
- }
11348
- return _context2.abrupt("return", resolvedAddress);
11349
-
11350
- case 7:
11351
- throw new ValidationError("Invalid address");
11352
-
11353
- case 8:
11354
- case "end":
11355
- return _context2.stop();
11356
- }
11357
- }), _callee2);
11358
- })));
11359
- return function validateAndGetAddress(_x6) {
11360
- return _ref3.apply(this, arguments);
11361
- };
11362
- }();
11363
- var fromEnsNameToAddress$1 = {
11364
- validateAndGetAddress: validateAndGetAddress
11365
- };
11366
- function handleScanRequest(_x7) {
11367
- return _handleScanRequest.apply(this, arguments);
11368
- }
11369
- function _handleScanRequest() {
11370
- _handleScanRequest = _asyncToGenerator(_regeneratorRuntime().mark((function _callee11(_ref4) {
11371
- var type, address, startDate, endDate, _ref4$page, page, _ref4$offset, offset, apiKey, functionName, chainId, network, API_INFO_MAP, apiInfo, baseUrl, ACTION_MAP, action, module, url, _yield$Promise$all, _yield$Promise$all2, startBlock, endBlock, _getUrlAndHeaders3, finalUrl, HEADERS, res, json;
11372
- return _regeneratorRuntime().wrap((function _callee11$(_context11) {
11373
- while (1) switch (_context11.prev = _context11.next) {
11374
- case 0:
11375
- type = _ref4.type, address = _ref4.address, startDate = _ref4.startDate, endDate = _ref4.endDate,
11376
- _ref4$page = _ref4.page, page = _ref4$page === void 0 ? 1 : _ref4$page, _ref4$offset = _ref4.offset,
11377
- offset = _ref4$offset === void 0 ? 10 : _ref4$offset, apiKey = _ref4.apiKey, functionName = _ref4.functionName,
11378
- chainId = _ref4.chainId, network = _ref4.network;
11379
- API_INFO_MAP = {
11380
- BASE: {
11381
- url: "https://api.basescan.org/api",
11382
- apiKeyName: SERVICES_API_KEY.Basescan
11383
- },
11384
- ETHERSCAN: {
11385
- url: "https://api.etherscan.io/v2/api",
11386
- apiKeyName: SERVICES_API_KEY.Etherscan
11387
- },
11388
- GNOSIS: {
11389
- url: "https://api.gnosisscan.io/api",
11390
- apiKeyName: SERVICES_API_KEY.Gnosisscan
11391
- }
11392
- };
11393
- if (!(type !== "gas")) {
11394
- _context11.next = 6;
11395
- break;
11396
- }
11397
- _context11.next = 5;
11398
- return fromEnsNameToAddress$1.validateAndGetAddress(address);
11399
-
11400
- case 5:
11401
- address = _context11.sent;
11402
-
11403
- case 6:
11404
- apiInfo = API_INFO_MAP[functionName];
11405
- baseUrl = apiInfo === null || apiInfo === void 0 ? void 0 : apiInfo.url;
11406
- if (baseUrl) {
11407
- _context11.next = 10;
11408
- break;
11409
- }
11410
- throw new ValidationError("Api not found for: ".concat(functionName));
11411
-
11412
- case 10:
11413
- ACTION_MAP = {
11414
- "all-txns": "txlist",
11415
- "token-txns": "tokentx",
11416
- "nft-txns": "tokennfttx",
11417
- gas: "gasoracle"
11418
- };
11419
- action = ACTION_MAP[type];
11420
- if (action) {
11421
- _context11.next = 14;
11422
- break;
11423
- }
11424
- throw new ValidationError("Invalid type: ".concat(type));
11425
-
11426
- case 14:
11427
- module = action === "gasoracle" ? "gastracker" : "account";
11428
- url = "".concat(baseUrl, "?chainid=").concat(chainId, "&module=").concat(module, "&action=").concat(action, "&apikey=").concat(apiKey);
11429
- if (![ "all-txns", "token-txns", "nft-txns" ].includes(type)) {
11430
- _context11.next = 27;
11431
- break;
11432
- }
11433
- url += "&address=".concat(address, "&startblock=0&endblock=99999999&sort=asc");
11434
- if (!(!isNaN(startDate) && !isNaN(endDate))) {
11435
- _context11.next = 26;
11436
- break;
11437
- }
11438
- _context11.next = 21;
11439
- return Promise.all([ fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startDate), network, apiKey), fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endDate), network, apiKey) ]);
11440
-
11441
- case 21:
11442
- _yield$Promise$all = _context11.sent;
11443
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
11444
- startBlock = _yield$Promise$all2[0];
11445
- endBlock = _yield$Promise$all2[1];
11446
- url += "&startblock=".concat(startBlock || "0", "&endblock=").concat(endBlock || "99999999");
11447
-
11448
- case 26:
11449
- url += "&page=".concat(page, "&offset=").concat(offset);
11450
-
11451
- case 27:
11452
- _getUrlAndHeaders3 = getUrlAndHeaders({
11453
- url: url,
11454
- serviceName: apiInfo.apiKeyName,
11455
- headers: {}
11456
- }), finalUrl = _getUrlAndHeaders3.URL, HEADERS = _getUrlAndHeaders3.HEADERS;
11457
- _context11.next = 30;
11458
- return fetch(finalUrl, {
11459
- method: "GET",
11460
- headers: HEADERS
11461
- });
11462
-
11463
- case 30:
11464
- res = _context11.sent;
11465
- if (res.ok) {
11466
- _context11.next = 33;
11467
- break;
11468
- }
11469
- throw new NetworkError(apiInfo.apiKeyName, res.status);
11470
-
11471
- case 33:
11472
- _context11.next = 35;
11473
- return res.json();
11474
-
11475
- case 35:
11476
- json = _context11.sent;
11477
- if (!(typeof json.result === "string")) {
11478
- _context11.next = 41;
11479
- break;
11480
- }
11481
- if (!json.result.includes("Invalid API Key")) {
11482
- _context11.next = 39;
11483
- break;
11484
- }
11485
- throw new InvalidApiKeyError(apiInfo.apiKeyName);
11486
-
11487
- case 39:
11488
- if (!json.result.includes("Max rate limit reached")) {
11489
- _context11.next = 41;
11490
- break;
11491
- }
11492
- throw new RateLimitError(apiInfo.apiKeyName);
11493
-
11494
- case 41:
11495
- return _context11.abrupt("return", type === "gas" && !Array.isArray(json.result) ? [ json.result ] : json.result);
11496
-
11497
- case 42:
11498
- case "end":
11499
- return _context11.stop();
11500
- }
11501
- }), _callee11);
11502
- })));
11503
- return _handleScanRequest.apply(this, arguments);
11504
- }
11505
- var fromUsernameToFid = function() {
11506
- var _ref5 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee3(username, apiKey) {
11507
- var url, _getUrlAndHeaders2, finalUrl, HEADERS, res, json, users, user;
11508
- return _regeneratorRuntime().wrap((function _callee3$(_context3) {
11509
- while (1) switch (_context3.prev = _context3.next) {
11510
- case 0:
11511
- if (username) {
11512
- _context3.next = 2;
11513
- break;
11514
- }
11515
- return _context3.abrupt("return", null);
11516
-
11517
- case 2:
11518
- url = "https://api.neynar.com/v2/farcaster/user/search/?q=".concat(username, "&limit=5");
11519
- _getUrlAndHeaders2 = getUrlAndHeaders({
11520
- url: url,
11521
- serviceName: "Neynar",
11522
- headers: {
11523
- "x-api-key": apiKey,
11524
- "x-neynar-experimental": "false"
11525
- }
11526
- }), finalUrl = _getUrlAndHeaders2.URL, HEADERS = _getUrlAndHeaders2.HEADERS;
11527
- _context3.next = 6;
11528
- return fetch(finalUrl, {
11529
- method: "GET",
11530
- headers: HEADERS
11531
- });
11532
-
11533
- case 6:
11534
- res = _context3.sent;
11535
- _context3.next = 9;
11536
- return res.json();
11537
-
11538
- case 9:
11539
- json = _context3.sent;
11540
- users = json.result ? json.result.users : [];
11541
- user = users.find((function(user) {
11542
- return user.username === username;
11543
- }));
11544
- return _context3.abrupt("return", user && user.fid || null);
11545
-
11546
- case 13:
11547
- case "end":
11548
- return _context3.stop();
11549
- }
11550
- }), _callee3);
11551
- })));
11552
- return function fromUsernameToFid(_x8, _x9) {
11553
- return _ref5.apply(this, arguments);
11554
- };
11555
- }();
11556
- var fromUsernameToFid$1 = {
11557
- fromUsernameToFid: fromUsernameToFid
11558
- };
11559
- var errorMessageHandler = function errorMessageHandler(err, functionName) {
11560
- switch (true) {
11561
- case err instanceof ValidationError:
11562
- {
11563
- return {
11564
- message: err.message,
11565
- functionName: functionName,
11566
- type: ERROR_MESSAGES_FLAG.INVALID_PARAM
11567
- };
11568
- }
11569
-
11570
- case err instanceof MissingApiKeyError:
11571
- return {
11572
- message: err.message,
11573
- functionName: functionName,
11574
- type: ERROR_MESSAGES_FLAG.MISSING_KEY
11575
- };
11576
-
11577
- case err instanceof RateLimitError:
11578
- return {
11579
- message: err.message,
11580
- functionName: functionName,
11581
- type: ERROR_MESSAGES_FLAG.RATE_LIMIT,
11582
- apiKeyName: err.api
11583
- };
11584
-
11585
- case err instanceof NetworkError:
11586
- if (err.status === 429) {
11587
- return {
11588
- message: err.message,
11589
- functionName: functionName,
11590
- type: ERROR_MESSAGES_FLAG.RATE_LIMIT,
11591
- apiKeyName: err.api
11592
- };
11593
- } else {
11594
- return {
11595
- message: err.message,
11596
- functionName: functionName,
11597
- type: ERROR_MESSAGES_FLAG.NETWORK_ERROR,
11598
- apiKeyName: err.api
11599
- };
11600
- }
11601
-
11602
- case err instanceof EnsError:
11603
- return {
11604
- message: err.message,
11605
- functionName: functionName,
11606
- type: ERROR_MESSAGES_FLAG.ENS
11607
- };
11608
-
11609
- case err instanceof InvalidApiKeyError:
11610
- return {
11611
- message: err.message,
11612
- functionName: functionName,
11613
- type: ERROR_MESSAGES_FLAG.INVALID_API_KEY,
11614
- apiKeyName: err.api
11615
- };
11616
-
11617
- default:
11618
- return {
11619
- message: "An unexpected error occured",
11620
- functionName: functionName,
11621
- type: ERROR_MESSAGES_FLAG.DEFAULT,
11622
- reason: err.message || err
11623
- };
11624
- }
11179
+ case err instanceof InvalidApiKeyError:
11180
+ return {
11181
+ message: err.message,
11182
+ functionName: functionName,
11183
+ type: ERROR_MESSAGES_FLAG.INVALID_API_KEY,
11184
+ apiKeyName: err.api
11185
+ };
11186
+
11187
+ default:
11188
+ return {
11189
+ message: "An unexpected error occured",
11190
+ functionName: functionName,
11191
+ type: ERROR_MESSAGES_FLAG.DEFAULT,
11192
+ reason: err.message || err
11193
+ };
11194
+ }
11625
11195
  };
11626
11196
  function validateParams(schema, rawParams) {
11627
11197
  var result = schema.safeParse(rawParams);
@@ -12110,65 +11680,65 @@ function _typeof(o) {
12110
11680
  }, {
12111
11681
  key: "mergeObjectAsync",
12112
11682
  value: function() {
12113
- var _mergeObjectAsync = _asyncToGenerator(_regeneratorRuntime().mark((function _callee4(status, pairs) {
11683
+ var _mergeObjectAsync = _asyncToGenerator(_regeneratorRuntime().mark((function _callee(status, pairs) {
12114
11684
  var syncPairs, _iterator8, _step8, pair, key, _value5;
12115
- return _regeneratorRuntime().wrap((function _callee4$(_context4) {
12116
- while (1) switch (_context4.prev = _context4.next) {
11685
+ return _regeneratorRuntime().wrap((function _callee$(_context) {
11686
+ while (1) switch (_context.prev = _context.next) {
12117
11687
  case 0:
12118
11688
  syncPairs = [];
12119
11689
  _iterator8 = _createForOfIteratorHelper(pairs);
12120
- _context4.prev = 2;
11690
+ _context.prev = 2;
12121
11691
  _iterator8.s();
12122
11692
 
12123
11693
  case 4:
12124
11694
  if ((_step8 = _iterator8.n()).done) {
12125
- _context4.next = 15;
11695
+ _context.next = 15;
12126
11696
  break;
12127
11697
  }
12128
11698
  pair = _step8.value;
12129
- _context4.next = 8;
11699
+ _context.next = 8;
12130
11700
  return pair.key;
12131
11701
 
12132
11702
  case 8:
12133
- key = _context4.sent;
12134
- _context4.next = 11;
11703
+ key = _context.sent;
11704
+ _context.next = 11;
12135
11705
  return pair.value;
12136
11706
 
12137
11707
  case 11:
12138
- _value5 = _context4.sent;
11708
+ _value5 = _context.sent;
12139
11709
  syncPairs.push({
12140
11710
  key: key,
12141
11711
  value: _value5
12142
11712
  });
12143
11713
 
12144
11714
  case 13:
12145
- _context4.next = 4;
11715
+ _context.next = 4;
12146
11716
  break;
12147
11717
 
12148
11718
  case 15:
12149
- _context4.next = 20;
11719
+ _context.next = 20;
12150
11720
  break;
12151
11721
 
12152
11722
  case 17:
12153
- _context4.prev = 17;
12154
- _context4.t0 = _context4["catch"](2);
12155
- _iterator8.e(_context4.t0);
11723
+ _context.prev = 17;
11724
+ _context.t0 = _context["catch"](2);
11725
+ _iterator8.e(_context.t0);
12156
11726
 
12157
11727
  case 20:
12158
- _context4.prev = 20;
11728
+ _context.prev = 20;
12159
11729
  _iterator8.f();
12160
- return _context4.finish(20);
11730
+ return _context.finish(20);
12161
11731
 
12162
11732
  case 23:
12163
- return _context4.abrupt("return", ParseStatus.mergeObjectSync(status, syncPairs));
11733
+ return _context.abrupt("return", ParseStatus.mergeObjectSync(status, syncPairs));
12164
11734
 
12165
11735
  case 24:
12166
11736
  case "end":
12167
- return _context4.stop();
11737
+ return _context.stop();
12168
11738
  }
12169
- }), _callee4, null, [ [ 2, 17, 20, 23 ] ]);
11739
+ }), _callee, null, [ [ 2, 17, 20, 23 ] ]);
12170
11740
  })));
12171
- function mergeObjectAsync(_x0, _x1) {
11741
+ function mergeObjectAsync(_x2, _x3) {
12172
11742
  return _mergeObjectAsync.apply(this, arguments);
12173
11743
  }
12174
11744
  return mergeObjectAsync;
@@ -12297,7 +11867,7 @@ function _typeof(o) {
12297
11867
  description: description
12298
11868
  };
12299
11869
  var customMap = function customMap(iss, ctx) {
12300
- var _ref7;
11870
+ var _ref2;
12301
11871
  var message = params.message;
12302
11872
  if (iss.code === "invalid_enum_value") {
12303
11873
  return {
@@ -12305,16 +11875,16 @@ function _typeof(o) {
12305
11875
  };
12306
11876
  }
12307
11877
  if (typeof ctx.data === "undefined") {
12308
- var _ref6;
11878
+ var _ref;
12309
11879
  return {
12310
- message: (_ref6 = message !== null && message !== void 0 ? message : required_error) !== null && _ref6 !== void 0 ? _ref6 : ctx.defaultError
11880
+ message: (_ref = message !== null && message !== void 0 ? message : required_error) !== null && _ref !== void 0 ? _ref : ctx.defaultError
12311
11881
  };
12312
11882
  }
12313
11883
  if (iss.code !== "invalid_type") return {
12314
11884
  message: ctx.defaultError
12315
11885
  };
12316
11886
  return {
12317
- message: (_ref7 = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _ref7 !== void 0 ? _ref7 : ctx.defaultError
11887
+ message: (_ref2 = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _ref2 !== void 0 ? _ref2 : ctx.defaultError
12318
11888
  };
12319
11889
  };
12320
11890
  return {
@@ -12494,32 +12064,32 @@ function _typeof(o) {
12494
12064
  }, {
12495
12065
  key: "parseAsync",
12496
12066
  value: function() {
12497
- var _parseAsync2 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee5(data, params) {
12067
+ var _parseAsync2 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee2(data, params) {
12498
12068
  var result;
12499
- return _regeneratorRuntime().wrap((function _callee5$(_context5) {
12500
- while (1) switch (_context5.prev = _context5.next) {
12069
+ return _regeneratorRuntime().wrap((function _callee2$(_context2) {
12070
+ while (1) switch (_context2.prev = _context2.next) {
12501
12071
  case 0:
12502
- _context5.next = 2;
12072
+ _context2.next = 2;
12503
12073
  return this.safeParseAsync(data, params);
12504
12074
 
12505
12075
  case 2:
12506
- result = _context5.sent;
12076
+ result = _context2.sent;
12507
12077
  if (!result.success) {
12508
- _context5.next = 5;
12078
+ _context2.next = 5;
12509
12079
  break;
12510
12080
  }
12511
- return _context5.abrupt("return", result.data);
12081
+ return _context2.abrupt("return", result.data);
12512
12082
 
12513
12083
  case 5:
12514
12084
  throw result.error;
12515
12085
 
12516
12086
  case 6:
12517
12087
  case "end":
12518
- return _context5.stop();
12088
+ return _context2.stop();
12519
12089
  }
12520
- }), _callee5, this);
12090
+ }), _callee2, this);
12521
12091
  })));
12522
- function parseAsync(_x10, _x11) {
12092
+ function parseAsync(_x4, _x5) {
12523
12093
  return _parseAsync2.apply(this, arguments);
12524
12094
  }
12525
12095
  return parseAsync;
@@ -12527,10 +12097,10 @@ function _typeof(o) {
12527
12097
  }, {
12528
12098
  key: "safeParseAsync",
12529
12099
  value: function() {
12530
- var _safeParseAsync = _asyncToGenerator(_regeneratorRuntime().mark((function _callee6(data, params) {
12100
+ var _safeParseAsync = _asyncToGenerator(_regeneratorRuntime().mark((function _callee3(data, params) {
12531
12101
  var ctx, maybeAsyncResult, result;
12532
- return _regeneratorRuntime().wrap((function _callee6$(_context6) {
12533
- while (1) switch (_context6.prev = _context6.next) {
12102
+ return _regeneratorRuntime().wrap((function _callee3$(_context3) {
12103
+ while (1) switch (_context3.prev = _context3.next) {
12534
12104
  case 0:
12535
12105
  ctx = {
12536
12106
  common: {
@@ -12549,20 +12119,20 @@ function _typeof(o) {
12549
12119
  path: ctx.path,
12550
12120
  parent: ctx
12551
12121
  });
12552
- _context6.next = 4;
12122
+ _context3.next = 4;
12553
12123
  return isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult);
12554
12124
 
12555
12125
  case 4:
12556
- result = _context6.sent;
12557
- return _context6.abrupt("return", handleResult(ctx, result));
12126
+ result = _context3.sent;
12127
+ return _context3.abrupt("return", handleResult(ctx, result));
12558
12128
 
12559
12129
  case 6:
12560
12130
  case "end":
12561
- return _context6.stop();
12131
+ return _context3.stop();
12562
12132
  }
12563
- }), _callee6, this);
12133
+ }), _callee3, this);
12564
12134
  })));
12565
- function safeParseAsync(_x12, _x13) {
12135
+ function safeParseAsync(_x6, _x7) {
12566
12136
  return _safeParseAsync.apply(this, arguments);
12567
12137
  }
12568
12138
  return safeParseAsync;
@@ -14721,32 +14291,32 @@ function _typeof(o) {
14721
14291
  }
14722
14292
  }
14723
14293
  if (ctx.common.async) {
14724
- return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function _callee7() {
14294
+ return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function _callee4() {
14725
14295
  var syncPairs, _iterator24, _step24, pair, _key4, _value8;
14726
- return _regeneratorRuntime().wrap((function _callee7$(_context7) {
14727
- while (1) switch (_context7.prev = _context7.next) {
14296
+ return _regeneratorRuntime().wrap((function _callee4$(_context4) {
14297
+ while (1) switch (_context4.prev = _context4.next) {
14728
14298
  case 0:
14729
14299
  syncPairs = [];
14730
14300
  _iterator24 = _createForOfIteratorHelper(pairs);
14731
- _context7.prev = 2;
14301
+ _context4.prev = 2;
14732
14302
  _iterator24.s();
14733
14303
 
14734
14304
  case 4:
14735
14305
  if ((_step24 = _iterator24.n()).done) {
14736
- _context7.next = 15;
14306
+ _context4.next = 15;
14737
14307
  break;
14738
14308
  }
14739
14309
  pair = _step24.value;
14740
- _context7.next = 8;
14310
+ _context4.next = 8;
14741
14311
  return pair.key;
14742
14312
 
14743
14313
  case 8:
14744
- _key4 = _context7.sent;
14745
- _context7.next = 11;
14314
+ _key4 = _context4.sent;
14315
+ _context4.next = 11;
14746
14316
  return pair.value;
14747
14317
 
14748
14318
  case 11:
14749
- _value8 = _context7.sent;
14319
+ _value8 = _context4.sent;
14750
14320
  syncPairs.push({
14751
14321
  key: _key4,
14752
14322
  value: _value8,
@@ -14754,31 +14324,31 @@ function _typeof(o) {
14754
14324
  });
14755
14325
 
14756
14326
  case 13:
14757
- _context7.next = 4;
14327
+ _context4.next = 4;
14758
14328
  break;
14759
14329
 
14760
14330
  case 15:
14761
- _context7.next = 20;
14331
+ _context4.next = 20;
14762
14332
  break;
14763
14333
 
14764
14334
  case 17:
14765
- _context7.prev = 17;
14766
- _context7.t0 = _context7["catch"](2);
14767
- _iterator24.e(_context7.t0);
14335
+ _context4.prev = 17;
14336
+ _context4.t0 = _context4["catch"](2);
14337
+ _iterator24.e(_context4.t0);
14768
14338
 
14769
14339
  case 20:
14770
- _context7.prev = 20;
14340
+ _context4.prev = 20;
14771
14341
  _iterator24.f();
14772
- return _context7.finish(20);
14342
+ return _context4.finish(20);
14773
14343
 
14774
14344
  case 23:
14775
- return _context7.abrupt("return", syncPairs);
14345
+ return _context4.abrupt("return", syncPairs);
14776
14346
 
14777
14347
  case 24:
14778
14348
  case "end":
14779
- return _context7.stop();
14349
+ return _context4.stop();
14780
14350
  }
14781
- }), _callee7, null, [ [ 2, 17, 20, 23 ] ]);
14351
+ }), _callee4, null, [ [ 2, 17, 20, 23 ] ]);
14782
14352
  })))).then((function(syncPairs) {
14783
14353
  return ParseStatus.mergeObjectSync(status, syncPairs);
14784
14354
  }));
@@ -15054,10 +14624,10 @@ function _typeof(o) {
15054
14624
  }
15055
14625
  if (ctx.common.async) {
15056
14626
  return Promise.all(options.map(function() {
15057
- var _ref9 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee8(option) {
14627
+ var _ref4 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee5(option) {
15058
14628
  var childCtx;
15059
- return _regeneratorRuntime().wrap((function _callee8$(_context8) {
15060
- while (1) switch (_context8.prev = _context8.next) {
14629
+ return _regeneratorRuntime().wrap((function _callee5$(_context5) {
14630
+ while (1) switch (_context5.prev = _context5.next) {
15061
14631
  case 0:
15062
14632
  childCtx = _objectSpread(_objectSpread({}, ctx), {}, {
15063
14633
  common: _objectSpread(_objectSpread({}, ctx.common), {}, {
@@ -15065,7 +14635,7 @@ function _typeof(o) {
15065
14635
  }),
15066
14636
  parent: null
15067
14637
  });
15068
- _context8.next = 3;
14638
+ _context5.next = 3;
15069
14639
  return option._parseAsync({
15070
14640
  data: ctx.data,
15071
14641
  path: ctx.path,
@@ -15073,21 +14643,21 @@ function _typeof(o) {
15073
14643
  });
15074
14644
 
15075
14645
  case 3:
15076
- _context8.t0 = _context8.sent;
15077
- _context8.t1 = childCtx;
15078
- return _context8.abrupt("return", {
15079
- result: _context8.t0,
15080
- ctx: _context8.t1
14646
+ _context5.t0 = _context5.sent;
14647
+ _context5.t1 = childCtx;
14648
+ return _context5.abrupt("return", {
14649
+ result: _context5.t0,
14650
+ ctx: _context5.t1
15081
14651
  });
15082
14652
 
15083
14653
  case 6:
15084
14654
  case "end":
15085
- return _context8.stop();
14655
+ return _context5.stop();
15086
14656
  }
15087
- }), _callee8);
14657
+ }), _callee5);
15088
14658
  })));
15089
- return function(_x14) {
15090
- return _ref9.apply(this, arguments);
14659
+ return function(_x8) {
14660
+ return _ref4.apply(this, arguments);
15091
14661
  };
15092
14662
  }())).then(handleResults);
15093
14663
  } else {
@@ -15389,8 +14959,8 @@ function _typeof(o) {
15389
14959
  data: ctx.data,
15390
14960
  path: ctx.path,
15391
14961
  parent: ctx
15392
- }) ]).then((function(_ref0) {
15393
- var _ref1 = _slicedToArray(_ref0, 2), left = _ref1[0], right = _ref1[1];
14962
+ }) ]).then((function(_ref5) {
14963
+ var _ref6 = _slicedToArray(_ref5, 2), left = _ref6[0], right = _ref6[1];
15394
14964
  return handleParsed(left, right);
15395
14965
  }));
15396
14966
  } else {
@@ -15523,8 +15093,8 @@ function _typeof(o) {
15523
15093
  }
15524
15094
  var keyType = this._def.keyType;
15525
15095
  var valueType = this._def.valueType;
15526
- var pairs = _toConsumableArray(ctx.data.entries()).map((function(_ref10, index) {
15527
- var _ref11 = _slicedToArray(_ref10, 2), key = _ref11[0], value = _ref11[1];
15096
+ var pairs = _toConsumableArray(ctx.data.entries()).map((function(_ref7, index) {
15097
+ var _ref8 = _slicedToArray(_ref7, 2), key = _ref8[0], value = _ref8[1];
15528
15098
  return {
15529
15099
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [ index, "key" ])),
15530
15100
  value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [ index, "value" ]))
@@ -15532,36 +15102,36 @@ function _typeof(o) {
15532
15102
  }));
15533
15103
  if (ctx.common.async) {
15534
15104
  var finalMap = new Map;
15535
- return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function _callee9() {
15105
+ return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function _callee6() {
15536
15106
  var _iterator35, _step35, pair, key, _value1;
15537
- return _regeneratorRuntime().wrap((function _callee9$(_context9) {
15538
- while (1) switch (_context9.prev = _context9.next) {
15107
+ return _regeneratorRuntime().wrap((function _callee6$(_context6) {
15108
+ while (1) switch (_context6.prev = _context6.next) {
15539
15109
  case 0:
15540
15110
  _iterator35 = _createForOfIteratorHelper(pairs);
15541
- _context9.prev = 1;
15111
+ _context6.prev = 1;
15542
15112
  _iterator35.s();
15543
15113
 
15544
15114
  case 3:
15545
15115
  if ((_step35 = _iterator35.n()).done) {
15546
- _context9.next = 17;
15116
+ _context6.next = 17;
15547
15117
  break;
15548
15118
  }
15549
15119
  pair = _step35.value;
15550
- _context9.next = 7;
15120
+ _context6.next = 7;
15551
15121
  return pair.key;
15552
15122
 
15553
15123
  case 7:
15554
- key = _context9.sent;
15555
- _context9.next = 10;
15124
+ key = _context6.sent;
15125
+ _context6.next = 10;
15556
15126
  return pair.value;
15557
15127
 
15558
15128
  case 10:
15559
- _value1 = _context9.sent;
15129
+ _value1 = _context6.sent;
15560
15130
  if (!(key.status === "aborted" || _value1.status === "aborted")) {
15561
- _context9.next = 13;
15131
+ _context6.next = 13;
15562
15132
  break;
15563
15133
  }
15564
- return _context9.abrupt("return", INVALID);
15134
+ return _context6.abrupt("return", INVALID);
15565
15135
 
15566
15136
  case 13:
15567
15137
  if (key.status === "dirty" || _value1.status === "dirty") {
@@ -15570,34 +15140,34 @@ function _typeof(o) {
15570
15140
  finalMap.set(key.value, _value1.value);
15571
15141
 
15572
15142
  case 15:
15573
- _context9.next = 3;
15143
+ _context6.next = 3;
15574
15144
  break;
15575
15145
 
15576
15146
  case 17:
15577
- _context9.next = 22;
15147
+ _context6.next = 22;
15578
15148
  break;
15579
15149
 
15580
15150
  case 19:
15581
- _context9.prev = 19;
15582
- _context9.t0 = _context9["catch"](1);
15583
- _iterator35.e(_context9.t0);
15151
+ _context6.prev = 19;
15152
+ _context6.t0 = _context6["catch"](1);
15153
+ _iterator35.e(_context6.t0);
15584
15154
 
15585
15155
  case 22:
15586
- _context9.prev = 22;
15156
+ _context6.prev = 22;
15587
15157
  _iterator35.f();
15588
- return _context9.finish(22);
15158
+ return _context6.finish(22);
15589
15159
 
15590
15160
  case 25:
15591
- return _context9.abrupt("return", {
15161
+ return _context6.abrupt("return", {
15592
15162
  status: status.value,
15593
15163
  value: finalMap
15594
15164
  });
15595
15165
 
15596
15166
  case 26:
15597
15167
  case "end":
15598
- return _context9.stop();
15168
+ return _context6.stop();
15599
15169
  }
15600
- }), _callee9, null, [ [ 1, 19, 22, 25 ] ]);
15170
+ }), _callee6, null, [ [ 1, 19, 22, 25 ] ]);
15601
15171
  }))));
15602
15172
  } else {
15603
15173
  var _finalMap = new Map;
@@ -16058,19 +15628,19 @@ function _typeof(o) {
16058
15628
  var processed = effect.transform(ctx.data, checkCtx);
16059
15629
  if (ctx.common.async) {
16060
15630
  return Promise.resolve(processed).then(function() {
16061
- var _ref13 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee0(processed) {
15631
+ var _ref0 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee7(processed) {
16062
15632
  var result;
16063
- return _regeneratorRuntime().wrap((function _callee0$(_context0) {
16064
- while (1) switch (_context0.prev = _context0.next) {
15633
+ return _regeneratorRuntime().wrap((function _callee7$(_context7) {
15634
+ while (1) switch (_context7.prev = _context7.next) {
16065
15635
  case 0:
16066
15636
  if (!(status.value === "aborted")) {
16067
- _context0.next = 2;
15637
+ _context7.next = 2;
16068
15638
  break;
16069
15639
  }
16070
- return _context0.abrupt("return", INVALID);
15640
+ return _context7.abrupt("return", INVALID);
16071
15641
 
16072
15642
  case 2:
16073
- _context0.next = 4;
15643
+ _context7.next = 4;
16074
15644
  return _this14._def.schema._parseAsync({
16075
15645
  data: processed,
16076
15646
  path: ctx.path,
@@ -16078,38 +15648,38 @@ function _typeof(o) {
16078
15648
  });
16079
15649
 
16080
15650
  case 4:
16081
- result = _context0.sent;
15651
+ result = _context7.sent;
16082
15652
  if (!(result.status === "aborted")) {
16083
- _context0.next = 7;
15653
+ _context7.next = 7;
16084
15654
  break;
16085
15655
  }
16086
- return _context0.abrupt("return", INVALID);
15656
+ return _context7.abrupt("return", INVALID);
16087
15657
 
16088
15658
  case 7:
16089
15659
  if (!(result.status === "dirty")) {
16090
- _context0.next = 9;
15660
+ _context7.next = 9;
16091
15661
  break;
16092
15662
  }
16093
- return _context0.abrupt("return", DIRTY(result.value));
15663
+ return _context7.abrupt("return", DIRTY(result.value));
16094
15664
 
16095
15665
  case 9:
16096
15666
  if (!(status.value === "dirty")) {
16097
- _context0.next = 11;
15667
+ _context7.next = 11;
16098
15668
  break;
16099
15669
  }
16100
- return _context0.abrupt("return", DIRTY(result.value));
15670
+ return _context7.abrupt("return", DIRTY(result.value));
16101
15671
 
16102
15672
  case 11:
16103
- return _context0.abrupt("return", result);
15673
+ return _context7.abrupt("return", result);
16104
15674
 
16105
15675
  case 12:
16106
15676
  case "end":
16107
- return _context0.stop();
15677
+ return _context7.stop();
16108
15678
  }
16109
- }), _callee0);
15679
+ }), _callee7);
16110
15680
  })));
16111
- return function(_x15) {
16112
- return _ref13.apply(this, arguments);
15681
+ return function(_x9) {
15682
+ return _ref0.apply(this, arguments);
16113
15683
  };
16114
15684
  }());
16115
15685
  } else {
@@ -16440,12 +16010,12 @@ function _typeof(o) {
16440
16010
  var _this$_processInputPa13 = this._processInputParams(input), status = _this$_processInputPa13.status, ctx = _this$_processInputPa13.ctx;
16441
16011
  if (ctx.common.async) {
16442
16012
  var handleAsync = function() {
16443
- var _ref14 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee1() {
16013
+ var _ref1 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee8() {
16444
16014
  var inResult;
16445
- return _regeneratorRuntime().wrap((function _callee1$(_context1) {
16446
- while (1) switch (_context1.prev = _context1.next) {
16015
+ return _regeneratorRuntime().wrap((function _callee8$(_context8) {
16016
+ while (1) switch (_context8.prev = _context8.next) {
16447
16017
  case 0:
16448
- _context1.next = 2;
16018
+ _context8.next = 2;
16449
16019
  return _this16._def["in"]._parseAsync({
16450
16020
  data: ctx.data,
16451
16021
  path: ctx.path,
@@ -16453,23 +16023,23 @@ function _typeof(o) {
16453
16023
  });
16454
16024
 
16455
16025
  case 2:
16456
- inResult = _context1.sent;
16026
+ inResult = _context8.sent;
16457
16027
  if (!(inResult.status === "aborted")) {
16458
- _context1.next = 5;
16028
+ _context8.next = 5;
16459
16029
  break;
16460
16030
  }
16461
- return _context1.abrupt("return", INVALID);
16031
+ return _context8.abrupt("return", INVALID);
16462
16032
 
16463
16033
  case 5:
16464
16034
  if (!(inResult.status === "dirty")) {
16465
- _context1.next = 10;
16035
+ _context8.next = 10;
16466
16036
  break;
16467
16037
  }
16468
16038
  status.dirty();
16469
- return _context1.abrupt("return", DIRTY(inResult.value));
16039
+ return _context8.abrupt("return", DIRTY(inResult.value));
16470
16040
 
16471
16041
  case 10:
16472
- return _context1.abrupt("return", _this16._def.out._parseAsync({
16042
+ return _context8.abrupt("return", _this16._def.out._parseAsync({
16473
16043
  data: inResult.value,
16474
16044
  path: ctx.path,
16475
16045
  parent: ctx
@@ -16477,12 +16047,12 @@ function _typeof(o) {
16477
16047
 
16478
16048
  case 11:
16479
16049
  case "end":
16480
- return _context1.stop();
16050
+ return _context8.stop();
16481
16051
  }
16482
- }), _callee1);
16052
+ }), _callee8);
16483
16053
  })));
16484
16054
  return function handleAsync() {
16485
- return _ref14.apply(this, arguments);
16055
+ return _ref1.apply(this, arguments);
16486
16056
  };
16487
16057
  }();
16488
16058
  return handleAsync();
@@ -16607,52 +16177,79 @@ function _typeof(o) {
16607
16177
  ZodOptional.create;
16608
16178
  ZodNullable.create;
16609
16179
  var preprocessType = ZodEffects.createWithPreprocess;
16610
- var farcasterSchema = objectType({
16611
- platform: literalType("farcaster"),
16612
- contentType: enumType([ "posts", "replies", "channels" ]),
16613
- identifier: stringType().nonempty(),
16614
- start: numberType()["int"]().nonnegative()["default"](0),
16615
- end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16616
- message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16617
- })["default"](10)
16618
- });
16619
- var lensSchema = objectType({
16620
- platform: literalType("lens"),
16621
- contentType: enumType([ "posts", "replies" ]),
16622
- identifier: stringType().nonempty(),
16623
- start: numberType()["int"]().nonnegative()["default"](0),
16624
- end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16625
- message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16626
- })["default"](10)
16627
- });
16628
- var fireflyParamsSchema = discriminatedUnionType("platform", [ farcasterSchema, lensSchema ]);
16629
- var fireFlyPlaformType = {
16630
- farcaster: {
16631
- posts: "farcasterid",
16632
- replies: "farcasterpostid",
16633
- channels: "farcasterchannels"
16634
- },
16635
- lens: {
16636
- posts: "lensid",
16637
- replies: "lenspostid"
16638
- }
16639
- };
16640
- var lensParamsSchema = objectType({
16641
- contentType: enumType([ "posts", "replies" ]),
16642
- identifier: stringType().nonempty(),
16643
- start: numberType()["int"]().nonnegative()["default"](0),
16644
- end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16645
- message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16646
- })["default"](10)
16647
- });
16648
- var farcasterParamsSchema = objectType({
16649
- contentType: enumType([ "posts", "replies", "channels" ]),
16650
- identifier: stringType().nonempty(),
16651
- start: numberType()["int"]().nonnegative()["default"](0),
16652
- end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16653
- message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16654
- })["default"](10)
16180
+ var aaveParamsSchema = objectType({
16181
+ graphType: enumType([ "v2", "v2-raw" ]),
16182
+ category: enumType([ "tokens", "markets" ]),
16183
+ param1: stringType().nonempty(),
16184
+ param2: stringType().optional()
16655
16185
  });
16186
+ function AAVE() {
16187
+ return _AAVE.apply(this, arguments);
16188
+ }
16189
+ function _AAVE() {
16190
+ _AAVE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee10() {
16191
+ var _argsToArray3, _argsToArray4, graphType, category, param1, param2, baseUrl, url, res, json, _args10 = arguments;
16192
+ return _regeneratorRuntime().wrap((function _callee10$(_context10) {
16193
+ while (1) switch (_context10.prev = _context10.next) {
16194
+ case 0:
16195
+ _context10.prev = 0;
16196
+ _argsToArray3 = argsToArray(_args10), _argsToArray4 = _slicedToArray(_argsToArray3, 4),
16197
+ graphType = _argsToArray4[0], category = _argsToArray4[1], param1 = _argsToArray4[2],
16198
+ param2 = _argsToArray4[3];
16199
+ validateParams(aaveParamsSchema, {
16200
+ graphType: graphType,
16201
+ category: category,
16202
+ param1: param1,
16203
+ param2: param2
16204
+ });
16205
+ baseUrl = "https://onchain-proxy.fileverse.io/third-party";
16206
+ url = "".concat(baseUrl) + "?service=aave" + "&graphType=".concat(encodeURIComponent(graphType)) + "&category=".concat(encodeURIComponent(category)) + "&input1=".concat(encodeURIComponent(param1)) + (param2 ? "&input2=".concat(encodeURIComponent(param2)) : "");
16207
+ _context10.next = 7;
16208
+ return fetch(url);
16209
+
16210
+ case 7:
16211
+ res = _context10.sent;
16212
+ if (res.ok) {
16213
+ _context10.next = 10;
16214
+ break;
16215
+ }
16216
+ throw new NetworkError("AAVE", res.status);
16217
+
16218
+ case 10:
16219
+ _context10.next = 12;
16220
+ return res.json();
16221
+
16222
+ case 12:
16223
+ json = _context10.sent;
16224
+ if (!Array.isArray(json)) {
16225
+ _context10.next = 15;
16226
+ break;
16227
+ }
16228
+ return _context10.abrupt("return", json.map((function(item) {
16229
+ var flat = {};
16230
+ Object.entries(item).forEach((function(_ref15) {
16231
+ var _ref16 = _slicedToArray(_ref15, 2), k = _ref16[0], v = _ref16[1];
16232
+ if (v === null || _typeof(v) !== "object") flat[k] = v;
16233
+ }));
16234
+ return flat;
16235
+ })));
16236
+
16237
+ case 15:
16238
+ return _context10.abrupt("return", json);
16239
+
16240
+ case 18:
16241
+ _context10.prev = 18;
16242
+ _context10.t0 = _context10["catch"](0);
16243
+ return _context10.abrupt("return", errorMessageHandler(_context10.t0, "AAVE"));
16244
+
16245
+ case 21:
16246
+ case "end":
16247
+ return _context10.stop();
16248
+ }
16249
+ }), _callee10, null, [ [ 0, 18 ] ]);
16250
+ })));
16251
+ return _AAVE.apply(this, arguments);
16252
+ }
16656
16253
  var dateStringToTimestamp = function dateStringToTimestamp(val) {
16657
16254
  var _val$split = val.split("/"), _val$split2 = _slicedToArray(_val$split, 3), dd = _val$split2[0], mm = _val$split2[1], yyyy = _val$split2[2];
16658
16255
  var date = new Date("".concat(yyyy, "-").concat(mm.padStart(2, "0"), "-").concat(dd.padStart(2, "0")));
@@ -16668,94 +16265,6 @@ function _typeof(o) {
16668
16265
  }), {
16669
16266
  message: "Invalid date format or value: expected DD/MM/YYYY"
16670
16267
  }));
16671
- var blockscoutParamsSchema = objectType({
16672
- address: stringType().nonempty(),
16673
- type: enumType([ "stat", "txns", "tokens" ]),
16674
- chain: enumType([ "ethereum", "gnosis", "arbitrum", "optimism", "soneium", "unichain" ])["default"]("ethereum"),
16675
- startTimestamp: dateOrTimestamp.optional(),
16676
- endTimestamp: dateOrTimestamp.optional(),
16677
- page: numberType()["int"]().nonnegative()["default"](1),
16678
- offset: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16679
- message: '"offset" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16680
- })["default"](10)
16681
- });
16682
- var gasSchema$1 = objectType({
16683
- type: literalType("gas"),
16684
- startDate: dateOrTimestamp.optional(),
16685
- endDate: dateOrTimestamp.optional(),
16686
- page: numberType()["int"]().nonnegative()["default"](1),
16687
- limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16688
- message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16689
- })["default"](10)
16690
- });
16691
- var txnSchema$1 = objectType({
16692
- type: enumType([ "all-txns", "token-txns", "nft-txns" ]),
16693
- address: stringType().nonempty(),
16694
- startDate: dateOrTimestamp.optional(),
16695
- endDate: dateOrTimestamp.optional(),
16696
- page: numberType()["int"]().nonnegative()["default"](1),
16697
- limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16698
- message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16699
- })["default"](10)
16700
- });
16701
- var baseParamsSchema = discriminatedUnionType("type", [ gasSchema$1, txnSchema$1 ]);
16702
- var gasSchema = objectType({
16703
- type: literalType("gas"),
16704
- startDate: dateOrTimestamp.optional(),
16705
- endDate: dateOrTimestamp.optional(),
16706
- page: numberType()["int"]().nonnegative()["default"](1),
16707
- limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16708
- message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16709
- })["default"](10)
16710
- });
16711
- var txnSchema = objectType({
16712
- type: enumType([ "all-txns", "token-txns", "nft-txns" ]),
16713
- address: stringType().nonempty(),
16714
- startDate: dateOrTimestamp.optional(),
16715
- endDate: dateOrTimestamp.optional(),
16716
- chain: enumType([ "ethereum", "base", "gnosis" ]),
16717
- page: numberType()["int"]().nonnegative()["default"](1),
16718
- limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16719
- message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16720
- })["default"](10)
16721
- });
16722
- var etherscanParamsSchema = discriminatedUnionType("type", [ gasSchema, txnSchema ]);
16723
- var allowedValues = [ "1h", "24h", "7d" ];
16724
- var param2Schema = stringType().refine((function(val) {
16725
- var tokens = val.split(",").map((function(t) {
16726
- return t.trim().toLowerCase();
16727
- }));
16728
- return tokens.some((function(token) {
16729
- return allowedValues.some((function(allowed) {
16730
- return token.includes(allowed);
16731
- }));
16732
- }));
16733
- }), {
16734
- message: "param2 must contain at least one of: '1h', '24h', '7d'"
16735
- }).optional();
16736
- var priceSchema = objectType({
16737
- category: literalType("price"),
16738
- param1: stringType().nonempty(),
16739
- param2: stringType().nonempty().optional()
16740
- });
16741
- var marketEcosystems = [ "all", "base", "meme", "aiagents", "bitcoin", "ethereum", "hyperliquid", "pump", "solana" ];
16742
- var marketSchema = objectType({
16743
- category: literalType("market"),
16744
- param1: enumType(marketEcosystems),
16745
- param2: param2Schema
16746
- });
16747
- var stablecoinsTypes = [ "all", "yield-bearing-stablecoins", "crypto-backed-stablecoin" ];
16748
- var stablecoinsSchema = objectType({
16749
- category: literalType("stablecoins"),
16750
- param1: enumType(stablecoinsTypes),
16751
- param2: param2Schema
16752
- });
16753
- var derivativesSchema = objectType({
16754
- category: literalType("derivatives"),
16755
- param1: stringType().nonempty(),
16756
- param2: anyType().optional()
16757
- });
16758
- var coingeckoParamsSchema = discriminatedUnionType("category", [ priceSchema, marketSchema, stablecoinsSchema, derivativesSchema ]);
16759
16268
  var baseSchema = objectType({
16760
16269
  addresses: stringType().nonempty(),
16761
16270
  category: enumType([ "balance", "txns" ]),
@@ -16784,640 +16293,791 @@ function _typeof(o) {
16784
16293
  }
16785
16294
  return true;
16786
16295
  }), {
16787
- message: "startTime and endTime required for txns",
16788
- path: [ "startTime" ]
16789
- }));
16790
- var safeParamsSchema = objectType({
16791
- address: stringType().nonempty(),
16792
- utility: literalType("txns"),
16793
- chain: enumType([ "ethereum", "gnosis" ]),
16794
- limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16795
- message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16796
- })["default"](10),
16797
- offset: numberType()["int"]().nonnegative()["default"](0)
16798
- });
16799
- var categories = [ "protocols", "yields", "dex", "fees" ];
16800
- var defillamaParamsSchema = objectType({
16801
- category: enumType(categories)
16802
- });
16803
- var CATEGORY_URLS = {
16804
- protocols: "https://api.llama.fi/protocols",
16805
- yields: "https://yields.llama.fi/pools",
16806
- dex: "https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true",
16807
- fees: "https://api.llama.fi/overview/fees?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true&dataType=dailyFees"
16808
- };
16809
- var uniswapParamsSchema = objectType({
16810
- graphType: enumType([ "v3", "v3-raw" ]),
16811
- category: enumType([ "tokens", "markets" ]),
16812
- param1: stringType().nonempty(),
16813
- param2: stringType().optional()
16814
- });
16815
- var aaveParamsSchema = objectType({
16816
- graphType: enumType([ "v2", "v2-raw" ]),
16817
- category: enumType([ "tokens", "markets" ]),
16818
- param1: stringType().nonempty(),
16819
- param2: stringType().optional()
16820
- });
16821
- function FIREFLY() {
16822
- return _FIREFLY.apply(this, arguments);
16823
- }
16824
- function _FIREFLY() {
16825
- _FIREFLY = _asyncToGenerator(_regeneratorRuntime().mark((function _callee12() {
16826
- var _argsToArray3, _argsToArray4, platform, contentType, identifier, _argsToArray4$, start, _argsToArray4$2, end, apiKey, url, _getUrlAndHeaders4, finalUrl, HEADERS, response, _yield$response$json, _data, _args12 = arguments;
16827
- return _regeneratorRuntime().wrap((function _callee12$(_context12) {
16828
- while (1) switch (_context12.prev = _context12.next) {
16829
- case 0:
16830
- _context12.prev = 0;
16831
- _argsToArray3 = argsToArray(_args12), _argsToArray4 = _slicedToArray(_argsToArray3, 5),
16832
- platform = _argsToArray4[0], contentType = _argsToArray4[1], identifier = _argsToArray4[2],
16833
- _argsToArray4$ = _argsToArray4[3], start = _argsToArray4$ === void 0 ? 0 : _argsToArray4$,
16834
- _argsToArray4$2 = _argsToArray4[4], end = _argsToArray4$2 === void 0 ? 10 : _argsToArray4$2;
16835
- validateParams(fireflyParamsSchema, {
16836
- platform: platform,
16837
- contentType: contentType,
16838
- identifier: identifier,
16839
- start: start,
16840
- end: end
16841
- });
16842
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
16843
- url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
16844
- url.searchParams.set("query", identifier.split(",").map((function(s) {
16845
- return s.trim();
16846
- })).filter(Boolean).join(","));
16847
- url.searchParams.set("type", fireFlyPlaformType[platform][contentType]);
16848
- url.searchParams.set("start", String(start));
16849
- url.searchParams.set("end", String(end));
16850
- _getUrlAndHeaders4 = getUrlAndHeaders({
16851
- url: url.toString(),
16852
- serviceName: "Firefly",
16853
- headers: {
16854
- "x-api-key": apiKey
16855
- }
16856
- }), finalUrl = _getUrlAndHeaders4.URL, HEADERS = _getUrlAndHeaders4.HEADERS;
16857
- _context12.next = 12;
16858
- return fetch(finalUrl, {
16859
- method: "GET",
16860
- headers: HEADERS
16861
- });
16296
+ message: "startTime and endTime required for txns",
16297
+ path: [ "startTime" ]
16298
+ }));
16299
+ var isAddress = function isAddress(input) {
16300
+ return /^0x[a-fA-F0-9]{40}$/.test(input);
16301
+ };
16302
+ var isAddress$1 = {
16303
+ isAddress: isAddress
16304
+ };
16305
+ function fromEnsNameToAddress(_x0) {
16306
+ return _fromEnsNameToAddress.apply(this, arguments);
16307
+ }
16308
+ function _fromEnsNameToAddress() {
16309
+ _fromEnsNameToAddress = _asyncToGenerator(_regeneratorRuntime().mark((function _callee11(name) {
16310
+ var ALCHEMY_KEY, provider, resolved;
16311
+ return _regeneratorRuntime().wrap((function _callee11$(_context11) {
16312
+ while (1) switch (_context11.prev = _context11.next) {
16313
+ case 0:
16314
+ if (!(typeof ethers === "undefined")) {
16315
+ _context11.next = 3;
16316
+ break;
16317
+ }
16318
+ _context11.next = 3;
16319
+ return new Promise((function(resolve, reject) {
16320
+ var script = document.createElement("script");
16321
+ script.src = "https://cdn.jsdelivr.net/npm/ethers@6.10.0/dist/ethers.umd.min.js";
16322
+ script.onload = resolve;
16323
+ script.onerror = reject;
16324
+ document.head.appendChild(script);
16325
+ }));
16862
16326
 
16863
- case 12:
16864
- response = _context12.sent;
16865
- if (response.ok) {
16866
- _context12.next = 15;
16327
+ case 3:
16328
+ ALCHEMY_KEY = window.localStorage.getItem(UTILITY.ALCHEMY_API_KEY);
16329
+ if (ALCHEMY_KEY) {
16330
+ _context11.next = 7;
16867
16331
  break;
16868
16332
  }
16869
- throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
16333
+ console.error("alchemy api key missing");
16334
+ return _context11.abrupt("return", null);
16335
+
16336
+ case 7:
16337
+ provider = new ethers.AlchemyProvider("mainnet", ALCHEMY_KEY);
16338
+ _context11.prev = 8;
16339
+ _context11.next = 11;
16340
+ return provider.resolveName(name);
16341
+
16342
+ case 11:
16343
+ resolved = _context11.sent;
16344
+ return _context11.abrupt("return", resolved || null);
16870
16345
 
16871
16346
  case 15:
16872
- _context12.next = 17;
16873
- return response.json();
16347
+ _context11.prev = 15;
16348
+ _context11.t0 = _context11["catch"](8);
16349
+ console.error("ENS resolution failed:", _context11.t0.message);
16350
+ return _context11.abrupt("return", null);
16874
16351
 
16875
- case 17:
16876
- _yield$response$json = _context12.sent;
16877
- _data = _yield$response$json.data;
16878
- if (Array.isArray(_data)) {
16879
- _context12.next = 21;
16352
+ case 19:
16353
+ case "end":
16354
+ return _context11.stop();
16355
+ }
16356
+ }), _callee11, null, [ [ 8, 15 ] ]);
16357
+ })));
16358
+ return _fromEnsNameToAddress.apply(this, arguments);
16359
+ }
16360
+ var validateAndGetAddress = function() {
16361
+ var _ref10 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee9(address) {
16362
+ var resolvedAddress;
16363
+ return _regeneratorRuntime().wrap((function _callee9$(_context9) {
16364
+ while (1) switch (_context9.prev = _context9.next) {
16365
+ case 0:
16366
+ if (!isAddress$1.isAddress(address)) {
16367
+ _context9.next = 2;
16880
16368
  break;
16881
16369
  }
16882
- return _context12.abrupt("return", []);
16370
+ return _context9.abrupt("return", address);
16883
16371
 
16884
- case 21:
16885
- return _context12.abrupt("return", _data.map((function(item) {
16886
- var flat = {};
16887
- for (var _i10 = 0, _Object$entries = Object.entries(item); _i10 < _Object$entries.length; _i10++) {
16888
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i10], 2), key = _Object$entries$_i[0], _value11 = _Object$entries$_i[1];
16889
- if (_typeof(_value11) !== "object" || _value11 === null) {
16890
- flat[key] = _value11;
16891
- }
16892
- }
16893
- flat.platform = platform;
16894
- return flat;
16895
- })));
16372
+ case 2:
16373
+ _context9.next = 4;
16374
+ return fromEnsNameToAddress(address);
16896
16375
 
16897
- case 24:
16898
- _context12.prev = 24;
16899
- _context12.t0 = _context12["catch"](0);
16900
- return _context12.abrupt("return", errorMessageHandler(_context12.t0, "FIREFLY"));
16376
+ case 4:
16377
+ resolvedAddress = _context9.sent;
16378
+ if (!resolvedAddress) {
16379
+ _context9.next = 7;
16380
+ break;
16381
+ }
16382
+ return _context9.abrupt("return", resolvedAddress);
16901
16383
 
16902
- case 27:
16384
+ case 7:
16385
+ throw new ValidationError("Invalid address");
16386
+
16387
+ case 8:
16903
16388
  case "end":
16904
- return _context12.stop();
16389
+ return _context9.stop();
16905
16390
  }
16906
- }), _callee12, null, [ [ 0, 24 ] ]);
16391
+ }), _callee9);
16907
16392
  })));
16908
- return _FIREFLY.apply(this, arguments);
16393
+ return function validateAndGetAddress(_x1) {
16394
+ return _ref10.apply(this, arguments);
16395
+ };
16396
+ }();
16397
+ var fromEnsNameToAddress$1 = {
16398
+ validateAndGetAddress: validateAndGetAddress
16399
+ };
16400
+ var PROXY_MAP;
16401
+ function initializeProxyMap() {
16402
+ if (!PROXY_MAP) {
16403
+ var fileverseProxyUrl = "".concat(window.NEXT_PUBLIC_PROXY_BASE_URL, "/proxy");
16404
+ PROXY_MAP = {
16405
+ Etherscan: {
16406
+ url: fileverseProxyUrl,
16407
+ removeParams: [ "apikey" ]
16408
+ },
16409
+ Basescan: {
16410
+ url: fileverseProxyUrl,
16411
+ removeParams: [ "apikey" ]
16412
+ },
16413
+ Gnosisscan: {
16414
+ url: fileverseProxyUrl,
16415
+ removeParams: [ "apikey" ]
16416
+ },
16417
+ Coingecko: {
16418
+ url: fileverseProxyUrl,
16419
+ removeParams: [ "apikey" ]
16420
+ },
16421
+ Firefly: {
16422
+ url: fileverseProxyUrl,
16423
+ removeParams: [ "apikey" ]
16424
+ },
16425
+ Neynar: {
16426
+ url: fileverseProxyUrl,
16427
+ removeParams: [ "api_key" ]
16428
+ },
16429
+ Safe: {
16430
+ url: fileverseProxyUrl,
16431
+ removeParams: [ "api_key" ]
16432
+ },
16433
+ Defillama: {
16434
+ url: fileverseProxyUrl,
16435
+ removeParams: [ "api_key" ]
16436
+ },
16437
+ GnosisPay: {
16438
+ url: fileverseProxyUrl,
16439
+ removeParams: [ "api_key" ]
16440
+ }
16441
+ };
16442
+ }
16443
+ return PROXY_MAP;
16909
16444
  }
16910
- function LENS() {
16911
- return _LENS.apply(this, arguments);
16445
+ function removeUrlParams(url, paramsToRemove) {
16446
+ if (!paramsToRemove || paramsToRemove.length === 0) {
16447
+ return url;
16448
+ }
16449
+ var urlObj = new URL(url);
16450
+ paramsToRemove.forEach((function(param) {
16451
+ if (urlObj.searchParams.has(param)) {
16452
+ urlObj.searchParams["delete"](param);
16453
+ }
16454
+ }));
16455
+ return urlObj.toString();
16912
16456
  }
16913
- function _LENS() {
16914
- _LENS = _asyncToGenerator(_regeneratorRuntime().mark((function _callee13() {
16915
- var _argsToArray5, _argsToArray6, contentType, identifier, _argsToArray6$, start, _argsToArray6$2, end, apiKey, url, typeMap, _getUrlAndHeaders5, finalUrl, HEADERS, response, _yield$response$json2, _data2, _args13 = arguments;
16916
- return _regeneratorRuntime().wrap((function _callee13$(_context13) {
16917
- while (1) switch (_context13.prev = _context13.next) {
16457
+ function getUrlAndHeaders(_ref11) {
16458
+ var url = _ref11.url, serviceName = _ref11.serviceName, _ref11$headers = _ref11.headers, headers = _ref11$headers === void 0 ? {} : _ref11$headers;
16459
+ var proxyMap = initializeProxyMap();
16460
+ var apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
16461
+ var isProxyModeEnabledValue = apiKeyLS === "DEFAULT_PROXY_MODE";
16462
+ var proxyConfig = proxyMap[serviceName];
16463
+ if (!proxyConfig && SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === "")) {
16464
+ throw new MissingApiKeyError(SERVICES_API_KEY[serviceName]);
16465
+ }
16466
+ if ((isProxyModeEnabledValue || !apiKeyLS || apiKeyLS === "") && proxyConfig) {
16467
+ var cleanedUrl = removeUrlParams(url, proxyConfig.removeParams);
16468
+ return {
16469
+ URL: proxyConfig.url,
16470
+ HEADERS: {
16471
+ "target-url": cleanedUrl,
16472
+ method: "GET",
16473
+ "Content-Type": "application/json"
16474
+ }
16475
+ };
16476
+ }
16477
+ return {
16478
+ URL: url,
16479
+ HEADERS: _objectSpread({}, headers)
16480
+ };
16481
+ }
16482
+ var fromTimeStampToBlock = function() {
16483
+ var _ref12 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee0(timestamp, chain, apiKey) {
16484
+ var chainId, url, _getUrlAndHeaders, finalUrl, HEADERS, res, json;
16485
+ return _regeneratorRuntime().wrap((function _callee0$(_context0) {
16486
+ while (1) switch (_context0.prev = _context0.next) {
16918
16487
  case 0:
16919
- _context13.prev = 0;
16920
- _argsToArray5 = argsToArray(_args13), _argsToArray6 = _slicedToArray(_argsToArray5, 4),
16921
- contentType = _argsToArray6[0], identifier = _argsToArray6[1], _argsToArray6$ = _argsToArray6[2],
16922
- start = _argsToArray6$ === void 0 ? 0 : _argsToArray6$, _argsToArray6$2 = _argsToArray6[3],
16923
- end = _argsToArray6$2 === void 0 ? 10 : _argsToArray6$2;
16924
- validateParams(lensParamsSchema, {
16925
- contentType: contentType,
16926
- identifier: identifier,
16927
- start: start,
16928
- end: end
16929
- });
16930
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
16931
- url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
16932
- url.searchParams.set("query", identifier.split(",").map((function(s) {
16933
- return s.trim();
16934
- })).filter(Boolean).join(","));
16935
- typeMap = {
16936
- posts: "lensid",
16937
- replies: "lenspostid"
16938
- };
16939
- url.searchParams.set("type", typeMap[contentType]);
16940
- url.searchParams.set("start", String(start));
16941
- url.searchParams.set("end", String(end));
16942
- _getUrlAndHeaders5 = getUrlAndHeaders({
16943
- url: url.toString(),
16944
- serviceName: "Firefly",
16945
- headers: {
16946
- "x-api-key": apiKey
16947
- }
16948
- }), finalUrl = _getUrlAndHeaders5.URL, HEADERS = _getUrlAndHeaders5.HEADERS;
16949
- _context13.next = 13;
16488
+ if (!(!timestamp || !chain)) {
16489
+ _context0.next = 2;
16490
+ break;
16491
+ }
16492
+ return _context0.abrupt("return");
16493
+
16494
+ case 2:
16495
+ chainId = CHAIN_ID_MAP[chain];
16496
+ url = "https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=".concat(timestamp, "&closest=before&apikey=").concat(apiKey, "&chainId=").concat(chainId);
16497
+ _getUrlAndHeaders = getUrlAndHeaders({
16498
+ url: url,
16499
+ serviceName: "Etherscan",
16500
+ headers: {}
16501
+ }), finalUrl = _getUrlAndHeaders.URL, HEADERS = _getUrlAndHeaders.HEADERS;
16502
+ _context0.next = 7;
16950
16503
  return fetch(finalUrl, {
16951
16504
  method: "GET",
16952
16505
  headers: HEADERS
16953
16506
  });
16954
16507
 
16955
- case 13:
16956
- response = _context13.sent;
16957
- if (response.ok) {
16958
- _context13.next = 16;
16508
+ case 7:
16509
+ res = _context0.sent;
16510
+ _context0.next = 10;
16511
+ return res.json();
16512
+
16513
+ case 10:
16514
+ json = _context0.sent;
16515
+ return _context0.abrupt("return", parseInt(json.result));
16516
+
16517
+ case 12:
16518
+ case "end":
16519
+ return _context0.stop();
16520
+ }
16521
+ }), _callee0);
16522
+ })));
16523
+ return function fromTimeStampToBlock(_x10, _x11, _x12) {
16524
+ return _ref12.apply(this, arguments);
16525
+ };
16526
+ }();
16527
+ var fromTimestampToBlock = {
16528
+ fromTimeStampToBlock: fromTimeStampToBlock
16529
+ };
16530
+ function toTimestamp(dateStr) {
16531
+ var _dateStr$split$map = dateStr.split("/").map(Number), _dateStr$split$map2 = _slicedToArray(_dateStr$split$map, 3), day = _dateStr$split$map2[0], month = _dateStr$split$map2[1], year = _dateStr$split$map2[2];
16532
+ var date = new Date(year, month - 1, day);
16533
+ return Math.floor(date.getTime() / 1e3);
16534
+ }
16535
+ function EOA() {
16536
+ return _EOA.apply(this, arguments);
16537
+ }
16538
+ function _EOA() {
16539
+ _EOA = _asyncToGenerator(_regeneratorRuntime().mark((function _callee13() {
16540
+ var fetchJSON, _argsToArray5, _argsToArray6, addresses, category, chains, startTime, endTime, _argsToArray6$, page, _argsToArray6$2, offset, apiKey, INPUTS, CHAINS, ADDRESS_MAP, _iterator41, _step41, inp, _address, ADDRS, out, _iterator42, _step42, _loop, _ret, _args16 = arguments;
16541
+ return _regeneratorRuntime().wrap((function _callee13$(_context16) {
16542
+ while (1) switch (_context16.prev = _context16.next) {
16543
+ case 0:
16544
+ _context16.prev = 0;
16545
+ fetchJSON = function() {
16546
+ var _ref17 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee12(url) {
16547
+ var _getUrlAndHeaders3, finalUrl, HEADERS, res, json;
16548
+ return _regeneratorRuntime().wrap((function _callee12$(_context12) {
16549
+ while (1) switch (_context12.prev = _context12.next) {
16550
+ case 0:
16551
+ _getUrlAndHeaders3 = getUrlAndHeaders({
16552
+ url: url,
16553
+ serviceName: "Etherscan",
16554
+ headers: {}
16555
+ }), finalUrl = _getUrlAndHeaders3.URL, HEADERS = _getUrlAndHeaders3.HEADERS;
16556
+ _context12.next = 3;
16557
+ return fetch(finalUrl, {
16558
+ method: "GET",
16559
+ headers: HEADERS
16560
+ });
16561
+
16562
+ case 3:
16563
+ res = _context12.sent;
16564
+ if (res.ok) {
16565
+ _context12.next = 6;
16566
+ break;
16567
+ }
16568
+ throw new NetworkError(SERVICES_API_KEY.Etherscan, res.status);
16569
+
16570
+ case 6:
16571
+ _context12.next = 8;
16572
+ return res.json();
16573
+
16574
+ case 8:
16575
+ json = _context12.sent;
16576
+ if (!(typeof json.result === "string")) {
16577
+ _context12.next = 14;
16578
+ break;
16579
+ }
16580
+ if (!json.result.includes("Invalid API Key")) {
16581
+ _context12.next = 12;
16582
+ break;
16583
+ }
16584
+ throw new InvalidApiKeyError(SERVICES_API_KEY.Etherscan);
16585
+
16586
+ case 12:
16587
+ if (!json.result.includes("Max rate limit reached")) {
16588
+ _context12.next = 14;
16589
+ break;
16590
+ }
16591
+ throw new RateLimitError(SERVICES_API_KEY.Etherscan);
16592
+
16593
+ case 14:
16594
+ return _context12.abrupt("return", json.result);
16595
+
16596
+ case 15:
16597
+ case "end":
16598
+ return _context12.stop();
16599
+ }
16600
+ }), _callee12);
16601
+ })));
16602
+ return function fetchJSON(_x16) {
16603
+ return _ref17.apply(this, arguments);
16604
+ };
16605
+ }();
16606
+ _argsToArray5 = argsToArray(_args16), _argsToArray6 = _slicedToArray(_argsToArray5, 7),
16607
+ addresses = _argsToArray6[0], category = _argsToArray6[1], chains = _argsToArray6[2],
16608
+ startTime = _argsToArray6[3], endTime = _argsToArray6[4], _argsToArray6$ = _argsToArray6[5],
16609
+ page = _argsToArray6$ === void 0 ? 1 : _argsToArray6$, _argsToArray6$2 = _argsToArray6[6],
16610
+ offset = _argsToArray6$2 === void 0 ? 10 : _argsToArray6$2;
16611
+ validateParams(eoaParamsSchema, {
16612
+ addresses: addresses,
16613
+ category: category,
16614
+ chains: chains,
16615
+ startTime: startTime,
16616
+ endTime: endTime,
16617
+ page: page,
16618
+ offset: offset
16619
+ });
16620
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
16621
+ INPUTS = addresses.split(",").map((function(s) {
16622
+ return s.trim();
16623
+ })).filter(Boolean);
16624
+ CHAINS = chains.split(",").map((function(s) {
16625
+ return s.trim();
16626
+ })).filter(Boolean);
16627
+ ADDRESS_MAP = {};
16628
+ _iterator41 = _createForOfIteratorHelper(INPUTS);
16629
+ _context16.prev = 9;
16630
+ _iterator41.s();
16631
+
16632
+ case 11:
16633
+ if ((_step41 = _iterator41.n()).done) {
16634
+ _context16.next = 23;
16959
16635
  break;
16960
16636
  }
16961
- throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
16962
-
16963
- case 16:
16964
- _context13.next = 18;
16965
- return response.json();
16966
-
16967
- case 18:
16968
- _yield$response$json2 = _context13.sent;
16969
- _data2 = _yield$response$json2.data;
16970
- if (Array.isArray(_data2)) {
16971
- _context13.next = 22;
16637
+ inp = _step41.value;
16638
+ if (!isAddress$1.isAddress(inp)) {
16639
+ _context16.next = 17;
16972
16640
  break;
16973
16641
  }
16974
- return _context13.abrupt("return", []);
16642
+ ADDRESS_MAP[inp.toLowerCase()] = null;
16643
+ _context16.next = 21;
16644
+ break;
16975
16645
 
16976
- case 22:
16977
- return _context13.abrupt("return", _data2.map((function(item) {
16978
- var flat = {};
16979
- for (var _i11 = 0, _Object$entries2 = Object.entries(item); _i11 < _Object$entries2.length; _i11++) {
16980
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i11], 2), key = _Object$entries2$_i[0], _value12 = _Object$entries2$_i[1];
16981
- if (_value12 == null || _typeof(_value12) !== "object") {
16982
- flat[key] = _value12;
16983
- }
16984
- }
16985
- flat.platform = "lens";
16986
- return flat;
16987
- })));
16646
+ case 17:
16647
+ _context16.next = 19;
16648
+ return fromEnsNameToAddress$1.validateAndGetAddress(inp);
16649
+
16650
+ case 19:
16651
+ _address = _context16.sent;
16652
+ ADDRESS_MAP[_address.toLowerCase()] = _address;
16653
+
16654
+ case 21:
16655
+ _context16.next = 11;
16656
+ break;
16657
+
16658
+ case 23:
16659
+ _context16.next = 28;
16660
+ break;
16988
16661
 
16989
16662
  case 25:
16990
- _context13.prev = 25;
16991
- _context13.t0 = _context13["catch"](0);
16992
- return _context13.abrupt("return", errorMessageHandler(_context13.t0, "LENS"));
16663
+ _context16.prev = 25;
16664
+ _context16.t0 = _context16["catch"](9);
16665
+ _iterator41.e(_context16.t0);
16993
16666
 
16994
16667
  case 28:
16995
- case "end":
16996
- return _context13.stop();
16997
- }
16998
- }), _callee13, null, [ [ 0, 25 ] ]);
16999
- })));
17000
- return _LENS.apply(this, arguments);
17001
- }
17002
- function FARCASTER() {
17003
- return _FARCASTER.apply(this, arguments);
17004
- }
17005
- function _FARCASTER() {
17006
- _FARCASTER = _asyncToGenerator(_regeneratorRuntime().mark((function _callee14() {
17007
- var _argsToArray7, _argsToArray8, contentType, identifier, _argsToArray8$, start, _argsToArray8$2, end, apiKey, url, typeMap, _getUrlAndHeaders6, finalUrl, HEADERS, response, _yield$response$json3, _data3, _args14 = arguments;
17008
- return _regeneratorRuntime().wrap((function _callee14$(_context14) {
17009
- while (1) switch (_context14.prev = _context14.next) {
17010
- case 0:
17011
- _context14.prev = 0;
17012
- _argsToArray7 = argsToArray(_args14), _argsToArray8 = _slicedToArray(_argsToArray7, 4),
17013
- contentType = _argsToArray8[0], identifier = _argsToArray8[1], _argsToArray8$ = _argsToArray8[2],
17014
- start = _argsToArray8$ === void 0 ? 0 : _argsToArray8$, _argsToArray8$2 = _argsToArray8[3],
17015
- end = _argsToArray8$2 === void 0 ? 10 : _argsToArray8$2;
17016
- validateParams(farcasterParamsSchema, {
17017
- contentType: contentType,
17018
- identifier: identifier,
17019
- start: start,
17020
- end: end
17021
- });
17022
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
17023
- url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
17024
- url.searchParams.set("query", identifier.split(",").map((function(s) {
17025
- return s.trim();
17026
- })).filter(Boolean).join(","));
17027
- typeMap = {
17028
- posts: "farcasterid",
17029
- replies: "farcasterpostid",
17030
- channels: "farcasterchannels"
17031
- };
17032
- url.searchParams.set("type", typeMap[contentType]);
17033
- url.searchParams.set("start", String(start));
17034
- url.searchParams.set("end", String(end));
17035
- _getUrlAndHeaders6 = getUrlAndHeaders({
17036
- url: url.toString(),
17037
- serviceName: "Firefly",
17038
- headers: {
17039
- "x-api-key": apiKey
17040
- }
17041
- }), finalUrl = _getUrlAndHeaders6.URL, HEADERS = _getUrlAndHeaders6.HEADERS;
17042
- _context14.next = 13;
17043
- return fetch(finalUrl, {
17044
- method: "GET",
17045
- headers: HEADERS
17046
- });
16668
+ _context16.prev = 28;
16669
+ _iterator41.f();
16670
+ return _context16.finish(28);
17047
16671
 
17048
- case 13:
17049
- response = _context14.sent;
17050
- if (response.ok) {
17051
- _context14.next = 16;
17052
- break;
17053
- }
17054
- throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
16672
+ case 31:
16673
+ ADDRS = Object.keys(ADDRESS_MAP);
16674
+ out = [];
16675
+ _iterator42 = _createForOfIteratorHelper(CHAINS);
16676
+ _context16.prev = 34;
16677
+ _loop = _regeneratorRuntime().mark((function _loop() {
16678
+ var chain, chainId, _loop2, _ret2, i, sb, eb, _loop3, _ret3, _i10, _ADDRS;
16679
+ return _regeneratorRuntime().wrap((function _loop$(_context15) {
16680
+ while (1) switch (_context15.prev = _context15.next) {
16681
+ case 0:
16682
+ chain = _step42.value;
16683
+ chainId = CHAIN_ID_MAP[chain];
16684
+ if (chainId) {
16685
+ _context15.next = 4;
16686
+ break;
16687
+ }
16688
+ throw new ValidationError("Invalid chain: ".concat(chain));
17055
16689
 
17056
- case 16:
17057
- _context14.next = 18;
17058
- return response.json();
16690
+ case 4:
16691
+ if (!(category === "balance")) {
16692
+ _context15.next = 17;
16693
+ break;
16694
+ }
16695
+ _loop2 = _regeneratorRuntime().mark((function _loop2(i) {
16696
+ var slice, url, data;
16697
+ return _regeneratorRuntime().wrap((function _loop2$(_context13) {
16698
+ while (1) switch (_context13.prev = _context13.next) {
16699
+ case 0:
16700
+ slice = ADDRS.slice(i, i + 20).join(",");
16701
+ url = "https://api.etherscan.io/v2/api?chainid=".concat(chainId) + "&module=account&action=addresstokenbalance&address=".concat(slice) + "&page=".concat(page, "&offset=").concat(offset, "&apikey=").concat(apiKey);
16702
+ _context13.next = 4;
16703
+ return fetchJSON(url);
17059
16704
 
17060
- case 18:
17061
- _yield$response$json3 = _context14.sent;
17062
- _data3 = _yield$response$json3.data;
17063
- if (Array.isArray(_data3)) {
17064
- _context14.next = 22;
17065
- break;
17066
- }
17067
- return _context14.abrupt("return", []);
16705
+ case 4:
16706
+ data = _context13.sent;
16707
+ if (Array.isArray(data)) {
16708
+ _context13.next = 7;
16709
+ break;
16710
+ }
16711
+ return _context13.abrupt("return", {
16712
+ v: {
16713
+ v: data
16714
+ }
16715
+ });
17068
16716
 
17069
- case 22:
17070
- return _context14.abrupt("return", _data3.map((function(item) {
17071
- var flat = {};
17072
- for (var _i12 = 0, _Object$entries3 = Object.entries(item); _i12 < _Object$entries3.length; _i12++) {
17073
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i12], 2), k = _Object$entries3$_i[0], v = _Object$entries3$_i[1];
17074
- if (v == null || _typeof(v) !== "object") {
17075
- flat[k] = v;
17076
- }
17077
- }
17078
- flat.platform = "farcaster";
17079
- return flat;
17080
- })));
16717
+ case 7:
16718
+ data.forEach((function(item, idx) {
16719
+ return out.push(_objectSpread({
16720
+ chain: chain,
16721
+ address: ADDRS[i + idx],
16722
+ name: ADDRESS_MAP[ADDRS[i + idx]]
16723
+ }, item));
16724
+ }));
17081
16725
 
17082
- case 25:
17083
- _context14.prev = 25;
17084
- _context14.t0 = _context14["catch"](0);
17085
- return _context14.abrupt("return", errorMessageHandler(_context14.t0, "FARCASTER"));
16726
+ case 8:
16727
+ case "end":
16728
+ return _context13.stop();
16729
+ }
16730
+ }), _loop2);
16731
+ }));
16732
+ i = 0;
17086
16733
 
17087
- case 28:
17088
- case "end":
17089
- return _context14.stop();
17090
- }
17091
- }), _callee14, null, [ [ 0, 25 ] ]);
17092
- })));
17093
- return _FARCASTER.apply(this, arguments);
17094
- }
17095
- function BLOCKSCOUT() {
17096
- return _BLOCKSCOUT.apply(this, arguments);
17097
- }
17098
- function _BLOCKSCOUT() {
17099
- _BLOCKSCOUT = _asyncToGenerator(_regeneratorRuntime().mark((function _callee15() {
17100
- var _json$result, _json$result2, _argsToArray9, _argsToArray0, address, type, _argsToArray0$, chain, startTimestamp, endTimestamp, page, offset, startTs, endTs, resolvedAddress, hostname, requestUrl, response, json, _args15 = arguments;
17101
- return _regeneratorRuntime().wrap((function _callee15$(_context15) {
17102
- while (1) switch (_context15.prev = _context15.next) {
17103
- case 0:
17104
- _context15.prev = 0;
17105
- _argsToArray9 = argsToArray(_args15), _argsToArray0 = _slicedToArray(_argsToArray9, 7),
17106
- address = _argsToArray0[0], type = _argsToArray0[1], _argsToArray0$ = _argsToArray0[2],
17107
- chain = _argsToArray0$ === void 0 ? "ethereum" : _argsToArray0$, startTimestamp = _argsToArray0[3],
17108
- endTimestamp = _argsToArray0[4], page = _argsToArray0[5], offset = _argsToArray0[6];
17109
- validateParams(blockscoutParamsSchema, {
17110
- address: address,
17111
- type: type,
17112
- chain: chain,
17113
- startTimestamp: startTimestamp,
17114
- endTimestamp: endTimestamp,
17115
- page: page,
17116
- offset: offset
17117
- });
17118
- startTs = startTimestamp !== null && startTimestamp !== void 0 ? startTimestamp : Math.floor((Date.now() - 30 * 24 * 3600 * 1e3) / 1e3);
17119
- endTs = endTimestamp;
17120
- _context15.next = 7;
17121
- return fromEnsNameToAddress$1.validateAndGetAddress(address);
16734
+ case 7:
16735
+ if (!(i < ADDRS.length)) {
16736
+ _context15.next = 15;
16737
+ break;
16738
+ }
16739
+ return _context15.delegateYield(_loop2(i), "t0", 9);
17122
16740
 
17123
- case 7:
17124
- resolvedAddress = _context15.sent;
17125
- hostname = BLOCKSCOUT_CHAINS_MAP[chain];
17126
- _context15.t0 = type;
17127
- _context15.next = _context15.t0 === "stat" ? 12 : _context15.t0 === "txns" ? 14 : _context15.t0 === "tokens" ? 16 : 18;
17128
- break;
16741
+ case 9:
16742
+ _ret2 = _context15.t0;
16743
+ if (!_ret2) {
16744
+ _context15.next = 12;
16745
+ break;
16746
+ }
16747
+ return _context15.abrupt("return", _ret2.v);
17129
16748
 
17130
- case 12:
17131
- requestUrl = "".concat(hostname, "/api/v2/addresses/").concat(resolvedAddress, "/counters");
17132
- return _context15.abrupt("break", 18);
16749
+ case 12:
16750
+ i += 20;
16751
+ _context15.next = 7;
16752
+ break;
17133
16753
 
17134
- case 14:
17135
- requestUrl = "".concat(hostname, "/api?module=account&action=txlist") + "&address=".concat(resolvedAddress) + "&start_timestamp=".concat(startTs) + "&end_timestamp=".concat(endTs !== null && endTs !== void 0 ? endTs : "") + "&page=".concat(page) + "&offset=".concat(offset) + "&sort=asc";
17136
- return _context15.abrupt("break", 18);
16754
+ case 15:
16755
+ _context15.next = 37;
16756
+ break;
16757
+
16758
+ case 17:
16759
+ _context15.next = 19;
16760
+ return fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startTime), chain, apiKey);
16761
+
16762
+ case 19:
16763
+ sb = _context15.sent;
16764
+ _context15.next = 22;
16765
+ return fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endTime), chain, apiKey);
16766
+
16767
+ case 22:
16768
+ eb = _context15.sent;
16769
+ if (sb) {
16770
+ _context15.next = 25;
16771
+ break;
16772
+ }
16773
+ throw new ValidationError("Invalid startTime: ".concat(startTime));
16774
+
16775
+ case 25:
16776
+ if (eb) {
16777
+ _context15.next = 27;
16778
+ break;
16779
+ }
16780
+ throw new ValidationError("Invalid endTime: ".concat(endTime));
16781
+
16782
+ case 27:
16783
+ _loop3 = _regeneratorRuntime().mark((function _loop3() {
16784
+ var addr, url, data;
16785
+ return _regeneratorRuntime().wrap((function _loop3$(_context14) {
16786
+ while (1) switch (_context14.prev = _context14.next) {
16787
+ case 0:
16788
+ addr = _ADDRS[_i10];
16789
+ url = "https://api.etherscan.io/v2/api?chainid=".concat(chainId) + "&module=account&action=tokentx&address=".concat(addr) + "&startblock=".concat(sb, "&endblock=").concat(eb) + "&page=".concat(page, "&offset=").concat(offset, "&sort=asc&apikey=").concat(apiKey);
16790
+ _context14.next = 4;
16791
+ return fetchJSON(url);
16792
+
16793
+ case 4:
16794
+ data = _context14.sent;
16795
+ if (Array.isArray(data)) {
16796
+ _context14.next = 7;
16797
+ break;
16798
+ }
16799
+ return _context14.abrupt("return", {
16800
+ v: {
16801
+ v: data
16802
+ }
16803
+ });
16804
+
16805
+ case 7:
16806
+ data.forEach((function(item) {
16807
+ return out.push(_objectSpread({
16808
+ chain: chain,
16809
+ address: addr,
16810
+ name: ADDRESS_MAP[addr]
16811
+ }, item));
16812
+ }));
16813
+
16814
+ case 8:
16815
+ case "end":
16816
+ return _context14.stop();
16817
+ }
16818
+ }), _loop3);
16819
+ }));
16820
+ _i10 = 0, _ADDRS = ADDRS;
17137
16821
 
17138
- case 16:
17139
- requestUrl = "".concat(hostname, "/api?module=account&action=tokenlist") + "&address=".concat(resolvedAddress);
17140
- return _context15.abrupt("break", 18);
16822
+ case 29:
16823
+ if (!(_i10 < _ADDRS.length)) {
16824
+ _context15.next = 37;
16825
+ break;
16826
+ }
16827
+ return _context15.delegateYield(_loop3(), "t1", 31);
17141
16828
 
17142
- case 18:
17143
- _context15.next = 20;
17144
- return fetch(requestUrl);
16829
+ case 31:
16830
+ _ret3 = _context15.t1;
16831
+ if (!_ret3) {
16832
+ _context15.next = 34;
16833
+ break;
16834
+ }
16835
+ return _context15.abrupt("return", _ret3.v);
17145
16836
 
17146
- case 20:
17147
- response = _context15.sent;
17148
- if (response.ok) {
17149
- _context15.next = 23;
17150
- break;
17151
- }
17152
- throw new NetworkError("BLOCKSCOUT", response.status);
16837
+ case 34:
16838
+ _i10++;
16839
+ _context15.next = 29;
16840
+ break;
17153
16841
 
17154
- case 23:
17155
- _context15.next = 25;
17156
- return response.json();
16842
+ case 37:
16843
+ case "end":
16844
+ return _context15.stop();
16845
+ }
16846
+ }), _loop);
16847
+ }));
16848
+ _iterator42.s();
17157
16849
 
17158
- case 25:
17159
- json = _context15.sent;
17160
- if (!(json !== null && json !== void 0 && (_json$result = json.result) !== null && _json$result !== void 0 && _json$result.includes("Invalid parameter(s)"))) {
17161
- _context15.next = 28;
16850
+ case 37:
16851
+ if ((_step42 = _iterator42.n()).done) {
16852
+ _context16.next = 44;
17162
16853
  break;
17163
16854
  }
17164
- throw new ValidationError("Invalid parameters");
16855
+ return _context16.delegateYield(_loop(), "t1", 39);
17165
16856
 
17166
- case 28:
17167
- if (!(json !== null && json !== void 0 && (_json$result2 = json.result) !== null && _json$result2 !== void 0 && _json$result2.includes("Not found"))) {
17168
- _context15.next = 30;
16857
+ case 39:
16858
+ _ret = _context16.t1;
16859
+ if (!_ret) {
16860
+ _context16.next = 42;
17169
16861
  break;
17170
16862
  }
17171
- throw new ValidationError("Address information not found");
16863
+ return _context16.abrupt("return", _ret.v);
17172
16864
 
17173
- case 30:
17174
- return _context15.abrupt("return", type === "stat" ? [ json ] : json.result);
16865
+ case 42:
16866
+ _context16.next = 37;
16867
+ break;
17175
16868
 
17176
- case 33:
17177
- _context15.prev = 33;
17178
- _context15.t1 = _context15["catch"](0);
17179
- return _context15.abrupt("return", errorMessageHandler(_context15.t1, "BLOCKSCOUT"));
16869
+ case 44:
16870
+ _context16.next = 49;
16871
+ break;
17180
16872
 
17181
- case 36:
17182
- case "end":
17183
- return _context15.stop();
17184
- }
17185
- }), _callee15, null, [ [ 0, 33 ] ]);
17186
- })));
17187
- return _BLOCKSCOUT.apply(this, arguments);
17188
- }
17189
- function BASE() {
17190
- return _BASE.apply(this, arguments);
17191
- }
17192
- function _BASE() {
17193
- _BASE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee16() {
17194
- var _argsToArray1, _argsToArray10, type, address, startDate, endDate, page, limit, API_KEY, _args16 = arguments;
17195
- return _regeneratorRuntime().wrap((function _callee16$(_context16) {
17196
- while (1) switch (_context16.prev = _context16.next) {
17197
- case 0:
17198
- _context16.prev = 0;
17199
- _argsToArray1 = argsToArray(_args16), _argsToArray10 = _slicedToArray(_argsToArray1, 6),
17200
- type = _argsToArray10[0], address = _argsToArray10[1], startDate = _argsToArray10[2],
17201
- endDate = _argsToArray10[3], page = _argsToArray10[4], limit = _argsToArray10[5];
17202
- validateParams(baseParamsSchema, {
17203
- type: type,
17204
- address: address,
17205
- startDate: startDate,
17206
- endDate: endDate,
17207
- page: page,
17208
- limit: limit
17209
- });
17210
- API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
17211
- _context16.next = 6;
17212
- return handleScanRequest({
17213
- type: type,
17214
- address: address,
17215
- startDate: startDate,
17216
- endDate: endDate,
17217
- page: page,
17218
- offset: limit,
17219
- apiKey: API_KEY,
17220
- functionName: "BASE",
17221
- chainId: CHAIN_ID_MAP.base,
17222
- network: "base"
17223
- });
16873
+ case 46:
16874
+ _context16.prev = 46;
16875
+ _context16.t2 = _context16["catch"](34);
16876
+ _iterator42.e(_context16.t2);
17224
16877
 
17225
- case 6:
17226
- return _context16.abrupt("return", _context16.sent);
16878
+ case 49:
16879
+ _context16.prev = 49;
16880
+ _iterator42.f();
16881
+ return _context16.finish(49);
17227
16882
 
17228
- case 9:
17229
- _context16.prev = 9;
17230
- _context16.t0 = _context16["catch"](0);
17231
- return _context16.abrupt("return", errorMessageHandler(_context16.t0, "BASE"));
16883
+ case 52:
16884
+ return _context16.abrupt("return", out);
17232
16885
 
17233
- case 12:
16886
+ case 55:
16887
+ _context16.prev = 55;
16888
+ _context16.t3 = _context16["catch"](0);
16889
+ return _context16.abrupt("return", errorMessageHandler(_context16.t3, "EOA"));
16890
+
16891
+ case 58:
17234
16892
  case "end":
17235
16893
  return _context16.stop();
17236
16894
  }
17237
- }), _callee16, null, [ [ 0, 9 ] ]);
16895
+ }), _callee13, null, [ [ 0, 55 ], [ 9, 25, 28, 31 ], [ 34, 46, 49, 52 ] ]);
17238
16896
  })));
17239
- return _BASE.apply(this, arguments);
16897
+ return _EOA.apply(this, arguments);
17240
16898
  }
17241
- function GNOSIS() {
17242
- return _GNOSIS.apply(this, arguments);
16899
+ var gasSchema$1 = objectType({
16900
+ type: literalType("gas"),
16901
+ startDate: dateOrTimestamp.optional(),
16902
+ endDate: dateOrTimestamp.optional(),
16903
+ page: numberType()["int"]().nonnegative()["default"](1),
16904
+ limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16905
+ message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16906
+ })["default"](10)
16907
+ });
16908
+ var txnSchema$1 = objectType({
16909
+ type: enumType([ "all-txns", "token-txns", "nft-txns" ]),
16910
+ address: stringType().nonempty(),
16911
+ startDate: dateOrTimestamp.optional(),
16912
+ endDate: dateOrTimestamp.optional(),
16913
+ page: numberType()["int"]().nonnegative()["default"](1),
16914
+ limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
16915
+ message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
16916
+ })["default"](10)
16917
+ });
16918
+ var baseParamsSchema = discriminatedUnionType("type", [ gasSchema$1, txnSchema$1 ]);
16919
+ function handleScanRequest(_x13) {
16920
+ return _handleScanRequest.apply(this, arguments);
17243
16921
  }
17244
- function _GNOSIS() {
17245
- _GNOSIS = _asyncToGenerator(_regeneratorRuntime().mark((function _callee17() {
17246
- var _argsToArray11, _argsToArray12, type, address, startDate, endDate, _argsToArray12$, page, _argsToArray12$2, limit, apiKey, _args17 = arguments;
17247
- return _regeneratorRuntime().wrap((function _callee17$(_context17) {
16922
+ function _handleScanRequest() {
16923
+ _handleScanRequest = _asyncToGenerator(_regeneratorRuntime().mark((function _callee14(_ref13) {
16924
+ 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;
16925
+ return _regeneratorRuntime().wrap((function _callee14$(_context17) {
17248
16926
  while (1) switch (_context17.prev = _context17.next) {
17249
16927
  case 0:
17250
- _context17.prev = 0;
17251
- _argsToArray11 = argsToArray(_args17), _argsToArray12 = _slicedToArray(_argsToArray11, 6),
17252
- type = _argsToArray12[0], address = _argsToArray12[1], startDate = _argsToArray12[2],
17253
- endDate = _argsToArray12[3], _argsToArray12$ = _argsToArray12[4], page = _argsToArray12$ === void 0 ? 1 : _argsToArray12$,
17254
- _argsToArray12$2 = _argsToArray12[5], limit = _argsToArray12$2 === void 0 ? 10 : _argsToArray12$2;
17255
- validateParams(baseParamsSchema, {
17256
- type: type,
17257
- address: address,
17258
- startDate: startDate,
17259
- endDate: endDate,
17260
- page: page,
17261
- limit: limit
17262
- });
17263
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Gnosisscan);
17264
- _context17.next = 6;
17265
- return handleScanRequest({
17266
- type: type,
17267
- address: address,
17268
- startDate: startDate,
17269
- endDate: endDate,
17270
- page: page,
17271
- offset: limit,
17272
- apiKey: apiKey,
17273
- functionName: "GNOSIS",
17274
- chainId: CHAIN_ID_MAP.gnosis,
17275
- network: "gnosis"
17276
- });
16928
+ type = _ref13.type, address = _ref13.address, startDate = _ref13.startDate, endDate = _ref13.endDate,
16929
+ _ref13$page = _ref13.page, page = _ref13$page === void 0 ? 1 : _ref13$page, _ref13$offset = _ref13.offset,
16930
+ offset = _ref13$offset === void 0 ? 10 : _ref13$offset, apiKey = _ref13.apiKey,
16931
+ functionName = _ref13.functionName, chainId = _ref13.chainId, network = _ref13.network;
16932
+ API_INFO_MAP = {
16933
+ BASE: {
16934
+ url: "https://api.basescan.org/api",
16935
+ apiKeyName: SERVICES_API_KEY.Basescan
16936
+ },
16937
+ ETHERSCAN: {
16938
+ url: "https://api.etherscan.io/v2/api",
16939
+ apiKeyName: SERVICES_API_KEY.Etherscan
16940
+ },
16941
+ GNOSIS: {
16942
+ url: "https://api.gnosisscan.io/api",
16943
+ apiKeyName: SERVICES_API_KEY.Gnosisscan
16944
+ }
16945
+ };
16946
+ if (!(type !== "gas")) {
16947
+ _context17.next = 6;
16948
+ break;
16949
+ }
16950
+ _context17.next = 5;
16951
+ return fromEnsNameToAddress$1.validateAndGetAddress(address);
17277
16952
 
17278
- case 6:
17279
- return _context17.abrupt("return", _context17.sent);
16953
+ case 5:
16954
+ address = _context17.sent;
17280
16955
 
17281
- case 9:
17282
- _context17.prev = 9;
17283
- _context17.t0 = _context17["catch"](0);
17284
- return _context17.abrupt("return", errorMessageHandler(_context17.t0, "GNOSIS"));
16956
+ case 6:
16957
+ apiInfo = API_INFO_MAP[functionName];
16958
+ baseUrl = apiInfo === null || apiInfo === void 0 ? void 0 : apiInfo.url;
16959
+ if (baseUrl) {
16960
+ _context17.next = 10;
16961
+ break;
16962
+ }
16963
+ throw new ValidationError("Api not found for: ".concat(functionName));
17285
16964
 
17286
- case 12:
17287
- case "end":
17288
- return _context17.stop();
17289
- }
17290
- }), _callee17, null, [ [ 0, 9 ] ]);
17291
- })));
17292
- return _GNOSIS.apply(this, arguments);
17293
- }
17294
- function NEYNAR() {
17295
- return _NEYNAR.apply(this, arguments);
17296
- }
17297
- function _NEYNAR() {
17298
- _NEYNAR = _asyncToGenerator(_regeneratorRuntime().mark((function _callee18() {
17299
- var neynarParamsSchema, _argsToArray13, _argsToArray14, username, apiKey, fid, url, _getUrlAndHeaders7, finalUrl, HEADERS, response, json, users, _args18 = arguments;
17300
- return _regeneratorRuntime().wrap((function _callee18$(_context18) {
17301
- while (1) switch (_context18.prev = _context18.next) {
17302
- case 0:
17303
- _context18.prev = 0;
17304
- neynarParamsSchema = objectType({
17305
- username: stringType().nonempty()
17306
- });
17307
- _argsToArray13 = argsToArray(_args18), _argsToArray14 = _slicedToArray(_argsToArray13, 1),
17308
- username = _argsToArray14[0];
17309
- validateParams(neynarParamsSchema, {
17310
- username: username
17311
- });
17312
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Neynar);
17313
- _context18.next = 7;
17314
- return fromUsernameToFid$1.fromUsernameToFid(username, apiKey);
16965
+ case 10:
16966
+ ACTION_MAP = {
16967
+ "all-txns": "txlist",
16968
+ "token-txns": "tokentx",
16969
+ "nft-txns": "tokennfttx",
16970
+ gas: "gasoracle"
16971
+ };
16972
+ action = ACTION_MAP[type];
16973
+ if (action) {
16974
+ _context17.next = 14;
16975
+ break;
16976
+ }
16977
+ throw new ValidationError("Invalid type: ".concat(type));
17315
16978
 
17316
- case 7:
17317
- fid = _context18.sent;
17318
- if (fid) {
17319
- _context18.next = 10;
16979
+ case 14:
16980
+ module = action === "gasoracle" ? "gastracker" : "account";
16981
+ url = "".concat(baseUrl, "?chainid=").concat(chainId, "&module=").concat(module, "&action=").concat(action, "&apikey=").concat(apiKey);
16982
+ if (![ "all-txns", "token-txns", "nft-txns" ].includes(type)) {
16983
+ _context17.next = 27;
17320
16984
  break;
17321
16985
  }
17322
- throw new ValidationError("Invalid username: ".concat(username));
16986
+ url += "&address=".concat(address, "&startblock=0&endblock=99999999&sort=asc");
16987
+ if (!(!isNaN(startDate) && !isNaN(endDate))) {
16988
+ _context17.next = 26;
16989
+ break;
16990
+ }
16991
+ _context17.next = 21;
16992
+ return Promise.all([ fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startDate), network, apiKey), fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endDate), network, apiKey) ]);
17323
16993
 
17324
- case 10:
17325
- url = "https://api.neynar.com/v2/farcaster/followers?fid=".concat(fid);
17326
- _getUrlAndHeaders7 = getUrlAndHeaders({
17327
- url: url.toString(),
17328
- serviceName: "Neynar",
17329
- headers: {
17330
- "x-api-key": apiKey,
17331
- "x-neynar-experimental": "false"
17332
- }
17333
- }), finalUrl = _getUrlAndHeaders7.URL, HEADERS = _getUrlAndHeaders7.HEADERS;
17334
- _context18.next = 14;
16994
+ case 21:
16995
+ _yield$Promise$all = _context17.sent;
16996
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
16997
+ startBlock = _yield$Promise$all2[0];
16998
+ endBlock = _yield$Promise$all2[1];
16999
+ url += "&startblock=".concat(startBlock || "0", "&endblock=").concat(endBlock || "99999999");
17000
+
17001
+ case 26:
17002
+ url += "&page=".concat(page, "&offset=").concat(offset);
17003
+
17004
+ case 27:
17005
+ _getUrlAndHeaders4 = getUrlAndHeaders({
17006
+ url: url,
17007
+ serviceName: apiInfo.apiKeyName,
17008
+ headers: {}
17009
+ }), finalUrl = _getUrlAndHeaders4.URL, HEADERS = _getUrlAndHeaders4.HEADERS;
17010
+ _context17.next = 30;
17335
17011
  return fetch(finalUrl, {
17336
17012
  method: "GET",
17337
17013
  headers: HEADERS
17338
17014
  });
17339
17015
 
17340
- case 14:
17341
- response = _context18.sent;
17342
- if (response.ok) {
17343
- _context18.next = 17;
17016
+ case 30:
17017
+ res = _context17.sent;
17018
+ if (res.ok) {
17019
+ _context17.next = 33;
17344
17020
  break;
17345
17021
  }
17346
- throw new NetworkError(SERVICES_API_KEY.Neynar, response.status);
17022
+ throw new NetworkError(apiInfo.apiKeyName, res.status);
17347
17023
 
17348
- case 17:
17349
- _context18.next = 19;
17350
- return response.json();
17024
+ case 33:
17025
+ _context17.next = 35;
17026
+ return res.json();
17351
17027
 
17352
- case 19:
17353
- json = _context18.sent;
17354
- users = (json === null || json === void 0 ? void 0 : json.users) || [];
17355
- if (users.length) {
17356
- _context18.next = 23;
17028
+ case 35:
17029
+ json = _context17.sent;
17030
+ if (!(typeof json.result === "string")) {
17031
+ _context17.next = 41;
17032
+ break;
17033
+ }
17034
+ if (!json.result.includes("Invalid API Key")) {
17035
+ _context17.next = 39;
17036
+ break;
17037
+ }
17038
+ throw new InvalidApiKeyError(apiInfo.apiKeyName);
17039
+
17040
+ case 39:
17041
+ if (!json.result.includes("Max rate limit reached")) {
17042
+ _context17.next = 41;
17357
17043
  break;
17358
17044
  }
17359
- return _context18.abrupt("return", []);
17360
-
17361
- case 23:
17362
- return _context18.abrupt("return", users.map((function(_ref15) {
17363
- var _user$profile, _user$profile2;
17364
- var user = _ref15.user;
17365
- return {
17366
- username: user.username,
17367
- custody_address: user.custody_address,
17368
- follower_count: user.follower_count,
17369
- country: ((_user$profile = user.profile) === null || _user$profile === void 0 || (_user$profile = _user$profile.location) === null || _user$profile === void 0 || (_user$profile = _user$profile.address) === null || _user$profile === void 0 ? void 0 : _user$profile.country) || "",
17370
- city: ((_user$profile2 = user.profile) === null || _user$profile2 === void 0 || (_user$profile2 = _user$profile2.location) === null || _user$profile2 === void 0 || (_user$profile2 = _user$profile2.address) === null || _user$profile2 === void 0 ? void 0 : _user$profile2.city) || ""
17371
- };
17372
- })));
17045
+ throw new RateLimitError(apiInfo.apiKeyName);
17373
17046
 
17374
- case 26:
17375
- _context18.prev = 26;
17376
- _context18.t0 = _context18["catch"](0);
17377
- return _context18.abrupt("return", errorMessageHandler(_context18.t0, "NEYNAR"));
17047
+ case 41:
17048
+ return _context17.abrupt("return", type === "gas" && !Array.isArray(json.result) ? [ json.result ] : json.result);
17378
17049
 
17379
- case 29:
17050
+ case 42:
17380
17051
  case "end":
17381
- return _context18.stop();
17052
+ return _context17.stop();
17382
17053
  }
17383
- }), _callee18, null, [ [ 0, 26 ] ]);
17054
+ }), _callee14);
17384
17055
  })));
17385
- return _NEYNAR.apply(this, arguments);
17056
+ return _handleScanRequest.apply(this, arguments);
17386
17057
  }
17387
- function ETHERSCAN() {
17388
- return _ETHERSCAN.apply(this, arguments);
17058
+ function BASE() {
17059
+ return _BASE.apply(this, arguments);
17389
17060
  }
17390
- function _ETHERSCAN() {
17391
- _ETHERSCAN = _asyncToGenerator(_regeneratorRuntime().mark((function _callee19() {
17392
- var _argsToArray15, _argsToArray16, type, chain, address, startDate, endDate, _argsToArray16$, page, _argsToArray16$2, limit, chainId, apiKey, _args19 = arguments;
17393
- return _regeneratorRuntime().wrap((function _callee19$(_context19) {
17394
- while (1) switch (_context19.prev = _context19.next) {
17061
+ function _BASE() {
17062
+ _BASE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee15() {
17063
+ var _argsToArray7, _argsToArray8, type, address, startDate, endDate, page, limit, API_KEY, _args18 = arguments;
17064
+ return _regeneratorRuntime().wrap((function _callee15$(_context18) {
17065
+ while (1) switch (_context18.prev = _context18.next) {
17395
17066
  case 0:
17396
- _context19.prev = 0;
17397
- _argsToArray15 = argsToArray(_args19), _argsToArray16 = _slicedToArray(_argsToArray15, 7),
17398
- type = _argsToArray16[0], chain = _argsToArray16[1], address = _argsToArray16[2],
17399
- startDate = _argsToArray16[3], endDate = _argsToArray16[4], _argsToArray16$ = _argsToArray16[5],
17400
- page = _argsToArray16$ === void 0 ? 1 : _argsToArray16$, _argsToArray16$2 = _argsToArray16[6],
17401
- limit = _argsToArray16$2 === void 0 ? 10 : _argsToArray16$2;
17402
- validateParams(etherscanParamsSchema, {
17067
+ _context18.prev = 0;
17068
+ _argsToArray7 = argsToArray(_args18), _argsToArray8 = _slicedToArray(_argsToArray7, 6),
17069
+ type = _argsToArray8[0], address = _argsToArray8[1], startDate = _argsToArray8[2],
17070
+ endDate = _argsToArray8[3], page = _argsToArray8[4], limit = _argsToArray8[5];
17071
+ validateParams(baseParamsSchema, {
17403
17072
  type: type,
17404
- chain: chain,
17405
17073
  address: address,
17406
17074
  startDate: startDate,
17407
17075
  endDate: endDate,
17408
17076
  page: page,
17409
17077
  limit: limit
17410
17078
  });
17411
- chainId = CHAIN_ID_MAP[chain];
17412
- if (chainId) {
17413
- _context19.next = 6;
17414
- break;
17415
- }
17416
- throw new ValidationError("Invalid chain: ".concat(chain));
17417
-
17418
- case 6:
17419
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
17420
- _context19.next = 9;
17079
+ API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
17080
+ _context18.next = 6;
17421
17081
  return handleScanRequest({
17422
17082
  type: type,
17423
17083
  address: address,
@@ -17425,40 +17085,181 @@ function _typeof(o) {
17425
17085
  endDate: endDate,
17426
17086
  page: page,
17427
17087
  offset: limit,
17428
- apiKey: apiKey,
17429
- functionName: "ETHERSCAN",
17430
- chainId: chainId,
17431
- network: chain
17088
+ apiKey: API_KEY,
17089
+ functionName: "BASE",
17090
+ chainId: CHAIN_ID_MAP.base,
17091
+ network: "base"
17432
17092
  });
17433
17093
 
17094
+ case 6:
17095
+ return _context18.abrupt("return", _context18.sent);
17096
+
17434
17097
  case 9:
17435
- return _context19.abrupt("return", _context19.sent);
17098
+ _context18.prev = 9;
17099
+ _context18.t0 = _context18["catch"](0);
17100
+ return _context18.abrupt("return", errorMessageHandler(_context18.t0, "BASE"));
17101
+
17102
+ case 12:
17103
+ case "end":
17104
+ return _context18.stop();
17105
+ }
17106
+ }), _callee15, null, [ [ 0, 9 ] ]);
17107
+ })));
17108
+ return _BASE.apply(this, arguments);
17109
+ }
17110
+ var blockscoutParamsSchema = objectType({
17111
+ address: stringType().nonempty(),
17112
+ type: enumType([ "stat", "txns", "tokens" ]),
17113
+ chain: enumType([ "ethereum", "gnosis", "arbitrum", "optimism", "soneium", "unichain" ])["default"]("ethereum"),
17114
+ startTimestamp: dateOrTimestamp.optional(),
17115
+ endTimestamp: dateOrTimestamp.optional(),
17116
+ page: numberType()["int"]().nonnegative()["default"](1),
17117
+ offset: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17118
+ message: '"offset" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17119
+ })["default"](10)
17120
+ });
17121
+ function BLOCKSCOUT() {
17122
+ return _BLOCKSCOUT.apply(this, arguments);
17123
+ }
17124
+ function _BLOCKSCOUT() {
17125
+ _BLOCKSCOUT = _asyncToGenerator(_regeneratorRuntime().mark((function _callee16() {
17126
+ var _json$result, _json$result2, _argsToArray9, _argsToArray0, address, type, _argsToArray0$, chain, startTimestamp, endTimestamp, page, offset, startTs, endTs, resolvedAddress, hostname, requestUrl, response, json, _args19 = arguments;
17127
+ return _regeneratorRuntime().wrap((function _callee16$(_context19) {
17128
+ while (1) switch (_context19.prev = _context19.next) {
17129
+ case 0:
17130
+ _context19.prev = 0;
17131
+ _argsToArray9 = argsToArray(_args19), _argsToArray0 = _slicedToArray(_argsToArray9, 7),
17132
+ address = _argsToArray0[0], type = _argsToArray0[1], _argsToArray0$ = _argsToArray0[2],
17133
+ chain = _argsToArray0$ === void 0 ? "ethereum" : _argsToArray0$, startTimestamp = _argsToArray0[3],
17134
+ endTimestamp = _argsToArray0[4], page = _argsToArray0[5], offset = _argsToArray0[6];
17135
+ validateParams(blockscoutParamsSchema, {
17136
+ address: address,
17137
+ type: type,
17138
+ chain: chain,
17139
+ startTimestamp: startTimestamp,
17140
+ endTimestamp: endTimestamp,
17141
+ page: page,
17142
+ offset: offset
17143
+ });
17144
+ startTs = startTimestamp !== null && startTimestamp !== void 0 ? startTimestamp : Math.floor((Date.now() - 30 * 24 * 3600 * 1e3) / 1e3);
17145
+ endTs = endTimestamp;
17146
+ _context19.next = 7;
17147
+ return fromEnsNameToAddress$1.validateAndGetAddress(address);
17148
+
17149
+ case 7:
17150
+ resolvedAddress = _context19.sent;
17151
+ hostname = BLOCKSCOUT_CHAINS_MAP[chain];
17152
+ _context19.t0 = type;
17153
+ _context19.next = _context19.t0 === "stat" ? 12 : _context19.t0 === "txns" ? 14 : _context19.t0 === "tokens" ? 16 : 18;
17154
+ break;
17436
17155
 
17437
17156
  case 12:
17438
- _context19.prev = 12;
17439
- _context19.t0 = _context19["catch"](0);
17440
- return _context19.abrupt("return", errorMessageHandler(_context19.t0, "ETHERSCAN"));
17157
+ requestUrl = "".concat(hostname, "/api/v2/addresses/").concat(resolvedAddress, "/counters");
17158
+ return _context19.abrupt("break", 18);
17441
17159
 
17442
- case 15:
17160
+ case 14:
17161
+ requestUrl = "".concat(hostname, "/api?module=account&action=txlist") + "&address=".concat(resolvedAddress) + "&start_timestamp=".concat(startTs) + "&end_timestamp=".concat(endTs !== null && endTs !== void 0 ? endTs : "") + "&page=".concat(page) + "&offset=".concat(offset) + "&sort=asc";
17162
+ return _context19.abrupt("break", 18);
17163
+
17164
+ case 16:
17165
+ requestUrl = "".concat(hostname, "/api?module=account&action=tokenlist") + "&address=".concat(resolvedAddress);
17166
+ return _context19.abrupt("break", 18);
17167
+
17168
+ case 18:
17169
+ _context19.next = 20;
17170
+ return fetch(requestUrl);
17171
+
17172
+ case 20:
17173
+ response = _context19.sent;
17174
+ if (response.ok) {
17175
+ _context19.next = 23;
17176
+ break;
17177
+ }
17178
+ throw new NetworkError("BLOCKSCOUT", response.status);
17179
+
17180
+ case 23:
17181
+ _context19.next = 25;
17182
+ return response.json();
17183
+
17184
+ case 25:
17185
+ json = _context19.sent;
17186
+ if (!(json !== null && json !== void 0 && (_json$result = json.result) !== null && _json$result !== void 0 && _json$result.includes("Invalid parameter(s)"))) {
17187
+ _context19.next = 28;
17188
+ break;
17189
+ }
17190
+ throw new ValidationError("Invalid parameters");
17191
+
17192
+ case 28:
17193
+ if (!(json !== null && json !== void 0 && (_json$result2 = json.result) !== null && _json$result2 !== void 0 && _json$result2.includes("Not found"))) {
17194
+ _context19.next = 30;
17195
+ break;
17196
+ }
17197
+ throw new ValidationError("Address information not found");
17198
+
17199
+ case 30:
17200
+ return _context19.abrupt("return", type === "stat" ? [ json ] : json.result);
17201
+
17202
+ case 33:
17203
+ _context19.prev = 33;
17204
+ _context19.t1 = _context19["catch"](0);
17205
+ return _context19.abrupt("return", errorMessageHandler(_context19.t1, "BLOCKSCOUT"));
17206
+
17207
+ case 36:
17443
17208
  case "end":
17444
17209
  return _context19.stop();
17445
17210
  }
17446
- }), _callee19, null, [ [ 0, 12 ] ]);
17211
+ }), _callee16, null, [ [ 0, 33 ] ]);
17447
17212
  })));
17448
- return _ETHERSCAN.apply(this, arguments);
17213
+ return _BLOCKSCOUT.apply(this, arguments);
17449
17214
  }
17215
+ var allowedValues = [ "1h", "24h", "7d" ];
17216
+ var param2Schema = stringType().refine((function(val) {
17217
+ var tokens = val.split(",").map((function(t) {
17218
+ return t.trim().toLowerCase();
17219
+ }));
17220
+ return tokens.some((function(token) {
17221
+ return allowedValues.some((function(allowed) {
17222
+ return token.includes(allowed);
17223
+ }));
17224
+ }));
17225
+ }), {
17226
+ message: "param2 must contain at least one of: '1h', '24h', '7d'"
17227
+ }).optional();
17228
+ var priceSchema = objectType({
17229
+ category: literalType("price"),
17230
+ param1: stringType().nonempty(),
17231
+ param2: stringType().nonempty().optional()
17232
+ });
17233
+ var marketEcosystems = [ "all", "base", "meme", "aiagents", "bitcoin", "ethereum", "hyperliquid", "pump", "solana" ];
17234
+ var marketSchema = objectType({
17235
+ category: literalType("market"),
17236
+ param1: enumType(marketEcosystems),
17237
+ param2: param2Schema
17238
+ });
17239
+ var stablecoinsTypes = [ "all", "yield-bearing-stablecoins", "crypto-backed-stablecoin" ];
17240
+ var stablecoinsSchema = objectType({
17241
+ category: literalType("stablecoins"),
17242
+ param1: enumType(stablecoinsTypes),
17243
+ param2: param2Schema
17244
+ });
17245
+ var derivativesSchema = objectType({
17246
+ category: literalType("derivatives"),
17247
+ param1: stringType().nonempty(),
17248
+ param2: anyType().optional()
17249
+ });
17250
+ var coingeckoParamsSchema = discriminatedUnionType("category", [ priceSchema, marketSchema, stablecoinsSchema, derivativesSchema ]);
17450
17251
  function COINGECKO() {
17451
17252
  return _COINGECKO.apply(this, arguments);
17452
17253
  }
17453
17254
  function _COINGECKO() {
17454
- _COINGECKO = _asyncToGenerator(_regeneratorRuntime().mark((function _callee20() {
17455
- var _category$toLowerCase, _argsToArray17, _argsToArray18, category, param1, param2, apiKey, headers, url, vs, map, _category, trend, _category2, _trend, _getUrlAndHeaders8, finalUrl, HEADERS, res, json, _json$status, msg, out, _i13, _Object$entries4, _Object$entries4$_i, token, prices, _i14, _Object$entries5, _Object$entries5$_i, cur, val, _data4, _args20 = arguments;
17456
- return _regeneratorRuntime().wrap((function _callee20$(_context20) {
17255
+ _COINGECKO = _asyncToGenerator(_regeneratorRuntime().mark((function _callee17() {
17256
+ var _category$toLowerCase, _argsToArray1, _argsToArray10, category, param1, param2, apiKey, headers, url, vs, map, _category, trend, _category2, _trend, _getUrlAndHeaders5, finalUrl, HEADERS, res, json, _json$status, msg, out, _i11, _Object$entries, _Object$entries$_i, token, prices, _i12, _Object$entries2, _Object$entries2$_i, cur, val, _data, _args20 = arguments;
17257
+ return _regeneratorRuntime().wrap((function _callee17$(_context20) {
17457
17258
  while (1) switch (_context20.prev = _context20.next) {
17458
17259
  case 0:
17459
17260
  _context20.prev = 0;
17460
- _argsToArray17 = argsToArray(_args20), _argsToArray18 = _slicedToArray(_argsToArray17, 3),
17461
- category = _argsToArray18[0], param1 = _argsToArray18[1], param2 = _argsToArray18[2];
17261
+ _argsToArray1 = argsToArray(_args20), _argsToArray10 = _slicedToArray(_argsToArray1, 3),
17262
+ category = _argsToArray10[0], param1 = _argsToArray10[1], param2 = _argsToArray10[2];
17462
17263
  validateParams(coingeckoParamsSchema, {
17463
17264
  category: category,
17464
17265
  param1: param1,
@@ -17507,11 +17308,11 @@ function _typeof(o) {
17507
17308
  return _context20.abrupt("break", 23);
17508
17309
 
17509
17310
  case 23:
17510
- _getUrlAndHeaders8 = getUrlAndHeaders({
17311
+ _getUrlAndHeaders5 = getUrlAndHeaders({
17511
17312
  url: url,
17512
17313
  serviceName: "Coingecko",
17513
17314
  headers: headers
17514
- }), finalUrl = _getUrlAndHeaders8.URL, HEADERS = _getUrlAndHeaders8.HEADERS;
17315
+ }), finalUrl = _getUrlAndHeaders5.URL, HEADERS = _getUrlAndHeaders5.HEADERS;
17515
17316
  _context20.next = 26;
17516
17317
  return fetch(finalUrl, {
17517
17318
  headers: HEADERS
@@ -17544,25 +17345,25 @@ function _typeof(o) {
17544
17345
  break;
17545
17346
  }
17546
17347
  out = {};
17547
- for (_i13 = 0, _Object$entries4 = Object.entries(json); _i13 < _Object$entries4.length; _i13++) {
17548
- _Object$entries4$_i = _slicedToArray(_Object$entries4[_i13], 2), token = _Object$entries4$_i[0],
17549
- prices = _Object$entries4$_i[1];
17550
- for (_i14 = 0, _Object$entries5 = Object.entries(prices); _i14 < _Object$entries5.length; _i14++) {
17551
- _Object$entries5$_i = _slicedToArray(_Object$entries5[_i14], 2), cur = _Object$entries5$_i[0],
17552
- val = _Object$entries5$_i[1];
17348
+ for (_i11 = 0, _Object$entries = Object.entries(json); _i11 < _Object$entries.length; _i11++) {
17349
+ _Object$entries$_i = _slicedToArray(_Object$entries[_i11], 2), token = _Object$entries$_i[0],
17350
+ prices = _Object$entries$_i[1];
17351
+ for (_i12 = 0, _Object$entries2 = Object.entries(prices); _i12 < _Object$entries2.length; _i12++) {
17352
+ _Object$entries2$_i = _slicedToArray(_Object$entries2[_i12], 2), cur = _Object$entries2$_i[0],
17353
+ val = _Object$entries2$_i[1];
17553
17354
  out["".concat(token.charAt(0).toUpperCase() + token.slice(1), "_").concat(cur.toUpperCase())] = val;
17554
17355
  }
17555
17356
  }
17556
17357
  return _context20.abrupt("return", [ out ]);
17557
17358
 
17558
17359
  case 39:
17559
- _data4 = Array.isArray(json) ? json : [ json ];
17560
- return _context20.abrupt("return", _data4.map((function(item) {
17360
+ _data = Array.isArray(json) ? json : [ json ];
17361
+ return _context20.abrupt("return", _data.map((function(item) {
17561
17362
  var flat = {};
17562
- for (var _i15 = 0, _Object$entries6 = Object.entries(item); _i15 < _Object$entries6.length; _i15++) {
17563
- var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i15], 2), key = _Object$entries6$_i[0], _value13 = _Object$entries6$_i[1];
17564
- if (_typeof(_value13) !== "object" || _value13 === null) {
17565
- flat[key] = _value13;
17363
+ for (var _i13 = 0, _Object$entries3 = Object.entries(item); _i13 < _Object$entries3.length; _i13++) {
17364
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i13], 2), key = _Object$entries3$_i[0], _value11 = _Object$entries3$_i[1];
17365
+ if (_typeof(_value11) !== "object" || _value11 === null) {
17366
+ flat[key] = _value11;
17566
17367
  }
17567
17368
  }
17568
17369
  return flat;
@@ -17577,476 +17378,694 @@ function _typeof(o) {
17577
17378
  case "end":
17578
17379
  return _context20.stop();
17579
17380
  }
17580
- }), _callee20, null, [ [ 0, 43 ] ]);
17381
+ }), _callee17, null, [ [ 0, 43 ] ]);
17581
17382
  })));
17582
17383
  return _COINGECKO.apply(this, arguments);
17583
17384
  }
17584
- function EOA() {
17585
- return _EOA.apply(this, arguments);
17385
+ var categories = [ "protocols", "yields", "dex", "fees" ];
17386
+ var defillamaParamsSchema = objectType({
17387
+ category: enumType(categories)
17388
+ });
17389
+ var CATEGORY_URLS = {
17390
+ protocols: "https://api.llama.fi/protocols",
17391
+ yields: "https://yields.llama.fi/pools",
17392
+ dex: "https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true",
17393
+ fees: "https://api.llama.fi/overview/fees?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true&dataType=dailyFees"
17394
+ };
17395
+ function DEFILLAMA() {
17396
+ return _DEFILLAMA.apply(this, arguments);
17586
17397
  }
17587
- function _EOA() {
17588
- _EOA = _asyncToGenerator(_regeneratorRuntime().mark((function _callee22() {
17589
- var fetchJSON, _argsToArray19, _argsToArray20, addresses, category, chains, startTime, endTime, _argsToArray20$, page, _argsToArray20$2, offset, apiKey, INPUTS, CHAINS, ADDRESS_MAP, _iterator41, _step41, inp, _address, ADDRS, out, _iterator42, _step42, _loop, _ret, _args25 = arguments;
17590
- return _regeneratorRuntime().wrap((function _callee22$(_context25) {
17591
- while (1) switch (_context25.prev = _context25.next) {
17398
+ function _DEFILLAMA() {
17399
+ _DEFILLAMA = _asyncToGenerator(_regeneratorRuntime().mark((function _callee18() {
17400
+ var _argsToArray11, _argsToArray12, category, url, res, json, _args21 = arguments;
17401
+ return _regeneratorRuntime().wrap((function _callee18$(_context21) {
17402
+ while (1) switch (_context21.prev = _context21.next) {
17592
17403
  case 0:
17593
- _context25.prev = 0;
17594
- fetchJSON = function() {
17595
- var _ref16 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee21(url) {
17596
- var _getUrlAndHeaders9, finalUrl, HEADERS, res, json;
17597
- return _regeneratorRuntime().wrap((function _callee21$(_context21) {
17598
- while (1) switch (_context21.prev = _context21.next) {
17599
- case 0:
17600
- _getUrlAndHeaders9 = getUrlAndHeaders({
17601
- url: url,
17602
- serviceName: "Etherscan",
17603
- headers: {}
17604
- }), finalUrl = _getUrlAndHeaders9.URL, HEADERS = _getUrlAndHeaders9.HEADERS;
17605
- _context21.next = 3;
17606
- return fetch(finalUrl, {
17607
- method: "GET",
17608
- headers: HEADERS
17609
- });
17610
-
17611
- case 3:
17612
- res = _context21.sent;
17613
- if (res.ok) {
17614
- _context21.next = 6;
17615
- break;
17616
- }
17617
- throw new NetworkError(SERVICES_API_KEY.Etherscan, res.status);
17618
-
17619
- case 6:
17620
- _context21.next = 8;
17621
- return res.json();
17622
-
17623
- case 8:
17624
- json = _context21.sent;
17625
- if (!(typeof json.result === "string")) {
17626
- _context21.next = 14;
17627
- break;
17628
- }
17629
- if (!json.result.includes("Invalid API Key")) {
17630
- _context21.next = 12;
17631
- break;
17632
- }
17633
- throw new InvalidApiKeyError(SERVICES_API_KEY.Etherscan);
17634
-
17635
- case 12:
17636
- if (!json.result.includes("Max rate limit reached")) {
17637
- _context21.next = 14;
17638
- break;
17639
- }
17640
- throw new RateLimitError(SERVICES_API_KEY.Etherscan);
17641
-
17642
- case 14:
17643
- return _context21.abrupt("return", json.result);
17644
-
17645
- case 15:
17646
- case "end":
17647
- return _context21.stop();
17648
- }
17649
- }), _callee21);
17650
- })));
17651
- return function fetchJSON(_x18) {
17652
- return _ref16.apply(this, arguments);
17653
- };
17654
- }();
17655
- _argsToArray19 = argsToArray(_args25), _argsToArray20 = _slicedToArray(_argsToArray19, 7),
17656
- addresses = _argsToArray20[0], category = _argsToArray20[1], chains = _argsToArray20[2],
17657
- startTime = _argsToArray20[3], endTime = _argsToArray20[4], _argsToArray20$ = _argsToArray20[5],
17658
- page = _argsToArray20$ === void 0 ? 1 : _argsToArray20$, _argsToArray20$2 = _argsToArray20[6],
17659
- offset = _argsToArray20$2 === void 0 ? 10 : _argsToArray20$2;
17660
- validateParams(eoaParamsSchema, {
17661
- addresses: addresses,
17662
- category: category,
17663
- chains: chains,
17664
- startTime: startTime,
17665
- endTime: endTime,
17666
- page: page,
17667
- offset: offset
17404
+ _context21.prev = 0;
17405
+ _argsToArray11 = argsToArray(_args21), _argsToArray12 = _slicedToArray(_argsToArray11, 1),
17406
+ category = _argsToArray12[0];
17407
+ validateParams(defillamaParamsSchema, {
17408
+ category: category
17668
17409
  });
17669
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
17670
- INPUTS = addresses.split(",").map((function(s) {
17671
- return s.trim();
17672
- })).filter(Boolean);
17673
- CHAINS = chains.split(",").map((function(s) {
17674
- return s.trim();
17675
- })).filter(Boolean);
17676
- ADDRESS_MAP = {};
17677
- _iterator41 = _createForOfIteratorHelper(INPUTS);
17678
- _context25.prev = 9;
17679
- _iterator41.s();
17680
-
17681
- case 11:
17682
- if ((_step41 = _iterator41.n()).done) {
17683
- _context25.next = 23;
17410
+ url = CATEGORY_URLS[category];
17411
+ if (url) {
17412
+ _context21.next = 6;
17684
17413
  break;
17685
17414
  }
17686
- inp = _step41.value;
17687
- if (!isAddress$1.isAddress(inp)) {
17688
- _context25.next = 17;
17415
+ throw new ValidationError("Invalid category: ".concat(category));
17416
+
17417
+ case 6:
17418
+ _context21.next = 8;
17419
+ return fetch(url);
17420
+
17421
+ case 8:
17422
+ res = _context21.sent;
17423
+ if (res.ok) {
17424
+ _context21.next = 11;
17689
17425
  break;
17690
17426
  }
17691
- ADDRESS_MAP[inp.toLowerCase()] = null;
17692
- _context25.next = 21;
17427
+ throw new NetworkError(SERVICES_API_KEY.Defillama, res.status);
17428
+
17429
+ case 11:
17430
+ _context21.next = 13;
17431
+ return res.json();
17432
+
17433
+ case 13:
17434
+ json = _context21.sent;
17435
+ _context21.t0 = category;
17436
+ _context21.next = _context21.t0 === "protocols" ? 17 : _context21.t0 === "yields" ? 19 : _context21.t0 === "dex" ? 21 : _context21.t0 === "fees" ? 21 : 23;
17693
17437
  break;
17694
17438
 
17695
17439
  case 17:
17696
- _context25.next = 19;
17697
- return fromEnsNameToAddress$1.validateAndGetAddress(inp);
17440
+ json = Array.isArray(json) ? json.slice(0, 500) : [];
17441
+ return _context21.abrupt("break", 23);
17698
17442
 
17699
17443
  case 19:
17700
- _address = _context25.sent;
17701
- ADDRESS_MAP[_address.toLowerCase()] = _address;
17444
+ json = Array.isArray(json.data) ? json.data.slice(0, 500) : [];
17445
+ return _context21.abrupt("break", 23);
17702
17446
 
17703
17447
  case 21:
17704
- _context25.next = 11;
17705
- break;
17448
+ json = Array.isArray(json.protocols) ? json.protocols.slice(0, 500) : [];
17449
+ return _context21.abrupt("break", 23);
17706
17450
 
17707
17451
  case 23:
17708
- _context25.next = 28;
17709
- break;
17710
-
17711
- case 25:
17712
- _context25.prev = 25;
17713
- _context25.t0 = _context25["catch"](9);
17714
- _iterator41.e(_context25.t0);
17715
-
17716
- case 28:
17717
- _context25.prev = 28;
17718
- _iterator41.f();
17719
- return _context25.finish(28);
17720
-
17721
- case 31:
17722
- ADDRS = Object.keys(ADDRESS_MAP);
17723
- out = [];
17724
- _iterator42 = _createForOfIteratorHelper(CHAINS);
17725
- _context25.prev = 34;
17726
- _loop = _regeneratorRuntime().mark((function _loop() {
17727
- var chain, chainId, _loop2, _ret2, i, sb, eb, _loop3, _ret3, _i16, _ADDRS;
17728
- return _regeneratorRuntime().wrap((function _loop$(_context24) {
17729
- while (1) switch (_context24.prev = _context24.next) {
17730
- case 0:
17731
- chain = _step42.value;
17732
- chainId = CHAIN_ID_MAP[chain];
17733
- if (chainId) {
17734
- _context24.next = 4;
17735
- break;
17736
- }
17737
- throw new ValidationError("Invalid chain: ".concat(chain));
17738
-
17739
- case 4:
17740
- if (!(category === "balance")) {
17741
- _context24.next = 17;
17742
- break;
17743
- }
17744
- _loop2 = _regeneratorRuntime().mark((function _loop2(i) {
17745
- var slice, url, data;
17746
- return _regeneratorRuntime().wrap((function _loop2$(_context22) {
17747
- while (1) switch (_context22.prev = _context22.next) {
17748
- case 0:
17749
- slice = ADDRS.slice(i, i + 20).join(",");
17750
- url = "https://api.etherscan.io/v2/api?chainid=".concat(chainId) + "&module=account&action=addresstokenbalance&address=".concat(slice) + "&page=".concat(page, "&offset=").concat(offset, "&apikey=").concat(apiKey);
17751
- _context22.next = 4;
17752
- return fetchJSON(url);
17753
-
17754
- case 4:
17755
- data = _context22.sent;
17756
- if (Array.isArray(data)) {
17757
- _context22.next = 7;
17758
- break;
17759
- }
17760
- return _context22.abrupt("return", {
17761
- v: {
17762
- v: data
17763
- }
17764
- });
17765
-
17766
- case 7:
17767
- data.forEach((function(item, idx) {
17768
- return out.push(_objectSpread({
17769
- chain: chain,
17770
- address: ADDRS[i + idx],
17771
- name: ADDRESS_MAP[ADDRS[i + idx]]
17772
- }, item));
17773
- }));
17774
-
17775
- case 8:
17776
- case "end":
17777
- return _context22.stop();
17778
- }
17779
- }), _loop2);
17780
- }));
17781
- i = 0;
17782
-
17783
- case 7:
17784
- if (!(i < ADDRS.length)) {
17785
- _context24.next = 15;
17786
- break;
17787
- }
17788
- return _context24.delegateYield(_loop2(i), "t0", 9);
17789
-
17790
- case 9:
17791
- _ret2 = _context24.t0;
17792
- if (!_ret2) {
17793
- _context24.next = 12;
17794
- break;
17795
- }
17796
- return _context24.abrupt("return", _ret2.v);
17797
-
17798
- case 12:
17799
- i += 20;
17800
- _context24.next = 7;
17801
- break;
17802
-
17803
- case 15:
17804
- _context24.next = 37;
17805
- break;
17452
+ return _context21.abrupt("return", (Array.isArray(json) ? json : [ json ]).map((function(item) {
17453
+ var out = {};
17454
+ for (var _i14 = 0, _Object$entries4 = Object.entries(item); _i14 < _Object$entries4.length; _i14++) {
17455
+ var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i14], 2), k = _Object$entries4$_i[0], v = _Object$entries4$_i[1];
17456
+ if (v === null || _typeof(v) !== "object") out[k] = v;
17457
+ }
17458
+ return out;
17459
+ })));
17806
17460
 
17807
- case 17:
17808
- _context24.next = 19;
17809
- return fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startTime), chain, apiKey);
17461
+ case 26:
17462
+ _context21.prev = 26;
17463
+ _context21.t1 = _context21["catch"](0);
17464
+ return _context21.abrupt("return", errorMessageHandler(_context21.t1, "DEFILLAMA"));
17810
17465
 
17811
- case 19:
17812
- sb = _context24.sent;
17813
- _context24.next = 22;
17814
- return fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endTime), chain, apiKey);
17466
+ case 29:
17467
+ case "end":
17468
+ return _context21.stop();
17469
+ }
17470
+ }), _callee18, null, [ [ 0, 26 ] ]);
17471
+ })));
17472
+ return _DEFILLAMA.apply(this, arguments);
17473
+ }
17474
+ var gasSchema = objectType({
17475
+ type: literalType("gas"),
17476
+ startDate: dateOrTimestamp.optional(),
17477
+ endDate: dateOrTimestamp.optional(),
17478
+ page: numberType()["int"]().nonnegative()["default"](1),
17479
+ limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17480
+ message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17481
+ })["default"](10)
17482
+ });
17483
+ var txnSchema = objectType({
17484
+ type: enumType([ "all-txns", "token-txns", "nft-txns" ]),
17485
+ address: stringType().nonempty(),
17486
+ startDate: dateOrTimestamp.optional(),
17487
+ endDate: dateOrTimestamp.optional(),
17488
+ chain: enumType([ "ethereum", "base", "gnosis" ]),
17489
+ page: numberType()["int"]().nonnegative()["default"](1),
17490
+ limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17491
+ message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17492
+ })["default"](10)
17493
+ });
17494
+ var etherscanParamsSchema = discriminatedUnionType("type", [ gasSchema, txnSchema ]);
17495
+ function ETHERSCAN() {
17496
+ return _ETHERSCAN.apply(this, arguments);
17497
+ }
17498
+ function _ETHERSCAN() {
17499
+ _ETHERSCAN = _asyncToGenerator(_regeneratorRuntime().mark((function _callee19() {
17500
+ var _argsToArray13, _argsToArray14, type, chain, address, startDate, endDate, _argsToArray14$, page, _argsToArray14$2, limit, chainId, apiKey, _args22 = arguments;
17501
+ return _regeneratorRuntime().wrap((function _callee19$(_context22) {
17502
+ while (1) switch (_context22.prev = _context22.next) {
17503
+ case 0:
17504
+ _context22.prev = 0;
17505
+ _argsToArray13 = argsToArray(_args22), _argsToArray14 = _slicedToArray(_argsToArray13, 7),
17506
+ type = _argsToArray14[0], chain = _argsToArray14[1], address = _argsToArray14[2],
17507
+ startDate = _argsToArray14[3], endDate = _argsToArray14[4], _argsToArray14$ = _argsToArray14[5],
17508
+ page = _argsToArray14$ === void 0 ? 1 : _argsToArray14$, _argsToArray14$2 = _argsToArray14[6],
17509
+ limit = _argsToArray14$2 === void 0 ? 10 : _argsToArray14$2;
17510
+ validateParams(etherscanParamsSchema, {
17511
+ type: type,
17512
+ chain: chain,
17513
+ address: address,
17514
+ startDate: startDate,
17515
+ endDate: endDate,
17516
+ page: page,
17517
+ limit: limit
17518
+ });
17519
+ chainId = CHAIN_ID_MAP[chain];
17520
+ if (chainId) {
17521
+ _context22.next = 6;
17522
+ break;
17523
+ }
17524
+ throw new ValidationError("Invalid chain: ".concat(chain));
17815
17525
 
17816
- case 22:
17817
- eb = _context24.sent;
17818
- if (sb) {
17819
- _context24.next = 25;
17820
- break;
17821
- }
17822
- throw new ValidationError("Invalid startTime: ".concat(startTime));
17526
+ case 6:
17527
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
17528
+ _context22.next = 9;
17529
+ return handleScanRequest({
17530
+ type: type,
17531
+ address: address,
17532
+ startDate: startDate,
17533
+ endDate: endDate,
17534
+ page: page,
17535
+ offset: limit,
17536
+ apiKey: apiKey,
17537
+ functionName: "ETHERSCAN",
17538
+ chainId: chainId,
17539
+ network: chain
17540
+ });
17823
17541
 
17824
- case 25:
17825
- if (eb) {
17826
- _context24.next = 27;
17827
- break;
17828
- }
17829
- throw new ValidationError("Invalid endTime: ".concat(endTime));
17542
+ case 9:
17543
+ return _context22.abrupt("return", _context22.sent);
17830
17544
 
17831
- case 27:
17832
- _loop3 = _regeneratorRuntime().mark((function _loop3() {
17833
- var addr, url, data;
17834
- return _regeneratorRuntime().wrap((function _loop3$(_context23) {
17835
- while (1) switch (_context23.prev = _context23.next) {
17836
- case 0:
17837
- addr = _ADDRS[_i16];
17838
- url = "https://api.etherscan.io/v2/api?chainid=".concat(chainId) + "&module=account&action=tokentx&address=".concat(addr) + "&startblock=".concat(sb, "&endblock=").concat(eb) + "&page=".concat(page, "&offset=").concat(offset, "&sort=asc&apikey=").concat(apiKey);
17839
- _context23.next = 4;
17840
- return fetchJSON(url);
17545
+ case 12:
17546
+ _context22.prev = 12;
17547
+ _context22.t0 = _context22["catch"](0);
17548
+ return _context22.abrupt("return", errorMessageHandler(_context22.t0, "ETHERSCAN"));
17841
17549
 
17842
- case 4:
17843
- data = _context23.sent;
17844
- if (Array.isArray(data)) {
17845
- _context23.next = 7;
17846
- break;
17847
- }
17848
- return _context23.abrupt("return", {
17849
- v: {
17850
- v: data
17851
- }
17852
- });
17550
+ case 15:
17551
+ case "end":
17552
+ return _context22.stop();
17553
+ }
17554
+ }), _callee19, null, [ [ 0, 12 ] ]);
17555
+ })));
17556
+ return _ETHERSCAN.apply(this, arguments);
17557
+ }
17558
+ var farcasterParamsSchema = objectType({
17559
+ contentType: enumType([ "posts", "replies", "channels" ]),
17560
+ identifier: stringType().nonempty(),
17561
+ start: numberType()["int"]().nonnegative()["default"](0),
17562
+ end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17563
+ message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17564
+ })["default"](10)
17565
+ });
17566
+ function FARCASTER() {
17567
+ return _FARCASTER.apply(this, arguments);
17568
+ }
17569
+ function _FARCASTER() {
17570
+ _FARCASTER = _asyncToGenerator(_regeneratorRuntime().mark((function _callee20() {
17571
+ var _argsToArray15, _argsToArray16, contentType, identifier, _argsToArray16$, start, _argsToArray16$2, end, apiKey, url, typeMap, _getUrlAndHeaders6, finalUrl, HEADERS, response, _yield$response$json, _data2, _args23 = arguments;
17572
+ return _regeneratorRuntime().wrap((function _callee20$(_context23) {
17573
+ while (1) switch (_context23.prev = _context23.next) {
17574
+ case 0:
17575
+ _context23.prev = 0;
17576
+ _argsToArray15 = argsToArray(_args23), _argsToArray16 = _slicedToArray(_argsToArray15, 4),
17577
+ contentType = _argsToArray16[0], identifier = _argsToArray16[1], _argsToArray16$ = _argsToArray16[2],
17578
+ start = _argsToArray16$ === void 0 ? 0 : _argsToArray16$, _argsToArray16$2 = _argsToArray16[3],
17579
+ end = _argsToArray16$2 === void 0 ? 10 : _argsToArray16$2;
17580
+ validateParams(farcasterParamsSchema, {
17581
+ contentType: contentType,
17582
+ identifier: identifier,
17583
+ start: start,
17584
+ end: end
17585
+ });
17586
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
17587
+ url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
17588
+ url.searchParams.set("query", identifier.split(",").map((function(s) {
17589
+ return s.trim();
17590
+ })).filter(Boolean).join(","));
17591
+ typeMap = {
17592
+ posts: "farcasterid",
17593
+ replies: "farcasterpostid",
17594
+ channels: "farcasterchannels"
17595
+ };
17596
+ url.searchParams.set("type", typeMap[contentType]);
17597
+ url.searchParams.set("start", String(start));
17598
+ url.searchParams.set("end", String(end));
17599
+ _getUrlAndHeaders6 = getUrlAndHeaders({
17600
+ url: url.toString(),
17601
+ serviceName: "Firefly",
17602
+ headers: {
17603
+ "x-api-key": apiKey
17604
+ }
17605
+ }), finalUrl = _getUrlAndHeaders6.URL, HEADERS = _getUrlAndHeaders6.HEADERS;
17606
+ _context23.next = 13;
17607
+ return fetch(finalUrl, {
17608
+ method: "GET",
17609
+ headers: HEADERS
17610
+ });
17853
17611
 
17854
- case 7:
17855
- data.forEach((function(item) {
17856
- return out.push(_objectSpread({
17857
- chain: chain,
17858
- address: addr,
17859
- name: ADDRESS_MAP[addr]
17860
- }, item));
17861
- }));
17612
+ case 13:
17613
+ response = _context23.sent;
17614
+ if (response.ok) {
17615
+ _context23.next = 16;
17616
+ break;
17617
+ }
17618
+ throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
17862
17619
 
17863
- case 8:
17864
- case "end":
17865
- return _context23.stop();
17866
- }
17867
- }), _loop3);
17868
- }));
17869
- _i16 = 0, _ADDRS = ADDRS;
17620
+ case 16:
17621
+ _context23.next = 18;
17622
+ return response.json();
17870
17623
 
17871
- case 29:
17872
- if (!(_i16 < _ADDRS.length)) {
17873
- _context24.next = 37;
17874
- break;
17875
- }
17876
- return _context24.delegateYield(_loop3(), "t1", 31);
17624
+ case 18:
17625
+ _yield$response$json = _context23.sent;
17626
+ _data2 = _yield$response$json.data;
17627
+ if (Array.isArray(_data2)) {
17628
+ _context23.next = 22;
17629
+ break;
17630
+ }
17631
+ return _context23.abrupt("return", []);
17877
17632
 
17878
- case 31:
17879
- _ret3 = _context24.t1;
17880
- if (!_ret3) {
17881
- _context24.next = 34;
17882
- break;
17883
- }
17884
- return _context24.abrupt("return", _ret3.v);
17633
+ case 22:
17634
+ return _context23.abrupt("return", _data2.map((function(item) {
17635
+ var flat = {};
17636
+ for (var _i15 = 0, _Object$entries5 = Object.entries(item); _i15 < _Object$entries5.length; _i15++) {
17637
+ var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i15], 2), k = _Object$entries5$_i[0], v = _Object$entries5$_i[1];
17638
+ if (v == null || _typeof(v) !== "object") {
17639
+ flat[k] = v;
17640
+ }
17641
+ }
17642
+ flat.platform = "farcaster";
17643
+ return flat;
17644
+ })));
17885
17645
 
17886
- case 34:
17887
- _i16++;
17888
- _context24.next = 29;
17889
- break;
17646
+ case 25:
17647
+ _context23.prev = 25;
17648
+ _context23.t0 = _context23["catch"](0);
17649
+ return _context23.abrupt("return", errorMessageHandler(_context23.t0, "FARCASTER"));
17890
17650
 
17891
- case 37:
17892
- case "end":
17893
- return _context24.stop();
17894
- }
17895
- }), _loop);
17896
- }));
17897
- _iterator42.s();
17651
+ case 28:
17652
+ case "end":
17653
+ return _context23.stop();
17654
+ }
17655
+ }), _callee20, null, [ [ 0, 25 ] ]);
17656
+ })));
17657
+ return _FARCASTER.apply(this, arguments);
17658
+ }
17659
+ var farcasterSchema = objectType({
17660
+ platform: literalType("farcaster"),
17661
+ contentType: enumType([ "posts", "replies", "channels" ]),
17662
+ identifier: stringType().nonempty(),
17663
+ start: numberType()["int"]().nonnegative()["default"](0),
17664
+ end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17665
+ message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17666
+ })["default"](10)
17667
+ });
17668
+ var lensSchema = objectType({
17669
+ platform: literalType("lens"),
17670
+ contentType: enumType([ "posts", "replies" ]),
17671
+ identifier: stringType().nonempty(),
17672
+ start: numberType()["int"]().nonnegative()["default"](0),
17673
+ end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17674
+ message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17675
+ })["default"](10)
17676
+ });
17677
+ var fireflyParamsSchema = discriminatedUnionType("platform", [ farcasterSchema, lensSchema ]);
17678
+ var fireFlyPlaformType = {
17679
+ farcaster: {
17680
+ posts: "farcasterid",
17681
+ replies: "farcasterpostid",
17682
+ channels: "farcasterchannels"
17683
+ },
17684
+ lens: {
17685
+ posts: "lensid",
17686
+ replies: "lenspostid"
17687
+ }
17688
+ };
17689
+ function FIREFLY() {
17690
+ return _FIREFLY.apply(this, arguments);
17691
+ }
17692
+ function _FIREFLY() {
17693
+ _FIREFLY = _asyncToGenerator(_regeneratorRuntime().mark((function _callee21() {
17694
+ var _argsToArray17, _argsToArray18, platform, contentType, identifier, _argsToArray18$, start, _argsToArray18$2, end, apiKey, url, _getUrlAndHeaders7, finalUrl, HEADERS, response, _yield$response$json2, _data3, _args24 = arguments;
17695
+ return _regeneratorRuntime().wrap((function _callee21$(_context24) {
17696
+ while (1) switch (_context24.prev = _context24.next) {
17697
+ case 0:
17698
+ _context24.prev = 0;
17699
+ _argsToArray17 = argsToArray(_args24), _argsToArray18 = _slicedToArray(_argsToArray17, 5),
17700
+ platform = _argsToArray18[0], contentType = _argsToArray18[1], identifier = _argsToArray18[2],
17701
+ _argsToArray18$ = _argsToArray18[3], start = _argsToArray18$ === void 0 ? 0 : _argsToArray18$,
17702
+ _argsToArray18$2 = _argsToArray18[4], end = _argsToArray18$2 === void 0 ? 10 : _argsToArray18$2;
17703
+ validateParams(fireflyParamsSchema, {
17704
+ platform: platform,
17705
+ contentType: contentType,
17706
+ identifier: identifier,
17707
+ start: start,
17708
+ end: end
17709
+ });
17710
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
17711
+ url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
17712
+ url.searchParams.set("query", identifier.split(",").map((function(s) {
17713
+ return s.trim();
17714
+ })).filter(Boolean).join(","));
17715
+ url.searchParams.set("type", fireFlyPlaformType[platform][contentType]);
17716
+ url.searchParams.set("start", String(start));
17717
+ url.searchParams.set("end", String(end));
17718
+ _getUrlAndHeaders7 = getUrlAndHeaders({
17719
+ url: url.toString(),
17720
+ serviceName: "Firefly",
17721
+ headers: {
17722
+ "x-api-key": apiKey
17723
+ }
17724
+ }), finalUrl = _getUrlAndHeaders7.URL, HEADERS = _getUrlAndHeaders7.HEADERS;
17725
+ _context24.next = 12;
17726
+ return fetch(finalUrl, {
17727
+ method: "GET",
17728
+ headers: HEADERS
17729
+ });
17898
17730
 
17899
- case 37:
17900
- if ((_step42 = _iterator42.n()).done) {
17901
- _context25.next = 44;
17731
+ case 12:
17732
+ response = _context24.sent;
17733
+ if (response.ok) {
17734
+ _context24.next = 15;
17902
17735
  break;
17903
17736
  }
17904
- return _context25.delegateYield(_loop(), "t1", 39);
17737
+ throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
17905
17738
 
17906
- case 39:
17907
- _ret = _context25.t1;
17908
- if (!_ret) {
17909
- _context25.next = 42;
17739
+ case 15:
17740
+ _context24.next = 17;
17741
+ return response.json();
17742
+
17743
+ case 17:
17744
+ _yield$response$json2 = _context24.sent;
17745
+ _data3 = _yield$response$json2.data;
17746
+ if (Array.isArray(_data3)) {
17747
+ _context24.next = 21;
17910
17748
  break;
17911
17749
  }
17912
- return _context25.abrupt("return", _ret.v);
17913
-
17914
- case 42:
17915
- _context25.next = 37;
17916
- break;
17750
+ return _context24.abrupt("return", []);
17917
17751
 
17918
- case 44:
17919
- _context25.next = 49;
17920
- break;
17752
+ case 21:
17753
+ return _context24.abrupt("return", _data3.map((function(item) {
17754
+ var flat = {};
17755
+ for (var _i16 = 0, _Object$entries6 = Object.entries(item); _i16 < _Object$entries6.length; _i16++) {
17756
+ var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i16], 2), key = _Object$entries6$_i[0], _value12 = _Object$entries6$_i[1];
17757
+ if (_typeof(_value12) !== "object" || _value12 === null) {
17758
+ flat[key] = _value12;
17759
+ }
17760
+ }
17761
+ flat.platform = platform;
17762
+ return flat;
17763
+ })));
17921
17764
 
17922
- case 46:
17923
- _context25.prev = 46;
17924
- _context25.t2 = _context25["catch"](34);
17925
- _iterator42.e(_context25.t2);
17765
+ case 24:
17766
+ _context24.prev = 24;
17767
+ _context24.t0 = _context24["catch"](0);
17768
+ return _context24.abrupt("return", errorMessageHandler(_context24.t0, "FIREFLY"));
17926
17769
 
17927
- case 49:
17928
- _context25.prev = 49;
17929
- _iterator42.f();
17930
- return _context25.finish(49);
17770
+ case 27:
17771
+ case "end":
17772
+ return _context24.stop();
17773
+ }
17774
+ }), _callee21, null, [ [ 0, 24 ] ]);
17775
+ })));
17776
+ return _FIREFLY.apply(this, arguments);
17777
+ }
17778
+ function GNOSIS() {
17779
+ return _GNOSIS.apply(this, arguments);
17780
+ }
17781
+ function _GNOSIS() {
17782
+ _GNOSIS = _asyncToGenerator(_regeneratorRuntime().mark((function _callee22() {
17783
+ var _argsToArray19, _argsToArray20, type, address, startDate, endDate, _argsToArray20$, page, _argsToArray20$2, limit, apiKey, _args25 = arguments;
17784
+ return _regeneratorRuntime().wrap((function _callee22$(_context25) {
17785
+ while (1) switch (_context25.prev = _context25.next) {
17786
+ case 0:
17787
+ _context25.prev = 0;
17788
+ _argsToArray19 = argsToArray(_args25), _argsToArray20 = _slicedToArray(_argsToArray19, 6),
17789
+ type = _argsToArray20[0], address = _argsToArray20[1], startDate = _argsToArray20[2],
17790
+ endDate = _argsToArray20[3], _argsToArray20$ = _argsToArray20[4], page = _argsToArray20$ === void 0 ? 1 : _argsToArray20$,
17791
+ _argsToArray20$2 = _argsToArray20[5], limit = _argsToArray20$2 === void 0 ? 10 : _argsToArray20$2;
17792
+ validateParams(baseParamsSchema, {
17793
+ type: type,
17794
+ address: address,
17795
+ startDate: startDate,
17796
+ endDate: endDate,
17797
+ page: page,
17798
+ limit: limit
17799
+ });
17800
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Gnosisscan);
17801
+ _context25.next = 6;
17802
+ return handleScanRequest({
17803
+ type: type,
17804
+ address: address,
17805
+ startDate: startDate,
17806
+ endDate: endDate,
17807
+ page: page,
17808
+ offset: limit,
17809
+ apiKey: apiKey,
17810
+ functionName: "GNOSIS",
17811
+ chainId: CHAIN_ID_MAP.gnosis,
17812
+ network: "gnosis"
17813
+ });
17931
17814
 
17932
- case 52:
17933
- return _context25.abrupt("return", out);
17815
+ case 6:
17816
+ return _context25.abrupt("return", _context25.sent);
17934
17817
 
17935
- case 55:
17936
- _context25.prev = 55;
17937
- _context25.t3 = _context25["catch"](0);
17938
- return _context25.abrupt("return", errorMessageHandler(_context25.t3, "EOA"));
17818
+ case 9:
17819
+ _context25.prev = 9;
17820
+ _context25.t0 = _context25["catch"](0);
17821
+ return _context25.abrupt("return", errorMessageHandler(_context25.t0, "GNOSIS"));
17939
17822
 
17940
- case 58:
17823
+ case 12:
17941
17824
  case "end":
17942
17825
  return _context25.stop();
17943
17826
  }
17944
- }), _callee22, null, [ [ 0, 55 ], [ 9, 25, 28, 31 ], [ 34, 46, 49, 52 ] ]);
17827
+ }), _callee22, null, [ [ 0, 9 ] ]);
17945
17828
  })));
17946
- return _EOA.apply(this, arguments);
17829
+ return _GNOSIS.apply(this, arguments);
17947
17830
  }
17948
- function FLVURL(_x16, _x17) {
17949
- return _FLVURL.apply(this, arguments);
17831
+ var lensParamsSchema = objectType({
17832
+ contentType: enumType([ "posts", "replies" ]),
17833
+ identifier: stringType().nonempty(),
17834
+ start: numberType()["int"]().nonnegative()["default"](0),
17835
+ end: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
17836
+ message: '"end" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
17837
+ })["default"](10)
17838
+ });
17839
+ function LENS() {
17840
+ return _LENS.apply(this, arguments);
17950
17841
  }
17951
- function _FLVURL() {
17952
- _FLVURL = _asyncToGenerator(_regeneratorRuntime().mark((function _callee23(token, vs_currencies) {
17842
+ function _LENS() {
17843
+ _LENS = _asyncToGenerator(_regeneratorRuntime().mark((function _callee23() {
17844
+ var _argsToArray21, _argsToArray22, contentType, identifier, _argsToArray22$, start, _argsToArray22$2, end, apiKey, url, typeMap, _getUrlAndHeaders8, finalUrl, HEADERS, response, _yield$response$json3, _data4, _args26 = arguments;
17953
17845
  return _regeneratorRuntime().wrap((function _callee23$(_context26) {
17954
17846
  while (1) switch (_context26.prev = _context26.next) {
17955
17847
  case 0:
17956
- return _context26.abrupt("return", new Promise((function(resolve) {
17957
- setTimeout((function() {
17958
- resolve([ {
17959
- Yoo: "gotcha"
17960
- } ]);
17961
- }), 1e4);
17848
+ _context26.prev = 0;
17849
+ _argsToArray21 = argsToArray(_args26), _argsToArray22 = _slicedToArray(_argsToArray21, 4),
17850
+ contentType = _argsToArray22[0], identifier = _argsToArray22[1], _argsToArray22$ = _argsToArray22[2],
17851
+ start = _argsToArray22$ === void 0 ? 0 : _argsToArray22$, _argsToArray22$2 = _argsToArray22[3],
17852
+ end = _argsToArray22$2 === void 0 ? 10 : _argsToArray22$2;
17853
+ validateParams(lensParamsSchema, {
17854
+ contentType: contentType,
17855
+ identifier: identifier,
17856
+ start: start,
17857
+ end: end
17858
+ });
17859
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
17860
+ url = new URL("https://openapi.firefly.land/v1/fileverse/fetch");
17861
+ url.searchParams.set("query", identifier.split(",").map((function(s) {
17862
+ return s.trim();
17863
+ })).filter(Boolean).join(","));
17864
+ typeMap = {
17865
+ posts: "lensid",
17866
+ replies: "lenspostid"
17867
+ };
17868
+ url.searchParams.set("type", typeMap[contentType]);
17869
+ url.searchParams.set("start", String(start));
17870
+ url.searchParams.set("end", String(end));
17871
+ _getUrlAndHeaders8 = getUrlAndHeaders({
17872
+ url: url.toString(),
17873
+ serviceName: "Firefly",
17874
+ headers: {
17875
+ "x-api-key": apiKey
17876
+ }
17877
+ }), finalUrl = _getUrlAndHeaders8.URL, HEADERS = _getUrlAndHeaders8.HEADERS;
17878
+ _context26.next = 13;
17879
+ return fetch(finalUrl, {
17880
+ method: "GET",
17881
+ headers: HEADERS
17882
+ });
17883
+
17884
+ case 13:
17885
+ response = _context26.sent;
17886
+ if (response.ok) {
17887
+ _context26.next = 16;
17888
+ break;
17889
+ }
17890
+ throw new NetworkError(SERVICES_API_KEY.Firefly, response.status);
17891
+
17892
+ case 16:
17893
+ _context26.next = 18;
17894
+ return response.json();
17895
+
17896
+ case 18:
17897
+ _yield$response$json3 = _context26.sent;
17898
+ _data4 = _yield$response$json3.data;
17899
+ if (Array.isArray(_data4)) {
17900
+ _context26.next = 22;
17901
+ break;
17902
+ }
17903
+ return _context26.abrupt("return", []);
17904
+
17905
+ case 22:
17906
+ return _context26.abrupt("return", _data4.map((function(item) {
17907
+ var flat = {};
17908
+ for (var _i17 = 0, _Object$entries7 = Object.entries(item); _i17 < _Object$entries7.length; _i17++) {
17909
+ var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i17], 2), key = _Object$entries7$_i[0], _value13 = _Object$entries7$_i[1];
17910
+ if (_value13 == null || _typeof(_value13) !== "object") {
17911
+ flat[key] = _value13;
17912
+ }
17913
+ }
17914
+ flat.platform = "lens";
17915
+ return flat;
17962
17916
  })));
17963
17917
 
17964
- case 1:
17918
+ case 25:
17919
+ _context26.prev = 25;
17920
+ _context26.t0 = _context26["catch"](0);
17921
+ return _context26.abrupt("return", errorMessageHandler(_context26.t0, "LENS"));
17922
+
17923
+ case 28:
17965
17924
  case "end":
17966
17925
  return _context26.stop();
17967
17926
  }
17968
- }), _callee23);
17927
+ }), _callee23, null, [ [ 0, 25 ] ]);
17969
17928
  })));
17970
- return _FLVURL.apply(this, arguments);
17929
+ return _LENS.apply(this, arguments);
17971
17930
  }
17972
- function SAFE() {
17973
- return _SAFE.apply(this, arguments);
17931
+ var neynarParamsSchema = objectType({
17932
+ username: stringType().nonempty()
17933
+ });
17934
+ var fromUsernameToFid = function() {
17935
+ var _ref14 = _asyncToGenerator(_regeneratorRuntime().mark((function _callee1(username, apiKey) {
17936
+ var url, _getUrlAndHeaders2, finalUrl, HEADERS, res, json, users, user;
17937
+ return _regeneratorRuntime().wrap((function _callee1$(_context1) {
17938
+ while (1) switch (_context1.prev = _context1.next) {
17939
+ case 0:
17940
+ if (username) {
17941
+ _context1.next = 2;
17942
+ break;
17943
+ }
17944
+ return _context1.abrupt("return", null);
17945
+
17946
+ case 2:
17947
+ url = "https://api.neynar.com/v2/farcaster/user/search/?q=".concat(username, "&limit=5");
17948
+ _getUrlAndHeaders2 = getUrlAndHeaders({
17949
+ url: url,
17950
+ serviceName: "Neynar",
17951
+ headers: {
17952
+ "x-api-key": apiKey,
17953
+ "x-neynar-experimental": "false"
17954
+ }
17955
+ }), finalUrl = _getUrlAndHeaders2.URL, HEADERS = _getUrlAndHeaders2.HEADERS;
17956
+ _context1.next = 6;
17957
+ return fetch(finalUrl, {
17958
+ method: "GET",
17959
+ headers: HEADERS
17960
+ });
17961
+
17962
+ case 6:
17963
+ res = _context1.sent;
17964
+ _context1.next = 9;
17965
+ return res.json();
17966
+
17967
+ case 9:
17968
+ json = _context1.sent;
17969
+ users = json.result ? json.result.users : [];
17970
+ user = users.find((function(user) {
17971
+ return user.username === username;
17972
+ }));
17973
+ return _context1.abrupt("return", user && user.fid || null);
17974
+
17975
+ case 13:
17976
+ case "end":
17977
+ return _context1.stop();
17978
+ }
17979
+ }), _callee1);
17980
+ })));
17981
+ return function fromUsernameToFid(_x14, _x15) {
17982
+ return _ref14.apply(this, arguments);
17983
+ };
17984
+ }();
17985
+ var fromUsernameToFid$1 = {
17986
+ fromUsernameToFid: fromUsernameToFid
17987
+ };
17988
+ function NEYNAR() {
17989
+ return _NEYNAR.apply(this, arguments);
17974
17990
  }
17975
- function _SAFE() {
17976
- _SAFE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee24() {
17977
- var _argsToArray21, _argsToArray22, address, utility, chain, _argsToArray22$, limit, _argsToArray22$2, offset, apiKey, chainId, resolved, url, _getUrlAndHeaders0, finalUrl, HEADERS, res, json, _args27 = arguments;
17991
+ function _NEYNAR() {
17992
+ _NEYNAR = _asyncToGenerator(_regeneratorRuntime().mark((function _callee24() {
17993
+ var _argsToArray23, _argsToArray24, username, apiKey, fid, url, _getUrlAndHeaders9, finalUrl, HEADERS, response, json, users, _args27 = arguments;
17978
17994
  return _regeneratorRuntime().wrap((function _callee24$(_context27) {
17979
17995
  while (1) switch (_context27.prev = _context27.next) {
17980
17996
  case 0:
17981
17997
  _context27.prev = 0;
17982
- _argsToArray21 = argsToArray(_args27), _argsToArray22 = _slicedToArray(_argsToArray21, 5),
17983
- address = _argsToArray22[0], utility = _argsToArray22[1], chain = _argsToArray22[2],
17984
- _argsToArray22$ = _argsToArray22[3], limit = _argsToArray22$ === void 0 ? 10 : _argsToArray22$,
17985
- _argsToArray22$2 = _argsToArray22[4], offset = _argsToArray22$2 === void 0 ? 0 : _argsToArray22$2;
17986
- validateParams(safeParamsSchema, {
17987
- address: address,
17988
- utility: utility,
17989
- chain: chain,
17990
- limit: limit,
17991
- offset: offset
17998
+ _argsToArray23 = argsToArray(_args27), _argsToArray24 = _slicedToArray(_argsToArray23, 1),
17999
+ username = _argsToArray24[0];
18000
+ validateParams(neynarParamsSchema, {
18001
+ username: username
17992
18002
  });
17993
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Safe);
17994
- chainId = SAFE_CHAIN_MAP[chain];
17995
- if (chainId) {
17996
- _context27.next = 7;
18003
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Neynar);
18004
+ _context27.next = 6;
18005
+ return fromUsernameToFid$1.fromUsernameToFid(username, apiKey);
18006
+
18007
+ case 6:
18008
+ fid = _context27.sent;
18009
+ if (fid) {
18010
+ _context27.next = 9;
17997
18011
  break;
17998
18012
  }
17999
- throw new ValidationError("Invalid chain: ".concat(chain));
18000
-
18001
- case 7:
18002
- _context27.next = 9;
18003
- return fromEnsNameToAddress$1.validateAndGetAddress(address);
18013
+ throw new ValidationError("Invalid username: ".concat(username));
18004
18014
 
18005
18015
  case 9:
18006
- resolved = _context27.sent;
18007
- url = "https://api.safe.global/tx-service/".concat(chainId, "/api/v2/safes/").concat(resolved, "/multisig-transactions?limit=").concat(limit, "&offset=").concat(offset);
18008
- _getUrlAndHeaders0 = getUrlAndHeaders({
18009
- url: url,
18010
- serviceName: "Etherscan",
18016
+ url = "https://api.neynar.com/v2/farcaster/followers?fid=".concat(fid);
18017
+ _getUrlAndHeaders9 = getUrlAndHeaders({
18018
+ url: url.toString(),
18019
+ serviceName: "Neynar",
18011
18020
  headers: {
18012
- Authorization: "Bearer ".concat(apiKey)
18021
+ "x-api-key": apiKey,
18022
+ "x-neynar-experimental": "false"
18013
18023
  }
18014
- }), finalUrl = _getUrlAndHeaders0.URL, HEADERS = _getUrlAndHeaders0.HEADERS;
18015
- _context27.next = 14;
18024
+ }), finalUrl = _getUrlAndHeaders9.URL, HEADERS = _getUrlAndHeaders9.HEADERS;
18025
+ _context27.next = 13;
18016
18026
  return fetch(finalUrl, {
18027
+ method: "GET",
18017
18028
  headers: HEADERS
18018
18029
  });
18019
18030
 
18020
- case 14:
18021
- res = _context27.sent;
18022
- if (res.ok) {
18023
- _context27.next = 17;
18031
+ case 13:
18032
+ response = _context27.sent;
18033
+ if (response.ok) {
18034
+ _context27.next = 16;
18024
18035
  break;
18025
18036
  }
18026
- throw new NetworkError(SERVICES_API_KEY.Safe, res.status);
18037
+ throw new NetworkError(SERVICES_API_KEY.Neynar, response.status);
18027
18038
 
18028
- case 17:
18029
- _context27.next = 19;
18030
- return res.json();
18039
+ case 16:
18040
+ _context27.next = 18;
18041
+ return response.json();
18031
18042
 
18032
- case 19:
18043
+ case 18:
18033
18044
  json = _context27.sent;
18034
- if (Array.isArray(json.results)) {
18045
+ users = (json === null || json === void 0 ? void 0 : json.users) || [];
18046
+ if (users.length) {
18035
18047
  _context27.next = 22;
18036
18048
  break;
18037
18049
  }
18038
- throw new ValidationError("Invalid API response");
18050
+ return _context27.abrupt("return", []);
18039
18051
 
18040
18052
  case 22:
18041
- return _context27.abrupt("return", json.results.map((function(_ref17) {
18042
- var confirmations = _ref17.confirmations, dataDecoded = _ref17.dataDecoded, rest = _objectWithoutProperties(_ref17, _excluded);
18043
- return rest;
18053
+ return _context27.abrupt("return", users.map((function(_ref18) {
18054
+ var _user$profile, _user$profile2;
18055
+ var user = _ref18.user;
18056
+ return {
18057
+ username: user.username,
18058
+ custody_address: user.custody_address,
18059
+ follower_count: user.follower_count,
18060
+ country: ((_user$profile = user.profile) === null || _user$profile === void 0 || (_user$profile = _user$profile.location) === null || _user$profile === void 0 || (_user$profile = _user$profile.address) === null || _user$profile === void 0 ? void 0 : _user$profile.country) || "",
18061
+ city: ((_user$profile2 = user.profile) === null || _user$profile2 === void 0 || (_user$profile2 = _user$profile2.location) === null || _user$profile2 === void 0 || (_user$profile2 = _user$profile2.address) === null || _user$profile2 === void 0 ? void 0 : _user$profile2.city) || ""
18062
+ };
18044
18063
  })));
18045
18064
 
18046
18065
  case 25:
18047
18066
  _context27.prev = 25;
18048
18067
  _context27.t0 = _context27["catch"](0);
18049
- return _context27.abrupt("return", errorMessageHandler(_context27.t0, "SAFE"));
18068
+ return _context27.abrupt("return", errorMessageHandler(_context27.t0, "NEYNAR"));
18050
18069
 
18051
18070
  case 28:
18052
18071
  case "end":
@@ -18054,101 +18073,123 @@ function _typeof(o) {
18054
18073
  }
18055
18074
  }), _callee24, null, [ [ 0, 25 ] ]);
18056
18075
  })));
18057
- return _SAFE.apply(this, arguments);
18076
+ return _NEYNAR.apply(this, arguments);
18058
18077
  }
18059
- function DEFILLAMA() {
18060
- return _DEFILLAMA.apply(this, arguments);
18078
+ var safeParamsSchema = objectType({
18079
+ address: stringType().nonempty(),
18080
+ utility: literalType("txns"),
18081
+ chain: enumType([ "ethereum", "gnosis" ]),
18082
+ limit: numberType()["int"]().nonnegative().max(MAX_PAGE_LIMIT, {
18083
+ message: '"limit" must be less than or equal to '.concat(MAX_PAGE_LIMIT)
18084
+ })["default"](10),
18085
+ offset: numberType()["int"]().nonnegative()["default"](0)
18086
+ });
18087
+ function SAFE() {
18088
+ return _SAFE.apply(this, arguments);
18061
18089
  }
18062
- function _DEFILLAMA() {
18063
- _DEFILLAMA = _asyncToGenerator(_regeneratorRuntime().mark((function _callee25() {
18064
- var _argsToArray23, _argsToArray24, category, apiKey, url, res, json, _args28 = arguments;
18090
+ function _SAFE() {
18091
+ _SAFE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee25() {
18092
+ var _argsToArray25, _argsToArray26, address, utility, chain, _argsToArray26$, limit, _argsToArray26$2, offset, apiKey, chainId, resolved, url, _getUrlAndHeaders0, finalUrl, HEADERS, res, json, _args28 = arguments;
18065
18093
  return _regeneratorRuntime().wrap((function _callee25$(_context28) {
18066
18094
  while (1) switch (_context28.prev = _context28.next) {
18067
18095
  case 0:
18068
18096
  _context28.prev = 0;
18069
- _argsToArray23 = argsToArray(_args28), _argsToArray24 = _slicedToArray(_argsToArray23, 1),
18070
- category = _argsToArray24[0];
18071
- validateParams(defillamaParamsSchema, {
18072
- category: category
18097
+ _argsToArray25 = argsToArray(_args28), _argsToArray26 = _slicedToArray(_argsToArray25, 5),
18098
+ address = _argsToArray26[0], utility = _argsToArray26[1], chain = _argsToArray26[2],
18099
+ _argsToArray26$ = _argsToArray26[3], limit = _argsToArray26$ === void 0 ? 10 : _argsToArray26$,
18100
+ _argsToArray26$2 = _argsToArray26[4], offset = _argsToArray26$2 === void 0 ? 0 : _argsToArray26$2;
18101
+ validateParams(safeParamsSchema, {
18102
+ address: address,
18103
+ utility: utility,
18104
+ chain: chain,
18105
+ limit: limit,
18106
+ offset: offset
18073
18107
  });
18074
- apiKey = window.localStorage.getItem(SERVICES_API_KEY.Defillama);
18075
- url = CATEGORY_URLS[category];
18076
- if (url) {
18108
+ apiKey = window.localStorage.getItem(SERVICES_API_KEY.Safe);
18109
+ chainId = SAFE_CHAIN_MAP[chain];
18110
+ if (chainId) {
18077
18111
  _context28.next = 7;
18078
18112
  break;
18079
18113
  }
18080
- throw new ValidationError("Invalid category: ".concat(category));
18114
+ throw new ValidationError("Invalid chain: ".concat(chain));
18081
18115
 
18082
18116
  case 7:
18083
18117
  _context28.next = 9;
18084
- return fetch(url);
18118
+ return fromEnsNameToAddress$1.validateAndGetAddress(address);
18085
18119
 
18086
18120
  case 9:
18121
+ resolved = _context28.sent;
18122
+ url = "https://api.safe.global/tx-service/".concat(chainId, "/api/v2/safes/").concat(resolved, "/multisig-transactions?limit=").concat(limit, "&offset=").concat(offset);
18123
+ _getUrlAndHeaders0 = getUrlAndHeaders({
18124
+ url: url,
18125
+ serviceName: "Etherscan",
18126
+ headers: {
18127
+ Authorization: "Bearer ".concat(apiKey)
18128
+ }
18129
+ }), finalUrl = _getUrlAndHeaders0.URL, HEADERS = _getUrlAndHeaders0.HEADERS;
18130
+ _context28.next = 14;
18131
+ return fetch(finalUrl, {
18132
+ headers: HEADERS
18133
+ });
18134
+
18135
+ case 14:
18087
18136
  res = _context28.sent;
18088
18137
  if (res.ok) {
18089
- _context28.next = 12;
18138
+ _context28.next = 17;
18090
18139
  break;
18091
18140
  }
18092
- throw new NetworkError(SERVICES_API_KEY.Defillama, res.status);
18141
+ throw new NetworkError(SERVICES_API_KEY.Safe, res.status);
18093
18142
 
18094
- case 12:
18095
- _context28.next = 14;
18143
+ case 17:
18144
+ _context28.next = 19;
18096
18145
  return res.json();
18097
18146
 
18098
- case 14:
18147
+ case 19:
18099
18148
  json = _context28.sent;
18100
- _context28.t0 = category;
18101
- _context28.next = _context28.t0 === "protocols" ? 18 : _context28.t0 === "yields" ? 20 : _context28.t0 === "dex" ? 22 : _context28.t0 === "fees" ? 22 : 24;
18102
- break;
18103
-
18104
- case 18:
18105
- json = Array.isArray(json) ? json.slice(0, 500) : [];
18106
- return _context28.abrupt("break", 24);
18107
-
18108
- case 20:
18109
- json = Array.isArray(json.data) ? json.data.slice(0, 500) : [];
18110
- return _context28.abrupt("break", 24);
18149
+ if (Array.isArray(json.results)) {
18150
+ _context28.next = 22;
18151
+ break;
18152
+ }
18153
+ throw new ValidationError("Invalid API response");
18111
18154
 
18112
18155
  case 22:
18113
- json = Array.isArray(json.protocols) ? json.protocols.slice(0, 500) : [];
18114
- return _context28.abrupt("break", 24);
18115
-
18116
- case 24:
18117
- return _context28.abrupt("return", (Array.isArray(json) ? json : [ json ]).map((function(item) {
18118
- var out = {};
18119
- for (var _i17 = 0, _Object$entries7 = Object.entries(item); _i17 < _Object$entries7.length; _i17++) {
18120
- var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i17], 2), k = _Object$entries7$_i[0], v = _Object$entries7$_i[1];
18121
- if (v === null || _typeof(v) !== "object") out[k] = v;
18122
- }
18123
- return out;
18156
+ return _context28.abrupt("return", json.results.map((function(_ref19) {
18157
+ var confirmations = _ref19.confirmations, dataDecoded = _ref19.dataDecoded, rest = _objectWithoutProperties(_ref19, _excluded);
18158
+ return rest;
18124
18159
  })));
18125
18160
 
18126
- case 27:
18127
- _context28.prev = 27;
18128
- _context28.t1 = _context28["catch"](0);
18129
- return _context28.abrupt("return", errorMessageHandler(_context28.t1, "DEFILLAMA"));
18161
+ case 25:
18162
+ _context28.prev = 25;
18163
+ _context28.t0 = _context28["catch"](0);
18164
+ return _context28.abrupt("return", errorMessageHandler(_context28.t0, "SAFE"));
18130
18165
 
18131
- case 30:
18166
+ case 28:
18132
18167
  case "end":
18133
18168
  return _context28.stop();
18134
18169
  }
18135
- }), _callee25, null, [ [ 0, 27 ] ]);
18170
+ }), _callee25, null, [ [ 0, 25 ] ]);
18136
18171
  })));
18137
- return _DEFILLAMA.apply(this, arguments);
18172
+ return _SAFE.apply(this, arguments);
18138
18173
  }
18174
+ var uniswapParamsSchema = objectType({
18175
+ graphType: enumType([ "v3", "v3-raw" ]),
18176
+ category: enumType([ "tokens", "markets" ]),
18177
+ param1: stringType().nonempty(),
18178
+ param2: stringType().optional()
18179
+ });
18139
18180
  function UNISWAP() {
18140
18181
  return _UNISWAP.apply(this, arguments);
18141
18182
  }
18142
18183
  function _UNISWAP() {
18143
18184
  _UNISWAP = _asyncToGenerator(_regeneratorRuntime().mark((function _callee26() {
18144
- var _argsToArray25, _argsToArray26, graphType, category, param1, param2, baseUrl, url, res, json, _args29 = arguments;
18185
+ var _argsToArray27, _argsToArray28, graphType, category, param1, param2, baseUrl, url, res, json, _args29 = arguments;
18145
18186
  return _regeneratorRuntime().wrap((function _callee26$(_context29) {
18146
18187
  while (1) switch (_context29.prev = _context29.next) {
18147
18188
  case 0:
18148
18189
  _context29.prev = 0;
18149
- _argsToArray25 = argsToArray(_args29), _argsToArray26 = _slicedToArray(_argsToArray25, 4),
18150
- graphType = _argsToArray26[0], category = _argsToArray26[1], param1 = _argsToArray26[2],
18151
- param2 = _argsToArray26[3];
18190
+ _argsToArray27 = argsToArray(_args29), _argsToArray28 = _slicedToArray(_argsToArray27, 4),
18191
+ graphType = _argsToArray28[0], category = _argsToArray28[1], param1 = _argsToArray28[2],
18192
+ param2 = _argsToArray28[3];
18152
18193
  validateParams(uniswapParamsSchema, {
18153
18194
  graphType: graphType,
18154
18195
  category: category,
@@ -18180,8 +18221,8 @@ function _typeof(o) {
18180
18221
  }
18181
18222
  return _context29.abrupt("return", json.map((function(item) {
18182
18223
  var flat = {};
18183
- Object.entries(item).forEach((function(_ref18) {
18184
- var _ref19 = _slicedToArray(_ref18, 2), k = _ref19[0], v = _ref19[1];
18224
+ Object.entries(item).forEach((function(_ref20) {
18225
+ var _ref21 = _slicedToArray(_ref20, 2), k = _ref21[0], v = _ref21[1];
18185
18226
  if (v === null || _typeof(v) !== "object") flat[k] = v;
18186
18227
  }));
18187
18228
  return flat;
@@ -18203,72 +18244,29 @@ function _typeof(o) {
18203
18244
  })));
18204
18245
  return _UNISWAP.apply(this, arguments);
18205
18246
  }
18206
- function AAVE() {
18207
- return _AAVE.apply(this, arguments);
18247
+ function FLVURL() {
18248
+ return _FLVURL.apply(this, arguments);
18208
18249
  }
18209
- function _AAVE() {
18210
- _AAVE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee27() {
18211
- var _argsToArray27, _argsToArray28, graphType, category, param1, param2, baseUrl, url, res, json, _args30 = arguments;
18250
+ function _FLVURL() {
18251
+ _FLVURL = _asyncToGenerator(_regeneratorRuntime().mark((function _callee27() {
18212
18252
  return _regeneratorRuntime().wrap((function _callee27$(_context30) {
18213
18253
  while (1) switch (_context30.prev = _context30.next) {
18214
18254
  case 0:
18215
- _context30.prev = 0;
18216
- _argsToArray27 = argsToArray(_args30), _argsToArray28 = _slicedToArray(_argsToArray27, 4),
18217
- graphType = _argsToArray28[0], category = _argsToArray28[1], param1 = _argsToArray28[2],
18218
- param2 = _argsToArray28[3];
18219
- validateParams(aaveParamsSchema, {
18220
- graphType: graphType,
18221
- category: category,
18222
- param1: param1,
18223
- param2: param2
18224
- });
18225
- baseUrl = "https://onchain-proxy.fileverse.io/third-party";
18226
- url = "".concat(baseUrl) + "?service=aave" + "&graphType=".concat(encodeURIComponent(graphType)) + "&category=".concat(encodeURIComponent(category)) + "&input1=".concat(encodeURIComponent(param1)) + (param2 ? "&input2=".concat(encodeURIComponent(param2)) : "");
18227
- _context30.next = 7;
18228
- return fetch(url);
18229
-
18230
- case 7:
18231
- res = _context30.sent;
18232
- if (res.ok) {
18233
- _context30.next = 10;
18234
- break;
18235
- }
18236
- throw new NetworkError("AAVE", res.status);
18237
-
18238
- case 10:
18239
- _context30.next = 12;
18240
- return res.json();
18241
-
18242
- case 12:
18243
- json = _context30.sent;
18244
- if (!Array.isArray(json)) {
18245
- _context30.next = 15;
18246
- break;
18247
- }
18248
- return _context30.abrupt("return", json.map((function(item) {
18249
- var flat = {};
18250
- Object.entries(item).forEach((function(_ref20) {
18251
- var _ref21 = _slicedToArray(_ref20, 2), k = _ref21[0], v = _ref21[1];
18252
- if (v === null || _typeof(v) !== "object") flat[k] = v;
18253
- }));
18254
- return flat;
18255
+ return _context30.abrupt("return", new Promise((function(resolve) {
18256
+ setTimeout((function() {
18257
+ resolve([ {
18258
+ Yoo: "gotcha"
18259
+ } ]);
18260
+ }), 1e4);
18255
18261
  })));
18256
18262
 
18257
- case 15:
18258
- return _context30.abrupt("return", json);
18259
-
18260
- case 18:
18261
- _context30.prev = 18;
18262
- _context30.t0 = _context30["catch"](0);
18263
- return _context30.abrupt("return", errorMessageHandler(_context30.t0, "AAVE"));
18264
-
18265
- case 21:
18263
+ case 1:
18266
18264
  case "end":
18267
18265
  return _context30.stop();
18268
18266
  }
18269
- }), _callee27, null, [ [ 0, 18 ] ]);
18267
+ }), _callee27);
18270
18268
  })));
18271
- return _AAVE.apply(this, arguments);
18269
+ return _FLVURL.apply(this, arguments);
18272
18270
  }
18273
18271
  function POLYMARKET() {
18274
18272
  return "Coming Soon";