From 2abdb29b87d3dc8e17bd85fae40e77fdd5d4fa78 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 3e34561568b6..17089dd29302 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3371,13 +3371,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); }