Apply era filter onlly on recent (#2415)

This commit is contained in:
Jaco Greeff 2020-03-18 11:01:34 +01:00 committed by GitHub
parent afc062a4fe
commit be2fe9c36d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,12 +29,13 @@ function useNextPayouts (onlyLatest?: boolean): [string, BN][] | undefined {
const prevEra = indexes.activeEra.subn(1);
const lastPayouts = allInfo
.map(({ stakingLedger }, index) => [stashIds[index], stakingLedger?.lastReward?.unwrapOr(new BN(-1)).addn(1)])
.filter((value): value is [string, EraIndex] => !!value[1])
.filter(([, era]) => !onlyLatest || era.lt(prevEra));
.filter((value): value is [string, EraIndex] => !!value[1]);
setNextPayouts(
onlyLatest
? lastPayouts.map(([stashId]) => [stashId, indexes.activeEra.subn(1)])
? lastPayouts
.filter(([, era]) => era.lte(prevEra))
.map(([stashId]) => [stashId, prevEra])
: lastPayouts
);
}