Skip to content

feat: add setting to dismiss prompt to enable smart contract #31609

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

Merged
merged 12 commits into from
Apr 9, 2025

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Apr 4, 2025

Description

We should add a toggle within Settings > Advanced to not be asked to update an account to a Smart Account again.

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/4559

Manual testing steps

  1. Go to settings > advance
  2. Toggle on option Dismiss "Switch to Smart Account" suggestion
  3. Ensure that propmt does not appear again

Screenshots/Recordings

Screenshot 2025-04-04 at 9 29 08 PM

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.

@jpuri jpuri added the team-confirmations Push issues to confirmations team label Apr 4, 2025
@jpuri jpuri requested a review from a team as a code owner April 4, 2025 16:00
Copy link
Contributor

github-actions bot commented Apr 4, 2025

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
Copy link
Collaborator

Builds ready [2bed795]
UI Startup Metrics (1213 ± 58 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1213109813575812511328
load10679761221551153995
domContentLoaded10619691217551151991
domInteractive17136981631
firstPaint8421371221388182991
backgroundConnect106495910
firstReactRender18143731923
getState11441768
initialActions001000
loadScripts81172195255846919
setupStore7516279
WebpackHomeuiStartup20751678253620422122362
load16141304195415817341821
domContentLoaded16081300193415717291816
domInteractive171266121354
firstPaint17564136113727183
backgroundConnect281079153163
firstReactRender170543411108293
getState1232692689
initialActions315135
loadScripts16001297190815617241799
setupStore37629569297
FirefoxBrowserifyHomeuiStartup13811195194915214461748
load12401077175514112961567
domContentLoaded12401076175414112961567
domInteractive9738199248897
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2517102112541
firstReactRender22195252229
getState7316279
initialActions001001
loadScripts12161047173413912741542
setupStore6413268
WebpackHomeuiStartup15661332210717116231938
load13481155189215813961715
domContentLoaded13481155189215813961715
domInteractive9738213278996
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25188682635
firstReactRender37287983954
getState9431689
initialActions102111
loadScripts13251135187415713751692
setupStore8535389
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 411 Bytes (0.01%)
  • ui: 1.49 KiB (0.02%)
  • common: 706 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [bb98225]
UI Startup Metrics (1240 ± 66 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1240111513896612931336
load10819171243701172979
domContentLoaded10759111236701170990
domInteractive18136391631
firstPaint698791207435242975
backgroundConnect106314910
firstReactRender21156292048
getState13539879
initialActions001000
loadScripts82667299170883927
setupStore8532478
WebpackHomeuiStartup21681673262518222752442
load17101306219615617872020
domContentLoaded17041302219115417822008
domInteractive181286141459
firstPaint169654556825791
backgroundConnect3110267283762
firstReactRender179533551125987
getState12465979
initialActions317135
loadScripts16931300204914517721964
setupStore24628538388
FirefoxBrowserifyHomeuiStartup13611178187415013991727
load12171031173214112581567
domContentLoaded12161030173214112581567
domInteractive9836322358997
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect23154962534
firstReactRender23195662430
getState941821879
initialActions0029301
loadScripts11941014171114012401545
setupStore842042067
WebpackHomeuiStartup15261309199415016101865
load13181131177114213961628
domContentLoaded13181130177014213961628
domInteractive9749167228996
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect26184882944
firstReactRender36286863946
getState9436589
initialActions001011
loadScripts12951113174814113741602
setupStore8533479
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 40 Bytes (0%)
  • ui: 1.48 KiB (0.02%)
  • common: 578 Bytes (0.01%)


if (!isUpgradeTransaction) {
if (!isUpgradeTransaction || dismissSmartAccountSuggestionEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately we can't just hide the acknowledge checkbox as the transaction would still perform the upgrade once approved.

If we instead check this here:

https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/lib/transaction/eip5792.ts#L187

Then the middleware would reject the request outright since the user has said they never want to upgrade.

Plus technically we should also check if the user is already upgraded and skip this check, but that can be done in a separate ticket as I have pending changes in the transaction controller to get that information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh my bad, I fixed this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me create task for

Plus technically we should also check if the user is already upgraded and skip this check, but that can be done in a separate ticket as I have pending changes in the transaction controller to get that information.

@@ -200,6 +201,7 @@ export const getDefaultPreferencesControllerState =
showMultiRpcModal: false,
privacyMode: false,
shouldShowAggregatedBalancePopover: true, // by default user should see popover;
dismissSmartAccountSuggestionEnabled: false,
Copy link
Member

Choose a reason for hiding this comment

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

We already have the accountUpgradeDisabledChains also, should this be combined into that?

Do we also want to display those in the settings UI?

Copy link
Contributor Author

@jpuri jpuri Apr 8, 2025

Choose a reason for hiding this comment

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

yep I was also thinking about re-using this - and I think this will be more a user level thing and not account level, additionally it will reflect across the app

@@ -1998,6 +1998,11 @@ export function getShouldShowAggregatedBalancePopover(state) {
return shouldShowAggregatedBalancePopover;
}

export function getDismissSmartAccountSuggestionEnabled(state) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we use ui/pages/confirmations/selectors/preferences.ts instead of adding to this huge file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@jpuri jpuri requested a review from matthewwalsh0 April 8, 2025 17:57
@metamaskbot
Copy link
Collaborator

Builds ready [33a4883]
UI Startup Metrics (1272 ± 63 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1272115415406313081388
load111198612725811581272
domContentLoaded110497912645911531264
domInteractive18146881729
firstPaint8251351255414214296
backgroundConnect117605910
firstReactRender20155471936
getState14541879
initialActions001001
loadScripts838710100057875919
setupStore8531478
WebpackHomeuiStartup21901698264318423072417
load17081293206916017881993
domContentLoaded16991284206015817821986
domInteractive181259121556
firstPaint161633285724892
backgroundConnect4011414613861
firstReactRender199543861136295
getState13382969
initialActions316145
loadScripts16901277203715517751963
setupStore22633332307
FirefoxBrowserifyHomeuiStartup13821228172611514651621
load12411068156911613331478
domContentLoaded12401067156911613321477
domInteractive10139263339098
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect251785102446
firstReactRender22193422227
getState7416289
initialActions001001
loadScripts12171033152711513121457
setupStore6413267
WebpackHomeuiStartup14831328192210415371722
load1276115517179913191515
domContentLoaded1276115517179913191514
domInteractive9542358348998
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2718305282739
firstReactRender35285453746
getState9531689
initialActions002111
loadScripts1251113916959612791431
setupStore8544579

matthewwalsh0
matthewwalsh0 previously approved these changes Apr 9, 2025
function validateUserPreference(dismissSmartAccountSuggestionEnabled: boolean) {
if (dismissSmartAccountSuggestionEnabled) {
throw rpcErrors.transactionRejected(
'User does not want to update account to smart account.',
Copy link
Member

Choose a reason for hiding this comment

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

Could we combine this with the above to use the same error, as they're ultimately both preferences to not upgrade?

Copy link
Contributor Author

@jpuri jpuri Apr 9, 2025

Choose a reason for hiding this comment

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

Message for both will be bit different, as other will be address level now and this is more user level thing.

Copy link
Member

Choose a reason for hiding this comment

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

Even so, from the perspective of the dApp, it's simply not supported for that chain and account. Plus I think we want to stick with methodNotSupported for now since the user hasn't technically rejected the transaction, but the act of upgrading.

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 will implement code changes in following PR.

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 these changes in PR while updating it to resolve conflicts

@jpuri jpuri enabled auto-merge April 9, 2025 13:10
@metamaskbot
Copy link
Collaborator

Builds ready [79078c5]
UI Startup Metrics (1246 ± 65 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1246113114386512981342
load109199312725911391209
domContentLoaded10859831266591151988
domInteractive17139491630
firstPaint7561331273432206296
backgroundConnect117617910
firstReactRender21145772138
getState13533878
initialActions001001
loadScripts83271999657866930
setupStore8446578
WebpackHomeuiStartup21951754266519423292425
load17291366218717418332029
domContentLoaded17221356218217218262022
domInteractive171272111549
firstPaint169673256326085
backgroundConnect4011227403864
firstReactRender173543621116093
getState2543245569
initialActions317146
loadScripts17121353217716818171990
setupStore25626342308
FirefoxBrowserifyHomeuiStartup13521188177713013811696
load12111071165312112481550
domContentLoaded12101071165312112481550
domInteractive10239238328998
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect24165782446
firstReactRender22195552227
getState7425479
initialActions001001
loadScripts11881053162312112261523
setupStore1042062667
WebpackHomeuiStartup16051416199612316871849
load13781202166711214531592
domContentLoaded13781202166611214531592
domInteractive10068165229097
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25194352833
firstReactRender38307674249
getState10442689
initialActions102111
loadScripts13541178164011114261570
setupStore8514289

@jpuri jpuri added this pull request to the merge queue Apr 9, 2025
auto-merge was automatically disabled April 9, 2025 15:43

Pull Request is not mergeable

Merged via the queue into main with commit ccd3cbc Apr 9, 2025
166 checks passed
@jpuri jpuri deleted the advance_setting_smart_account branch April 9, 2025 16:27
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2025
@metamaskbot metamaskbot added the release-12.17.0 Issue or pull request that will be included in release 12.17.0 label Apr 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.17.0 Issue or pull request that will be included in release 12.17.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants