Skip to content

Commit

Permalink
Fix payouts to reflect the fixes in the api (#11079)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul authored Nov 12, 2024
1 parent 12ccf10 commit 112e97a
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 112e97a

Please sign in to comment.