From ea3ff1d6c4acbb5b1b6469499dd017ebd5c4e117 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Tue, 29 Oct 2024 07:52:57 -0400 Subject: [PATCH] Adjust nextElected to use erasStakersOverview --- packages/api-derive/src/staking/validators.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-derive/src/staking/validators.ts b/packages/api-derive/src/staking/validators.ts index e8561e904c0a..aad1f2d687da 100644 --- a/packages/api-derive/src/staking/validators.ts +++ b/packages/api-derive/src/staking/validators.ts @@ -12,11 +12,11 @@ import { memo } from '../util/index.js'; export function nextElected (instanceId: string, api: DeriveApi): () => Observable { return memo(instanceId, (): Observable => // 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))) )