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

Adjusted fromWei #7366

Conversation

TemirlanBasitov
Copy link
Contributor

@TemirlanBasitov TemirlanBasitov commented Oct 30, 2024

Description

Please include a summary of the changes and be sure to follow our Contribution Guidelines.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run lint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:coverage and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have linked Issue(s) with this PR in "Linked Issues" menu.

@@ -546,15 +554,9 @@ export const fromWei = (number: Numbers, unit: EtherUnits | number): string => {
const fraction = zeroPaddedValue.slice(-numberOfZerosInDenomination).replace(/\.?0+$/, '');

if (integer === '') {
return `0.${fraction}`;
return fraction ? `0.${fraction}` : "0";
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be great to add a unit test to cover this line. thanks

@@ -2752,26 +2752,26 @@ If there are any bugs, improvements, optimizations or any new feature proposal f

Copy link
Contributor

Choose a reason for hiding this comment

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

Are the changes to this file intentional?

@krzysu
Copy link
Contributor

krzysu commented Nov 19, 2024

The issue has been resolved with this PR, making this one no longer relevant. Thank you, @TemirlanBasitov, for your effort and contribution—it’s greatly appreciated! 🙌

@krzysu krzysu closed this Nov 19, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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