Skip to content

Handle tokens with zero decimals#2137

Merged
rdig merged 13 commits intomasterfrom
fix/2133-handle-zero-token-decimals
Apr 23, 2020
Merged

Handle tokens with zero decimals#2137
rdig merged 13 commits intomasterfrom
fix/2133-handle-zero-token-decimals

Conversation

@rdig
Copy link
Member

@rdig rdig commented Apr 22, 2020

Description

This PR fixes the tokens values displays within the app, for tokens which report they're decimals value as 0 (zero).

This was previously causing the 0 value to be treated as false, which would have had triggered the 18 decimals value fallback.

Reviewer Note: This needs to be tested with it's server counterpart: JoinColony/colonyServer#95

New stuff

  • getTokenDecimalsWithFallback token util

Changes

  • token client side query now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenItem now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenCard now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenMintDialog now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenMintDialogForm now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenIMoveDialog now uses getTokenDecimalsWithFallback for tokens decimals display
  • TokenIMoveDialogForm now uses getTokenDecimalsWithFallback for tokens decimals display
  • AmountTokens now uses getTokenDecimalsWithFallback for tokens decimals display
  • PayoutsList now uses getTokenDecimalsWithFallback for tokens decimals display
  • TransactionListItem now uses getTokenDecimalsWithFallback for tokens decimals display
  • ColonyInitialFunding now uses getTokenDecimalsWithFallback for tokens decimals display
  • TaskFeedCompletedInfo now uses getTokenDecimalsWithFallback for tokens decimals display
  • TaskFeedEvent now uses getTokenDecimalsWithFallback for tokens decimals display

Screenshots

Before
Screenshot from 2020-04-22 17-50-38

After
Screenshot from 2020-04-22 17-50-55

Resolves #2133

@rdig rdig requested review from ceolson01 and chmanie April 22, 2020 15:08
@rdig rdig self-assigned this Apr 22, 2020
Copy link
Member

@chmanie chmanie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray! Great fix. This looks good to me

* a number, and return that number (even if that number is 0).
* If it's not a number then fallback to the default token decimals value.
*/
export const getTokenDecimalsWithFallback = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the name a bit long (especially because we don't have a getTokenDecimals function. But better too long than too short, I guess!

@rdig rdig merged commit 9b8b2ac into master Apr 23, 2020
@rdig rdig deleted the fix/2133-handle-zero-token-decimals branch April 23, 2020 11:28
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.

Tokens with anything other than 18 decimal places are unusable in the dapp

2 participants