Skip to content

Commit

Permalink
refactor: remove addNewAccount code repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed Jan 26, 2024
1 parent 7db3917 commit 84d9cf4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/keyring-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = merge(baseConfig, {
global: {
branches: 95.17,
functions: 100,
lines: 99.22,
lines: 99.21,
statements: 99.22,
},
},
Expand Down
12 changes: 4 additions & 8 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,13 @@ export class KeyringController extends BaseController<
};
}

await this.addNewAccountForKeyring(primaryKeyring);
const newAccounts = await this.getAccounts();

const addedAccountAddress = await this.addNewAccountForKeyring(
primaryKeyring,
);
await this.verifySeedPhrase();

this.updateIdentities(newAccounts);
const addedAccountAddress = newAccounts.find(
(selectedAddress: string) => !oldAccounts.includes(selectedAddress),
);
this.updateIdentities(await this.getAccounts());

assertIsStrictHexString(addedAccountAddress);
return {
keyringState: this.#getMemState(),
addedAccountAddress,
Expand Down

0 comments on commit 84d9cf4

Please sign in to comment.