Skip to content

Commit

Permalink
Merge branch 'add-validator-registry-endpoint' into release-v0.5.15
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon committed Feb 12, 2024
2 parents e7761e5 + de74ea6 commit de3c849
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions validators/validatorsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ function ValidatorsController(chainRegistry, validatorRegistry) {
});
});

router.get('/registry', async (ctx, next) => {
const validators = await validatorRegistry.getRegistryValidators()
renderJson(ctx, {
repository: await repositoryResponse(),
validators: _.shuffle(validators).map(validator => {
return validator.toJSON();
})
});
});

router.get('/chains/:chain', async (ctx, next) => {
const chain = await chainRegistry.getChain(ctx.params.chain);
let validators = chain && await validatorRegistry.getChainValidatorsWithRegistry(chain)
Expand Down Expand Up @@ -67,7 +77,7 @@ function ValidatorsController(chainRegistry, validatorRegistry) {
const registryValidator = await validatorRegistry.getRegistryValidator(ctx.params.validator);
if(registryValidator){
for (const chainData of registryValidator.chains) {
let chain = await chainRegistry.getChain(chainData.name)
let chain = await chainRegistry.getChain(chainData.name)
if(chain){
await validatorRegistry.getChainValidator(chain, chainData.address, registryValidator)
}
Expand All @@ -83,7 +93,7 @@ function ValidatorsController(chainRegistry, validatorRegistry) {
const registryValidator = await validatorRegistry.getRegistryValidator(ctx.params.validator);
if(registryValidator){
for (const chainData of registryValidator.chains) {
let chain = await chainRegistry.getChain(chainData.name)
let chain = await chainRegistry.getChain(chainData.name)
if(chain){
await validatorRegistry.getChainValidator(chain, chainData.address, registryValidator)
}
Expand Down Expand Up @@ -130,4 +140,4 @@ function ValidatorsController(chainRegistry, validatorRegistry) {
};
}

export default ValidatorsController
export default ValidatorsController

0 comments on commit de3c849

Please sign in to comment.