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

WebUI must handle token decimals #2197

Closed
andrevmatos opened this issue Aug 16, 2018 · 4 comments
Closed

WebUI must handle token decimals #2197

andrevmatos opened this issue Aug 16, 2018 · 4 comments

Comments

@andrevmatos
Copy link
Contributor

Problem Definition

Right now, webUI shows tokens as Raiden sees it: only token weis, as integers. The webUI/client is responsible for managing token decimals, and should handle it gracefully. Each token contract have a decimals() method which returns an integer for the amount of decimals this token is configured with. UI input type="number"s should convert from decimal number to integer before sending the values to the REST API (raiden_amount = int(input_amount * 10**decimals)) and prevent user from entering more decimals than token supports, and places where any amount/deposit/balance is displayed should take it into account (ui_amount = raiden_amount / 10**decimals). BigNumber may be required. RaidenService may do it before handling data to the rest of the components.

@LefterisJP
Copy link
Contributor

Each token contract have a decimals() method which returns an integer for the amount of decimals this token is configured with

Important note for @kelsos and @andrevmatos:

The decimals() attribute is not a requirement for the contract. It is optional and may be missing. If it's missing we have to assume 18 decimals.

@kelsos
Copy link
Contributor

kelsos commented Aug 27, 2018

@LefterisJP I decided to deploy a test token and I just replaced uint8 public decimals = 18; with uint8 public decimals; This returns a 0, but zero can be a valid value for a non divisible token. Is that what you meant by missing or did I misunderstood something?

@LefterisJP
Copy link
Contributor

No you misunderstand. Of course it would be 0 if the variable is not initialized. Missing means the contract not having the decimals attribute at all.

@kelsos
Copy link
Contributor

kelsos commented Aug 27, 2018

@LefterisJP Thanks for clarifying I will look into it. I just remembered we already discussed this in person along with the approach to solve it. I am almost sure that the current webui will not be able to handle the missing value. I will do a check to be sure and proceed with opening an issue and fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants