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:
@@ -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);
|
||||
Reference in New Issue
Block a user