Additional derive cleanups (#4307)

* Additional derive cleanups

* Adjust

* Multi cache set

* Adjust mapping
This commit is contained in:
Jaco
2021-12-09 12:12:05 +02:00
committed by GitHub
parent 584cbb994b
commit e32ac213b9
21 changed files with 129 additions and 154 deletions
+2 -4
View File
@@ -10,7 +10,7 @@ import type { DeriveStakingQuery, StakingQueryFlags } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
import { firstObservable, memo } from '../util';
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestination: PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
return {
@@ -95,9 +95,7 @@ function getBatch (api: ApiInterfaceRx, activeEra: EraIndex, stashIds: AccountId
*/
export function query (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, flags: StakingQueryFlags) => Observable<DeriveStakingQuery> {
return memo(instanceId, (accountId: Uint8Array | string, flags: StakingQueryFlags): Observable<DeriveStakingQuery> =>
api.derive.staking.queryMulti([accountId], flags).pipe(
map(([first]) => first)
)
firstObservable(api.derive.staking.queryMulti([accountId], flags))
);
}