Adjust for zero-length combines (#2369)
This commit is contained in:
@@ -32,13 +32,13 @@
|
||||
"@polkadot/rpc-core": "1.20.0-beta.4",
|
||||
"@polkadot/rpc-provider": "1.20.0-beta.4",
|
||||
"@polkadot/types": "1.20.0-beta.4",
|
||||
"@polkadot/util": "^2.14.1",
|
||||
"@polkadot/util-crypto": "^2.14.1",
|
||||
"@polkadot/util": "^2.15.0-beta.0",
|
||||
"@polkadot/util-crypto": "^2.15.0-beta.0",
|
||||
"bn.js": "^5.1.2",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.14.1"
|
||||
"@polkadot/keyring": "^2.15.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveStakingElected } from '../types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -13,16 +13,20 @@ import { memo } from '../util';
|
||||
export function electedInfo (api: ApiInterfaceRx): () => Observable<DeriveStakingElected> {
|
||||
return memo((): Observable<DeriveStakingElected> =>
|
||||
api.derive.staking.validators().pipe(
|
||||
switchMap(({ nextElected }): Observable<DeriveStakingElected> =>
|
||||
combineLatest(
|
||||
switchMap(({ nextElected }): Observable<DeriveStakingElected> => {
|
||||
if (!nextElected.length) {
|
||||
return of({ info: [], nextElected: [] });
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
nextElected.map((accountId) => api.derive.staking.query(accountId))
|
||||
).pipe(
|
||||
map((info): DeriveStakingElected => ({
|
||||
info,
|
||||
nextElected
|
||||
}))
|
||||
)
|
||||
)
|
||||
);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { DeriveStakingWaiting } from '../types';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -20,6 +20,10 @@ export function waitingInfo (api: ApiInterfaceRx): () => Observable<DeriveStakin
|
||||
const elected = nextElected.map((a) => a.toString());
|
||||
const waiting = stashes.filter((v) => !elected.includes(v.toString()));
|
||||
|
||||
if (!waiting.length) {
|
||||
return of({ info: [], waiting: [] });
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
waiting.map((accountId) => api.derive.staking.query(accountId))
|
||||
).pipe(
|
||||
|
||||
Reference in New Issue
Block a user