-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Conversation
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. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations
🖥️ @MetaMask/wallet-ux
|
Builds ready [076bf65]
UI Startup Metrics (1165 ± 64 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3c470fc]
UI Startup Metrics (1191 ± 63 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [53eeaff]
UI Startup Metrics (1193 ± 54 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
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}`; | ||
} |
There was a problem hiding this comment.
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:
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?
ui/components/multichain/create-snap-account/create-snap-account.tsx
Outdated
Show resolved
Hide resolved
…nt.tsx Co-authored-by: Charly Chevalier <[email protected]>
Builds ready [9f33348]
UI Startup Metrics (1223 ± 68 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
This PR temporarily changes the default suggested name of a first party snap account to reflect the network.
Related issues
Fixes:
Manual testing steps
Solana Account 1
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist