Small cleanups & consistency (#2151)

* Small cleanups & consistency

* Fixes
This commit is contained in:
Jaco Greeff
2020-04-09 18:32:30 +02:00
committed by GitHub
parent 3b67b65091
commit afdb476796
10 changed files with 31 additions and 48 deletions
@@ -8,7 +8,6 @@ import { DeriveStakingValidators } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { StorageKey } from '@polkadot/types';
import { memo } from '../util';
@@ -18,9 +17,7 @@ export function nextElected (api: ApiInterfaceRx): () => Observable<AccountId[]>
? 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 }): Observable<StorageKey[]> =>
api.query.staking.erasStakers.keys(currentEra)
),
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
map((keys): AccountId[] =>
keys.map((key): AccountId => key.args[1] as AccountId)
)