Remove double-up-drr (memo vs rpc) (#1541)

* Remove inner memo (no double-up on stringify)

* Validators-specific query
This commit is contained in:
Jaco Greeff
2019-11-03 23:47:55 +01:00
committed by GitHub
parent d39878c875
commit 2371d6a29c
38 changed files with 100 additions and 93 deletions
+12 -8
View File
@@ -4,22 +4,26 @@
import { AccountId } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveStakingValidators } from '../types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
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),
export const validators = memo((api: ApiInterfaceRx): () => Observable<DeriveStakingValidators> => {
return (): Observable<DeriveStakingValidators> =>
api.queryMulti<[Vec<AccountId>, Vec<AccountId>]>([
api.query.session.validators,
api.query.staking.currentElected
]).pipe(
map(([validators, currentElected]): DeriveStakingValidators => ({
currentElected, validators
})),
drr()
));
);
}, true);