From 853f37862f75f4e71e69275fd109843f4b416a32 Mon Sep 17 00:00:00 2001 From: onmax Date: Tue, 19 Nov 2024 13:04:45 -0600 Subject: [PATCH] chore: use correct epoch number --- server/api/[version]/validators/index.get.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/api/[version]/validators/index.get.ts b/server/api/[version]/validators/index.get.ts index 597d4cd..6f84a26 100644 --- a/server/api/[version]/validators/index.get.ts +++ b/server/api/[version]/validators/index.get.ts @@ -13,7 +13,7 @@ export default defineCachedEventHandler(async (event) => { let addresses: string[] = [] - let epochNumber = 1 + const epochNumber = 1 // In case server is offline, at least we can show the database data if (isOnline) { @@ -33,10 +33,10 @@ export default defineCachedEventHandler(async (event) => { consola.warn(`Error calculating scores for range ${JSON.stringify(range)}`, error) } - const { data: _epochNumber, error: errorEpochNumber } = await getRpcClient().blockchain.getEpochNumber() - if (errorEpochNumber) - throw createError(errorEpochNumber) - epochNumber = _epochNumber - 1 + const { data: epochNumber, error: errorEpochNumber } = await getRpcClient().blockchain.getEpochNumber() + if (errorEpochNumber || !epochNumber) + throw createError(errorEpochNumber || 'Epoch number not found') + // epochNumber = _epochNumber - 1 } const { data: validators, error: errorValidators } = await fetchValidators({ ...params, addresses, epochNumber })