[Staking] Runtime api if era rewards are pending to be claimed (#4301)

closes https://github.com/paritytech/polkadot-sdk/issues/426.
related to https://github.com/paritytech/polkadot-sdk/pull/1189.

Would help offchain programs to query if there are unclaimed pages of
rewards for a given era.

The logic could look like below

```js
// loop as long as all era pages are claimed.
while (api.call.stakingApi.pendingRewards(era, validator_stash)) {
  api.tx.staking.payout_stakers(validator_stash, era)
}
```
This commit is contained in:
Ankan authored and GitHub committed 2024-04-28 12:35:51 +00:00
1 parent 2a497d2975
commit 73b9a8391f
7 files changed
+163 -2

No files matched your search

@@ -30,7 +30,10 @@ sp_api::decl_runtime_apis! {
/// Returns the nominations quota for a nominator with a given balance.
fn nominations_quota(balance: Balance) -> u32;
/// Returns the page count of exposures for a validator in a given era.
/// Returns the page count of exposures for a validator `account` in a given era.
fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page;
/// Returns true if validator `account` has pages to be claimed for the given era.
fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool;
}
}