diff --git a/scripts/ssv/reads/getClusterStateFromApi.ts b/scripts/ssv/reads/getClusterStateFromApi.ts index ffbd6d4..6b31fc6 100644 --- a/scripts/ssv/reads/getClusterStateFromApi.ts +++ b/scripts/ssv/reads/getClusterStateFromApi.ts @@ -16,9 +16,9 @@ export async function getClusterStateFromApi( const result = await axios.get( `https://api.ssv.network/api/v4/${isHolesky ? 'holesky' : 'mainnet'}/clusters/` + - args, + args, ) logger.info('getClusterStateFromApi finished for ' + args) - return result.data.data as ClusterStateApi + return result.data.cluster as ClusterStateApi } diff --git a/scripts/ssv/reads/getIsValidatorExited.ts b/scripts/ssv/reads/getIsValidatorExited.ts index e1d2901..8ad9dc0 100644 --- a/scripts/ssv/reads/getIsValidatorExited.ts +++ b/scripts/ssv/reads/getIsValidatorExited.ts @@ -1,19 +1,24 @@ import axios from 'axios' import { logger } from '../../common/helpers/logger' +import { sleep } from '../../common/helpers/sleep' -export async function getIsValidatorExited(pubkey: string) { +export async function getIsValidatorExited(pubkey: string): Promise { logger.info('getIsValidatorExited started for ' + pubkey) if (!process.env.BEACON_URL) { throw new Error('No BEACON_URL in ENV') } - const result = await axios.get( - process.env.BEACON_URL! + '/eth/v1/beacon/states/head/validators/' + pubkey, - ) - - const isExited = result.data.data.status === 'withdrawal_done' - - logger.info('getIsValidatorExited finished for ' + pubkey + ' ' + isExited) - return isExited + try { + const result = await axios.get( + process.env.BEACON_URL! + '/eth/v1/beacon/states/head/validators/' + pubkey, + ) + const isExited = result.data.data.status === 'withdrawal_done' + logger.info('getIsValidatorExited finished for ' + pubkey + ' ' + isExited) + return isExited + } catch { + logger.info('Retrying....') + await sleep(3000) + return await getIsValidatorExited(pubkey) + } }