Skip to content

Commit

Permalink
Fix isClaimed: false
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Oct 24, 2024
1 parent 8b07d7b commit 894c5a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/api-derive/src/staking/stakerRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function extractCompatRewards (claimedRewardsEras: Vec<u32>, ledger?: PalletStak
return claimedRewardsEras.toArray().concat(l);
}

function parseRewards (api: DeriveApi, stashId: AccountId, [erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
function parseRewards (api: DeriveApi, stashId: AccountId, [erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[], claimedRewardsEras: Vec<u32>): DeriveStakerReward[] {
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
const { eraPoints, validators: allValPoints } = erasPoints.find((p) => p.era.eq(era)) || { eraPoints: BN_ZERO, validators: {} as DeriveEraValPoints };
const { eraReward } = erasRewards.find((r) => r.era.eq(era)) || { eraReward: api.registry.createType('Balance') };
Expand Down Expand Up @@ -84,7 +84,7 @@ function parseRewards (api: DeriveApi, stashId: AccountId, [erasPoints, erasPref
return {
era,
eraReward,
isClaimed: false,
isClaimed: claimedRewardsEras.some((c) => c.eq(era)),
isEmpty,
isValidator,
nominating,
Expand Down Expand Up @@ -184,7 +184,7 @@ export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds
const allRewards = queries.map(({ claimedRewardsEras, stakingLedger, stashId }, index): DeriveStakerReward[] =>
(!stashId || (!stakingLedger && !claimedRewardsEras))
? []
: parseRewards(api, stashId, erasResult, exposures[index])
: parseRewards(api, stashId, erasResult, exposures[index], claimedRewardsEras)
);

if (withActive) {
Expand Down

0 comments on commit 894c5a7

Please sign in to comment.