-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
chore: BigNumber.toString(10) to prevent output as exponential #12576
Conversation
1597485
to
f4dbc86
Compare
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.
I am worried that someone will forget to add 10
and the same issue will occur again later.
It is now already missing in e.g. blockfrost.ts
Can we modify the BigNumber config to a really big number?
BigNumber.config({ EXPONENTIAL_AT: 1e+50 });
or modify toString
prototype to have base=10
by default?
const originalToString = BigNumber.prototype.toString;
BigNumber.prototype.toString = (base = 10) => originalToString.call(this, base);
Yeah, it's true that this is not that maintainable. My idea to solve this was by making an Eslint plugin, since I already have a script which I used to make these changes. But based on your ideas, I think the best solution would probably be to create a new wrapper package which we would import instead of BigNumber, there would use |
c59cac9
to
8fe54c4
Compare
8fe54c4
to
b6b7a7e
Compare
b6b7a7e
to
3a3a16b
Compare
@Nodonisko @mroz22 can you please do the final review and approve/add comment? Thanks! |
Description
This change ensures that all
toString
calls onBigNumber
objects include base 10 as a parameter. By doing this, we prevent numbers from being displayed in exponential form.