polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

api.derive.staking.electedInfo returns duplicated data #5869

Closed bizk closed 6 months ago

bizk commented 6 months ago

When using api.derive.staking.electedInfo it will fetch duplicated data that should exist only once.

I.e if running the following code

        const resp:any = await this.dotAPI.derive.staking.electedInfo()
        resp['info'].map(async param => {
          console.log(param["accountId"].toString())
        })

will return something like this (where . . . represents repeated addresses)

5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh
5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh
5GTD7ZeD823BjpmZBCSzBQp7cvHR1Gunq7oDkurZr9zUev2n
5GTD7ZeD823BjpmZBCSzBQp7cvHR1Gunq7oDkurZr9zUev2n
.
.
.
5GTD7ZeD823BjpmZBCSzBQp7cvHR1Gunq7oDkurZr9zUev2n
5GYaYNVq6e855t5hVCyk4Wuqssaf6ADTrvdPZ3QXyHvFXTip
5CAsa5uG1i3Duq5NM1g8zYjNvUCwkwADxgFQiypSLTg6Hnwm
5CAsa5uG1i3Duq5NM1g8zYjNvUCwkwADxgFQiypSLTg6Hnwm
5CcHdjf6sPcEkTmXFzF2CfH7MFrVHyY5PZtSm1eZsxgsj1KC
5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ
5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ
.
.
.
5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ

REQUIRED:

TarikGul commented 6 months ago

Thanks for reporting this, I am in the process of fixes the staking derives so I'll look into this today as well.

It currently looks like it has to do with api.derive.staking.queryMulti.

TarikGul commented 6 months ago

Im not exactly able to reproduce the above, what chain are you querying westend?

bizk commented 6 months ago

I have been using westend. I got it working by using api.derive.staking.queryMulti, but I found the behaviour odd

polkadot-js-bot commented 6 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.