Skip to content

feat: improvement for how we display big and small numbers#25438

Merged
jpuri merged 48 commits intodevelopfrom
permit_value_display_fix
Jul 4, 2024
Merged

feat: improvement for how we display big and small numbers#25438
jpuri merged 48 commits intodevelopfrom
permit_value_display_fix

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented Jun 20, 2024

Description

Improvement in how we display big and small token value on permit signature page.

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2649

Manual testing steps

  1. Go to test DAPP
  2. Submit permit signature request
  3. Check the token value in page displayed

Screenshots/Recordings

Screenshot 2024-06-20 at 5 29 42 PM Screenshot 2024-06-20 at 5 29 34 PM

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.

@jpuri jpuri added confirmation-redesign team-confirmations Push issues to confirmations team labels Jun 20, 2024
@jpuri jpuri requested review from a team as code owners June 20, 2024 12:19
@jpuri jpuri force-pushed the permit_value_display_fix branch from 92b0369 to 8c99c92 Compare June 20, 2024 12:19
@github-actions
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Collaborator

Builds ready [8c99c92]
Page Load Metrics (52 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6910484105
domContentLoaded9231242
load41655284
domInteractive9231242
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 4.14 KiB (0.06%)
  • common: 118 Bytes (0.00%)

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.61%. Comparing base (6557b59) to head (7507aab).
Report is 6 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25438   +/-   ##
========================================
  Coverage    69.61%   69.61%           
========================================
  Files         1364     1364           
  Lines        48189    48199   +10     
  Branches     13297    13299    +2     
========================================
+ Hits         33542    33549    +7     
- Misses       14647    14650    +3     

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

export const DefaultStory = ({ text }) => <ConfirmInfoRowText text={text} />;
DefaultStory.args = {
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
tooltip: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but is it worth a constant for this such as TEXT_MOCK?

}, [exchangeRate, value]);

const { tokenValue, tokenValueMaxPrecision } = useMemo(() => {
const valueBN = new BigNumber(value / Math.pow(10, tokenDecimals));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the same logic we do in the decimals PR, perhaps an applyDecimals util?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A new util for just division does may not be very useful.

);
}
if (isPermit && label === 'value') {
const valueBN = new BigNumber(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but could we split this function up with some local components such as DataFieldNumber?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is more requirement for formatting I will do some refactoring in DataTree in upcoming PRs.

import {
formatAmount,
formatAmountMaxPrecision,
} from '../../../../simulation-details/formatAmount';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could move this to a higher level util but I think this makes sense in this context since we're also a simulation component 👍

const valueBN = new BigNumber(value / Math.pow(10, tokenDecimals));
return {
tokenValue: formatAmount('en-US', valueBN),
tokenValueMaxPrecision: formatAmountMaxPrecision('en-US', valueBN),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

similar to the existing simulation UI, I think we should support varying locales rather than only en-US

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Base automatically changed from permit_token_decimal_fix to develop July 2, 2024 14:39
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jul 2, 2024

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [7507aab]
Page Load Metrics (200 ± 219 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint713761397134
domContentLoaded1196412512
load542182200456219
domInteractive1196412512
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.8 KiB (0.03%)
  • common: 0 Bytes (0.00%)

@jpuri jpuri merged commit 8adc3cc into develop Jul 4, 2024
@jpuri jpuri deleted the permit_value_display_fix branch July 4, 2024 00:03
@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2024
@metamaskbot metamaskbot added the release-12.2.0 Issue or pull request that will be included in release 12.2.0 label Jul 4, 2024
@digiwand
Copy link
Copy Markdown
Contributor

PR fix error on digits > 15 digits: #25751
Issue to fix loss of precision for values greater than Number.MAX_SAFE_INTEGER: #25755

@digiwand
Copy link
Copy Markdown
Contributor

related cherry-pick PR: #25720

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

confirmation-redesign release-12.2.0 Issue or pull request that will be included in release 12.2.0 team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants