Skip to content

Commit be7e29f

Browse files
fix: add try catch to _addSolanaAccount cp-12.18.0 (#32421)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This adds a try catch to `_addSolanaAccount` to not block the onboarding flow if it fails. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32421?quickstart=1) ## **Related issues** Fixes: #32413 ## **Manual testing steps** 1. Go through IMPORT onboarding flow (until Your Wallet is ready screen) 2. Click Manager default privacy settings 3. Click General 4. Toggle off Basic Functionality 5. Go back to main screen 6. Click Done and continue to finish onboarding 7. See that you are able to go to the wallet overview. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). 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. --------- Co-authored-by: Frederik Bolding <[email protected]>
1 parent f60bf02 commit be7e29f

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

app/scripts/metamask-controller.js

+24-19
Original file line numberDiff line numberDiff line change
@@ -4989,28 +4989,33 @@ export default class MetamaskController extends EventEmitter {
49894989
///: BEGIN:ONLY_INCLUDE_IF(solana)
49904990
async _addSolanaAccount(keyringId) {
49914991
let entropySource = keyringId;
4992-
if (!entropySource) {
4993-
// Get the entropy source from the first HD keyring
4994-
const id = await this.keyringController.withKeyring(
4995-
{ type: KeyringTypes.hd },
4996-
async ({ metadata }) => {
4997-
return metadata.id;
4992+
try {
4993+
if (!entropySource) {
4994+
// Get the entropy source from the first HD keyring
4995+
const id = await this.keyringController.withKeyring(
4996+
{ type: KeyringTypes.hd },
4997+
async ({ metadata }) => {
4998+
return metadata.id;
4999+
},
5000+
);
5001+
entropySource = id;
5002+
}
5003+
5004+
const client = await this._getSolanaWalletSnapClient();
5005+
return await client.createAccount(
5006+
{ entropySource },
5007+
{
5008+
displayConfirmation: false,
5009+
displayAccountNameSuggestion: false,
5010+
setSelectedAccount: false,
49985011
},
49995012
);
5000-
entropySource = id;
5013+
} catch (e) {
5014+
// Do not block the onboarding flow if this fails
5015+
log.warn(`Failed to add Solana account. Error: ${e}`);
5016+
captureException(e);
5017+
return null;
50015018
}
5002-
5003-
const client = await this._getSolanaWalletSnapClient();
5004-
return await client.createAccount(
5005-
{
5006-
entropySource,
5007-
},
5008-
{
5009-
displayConfirmation: false,
5010-
displayAccountNameSuggestion: false,
5011-
setSelectedAccount: false,
5012-
},
5013-
);
50145019
}
50155020
///: END:ONLY_INCLUDE_IF
50165021

0 commit comments

Comments
 (0)