Skip to content

Commit

Permalink
Merge branch 'main' into 3429--tokenlist-polling-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish authored Nov 5, 2024
2 parents 22f474a + 5f6b020 commit e3b867f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 47 deletions.
4 changes: 4 additions & 0 deletions packages/keyring-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.1]

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/keyring-controller/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},

Expand Down
26 changes: 0 additions & 26 deletions packages/keyring-controller/src/KeyringController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
19 changes: 0 additions & 19 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
return this.#persistOrRollback(async () => {
const primaryKeyring = this.getKeyringsByType('HD Key Tree')[0] as
| EthKeyring<Json>
| 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.
Expand Down

0 comments on commit e3b867f

Please sign in to comment.