From eca5f4c248d76d2300267c39b1120ca05ace59a2 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Thu, 1 Feb 2024 12:04:18 +0100 Subject: [PATCH] While loading validators, also compile a hash map --- src/oasis-nexus/api.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index df3e3b0894..1f5b268a94 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -886,15 +886,19 @@ export const useGetConsensusValidators: typeof generated.useGetConsensusValidato ...arrayify(axios.defaults.transformResponse), (data: generated.ValidatorList, headers, status) => { if (status !== 200) return data + const validators = data.validators.map(validator => { + return { + ...validator, + escrow: fromBaseUnits(validator.escrow, consensusDecimals), + ticker, + } + }) + const map = new Map() + validators.forEach(validator => map.set(validator.entity_address, validator)) return { ...data, - validators: data.validators.map(validator => { - return { - ...validator, - escrow: fromBaseUnits(validator.escrow, consensusDecimals), - ticker, - } - }), + validators, + map, } }, ...arrayify(options?.request?.transformResponse),