Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

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

Closed
danforbes opened this issue Oct 17, 2024 · 6 comments
Closed

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

danforbes opened this issue Oct 17, 2024 · 6 comments
Labels
4.x 4.0 related Bug Addressing a bug Good First Issue Great to learn the internals of web3.js P1 High severity bugs

Comments

@danforbes
Copy link
Contributor

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.

@whitemoshui
Copy link
Contributor

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?

@mconnelly8 mconnelly8 added Bug Addressing a bug 4.x 4.0 related P1 High severity bugs labels Oct 29, 2024
@TemirlanBasitov
Copy link
Contributor

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

@danforbes danforbes linked a pull request Nov 4, 2024 that will close this issue
17 tasks
@mconnelly8
Copy link

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.

@mconnelly8 mconnelly8 added the Good First Issue Great to learn the internals of web3.js label Nov 4, 2024
@whitemoshui
Copy link
Contributor

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.

@whitemoshui whitemoshui mentioned this issue Nov 14, 2024
17 tasks
@whitemoshui
Copy link
Contributor

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.

@krzysu
Copy link
Contributor

krzysu commented Nov 19, 2024

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

@krzysu krzysu closed this as completed Nov 19, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
4.x 4.0 related Bug Addressing a bug Good First Issue Great to learn the internals of web3.js P1 High severity bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@krzysu @danforbes @TemirlanBasitov @mconnelly8 @whitemoshui and others