Skip to content

Commit

Permalink
Adjust nextElected to use erasStakersOverview (#6011)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul authored Oct 29, 2024
1 parent 64e30dd commit 508439c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/api-derive/src/staking/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { memo } from '../util/index.js';
export function nextElected (instanceId: string, api: DeriveApi): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> =>
// Compatibility for future generation changes in staking.
api.query.staking.erasStakersPaged
api.query.staking.erasStakersOverview
? api.derive.session.indexes().pipe(
// only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }) => api.query.staking.erasStakersPaged.keys(currentEra)),
switchMap(({ currentEra }) => api.query.staking.erasStakersOverview.keys(currentEra)),
// Dedupe any duplicates
map((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a)))
)
Expand Down

0 comments on commit 508439c

Please sign in to comment.