From 9529284905940f15dd699132b2113ccecfe9e301 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Mon, 31 Jul 2023 15:19:39 +0200 Subject: [PATCH] refactor: use getAccounts to check if account is new --- app/scripts/metamask-controller.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7eb291d89605..59b9d3720c24 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3388,13 +3388,12 @@ export default class MetamaskController extends EventEmitter { await new Promise((resolve) => setTimeout(resolve, 5_000)); } - const { identities: oldIdentities } = - this.preferencesController.store.getState(); + const oldAccounts = await this.coreKeyringController.getAccounts(); const { addedAccountAddress } = await this.coreKeyringController.addNewAccount(accountCount); - if (Object.keys(oldIdentities).length === accountCount) { + if (!oldAccounts.includes(addedAccountAddress)) { this.preferencesController.setSelectedAddress(addedAccountAddress); }