Skip to content

Commit

Permalink
fix kusama (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanLav authored Apr 21, 2024
1 parent 88a9e51 commit 291c05d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/payoutHelper/payouters/RelaychainPayouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ export class RelychainPayoutHelper extends PayoutHelper {
private async getLastReward(validatorAddress: string, isHistoryCheckForced = false): Promise<number> {
const ledger = (await this.api.derive.staking.account(validatorAddress)).stakingLedger;
let lastReward: number;
const rewards = ledger.claimedRewards || ledger.legacyClaimedRewards; // Workaround for the Kusama upgrade
// TODO: Remove the workaround and check the logic for reward payout

if (isHistoryCheckForced || ledger.claimedRewards.length == 0) {
if (isHistoryCheckForced || rewards.length == 0) {
// @ts-ignore
lastReward = this.api.consts.staking.historyDepth.toNumber();
} else {
lastReward = ledger.claimedRewards.pop().toNumber();
lastReward = rewards.pop().toNumber();
}
return lastReward;
}
Expand Down

0 comments on commit 291c05d

Please sign in to comment.