safe-react icon indicating copy to clipboard operation
safe-react copied to clipboard

Library for numbers formatting

Open lukasschor opened this issue 4 years ago • 5 comments

We have an internal guideline of how balance numbers should be formatted

https://github.com/gnosis/safe/wiki/How-to-format-amounts

It is beneficial if these formatting guidelines are implemented consistently throughout the interface but also in Safe Apps built by external developers.

We should expose this as a library to external developers so they can easily implement these number formatting rules.

lukasschor avatar Jun 19 '20 09:06 lukasschor

So basically what we need to do is include this to safe apps sdk: https://github.com/gnosis/safe-react/blob/development/src/logic/tokens/utils/formatAmount.ts

mmv08 avatar Jun 19 '20 10:06 mmv08

Maybe this could also be part of safe-react-components? Would be cool to have a component that turns an amount + token contract address into a fully formatted value, maybe even with the right token icon / ticker / name. Not sure if that's possible though.

lukasschor avatar Aug 19 '20 11:08 lukasschor

@lukasschor I wouldn't include it in the components library, because in this case the developer would have to use react in order to reuse our formatting logic and IMO number formatting is a framework-agnostic thing. Keeping in mind that we want to extend the sdk with helper methods (querying the tx, etc) I think adding an util function for formatting numbers there is a good idea.

mmv08 avatar Aug 19 '20 21:08 mmv08

Oh, sorry I read your message wrong, I didn't spot "also" in "this could also be part of" 🤦‍♂️

Actually I meant that I wouldn't include the formatting logic ONLY in the component library. The component you described is a good idea and can be handy

mmv08 avatar Aug 19 '20 21:08 mmv08

@lukasschor , the app view in case of big amount in the balance from prod Mainnet: safe - 0xf661107395729AFc8A027B976337B859A0847D8e Macbook Chrome image

liliya-soroka avatar Sep 07 '20 10:09 liliya-soroka