Skip to content
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

fix(#7044): toWei trim strings with more than 20 decimal places #7045

Merged
merged 5 commits into from
May 21, 2024

Conversation

gordon-to
Copy link
Contributor

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.

@gordon-to
Copy link
Contributor Author

fixes #7044

let parsedNumber = number;
if (typeof parsedNumber === 'number'){
if (parsedNumber < 1e-15){
let parsedNumber: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

@gordon-to thanks for PR,

due to this change , there are build errors:

Error: web3-utils: src/converters.ts(580,10): error TS2454: Variable 'parsedNumber' is used before being assigned.
Error: web3-utils: src/converters.ts(580,92): error TS24[54](https://github.com/web3/web3.js/actions/runs/9125740835/job/25095746688?pr=7045#step:6:55): Variable 'parsedNumber' is used before being assigned.

@gordon-to gordon-to marked this pull request as draft May 17, 2024 13:05
@luu-alex
Copy link
Contributor

hey there, the PR is failing some of the testcases, in the web3.js/packages/web3-utils run yarn test:unit to see tests

@gordon-to gordon-to marked this pull request as ready for review May 17, 2024 15:42
@luu-alex
Copy link
Contributor

I added more tests and also added a fix for the function fromWei. Someone on the team will review this PR
Thanks for your contribution :)

@luu-alex luu-alex merged commit 553f270 into web3:4.x May 21, 2024
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants