Skip to content

feat: reset user's preferences when resetting wallet#39973

Merged
chaitanyapotti merged 3 commits intomainfrom
fix/reset-wallet-preferences
Feb 11, 2026
Merged

feat: reset user's preferences when resetting wallet#39973
chaitanyapotti merged 3 commits intomainfrom
fix/reset-wallet-preferences

Conversation

@lwin-kyaw
Copy link
Contributor

@lwin-kyaw lwin-kyaw commented Feb 11, 2026

Description

When a user resets their wallet via the "Forgot Password" flow, certain state was not being fully cleared. Specifically, the PreferencesController state (locale, theme, blockies, advanced gas fees, known method data, etc.) and the AddressBookController state (saved contacts) were persisted across wallet resets, leaking previous wallet configuration into the freshly restored wallet.

This PR:

  1. Adds a resetState() method to PreferencesController that resets all preferences back to their default values.
  2. Calls addressBookController.clear() during wallet reset to remove saved contacts.
  3. Calls preferencesController.resetState() during wallet reset to restore default preferences.
  4. Adds unit tests for the new resetState() method.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Fixed a bug where user preferences and saved contacts were not cleared when resetting the wallet

Related issues

Fixes: #39863

Manual testing steps

  1. Install the extension and complete onboarding with a seed phrase.
  2. Customize some preferences: change locale, switch to dark theme, enable blockies, add a contact in the address book.
  3. Navigate to Settings → Advanced → Reset Wallet (or use the "Forgot Password" flow from the lock screen).
  4. Complete the wallet restore using the same or different seed phrase.
  5. Verify that all preferences are reset to defaults (OS theme, jazzicon avatar, default locale, etc.).
  6. Verify that the address book / contacts list is empty.

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.

Note

Medium Risk
Touches the wallet reset flow and preference defaults; mistakes could cause incorrect post-reset configuration or unintended data persistence/clearing.

Overview
Ensures the "Forgot Password" wallet reset flow fully clears user-specific configuration by resetting PreferencesController state back to defaults and clearing the address book.

Adds PreferencesController.resetState() (overriding a couple of defaults like currentLocale to FALLBACK_LOCALE and autoLockTimeLimit to DEFAULT_AUTO_LOCK_TIME_LIMIT) and wires it into metamask-controller.resetWallet, with a new unit test verifying key preference fields are reset.

Written by Cursor Bugbot for commit 71fcf80. This will update automatically on new commits. Configure here.

@github-actions
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.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 11, 2026

Builds ready [689465b]
UI Startup Metrics (1373 ± 96 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1373117116299614341521
load117999914139412371335
domContentLoaded117399614069312301325
domInteractive2815159222485
firstPaint1426635771200277
backgroundConnect23721641622238265
firstReactRender1592531620
initialActions301531513
loadScripts95177211939210021102
setupStore1162441319
numNetworkReqs231588201583
BrowserifyPower User HomeuiStartup2381145710603157321084776
load12491076232021112771779
domContentLoaded12291066230320212601711
domInteractive48192725143161
firstPaint220851676176267420
backgroundConnect738293824812273732471
firstReactRender24154772541
initialActions103112
loadScripts979821193618910101415
setupStore1675981728
numNetworkReqs1215124845142220
WebpackStandard HomeuiStartup83267611091059201016
load7226041015103828878
domContentLoaded7165991006102823872
domInteractive261692182377
firstPaint1166134663144224
backgroundConnect26174973040
firstReactRender14102941721
initialActions104111
loadScripts7145971004102817870
setupStore1162641221
numNetworkReqs231592211584
WebpackPower User HomeuiStartup1262942257223213261548
load74964613841297351033
domContentLoaded73863713781297221026
domInteractive39191593036129
firstPaint156641212129159298
backgroundConnect172134102195162268
firstReactRender23173742530
initialActions103111
loadScripts73563513681277201018
setupStore1353951621
numNetworkReqs1305427446156209
FirefoxBrowserifyStandard HomeuiStartup16321440226015816611936
load14081246181111514411639
domContentLoaded14061240181111514411639
domInteractive80332354399142
firstPaint------
backgroundConnect6131220296084
firstReactRender12101911314
initialActions103122
loadScripts13781220178310714161599
setupStore167184231346
numNetworkReqs231394201782
BrowserifyPower User HomeuiStartup364727901143790538984340
load21711825985680721862601
domContentLoaded21701824985680721862601
domInteractive17348816135173413
firstPaint------
backgroundConnect4041531255265483983
firstReactRender251897132533
initialActions214123
loadScripts21201763980780621212534
setupStore17611829226189740
numNetworkReqs75382334585189
WebpackStandard HomeuiStartup16181402228114116541877
load1390121717409914371547
domContentLoaded13891216174010014371547
domInteractive922823139119143
firstPaint------
backgroundConnect56231462760115
firstReactRender14112631521
initialActions102122
loadScripts1362120317159414091523
setupStore186169251562
numNetworkReqs231395181774
WebpackPower User HomeuiStartup27871975931180029303783
load16031302769267115472184
domContentLoaded16021302769167115472184
domInteractive15233878163122578
firstPaint------
backgroundConnect4011275574580489913
firstReactRender22167072430
initialActions203123
loadScripts15141278259328515182121
setupStore16210736189209617
numNetworkReqs72362174188162
📊 Page Load Benchmark Results

Current Commit: 689465b | Date: 2/11/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±41ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 722ms (±38ms) 🟢 | historical mean value: 719ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±14ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 41ms 1.01s 1.33s 1.06s 1.33s
domContentLoaded 722ms 38ms 700ms 999ms 744ms 999ms
firstPaint 77ms 14ms 60ms 208ms 84ms 208ms
firstContentfulPaint 77ms 14ms 60ms 208ms 84ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 368 Bytes (0.01%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 11, 2026

Builds ready [71fcf80]
UI Startup Metrics (1368 ± 87 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1368116715918714201525
load118398413798412381329
domContentLoaded117597613738512261321
domInteractive2716102182472
firstPaint161681169125208302
backgroundConnect24321743127244282
firstReactRender1592731722
initialActions107112
loadScripts9487541129839991094
setupStore1162231318
numNetworkReqs221591191579
BrowserifyPower User HomeuiStartup17371357424231217392139
load11461023175016111161600
domContentLoaded11291010169315111061500
domInteractive3518206283589
firstPaint1667046084221331
backgroundConnect3332761879157326379
firstReactRender22144572439
initialActions104112
loadScripts89277614271458691255
setupStore1575461724
numNetworkReqs1144525445142205
WebpackStandard HomeuiStartup80366498487873945
load69659587983759842
domContentLoaded69159286982756836
domInteractive251592182278
firstPaint985831145111183
backgroundConnect24174372738
firstReactRender13102341620
initialActions103112
loadScripts68859086381754834
setupStore1154961121
numNetworkReqs231590211583
WebpackPower User HomeuiStartup1209875199619113071631
load70861613271247011039
domContentLoaded69960913171236891014
domInteractive35182073330103
firstPaint14362671112154352
backgroundConnect16212936548160286
firstReactRender21153732327
initialActions102111
loadScripts69660813091216871006
setupStore1253241321
numNetworkReqs1174426751145213
FirefoxBrowserifyStandard HomeuiStartup15981368228617316252029
load13801163203513714331620
domContentLoaded13791158202813714331620
domInteractive803325247109148
firstPaint------
backgroundConnect57291612459104
firstReactRender1291811314
initialActions106112
loadScripts13551144200613513951583
setupStore136165171229
numNetworkReqs241299221785
BrowserifyPower User HomeuiStartup26131981675655026793347
load15431218551346015802049
domContentLoaded15431215551346015802044
domInteractive11736714106111366
firstPaint------
backgroundConnect233931091199212795
firstReactRender18135971721
initialActions103122
loadScripts15041165546745615272025
setupStore1207702176113566
numNetworkReqs67341563290129
WebpackStandard HomeuiStartup16681360202512817581907
load14331171165710114981605
domContentLoaded14321165165710214971603
domInteractive882321645123166
firstPaint------
backgroundConnect60271542669113
firstReactRender14112421519
initialActions103122
loadScripts1403114916149914621575
setupStore14779111436
numNetworkReqs231383181777
WebpackPower User HomeuiStartup25911929372537827133451
load14931260244323416171893
domContentLoaded14921259244323416171893
domInteractive11830706132102563
firstPaint------
backgroundConnect249113961183241764
firstReactRender21143942429
initialActions2034322
loadScripts14571223241722815771862
setupStore1717786226185682
numNetworkReqs65341473297124
📊 Page Load Benchmark Results

Current Commit: 71fcf80 | Date: 2/11/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.00s (±41ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 693ms (±37ms) 🟢 | historical mean value: 719ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±12ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.00s 41ms 971ms 1.29s 1.04s 1.29s
domContentLoaded 693ms 37ms 669ms 958ms 732ms 958ms
firstPaint 78ms 12ms 68ms 188ms 84ms 188ms
firstContentfulPaint 78ms 12ms 68ms 188ms 84ms 188ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 402 Bytes (0.01%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@chaitanyapotti chaitanyapotti added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 5a7b562 Feb 11, 2026
176 checks passed
@chaitanyapotti chaitanyapotti deleted the fix/reset-wallet-preferences branch February 11, 2026 09:43
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2026
@metamaskbot metamaskbot added the release-13.19.0 Issue or pull request that will be included in release 13.19.0 label Feb 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-onboarding release-13.19.0 Issue or pull request that will be included in release 13.19.0 size-M team-onboarding Onboarding team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Reset Wallet - Resetting the wallet and Importing a new SRP doesn't clear my complete wallet state (Contacts from previous SRP are still there)

4 participants