web3/web3.js

`fromWei` Returns "0." for `0` and Any Denomination Other Than Wei

danforbes opened this issue · 6 comments

When fromWei is called with 0 and any denomination other than wei, it returns the value "0." The trailing decimal point is unnecessary and should not be included.

Hi, may I work on researching and fixing this issue? It looks like a good-first-issue. Also, I'd like to ask if this kind of change would be considered a breaking change?

@danforbes we can add check. if the result is "0." and, if so, return "0" instead.

Hey @whitemoshui, go ahead and take a stab at this. This wouldn't be considered a breaking change.

We'd like to get this implemented soon, so let us know if you have any questions.

Hey @whitemoshui, go ahead and take a stab at this. This wouldn't be considered a breaking change.

We'd like to get this implemented soon, so let us know if you have any questions.

I saw there is a PR to fix. If he doesn't response, I can take over this issue later.

Since #7366 appears to be inactive for weeks, I've submitted a new PR addressing the same fromWei behavior.

If there are plans to continue with #7366, I'm happy to close mine. Otherwise, we could proceed with the new implementation to resolve this issue.

Please let me know which approach you prefer.

Thank you all for your contributions in resolving this bug! Your efforts are greatly appreciated! 🎉