diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e1bf4a03..13e1740cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ Contributed: Changes: -- Add individual era-slash cancels on staking sleashes page +- Add individual era-slash cancels on staking slashes page +- Adjust max payout batch size (40 txs for 64 payees) based on staking payout constant - Add "copy seed" button to align with the extension UX on new accounts - Combine confirmation/backup of imports/new account into the modals (no double-modal) - Fix ecdsa JSON import dialogs diff --git a/packages/page-staking/src/Payouts/PayButton.tsx b/packages/page-staking/src/Payouts/PayButton.tsx index 0ca098648c..1f354bc521 100644 --- a/packages/page-staking/src/Payouts/PayButton.tsx +++ b/packages/page-staking/src/Payouts/PayButton.tsx @@ -14,7 +14,8 @@ import { useApi, useToggle } from '@polkadot/react-hooks'; import { useTranslation } from '../translate'; -const MAX_BATCH_SIZE = 40; +const DEFAULT_BATCH = 40; +const DEFAULT_PAYOUTS = 64; interface Props { className?: string; @@ -28,10 +29,12 @@ interface SinglePayout { validatorId: string; } -function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValidator[]): SubmittableExtrinsic<'promise'> | null { +function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValidator[], maxPayouts: number): SubmittableExtrinsic<'promise'> | null { + const batchSize = DEFAULT_BATCH * (DEFAULT_PAYOUTS / maxPayouts); + if (Array.isArray(payout)) { if (payout.length === 1) { - return createExtrinsic(api, payout[0]); + return createExtrinsic(api, payout[0], maxPayouts); } return api.tx.utility.batch( @@ -44,7 +47,7 @@ function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValid return payouts; }, []) .sort((a, b) => a.era.cmp(b.era)) - .filter((_, index) => index < MAX_BATCH_SIZE) + .filter((_, index) => index < batchSize) .map(({ era, validatorId }) => api.tx.staking.payoutStakers(validatorId, era)) ); } @@ -56,7 +59,7 @@ function createExtrinsic (api: ApiPromise, payout: PayoutValidator | PayoutValid : api.tx.utility.batch( eras .sort((a, b) => a.era.cmp(b.era)) - .filter((_, index) => index < MAX_BATCH_SIZE) + .filter((_, index) => index < batchSize) .map(({ era }) => api.tx.staking.payoutStakers(validatorId, era)) ); } @@ -70,7 +73,7 @@ function PayButton ({ className, isAll, isDisabled, payout }: Props): React.Reac useEffect((): void => { api.tx.utility && payout && setExtrinsic( - () => createExtrinsic(api, payout) + () => createExtrinsic(api, payout, api.consts.staking.maxNominatorRewardedPerValidator?.toNumber() || DEFAULT_PAYOUTS) ); }, [api, isDisabled, payout]);