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
@@ -8,7 +8,7 @@ import type { DeriveEraValidatorExposure, DeriveStakerExposure } from '../types'
import { map, switchMap } from 'rxjs';
import { memo } from '../util';
import { firstObservable, memo } from '../util';
export function _stakerExposures (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerExposure[][]> {
return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive: boolean): Observable<DeriveStakerExposure[][]> => {
@@ -48,8 +48,6 @@ export function stakerExposures (instanceId: string, api: ApiInterfaceRx): (acco
export function stakerExposure (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, withActive?: boolean) => Observable<DeriveStakerExposure[]> {
return memo(instanceId, (accountId: Uint8Array | string, withActive = false): Observable<DeriveStakerExposure[]> =>
api.derive.staking.stakerExposures([accountId], withActive).pipe(
map(([first]) => first)
)
firstObservable(api.derive.staking.stakerExposures([accountId], withActive))
);
}