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

feat: Display advanced section within confirmation by default for some users #25687

Merged
merged 19 commits into from
Jul 17, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Jul 4, 2024

Description

Display advanced details section within confirmation by default for users that have edit nonce or showing hex data on. The PR includes e2e tests for these changes.

This PR also changes the copy for the nonce toggle and includes minor refactors to the gas fees logic.

Open in GitHub Codespaces

Related issues

Fixes: #2737

Manual testing steps

  1. Enable nonce editing in the settings
  2. Deploy an erc721 contract in the test dApp
  3. Trigger an erc721 mint in the test dApp
  4. The confirmation should come up with the advanced details toggled on

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.

@pedronfigueiredo pedronfigueiredo added confirmation-redesign team-confirmations Push issues to confirmations team labels Jul 4, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Jul 4, 2024
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners July 4, 2024 14:20
Copy link
Contributor

github-actions bot commented Jul 4, 2024

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.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/2737 branch 7 times, most recently from bf3b4da to 90685dd Compare July 5, 2024 10:43
@@ -94,6 +94,7 @@ export default class PreferencesController {
featureNotificationsEnabled: false,
showTokenAutodetectModal: null,
showNftAutodetectModal: null, // null because we want to show the modal only the first time
isConfirmationAdvancedDetailsOpen: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

isConfirmationAdvancedDetailsOpen sounds more like app state then preference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an app state though, we substituted useState with this background preference property for expanding and collapsing advanced details...

Copy link
Member

Choose a reason for hiding this comment

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

Even though it's triggered via a toggle, it is still a mechanism to indicate their preference which we could theoretically use elsewhere.

So maybe showConfirmationAdvancedDetails?

const advancedDetailsObject = useMemo(
() => ({ showAdvancedDetails, setShowAdvancedDetails }),
[showAdvancedDetails, setShowAdvancedDetails],
);
Copy link
Contributor

Choose a reason for hiding this comment

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

useMemo here does not looks very useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The useMemo is primarily used for maintaining referential equality and potentially preventing unnecessary re-renders in child components.

Copy link
Member

@matthewwalsh0 matthewwalsh0 Jul 10, 2024

Choose a reason for hiding this comment

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

I think the container for the properties typically shouldn't matter, as any dependent component or hook would be using the values within the object as dependencies, rather than the container itself.

require('../../../../../../store/actions').setConfirmationAdvancedDetailsOpen;

getConfirmationAdvancedDetailsOpenMock.mockReturnValue(false);
setConfirmationAdvancedDetailsOpenMock.mockReturnValue(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

spyOn may also be used here for mocking.

size={ButtonIconSize.Sm}
// to reset the button padding
style={{ marginLeft: '-4px' }}
data-testid="edit-nonce-icon"
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope this left margin does not effect existing use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change in the name of consistency with the designs, so I think it's safe.

'.settings-page__header__title-container__close-button',
);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

jpuri
jpuri previously approved these changes Jul 9, 2024
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.

Great work 👍
I left some small feedbacks

Copy link

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 14 lines in your changes missing coverage. Please review.

Project coverage is 69.75%. Comparing base (ad5bd9f) to head (5cf58d4).

Files Patch % Lines
...firm/info/hooks/useKnownMethodDataInTransaction.ts 0.00% 9 Missing ⚠️
ui/store/actions.ts 0.00% 2 Missing ⚠️
ui/helpers/constants/settings.js 0.00% 1 Missing ⚠️
...rmations/components/confirm/header/header-info.tsx 80.00% 1 Missing ⚠️
.../info/shared/gas-fees-section/gas-fees-section.tsx 66.67% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25687      +/-   ##
===========================================
- Coverage    69.76%   69.75%   -0.01%     
===========================================
  Files         1398     1400       +2     
  Lines        49171    49199      +28     
  Branches     13574    13578       +4     
===========================================
+ Hits         34303    34318      +15     
- Misses       14868    14881      +13     

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

@pedronfigueiredo pedronfigueiredo merged commit 8c519db into develop Jul 17, 2024
78 of 79 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/2737 branch July 17, 2024 10:22
@github-actions github-actions bot locked and limited conversation to collaborators Jul 17, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 17, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [5cf58d4]
Page Load Metrics (65 ± 7 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6312394157
domContentLoaded95024136
load409965157
domInteractive95024136
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 886 Bytes (0.03%)
  • ui: 402 Bytes (0.01%)
  • common: 121 Bytes (0.00%)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmation-redesign release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants