Allow geneic args for keys/entries (#3165)

This commit is contained in:
Jaco Greeff
2021-02-10 13:04:23 +01:00
committed by GitHub
parent 3e014b38e6
commit 40edc131fe
8 changed files with 33 additions and 27 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ import { memo } from '../util';
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> =>
api.query.staking.validators.keys().pipe(
map((keys) => keys.map((key) => key.args[0]).filter((a) => a))
map((keys) => keys.map(({ args: [validatorId] }) => validatorId).filter((a) => a))
)
);
}
@@ -18,7 +18,7 @@ export function nextElected (instanceId: string, api: ApiInterfaceRx): () => Obs
// 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.erasStakers.keys(currentEra)),
map((keys) => keys.map((key) => key.args[1]))
map((keys) => keys.map(({ args: [, accountId] }) => accountId))
)
: api.query.staking.currentElected<AccountId[]>()
);