[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
2024-04-28 14:35:51 +02:00
committed by GitHub
parent 2a497d2975
commit 73b9a8391f
7 changed files with 163 additions and 2 deletions
+4
View File
@@ -2791,6 +2791,10 @@ impl_runtime_apis! {
fn eras_stakers_page_count(era: sp_staking::EraIndex, account: AccountId) -> sp_staking::Page {
Staking::api_eras_stakers_page_count(era, account)
}
fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
Staking::api_pending_rewards(era, account)
}
}
impl sp_consensus_babe::BabeApi<Block> for Runtime {