Skip to content

fix: hide testnet amounts if user opt out in the settings #25167

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

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Jun 10, 2024

Description

This PR aims to hide testnet fiat values if user opt out in the settings.

Open in GitHub Codespaces

Related issues

Manual testing steps

  1. Change current network to any testnet
  2. Go to setting, turn on "Show conversion on test networks"
  3. Try simple send - see fiat values displayed in simulations
  4. Go to setting, turn off "Show conversion on test networks"
  5. Try simple send - see no fiat values displayed in simulations
  6. Change current network to mainnet or any other network which is not testnet
  7. Try simple send - see fiat values displayed in simulations

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.

@OGPoyraz OGPoyraz requested review from a team as code owners June 10, 2024 10:17
@OGPoyraz OGPoyraz added the team-confirmations Push issues to confirmations team label Jun 10, 2024
@OGPoyraz OGPoyraz changed the title Hide testnet amounts if user opt out in the settings fix: hide testnet amounts if user opt out in the settings Jun 10, 2024
@OGPoyraz OGPoyraz linked an issue Jun 10, 2024 that may be closed by this pull request
@metamaskbot
Copy link
Collaborator

Builds ready [cefe856]
Page Load Metrics (272 ± 287 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint774051156933
domContentLoaded109319189
load472155272598287
domInteractive109318189
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1 KiB (0.01%)
  • common: 90 Bytes (0.00%)

Copy link

codecov bot commented Jun 10, 2024

Codecov Report

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

Project coverage is 64.89%. Comparing base (533a483) to head (9852b71).
Report is 13 commits behind head on develop.

Files Patch % Lines
...ons/components/simulation-details/fiat-display.tsx 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25167      +/-   ##
===========================================
+ Coverage    64.88%   64.89%   +0.01%     
===========================================
  Files         1388     1389       +1     
  Lines        55091    55103      +12     
  Branches     14471    14475       +4     
===========================================
+ Hits         35743    35754      +11     
- Misses       19348    19349       +1     

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

jpuri
jpuri previously approved these changes Jun 10, 2024
const mockStateWithTestnet = merge({}, mockState, {
metamask: {
providerConfig: {
chainId: CHAIN_IDS.SEPOLIA,
Copy link
Member Author

Choose a reason for hiding this comment

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

If we are going with this approach, I believe it's crucial to set some state props like this for the branch of these tests.

Even if mockState is set as using Goerli chain id which is fine for this test, I believe we should still set the stage for only our test. This is the reason of I am creating mockStateWithTestnet

Copy link
Member

Choose a reason for hiding this comment

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

I think extending the default state in the unit tests is a standard pattern.

We also could have defined a CHAIN_ID_MOCK constant using the mockState but this is great also.

@metamaskbot
Copy link
Collaborator

Builds ready [588c8d1]
Page Load Metrics (55 ± 6 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6911686136
domContentLoaded9161221
load439155126
domInteractive9161221
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1 KiB (0.01%)
  • common: 90 Bytes (0.00%)

*/
export const useHideFiatForTestnet = (providedChainId?: Hex): boolean => {
const showFiatInTestnets = useSelector(getShowFiatInTestnets);
const chainId = providedChainId ?? useSelector(getCurrentChainId);
Copy link
Member

Choose a reason for hiding this comment

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

We always have to call useSelector even if we don't use the value, since it's a hook.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

const mockStateWithTestnet = merge({}, mockState, {
metamask: {
providerConfig: {
chainId: CHAIN_IDS.SEPOLIA,
Copy link
Member

Choose a reason for hiding this comment

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

I think extending the default state in the unit tests is a standard pattern.

We also could have defined a CHAIN_ID_MOCK constant using the mockState but this is great also.

@metamaskbot
Copy link
Collaborator

Builds ready [9852b71]
Page Load Metrics (133 ± 165 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7011085115
domContentLoaded9241242
load411631133344165
domInteractive9241242
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.01 KiB (0.01%)
  • common: 90 Bytes (0.00%)

@OGPoyraz OGPoyraz merged commit 52a65bc into develop Jun 25, 2024
74 checks passed
@OGPoyraz OGPoyraz deleted the 9906-hide-amount-in-simulations-for-testnets-if-its-opted-out-by-user branch June 25, 2024 13:06
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

Hide amount in simulations for testnets if it's opted out by user
5 participants