According to the documentation, api.query.nominationPools.poolMembers
should yield details about pool members.
The result should be a Map so we should be able to iterate the .entries / .keys.
(async () {
const provider = new WsProvider('wss://kusama-rpc.polkadot.io')
const api = await ApiPromise.create({ provider: provider })
var addresses = [
'F3opxRbN5ZavB4LTn2JaUnScQc7G7G177CPnqjBpa9F9Gdr', // pool 50 stash
'F3opxRbN5ZavB4LTn2aKWL2iuHJifMsqn8uLnR2HQ1yQs7t', // pool 50 reward
'HhYuQCR1pJKVwPruCSNr8xp4R1ovqtAbNy3S8VuMXsPtBmH', // pool 50 depositor/root/etc
]
addresses.forEach(async (address) => {
console.log('address', address)
var members = await api.query.nominationPools.poolMembers.entries(address)
var keys = await api.query.nominationPools.poolMembers.keys(address)
console.log('members', members, 'keys', keys)
// const accountIds = keys.map(({ args: [accountId] }) => accountId)
const accountIds = keys.map(({ args }) => args)
console.debug('accountIds', accountIds)
members.forEach(([key, member]) => {
console.log('key arguments:', key.args.map((k) => k.toHuman()));
console.log(' exposure:', member.toHuman());
})
})
})()
However, I can't get anything from the entries()
or keys()
returns
address F3opxRbN5ZavB4LTn2JaUnScQc7G7G177CPnqjBpa9F9Gdr
address F3opxRbN5ZavB4LTn2aKWL2iuHJifMsqn8uLnR2HQ1yQs7t
address HhYuQCR1pJKVwPruCSNr8xp4R1ovqtAbNy3S8VuMXsPtBmH
done...
members [] keys []
accountIds []
members [] keys []
accountIds []
members [] keys []
accountIds []
Just calling await api.query.nominationPools.poolMembers(POOL_ADDRESS)
produces:
{
"poolId" : 34,
"points" : 1011793913984.0,
"rewardPoolTotalEarnings" : 449109804460.0,
"unbondingEras" : {}
},