Skip to content

feat: Add CreateSnapAccount component #30611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

PatrykLucka
Copy link
Contributor

@PatrykLucka PatrykLucka commented Feb 27, 2025

Description

This PR introduces a new form for built-in Snap account creation (currently limited to Solana), allowing users to select the SRP. It also standardizes the account creation UX across EVM and Solana networks.

Related issues

Jira ticket: https://consensyssoftware.atlassian.net/browse/MMMULTISRP-19
Design: Figma
SIP-30 doc: https://github.com/MetaMask/SIPs/blob/207518f3ea50fe536ac0e58264481d7679c46824/SIPS/sip-30.md#creating-accounts

Manual testing steps

With one SRP:

  1. Open account menu
  2. Click "Add account or hardware wallet"
  3. Click "Solana account"

New form should be visible with an option to set Solana account name.

With more than one SRP:

  1. Open account menu
  2. Click "Add account or hardware wallet"
  3. Click "Solana account"

New form should be visible with an option to select SRP and name.

Screenshots/Recordings

Before

Screenshot 2025-03-11 at 18 33 03

After

Screenshot 2025-03-11 at 18 30 30

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.

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.

@metamaskbot metamaskbot added the team-mmi PRs from the MMI team label Feb 27, 2025
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch 2 times, most recently from 49decfb to 260e856 Compare February 28, 2025 11:13
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch from 260e856 to a426a97 Compare March 7, 2025 10:11
@PatrykLucka PatrykLucka changed the base branch from multi-srp-mvp-2 to feat/multi-srp-add-account March 7, 2025 10:11
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch 5 times, most recently from 3547c2d to d1a54d6 Compare March 11, 2025 17:31
Base automatically changed from feat/multi-srp-add-account to main March 14, 2025 02:19
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch 8 times, most recently from 26304f7 to 023d0a2 Compare March 17, 2025 15:39
@PatrykLucka PatrykLucka marked this pull request as ready for review March 17, 2025 16:01
@PatrykLucka PatrykLucka requested a review from a team as a code owner March 17, 2025 16:01
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Mar 18, 2025
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch from 023d0a2 to f829b9b Compare March 18, 2025 10:02
@metamaskbot
Copy link
Collaborator

Builds ready [f829b9b]
Page Load Metrics (3930 ± 1925 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint173920309368840141928
domContentLoaded171020188341440111926
load177020290393040091925
domInteractive284667610651
backgroundConnect491445474460221
firstReactRender2250512714067
getState16991266311149
initialActions01000
loadScripts126518799268438051827
setupStore91046157243117
uiStartup202720486675157772774
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 195 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

Everything works, albeit a bit slow-ish on my machine. Found a usability issue:

If you set a custom name, then change the SRP the account should be associated with, the name field gets cleared out. That would be frustrating for users, so we should store that name in component state and restore it once the user comes back from choosing SRP.

Screen.Recording.2025-03-18.at.9.15.56.AM.mov

@github-project-automation github-project-automation bot moved this from Needs dev review to Needs more work from the author in PR review queue Mar 18, 2025
@Tlees-MMI Tlees-MMI moved this from Needs more work from the author to Needs dev review in PR review queue Mar 18, 2025
@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch 2 times, most recently from 4e28ca1 to 1edcdd4 Compare March 20, 2025 13:33
@metamaskbot
Copy link
Collaborator

Builds ready [1edcdd4]
Page Load Metrics (4502 ± 2036 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint191319189426541962015
domContentLoaded176218146389140641951
load197319580450242412036
domInteractive2978010616579
backgroundConnect1491431592422202
firstReactRender292861156632
getState4584523819091
initialActions01000
loadScripts133116050308036941774
setupStore961516215474
uiStartup253021948677645432181
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 195 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@PatrykLucka
Copy link
Contributor Author

Thanks for pointing this out @darkwing ! I really appreciate you taking the time to investigate this. This issue actually applies to the EVM account flow as well, so it might be better to address it in a separate PR. Additionally, this is something that’s about to change soon anyway.

The reason there’s no easy fix right now is that the name is stored in the CreateAccount component, which gets unmounted when switching to the SRP selector view. Fixing this would require moving the name state to the account-list-menu, which might not be worth the effort since this component is due for changes soon.

Happy to discuss further if you have thoughts on this!

Comment on lines 496 to 508
switch (mode) {
case ACTION_MODES.ADD_BITCOIN:
return {
clientType: WalletClientType.Bitcoin,
chainId: MultichainNetworks.BITCOIN,
};
case ACTION_MODES.ADD_BITCOIN_TESTNET:
return {
clientType: WalletClientType.Bitcoin,
chainId: MultichainNetworks.BITCOIN_TESTNET,
};
case ACTION_MODES.ADD_SOLANA:
return {
clientType: WalletClientType.Solana,
chainId: MultichainNetworks.SOLANA,
};
default:
return {
clientType: null,
chainId: null,
};
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move this somewhere else as a config that you import, not to interfere with UI stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I've changed it to map object and moved it the top of the file, so it will be easier to read

@PatrykLucka PatrykLucka force-pushed the MMMULTISRP-19-create-non-evm-account-from-n-srp branch from f96b132 to e4c1709 Compare March 24, 2025 10:09
@metamaskbot
Copy link
Collaborator

Builds ready [e4c1709]
Page Load Metrics (2144 ± 228 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint161835902028439211
domContentLoaded153234651884421202
load163137392144475228
domInteractive25250485024
backgroundConnect10455726711354
firstReactRender31122752311
getState323111387335
initialActions01000
loadScripts113623031334243116
setupStore13303907938
uiStartup2038876537851414679
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 195 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 24, 2025
@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 24, 2025
Merged via the queue into main with commit 5bf44ce Mar 24, 2025
109 checks passed
@PatrykLucka PatrykLucka deleted the MMMULTISRP-19-create-non-evm-account-from-n-srp branch March 24, 2025 16:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2025
@metamaskbot metamaskbot added the release-12.16.0 Issue or pull request that will be included in release 12.16.0 label Mar 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.16.0 Issue or pull request that will be included in release 12.16.0 team-mmi PRs from the MMI team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants