-
Notifications
You must be signed in to change notification settings - Fork 574
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
fix: cap input quantity, truncate rfq card qty #2344
base: master
Are you sure you want to change the base?
Conversation
(auto-deploy) A deployment has been created for this Pull Request Preview linksAs part of the code review process, please ensure that you test against the following
PerformancePlease ensure that this PR does not degrade the performance of the UI. We should maintain a performance score of 95+. |
@@ -72,7 +76,7 @@ const quantity$ = prepareStream$(_quantity$, "").pipe( | |||
const numValue = Math.trunc(Math.abs(parseQuantity(quantity))) |
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.
suggestion(/later): I would put this whole thing in the util function, or create a new one, and could perhaps simplify If parseQuantity()
returns NaN
, which it can, then we really catch it as early as possible.
Also, a near dup of code in formatNotional
, but that has no Math.trunc()
..
@@ -216,8 +217,10 @@ export const [usePrice, price$] = bind( | |||
|
|||
const truncated = formatter(inputQuantityAsNumber) | |||
|
|||
const value = Number( | |||
truncated.replace(filterRegExp, "").replace(decimalRegExp, "."), | |||
const value = applyMaximum( |
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.
suggestion re above: some could be extracted to util module (e.g. decimalRegExp
is a dup)
@@ -230,3 +230,8 @@ export const parseQuantity = (rawValue: string): number => | |||
Number(rawValue.replace(filterRegExp, "").replace(decimalRegExp, ".")) | |||
|
|||
export const adjustUserCreditQuantity = (value: number): number => value * 1000 | |||
|
|||
const MAX_INPUT_VALUE = 100000000 |
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.
minor: 100 mill, but hard to read, I always use underscores ..
No description provided.