@merkl/api 0.20.125 → 0.20.127

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.
@@ -300,12 +300,12 @@ export class TokenService {
300
300
  }));
301
301
  }
302
302
  static async getAllValidRewardTokens(query) {
303
- return await CacheService.wrap(TTLPresets.MIN_5, async () => {
304
- let chainIds = !!query.chainId
305
- ? query.chainId?.split(",").map(n => Number.parseInt(n))
306
- : (await ChainService.findMany({
307
- test: true,
308
- })).map(chain => chain.id);
303
+ const chainIds = !!query.chainId
304
+ ? query.chainId?.split(",").map(n => Number.parseInt(n))
305
+ : (await ChainService.findMany({
306
+ test: true,
307
+ })).map(chain => chain.id);
308
+ return await CacheService.wrap(TTLPresets.MIN_5, async (chainIds) => {
309
309
  /** Fetch current Merkle Roots */
310
310
  const promises = await Promise.allSettled(chainIds.map(chainId => withTimeout(TokenService.getValidRewardTokens(chainId), 5_000)));
311
311
  /** Filter out unsuccessful chainIds */
@@ -316,7 +316,7 @@ export class TokenService {
316
316
  acc[chainIds[index]] = promise.value;
317
317
  return acc;
318
318
  }, {});
319
- });
319
+ }, chainIds);
320
320
  }
321
321
  static async getValidRewardTokens(chainId) {
322
322
  const validRewardTokens = await DistributionCreatorService(chainId).validRewardTokens();
@@ -12,7 +12,7 @@ export default class CoingeckoService {
12
12
  return await this.fetchPrices(filteredTokens);
13
13
  }
14
14
  buildUrl(tokens) {
15
- const tikerParams = tokens
15
+ const tickerParams = tokens
16
16
  .map(token => {
17
17
  const args = token.args;
18
18
  if (!args?.ticker)
@@ -20,7 +20,7 @@ export default class CoingeckoService {
20
20
  return `coingecko:${args.ticker}`;
21
21
  })
22
22
  .join(",");
23
- return this.baseUrl.concat(tikerParams);
23
+ return this.baseUrl.concat(tickerParams);
24
24
  }
25
25
  async fetchPrices(tickers) {
26
26
  const chunkSize = 200;
@@ -28,7 +28,7 @@ export default class CoingeckoService {
28
28
  for (let i = 0; i < tickers.length; i += chunkSize) {
29
29
  chunks.push(tickers.slice(i, Math.min(tickers.length, i + chunkSize)));
30
30
  }
31
- const promises = (await Promise.all(chunks.map(async (chunk) => {
31
+ const promises = (await Promise.allSettled(chunks.map(async (chunk) => {
32
32
  const url = this.buildUrl(chunk);
33
33
  return axios
34
34
  .get(url, { timeout: 10000 })
@@ -37,7 +37,9 @@ export default class CoingeckoService {
37
37
  log.error("❌ CoingeckoService not responding", err);
38
38
  throw "❌ CoingeckoService not responding";
39
39
  });
40
- }))).filter(result => !!result);
40
+ })))
41
+ .filter(result => result.status === "fulfilled")
42
+ .map(result => result.value);
41
43
  return promises.reduce((acc, val) => acc.concat(val), []);
42
44
  }
43
45
  // biome-ignore lint/suspicious/noExplicitAny: <explanation> Need to be typed according to coinguekko answer type