-
Notifications
You must be signed in to change notification settings - Fork 795
Conversation
9faa56a
to
a701787
Compare
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.
lgtm, since this is a breaking change, could you make a note in the CHANGELOG and.
a basic example in the function's rustdoc could also be useful, basically copy-paste from test and maybe show how to convert back to U256?
@mattsse I will update the changelog and rust doc when I get back to my computer. |
@mattsse it seems the WASM build is broken because of the rug crate https://github.com/gakonst/ethers-rs/runs/4266231384?check_suite_focus=true is this a problem? |
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.
I think the requested change should fix the wasm build
19174bd
to
146e570
Compare
uh oh, this appears to be an issue with gmp-mpfr-sys that's not wasm compatible? https://gitlab.com/tspiteri/gmp-mpfr-sys/-/blob/master/build.rs |
yeah I will look into it |
it seems the gmp-mpfr-sys lib doesn't support wasm https://gitlab.com/tspiteri/gmp-mpfr-sys/-/issues/18 should I look for a different lib for float? |
Yes I'd prefer if we switched to a different float lib! Also, the function should still return |
@gakonst I will look into a different implementation that supports wasm however the functions should return a float or a string, not a U256 since that is incorrect functionality. That would mean that all values less than 0 would be returned as 0. so 0.56749 ETH would be returned as 0 which in my opinion is broken. the ethers implementation returns a string which is a float number: https://docs.ethers.io/v5/api/utils/display-logic/#utils-formatUnits |
aee8086
to
b09e3f7
Compare
b09e3f7
to
d57bb73
Compare
I rebased to fix the conflict |
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.
Looking good.
Motivation
parse_units and format_units were not behaving as expected when the decimal number was greater than 15 such as ether amounts
Solution
modified parse_units and format_units to use rug::Float of 128bit such that 18 decimal point floats don't get truncated. format_units now returns a rug::Float so that might break code that is using this function however it's an easy fix for such projects.
PR Checklist