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: add Kusama chain check in historic blocks #1415

Merged
merged 4 commits into from
Mar 20, 2024
Merged

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Mar 20, 2024

Description

Added a check to determine if we are connected in the Kusama chain, as the calculations are Kusama specific.

Credits & Thanks

  • to @ruiparitydata for bringing this to our attention and providing useful examples and test cases so we can easily replicate the error.

@Imod7 Imod7 requested a review from a team as a code owner March 20, 2024 17:22
@@ -104,17 +104,18 @@ export default class AccountsStakingPayoutsController extends AbstractController
const earlyErasBlockInfo: IEarlyErasBlockInfo = kusamaEarlyErasBlockInfo;
let hash = await this.getHashFromAt(at);
let apiAt = await this.api.at(hash);
const runtimeInfo = await this.api.rpc.state.getRuntimeVersion(hash);
Copy link
Member

@TarikGul TarikGul Mar 20, 2024

Choose a reason for hiding this comment

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

Let's right a variable here that is:

const isKusama = runtimeInfo.specName.toString().toLowerCase() === 'kusama';

This should clean the rest up a bit

Copy link
Contributor

Choose a reason for hiding this comment

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

Beat me to it

? historicApi.query.staking.validators(validatorId)
: historicApi.query.staking.erasValidatorPrefs(era, validatorId);
commissionPromise =
ancient && specName.toLowerCase() === 'kusama'
Copy link
Member

Choose a reason for hiding this comment

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

We can do the isKusama variable here as well if you'd like.

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.

Just some nits and questions. But overall LGTM

Co-authored-by: Alberto Nicolas Penayo <74352651+bee344@users.noreply.github.com>
Copy link
Contributor

@bee344 bee344 left a comment

Choose a reason for hiding this comment

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

Looks mighty fine to me

@Imod7 Imod7 merged commit cfbcddd into master Mar 20, 2024
15 checks passed
@Imod7 Imod7 deleted the domi-payouts-chain-fix branch March 20, 2024 21:55
This pull request was closed.
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.

4 participants