To expand on what @ankan explained, this is quite a large staking pallet update, and DApps will need to migrate to the new storage items and calls.
I’d like to document some implementation details that were picked up when supporting paged rewards on staking dashboard (the full PR can be referred to here: Add paged rewards support by rossbulat · Pull Request #1678 · polkadot-cloud/polkadot-staking-dashboard · GitHub)
maxNominatorRewardedPerValidator is now maxExposurePageSize
The constant maxNominatorRewardedPerValidator no longer exists, and is replaced by maxExposurePageSize. Make sure you query consts.staking.maxExposurePageSize - and this should just warrant variable name changes in your code.
Hard-coded paged rewards networks & start era
I opted to hardcode which networks have paged rewards active, and which era paged rewards started. This looks like this in code:
// DEPRECATION: Paged Rewards
//
// Temporary until paged rewards migration has completed on all networks.
export const NetworksWithPagedRewards: NetworkName[] = ['westend'];
export const PagedRewardsStartEra: Record<NetworkName, number | null> = {
polkadot: null,
kusama: null,
westend: 7167,
};
You can then create a function that determines if paged rewards is active for a particular era:
// Given an era, determine whether paged rewards are active.
const isPagedRewardsActive = (era: BigNumber): boolean => {
const networkStartEra = PagedRewardsStartEra[network];
if (!networkStartEra) return false;
return (
NetworksWithPagedRewards.includes(network) &&
era.isGreaterThanOrEqualTo(networkStartEra)
);
}
If paged rewards are active, make sure to query eras stakers data from erasStakersOverview and erasStakersPaged, from the era paged rewards started.
If the current era is less than the paged rewards start era, or the network does not yet support paged rewards, query from the deprecated erasStakers storage item.
ErasStakers Changes: total and value in Overview, others in Paged
DApps can still adhere to the previous erasStakers structure whereby the total, value and others properties were fetched altogether. The difference now is that total and value are fetched from staking.erasStakersOverview, and others is fetched from staking.erasStakersPaged.
The only way to determine a nominator’s page is by iterating erasStakersPaged.
There is currently no shortcut for DApps to determine a nominator’s page in storage. I would suggest spinning up a service worker in your DApp that iterates erasStakersPaged others until the staker is found, and then return the page number.
Keep track of claimed paged in ClaimedRewards storage item
A new CliamedRewards storage item keeps track of what pages have been claimed for an era, mapping era => number[].
Use the new payout_stakers_paged call
To claim rewards for a particular page, a new payout_stakers_paged call can be used. supply the page number to payout in this call. payout_stakers still exists, but will pay out the earliest unclaimed page.
Happy to answer any questions relating to DApps supporting this new feature if I missed anything.