diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e4476bfaf229..2350c59103ca 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -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} The address of the newly-created account. */ async addNewAccount(accountCount) { const isActionMetricsQueueE2ETest = @@ -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; }