-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Hateful Dispare: Don't Change the BN .toString method please #248
Comments
Hey Nick! So, this was something I'd put a lot of consideration into back in the day; three-ish years ago, and did a lot of research on. :) Keep in mind that
Here are some various ECMAScript specifications too:
Other reasons I avoided using The ethers documentation also reinforces what it means to be a "hexstring", as opposed to a hexadecimal number. A hexstring always has a "0x" prefix. So, A lot of the other libraries also take in weird things, such as The documentation does point out that it returns a decimal value, but I'll make sure to highlight that more in the v4 docs, which should be coming out very soon. Libraries that do support
Libraries that do not support it:
These were literally just the first 5 random libraries I found on google and NPM, so it's not /that/ wide-spread. Just sayin'. :) |
@ricmoo as always, great reasoning and thinking. Sorry for my verboseness but this caused me a ton of problems (2 days) -- I thought I was going crazy. I would say flag it more in the docs though. And also, BN and BigNumber are the common ones use in Ethereum, which is why I flag the toString(radix) as common, even though others might support different notation. None-the-less, I think this conversation is good record for the decision, you could even include it in the docs as further reference. Anyway, good day! |
https://github.com/ethers-io/ethers.js/blob/master/utils/bignumber.js#L126
Ethers.js BigNumber converts the toString method to always return base10. This was NOT known to me even after a decent read of the docs and confused the hell out of me and my tests. As in every other BN library .toString allows the
base
specifier input. I think I and other devs would appreciate you don't change such a critical method away from the BN library spec.I see you commented out the override and added an explicit toHexString method. I would flag this hard and several times in the docs if you choose to continue to override
toString
in this non-conventional way.Sincerely, your dear friend and code admirror.
The text was updated successfully, but these errors were encountered: