Skip to content

Commit

Permalink
[Fixed] 0 reward validator not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
greedyboi committed Jan 31, 2024
1 parent 2e9002f commit 515e21e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/utils/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ export const getUserValidators = (
),
});
} else {
for (const reward of rewards.rewards) {
if (delegation.delegation && reward.validatorAddress === delegation.delegation.validatorAddress) {
validators.push({
...validator,
reward:
parseFloat(reward.reward.length > 0 ? reward.reward[0].amount : '0') / CLIENT_PRECISION,
stakedCoins: NumbersUtils.formatTo6digit(
NumbersUtils.convertUnitNumber(delegation.balance?.amount || '0'),
),
});
}
}
const valReward = rewards.rewards.find(
(r) => delegation.delegation && r.validatorAddress === delegation.delegation.validatorAddress,
);

validators.push({
...validator,
reward:
parseFloat(valReward && valReward.reward.length > 0 ? valReward.reward[0].amount : '0') /
CLIENT_PRECISION,
stakedCoins: NumbersUtils.formatTo6digit(
NumbersUtils.convertUnitNumber(delegation.balance?.amount || '0'),
),
});
}
}
}
Expand Down

0 comments on commit 515e21e

Please sign in to comment.