Skip to content

Commit 796d640

Browse files
authored
feat: add new actions to KeyringController (#6928)
## Explanation Added actions for `createNewVaultAndKeychain` and `createNewVaultAndRestore`. These are meant to be consumed by the `createNewMultichainAccountWallet` method in the `MultichainAccountService`. ## References N/A ## 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), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds messenger actions and handlers for `createNewVaultAndKeychain` and `createNewVaultAndRestore`, and documents them in the changelog. > > - **KeyringController**: > - Add action types `KeyringControllerCreateNewVaultAndKeychainAction` and `KeyringControllerCreateNewVaultAndRestoreAction` in `src/KeyringController.ts`. > - Extend `KeyringControllerActions` union to include the new actions. > - Register action handlers for `${name}:createNewVaultAndKeychain` and `${name}:createNewVaultAndRestore`. > - **Docs**: > - Update `packages/keyring-controller/CHANGELOG.md` under Unreleased to note the new actions. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e424f6b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent dfd2a80 commit 796d640

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-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+
- Add actions for `createNewVaultAndKeychain` and `createNewVaultAndRestore` ([#6928](https://github.com/MetaMask/core/pull/6928))
13+
- These actions are meant to to be consumed by the `MultichainAccountService` in its `createMultichainAccountWallet` method.
14+
1015
### Changed
1116

1217
- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))

packages/keyring-controller/src/KeyringController.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ export type KeyringControllerWithKeyringAction = {
184184
handler: KeyringController['withKeyring'];
185185
};
186186

187+
export type KeyringControllerCreateNewVaultAndKeychainAction = {
188+
type: `${typeof name}:createNewVaultAndKeychain`;
189+
handler: KeyringController['createNewVaultAndKeychain'];
190+
};
191+
192+
export type KeyringControllerCreateNewVaultAndRestoreAction = {
193+
type: `${typeof name}:createNewVaultAndRestore`;
194+
handler: KeyringController['createNewVaultAndRestore'];
195+
};
196+
187197
export type KeyringControllerAddNewKeyringAction = {
188198
type: `${typeof name}:addNewKeyring`;
189199
handler: KeyringController['addNewKeyring'];
@@ -226,7 +236,9 @@ export type KeyringControllerActions =
226236
| KeyringControllerSignUserOperationAction
227237
| KeyringControllerAddNewAccountAction
228238
| KeyringControllerWithKeyringAction
229-
| KeyringControllerAddNewKeyringAction;
239+
| KeyringControllerAddNewKeyringAction
240+
| KeyringControllerCreateNewVaultAndKeychainAction
241+
| KeyringControllerCreateNewVaultAndRestoreAction;
230242

231243
export type KeyringControllerEvents =
232244
| KeyringControllerStateChangeEvent
@@ -1780,6 +1792,16 @@ export class KeyringController extends BaseController<
17801792
`${name}:addNewKeyring`,
17811793
this.addNewKeyring.bind(this),
17821794
);
1795+
1796+
this.messagingSystem.registerActionHandler(
1797+
`${name}:createNewVaultAndKeychain`,
1798+
this.createNewVaultAndKeychain.bind(this),
1799+
);
1800+
1801+
this.messagingSystem.registerActionHandler(
1802+
`${name}:createNewVaultAndRestore`,
1803+
this.createNewVaultAndRestore.bind(this),
1804+
);
17831805
}
17841806

17851807
/**

0 commit comments

Comments
 (0)