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: fix handling of null stake when parsing account info #8

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

refi93
Copy link
Contributor

@refi93 refi93 commented Sep 16, 2024

We noticed that parsed account info may contain null stake in which case the lib crashes. This PR attempts to fix that

related to #7

@refi93 refi93 changed the title fix: fix handling of null stake when parsing account info (WIP) fix: fix handling of null stake when parsing account info Sep 16, 2024
Copy link
Contributor

@roccomuso roccomuso left a comment

Choose a reason for hiding this comment

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

thx for the PR, I noticed this as well

Copy link
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I'll merge this as is, and then clean up the bit I mentioned about the discriminant

Comment on lines +36 to +45
const { effective, activating, deactivating } = stakeAccount.stake ?
getStakeActivatingAndDeactivating(
stakeAccount.stake.delegation,
BigInt(epochInfo.epoch),
stakeHistory
);
) : {
effective: BigInt(0),
activating: BigInt(0),
deactivating: BigInt(0),
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than zeroing these, I prefer to keep this code consistent with the web3.js v2 version which only looks at the discriminant. Unfortunately, the discriminant is incorrect in the web3.js v1 version, so we can go with this for now

@joncinque joncinque merged commit 669ed92 into anza-xyz:main Oct 11, 2024
4 checks passed
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