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

fix: change in number format to fix loss of precision for very big values #25968

Merged
merged 6 commits into from
Jul 26, 2024

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Jul 19, 2024

Description

fix loss of precision for very big values in signature simulations

Related issues

Fixes: #25755

Manual testing steps

  1. Create a permit request of arbitrary high value like 115792089237316195423570985008687907853269984665640564039457584007913129639935
  2. As you submit the request ensure that precision is not lost

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Jul 19, 2024
@jpuri jpuri force-pushed the numberformat_fix branch from 694ecf8 to d5bcd33 Compare July 22, 2024 07:19
@jpuri jpuri changed the title Change in number format to fix loss of precision for very big values fix: change in number format to fix loss of precision for very big values Jul 22, 2024
@jpuri jpuri requested a review from dbrans July 22, 2024 07:20
@metamaskbot
Copy link
Collaborator

Builds ready [d5bcd33]
Page Load Metrics (145 ± 159 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint761631032211
domContentLoaded8101312211
load381585145331159
domInteractive8101312211
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 55 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.94%. Comparing base (51410b2) to head (115a1b2).
Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25968   +/-   ##
========================================
  Coverage    69.94%   69.94%           
========================================
  Files         1409     1409           
  Lines        49795    49802    +7     
  Branches     13773    13775    +2     
========================================
+ Hits         34826    34833    +7     
  Misses       14969    14969           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jpuri jpuri force-pushed the numberformat_fix branch from 38b1c82 to 23fa295 Compare July 25, 2024 12:49
@metamaskbot
Copy link
Collaborator

Builds ready [3f21bca]
Page Load Metrics (218 ± 223 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint753691106230
domContentLoaded96728168
load421713218464223
domInteractive96728168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 88 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

// string is valid parameter for format function
// for some reason it gives TS issue
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format#number
amount.toFixed(0) as unknown as number,
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome find!

In that case, we don't need the if (maximumFractionDigits === 0) { above... we can have the same code path for all amounts here.

@jpuri jpuri requested a review from dbrans July 25, 2024 15:42
@jpuri jpuri marked this pull request as ready for review July 25, 2024 15:45
@jpuri jpuri requested a review from a team as a code owner July 25, 2024 15:45
Copy link

sonarcloud bot commented Jul 25, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [115a1b2]
Page Load Metrics (506 ± 358 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint792771194220
domContentLoaded116135136
load541889506745358
domInteractive116135136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 31 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

Great fix!

@jpuri jpuri merged commit 30dce33 into develop Jul 26, 2024
76 checks passed
@jpuri jpuri deleted the numberformat_fix branch July 26, 2024 13:11
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 2024
@metamaskbot metamaskbot added the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Jul 26, 2024
@digiwand digiwand added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Aug 19, 2024
@digiwand digiwand removed the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Aug 19, 2024
@digiwand
Copy link
Contributor

Cherry-pick to V12.1.0 #26496

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
rc-cherry-picked release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Precision is lost displaying Permit value in simulation and data tree
5 participants