Fix staking.info (#1091)

* Frankenstein

* Remove console.log

* Fix lint

* Remove console

* Fix tests

* Put back old version

* Add comment

* Store changeset data (filling in the blanks) (#1094)

* Store changeset data (filling in the blanks)

* Option(StorageData, null) when not available

* Make test pass
This commit is contained in:
Amaury Martiny
2019-07-10 13:08:32 +02:00
committed by Jaco Greeff
parent 7dfdab7bcc
commit a3ce8672af
7 changed files with 83 additions and 40 deletions
+12 -12
View File
@@ -83,18 +83,18 @@ function withStashController (api: ApiInterface$Rx, accountId: AccountId, contro
const stashId = accountId;
return (
combineLatest([
eraLength(api)(),
bestNumber(api)(),
api.queryMulti([
[api.query.session.nextKeyFor, controllerId],
[api.query.staking.ledger, controllerId],
[api.query.staking.nominators, stashId],
[api.query.staking.payee, stashId],
[api.query.staking.stakers, stashId],
[api.query.staking.validators, stashId]
])
]) as any as Observable<[BN, BlockNumber, [Option<Keys | SessionKey>, Option<StakingLedger>, [Array<AccountId>], RewardDestination, Exposure, [ValidatorPrefs]]]>
combineLatest([
eraLength(api)(),
bestNumber(api)(),
api.queryMulti([
[api.query.session.nextKeyFor, controllerId],
[api.query.staking.ledger, controllerId],
[api.query.staking.nominators, stashId],
[api.query.staking.payee, stashId],
[api.query.staking.stakers, stashId],
[api.query.staking.validators, stashId]
])
]) as any as Observable<[BN, BlockNumber, [Option<Keys | SessionKey>, Option<StakingLedger>, [Array<AccountId>], RewardDestination, Exposure, [ValidatorPrefs]]]>
).pipe(
map(([eraLength, bestNumber, [nextKeyFor, _stakingLedger, [nominators], rewardDestination, stakers, [validatorPrefs]]]) => {
const stakingLedger = _stakingLedger.unwrapOr(null) || undefined;
+9 -1
View File
@@ -2,8 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { distinctUntilChanged, publishReplay, refCount } from 'rxjs/operators';
import { catchError, distinctUntilChanged, publishReplay, refCount } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { logger } from '@polkadot/util';
const l = logger('drr');
/**
* Shorthand for distinctUntilChanged(), publishReplay(1) and refCount().
@@ -12,6 +15,11 @@ import { Observable } from 'rxjs';
*/
export const drr = () => <T>(source$: Observable<T>): Observable<T> =>
source$.pipe(
catchError(err => {
l.error(err);
throw err;
}),
distinctUntilChanged(),
publishReplay(1),
refCount()