Skip to content

fix: workaround for first party snap account name suggestion #31542

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 8 commits into from
Apr 4, 2025

Conversation

montelaidev
Copy link
Contributor

@montelaidev montelaidev commented Apr 3, 2025

Description

This PR temporarily changes the default suggested name of a first party snap account to reflect the network.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to account menu
  2. Click on solana
  3. See the suggested name is Solana Account 1

Screenshots/Recordings

Before

Screenshot 2025-04-03 at 15 29 03

After

Screenshot 2025-04-03 at 15 28 45

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

github-actions bot commented Apr 3, 2025

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
Copy link
Collaborator

metamaskbot commented Apr 3, 2025

✨ Files requiring CODEOWNER review ✨

✅ @MetaMask/confirmations

  • ui/pages/confirmations/confirmation/templates/__snapshots__/create-named-snap-account.test.js.snap

🖥️ @MetaMask/wallet-ux

  • ui/components/multichain/account-list-menu/account-list-menu.test.tsx
  • ui/components/multichain/create-account/create-account.tsx
  • ui/components/multichain/create-snap-account/create-snap-account.test.tsx
  • ui/components/multichain/create-snap-account/create-snap-account.tsx

@metamaskbot
Copy link
Collaborator

Builds ready [076bf65]
UI Startup Metrics (1165 ± 64 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1165106515446411971249
load1017882138360947992
domContentLoaded1011875137860943988
domInteractive16134651527
firstPaint813911152348947994
backgroundConnect10652589
firstReactRender20144961935
getState10430768
initialActions001001
loadScripts799673115360825877
setupStore7416278
WebpackHomeuiStartup20891707261420022052330
load16181324203615817241882
domContentLoaded16111321200315617201875
domInteractive171264121453
firstPaint187643455824275
backgroundConnect3014246273073
firstReactRender196533811148594
getState9322389
initialActions317134
loadScripts16021318197615317141853
setupStore23726547249
FirefoxBrowserifyHomeuiStartup13641192195813713901742
load12271060179913312581586
domContentLoaded12271060179913412581586
domInteractive9842204278796
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2316129112431
firstReactRender22182922327
getState7445479
initialActions002001
loadScripts12051042176312912341526
setupStore6432467
WebpackHomeuiStartup14931313202915615331903
load12911146181514113281639
domContentLoaded12911146181514113271639
domInteractive8838161248996
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect24176572538
firstReactRender34285653647
getState8332589
initialActions1010111
loadScripts12691129179214013081618
setupStore7521378
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 351 Bytes (0.01%)
  • ui: 12.1 KiB (0.18%)
  • common: -157 Bytes (0%)

@montelaidev montelaidev marked this pull request as ready for review April 3, 2025 07:33
@montelaidev montelaidev requested a review from a team as a code owner April 3, 2025 07:33
@metamaskbot
Copy link
Collaborator

Builds ready [3c470fc]
UI Startup Metrics (1191 ± 63 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1191106014196312361286
load1039944123557948993
domContentLoaded1032940123157948992
domInteractive16133451630
firstPaint8041541238379249987
backgroundConnect116588910
firstReactRender19133941930
getState10531668
initialActions001001
loadScripts818720101658861895
setupStore8514278
WebpackHomeuiStartup20611640257623721842506
load16041258200218417281937
domContentLoaded15971254198018117231923
domInteractive171265121452
firstPaint1906738863228388
backgroundConnect261484152772
firstReactRender170533531118896
getState1332783889
initialActions216134
loadScripts15901251195417817201898
setupStore28728559219
FirefoxBrowserifyHomeuiStartup13801172190914714271766
load12371056175514012781620
domContentLoaded12361056175514012781620
domInteractive10047203259198
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect251694122652
firstReactRender22193032228
getState7436478
initialActions002001
loadScripts12131040173213812541591
setupStore6429367
WebpackHomeuiStartup15741362207415016381883
load13531179187114413971683
domContentLoaded13531178187114413961682
domInteractive10143199269198
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect27185982947
firstReactRender36295253949
getState10436789
initialActions102111
loadScripts13291157184414313761659
setupStore8644588
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 351 Bytes (0.01%)
  • ui: 12.78 KiB (0.19%)
  • common: 63 Bytes (0%)

@montelaidev montelaidev requested a review from a team as a code owner April 3, 2025 09:11
OGPoyraz
OGPoyraz previously approved these changes Apr 3, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [53eeaff]
UI Startup Metrics (1193 ± 54 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1193107713345412281288
load10409541180481135980
domContentLoaded10349501177481177982
domInteractive16133851627
firstPaint8071741181368253976
backgroundConnect107607910
firstReactRender20156171937
getState11429768
initialActions002001
loadScripts81869494548844903
setupStore8522378
WebpackHomeuiStartup20681663254222322042472
load16081300196517217281917
domContentLoaded16021296194717017221892
domInteractive161255111449
firstPaint205651712162228362
backgroundConnect261479132864
firstReactRender189553521178695
getState1132912889
initialActions214134
loadScripts15941293192216717161867
setupStore24627349189
FirefoxBrowserifyHomeuiStartup14221207210417214561804
load12841080195716713251660
domContentLoaded12841080195616713251660
domInteractive11437281324095
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect23164252532
firstReactRender23194742530
getState6321278
initialActions001001
loadScripts12631058193616713041640
setupStore6416267
WebpackHomeuiStartup15671359208514516181853
load13541169189513613941635
domContentLoaded13531168189513613941635
domInteractive10948390379299
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25184752835
firstReactRender35284843744
getState8431589
initialActions102111
loadScripts13301144187613613661614
setupStore8529389
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 351 Bytes (0.01%)
  • ui: 12.78 KiB (0.19%)
  • common: 63 Bytes (0%)

@montelaidev montelaidev enabled auto-merge April 3, 2025 09:59
Comment on lines 74 to 93
const removeParenthesesAndCapitalizeWordInParentheses = (
text: string,
): string => {
const match = text.match(/\((.*?)\)/u);
if (!match) {
return text;
}
const word = match[1];
return word.charAt(0).toUpperCase() + word.slice(1);
};

const networkNickname = MULTICHAIN_NETWORK_TO_NICKNAME[chainId] ?? '';
const firstPartyAccountName =
removeParenthesesAndCapitalizeWordInParentheses(networkNickname);

switch (clientType) {
case WalletClientType.Bitcoin:
case WalletClientType.Solana: {
return `${firstPartyAccountName} Account ${accountNumber}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that it's temporary, we could maybe use a simpler solution like:

Suggested change
const removeParenthesesAndCapitalizeWordInParentheses = (
text: string,
): string => {
const match = text.match(/\((.*?)\)/u);
if (!match) {
return text;
}
const word = match[1];
return word.charAt(0).toUpperCase() + word.slice(1);
};
const networkNickname = MULTICHAIN_NETWORK_TO_NICKNAME[chainId] ?? '';
const firstPartyAccountName =
removeParenthesesAndCapitalizeWordInParentheses(networkNickname);
switch (clientType) {
case WalletClientType.Bitcoin:
case WalletClientType.Solana: {
return `${firstPartyAccountName} Account ${accountNumber}`;
}
switch (clientType) {
case WalletClientType.Bitcoin:
return `Bitcoin Account ${accountNumber}`;
case WalletClientType.Solana: {
return `Solana Account ${accountNumber}`;
}

And yes, this does not work for testnets, but we don't support them for now, and we can always extend the logic a bit like:

    switch (clientType) {
      case WalletClientType.Bitcoin: {
        if (chainId === MultichainNetworks.BITCOIN_TESTNET) {
          return `Bitcoin Testnet Account ${accountNumber}`;
        }
        return `Bitcoin Account ${accountNumber}`;
      }
      ...
    }

WDYT?

@montelaidev montelaidev requested review from ccharly and OGPoyraz April 3, 2025 14:32
OGPoyraz
OGPoyraz previously approved these changes Apr 3, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [9f33348]
UI Startup Metrics (1223 ± 68 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1223110414986812611362
load10819731281661159987
domContentLoaded10759651276671163982
domInteractive16134151628
firstPaint8291341287410215981
backgroundConnect106335910
firstReactRender19144151933
getState10426679
initialActions001000
loadScripts826715102767862923
setupStore7414278
WebpackHomeuiStartup20841679252619022142353
load16291332199915417351878
domContentLoaded16221328192215017311852
domInteractive171263121455
firstPaint161643245723170
backgroundConnect3312238303564
firstReactRender168533511128295
getState9328489
initialActions812803634
loadScripts16131325189714917261841
setupStore40630077289
FirefoxBrowserifyHomeuiStartup13971218197015614241784
load12511053180414912881609
domContentLoaded12511053180414912881608
domInteractive10339410428897
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect24166992435
firstReactRender24205262430
getState7447678
initialActions002001
loadScripts12291036177214612651568
setupStore6435368
WebpackHomeuiStartup15441353214915415891879
load13311179194614813751651
domContentLoaded13311179194614813751651
domInteractive9136168258996
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25185462732
firstReactRender36297773945
getState8430579
initialActions004111
loadScripts13081160192214713561629
setupStore8525389
Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 550 Bytes (0.01%)
  • common: 0 Bytes (0%)

Copy link
Contributor

@vinnyhoward vinnyhoward left a comment

Choose a reason for hiding this comment

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

LGTM!

@montelaidev montelaidev requested a review from OGPoyraz April 4, 2025 08:26
@montelaidev montelaidev added this pull request to the merge queue Apr 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 4, 2025
@montelaidev montelaidev added this pull request to the merge queue Apr 4, 2025
Merged via the queue into main with commit 25f4fa8 Apr 4, 2025
164 checks passed
@montelaidev montelaidev deleted the fix/mmmultisrp-142 branch April 4, 2025 12:16
@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2025
@metamaskbot metamaskbot added the release-12.17.0 Issue or pull request that will be included in release 12.17.0 label Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.17.0 Issue or pull request that will be included in release 12.17.0 team-accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants