feat: define account name during creation
Description
Changes the add snap account flow to include a final modal that allows snaps to suggest a name for the new account or for the user to input a name for their new account. The new snap account is now created with a name either inputted by the user, suggested by the snap, or the default fallback account name.
Related issues
Fixes: https://github.com/MetaMask/accounts-planning/issues/261
Manual testing steps
Testing with preinstalled snap
You will need to temporarily add @metamask/account-watcher as a preinstalled snap
- Comment out these lines from the
getSnapsListselector
// Comment these lines out below so that preinstalled snaps aren't hidden from snaps list
if (snap.preinstalled) {
return snap.hidden === false;
}
- Add the Account Watcher snap with
yarn add @metamask/account-watcher - Replace preinstalled-snaps.ts with this:
import type { PreinstalledSnap } from '@metamask/snaps-controllers';
import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json';
import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json';
const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([
MessageSigningSnap as PreinstalledSnap,
AccountWatcherSnap as PreinstalledSnap,
]);
export default PREINSTALLED_SNAPS;
- Build the extension and go to vertical three dot menu > Snaps > Account Watcher
- Go through the flow to watch an account without inputting a name, with inputting a name, and canceling adding the account
Testing with account management snap
- Go to the SSK and connect the snap
- Go through the flow to create an account without inputting a name, with inputting a name, and canceling adding the account
Screenshots/Recordings
Demos
Preinstalled snap flow
https://github.com/MetaMask/metamask-extension/assets/91970214/3782a417-4fd0-4b56-b4b7-30f64e75c6e8
Account management snap flow
https://github.com/MetaMask/metamask-extension/assets/91970214/9f53a67d-13c5-44ac-b286-78eddbfb89ae
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
- [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.
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.
No dependency changes detected. Learn more about Socket for GitHub ↗︎
👍 No dependency changes detected in pull request
Question for @ccharly and @gantunesr Do you think we should throw an error after this line if a user cancels creating the account via the naming modal?
I noticed in the current implementation we do throw an error if a user cancels account creation. I have not been doing so, but maybe it is necessary?
@k-g-j
Question for @ccharly and @gantunesr Do you think we should throw an error after this line if a user cancels creating the account via the naming modal?
I noticed in the current implementation we do throw an error if a user cancels account creation. I have not been doing so, but maybe it is necessary?
IMO, yes, we should throw here too. This error seems to bubble up to the caller (when testing with the SSK, the dapp got the error message back), since cancelling the account renaming will trigger account removal, we should keep this behavior consistent and also returns an error here.
Throwing an error here, might have an impact on the extension when we trigger this kind of flow from the extension itself, but we would have to adapt the behavior of the extension in this case.
IMO, yes, we should throw here too.
Okay, I applied your suggestion here 203e9ac and will test it in the extension
Will test it in the extension
Update: It seems to work much better when throwing the error and being consistent here. As @ccharly said, when testing with the SSK, the dapp got the error message back 😄
Codecov Report
Attention: Patch coverage is 41.17647% with 10 lines in your changes missing coverage. Please review.
Project coverage is 69.94%. Comparing base (
b27dd2b) to head (36c7403).
Additional details and impacted files
@@ Coverage Diff @@
## develop #25191 +/- ##
========================================
Coverage 69.94% 69.94%
========================================
Files 1409 1409
Lines 49794 49771 -23
Branches 13773 13762 -11
========================================
- Hits 34826 34811 -15
+ Misses 14968 14960 -8
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Builds ready [3bc5ff7]
- 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 (181 ± 214 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 70 | 359 | 119 | 70 | 34 |
| domContentLoaded | 10 | 155 | 35 | 32 | 15 | ||
| load | 48 | 2114 | 181 | 446 | 214 | ||
| domInteractive | 10 | 155 | 35 | 32 | 15 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 573 Bytes (0.02%)
- ui: -507.66 KiB (-6.73%)
- common: 1.68 KiB (0.02%)
Builds ready [a3fcb3a]
- 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 (71 ± 10 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 78 | 143 | 101 | 18 | 8 |
| domContentLoaded | 11 | 72 | 31 | 17 | 8 | ||
| load | 50 | 118 | 71 | 20 | 10 | ||
| domInteractive | 11 | 72 | 31 | 17 | 8 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 573 Bytes (0.02%)
- ui: -483.32 KiB (-6.42%)
- common: 1.68 KiB (0.02%)
Builds ready [36c7403]
- 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 (174 ± 188 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 74 | 234 | 116 | 35 | 17 |
| domContentLoaded | 11 | 154 | 34 | 32 | 15 | ||
| load | 50 | 1874 | 174 | 391 | 188 | ||
| domInteractive | 11 | 154 | 34 | 32 | 15 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 573 Bytes (0.02%)
- ui: -483.32 KiB (-6.42%)
- common: 1.68 KiB (0.02%)
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Builds ready [1f02535]
- 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 (56 ± 6 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 70 | 119 | 87 | 13 | 6 |
| domContentLoaded | 9 | 55 | 23 | 11 | 5 | ||
| load | 40 | 91 | 56 | 12 | 6 | ||
| domInteractive | 9 | 55 | 23 | 11 | 5 |
Bundle size diffs [🚨 Warning! Bundle size has increased!]
- background: 573 Bytes (0.02%)
- ui: -483.32 KiB (-6.42%)
- common: 1.68 KiB (0.02%)