Skip to content

Commit

Permalink
While loading validators, also compile a hash map
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 1, 2024
1 parent bee23db commit eca5f4c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, generated.Validator>()
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),
Expand Down

0 comments on commit eca5f4c

Please sign in to comment.