-
Notifications
You must be signed in to change notification settings - Fork 5k
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 towei scientific notation #6908
Merged
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
6b95286
update utils
97255b3
replace web3 eventemitter for eventemitter3
79a25f2
update tests
fb28b3b
update snapshot
334ea0b
remove connection error test
0aa37ec
Merge branch '4.x' into fix-native
007104e
Merge branch '4.x' into fix-native
111bcfb
Merge branch '4.x' into fix-native
5d33fc0
fix scientific notation
2fbddbd
Merge branch '4.x' into fix-towei
af42d35
Merge branch '4.x' into fix-towei
e64a3fe
Merge branch '4.x' into fix-towei
da99254
add error
9e7c3f4
add warnings and address feedback
d86bb69
Merge branch '4.x' into fix-towei
125f7bb
update
9f1fbf0
Merge branch '4.x' into fix-towei
Muhammad-Altabba 3b91d5e
Merge branch '4.x' into fix-towei
42a724c
update
facdf3a
add testcases
d10eeaa
add more testcases
da396eb
Merge branch '4.x' into fix-towei
Muhammad-Altabba bad1323
uses parsednumber
287121a
Merge branch '4.x' into fix-towei
2086e98
Merge branch '4.x' into fix-towei
b2da839
update test case
560c041
refactor
f47c107
update changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,9 +300,21 @@ export const fromWeiValidData: [[Numbers, EtherUnits], string][] = [ | |
[[1.9999999999999991611392e+22, 'ether'], '19999.999999999991611392'], | ||
]; | ||
|
||
export const toWeiValidData: [[Numbers, EtherUnits], string][] = [ | ||
export const toWeiValidData: [[Numbers, EtherUnits], Numbers][] = [ | ||
...conversionBaseData, | ||
[['255', 'wei'], '0xFF'], | ||
[['255', 'wei'], '0xFF'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is doublicate. Was it meant to have differnt values? Or, should this be deleted? |
||
[['100000000000', 'ether'], 0.0000001], | ||
[['1000000000', 'ether'], 0.000000001], | ||
[['1000000', 'ether'], 0.000000000001] | ||
|
||
]; | ||
|
||
export const toWeiValidDataWarnings: [[Numbers, EtherUnits], string][] = [ | ||
[[0.0000000000000000000001, 'ether'], 'Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods'], | ||
[[0.0000000000000000000001, 'ether'], 'Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods'], | ||
[[1999999000000009900000, 'kwei'], 'Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods'], | ||
|
||
]; | ||
|
||
export const fromWeiInvalidData: [[any, any], string][] = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, why this is no need to call
parsedNumber = BigInt(parsedNumber);
here similar to the logic forparsedNumber < 1e-15
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large decimal numbers values become scientific notation (for example
1e-15
) and scientific notation is not accepted by BigInt. On line 573 we will convert the number to a string, so there is no need to convert to a bigint