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

format: handle input edge cases (zero decimals) #777

Merged
merged 2 commits into from
Jun 10, 2020
Merged

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Jun 10, 2020

Tokens may have 0 decimals (either explicitly declared or just assumed, e.g. for NFTs).

Only added additional test cases that we should handle for now!

@sohkai sohkai requested a review from bpierre June 10, 2020 07:04
@sohkai sohkai changed the title format: add tests to handle input edge cases (zero decimals) format: handle input edge cases (zero decimals) Jun 10, 2020
@bpierre bpierre marked this pull request as ready for review June 10, 2020 10:17
@bpierre
Copy link
Contributor

bpierre commented Jun 10, 2020

@sohkai Done. For decimal units greater than digits, I was thinking that we could reasonably tolerate it, what do you think?

@sohkai
Copy link
Contributor Author

sohkai commented Jun 10, 2020

Done. For decimal units greater than digits, I was thinking that we could reasonably tolerate it, what do you think?

I'm ok with this too!

I was originally thinking it would be better to be strict, like we are with the negative decimals/digits, but agreed that it's a different case when digits > decimals:

  • Negative decimals/digits are just logically wrong
  • You may want to specify a digit setting across all of your token displays, e.g. 3-5 (as we do), and not worry about having to do a clamp against provided decimals

@bpierre
Copy link
Contributor

bpierre commented Jun 10, 2020

You may want to specify a digit setting across all of your token displays, e.g. 3-5 (as we do), and not worry about having to do a clamp against provided decimals

Good point! 👍

@bpierre bpierre merged commit 6df85f2 into master Jun 10, 2020
@bpierre bpierre deleted the format-handle-zeros branch June 10, 2020 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants