Skip to content
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

Fix isClaimed in api.derive.staking.{stakerRewards, stakerRewardsMultiEras, stakerRewardsMulti} #6026

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

TarikGul
Copy link
Member

@TarikGul TarikGul commented Nov 11, 2024

The main problem was not taking the isClaimed field that was already calculated in parseRewards and instead recalculating it in filterRewards.

I tested this against stash account: 13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR. Which at the time had no reward for era 1623 claimed but had a reward claimed for 1622. So I tested it for [1623, and 1622] and logged the allRewards in queryMulti in order to show the data being aggregated, and the final result. The results were as follows:

Before:

# allRewards logged
[
    [
        {
            "era": "0x00000657",
            "eraReward": "0x0000000000000000000e0f44fc1ae1df",
            "isClaimed": false,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x0000000000000000000006ff53b88314",
                    "value": "0x0000000000000000000006ff53b88314"
                }
            }
        },
        {
            "era": "0x00000656",
            "eraReward": "0x0000000000000000000e10d55cf10583",
            "isClaimed": true,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x00000000000000000000074ef098c2a6",
                    "value": "0x00000000000000000000074ef098c2a6"
                }
            }
        }
    ]
]

# Final result logged
[
    [
        {
            "era": "0x00000657",
            "eraReward": "0x0000000000000000000e0f44fc1ae1df",
            "isClaimed": true,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x0000000000000000000006ff53b88314",
                    "value": "0x0000000000000000000006ff53b88314"
                }
            },
            "nominators": []
        }
    ]
]

After:

# allRewards logged
[
    [
        {
            "era": "0x00000657",
            "eraReward": "0x0000000000000000000e0f44fc1ae1df",
            "isClaimed": false,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x0000000000000000000006ff53b88314",
                    "value": "0x0000000000000000000006ff53b88314"
                }
            }
        },
        {
            "era": "0x00000656",
            "eraReward": "0x0000000000000000000e10d55cf10583",
            "isClaimed": true,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x00000000000000000000074ef098c2a6",
                    "value": "0x00000000000000000000074ef098c2a6"
                }
            }
        }
    ]
]

# Final result logged
[
    [
        {
            "era": "0x00000657",
            "eraReward": "0x0000000000000000000e0f44fc1ae1df",
            "isClaimed": false,
            "isEmpty": false,
            "isValidator": true,
            "nominating": [],
            "validators": {
                "13gMD93wc2P44QaVXRvThy1Q81846QKVovPBjZEWLzW9HnVR": {
                    "total": "0x0000000000000000000006ff53b88314",
                    "value": "0x0000000000000000000006ff53b88314"
                }
            },
            "nominators": []
        }
    ]
]

rel: polkadot-js/apps#11071

@polkadot-js-bot polkadot-js-bot merged commit fd1871b into master Nov 11, 2024
6 checks passed
@polkadot-js-bot polkadot-js-bot deleted the tg-fix-isClaimed branch November 11, 2024 20:55
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants