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: number formatting on swap + send tx detail #26029

Merged
merged 17 commits into from
Jul 25, 2024

Conversation

bergeron
Copy link
Contributor

@bergeron bergeron commented Jul 22, 2024

Description

Fixes an issue when rendering details for a swap + send transaction.

Token amounts less than 1 with >= 6 leading zeroes were formatted in scientific notation.

toString and toPrecision both render scientific in that case, so this PR uses toFixed instead.

Open in GitHub Codespaces

Related issues

Fixes: #25876

Manual testing steps

  1. Do a swap + send transaction with a source and/or destination amount < .000001
  2. Click activity tab
  3. Click on the transaction
  4. Source and destination amounts should not be in scientific notation

Screenshots/Recordings

Before

Screenshot 2024-07-22 at 4 09 49 PM

After

Screenshot 2024-07-22 at 4 14 20 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.

@bergeron bergeron requested a review from a team as a code owner July 22, 2024 23:15
@bergeron bergeron changed the title fix number formatting on swap + send tx detail fix: number formatting on swap + send tx detail Jul 22, 2024
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.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

@bergeron bergeron force-pushed the brian/swap-send-tx-detail-number-formatting branch from 7a10056 to c97c4b3 Compare July 23, 2024 02:22
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)

This pull request addresses the issue of scientific notation in swap and send transaction details for token amounts less than 1 with six or more leading zeroes.

  • shared/lib/transaction-controller-utils.test.js: Enhanced precision handling for token amounts in swap transactions, ensuring getSwapsTokensReceivedFromTxMeta respects precision arguments.
  • ui/pages/swaps/swaps.util.ts: Updated formatSwapsValueForDisplay to handle small values without scientific notation.
  • ui/components/app/transaction-breakdown/transaction-breakdown.test.js: Added test cases to ensure TransactionBreakdown correctly renders small token amounts without scientific notation.

These changes ensure accurate rendering of transaction details, especially for small token amounts.

1 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)

This pull request addresses the issue of scientific notation in swap and send transaction details for token amounts less than 1 with six or more leading zeroes.

  • shared/lib/transaction-controller-utils.test.js: Enhanced precision handling for token amounts in swap transactions, ensuring getSwapsTokensReceivedFromTxMeta respects precision arguments.
  • ui/pages/swaps/swaps.util.ts: Updated formatSwapsValueForDisplay to handle small values without scientific notation.
  • ui/components/app/transaction-breakdown/transaction-breakdown.test.js: Added test cases to ensure TransactionBreakdown correctly renders small token amounts without scientific notation.

These changes ensure accurate rendering of transaction details, especially for small token amounts.

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

micaelae
micaelae previously approved these changes Jul 23, 2024
BZahory
BZahory previously approved these changes Jul 23, 2024
@bergeron bergeron dismissed stale reviews from micaelae and BZahory via fe995e1 July 24, 2024 14:47
greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

greptile-apps[bot]

This comment was marked as spam.

Copy link

sonarcloud bot commented Jul 24, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [5b0eb3d]
Page Load Metrics (163 ± 196 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722991094723
domContentLoaded96828168
load381939163408196
domInteractive96828168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 45 Bytes (0.00%)
  • common: 47 Bytes (0.00%)

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.67%. Comparing base (f861486) to head (5b0eb3d).

Files Patch % Lines
shared/lib/transactions-controller-utils.js 88.89% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26029   +/-   ##
========================================
  Coverage    69.67%   69.67%           
========================================
  Files         1405     1405           
  Lines        49728    49733    +5     
  Branches     13748    13751    +3     
========================================
+ Hits         34646    34651    +5     
  Misses       15082    15082           

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

@bergeron bergeron merged commit 6c41556 into develop Jul 25, 2024
76 checks passed
@bergeron bergeron deleted the brian/swap-send-tx-detail-number-formatting branch July 25, 2024 01:54
@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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: On the Transaction details screen, amounts are presented in scientific notation
4 participants