-
Notifications
You must be signed in to change notification settings - Fork 906
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
Fixes notification amount #4300
Conversation
03cd66d
to
aadf661
Compare
export const handleContributionAmount = (amount: string) => { | ||
let result = '0.0' | ||
const amountSplit = amount.split('.') | ||
if (amountSplit && amountSplit[0].length > 18) { |
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.
>= 19
would be easier to read as probi are always 19 characters
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.
>= 19
and > 18
both tell you that we are looking for number 19. Personally I like to avoid >=
as it's really easy to miss when reading through stuff
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.
Easier to read if the magic number is replaced
let result = '0.0' | ||
const amountSplit = amount.split('.') | ||
if (amountSplit && amountSplit[0].length > 18) { | ||
const result = new BigNumber(amount).dividedBy('1e18').toFixed(1, BigNumber.ROUND_DOWN) |
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.
Monetary amounts are normally rounded up, is this correct to round down?
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.
Based upon being correct, see comment below for test
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.
done
aadf661
to
8dbeee6
Compare
Resolves brave/brave-browser#7562
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.