ocean.py: Base 18 conversions are inconsistent, hurting DX/maintainability

There are currently inconsistencies in the handling of large integers. Smart contracts use big integer number representation and multiply a number with 10^18 in order to properly represent it. Ocean.py is inconsistent in dealing with this representation, sometimes showing end-users the “long” number and internally using the short version etc.

Solution Everything related to internals should be handled in the “long” format. Everything related to GUIs should be handled in the “short” format (aka normal numbers 😅 )

Discussion and additional context

  • We need to identify and fix where each format is appropriate throughout the application.
  • An example: in the models/data_token.py file, requesting get_info will return a dictionary. One of its keys is totalSupply, with a value of x. This makes me think there are x tokens. However, running the totalSupply function directly will return x * 10^18. This makes me think I have many more tokens than x. And if I don’t check the value to actually see that something is wrong, I might perform operations on them, and the result will be wrong.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (25 by maintainers)

Most upvoted comments

Or both. Benefit is that it’s human readable and easy to debug.