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

chore: centralize redesigned confirmation decision logic #28445

Conversation

cryptotavares
Copy link
Contributor

@cryptotavares cryptotavares commented Nov 13, 2024

Description

This PR centralizes the redesigned confirmation decision logic to improve code organization and reduce duplication across the codebase. Currently, redesign confirmation decision logic is scattered across multiple files, making it harder to maintain and more prone to inconsistencies.

Motivation

The existing implementation has several issues:

  1. Duplicate logic for handling confirmation decisions across different transaction types
  2. Prevent inconsistent handling of redesigned confirmation flows

Key changes:

  • Move supported redesigned confirmation decision logic to the shared dir (to be used both in the ui and app bundles)
  • Updated signature metrics tracking to support developer mode enabled

Types of changes:

  • Code style update (changes that do not affect the meaning of the code)

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Ensure that when either the experimental confirmations redesign toggle, developer option confirmations redesign toggle or the env ENABLE_CONFIRMATIONS_REDESIGN is enabled the we are presenting the new redesign confirmations.

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.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Nov 13, 2024
Copy link

sentry-io bot commented Nov 13, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: app/scripts/lib/createRPCMethodTrackingMiddleware.js

Function Unhandled Issue
finalizeSignatureFragment Error: Event fragment with id signature-911707255 does not exist. /sc...
Event Count: 1 Affected Users: 0
📄 File: app/scripts/lib/transaction/metrics.ts (Click to Expand)
Function Unhandled Issue
buildEventFragmentProperties TypeError: null has no properties /background.html
Event Count: 20 Affected Users: 0
buildEventFragmentProperties SyntaxError: Invalid or unexpected token /scripts...
Event Count: 7 Affected Users: 0
buildEventFragmentProperties TypeError: Cannot destructure property 'name' of '(intermediate value)' as it is null. ...
Event Count: 5 Affected Users: 0
buildEventFragmentProperties TypeError: e.ᅦ槌ᅯ榫ᅤ槝iceModel is not a function /sc...
Event Count: 4 Affected Users: 0
---

Did you find this useful? React with a 👍 or 👎

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Nov 14, 2024
@cryptotavares cryptotavares force-pushed the cryptotavares/centralize-redesigned-confirmation-decision-logic branch from 58fce0b to 7702e54 Compare November 14, 2024 22:23
@cryptotavares cryptotavares marked this pull request as ready for review November 14, 2024 22:41
@cryptotavares cryptotavares requested review from a team as code owners November 14, 2024 22:41
@metamaskbot
Copy link
Collaborator

Builds ready [7702e54]
Page Load Metrics (1929 ± 125 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint37927821877437210
domContentLoaded160926751904261125
load166227121929260125
domInteractive17114522110
backgroundConnect65121147
firstReactRender482781144722
getState482232613
initialActions01000
loadScripts11722017141320196
setupStore55817189
uiStartup181230492165307147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 287 Bytes (0.00%)
  • ui: 1.31 KiB (0.02%)
  • common: 280 Bytes (0.00%)

jpuri
jpuri previously approved these changes Nov 15, 2024
shared/modules/confirmation.utils.ts Outdated Show resolved Hide resolved
shared/modules/confirmation.utils.ts Outdated Show resolved Hide resolved
shared/modules/confirmation.utils.ts Outdated Show resolved Hide resolved
shared/modules/confirmation.utils.ts Outdated Show resolved Hide resolved
shared/modules/confirmation.utils.ts Outdated Show resolved Hide resolved
ui/pages/confirmations/utils/confirm.ts Outdated Show resolved Hide resolved
@digiwand
Copy link
Contributor

looks like there are a few more lint errors to fix @cryptotavares
CleanShot 2024-11-20 at 21 11 16@2x

jsdoc is not picking up the destruct
plus the TS inline type
@metamaskbot
Copy link
Collaborator

Builds ready [746342a]
Page Load Metrics (1976 ± 72 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint17202274197715173
domContentLoaded16782190193813866
load17102261197615172
domInteractive3010947189
backgroundConnect9113352713
firstReactRender48303995024
getState51169952311
initialActions01000
loadScripts12481723144812661
setupStore610811
uiStartup19772686230419895
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 472 Bytes (0.01%)
  • ui: 1.46 KiB (0.02%)
  • common: 201 Bytes (0.00%)

Comment on lines +74 to +76
const isRedesignedConfirmationsDeveloperSettingEnabled =
process.env.ENABLE_CONFIRMATION_REDESIGN === 'true' ||
isRedesignedConfirmationsDeveloperEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused about how ENABLE_CONFIRMATION_REDESIGN was being handled. Thanks for clearing this up and for the helpful tests!

@metamaskbot
Copy link
Collaborator

Builds ready [6c56694]
Page Load Metrics (2161 ± 119 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45525211953536257
domContentLoaded183227112139246118
load184327442161248119
domInteractive30227655325
backgroundConnect106725189
firstReactRender652011013316
getState461801002612
initialActions01000
loadScripts13882043163019694
setupStore6451184
uiStartup214834292516296142
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 472 Bytes (0.01%)
  • ui: 1.46 KiB (0.02%)
  • common: 201 Bytes (0.00%)

@cryptotavares cryptotavares added this pull request to the merge queue Nov 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2024
@cryptotavares cryptotavares added this pull request to the merge queue Nov 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2024
@cryptotavares cryptotavares added this pull request to the merge queue Nov 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2024
@cryptotavares cryptotavares added this pull request to the merge queue Nov 21, 2024
Merged via the queue into develop with commit 6023787 Nov 21, 2024
75 checks passed
@cryptotavares cryptotavares deleted the cryptotavares/centralize-redesigned-confirmation-decision-logic branch November 21, 2024 15:31
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2024
@metamaskbot metamaskbot added the release-12.9.0 Issue or pull request that will be included in release 12.9.0 label Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template release-12.9.0 Issue or pull request that will be included in release 12.9.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants