Skip to content

fix: changed how claimed variable is set in staking-payouts #1378

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

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Jan 10, 2024

Description

In staking-payouts endpoint, the claimed field is returning false even when rewards are actually claimed.

Testing

The claimed variable is set in this line of code where we check if the requested eraIndex is included in the claimedRewards vector. After testing, it shows that the includes function does not work as expected and does not return true when the eraIndex is included in the array. The reason might be related to types because I tried to use includes when changed the type of the eraIndex and it returned true. However this is still weird because if I check :

  • validatorLedger.claimedRewards.toRawType() -> it returns 'Vec<u32>' and
  • eraIndex.toRawType() -> it returns 'u32'
    so I would expect includes to work even if I do not change anything.

Proposed Solution

On the other hand, if we use the indexOf function it returns correctly the index where era is found in the array.
This works and we have to make sure to add the query param unclaimedOnly=false.

@Imod7 Imod7 requested a review from a team as a code owner January 10, 2024 14:03
Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great fix!

@Imod7 Imod7 merged commit 0560806 into master Jan 10, 2024
@Imod7 Imod7 deleted the domi-claimed-fix branch January 10, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants