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: Permit value decimal & refactor: Create reusable ConfirmInfoRowTextTokenUnits component #26105

Merged
merged 5 commits into from
Jul 25, 2024

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Jul 24, 2024

Description

No UI/UX changes

Create reusable ConfirmInfoRowTextTokenUnits

This also fixes the missing token decimals we had on the Permit value

notes:

  • there is an outstanding bug ticket to redesign the display length of the amount to max 15 characters. This will be handled separately
  • there's also a precision issue being handle separately

Open in GitHub Codespaces

Related issues

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

Manual testing steps

  1. Create a redesign Permit transaction
  2. Observe amount displays as expected

Screenshots/Recordings

Before

After

CleanShot 2024-07-25 at 03 35 08

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.

@digiwand digiwand requested review from a team as code owners July 24, 2024 20:48
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 24, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The refactor and redesign of the confirmation token amount feature introduces new components and updates existing ones to improve functionality and maintainability.

  • New Component: Added ui/components/app/confirm/info/row/text-token.tsx to format and display token amounts with precision.
  • Storybook Addition: Introduced ui/components/app/confirm/info/row/text-token.stories.tsx for visual testing of the ConfirmInfoRowTextToken component.
  • Unit Tests: Added ui/components/app/confirm/info/row/text-token.test.tsx to ensure correct rendering and formatting of token values.
  • Refactor: Updated ui/pages/confirmations/components/confirm/info/typed-sign/permit-simulation/permit-simulation.tsx to use calcTokenAmount for consistent token calculations.
  • Code Simplification: Modified ui/pages/confirmations/components/confirm/row/dataTree.tsx to replace custom formatting with the new ConfirmInfoRowTextToken component.

6 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The refactor and redesign of the confirmation token amount feature primarily involve renaming components and updating their usage to improve clarity and maintainability.

  • Component Renaming: ui/components/app/confirm/info/row/text-token.tsx renamed to text-token-units.tsx to better reflect its functionality.
  • Export Update: Modified ui/components/app/confirm/info/row/index.ts to export text-token-units instead of text-token.
  • Story and Test Updates: Renamed text-token.stories.tsx and text-token.test.tsx to text-token-units.stories.tsx and text-token-units.test.tsx respectively, aligning with the new component name.
  • DataTree Component Update: Adjusted ui/pages/confirmations/components/confirm/row/dataTree.tsx to use ConfirmInfoRowTextTokenUnits for better naming consistency.

5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@digiwand digiwand changed the title Refactor redesign conf token amount refactor: Create reusable ConfirmInfoRowTextTokenUnits component Jul 24, 2024
Copy link

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

The refactor introduces a reusable ConfirmInfoRowTextTokenUnits component to streamline token amount display across the application.

  • New Component: Added ConfirmInfoRowTextTokenUnits in ui/components/app/confirm/info/row/text-token-units.tsx.
  • Test Enhancements: Updated shared/lib/transaction-controller-utils.test.js to include precision handling tests.
  • Storybook Addition: Created invalid-custom-network-alert.stories.tsx for visual testing of InvalidCustomNetworkAlert.
  • E2E Test Reliability: Improved test/e2e/accounts/create-snap-account.spec.ts by adding wait conditions for popup handling.
  • UI Consistency: Modified ui/pages/onboarding-flow/metametrics/index.scss to maintain consistent button width across screen sizes.

12 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@metamaskbot
Copy link
Collaborator

Builds ready [d1f422d]
Page Load Metrics (171 ± 196 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint693041134823
domContentLoaded1097292311
load431945171409196
domInteractive1097292311
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.17 KiB (0.02%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.67%. Comparing base (d6b7829) to head (d1f422d).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #26105      +/-   ##
===========================================
- Coverage    69.67%   69.67%   -0.00%     
===========================================
  Files         1405     1406       +1     
  Lines        49733    49731       -2     
  Branches     13751    13751              
===========================================
- Hits         34651    34649       -2     
  Misses       15082    15082              

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

@digiwand digiwand merged commit c204377 into develop Jul 25, 2024
76 checks passed
@digiwand digiwand deleted the refactor-redesign-conf-token-amount branch July 25, 2024 10:44
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 25, 2024
@digiwand digiwand added release-12.1.0 Issue or pull request that will be included in release 12.1.0 rc-cherry-picked and removed release-12.3.0 Issue or pull request that will be included in release 12.3.0 labels Aug 19, 2024
@digiwand digiwand changed the title refactor: Create reusable ConfirmInfoRowTextTokenUnits component fix: Permit value decimal & refactor: Create reusable ConfirmInfoRowTextTokenUnits component Aug 20, 2024
// FIXME - Precision may be lost for large values when using formatAmount
/** @see {@link https://github.com/MetaMask/metamask-extension/issues/25755} */
const tokenValue = formatAmount('en-US', resultBn);
const tokenValueMaxPrecision = formatAmountMaxPrecision('en-US', valueBN);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

valueBn should have been resultBn here. This caused the token decimal issue.

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.

4 participants