From 884d3444af1d1d10473ac787e52f023ab9711c41 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Thu, 24 Oct 2024 14:26:24 +0200 Subject: [PATCH 1/3] chore: remove `addNewAccountWithoutUpdate` --- .../src/KeyringController.test.ts | 26 ------------------- .../src/KeyringController.ts | 19 -------------- 2 files changed, 45 deletions(-) diff --git a/packages/keyring-controller/src/KeyringController.test.ts b/packages/keyring-controller/src/KeyringController.test.ts index 10a2c5311f..d8e6218725 100644 --- a/packages/keyring-controller/src/KeyringController.test.ts +++ b/packages/keyring-controller/src/KeyringController.test.ts @@ -361,32 +361,6 @@ describe('KeyringController', () => { }); }); - describe('addNewAccountWithoutUpdate', () => { - it('should add new account without updating', async () => { - await withController(async ({ controller, initialState }) => { - await controller.addNewAccountWithoutUpdate(); - expect(initialState.keyrings).toHaveLength(1); - expect(initialState.keyrings[0].accounts).not.toStrictEqual( - controller.state.keyrings[0].accounts, - ); - expect(controller.state.keyrings[0].accounts).toHaveLength(2); - // we make sure that updateIdentities is not called - // during this test - }); - }); - - it('should throw error with no HD keyring', async () => { - await withController( - { skipVaultCreation: true }, - async ({ controller }) => { - await expect(controller.addNewAccountWithoutUpdate()).rejects.toThrow( - 'No HD keyring found', - ); - }, - ); - }); - }); - describe('addNewKeyring', () => { describe('when there is a builder for the given type', () => { it('should add new keyring', async () => { diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 3e15c3f5b5..375397fd60 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -732,25 +732,6 @@ export class KeyringController extends BaseController< }); } - /** - * Adds a new account to the default (first) HD seed phrase keyring without updating identities in preferences. - * - * @returns Promise resolving to the added account address. - */ - async addNewAccountWithoutUpdate(): Promise { - return this.#persistOrRollback(async () => { - const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0] as - | EthKeyring - | undefined; - if (!primaryKeyring) { - throw new Error('No HD keyring found'); - } - const [addedAccountAddress] = await primaryKeyring.addAccounts(1); - await this.verifySeedPhrase(); - return addedAccountAddress; - }); - } - /** * Effectively the same as creating a new keychain then populating it * using the given seed phrase. From eb5742b84cb68a9bbd8490814c85b0dc99288341 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Thu, 24 Oct 2024 14:31:11 +0200 Subject: [PATCH 2/3] update changelog --- packages/keyring-controller/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index 5e152c33a6..b509c88d41 100644 --- a/packages/keyring-controller/CHANGELOG.md +++ b/packages/keyring-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- **BREAKING** Remove `addNewAccountWithoutUpdate` method ([#4845](https://github.com/MetaMask/core/pull/4845)) + ## [17.3.0] ### Changed From f00185b7b0b62b8b0b50cfa503e464b31e731cf3 Mon Sep 17 00:00:00 2001 From: Michele Esposito Date: Thu, 24 Oct 2024 14:33:55 +0200 Subject: [PATCH 3/3] adjust jest coverage threshold --- packages/keyring-controller/jest.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/keyring-controller/jest.config.js b/packages/keyring-controller/jest.config.js index 912580f270..3dbee99897 100644 --- a/packages/keyring-controller/jest.config.js +++ b/packages/keyring-controller/jest.config.js @@ -19,8 +19,8 @@ module.exports = merge(baseConfig, { global: { branches: 95.51, functions: 100, - lines: 99.08, - statements: 99.09, + lines: 99.07, + statements: 99.08, }, },