chore: add wallet state injection and `yarn start:with-state` script
Description
With this PR, we add a new script that you can use to build the wallet in dev mode with a preloaded state.
Default Functionality:
- Run
yarn start:with-state- should load a wallet with the SRP and password set in the metamaskrc file, with several controllers data (contacts, transactions, notifications...) defined in the fixtures-config file.
Custom Functionality:
- Changing the params on the
fixtures-config.jsfile and running again the script, will set each fixture data dynamically (ie withAddressBook, will load xyz contacts, etc) - Pasting your own wallet state into the
fixtures-state.jsonand then running the script, will load the file state (and not generate the dynamic fixtures) instead of using the config file - These changes will be gitignored
Future Work:
This sets the base for adding and customizing more wallet state. We can expand this as much as we want. Here are the listed possible future tasks:
- [ ] Add accounts --> next priority
These is left to interested parties to do (if there is a need):
- [ ] Add unapproved transactions
- [ ] Add different kind of transactions (Send Token, Send NFT, Send Legacy etc)
- [ ] Add unapproved signatures
- [ ] Add read notifications
- [ ] Add different kind of notifications (send, received..)
Related issues
Fixes:
Manual testing steps
Check main functionality:
- Add a
PASSWORDand aTEST_SRPto your metamaskrc file - Run
yarn start:with-state - Upload a fresh MM -- see all the fixtures data is loaded
=============================== Check config file:
- Go to the
fixtures-config.jsfile - Change some values
- Run
yarn start:with-state - Upload a fresh MM and open it -- see the changes applied accordingly
=============================== Check json state file:
- Go to the
fixtures-state.jsonfile - Paste a wallet state (you can export one by pasting this into the console
copy(await stateHooks.metamaskGetState())) - Run
yarn start:with-state - Upload a fresh MM -- see your wallet json state is applied
Screenshots/Recordings
https://github.com/user-attachments/assets/3ab6035d-8576-4399-8963-867d39e251f6
Pre-merge author checklist
- [X] I've followed MetaMask Contributor Docs and MetaMask Extension Coding Standards.
- [X] I've completed the PR template to the best of my ability
- [] 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.
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.
Codecov Report
Attention: Patch coverage is 0% with 128 lines in your changes missing coverage. Please review.
Project coverage is 69.90%. Comparing base (
c462fb8) to head (46bd784).
Additional details and impacted files
@@ Coverage Diff @@
## develop #26222 +/- ##
===========================================
- Coverage 70.02% 69.90% -0.12%
===========================================
Files 1443 1450 +7
Lines 50162 50249 +87
Branches 14039 14046 +7
===========================================
Hits 35124 35124
- Misses 15038 15125 +87
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Builds ready [dabdb0f]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (231 ± 230 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 78 | 341 | 114 | 55 | 26 |
| domContentLoaded | 9 | 63 | 26 | 14 | 7 | ||
| load | 51 | 1668 | 231 | 478 | 230 | ||
| domInteractive | 9 | 63 | 26 | 14 | 7 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 349.72 KiB (10.11%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [3ffe5c6]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (155 ± 182 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 66 | 235 | 101 | 37 | 18 |
| domContentLoaded | 9 | 169 | 29 | 36 | 17 | ||
| load | 39 | 1796 | 155 | 379 | 182 | ||
| domInteractive | 9 | 169 | 29 | 36 | 17 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 409.85 KiB (11.85%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [14c8f4c]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (89 ± 9 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 77 | 148 | 115 | 20 | 10 |
| domContentLoaded | 50 | 124 | 86 | 20 | 9 | ||
| load | 57 | 128 | 89 | 18 | 9 | ||
| domInteractive | 12 | 67 | 31 | 13 | 6 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 380.52 KiB (9.74%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [e793540]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (74 ± 9 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 60 | 129 | 100 | 20 | 10 |
| domContentLoaded | 39 | 112 | 70 | 20 | 10 | ||
| load | 46 | 112 | 74 | 18 | 9 | ||
| domInteractive | 8 | 67 | 26 | 14 | 7 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 381.08 KiB (9.75%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [3e9ddff]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (75 ± 8 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 81 | 148 | 102 | 15 | 7 |
| domContentLoaded | 51 | 130 | 70 | 18 | 9 | ||
| load | 58 | 130 | 75 | 17 | 8 | ||
| domInteractive | 18 | 74 | 29 | 13 | 6 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 285.71 KiB (7.90%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [dd598ba]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (67 ± 7 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 66 | 131 | 89 | 17 | 8 |
| domContentLoaded | 39 | 106 | 64 | 16 | 8 | ||
| load | 45 | 106 | 67 | 15 | 7 | ||
| domInteractive | 9 | 31 | 23 | 5 | 2 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 285.6 KiB (7.90%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Hi @seaona , i tested on your branch, i encountered a issue that the ERC20 tokens are not displayed, not sure what's the problem, could you have a look? Thanks !
https://github.com/user-attachments/assets/9d7d9e28-15f1-4228-995e-c13dc6d56380
Hi @seaona , i tested on your branch, i encountered a issue that the ERC20 tokens are not displayed, not sure what's the problem, could you have a look? Thanks !
whoaa nice catch :heart_eyes: thank you @chloeYue ! the logic for substituting the account address was not correct, so it was appearing only in mine since the address was hardcoded. Now it should be fixed
Builds ready [27c2962]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1739 ± 65 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 1531 | 2084 | 1742 | 137 | 66 |
| domContentLoaded | 1522 | 2077 | 1723 | 136 | 65 | ||
| load | 1531 | 2086 | 1739 | 135 | 65 | ||
| domInteractive | 16 | 91 | 37 | 18 | 8 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 289.18 KiB (8.48%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Test ok on latest commit, ERC20 tokens are displayed:
Builds ready [46bd784]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1742 ± 86 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 234 | 2069 | 1529 | 564 | 271 |
| domContentLoaded | 1447 | 2048 | 1725 | 173 | 83 | ||
| load | 1455 | 2059 | 1742 | 180 | 86 | ||
| domInteractive | 14 | 95 | 39 | 23 | 11 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 274.33 KiB (7.75%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Test OK on the latest branch status !
Missing release label release-12.5.0 on PR. Adding release label release-12.5.0 on PR and removing other release labels(release-12.6.0), as PR was added to branch 12.5.0 when release was cut.
