Filter empty rewards (#2881)

* Filter empty rewards

* Keep to 40 eras
This commit is contained in:
Jaco Greeff 2020-06-04 17:37:35 +02:00 committed by GitHub
parent 13f7f1814f
commit 26b70cdf9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -28,7 +28,8 @@ function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValid
payout.reduce((calls: SubmittableExtrinsic<'promise'>[], { eras, validatorId }): SubmittableExtrinsic<'promise'>[] =>
calls.concat(
...eras.map(({ era }) => api.tx.staking.payoutStakers(validatorId, era))
), [])
), []
).filter((_, index) => index < 40)
);
}

View File

@ -20,7 +20,7 @@ function getRewards ([[stashIds], available]: [[string[]], DeriveStakerReward[][
const allRewards: Record<string, DeriveStakerReward[]> = {};
stashIds.forEach((stashId, index): void => {
allRewards[stashId] = available[index];
allRewards[stashId] = available[index].filter(({ eraReward }) => !eraReward.isZero());
});
return {