From de74ea6182c92abb2a8c375a35599a99c8569677 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Mon, 12 Feb 2024 21:47:37 +0000 Subject: [PATCH] Add validators registry endpoint --- validators/validatorsController.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/validators/validatorsController.js b/validators/validatorsController.js index 4f95a49..d9954cc 100644 --- a/validators/validatorsController.js +++ b/validators/validatorsController.js @@ -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) @@ -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) } @@ -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) } @@ -130,4 +140,4 @@ function ValidatorsController(chainRegistry, validatorRegistry) { }; } -export default ValidatorsController \ No newline at end of file +export default ValidatorsController