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: add alerts for redesigned contract interaction confirmation #25174

Merged
merged 55 commits into from
Jun 21, 2024

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Jun 10, 2024

Description

Migrate the existing transaction alerts for contract interaction transactions to the new alert system.

In addition:

  • Update the useCurrentConfirmation hook to simplify the logic and use deep equal selectors to automatically update the confirmation if the underlying data changes.
  • Update the alert system to recursively close all the alert modals when clicking an action button.

Open in GitHub Codespaces

Related issues

Fixes: #23953

Manual testing steps

E2E tests per alert will be created in a subsequent ticket, so testing each alert now is not needed.

Instead we could just verify that the existing signature confirmations are unaffected and no transaction alerts are shown.

Screenshots/Recordings

Before

Before - Gas Estimation Failed Before - Insufficient Balance Before - Submit In Progress Before - Pending Transactions Before - Gas Fee Low Before - Low Gas Before - No Gas Price Before - Blockaid

After

After - Gas Estimation Failed After - Insufficient Balance After - Submit In Progress After - Pending Transactions After - Gas Fee Low After - Low Gas After - No Gas Price After - Blockaid

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.

@matthewwalsh0 matthewwalsh0 added the team-confirmations Push issues to confirmations team label Jun 10, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [04229ba]
Page Load Metrics (51 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6311084105
domContentLoaded9271242
load42695184
domInteractive9271242

@metamaskbot
Copy link
Collaborator

Builds ready [500e1ba]
Page Load Metrics (47 ± 4 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint58997895
domContentLoaded8261142
load39724784
domInteractive8251142

OGPoyraz
OGPoyraz previously approved these changes Jun 20, 2024
export const selectUnapprovedMessage = createDeepEqualSelector(
internalSelectUnapprovedMessage,
(message) => message,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

These new selectors aren't really specific to confirmations, since they are simply querying the signature controller state and using createSelector and createDeepEqualSelector to minimise re-renders. All the existing message selectors were legacy and mixed with transactions.

On a broader level, I worry that creating separate confirmation specific selectors might restrict their re-usability since all the existing selectors are defined at the top level in ui/selectors, so arguably any truly confirmation specific ones could also sit in ui/selectors/confirmation.ts?

isSIWE,
transactionMetadata,
signatureMessage,
]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we are doing all of logic like iterating over confirmations outside useMemo.

Copy link
Member Author

@matthewwalsh0 matthewwalsh0 Jun 20, 2024

Choose a reason for hiding this comment

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

That's correct, the performance cost of any logic here is negligible so the purpose of the useMemo is to only return a fresh object reference when the underlying data has changed, to prevent all the dependent components re-rendering unnecessarily.

Any iteration over the controller state is encapsulated within the selectors, which is a cleaner separation of concerns, plus we can benefit from deep equal selectors that also only return new object references when the specifc controller state we care about has actually changed.

);
};

export default ConfirmAlerts;
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 Jun 20, 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.

Changes look good 👍

@sleepytanya
Copy link
Contributor

Sign alerts look good:

signAlerts.mov

New Sign Permit is not detected as 'deceptive' - I'm not sure if it is expected:

signPermit.mov

@metamaskbot
Copy link
Collaborator

Builds ready [e2138dc]
Page Load Metrics (44 ± 3 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint61917573
domContentLoaded9201021
load38624473
domInteractive9201021
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 20.87 KiB (0.30%)
  • common: 3.4 KiB (0.05%)

@matthewwalsh0 matthewwalsh0 merged commit 7c87e58 into develop Jun 21, 2024
74 checks passed
@matthewwalsh0 matthewwalsh0 deleted the feat/redesign-transaction-alerts branch June 21, 2024 16:26
@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 21, 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.

Migrate existing alerts to new contract interaction confirmation
7 participants