Cleanup staking info (#1532)

* Cleanup staking info

* Cache calls

* V1, V2 (Aura & Babe) tested & working

* Hopefully pacify docs build

* Second time lucky?

* Third time lucky?

* Fouth time
This commit is contained in:
Jaco Greeff
2019-10-30 14:15:20 +01:00
committed by GitHub
parent 2676909cd0
commit 8379689eaa
17 changed files with 232 additions and 102 deletions
+5 -2
View File
@@ -83,13 +83,16 @@ function queryBalances (api: ApiInterfaceRx, accountId: AccountId): Observable<R
* ```
*/
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalances> {
const bestNumberCall = bestNumber(api);
const idAndIndexCall = idAndIndex(api);
return (address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> => {
return idAndIndex(api)(address).pipe(
return idAndIndexCall(address).pipe(
switchMap(([accountId]): Observable<Result> =>
(accountId
? combineLatest([
of(accountId),
bestNumber(api)(),
bestNumberCall(),
queryBalances(api, accountId),
// FIXME This is having issues with Kusama, only use accountNonce atm
// api.rpc.account && api.rpc.account.nextIndex
@@ -15,8 +15,10 @@ import { drr } from '../util/drr';
import { votingBalances } from './votingBalances';
export function votingBalancesNominatorsFor (api: ApiInterfaceRx): (address: AccountId | AccountIndex | Address | string) => Observable<DerivedBalances[]> {
const idAndIndexCall = idAndIndex(api);
return (address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> => {
return idAndIndex(api)(address).pipe(
return idAndIndexCall(address).pipe(
switchMap(([accountId]): Observable<AccountId[]> =>
accountId
? (api.query.staking.nominatorsFor<Vec<AccountId>>(accountId))