From 1a4be9e02c31570160ad6b19d214d85fcb8c2204 Mon Sep 17 00:00:00 2001 From: tarikgul Date: Mon, 11 Nov 2024 20:49:30 -0500 Subject: [PATCH] Fix payouts to reflect the fixes in the api --- 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 e411244b8c82..8f305caaf338 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 ( <>