-
Notifications
You must be signed in to change notification settings - Fork 150
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
feat: add at
query param for staking-payouts
#1388
Conversation
at
query param for staking-payoutsat
query param for staking-payouts [WIP]
at
query param for staking-payouts [WIP]at
query param for staking-payouts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 💯
It might be worth noting that Subscan and Sidecar display rewards differently (at least in the views I checked). I thought of adding the difference here in case it is helpful for others who might also check Subscan:
- For example, while connected in Kusama and checking some rewards from this list from Subscan I can see the rewards for different eras and blocks.
- For example, for block
20193750
I can see the reward0.152 KSM
for era5787
- If I query the Sidecar endpoint for this block
accounts/J47U9wGuwzccFPoz8bnMTKJt7WGpPp8ZNgvtXFDL9PHwpCt/staking-payouts?unclaimedOnly=false&at=20193750
it returns the reward for era5789
- So for the same block I get different era.
- The difference is due to the fact that:
- Sidecar gives back the rewards that correspond to each era (claimed or unclaimed) so it gives the
state
information. - Subscan gives back only the rewards that were claimed hence when and if someone made that call to get the corresponding reward. If no one makes that call and if 84 eras pass, this reward will be lost. (polkadot wiki)
- Sidecar gives back the rewards that correspond to each era (claimed or unclaimed) so it gives the
Important Note
- The reward amounts per era is consistent across both platforms.
- Also, just noting that there are examples that some blocks and eras will be aligned in both platforms too.
Credits to @IkerAlus for the explanation and clarifications.
Summary
This PR focuses on expanding the query params for
/accounts/{accountId}/staking-payouts
to include theat
query param. This required me to remove the oldapi.derive.staking.eraExposure(eraIndex)
that is exposed from polkadot-js and write a modified version that was abstracted from the polkadot-js source code to allow us to add a historic api to it.Query param
at
- Block height (as a non-negative integer) or hash (as a hex string).Extra
I rewrote all the tests for the endpoint to be cleaner and include specific information on the block and the era so if anything needs to be added in the future it will be simple to extract the necessary data from polkadot.
closes: #1033