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

refactor: memoize fetchErc20Decimals, relocate to utils/token, and apply to other instances #27088

Merged
merged 21 commits into from
Sep 19, 2024

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Sep 12, 2024

Description

  • move fetchErc20Decimals method to utils/token
  • use fetchErc20Decimals for other instances calling getTokenStandardAndDetails. This will set decimals to 18 if no decimals were retrieved in the response. Previously, it used 0 instead of 18 in these cases.
  • memoize method to avoid making additional requests for the same token - performance improvement
  • create tests for memorized fetchErc20Decimals method

Open in GitHub Codespaces

Related issues

Fixes: #24374

Manual testing steps

  1. Test token values and fiat conversions on confirmation pages

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.

@github-actions github-actions bot added the team-confirmations Push issues to confirmations team label Sep 12, 2024
@digiwand digiwand changed the title refactor: mv fetchErc20Decimals to utils/token refactor: memoize fetchErc20Decimals, relocate to utils/token, and apply to other instances Sep 12, 2024
@digiwand digiwand marked this pull request as ready for review September 12, 2024 13:58
@digiwand digiwand requested a review from a team as a code owner September 12, 2024 13:58
@metamaskbot
Copy link
Collaborator

Builds ready [dba0ba3]
Page Load Metrics (1681 ± 89 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint17721001616376180
domContentLoaded13992090165917885
load14402102168118589
domInteractive235732105
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.07 KiB (0.01%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [5602fd9]
Page Load Metrics (1702 ± 110 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22022811611385185
domContentLoaded144422021687221106
load145222881702230110
domInteractive147133147
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.07 KiB (0.01%)
  • common: 0 Bytes (0.00%)

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.95%. Comparing base (9459903) to head (a7c315d).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #27088      +/-   ##
===========================================
- Coverage    69.95%   69.95%   -0.00%     
===========================================
  Files         1441     1443       +2     
  Lines        50099    50095       -4     
  Branches     14007    14005       -2     
===========================================
- Hits         35046    35043       -3     
+ Misses       15053    15052       -1     

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

matthewwalsh0
matthewwalsh0 previously approved these changes Sep 14, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Minor, given there is very little in index.ts currently, do we warrant this level of modularity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

questionable, so updated this to share ui/pages/confirmations/utils/token.ts

@metamaskbot
Copy link
Collaborator

Builds ready [a7c315d]
Page Load Metrics (1545 ± 75 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint13461975155615976
domContentLoaded13391922152914871
load13471931154515675
domInteractive14175403617
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 491 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

matthewwalsh0
matthewwalsh0 previously approved these changes Sep 17, 2024
@digiwand
Copy link
Contributor Author

oops, accidentally merged a commit. Reverted after. May I get a reapproval please? @matthewwalsh0

Copy link

@metamaskbot
Copy link
Collaborator

Builds ready [99cfb20]
Page Load Metrics (1895 ± 107 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint24126401501734353
domContentLoaded161326131866224107
load162626201895222107
domInteractive196038105
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 491 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

👍

@digiwand digiwand merged commit 88664bb into develop Sep 19, 2024
78 checks passed
@digiwand digiwand deleted the refactor-token-decimals-fetch-logic-and-memoize branch September 19, 2024 07:55
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 19, 2024
@metamaskbot metamaskbot added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fetchErc20Decimals should not use getTokenStandardAndDetails
4 participants