@fileverse-dev/formulajs 4.4.12-mod-8 → 4.4.12-mod-9

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.12-mod-8 */
1
+ /* @fileverse-dev/formulajs v4.4.12-mod-9 */
2
2
  var _excluded = [ "confirmations", "dataDecoded" ];
3
3
 
4
4
  function _objectWithoutProperties(e, t) {
@@ -16603,7 +16603,7 @@ function _typeof(o) {
16603
16603
  }
16604
16604
  }), _callee13);
16605
16605
  })));
16606
- return function fetchJSON(_x16) {
16606
+ return function fetchJSON(_x17) {
16607
16607
  return _ref18.apply(this, arguments);
16608
16608
  };
16609
16609
  }();
@@ -18405,17 +18405,70 @@ function _typeof(o) {
18405
18405
  maximumFractionDigits: 2
18406
18406
  }).format(normalized);
18407
18407
  }
18408
- function DUNESIM() {
18409
- return _DUNESIM.apply(this, arguments);
18408
+ var cachedChains = null;
18409
+ function getChainName(_x16) {
18410
+ return _getChainName.apply(this, arguments);
18410
18411
  }
18411
- function _DUNESIM() {
18412
- _DUNESIM = _asyncToGenerator(_regeneratorRuntime().mark((function _callee30() {
18413
- var _ref27, _json$activity, _ref28, _json$holders, _ref29, _json$tokens, _argsToArray31, _argsToArray32, type, input1, input2, input3, input4, route, buildQuery, address, qs, chain, _qs, tokenAddress, _qs2, _chain, apiKey, url, _getUrlAndHeaders1, finalUrl, HEADERS, res, json, _data6, result, _args33 = arguments;
18412
+ function _getChainName() {
18413
+ _getChainName = _asyncToGenerator(_regeneratorRuntime().mark((function _callee30(chainId) {
18414
+ var res, chain;
18414
18415
  return _regeneratorRuntime().wrap((function _callee30$(_context33) {
18415
18416
  while (1) switch (_context33.prev = _context33.next) {
18416
18417
  case 0:
18417
18418
  _context33.prev = 0;
18418
- _argsToArray31 = argsToArray(_args33), _argsToArray32 = _slicedToArray(_argsToArray31, 5),
18419
+ if (cachedChains) {
18420
+ _context33.next = 10;
18421
+ break;
18422
+ }
18423
+ _context33.next = 4;
18424
+ return fetch("https://chainid.network/chains_mini.json");
18425
+
18426
+ case 4:
18427
+ res = _context33.sent;
18428
+ if (res.ok) {
18429
+ _context33.next = 7;
18430
+ break;
18431
+ }
18432
+ throw new Error("Failed to fetch chains.json");
18433
+
18434
+ case 7:
18435
+ _context33.next = 9;
18436
+ return res.json();
18437
+
18438
+ case 9:
18439
+ cachedChains = _context33.sent;
18440
+
18441
+ case 10:
18442
+ chain = cachedChains.find((function(c) {
18443
+ return c.chainId === chainId;
18444
+ }));
18445
+ return _context33.abrupt("return", chain ? chain.name : chainId);
18446
+
18447
+ case 14:
18448
+ _context33.prev = 14;
18449
+ _context33.t0 = _context33["catch"](0);
18450
+ console.log(_context33.t0);
18451
+ return _context33.abrupt("return", chainId);
18452
+
18453
+ case 18:
18454
+ case "end":
18455
+ return _context33.stop();
18456
+ }
18457
+ }), _callee30, null, [ [ 0, 14 ] ]);
18458
+ })));
18459
+ return _getChainName.apply(this, arguments);
18460
+ }
18461
+ function DUNESIM() {
18462
+ return _DUNESIM.apply(this, arguments);
18463
+ }
18464
+ function _DUNESIM() {
18465
+ _DUNESIM = _asyncToGenerator(_regeneratorRuntime().mark((function _callee31() {
18466
+ var _ref27, _json$activity, _ref28, _json$holders, _ref29, _json$tokens, _argsToArray31, _argsToArray32, type, input1, input2, input3, input4, route, buildQuery, address, qs, chain, _qs, tokenAddress, _qs2, _chain, apiKey, url, _getUrlAndHeaders1, finalUrl, HEADERS, res, json, _data6, result, _final, globalDecimals, _iterator43, _step43, _loop4, _args35 = arguments;
18467
+ return _regeneratorRuntime().wrap((function _callee31$(_context35) {
18468
+ while (1) switch (_context35.prev = _context35.next) {
18469
+ case 0:
18470
+ _context35.prev = 0;
18471
+ _argsToArray31 = argsToArray(_args35), _argsToArray32 = _slicedToArray(_argsToArray31, 5),
18419
18472
  type = _argsToArray32[0], input1 = _argsToArray32[1], input2 = _argsToArray32[2],
18420
18473
  input3 = _argsToArray32[3], input4 = _argsToArray32[4];
18421
18474
  validateParams(duneSimParamsSchema, {
@@ -18437,14 +18490,14 @@ function _typeof(o) {
18437
18490
  return parts.length ? "?".concat(parts.join("&")) : "";
18438
18491
  };
18439
18492
  if (!(type === "activity")) {
18440
- _context33.next = 11;
18493
+ _context35.next = 11;
18441
18494
  break;
18442
18495
  }
18443
- _context33.next = 8;
18496
+ _context35.next = 8;
18444
18497
  return fromEnsNameToAddress$1.validateAndGetAddress(input1);
18445
18498
 
18446
18499
  case 8:
18447
- address = _context33.sent;
18500
+ address = _context35.sent;
18448
18501
  qs = buildQuery([ [ "chain_ids", SUPPORTED_TOKEN_NAMES[input2] || input2 ], [ "limit", input3 ] ]);
18449
18502
  route = "activity/".concat(address).concat(qs);
18450
18503
 
@@ -18469,64 +18522,172 @@ function _typeof(o) {
18469
18522
  "X-Sim-Api-Key": apiKey
18470
18523
  }
18471
18524
  }), finalUrl = _getUrlAndHeaders1.URL, HEADERS = _getUrlAndHeaders1.HEADERS;
18472
- _context33.next = 18;
18525
+ _context35.next = 18;
18473
18526
  return fetch(finalUrl, {
18474
18527
  method: "GET",
18475
18528
  headers: HEADERS
18476
18529
  });
18477
18530
 
18478
18531
  case 18:
18479
- res = _context33.sent;
18532
+ res = _context35.sent;
18480
18533
  if (res.ok) {
18481
- _context33.next = 21;
18534
+ _context35.next = 21;
18482
18535
  break;
18483
18536
  }
18484
18537
  throw new NetworkError(SERVICES_API_KEY.DuneSim, res.status);
18485
18538
 
18486
18539
  case 21:
18487
- _context33.next = 23;
18540
+ _context35.next = 23;
18488
18541
  return res.json();
18489
18542
 
18490
18543
  case 23:
18491
- json = _context33.sent;
18544
+ json = _context35.sent;
18492
18545
  _data6 = type === "activity" ? (_ref27 = (_json$activity = json === null || json === void 0 ? void 0 : json.activity) !== null && _json$activity !== void 0 ? _json$activity : json) !== null && _ref27 !== void 0 ? _ref27 : [] : type === "token-holders" ? (_ref28 = (_json$holders = json === null || json === void 0 ? void 0 : json.holders) !== null && _json$holders !== void 0 ? _json$holders : json) !== null && _ref28 !== void 0 ? _ref28 : [] : type === "price" ? (_ref29 = (_json$tokens = json === null || json === void 0 ? void 0 : json.tokens) !== null && _json$tokens !== void 0 ? _json$tokens : json) !== null && _ref29 !== void 0 ? _ref29 : [] : json !== null && json !== void 0 ? json : [];
18493
- result = (Array.isArray(_data6) ? _data6 : [ _data6 ]).map((function(item) {
18494
- if (item !== null && item !== void 0 && item.decimals) {
18495
- if (item !== null && item !== void 0 && item.total_supply) {
18496
- item.total_supply = formatNumber(item === null || item === void 0 ? void 0 : item.total_supply, item.decimals);
18546
+ result = Array.isArray(_data6) ? _data6 : [ _data6 ];
18547
+ _final = [];
18548
+ _iterator43 = _createForOfIteratorHelper(result);
18549
+ _context35.prev = 28;
18550
+ _loop4 = _regeneratorRuntime().mark((function _loop4() {
18551
+ var item, prices, _resData$tokens$, _chain2, _url, _getUrlAndHeaders10, _finalUrl, _HEADERS, _res, resData, decimals;
18552
+ return _regeneratorRuntime().wrap((function _loop4$(_context34) {
18553
+ while (1) switch (_context34.prev = _context34.next) {
18554
+ case 0:
18555
+ item = _step43.value;
18556
+ if (item !== null && item !== void 0 && item.decimals) {
18557
+ if (item !== null && item !== void 0 && item.total_supply) {
18558
+ item.total_supply = formatNumber(item === null || item === void 0 ? void 0 : item.total_supply, item.decimals);
18559
+ }
18560
+ }
18561
+ if (item !== null && item !== void 0 && item.first_acquired) {
18562
+ item.first_acquired = new Intl.DateTimeFormat("en-US", {
18563
+ year: "numeric",
18564
+ month: "long",
18565
+ day: "numeric",
18566
+ hour: "numeric",
18567
+ minute: "2-digit"
18568
+ }).format(new Date(item.first_acquired));
18569
+ }
18570
+ if (item.historical_prices) {
18571
+ prices = item.historical_prices;
18572
+ prices.forEach((function(priceData) {
18573
+ var key = "price_" + priceData.offset_hours + "h";
18574
+ var price = priceData.price_usd;
18575
+ item[key] = price;
18576
+ }));
18577
+ }
18578
+ if (type === "price") {
18579
+ delete item["chain_id"];
18580
+ delete item["decimals"];
18581
+ delete item["logo"];
18582
+ }
18583
+ if (!(type === "activity")) {
18584
+ _context34.next = 9;
18585
+ break;
18586
+ }
18587
+ _context34.next = 8;
18588
+ return getChainName(item.chain_id);
18589
+
18590
+ case 8:
18591
+ item.chain_id = _context34.sent;
18592
+
18593
+ case 9:
18594
+ if (!(type === "token-holders")) {
18595
+ _context34.next = 30;
18596
+ break;
18597
+ }
18598
+ if (!item.balance) {
18599
+ _context34.next = 30;
18600
+ break;
18601
+ }
18602
+ if (globalDecimals) {
18603
+ _context34.next = 29;
18604
+ break;
18605
+ }
18606
+ _context34.prev = 12;
18607
+ _chain2 = SUPPORTED_TOKEN_NAMES[input2] || input2;
18608
+ _url = "https://api.sim.dune.com/v1/evm/token-info/".concat(input1, "?chain_ids=").concat(_chain2);
18609
+ _getUrlAndHeaders10 = getUrlAndHeaders({
18610
+ url: _url,
18611
+ serviceName: "DuneSim",
18612
+ headers: {
18613
+ "X-Sim-Api-Key": apiKey
18614
+ }
18615
+ }), _finalUrl = _getUrlAndHeaders10.URL, _HEADERS = _getUrlAndHeaders10.HEADERS;
18616
+ _context34.next = 18;
18617
+ return fetch(_finalUrl, {
18618
+ method: "GET",
18619
+ headers: _HEADERS
18620
+ });
18621
+
18622
+ case 18:
18623
+ _res = _context34.sent;
18624
+ _context34.next = 21;
18625
+ return _res.json();
18626
+
18627
+ case 21:
18628
+ resData = _context34.sent;
18629
+ decimals = (_resData$tokens$ = resData.tokens[0]) === null || _resData$tokens$ === void 0 ? void 0 : _resData$tokens$.decimals;
18630
+ globalDecimals = decimals;
18631
+ _context34.next = 29;
18632
+ break;
18633
+
18634
+ case 26:
18635
+ _context34.prev = 26;
18636
+ _context34.t0 = _context34["catch"](12);
18637
+ console.log(_context34.t0);
18638
+
18639
+ case 29:
18640
+ item.balance = formatNumber(item.balance, globalDecimals);
18641
+
18642
+ case 30:
18643
+ _final.push(flattenObject(item));
18644
+
18645
+ case 31:
18646
+ case "end":
18647
+ return _context34.stop();
18497
18648
  }
18498
- }
18499
- if (item !== null && item !== void 0 && item.first_acquired) {
18500
- item.first_acquired = new Intl.DateTimeFormat("en-US", {
18501
- year: "numeric",
18502
- month: "long",
18503
- day: "numeric",
18504
- hour: "numeric",
18505
- minute: "2-digit"
18506
- }).format(new Date(item.first_acquired));
18507
- }
18508
- if (item.historical_prices) {
18509
- var prices = item.historical_prices;
18510
- prices.forEach((function(priceData) {
18511
- var key = "price_" + priceData.offset_hours + "h";
18512
- var price = priceData.price_usd;
18513
- item[key] = price;
18514
- }));
18515
- }
18516
- return flattenObject(item);
18649
+ }), _loop4, null, [ [ 12, 26 ] ]);
18517
18650
  }));
18518
- return _context33.abrupt("return", result);
18651
+ _iterator43.s();
18519
18652
 
18520
- case 29:
18521
- _context33.prev = 29;
18522
- _context33.t0 = _context33["catch"](0);
18523
- return _context33.abrupt("return", errorMessageHandler(_context33.t0, "DUNESIM"));
18653
+ case 31:
18654
+ if ((_step43 = _iterator43.n()).done) {
18655
+ _context35.next = 35;
18656
+ break;
18657
+ }
18658
+ return _context35.delegateYield(_loop4(), "t0", 33);
18659
+
18660
+ case 33:
18661
+ _context35.next = 31;
18662
+ break;
18663
+
18664
+ case 35:
18665
+ _context35.next = 40;
18666
+ break;
18667
+
18668
+ case 37:
18669
+ _context35.prev = 37;
18670
+ _context35.t1 = _context35["catch"](28);
18671
+ _iterator43.e(_context35.t1);
18672
+
18673
+ case 40:
18674
+ _context35.prev = 40;
18675
+ _iterator43.f();
18676
+ return _context35.finish(40);
18524
18677
 
18525
- case 32:
18678
+ case 43:
18679
+ return _context35.abrupt("return", _final);
18680
+
18681
+ case 46:
18682
+ _context35.prev = 46;
18683
+ _context35.t2 = _context35["catch"](0);
18684
+ return _context35.abrupt("return", errorMessageHandler(_context35.t2, "DUNESIM"));
18685
+
18686
+ case 49:
18526
18687
  case "end":
18527
- return _context33.stop();
18688
+ return _context35.stop();
18528
18689
  }
18529
- }), _callee30, null, [ [ 0, 29 ] ]);
18690
+ }), _callee31, null, [ [ 0, 46 ], [ 28, 37, 40, 43 ] ]);
18530
18691
  })));
18531
18692
  return _DUNESIM.apply(this, arguments);
18532
18693
  }
@@ -18543,11 +18704,11 @@ function _typeof(o) {
18543
18704
  return _FLVURL.apply(this, arguments);
18544
18705
  }
18545
18706
  function _FLVURL() {
18546
- _FLVURL = _asyncToGenerator(_regeneratorRuntime().mark((function _callee31() {
18547
- return _regeneratorRuntime().wrap((function _callee31$(_context34) {
18548
- while (1) switch (_context34.prev = _context34.next) {
18707
+ _FLVURL = _asyncToGenerator(_regeneratorRuntime().mark((function _callee32() {
18708
+ return _regeneratorRuntime().wrap((function _callee32$(_context36) {
18709
+ while (1) switch (_context36.prev = _context36.next) {
18549
18710
  case 0:
18550
- return _context34.abrupt("return", new Promise((function(resolve) {
18711
+ return _context36.abrupt("return", new Promise((function(resolve) {
18551
18712
  setTimeout((function() {
18552
18713
  resolve([ {
18553
18714
  Yoo: "gotcha"
@@ -18557,9 +18718,9 @@ function _typeof(o) {
18557
18718
 
18558
18719
  case 1:
18559
18720
  case "end":
18560
- return _context34.stop();
18721
+ return _context36.stop();
18561
18722
  }
18562
- }), _callee31);
18723
+ }), _callee32);
18563
18724
  })));
18564
18725
  return _FLVURL.apply(this, arguments);
18565
18726
  }