Skip to content

Commit b2da989

Browse files
authored
feat: add removeAccount action (#7241)
## Explanation Added an action for `removeAccount` in the keyring controller. Meant to be used in the `MultichainAccountService` inside of a remove wallet method. ## References NA ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Exposes `removeAccount` via `KeyringController` messenger and documents it in the changelog. > > - **Keyring Controller**: > - Add `KeyringControllerRemoveAccountAction` type and include it in `KeyringControllerActions`. > - Register `${name}:removeAccount` handler in `#registerMessageHandlers` to invoke `removeAccount`. > - **Docs**: > - Update `packages/keyring-controller/CHANGELOG.md` under Unreleased to mention the new `removeAccount` action. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a3eccba. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2b5cd5f commit b2da989

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/keyring-controller/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added an action to call `removeAccount` ([#7241](https://github.com/MetaMask/core/pull/7241))
13+
- This action is meant to be consumed by the `MultichainAccountService` to encapsulate the act of removing a wallet when seed phrase backup fails in the clients.
14+
1015
## [25.0.0]
1116

1217
### Added

packages/keyring-controller/src/KeyringController.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ export type KeyringControllerAddNewKeyringAction = {
199199
handler: KeyringController['addNewKeyring'];
200200
};
201201

202+
export type KeyringControllerRemoveAccountAction = {
203+
type: `${typeof name}:removeAccount`;
204+
handler: KeyringController['removeAccount'];
205+
};
206+
202207
export type KeyringControllerStateChangeEvent = {
203208
type: `${typeof name}:stateChange`;
204209
payload: [KeyringControllerState, Patch[]];
@@ -238,7 +243,8 @@ export type KeyringControllerActions =
238243
| KeyringControllerWithKeyringAction
239244
| KeyringControllerAddNewKeyringAction
240245
| KeyringControllerCreateNewVaultAndKeychainAction
241-
| KeyringControllerCreateNewVaultAndRestoreAction;
246+
| KeyringControllerCreateNewVaultAndRestoreAction
247+
| KeyringControllerRemoveAccountAction;
242248

243249
export type KeyringControllerEvents =
244250
| KeyringControllerStateChangeEvent
@@ -1817,6 +1823,11 @@ export class KeyringController<
18171823
`${name}:createNewVaultAndRestore`,
18181824
this.createNewVaultAndRestore.bind(this),
18191825
);
1826+
1827+
this.messenger.registerActionHandler(
1828+
`${name}:removeAccount`,
1829+
this.removeAccount.bind(this),
1830+
);
18201831
}
18211832

18221833
/**

0 commit comments

Comments
 (0)