Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 42 additions & 11 deletions packages/keyring-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [25.5.0]

### Added

- Expose missing public `KeyringController` methods through its messenger ([#8674](https://github.com/MetaMask/core/pull/8674))
- The following actions are now available:
- `KeyringController:changePassword`,
- `KeyringController:exportAccount`,
- `KeyringController:exportEncryptionKey`,
- `KeyringController:getAccountKeyringType`,
- `KeyringController:importAccountWithStrategy`,
- `KeyringController:setLocked`,
- `KeyringController:submitEncryptionKey`,
- `KeyringController:submitPassword`,
- `KeyringController:verifyPassword`,
- Corresponding action types are available as well.

## [25.4.0]

### Changed

- Bump `@metamask/eth-hd-keyring` from `^14.1.0` to `^14.1.1` ([#8647](https://github.com/MetaMask/core/pull/8647))
- Bump `@metamask/eth-simple-keyring` from `^12.0.1` to `^12.0.2` ([#8647](https://github.com/MetaMask/core/pull/8647))
- Bump `@metamask/keyring-api` from `^23.0.1` to `^23.1.0` ([#8647](https://github.com/MetaMask/core/pull/8647))
- Bump `@metamask/keyring-internal-api` from `^11.0.0` to `^11.0.1` ([#8647](https://github.com/MetaMask/core/pull/8647))

## [25.3.0]

### Added

- Expose `KeyringController:exportSeedPhrase` method through `KeyringController` messenger ([#8587](https://github.com/MetaMask/core/pull/8587))
Expand Down Expand Up @@ -179,8 +207,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/keyring-api` from `^18.0.0` to `^20.0.0` ([#6146](https://github.com/MetaMask/core/pull/6146)), ([#6248](https://github.com/MetaMask/core/pull/6248))
- Bump `@metamask/keyring-internal-api` from `^6.2.0` to `^8.0.0` ([#6146](https://github.com/MetaMask/core/pull/6146)), ([#6248](https://github.com/MetaMask/core/pull/6248))
- Bump `@metamask/keyring-api` from `^18.0.0` to `^20.0.0` ([#6146](https://github.com/MetaMask/core/pull/6146), [#6248](https://github.com/MetaMask/core/pull/6248))
- Bump `@metamask/keyring-internal-api` from `^6.2.0` to `^8.0.0` ([#6146](https://github.com/MetaMask/core/pull/6146), [#6248](https://github.com/MetaMask/core/pull/6248))
- Bump `@metamask/utils` from `^11.2.0` to `^11.4.2` ([#6054](https://github.com/MetaMask/core/pull/6054))

## [22.1.0]
Expand Down Expand Up @@ -304,7 +332,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bump `@metamask/keyring-api"` from `^17.0.0` to `^17.2.0` ([#5366](https://github.com/MetaMask/core/pull/5366))
- Bump `@metamask/keyring-internal-api` from `^4.0.1` to `^4.0.3` ([#5356](https://github.com/MetaMask/core/pull/5356)), ([#5366](https://github.com/MetaMask/core/pull/5366))
- Bump `@metamask/keyring-internal-api` from `^4.0.1` to `^4.0.3` ([#5356](https://github.com/MetaMask/core/pull/5356), [#5366](https://github.com/MetaMask/core/pull/5366))

### Fixed

Expand Down Expand Up @@ -347,7 +375,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/keyring-api` from `^14.0.0` to `^16.1.0` ([#5190](https://github.com/MetaMask/core/pull/5190)), ([#5208](https://github.com/MetaMask/core/pull/5208))
- Bump `@metamask/keyring-api` from `^14.0.0` to `^16.1.0` ([#5190](https://github.com/MetaMask/core/pull/5190), [#5208](https://github.com/MetaMask/core/pull/5208))

## [19.0.4]

Expand All @@ -361,9 +389,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.1` ([#5079](https://github.com/MetaMask/core/pull/5079)), ([#5135](https://github.com/MetaMask/core/pull/5135))
- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.1`, ([#5079](https://github.com/MetaMask/core/pull/5079), [#5135](https://github.com/MetaMask/core/pull/5135))
- Bump `@metamask/keyring-api` from `^12.0.0` to `^13.0.0` ([#5066](https://github.com/MetaMask/core/pull/5066))
- Bump `@metamask/keyring-internal-api` from `^1.0.0` to `^2.0.0` ([#5066](https://github.com/MetaMask/core/pull/5066)), ([#5136](https://github.com/MetaMask/core/pull/5136))
- Bump `@metamask/keyring-internal-api` from `^1.0.0` to `^2.0.0` ([#5066](https://github.com/MetaMask/core/pull/5066), [#5136](https://github.com/MetaMask/core/pull/5136))
- Bump `@metamask/utils` to `^11.0.1` ([#5080](https://github.com/MetaMask/core/pull/5080))
- Bump `@metamask/rpc-errors` to `^7.0.2` ([#5080](https://github.com/MetaMask/core/pull/5080))

Expand Down Expand Up @@ -432,7 +460,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump accounts related packages ([#4713](https://github.com/MetaMask/core/pull/4713)), ([#4728](https://github.com/MetaMask/core/pull/4728))
- Bump accounts related packages ([#4713](https://github.com/MetaMask/core/pull/4713), [#4728](https://github.com/MetaMask/core/pull/4728))
- Those packages are now built slightly differently and are part of the [accounts monorepo](https://github.com/MetaMask/accounts).
- Bump `@metamask/keyring-api` from `^8.1.0` to `^8.1.4`
- Bump `@metamask/eth-hd-keyring` from `^7.0.1` to `^7.0.4`
Expand All @@ -450,7 +478,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
All of the ATTW checks now pass.
- Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648)).
- Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648))
- Previously, the build tool we used to generate JavaScript files extracted
common code to "chunk" files. While this was intended to make this package
more tree-shakeable, it also made debugging more difficult for our
Expand Down Expand Up @@ -896,7 +924,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add `cancelQRSynchronization` method ([#1387](https://github.com/MetaMask/core.git/pull/1387))
- Add `cancelQRSynchronization` method ([#1387](https://github.com/MetaMask/core/pull/1387))

## [5.0.0]

Expand Down Expand Up @@ -950,7 +978,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **BREAKING:**: Bump eth-keyring-controller version to @metamask/eth-keyring-controller v10 ([#1072](https://github.com/MetaMask/core.git/pull/1072))
- **BREAKING:**: Bump eth-keyring-controller version to @metamask/eth-keyring-controller v10 ([#1072](https://github.com/MetaMask/core/pull/1072))
- `exportSeedPhrase` now returns a `Uint8Array` typed SRP (can be converted to a string using [this approach](https://github.com/MetaMask/eth-hd-keyring/blob/53b0570559595ba5b3fd8c80e900d847cd6dee3d/index.js#L40)). It was previously a Buffer.
- The HD keyring included with the keyring controller has been updated from v4 to v6. See [the `eth-hd-keyring` changelog entries for v5 and v6](https://github.com/MetaMask/eth-hd-keyring/blob/main/CHANGELOG.md#600) for further details on breaking changes.

Expand Down Expand Up @@ -980,7 +1008,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

All changes listed after this point were applied to this package following the monorepo conversion.

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.2.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.5.0...HEAD
[25.5.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.4.0...@metamask/keyring-controller@25.5.0
[25.4.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.3.0...@metamask/keyring-controller@25.4.0
[25.3.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.2.0...@metamask/keyring-controller@25.3.0
[25.2.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.1.1...@metamask/keyring-controller@25.2.0
[25.1.1]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.1.0...@metamask/keyring-controller@25.1.1
[25.1.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@25.0.0...@metamask/keyring-controller@25.1.0
Expand Down
12 changes: 6 additions & 6 deletions packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/keyring-controller",
"version": "25.2.0",
"version": "25.5.0",
"description": "Stores identities seen in the wallet and manages interactions such as signing",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -56,11 +56,11 @@
"@ethereumjs/util": "^9.1.0",
"@metamask/base-controller": "^9.1.0",
"@metamask/browser-passworder": "^6.0.0",
"@metamask/eth-hd-keyring": "^14.1.0",
"@metamask/eth-hd-keyring": "^14.1.1",
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/eth-simple-keyring": "^12.0.1",
"@metamask/keyring-api": "^23.0.1",
"@metamask/keyring-internal-api": "^11.0.0",
"@metamask/eth-simple-keyring": "^12.0.2",
"@metamask/keyring-api": "^23.1.0",
"@metamask/keyring-internal-api": "^11.0.1",
"@metamask/messenger": "^1.2.0",
"@metamask/utils": "^11.9.0",
"async-mutex": "^0.5.0",
Expand All @@ -75,7 +75,7 @@
"@lavamoat/allow-scripts": "^3.0.4",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^6.1.0",
"@metamask/keyring-utils": "^3.1.0",
"@metamask/keyring-utils": "^3.2.1",
"@metamask/scure-bip39": "^2.1.1",
"@ts-bridge/cli": "^0.6.4",
"@types/jest": "^29.5.14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export type KeyringControllerAddNewKeyringAction = {
handler: KeyringController['addNewKeyring'];
};

/**
* Method to verify a given password validity. Throws an
* error if the password is invalid.
*
* @param password - Password of the keyring.
*/
export type KeyringControllerVerifyPasswordAction = {
type: `KeyringController:verifyPassword`;
handler: KeyringController['verifyPassword'];
};

/**
* Returns the status of the vault.
*
Expand All @@ -80,6 +91,18 @@ export type KeyringControllerExportSeedPhraseAction = {
handler: KeyringController['exportSeedPhrase'];
};

/**
* Gets the private key from the keyring controlling an address.
*
* @param password - Password of the keyring.
* @param address - Address to export.
* @returns Promise resolving to the private key for an address.
*/
export type KeyringControllerExportAccountAction = {
type: `KeyringController:exportAccount`;
handler: KeyringController['exportAccount'];
};

/**
* Returns the public addresses of all accounts from every keyring.
*
Expand Down Expand Up @@ -157,6 +180,19 @@ export type KeyringControllerPersistAllKeyringsAction = {
handler: KeyringController['persistAllKeyrings'];
};

/**
* Imports an account with the specified import strategy.
*
* @param strategy - Import strategy name.
* @param args - Array of arguments to pass to the underlying stategy.
* @throws Will throw when passed an unrecognized strategy.
* @returns Promise resolving to the imported account address.
*/
export type KeyringControllerImportAccountWithStrategyAction = {
type: `KeyringController:importAccountWithStrategy`;
handler: KeyringController['importAccountWithStrategy'];
};

/**
* Removes an account from keyring state.
*
Expand All @@ -169,6 +205,16 @@ export type KeyringControllerRemoveAccountAction = {
handler: KeyringController['removeAccount'];
};

/**
* Deallocates all secrets and locks the wallet.
*
* @returns Promise resolving when the operation completes.
*/
export type KeyringControllerSetLockedAction = {
type: `KeyringController:setLocked`;
handler: KeyringController['setLocked'];
};

/**
* Signs message by calling down into a specific keyring.
*
Expand Down Expand Up @@ -269,6 +315,53 @@ export type KeyringControllerSignUserOperationAction = {
handler: KeyringController['signUserOperation'];
};

/**
* Changes the password used to encrypt the vault.
*
* @param password - The new password.
* @returns Promise resolving when the operation completes.
*/
export type KeyringControllerChangePasswordAction = {
type: `KeyringController:changePassword`;
handler: KeyringController['changePassword'];
};

/**
* Attempts to decrypt the current vault and load its keyrings, using the
* given encryption key and salt. The optional salt can be used to check for
* consistency with the vault salt.
*
* @param encryptionKey - Key to unlock the keychain.
* @param encryptionSalt - Optional salt to unlock the keychain.
* @returns Promise resolving when the operation completes.
*/
export type KeyringControllerSubmitEncryptionKeyAction = {
type: `KeyringController:submitEncryptionKey`;
handler: KeyringController['submitEncryptionKey'];
};

/**
* Exports the vault encryption key.
*
* @returns The vault encryption key.
*/
export type KeyringControllerExportEncryptionKeyAction = {
type: `KeyringController:exportEncryptionKey`;
handler: KeyringController['exportEncryptionKey'];
};

/**
* Attempts to decrypt the current vault and load its keyrings,
* using the given password.
*
* @param password - Password to unlock the keychain.
* @returns Promise resolving when the operation completes.
*/
export type KeyringControllerSubmitPasswordAction = {
type: `KeyringController:submitPassword`;
handler: KeyringController['submitPassword'];
};

/**
* Select a keyring and execute the given operation with
* the selected keyring, as a mutually exclusive atomic
Expand Down Expand Up @@ -415,6 +508,17 @@ export type KeyringControllerWithControllerAction = {
handler: KeyringController['withController'];
};

/**
* Gets the type of the keyring that manages the specified account.
*
* @param account - The account address to look up.
* @returns A promise that resolves to the type of the keyring managing the account.
*/
export type KeyringControllerGetAccountKeyringTypeAction = {
type: `KeyringController:getAccountKeyringType`;
handler: KeyringController['getAccountKeyringType'];
};

/**
* Union of all KeyringController action types.
*/
Expand All @@ -423,15 +527,19 @@ export type KeyringControllerMethodActions =
| KeyringControllerCreateNewVaultAndRestoreAction
| KeyringControllerCreateNewVaultAndKeychainAction
| KeyringControllerAddNewKeyringAction
| KeyringControllerVerifyPasswordAction
| KeyringControllerIsUnlockedAction
| KeyringControllerExportSeedPhraseAction
| KeyringControllerExportAccountAction
| KeyringControllerGetAccountsAction
| KeyringControllerGetEncryptionPublicKeyAction
| KeyringControllerDecryptMessageAction
| KeyringControllerGetKeyringForAccountAction
| KeyringControllerGetKeyringsByTypeAction
| KeyringControllerPersistAllKeyringsAction
| KeyringControllerImportAccountWithStrategyAction
| KeyringControllerRemoveAccountAction
| KeyringControllerSetLockedAction
| KeyringControllerSignMessageAction
| KeyringControllerSignEip7702AuthorizationAction
| KeyringControllerSignPersonalMessageAction
Expand All @@ -440,8 +548,13 @@ export type KeyringControllerMethodActions =
| KeyringControllerPrepareUserOperationAction
| KeyringControllerPatchUserOperationAction
| KeyringControllerSignUserOperationAction
| KeyringControllerChangePasswordAction
| KeyringControllerSubmitEncryptionKeyAction
| KeyringControllerExportEncryptionKeyAction
| KeyringControllerSubmitPasswordAction
| KeyringControllerWithKeyringAction
| KeyringControllerWithKeyringUnsafeAction
| KeyringControllerWithKeyringV2Action
| KeyringControllerWithKeyringV2UnsafeAction
| KeyringControllerWithControllerAction;
| KeyringControllerWithControllerAction
| KeyringControllerGetAccountKeyringTypeAction;
15 changes: 15 additions & 0 deletions packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ const MESSENGER_EXPOSED_METHODS = [
'removeAccount',
'isUnlocked',
'exportSeedPhrase',
'changePassword',
'exportAccount',
'exportEncryptionKey',
'getAccountKeyringType',
'importAccountWithStrategy',
'setLocked',
'submitEncryptionKey',
'submitPassword',
'verifyPassword',
] as const;

/**
Expand Down Expand Up @@ -2207,6 +2216,12 @@ export class KeyringController<
});
}

/**
* Gets the type of the keyring that manages the specified account.
*
* @param account - The account address to look up.
* @returns A promise that resolves to the type of the keyring managing the account.
*/
async getAccountKeyringType(account: string): Promise<string> {
this.#assertIsUnlocked();

Expand Down
9 changes: 9 additions & 0 deletions packages/keyring-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export type {
KeyringControllerWithKeyringV2Action,
KeyringControllerWithKeyringV2UnsafeAction,
KeyringControllerExportSeedPhraseAction,
KeyringControllerVerifyPasswordAction,
KeyringControllerExportAccountAction,
KeyringControllerImportAccountWithStrategyAction,
KeyringControllerSetLockedAction,
KeyringControllerChangePasswordAction,
KeyringControllerSubmitEncryptionKeyAction,
KeyringControllerExportEncryptionKeyAction,
KeyringControllerSubmitPasswordAction,
KeyringControllerGetAccountKeyringTypeAction,
} from './KeyringController-method-action-types';
export type * from './types';
export * from './errors';
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `mm daemon start` spawns the daemon with `--infura-project-id`, `--password`, `--srp` (or the matching env vars).
- `mm daemon call <Action> [<jsonArrayParams>]` dispatches any messenger action over JSON-RPC.
- `mm daemon stop`, `mm daemon status`, `mm daemon purge` manage daemon lifecycle and state.
- Persist daemon state to a SQLite database at `<dataDir>/wallet.db`; subsequent `daemon start` runs reuse the persisted KeyringController vault instead of re-importing the SRP ([#8446](https://github.com/MetaMask/core/pull/8446)).
- `mm wallet unlock` submits the password to the running daemon for cases where it was started without one (or after the keyring was locked via `KeyringController:setLocked`). Accepts `--password <pw>`, falls back to `MM_WALLET_PASSWORD`, and prompts interactively when neither is supplied.
- Persist daemon state to a SQLite database at `<dataDir>/wallet.db`; subsequent `daemon start` runs reuse the persisted KeyringController vault instead of re-importing the SRP, and the daemon auto-unlocks the keyring with the supplied password so keyring-bound messenger actions (signing, `AccountsController:listAccounts`, etc.) work immediately after a restart. `--password` is optional on subsequent runs: omit it to start with a locked keyring and unlock later with `mm wallet unlock` ([#8446](https://github.com/MetaMask/core/pull/8446)).

[Unreleased]: https://github.com/MetaMask/core/
1 change: 1 addition & 0 deletions packages/wallet-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"dependencies": {
"@inquirer/confirm": "^6.0.11",
"@inquirer/password": "^4.0.16",
"@metamask/remote-feature-flag-controller": "^4.2.0",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/utils": "^11.9.0",
Expand Down
Loading
Loading