Add staking.stakers to derive.staking.info (#931)
* Add staking.stakers to derive.staking.info * alphabetical ordering * add staking.nominators * Fix lint
This commit is contained in:
@@ -7,7 +7,7 @@ import { DerivedStaking } from '../types';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { ApiInterface$Rx } from '@polkadot/api/types';
|
||||
import { AccountId, Option, StakingLedger, ValidatorPrefs } from '@polkadot/types';
|
||||
import { AccountId, Exposure, Option, StakingLedger, ValidatorPrefs } from '@polkadot/types';
|
||||
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
@@ -16,17 +16,21 @@ function withStashController (api: ApiInterface$Rx, accountId: AccountId, contro
|
||||
|
||||
return (
|
||||
api.queryMulti([
|
||||
[api.query.session.nextKeyFor, controllerId],
|
||||
[api.query.staking.ledger, controllerId],
|
||||
[api.query.staking.validators, stashId],
|
||||
[api.query.session.nextKeyFor, controllerId]
|
||||
]) as any as Observable<[Option<StakingLedger>, [ValidatorPrefs], Option<AccountId>]>
|
||||
[api.query.staking.nominators, stashId],
|
||||
[api.query.staking.stakers, stashId],
|
||||
[api.query.staking.validators, stashId]
|
||||
]) as any as Observable<[Option<AccountId>, Option<StakingLedger>, [Array<AccountId>], Exposure, [ValidatorPrefs]]>
|
||||
).pipe(
|
||||
map(([stakingLedger, [validatorPrefs], nextKeyFor]) => ({
|
||||
map(([nextKeyFor, stakingLedger, [nominators], stakers, [validatorPrefs]]) => ({
|
||||
accountId,
|
||||
controllerId,
|
||||
nextSessionId: nextKeyFor.isSome
|
||||
? nextKeyFor.unwrap()
|
||||
: undefined,
|
||||
nominators,
|
||||
stakers,
|
||||
stakingLedger: stakingLedger.isSome
|
||||
? stakingLedger.unwrap()
|
||||
: undefined,
|
||||
@@ -43,16 +47,20 @@ function withControllerLedger (api: ApiInterface$Rx, accountId: AccountId, staki
|
||||
|
||||
return (
|
||||
api.queryMulti([
|
||||
[api.query.staking.validators, stashId],
|
||||
[api.query.session.nextKeyFor, controllerId]
|
||||
]) as any as Observable<[[ValidatorPrefs], Option<AccountId>]>
|
||||
[api.query.session.nextKeyFor, controllerId],
|
||||
[api.query.staking.nominators, stashId],
|
||||
[api.query.staking.stakers, stashId],
|
||||
[api.query.staking.validators, stashId]
|
||||
]) as any as Observable<[Option<AccountId>, [Array<AccountId>], Exposure, [ValidatorPrefs]]>
|
||||
).pipe(
|
||||
map(([[validatorPrefs], nextKeyFor]) => ({
|
||||
map(([nextKeyFor, [nominators], stakers, [validatorPrefs]]) => ({
|
||||
accountId,
|
||||
controllerId,
|
||||
nextSessionId: nextKeyFor.isSome
|
||||
? nextKeyFor.unwrap()
|
||||
: undefined,
|
||||
nominators,
|
||||
stakers,
|
||||
stakingLedger,
|
||||
stashId,
|
||||
validatorPrefs
|
||||
|
||||
Reference in New Issue
Block a user