metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

fix: preferences controller state sync

Open montelaidev opened this issue 1 year ago • 6 comments

Description

This PR syncs the state of accounts between the AccountsController and PreferencesController to keep them in sync.

The PreferencesController now mirrors the accounts from the AccountsController's InternalAccounts state. This ensures the PreferencesController always reflects the accurate account state.

Any write operations like setting the selected account or label are passed through to the AccountsController:

  • setSelectedAddress calls setSelectedAccount on the AccountsController
  • setAccountLabel calls setAccountName on the AccountsController

To get the selected account, the PreferencesController retrieves it from the AccountsController instead of internal state.

This allows the AccountsController to be the source of truth, while any write operations called on the PreferencesController are delegated to the AccountsController.

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Pre-merge author checklist

  • [x] I’ve followed MetaMask Coding Standards.
  • [x] I've completed the PR template to the best of my ability
  • [x] I’ve included tests if applicable
  • [x] I’ve documented my code using JSDoc format if applicable
  • [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

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.

montelaidev avatar May 21 '24 13:05 montelaidev

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.

github-actions[bot] avatar May 21 '24 13:05 github-actions[bot]

@metamaskbot update-policies

montelaidev avatar May 21 '24 15:05 montelaidev

Policies updated

metamaskbot avatar May 21 '24 15:05 metamaskbot

Builds ready [3081d96]
Page Load Metrics (1227 ± 617 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint721961224521
domContentLoaded97319147
load59299212271285617
domInteractive97319147
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -719 Bytes (-0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 182 Bytes (0.00%)

metamaskbot avatar May 22 '24 01:05 metamaskbot

Codecov Report

Attention: Patch coverage is 76.74419% with 10 lines in your changes missing coverage. Please review.

Project coverage is 65.70%. Comparing base (a85b6cf) to head (c3cb9a5).

Files Patch % Lines
app/scripts/controllers/preferences.js 76.92% 9 Missing :warning:
app/scripts/metamask-controller.js 75.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24678      +/-   ##
===========================================
- Coverage    65.73%   65.70%   -0.03%     
===========================================
  Files         1369     1369              
  Lines        54417    54366      -51     
  Branches     14161    14149      -12     
===========================================
- Hits         35766    35718      -48     
+ Misses       18651    18648       -3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 22 '24 01:05 codecov[bot]

Builds ready [a8ceada]
Page Load Metrics (857 ± 565 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint721871153617
domContentLoaded10361884
load6028788571177565
domInteractive10361884
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -719 Bytes (-0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 182 Bytes (0.00%)

metamaskbot avatar May 24 '24 15:05 metamaskbot

Builds ready [080a35d]
Page Load Metrics (985 ± 542 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint591941013416
domContentLoaded9381584
load4826059851129542
domInteractive9381584
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -719 Bytes (-0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 182 Bytes (0.00%)

metamaskbot avatar May 27 '24 09:05 metamaskbot

Builds ready [850ab48]
Page Load Metrics (140 ± 174 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6912289136
domContentLoaded9251242
load451721140363174
domInteractive9251242

metamaskbot avatar Jun 03 '24 12:06 metamaskbot

@metamaskbot update-policies

montelaidev avatar Jun 04 '24 01:06 montelaidev

Policies updated

metamaskbot avatar Jun 04 '24 02:06 metamaskbot

Builds ready [cf567b3]
Page Load Metrics (150 ± 197 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint761139095
domContentLoaded8141121
load421941150411197
domInteractive8141121

metamaskbot avatar Jun 04 '24 08:06 metamaskbot

Builds ready [c3cb9a5]
Page Load Metrics (45 ± 2 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint65897873
domContentLoaded811910
load41534532
domInteractive811910

metamaskbot avatar Jun 04 '24 14:06 metamaskbot