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