MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.52k stars 4.7k forks source link

fix: Ensure smart transaction modal is shown for users upgrading from previous versions #24377

Closed danjm closed 1 week ago

danjm commented 2 weeks ago

Description

This fixes a bug I found while testing v11.15.1. The bug is that currently only new users will see the "Enable Smart Transactions" modal. People who already have metamask installed and then update to v11.15.1 will not see the "Enable Smart Transactions" modal. This means that existing users won't be notified that they can turn this functionality on.

The reason is that getIsSmartTransactionsOptInModalAvailable only returns true if the result of getSmartTransactionsOptInStatus(state) is null. That depends on the smartTransactionsOptInStatus property, from the preferences controller. That property is set within the preferencesController.preferences property, which is an object, within initState of the the preferences controller. initState is always over written by pre-existing state if it existis (via the ...opts.initState, line). If a user is updating to v11.15.1 from a previous version, preferencesController.preferences from the previous version will overwrite the default preferencesController.preferences, and so smartTransactionsOptInStatus will be undefined (and not null).

The simple fix applied here is for getSmartTransactionsOptInStatus to return null if smartTransactionsOptInStatus is undefined.

Open in GitHub Codespaces

Manual testing steps

  1. Locally build and install v11.14.5 and onboard
  2. Build this branch and update the existing local build to the build generated by this branch
  3. open metamask and you should see the "Enable Smart Transactions" modal

Follow the above 3 steps on develop or on Version-v11.15.1, and there will be no modal shown on step three.

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

github-actions[bot] commented 2 weeks ago

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 commented 2 weeks ago
Builds ready [54fa4e1]
Page Load Metrics (564 ± 488 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint57138812211
domContentLoaded84615126
load4530175641017488
domInteractive84615126
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 7 Bytes (0.00%)
metamaskbot commented 1 week ago

Missing release label release-11.15.2 on PR. Adding release label release-11.15.2 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.15.2.