From 112e97a1e1861eec7456ed01e7044ec5a7d14d8a Mon Sep 17 00:00:00 2001 From: Tarik Gul <47201679+TarikGul@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:38:44 -0800 Subject: [PATCH] Fix payouts to reflect the fixes in the api (#11079) --- packages/page-staking/src/Payouts/PayButton.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/page-staking/src/Payouts/PayButton.tsx b/packages/page-staking/src/Payouts/PayButton.tsx index e411244b8c8..8f305caaf33 100644 --- a/packages/page-staking/src/Payouts/PayButton.tsx +++ b/packages/page-staking/src/Payouts/PayButton.tsx @@ -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; @@ -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; @@ -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 ( <>