Skip to content
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

Merged
merged 1 commit into from
Jan 6, 2020
Merged

Fixes notification amount #4300

merged 1 commit into from
Jan 6, 2020

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Jan 3, 2020

Resolves brave/brave-browser#7562

Submitter Checklist:

Test Plan:

  • covered with unit tests

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@NejcZdovc NejcZdovc added this to the 1.5.x - Nightly milestone Jan 3, 2020
@NejcZdovc NejcZdovc requested a review from a team January 3, 2020 09:18
@NejcZdovc NejcZdovc self-assigned this Jan 3, 2020
@NejcZdovc NejcZdovc force-pushed the notification-amount branch from 03cd66d to aadf661 Compare January 3, 2020 09:20
export const handleContributionAmount = (amount: string) => {
let result = '0.0'
const amountSplit = amount.split('.')
if (amountSplit && amountSplit[0].length > 18) {
Copy link
Collaborator

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

Copy link
Contributor Author

@NejcZdovc NejcZdovc Jan 3, 2020

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

Copy link
Collaborator

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)
Copy link
Collaborator

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?

Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@NejcZdovc NejcZdovc force-pushed the notification-amount branch from aadf661 to 8dbeee6 Compare January 6, 2020 19:37
@tmancey tmancey self-requested a review January 6, 2020 19:57
@NejcZdovc NejcZdovc merged commit f6f7d0a into master Jan 6, 2020
@NejcZdovc NejcZdovc deleted the notification-amount branch January 6, 2020 23:19
brave-builds pushed a commit that referenced this pull request Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle migration path for old notifications for AC
2 participants