I am trying to find the reward points belonging to a validator. I started with this:
const activeEra = await api.query.staking.activeEra()
const rewardPoints = await api.query.staking.erasRewardPoints(activeEra.unwrap().index)
const individualRewardPoints = activeEraRewardPoints.individual
Now, it looks like the individualRewardPoints
is some kind of map keyed by validator accounts, however I couldn't find how to get the specific item (I don't want to iterate over the map). Having a string, I tried these:
const alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
individualRewardPoints.get(alice)
individualRewardPoints.get(Buffer.from(alice))
This looked promising but still doesn't work:
{ decodeAddress } = require ('@polkadot/keyring')
individualRewardPoints.get(decodeAddress(alice))
All of them return undefined
. What's the way to get the reward points of a validator?