Pass online/offline status indicators with staking accounts (#1265)
* staking online status * restrict onlineStatus.online to validators * get onlineStatus for stash/validator only * tests * fixes * Add offline * Revert stash, change to stashId, linting * Heartbeat signature * Make CodeClimate (slightly) happier * keep compatibility * change status type * rv null possible * cleanup
This commit is contained in:
@@ -19,6 +19,7 @@ import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import { bestNumber } from '../chain/bestNumber';
|
||||
import { eraLength } from '../session/eraLength';
|
||||
import { recentlyOffline } from './recentlyOffline';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
type MultiResult = [Option<Keys>, [
|
||||
@@ -128,20 +129,20 @@ function retrieveMulti (api: ApiInterfaceRx, stashId: AccountId, controllerId: A
|
||||
}
|
||||
|
||||
function retrieveInfo (api: ApiInterfaceRx, stashId: AccountId, controllerId: AccountId): Observable<DerivedStaking> {
|
||||
return (
|
||||
combineLatest([
|
||||
eraLength(api)(),
|
||||
bestNumber(api)(),
|
||||
retrieveMulti(api, stashId, controllerId)
|
||||
])
|
||||
).pipe(
|
||||
map(([eraLength, bestNumber, [nextKeys, [queuedKeys, _stakingLedger, [nominators], rewardDestination, stakers, [validatorPrefs]]]]): DerivedStaking => {
|
||||
return combineLatest([
|
||||
eraLength(api)(),
|
||||
bestNumber(api)(),
|
||||
recentlyOffline(api)(),
|
||||
retrieveMulti(api, stashId, controllerId)
|
||||
]).pipe(
|
||||
map(([eraLength, bestNumber, recentlyOffline, [nextKeys, [queuedKeys, _stakingLedger, [nominators], rewardDestination, stakers, [validatorPrefs]]]]): DerivedStaking => {
|
||||
const stakingLedger = _stakingLedger.unwrapOr(undefined);
|
||||
|
||||
return {
|
||||
accountId: stashId,
|
||||
controllerId,
|
||||
nominators,
|
||||
offline: recentlyOffline[stashId.toString()],
|
||||
redeemable: redeemableSum(stakingLedger, eraLength, bestNumber),
|
||||
rewardDestination,
|
||||
stakers,
|
||||
|
||||
Reference in New Issue
Block a user