Skip to content

Commit

Permalink
Merge pull request #6 from sanbir/main
Browse files Browse the repository at this point in the history
retry
  • Loading branch information
sanbir authored Aug 21, 2024
2 parents cd182e8 + c3dd8d6 commit 4254d1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions scripts/ssv/reads/getClusterStateFromApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
23 changes: 14 additions & 9 deletions scripts/ssv/reads/getIsValidatorExited.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
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)
}
}

0 comments on commit 4254d1b

Please sign in to comment.