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

fix: Consistent confirmation navigation #27326

Merged
merged 4 commits into from
Sep 24, 2024
Merged

fix: Consistent confirmation navigation #27326

merged 4 commits into from
Sep 24, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Sep 23, 2024

Description

As per the way the old confirmation navigation works, when submitting multiple confirmation requests to the wallet, we want to select the oldest confirmation by default (1 of X).

If paramsTransactionId is undefined in ui/pages/confirmations/hooks/syncConfirmPath.ts, the default confirmation id comes from currentConfirmation. As such, the first currentConfirmation selected in useCurrentConfirmation will determine the default position in the array of X sorted confirmations.

Instead of using latestPendingApproval, we want to use the oldest (first to be created) one.

Open in GitHub Codespaces

Related issues

Fixes: #27252

Manual testing steps

  1. Go to this page...

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 the team-confirmations Push issues to confirmations team label Sep 23, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Sep 23, 2024
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner September 23, 2024 09:31
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.

jpuri
jpuri previously approved these changes Sep 23, 2024
@@ -28,15 +28,9 @@ export function pendingConfirmationsSortedSelector(
.sort((a1, a2) => a1.time - a2.time);
}

const internalLatestPendingConfirmationSelector = createSelector(
export const oldestPendingConfirmationSelector = createSelector(
Copy link
Member

@matthewwalsh0 matthewwalsh0 Sep 23, 2024

Choose a reason for hiding this comment

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

Do we definitely want to remove the createDeepEqualSelector here?

The recent Redux state PR should only update pendingApprovals when it actually changes, but if it does, then we'll get a fresh object reference and re-fire here unnecessarily?

These selectors are critical since they can impact everything using useConfirmContext.

ui/pages/confirmations/selectors/confirm.ts Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [0a6a568]
Page Load Metrics (1753 ± 67 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23820881669352169
domContentLoaded14972076172813364
load15052099175313967
domInteractive178040189
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: -134 Bytes (-0.00%)

jpuri
jpuri previously approved these changes Sep 24, 2024
ui/pages/confirmations/selectors/confirm.ts Show resolved Hide resolved
@@ -21,22 +20,16 @@ export function pendingConfirmationsSelector(state: ConfirmMetamaskState) {
export function pendingConfirmationsSortedSelector(
state: ConfirmMetamaskState,
) {
return getPendingApprovals(state)
return Object.values(state.metamask.pendingApprovals ?? {})
Copy link
Member

Choose a reason for hiding this comment

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

There's no value in doing this yet as we're not using createSelector so we'll always generate a new reference anyway, but at least we can re-use getPendingApprovals.

Copy link

sonarcloud bot commented Sep 24, 2024

@pedronfigueiredo pedronfigueiredo merged commit ca9be28 into develop Sep 24, 2024
76 of 77 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/27252 branch September 24, 2024 12:58
@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 24, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [8e9da4f]
Page Load Metrics (1945 ± 120 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint159125071942253121
domContentLoaded158324831919249119
load159325101945249120
domInteractive207236147
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: -29 Bytes (-0.00%)

@metamaskbot metamaskbot added the release-12.5.0 Issue or pull request that will be included in release 12.5.0 label Sep 29, 2024
@metamaskbot metamaskbot removed the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label 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
4 participants