@fileverse-dev/formulajs 4.4.11-mod-68-patch-1 → 4.4.11-mod-70

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.
package/lib/esm/index.mjs CHANGED
@@ -13142,126 +13142,15 @@ const SERVICES_API_KEY = {
13142
13142
  Defillama: 'Defillama'
13143
13143
  };
13144
13144
 
13145
- // Proxy map configuration
13146
- const PROXY_MAP = {
13147
- Etherscan: {
13148
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13149
- removeParams: ['apikey']
13150
- },
13151
- Basescan: {
13152
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13153
- removeParams: ['apikey']
13154
- },
13155
- Gnosisscan: {
13156
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13157
- removeParams: ['apikey']
13158
- },
13159
- Coingecko: {
13160
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13161
- removeParams: ['apikey']
13162
- },
13163
- Firefly: {
13164
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13165
- removeParams: ['apikey']
13166
- },
13167
- Neynar: {
13168
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13169
- removeParams: ['api_key']
13170
- },
13171
- Safe: {
13172
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13173
- removeParams: ['api_key']
13174
- },
13175
- Defillama: {
13176
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13177
- removeParams: ['api_key']
13178
- },
13179
- GnosisPay: {
13180
- url: "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy",
13181
- removeParams: ['api_key']
13182
- },
13183
- // Add more services as needed. It can be direct url instead of ENV variable
13184
- // ANOTHER_SERVICE: "https://another-proxy-url.com"
13185
- };
13186
-
13187
- /**
13188
- * Removes specified parameters from a URL
13189
- * @param {string} url - The original URL
13190
- * @param {string[]} paramsToRemove - Array of parameter names to remove
13191
- * @returns {string} URL with specified parameters removed
13192
- */
13193
- function removeUrlParams(url, paramsToRemove) {
13194
- if (!paramsToRemove || paramsToRemove.length === 0) {
13195
- return url;
13196
- }
13197
-
13198
- const urlObj = new URL(url);
13199
-
13200
- paramsToRemove.forEach(param => {
13201
- if (urlObj.searchParams.has(param)) {
13202
- urlObj.searchParams.delete(param);
13203
- }
13204
- });
13205
-
13206
- return urlObj.toString();
13207
- }
13208
-
13209
- /**
13210
- * Handles URL routing through proxy or direct API calls
13211
- * @param {string} url - The original API URL
13212
- * @param {string} serviceName - The name of the service (e.g., 'EOA')
13213
- * @param {string} headers - The name of the service (e.g., 'EOA')
13214
- * @returns {Object} Object containing URL and HEADERS for the fetch request
13215
- */
13216
- function getUrlAndHeaders({ url, serviceName, headers = {} }) {
13217
- console.log('getUrlAndHeaders new modified function from formulajs', url, apiKeyName, serviceName);
13218
- // Check if proxy is enabled in localStorage
13219
- const apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
13220
- const isProxyModeEnabledValue = apiKeyLS === 'DEFAULT_PROXY_MODE';
13221
-
13222
- // Check if proxy URL exists for this service
13223
- const proxyConfig = PROXY_MAP[serviceName];
13224
-
13225
- // If proxy mode is enabled AND proxy URL exists for this service
13226
- if (isProxyModeEnabledValue && proxyConfig && serviceName && SERVICES_API_KEY[serviceName]) {
13227
- console.log('isProxyModeEnabledValue', isProxyModeEnabledValue);
13228
- // Remove specified parameters from the target URL
13229
- const cleanedUrl = removeUrlParams(url, proxyConfig.removeParams);
13230
-
13231
- return {
13232
- URL: proxyConfig.url,
13233
- HEADERS: {
13234
- 'target-url': cleanedUrl,
13235
- method: 'GET',
13236
- 'Content-Type': 'application/json'
13237
- }
13238
- };
13239
- }
13240
-
13241
-
13242
- return {
13243
- URL: url,
13244
- HEADERS: {
13245
- ...headers,
13246
- method: 'GET',
13247
- 'Content-Type': 'application/json'
13248
- }
13249
- };
13250
- }
13251
-
13252
13145
  const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
13253
- if (!timestamp || !chain || !apiKey) return
13254
- const chainId = CHAIN_ID_MAP[chain];
13255
- const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
13256
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders(url);
13257
- const res = await fetch(finalUrl, {
13258
- method: 'GET',
13259
- headers: HEADERS,
13260
- });
13261
- const json = await res.json();
13262
- return parseInt(json.result);
13146
+ if(!timestamp || !chain || !apiKey) return
13147
+ const chainId = CHAIN_ID_MAP[chain];
13148
+ const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
13149
+ const res = await fetch(url);
13150
+ const json = await res.json();
13151
+ return parseInt(json.result);
13263
13152
 
13264
- };
13153
+ };
13265
13154
 
13266
13155
  var fromTimestampToBlock = {
13267
13156
  fromTimeStampToBlock
@@ -13398,13 +13287,14 @@ async function handleScanRequest({
13398
13287
  'all-txns': 'txlist',
13399
13288
  'token-txns': 'tokentx',
13400
13289
  'nft-txns': 'tokennfttx',
13401
- gas: 'gastracker'
13290
+ 'gas': 'gasoracle'
13402
13291
  };
13403
13292
 
13404
13293
  const action = ACTION_MAP[type];
13405
13294
  if (!action) throw new ValidationError(`Invalid type: ${type}`)
13406
13295
 
13407
- let url = `${baseUrl}?chainid=${chainId}&module=account&action=${action}&apikey=${apiKey}`;
13296
+ const module = action === 'gasoracle' ? 'gastracker' : 'account';
13297
+ let url = `${baseUrl}?chainid=${chainId}&module=${module}&action=${action}&apikey=${apiKey}`;
13408
13298
 
13409
13299
  if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
13410
13300
  url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
@@ -13418,11 +13308,7 @@ async function handleScanRequest({
13418
13308
  }
13419
13309
  url += `&page=${page}&offset=${offset}`;
13420
13310
  }
13421
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({url, serviceName: 'Etherscan', headers: {}});
13422
- const res = await fetch(finalUrl, {
13423
- method: 'GET',
13424
- headers: HEADERS,
13425
- });
13311
+ const res = await fetch(url);
13426
13312
  if (!res.ok) {
13427
13313
  throw new NetworkError(apiInfo.apiKeyName, res.status)
13428
13314
  }
@@ -13437,23 +13323,18 @@ async function handleScanRequest({
13437
13323
  throw new RateLimitError(apiInfo.apiKeyName)
13438
13324
  }
13439
13325
 
13440
- return json.result
13326
+ return type === 'gas' ? [json.result] : json.result
13441
13327
  }
13442
13328
 
13443
13329
  const fromUsernameToFid = async (username, apiKey) => {
13444
- if (!username) return null
13330
+ if(!username) return null
13445
13331
  const url = `https://api.neynar.com/v2/farcaster/user/search/?q=${username}&limit=5`;
13446
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
13447
- url, serviceName: 'Neynar', headers: {
13332
+ const res = await fetch(url, {
13333
+ headers: {
13448
13334
  'x-api-key': apiKey,
13449
13335
  'x-neynar-experimental': 'false'
13450
13336
  }
13451
13337
  });
13452
-
13453
- const res = await fetch(finalUrl, {
13454
- method: 'GET',
13455
- headers: HEADERS,
13456
- });
13457
13338
  const json = await res.json();
13458
13339
  const users = json.result ? json.result.users : [];
13459
13340
  const user = users.find(user => user.username === username);
@@ -17466,7 +17347,7 @@ const farcasterSchema = objectType({
17466
17347
  contentType: enumType(['posts', 'replies', 'channels']),
17467
17348
  identifier: stringType().nonempty(),
17468
17349
  start: numberType().int().nonnegative().default(0),
17469
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17350
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17470
17351
  });
17471
17352
 
17472
17353
  const lensSchema = objectType({
@@ -17474,7 +17355,7 @@ const lensSchema = objectType({
17474
17355
  contentType: enumType(['posts', 'replies']),
17475
17356
  identifier: stringType().nonempty(),
17476
17357
  start: numberType().int().nonnegative().default(0),
17477
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17358
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17478
17359
  });
17479
17360
 
17480
17361
  const fireflyParamsSchema = discriminatedUnionType('platform', [
@@ -17497,31 +17378,33 @@ const lensParamsSchema = objectType({
17497
17378
  contentType: enumType(['posts', 'replies']),
17498
17379
  identifier: stringType().nonempty(),
17499
17380
  start: numberType().int().nonnegative().default(0),
17500
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17381
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17501
17382
  });
17502
17383
 
17503
17384
  const farcasterParamsSchema = objectType({
17504
17385
  contentType: enumType(['posts', 'replies', 'channels']),
17505
17386
  identifier: stringType().nonempty(),
17506
17387
  start: numberType().int().nonnegative().default(0),
17507
- end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17388
+ end: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"end" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17508
17389
  });
17509
17390
 
17510
17391
  const dateStringToTimestamp = (val) => {
17511
- const [mm, dd, yyyy] = val.split('/');
17512
- return Math.floor(new Date(`${yyyy}-${mm}-${dd}`).getTime() / 1000);
17392
+ const [dd, mm, yyyy] = val.split('/');
17393
+ const date = new Date(`${yyyy}-${mm.padStart(2, '0')}-${dd.padStart(2, '0')}`);
17394
+ const timestamp = date.getTime();
17395
+ return isNaN(timestamp) ? NaN : Math.floor(timestamp / 1000);
17513
17396
  };
17514
17397
 
17515
17398
  /**
17516
- * Accepts either a UNIXtimestamp number or a MM/DD/YYYY string,
17399
+ * Accepts either a UNIX timestamp number or a DD/MM/YYYY string,
17517
17400
  * and always returns a nonnegative integer timestamp.
17518
17401
  */
17519
17402
  const dateOrTimestamp = preprocessType(
17520
17403
  (val) =>
17521
- typeof val === 'string' && /^\d{2}\/\d{2}\/\d{4}$/.test(val)
17404
+ typeof val === 'string' && /^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)
17522
17405
  ? dateStringToTimestamp(val)
17523
17406
  : val,
17524
- numberType().int().nonnegative()
17407
+ numberType({ invalid_type_error: 'Date must be a valid DD/MM/YYYY or timestamp' }).int('Date must be an integer timestamp').nonnegative('Date must be a nonnegative timestamp').refine((n) => !isNaN(n), { message: 'Invalid date format or value: expected DD/MM/YYYY' })
17525
17408
  );
17526
17409
 
17527
17410
  const blockscoutParamsSchema = objectType({
@@ -17531,7 +17414,7 @@ const blockscoutParamsSchema = objectType({
17531
17414
  startTimestamp: dateOrTimestamp.optional(),
17532
17415
  endTimestamp: dateOrTimestamp.optional(),
17533
17416
  page: numberType().int().nonnegative().default(1),
17534
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17417
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17535
17418
  });
17536
17419
 
17537
17420
  const gasSchema$1 = objectType({
@@ -17539,7 +17422,7 @@ const gasSchema$1 = objectType({
17539
17422
  startDate: dateOrTimestamp.optional(),
17540
17423
  endDate: dateOrTimestamp.optional(),
17541
17424
  page: numberType().int().nonnegative().default(1),
17542
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17425
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17543
17426
  });
17544
17427
 
17545
17428
  const txnSchema$1 = objectType({
@@ -17548,7 +17431,7 @@ const txnSchema$1 = objectType({
17548
17431
  startDate: dateOrTimestamp.optional(),
17549
17432
  endDate: dateOrTimestamp.optional(),
17550
17433
  page: numberType().int().nonnegative().default(1),
17551
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17434
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17552
17435
  });
17553
17436
 
17554
17437
  const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
@@ -17558,7 +17441,7 @@ const gasSchema = objectType({
17558
17441
  startDate: dateOrTimestamp.optional(),
17559
17442
  endDate: dateOrTimestamp.optional(),
17560
17443
  page: numberType().int().nonnegative().default(1),
17561
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17444
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17562
17445
  });
17563
17446
 
17564
17447
  const txnSchema = objectType({
@@ -17568,11 +17451,21 @@ const txnSchema = objectType({
17568
17451
  endDate: dateOrTimestamp.optional(),
17569
17452
  chain: enumType(['ethereum','base','gnosis']),
17570
17453
  page: numberType().int().nonnegative().default(1),
17571
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17454
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17572
17455
  });
17573
17456
 
17574
17457
  const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
17575
17458
 
17459
+ const allowedValues = ['1h', '24h', '7d'];
17460
+ const param2Schema = stringType()
17461
+ .refine((val) => {
17462
+ const tokens = val.split(',').map((t) => t.trim().toLowerCase());
17463
+ return tokens.some((token) =>
17464
+ allowedValues.some((allowed) => token.includes(allowed))
17465
+ );
17466
+ }, {
17467
+ message: "param2 must contain at least one of: '1h', '24h', '7d'",
17468
+ }).optional();
17576
17469
  const priceSchema = objectType({
17577
17470
  category: literalType('price'),
17578
17471
  param1: stringType().nonempty(),
@@ -17582,13 +17475,13 @@ const marketEcosystems = ['all','base','meme','aiagents','bitcoin','ethereum','h
17582
17475
  const marketSchema = objectType({
17583
17476
  category: literalType('market'),
17584
17477
  param1: enumType(marketEcosystems),
17585
- param2: enumType(['1h','24h','7d']).optional(),
17478
+ param2: param2Schema,
17586
17479
  });
17587
17480
  const stablecoinsTypes = ['all','yield-bearing-stablecoins','crypto-backed-stablecoin'];
17588
17481
  const stablecoinsSchema = objectType({
17589
17482
  category: literalType('stablecoins'),
17590
17483
  param1: enumType(stablecoinsTypes),
17591
- param2: enumType(['1h','24h','7d']).optional(),
17484
+ param2: param2Schema,
17592
17485
  });
17593
17486
  const derivativesSchema = objectType({
17594
17487
  category: literalType('derivatives'),
@@ -17616,7 +17509,7 @@ const baseSchema = objectType({
17616
17509
  startTime: dateOrTimestamp.optional(),
17617
17510
  endTime: dateOrTimestamp.optional(),
17618
17511
  page: numberType().int().nonnegative().default(1),
17619
- offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17512
+ offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17620
17513
  });
17621
17514
 
17622
17515
  const eoaParamsSchema = preprocessType(
@@ -17645,7 +17538,7 @@ const safeParamsSchema = objectType({
17645
17538
  address: stringType().nonempty(),
17646
17539
  utility: literalType('txns'),
17647
17540
  chain: enumType(['ethereum','gnosis']),
17648
- limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT).default(10),
17541
+ limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
17649
17542
  offset: numberType().int().nonnegative().default(0),
17650
17543
  });
17651
17544
 
@@ -17681,9 +17574,9 @@ const aaveParamsSchema = objectType({
17681
17574
 
17682
17575
  async function FIREFLY() {
17683
17576
  try {
17684
- const [platform, contentType, identifier, start = 0, end = 10] = argsToArray(arguments);
17577
+ const [platform, contentType, identifier, start = 0, end = 10] = argsToArray(arguments);
17685
17578
 
17686
- validateParams(fireflyParamsSchema, {
17579
+ validateParams(fireflyParamsSchema, {
17687
17580
  platform,
17688
17581
  contentType,
17689
17582
  identifier,
@@ -17705,14 +17598,12 @@ async function FIREFLY() {
17705
17598
  .filter(Boolean)
17706
17599
  .join(',')
17707
17600
  );
17708
- url.searchParams.set('type', fireFlyPlaformType[platform][contentType]);
17709
- url.searchParams.set('start', String(start));
17710
- url.searchParams.set('end', String(end));
17601
+ url.searchParams.set('type', fireFlyPlaformType[platform][contentType]);
17602
+ url.searchParams.set('start', String(start));
17603
+ url.searchParams.set('end', String(end));
17711
17604
 
17712
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
17713
- const response = await fetch(finalUrl, {
17714
- method: 'GET',
17715
- headers: HEADERS,
17605
+ const response = await fetch(url.toString(), {
17606
+ headers: { 'x-api-key': apiKey }
17716
17607
  });
17717
17608
  if (!response.ok) {
17718
17609
  throw new NetworkError(SERVICES_API_KEY.Firefly, response.status)
@@ -17770,18 +17661,15 @@ async function LENS() {
17770
17661
  .join(',')
17771
17662
  );
17772
17663
  const typeMap = {
17773
- posts: 'lensid',
17664
+ posts: 'lensid',
17774
17665
  replies: 'lenspostid',
17775
17666
  };
17776
17667
  url.searchParams.set('type', typeMap[contentType]);
17777
17668
  url.searchParams.set('start', String(start));
17778
- url.searchParams.set('end', String(end));
17669
+ url.searchParams.set('end', String(end));
17779
17670
 
17780
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
17781
-
17782
- const response = await fetch(finalUrl, {
17783
- method: 'GET',
17784
- headers: HEADERS,
17671
+ const response = await fetch(url.toString(), {
17672
+ headers: { 'x-api-key': apiKey },
17785
17673
  });
17786
17674
  if (!response.ok) {
17787
17675
  throw new NetworkError(SERVICES_API_KEY.Firefly, response.status)
@@ -17808,7 +17696,7 @@ async function FARCASTER() {
17808
17696
  try {
17809
17697
  const [contentType, identifier, start = 0, end = 10] =
17810
17698
  argsToArray(arguments);
17811
- validateParams(farcasterParamsSchema, {
17699
+ validateParams(farcasterParamsSchema, {
17812
17700
  contentType,
17813
17701
  identifier,
17814
17702
  start,
@@ -17834,19 +17722,16 @@ async function FARCASTER() {
17834
17722
  .join(',')
17835
17723
  );
17836
17724
  const typeMap = {
17837
- posts: 'farcasterid',
17838
- replies: 'farcasterpostid',
17839
- channels: 'farcasterchannels',
17840
- };
17725
+ posts: 'farcasterid',
17726
+ replies: 'farcasterpostid',
17727
+ channels: 'farcasterchannels',
17728
+ };
17841
17729
  url.searchParams.set('type', typeMap[contentType]);
17842
17730
  url.searchParams.set('start', String(start));
17843
- url.searchParams.set('end', String(end));
17844
-
17845
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url: url.toString(), serviceName: 'Firefly', headers });
17731
+ url.searchParams.set('end', String(end));
17846
17732
 
17847
- const response = await fetch(finalUrl, {
17848
- method: 'GET',
17849
- headers: HEADERS,
17733
+ const response = await fetch(url.toString(), {
17734
+ headers: { 'x-api-key': apiKey },
17850
17735
  });
17851
17736
  if (!response.ok) {
17852
17737
  throw new NetworkError(
@@ -17955,12 +17840,12 @@ async function BLOCKSCOUT() {
17955
17840
  }
17956
17841
 
17957
17842
  async function BASE() {
17958
- try {
17843
+ try {
17959
17844
  const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
17960
- validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
17845
+ validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
17961
17846
  const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
17962
17847
  if (!API_KEY) throw new MissingApiKeyError(SERVICES_API_KEY.Basescan)
17963
-
17848
+
17964
17849
  return await handleScanRequest({
17965
17850
  type,
17966
17851
  address,
@@ -17973,9 +17858,9 @@ async function BASE() {
17973
17858
  chainId: CHAIN_ID_MAP.base,
17974
17859
  network: 'base'
17975
17860
  })
17976
- } catch (error) {
17977
- return errorMessageHandler(error, 'BASE')
17978
- }
17861
+ } catch (error) {
17862
+ return errorMessageHandler(error, 'BASE')
17863
+ }
17979
17864
  }
17980
17865
  async function GNOSIS() {
17981
17866
  try {
@@ -18016,9 +17901,9 @@ async function GNOSIS() {
18016
17901
 
18017
17902
  async function NEYNAR() {
18018
17903
  try {
18019
- const neynarParamsSchema = objectType({
18020
- username: stringType().nonempty()
18021
- });
17904
+ const neynarParamsSchema = objectType({
17905
+ username: stringType().nonempty()
17906
+ });
18022
17907
 
18023
17908
  const [username] = argsToArray(arguments);
18024
17909
 
@@ -18032,19 +17917,12 @@ async function NEYNAR() {
18032
17917
 
18033
17918
  const url = `https://api.neynar.com/v2/farcaster/followers?fid=${fid}`;
18034
17919
 
18035
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
18036
- url: url.toString(), serviceName: 'Firefly', headers: {
18037
- headers: {
18038
- 'x-api-key': API_KEY,
18039
- 'x-neynar-experimental': 'false'
18040
- }
17920
+ const response = await fetch(url, {
17921
+ headers: {
17922
+ 'x-api-key': apiKey,
17923
+ 'x-neynar-experimental': 'false',
18041
17924
  }
18042
17925
  });
18043
-
18044
- const response = await fetch(finalUrl, {
18045
- method: 'GET',
18046
- headers: HEADERS,
18047
- });
18048
17926
  if (!response.ok) {
18049
17927
  throw new NetworkError(SERVICES_API_KEY.Neynar, response.status)
18050
17928
  }
@@ -18178,20 +18056,20 @@ async function COINGECKO() {
18178
18056
  break
18179
18057
  }
18180
18058
  case 'market': {
18181
- const map = { all: '', base: 'base-ecosystem', meme: 'meme-token', aiagents: 'ai-agents', bitcoin: 'bitcoin-ecosystem', ethereum: 'ethereum-ecosystem', hyperliquid: 'hyperliquid-ecosystem', pump: 'pump-ecosystem', solana: 'solana-ecosystem' };
18059
+ const map = { all:'', base:'base-ecosystem', meme:'meme-token', aiagents:'ai-agents', bitcoin:'bitcoin-ecosystem', ethereum:'ethereum-ecosystem', hyperliquid:'hyperliquid-ecosystem', pump:'pump-ecosystem', solana:'solana-ecosystem' };
18182
18060
  const _category = map[param1] || '';
18183
18061
  const trend = param2 ? `&price_change_percentage=${param2}` : '';
18184
- url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&include_tokens=top&page=1&per_page=100${_category ? `&category=${_category}` : ''}${trend}`;
18062
+ url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&include_tokens=top&page=1&per_page=100${_category?`&category=${_category}`:''}${trend}`;
18185
18063
  break
18186
18064
  }
18187
18065
  case 'stablecoins': {
18188
- const _category = param1 === 'all' ? 'stablecoins' : param1;
18066
+ const _category = param1==='all'? 'stablecoins' : param1;
18189
18067
  const trend = param2 ? `&price_change_percentage=${param2}` : '';
18190
18068
  url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&category=${_category}&order=market_cap_desc&page=1&per_page=100${trend}`;
18191
18069
  break
18192
18070
  }
18193
18071
  case 'derivatives': {
18194
- url = (!param1 || param1 === 'all')
18072
+ url = (!param1 || param1==='all')
18195
18073
  ? 'https://api.coingecko.com/api/v3/derivatives'
18196
18074
  : `https://api.coingecko.com/api/v3/derivatives/exchanges/${param1}?include_tickers=all`;
18197
18075
  break
@@ -18206,17 +18084,17 @@ async function COINGECKO() {
18206
18084
  throw new NetworkError(SERVICES_API_KEY.Coingecko, res.status)
18207
18085
  }
18208
18086
 
18209
- if (category === 'price') {
18087
+ if (category==='price') {
18210
18088
  const out = {};
18211
18089
  for (const [token, prices] of Object.entries(json))
18212
- for (const [cur, val] of Object.entries(prices))
18213
- out[`${token.charAt(0).toUpperCase() + token.slice(1)}_${cur.toUpperCase()}`] = val;
18090
+ for (const [cur,val] of Object.entries(prices))
18091
+ out[`${token.charAt(0).toUpperCase()+token.slice(1)}_${cur.toUpperCase()}`]=val;
18214
18092
  return [out]
18215
18093
  }
18216
18094
 
18217
18095
  const data = Array.isArray(json) ? json : [json];
18218
- return data.map(item => {
18219
- const flat = {};
18096
+ return data.map(item=>{
18097
+ const flat={};
18220
18098
  for (const [key, value] of Object.entries(item)) {
18221
18099
  if (typeof value !== 'object' || value === null) {
18222
18100
  flat[key] = value;
@@ -18224,13 +18102,12 @@ async function COINGECKO() {
18224
18102
  }
18225
18103
  return flat
18226
18104
  })
18227
- } catch (err) {
18228
- return errorMessageHandler(err, 'COINGECKO')
18105
+ } catch(err) {
18106
+ return errorMessageHandler(err,'COINGECKO')
18229
18107
  }
18230
18108
  }
18231
18109
 
18232
18110
  async function EOA() {
18233
- console.log('EOA');
18234
18111
  try {
18235
18112
  const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
18236
18113
  argsToArray(arguments);
@@ -18239,8 +18116,8 @@ async function EOA() {
18239
18116
  const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
18240
18117
  if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
18241
18118
 
18242
- const INPUTS = addresses.split(',').map(s => s.trim()).filter(Boolean);
18243
- const CHAINS = chains.split(',').map(s => s.trim()).filter(Boolean);
18119
+ const INPUTS = addresses.split(',').map(s=>s.trim()).filter(Boolean);
18120
+ const CHAINS = chains.split(',').map(s=>s.trim()).filter(Boolean);
18244
18121
 
18245
18122
  const ADDRESS_MAP = {};
18246
18123
  for (const inp of INPUTS) {
@@ -18257,12 +18134,7 @@ async function EOA() {
18257
18134
  const out = [];
18258
18135
 
18259
18136
  async function fetchJSON(url) {
18260
- const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
18261
- console.log('finalUrl', finalUrl, HEADERS);
18262
- const res = await fetch(finalUrl, {
18263
- method: 'GET',
18264
- headers: HEADERS,
18265
- });
18137
+ const res = await fetch(url);
18266
18138
  if (!res.ok) throw new NetworkError(SERVICES_API_KEY.Etherscan, res.status)
18267
18139
  const json = await res.json();
18268
18140
 
@@ -18280,15 +18152,15 @@ async function EOA() {
18280
18152
 
18281
18153
  if (category === 'balance') {
18282
18154
  // chunk 20
18283
- for (let i = 0; i < ADDRS.length; i += 20) {
18284
- const slice = ADDRS.slice(i, i + 20).join(',');
18155
+ for (let i=0; i<ADDRS.length; i+=20) {
18156
+ const slice = ADDRS.slice(i,i+20).join(',');
18285
18157
  const url =
18286
- `https://api.etherscan.io/v2/api?chainid=${chainId}` +
18287
- `&module=account&action=addresstokenbalance&address=${slice}` +
18158
+ `https://api.etherscan.io/v2/api?chainid=${chainId}`+
18159
+ `&module=account&action=addresstokenbalance&address=${slice}`+
18288
18160
  `&page=${page}&offset=${offset}&apikey=${apiKey}`;
18289
18161
  const data = await fetchJSON(url);
18290
18162
  if (!Array.isArray(data)) return data
18291
- data.forEach((item, idx) => out.push({ chain, address: ADDRS[i + idx], name: ADDRESS_MAP[ADDRS[i + idx]], ...item }));
18163
+ data.forEach((item, idx) => out.push({ chain, address: ADDRS[i+idx], name: ADDRESS_MAP[ADDRS[i+idx]], ...item }));
18292
18164
  }
18293
18165
  } else {
18294
18166
  // txns
@@ -18298,9 +18170,9 @@ async function EOA() {
18298
18170
  if (!eb) throw new ValidationError(`Invalid endTime: ${endTime}`)
18299
18171
  for (const addr of ADDRS) {
18300
18172
  const url =
18301
- `https://api.etherscan.io/v2/api?chainid=${chainId}` +
18302
- `&module=account&action=tokentx&address=${addr}` +
18303
- `&startblock=${sb}&endblock=${eb}` +
18173
+ `https://api.etherscan.io/v2/api?chainid=${chainId}`+
18174
+ `&module=account&action=tokentx&address=${addr}`+
18175
+ `&startblock=${sb}&endblock=${eb}`+
18304
18176
  `&page=${page}&offset=${offset}&sort=asc&apikey=${apiKey}`;
18305
18177
  const data = await fetchJSON(url);
18306
18178
  if (!Array.isArray(data)) return data
@@ -18375,20 +18247,20 @@ async function DEFILLAMA() {
18375
18247
 
18376
18248
  switch (category) {
18377
18249
  case 'protocols':
18378
- json = Array.isArray(json) ? json.slice(0, 500) : [];
18250
+ json = Array.isArray(json) ? json.slice(0,500) : [];
18379
18251
  break
18380
18252
  case 'yields':
18381
- json = Array.isArray(json.data) ? json.data.slice(0, 500) : [];
18253
+ json = Array.isArray(json.data) ? json.data.slice(0,500) : [];
18382
18254
  break
18383
18255
  case 'dex':
18384
18256
  case 'fees':
18385
- json = Array.isArray(json.protocols) ? json.protocols.slice(0, 500) : [];
18257
+ json = Array.isArray(json.protocols) ? json.protocols.slice(0,500) : [];
18386
18258
  break
18387
18259
  }
18388
18260
 
18389
18261
  return (Array.isArray(json) ? json : [json]).map(item => {
18390
18262
  const out = {};
18391
- for (const [k, v] of Object.entries(item)) {
18263
+ for (const [k,v] of Object.entries(item)) {
18392
18264
  if (v === null || typeof v !== 'object') out[k] = v;
18393
18265
  }
18394
18266
  return out
@@ -18424,7 +18296,7 @@ async function UNISWAP() {
18424
18296
  // flatten nested
18425
18297
  return json.map(item => {
18426
18298
  const flat = {};
18427
- Object.entries(item).forEach(([k, v]) => {
18299
+ Object.entries(item).forEach(([k,v]) => {
18428
18300
  if (v === null || typeof v !== 'object') flat[k] = v;
18429
18301
  });
18430
18302
  return flat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.11-mod-68-patch-1",
3
+ "version": "4.4.11-mod-70",
4
4
  "description": "JavaScript implementation of most Microsoft Excel formula functions",
5
5
  "author": "Formulajs",
6
6
  "publishConfig": {