Add support for custom units#302
Conversation
kclowes
left a comment
There was a problem hiding this comment.
I think I'd rather see this as a new function instead of co-opting to/from_wei. Are you up for making that change instead?
Yes, of course. I will soon make these change in PR. |
|
Thank you! |
|
I created auxiliary private functions (_from_wei, _to_wei) as I use in the following functions, because the logic was very similar. I also thought about a clear name for the new functions and decided to stop at from/to_wei_decimals. I decided to choose “decimals” because it comes more from the ERC-20 standard, where such a name is often used. Maybe you have some ideas? |
fselmo
left a comment
There was a problem hiding this comment.
lgtm. Thanks @Roman505050 👍🏼
I like that name. Thanks for the PR @Roman505050! |
What was wrong?
The addition of integer support allows for more flexibility when handling units with varying decimal places. Tokens on blockchains often use different precisions (e.g., 6, 18 decimals), and using integers to specify these decimal places ensures accurate conversions. This enhancement improves handling of token values with varying decimal precision.
How was it fixed?
Support for integer-based unit values was added. This allows specifying the number of decimal places directly as an integer (e.g., from_wei(123456789, 6)), ensuring accurate conversions and improving flexibility in handling tokens with different decimal precisions.
Todo:
Cute Animal Picture