derive.accounts.info returns accountId/Index (#1533)

* derive.accounts.info returns accountId/Index

* Swap all idAndIndex to account.info
This commit is contained in:
Jaco Greeff
2019-10-31 10:48:29 +01:00
committed by GitHub
parent 2f350e3bc2
commit 453aacb669
4 changed files with 37 additions and 31 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec, createType } from '@polkadot/types';
import { bnMax } from '@polkadot/util';
import { idAndIndex } from '../accounts/idAndIndex';
import { info } from '../accounts/info';
import { bestNumber } from '../chain/bestNumber';
import { DerivedBalances } from '../types';
import { drr } from '../util/drr';
@@ -84,11 +84,11 @@ 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);
const infoCall = info(api);
return (address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> => {
return idAndIndexCall(address).pipe(
switchMap(([accountId]): Observable<Result> =>
return infoCall(address).pipe(
switchMap(({ accountId }): Observable<Result> =>
(accountId
? combineLatest([
of(accountId),
@@ -9,17 +9,17 @@ import { switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Vec } from '@polkadot/types';
import { idAndIndex } from '../accounts/idAndIndex';
import { info } from '../accounts/info';
import { DerivedBalances } from '../types';
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);
const infoCall = info(api);
return (address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> => {
return idAndIndexCall(address).pipe(
switchMap(([accountId]): Observable<AccountId[]> =>
return infoCall(address).pipe(
switchMap(({ accountId }): Observable<AccountId[]> =>
accountId
? (api.query.staking.nominatorsFor<Vec<AccountId>>(accountId))
: of([] as AccountId[])