Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix staking payouts #11079

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/page-staking/src/Payouts/PayButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function createExtrinsics (api: ApiPromise, payout: PayoutValidator | PayoutVali

return eras.length === 1
? [api.tx.staking.payoutStakers(validatorId, eras[0].era)]
: createStream(api, eras.map((era): SinglePayout => ({ era: era.era, validatorId })));
: createStream(api, eras.filter((era) => !era.isClaimed).map((era): SinglePayout => ({ era: era.era, validatorId })));
} else if (payout.length === 1) {
if (payout[0].eras.every((e) => e.isClaimed)) {
return null;
Expand All @@ -59,8 +59,10 @@ function createExtrinsics (api: ApiPromise, payout: PayoutValidator | PayoutVali
}

return createStream(api, payout.reduce((payouts: SinglePayout[], { eras, validatorId }): SinglePayout[] => {
eras.forEach(({ era }): void => {
payouts.push({ era, validatorId });
eras.forEach(({ era, isClaimed }): void => {
if (!isClaimed) {
payouts.push({ era, validatorId });
}
});

return payouts;
Expand Down Expand Up @@ -88,7 +90,7 @@ function PayButton ({ className, isAll, isDisabled, payout }: Props): React.Reac
);
}, [api, payout]);

const isPayoutEmpty = !payout || (Array.isArray(payout) && !payout.some((p) => p.eras.some((e) => !e.isClaimed))) || (Array.isArray(payout) && payout.length === 0);
const isPayoutEmpty = !payout || (!Array.isArray(payout) && !payout.eras.some((e) => !e.isClaimed)) || (Array.isArray(payout) && payout.some((p) => !p.eras.some((e) => !e.isClaimed))) || (Array.isArray(payout) && payout.length === 0);

return (
<>
Expand Down
Loading