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

feat: converted PreferencesController to typescript

Open kanthesha opened this issue 1 year ago • 2 comments

Description

As a prerequisite for migrating PreferencesController to BaseController v2, and to support the TypeScript migration effort for the extension, we want to convert PreferencesController to TypeScript.

Open in GitHub Codespaces

Related issues

Fixes: #25923

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.

kanthesha avatar Aug 28 '24 13:08 kanthesha

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 Aug 28 '24 13:08 github-actions[bot]

Codecov Report

Attention: Patch coverage is 65.51724% with 20 lines in your changes missing coverage. Please review.

Project coverage is 70.13%. Comparing base (d6d43eb) to head (16b085d). Report is 27 commits behind head on develop.

Files with missing lines Patch % Lines
app/scripts/controllers/preferences-controller.ts 65.52% 20 Missing :warning:
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26710   +/-   ##
========================================
  Coverage    70.13%   70.13%           
========================================
  Files         1425     1425           
  Lines        49669    49673    +4     
  Branches     13895    13897    +2     
========================================
+ Hits         34833    34836    +3     
- Misses       14836    14837    +1     

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

codecov[bot] avatar Aug 29 '24 09:08 codecov[bot]

Builds ready [f23b286]
Page Load Metrics (72 ± 10 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint69172982411
domContentLoaded44126662311
load51127722110
domInteractive106426136
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 610 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Aug 29 '24 10:08 metamaskbot

Builds ready [0416ba9]
Page Load Metrics (1901 ± 109 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint21925601755536258
domContentLoaded16672453187820297
load170126381901227109
domInteractive1410736199
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 626 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Aug 29 '24 11:08 metamaskbot

Builds ready [975f53d]
Page Load Metrics (1803 ± 113 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22223071731412198
domContentLoaded148622971773229110
load148923101803234113
domInteractive236736147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 694 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 03 '24 12:09 metamaskbot

Builds ready [f718267]
Page Load Metrics (1563 ± 95 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22723621440441212
domContentLoaded13792275155018086
load13862368156319795
domInteractive216029105
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 626 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 03 '24 14:09 metamaskbot

Builds ready [fc8725d]
Page Load Metrics (2146 ± 105 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint24025261848682328
domContentLoaded171625262115221106
load173125422146219105
domInteractive20106432010
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 626 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 03 '24 18:09 metamaskbot

Builds ready [3999010]
Page Load Metrics (1733 ± 54 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23419951584463222
domContentLoaded15651958171210651
load15751970173311354
domInteractive128739199
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 626 Bytes (0.02%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 04 '24 10:09 metamaskbot

Nit: We can also update the Controller initialisation in metamask-controller.js to add setSelectedAccount and remove provider from the constructor

   const preferencesMessenger = this.controllerMessenger.getRestricted({
      name: 'PreferencesController',
      allowedActions: [
        'AccountsController:setSelectedAccount',
        'AccountsController:getAccountByAddress',
        'AccountsController:setAccountName',
        'AccountsController:setSelectedAccount',
      ],
      allowedEvents: ['AccountsController:stateChange'],
    });

    this.preferencesController = new PreferencesController({
      initState: initState.PreferencesController,
      initLangCode: opts.initLangCode,
      messenger: preferencesMessenger,
      networkConfigurations: this.networkController.state.networkConfigurations,
    });

cryptodev-2s avatar Sep 04 '24 14:09 cryptodev-2s

'AccountsController:setSelectedAccount',

It is a small change, we can include, but it is not inline with the task of this PR. I would prefer to create a separate ticket on this and make this change.

kanthesha avatar Sep 04 '24 17:09 kanthesha

Builds ready [38995d2]
Page Load Metrics (1826 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23920741657481231
domContentLoaded15932102181013465
load15972108182613464
domInteractive187236168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 457 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 04 '24 17:09 metamaskbot

Builds ready [68871a1]
Page Load Metrics (1807 ± 92 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint25725121655497238
domContentLoaded16112442178318589
load16402514180719192
domInteractive157334157
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 457 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 04 '24 18:09 metamaskbot

Builds ready [bb1431f]
Page Load Metrics (2058 ± 178 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27730872002561269
domContentLoaded154728852032367176
load155728912058371178
domInteractive1497402512
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 457 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 09 '24 12:09 metamaskbot

Builds ready [10a6083]
Page Load Metrics (1854 ± 204 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23333061730668321
domContentLoaded155030021830396190
load155531521854425204
domInteractive13207474421
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 457 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 09 '24 14:09 metamaskbot

Builds ready [16b085d]
Page Load Metrics (1565 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint12918851430430207
domContentLoaded1418178215429948
load14261899156511455
domInteractive18582584
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 457 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Sep 09 '24 15:09 metamaskbot