-
Notifications
You must be signed in to change notification settings - Fork 111
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
Amounts displaying refactoring #1907
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
CLA Assistant Lite All Contributors have signed the CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @shoom3301 , great job!
-
However, we should think what to display when users trade with tiny amounts now:
-
And it would be also great to apply these changes to the Price field onn the Limit orders page:
-
There are no changes to amounts on an order confirm screen. Is this OK?
-
I noticed that 4 decimals are added to an amount when go to the Limit orders page and back to the Swap page:
Thanks!
Why 4 decimals? The UI should show you exactly what you sign. No more, no less :) This means:
|
Agree, price should have good precision, at least if it is a small amount. Maybe is a matter of having XX significant digits? |
Yes we should be consistent |
… fix/139 � Conflicts: � src/cow-react/modules/trade/utils/tokenViewAmount.ts
@elena-zh thank you! |
Hey @shoom3301 , great job!
Is it possible to use 4-decimals rounding for amounts that >1, and use the current logic (up to 18 decimals) when amounts are less than 1?
Thanks! |
@elena-zh thanks, fixed!
It could create other problems, so I would like to think about it in another task |
Some edge cases that I see now: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more comments. I'll eventually reach 0 :D
src/cow-react/common/pure/CurrencyInputPanel/CurrencyPreview.tsx
Outdated
Show resolved
Hide resolved
src/cow-react/modules/limitOrders/pure/ReceiptModal/FilledField.tsx
Outdated
Show resolved
Hide resolved
Hey @shoom3301 , amazing job! All issues I reported are fixed. Could you please take a look into this issue? |
@elena-zh thanks! Fixed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved!!!
@SocketSecurity ignore [email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is approved, no more comments \o/
Now testing the app, a few comments :D
ru
language:
Shouldn't the thousands separator apply also to the input numbers?
pt-br
language
I haven't seen all comments but I assume Elena has mentioned this.
The decimal separator is different in the display fields from the input field.
To be fair, this has been like this since the start.
Are we keeping this behaviour?
ar
language (arabic)
Hehe, this is funny.
Not sure we want to do something about this, but anyway.
With this language we can notice that the decimals part is not respecting the language locale.
Hey @alfetopito
I think it was discussed in https://cowservices.slack.com/archives/C0361CDG8GP/p1675354573189409?thread_ts=1675337080.573789&cid=C0361CDG8GP : there is a separate task for this #213 , and it will be addressed (one day) in a separate PR. |
Thanks @alfetopito ! |
Summary
Fixes #139 #137
How does it work
Docs: https://github.com/cowprotocol/cowswap/blob/fix/139/src/cow-react/utils/amountFormat/README.md
Implementation: https://github.com/cowprotocol/cowswap/blob/fix/139/src/cow-react/utils/amountFormat/index.ts#L18
Test cases: https://github.com/cowprotocol/cowswap/blob/fix/139/src/cow-react/utils/amountFormat/index.test.ts
Testing
localStorage.setItem('amountsRefactoring', '1')
- run this in the browser console and reload the page to highlight places with the refactored amountsWhat changed
@cowprotocol/cow-js
formatSmartAmount
,formatSmart
,formatSmartLocaleAware
,formatMax
were replaced by<TokenAmount>
component<FiatAmount>
componentformatAmountInput
function)Affected area
BigNumber.js
and because of it we convert amounts using .toNumber() cast