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 DecCoin decoder to avoid absurdly large values #31

Merged
merged 2 commits into from
Jul 14, 2022
Merged

Fix DecCoin decoder to avoid absurdly large values #31

merged 2 commits into from
Jul 14, 2022

Conversation

jtary
Copy link
Contributor

@jtary jtary commented Jul 14, 2022

Modifies the decoder for DecCoins to convert the value into a decimal (as it should).

Note: This change modifies the decoder directly -- it does not fix the generator. If the protobufs are regenerated, this fix will need to be applied again. A unit test was added to check a regression does not occur.

@@ -135,7 +135,7 @@ export const DecCoin = {
message.denom = reader.string();
break;
case 2:
message.amount = reader.string();
message.amount = (parseInt(reader.string()) / (10 ** 18)).toPrecision(18);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual meat-and-potatoes of this fix. Turns 2000000000000000000 into 2.000000000000000000.

@jtary jtary merged commit 957abcb into main Jul 14, 2022
@jtary jtary deleted the deccoin branch July 14, 2022 16:13
github-actions bot pushed a commit that referenced this pull request Jul 14, 2022
Fix DecCoin decoder to avoid absurdly large values 0.1.1
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.

2 participants