Skip to content

Commit

Permalink
Merge pull request #104 from TarikGul/main
Browse files Browse the repository at this point in the history
Fix listPendingPayouts bug
  • Loading branch information
joepetrowski authored Dec 4, 2024
2 parents f8796ea + b0933f2 commit 80211c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export async function listPendingPayouts({

const controller = controllerOpt.unwrap();
// Check for unclaimed payouts from `current-eraDepth` to `current` era
for (let e = currEra - eraDepth; e <= currEra; e++) {
// The current era is not claimable. Therefore we need to substract by 1.
for (let e = (currEra - 1) - eraDepth; e <= (currEra - 1); e++) {
const payoutClaimed = await payoutClaimedForAddressForEra(api, controller.toString(), e);
if (payoutClaimed) {
continue;
Expand All @@ -151,7 +152,7 @@ export async function listPendingPayouts({
}
}

payouts.length &&
if (payouts.length) {
log.info(
`The following unclaimed payouts where found: \n${payouts
.map(
Expand All @@ -163,6 +164,9 @@ export async function listPendingPayouts({
.join('\n')}`
) &&
log.info(`Total of ${payouts.length} unclaimed payouts.`);
} else {
log.info(`No payouts found.`)
}

return payouts;
}
Expand Down

0 comments on commit 80211c3

Please sign in to comment.