Skip to content

Commit

Permalink
refactor: select account only when is new
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Jul 28, 2023
1 parent 6b796b5 commit 500075f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,7 @@ export default class MetamaskController extends EventEmitter {
* Adds a new account to the default (first) HD seed phrase Keyring.
*
* @param accountCount
* @returns {} keyState
* @returns {Promise<string>} The address of the newly-created account.
*/
async addNewAccount(accountCount) {
const isActionMetricsQueueE2ETest =
Expand All @@ -3371,10 +3371,15 @@ export default class MetamaskController extends EventEmitter {
await new Promise((resolve) => setTimeout(resolve, 5_000));
}

const { identities: oldIdentities } =
this.preferencesController.store.getState();

const { addedAccountAddress } =
await this.coreKeyringController.addNewAccount(accountCount);

this.preferencesController.setSelectedAddress(addedAccountAddress);
if (!oldIdentities[addedAccountAddress]) {
this.preferencesController.setSelectedAddress(addedAccountAddress);
}

return addedAccountAddress;
}
Expand Down

0 comments on commit 500075f

Please sign in to comment.