Staking overview derive (#1537)

* Staking overview derive

* Expand derives

* Extract currentIndex/currentEra

* WIP

* Controllers opt

* Add memo

* Memomize the whole lot

* Doc building fixes

* Doc fixes #2
This commit is contained in:
Jaco Greeff
2019-11-02 23:10:10 +01:00
committed by GitHub
parent 1d92b7bead
commit 7cc961f789
44 changed files with 493 additions and 307 deletions
@@ -0,0 +1,26 @@
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { drr, memo } from '../util';
import { overview } from './overview';
/**
* @description Retrieve latest list of validators
*/
export const validators = memo((api: ApiInterfaceRx): () => Observable<AccountId[]> => {
const overviewCall = overview(api);
return memo((): Observable<AccountId[]> =>
overviewCall().pipe(
map(({ validators }): AccountId[] => validators),
drr()
)
);
}, true);