Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added staking.claimed() in replacement of staking.ledger().legacyClaimedRewards #1436

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/services/accounts/AccountsStakingPayoutsService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
erasValidatorPrefsAt,
erasValidatorRewardAt,
ledgerAt,
palletVersionAt,
} from '../test-helpers/mock/accounts';
import { AccountsStakingPayoutsService } from './AccountsStakingPayoutsService';

Expand Down Expand Up @@ -59,6 +60,7 @@ const mockHistoricApi = {
erasStakersClipped: {
entries: erasStakersClippedAt,
},
palletVersion: palletVersionAt,
},
},
} as unknown as ApiDecoration<'promise'>;
Expand Down
13 changes: 12 additions & 1 deletion src/services/accounts/AccountsStakingPayoutsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,20 @@ export class AccountsStakingPayoutsService extends AbstractService {
return {
commission,
};
} else {
validatorLedger = validatorLedgerOption.unwrap();
if (
historicApi.query.staking.claimedRewards &&
(await historicApi.query.staking.claimedRewards(era, validatorControllerOption.unwrap())).length ===
(await historicApi.query.staking.erasStakersOverview(era, validatorControllerOption.unwrap()))
.unwrap()
.pageCount.toNumber()
) {
const eraVal: u32 = historicApi.registry.createType('u32', era);
validatorLedger.legacyClaimedRewards.push(eraVal);
}
}

validatorLedger = validatorLedgerOption.unwrap();
validatorLedgerCache[validatorId] = validatorLedger;
}

Expand Down
2 changes: 2 additions & 0 deletions src/services/test-helpers/mock/accounts/stakingPayouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export const erasRewardPointsAt = (_: EraIndex) =>
),
);

export const palletVersionAt = () => Promise.resolve().then(() => api.registry.createType('u16', '13'));

export const deriveEraExposureParam = {
era: api.registry.createType('EraIndex', ERA),
nominators: {
Expand Down
Loading