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
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { AccountId, Balance, BlockNumber, StakingLedger, ValidatorPrefs, Vote } from '@plugnet/types';
|
||||
import { AccountId, Balance, BlockNumber, Exposure, StakingLedger, ValidatorPrefs, Vote } from '@plugnet/types';
|
||||
|
||||
export type DerivedBalances = {
|
||||
accountId: AccountId,
|
||||
@@ -61,6 +61,8 @@ export type DerivedStaking = {
|
||||
accountId: AccountId,
|
||||
controllerId?: AccountId,
|
||||
nextSessionId?: AccountId,
|
||||
nominators?: Array<AccountId>,
|
||||
stakers?: Exposure,
|
||||
stakingLedger?: StakingLedger,
|
||||
stashId?: AccountId,
|
||||
validatorPrefs?: ValidatorPrefs
|
||||
|
||||
Reference in New Issue
Block a user