Skip to content

refactor!: LedgerKeyring implements Keyring type - #194

Merged
mikesposito merged 22 commits into
mainfrom
mikesposito/ledger-keyring-type
Feb 19, 2025
Merged

mikesposito merged 22 commits into
mainfrom
mikesposito/ledger-keyring-type

Conversation

@mikesposito

@mikesposito mikesposito commented Feb 5, 2025 •

Copy link
Copy Markdown
Member

The LedgerKeyring is being overhauled to implement the Keyring type from @metamask/keyring-utils. Most of the changes are due to the addresses type that is now Hex

Changed

  • BREAKING: LedgerKeyring now implements the Keyring type (#194)
    • The class does not extend EventEmitter anymore.
    • The LedgerKeyring.accounts class variable is now a readonly Hex[] array.
    • The addAccounts method signature has been changed
      • An amount number parameter is now required to specify the number of accounts to add.
      • The method now returns a promise resolving to an array of Hex addresses.
    • The unlock method now returns Promise<Hex>
    • The getAccounts method now returns Promise<Hex[]>
    • The deserialize method now requires a LedgerKeyringSerializedState typed parameter
    • The signTransaction method now accepts an Hex typed value as the address parameter
    • The signMessage method now accepts an Hex typed value as the withAccount parameter
    • The signPersonalMessage method now accepts an Hex typed value as the withAccount parameter
    • The signTypedData method now accepts an Hex typed value as the withAccount parameter
    • The unlockAccountByAddress method now accepts an Hex typed value as the address parameter

Removed

  • BREAKING: The exportAccount method has been removed

@mikesposito
mikesposito marked this pull request as ready for review February 5, 2025 12:36
@mikesposito
mikesposito requested a review from a team as a code owner February 5, 2025 12:36
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
@mikesposito
mikesposito marked this pull request as draft February 5, 2025 15:48
@mikesposito

This comment has been minimized.

@mikesposito
mikesposito marked this pull request as ready for review February 18, 2025 14:06
Comment thread packages/keyring-eth-ledger-bridge/CHANGELOG.md Outdated
Comment thread packages/keyring-eth-ledger-bridge/CHANGELOG.md Outdated
Comment thread packages/keyring-eth-ledger-bridge/CHANGELOG.md Outdated
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.test.ts
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts Outdated
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
Comment thread packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts Outdated
ccharly
ccharly previously approved these changes Feb 19, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Feb 19, 2025
The `TrezorKeyring` is being overhauled to implement the `Keyring` type
from `@metamask/utils`. Most of the changes are due to the addresses
type that is now `Hex`

```
### Changed

- **BREAKING:** `TrezorKeyring` now implements the `Keyring` type ([#194](#194))
  - The class does not extend `EventEmitter` anymore.
  - The `TrezorKeyring.accounts` class variable is now a `readonly Hex[]` array.
  - The `addAccounts` method signature has been changed
    - An `amount` number parameter is now required to specify the number of accounts to add.
    - The method now returns a promise resolving to an array of `Hex` addresses.
  - The `deserialize` method now requires a `TrezorControllerOptions` object as a parameter.
  - The `unlock` method now returns `Promise<Hex>`
  - The `getAccounts` method now returns `Promise<Hex[]>`
  - The `signTransaction` method now accepts an `Hex` typed value as the `address` parameter
  - The `signMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signPersonalMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signTypedData` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `unlockAccountByAddress` method now accepts an `Hex` typed value as the `address` parameter

### Removed

- **BREAKING:** The `exportAccount` method has been removed
```

* Fixes: #142

---------

Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
@mikesposito
mikesposito added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 6a53bf0 Feb 19, 2025
@mikesposito
mikesposito deleted the mikesposito/ledger-keyring-type branch February 19, 2025 14:35
ccharly added a commit that referenced this pull request Feb 20, 2025
The `TrezorKeyring` is being overhauled to implement the `Keyring` type
from `@metamask/utils`. Most of the changes are due to the addresses
type that is now `Hex`

```
### Changed

- **BREAKING:** `TrezorKeyring` now implements the `Keyring` type ([#194](#194))
  - The class does not extend `EventEmitter` anymore.
  - The `TrezorKeyring.accounts` class variable is now a `readonly Hex[]` array.
  - The `addAccounts` method signature has been changed
    - An `amount` number parameter is now required to specify the number of accounts to add.
    - The method now returns a promise resolving to an array of `Hex` addresses.
  - The `deserialize` method now requires a `TrezorControllerOptions` object as a parameter.
  - The `unlock` method now returns `Promise<Hex>`
  - The `getAccounts` method now returns `Promise<Hex[]>`
  - The `signTransaction` method now accepts an `Hex` typed value as the `address` parameter
  - The `signMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signPersonalMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signTypedData` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `unlockAccountByAddress` method now accepts an `Hex` typed value as the `address` parameter

### Removed

- **BREAKING:** The `exportAccount` method has been removed
```

* Fixes: #142

---------

Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
ccharly added a commit that referenced this pull request Feb 20, 2025
The `LedgerKeyring` is being overhauled to implement the `Keyring` type
from `@metamask/keyring-utils`. Most of the changes are due to the
addresses type that is now `Hex`

### Changed

- **BREAKING:** `LedgerKeyring` now implements the `Keyring` type
([#194](#194))
  - The class does not extend `EventEmitter` anymore.
- The `LedgerKeyring.accounts` class variable is now a `readonly Hex[]`
array.
  - The `addAccounts` method signature has been changed
- An `amount` number parameter is now required to specify the number of
accounts to add.
- The method now returns a promise resolving to an array of `Hex`
addresses.
  - The `unlock` method now returns `Promise<Hex>`
  - The `getAccounts` method now returns `Promise<Hex[]>`
- The `deserialize` method now requires a `LedgerKeyringSerializedState`
typed parameter
- The `signTransaction` method now accepts an `Hex` typed value as the
`address` parameter
- The `signMessage` method now accepts an `Hex` typed value as the
`withAccount` parameter
- The `signPersonalMessage` method now accepts an `Hex` typed value as
the `withAccount` parameter
- The `signTypedData` method now accepts an `Hex` typed value as the
`withAccount` parameter
- The `unlockAccountByAddress` method now accepts an `Hex` typed value
as the `address` parameter

### Removed

- **BREAKING:** The `exportAccount` method has been removed

---
* Fixes: #143

---------

Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
github-merge-queue Bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Mar 7, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
These packages are being bumped to their latest version:
### `@metamask/keyring-controller`

- **BREAKING:** `addNewKeyring` method now returns
`Promise<KeyringMetadata>` instead of `Promise<unknown>`
([#5372](MetaMask/core#5372))
- Consumers can use the returned `KeyringMetadata.id` to access the
created keyring instance via `withKeyring`.
- **BREAKING:** `withKeyring` method now requires a callback argument of
type `({ keyring: SelectedKeyring; metadata: KeyringMetadata }) =>
Promise<CallbackResult>`
([#5372](MetaMask/core#5372))
- Bump `@metamask/keyring-internal-api` from `^4.0.3` to `^5.0.0`
([#5405](MetaMask/core#5405))
- Bump `@metamask/eth-hd-keyring` from `^10.0.0` to `^11.0.0`
([#5405](MetaMask/core#5405))
- Bump `@metamask/eth-simple-keyring` from `^8.1.0` to `^9.0.0`
([#5405](MetaMask/core#5405))

### `@metamask/profile-sync-controller`

- Bump `@metamask/keyring-internal-api` from `^4.0.3` to `^5.0.0`
([#5405](MetaMask/core#5405))

### `@metamask/eth-ledger-bridge-keyring`
- **BREAKING:** `LedgerKeyring` now implements the `Keyring` type
([#194](MetaMask/accounts#194))
    - The class does not extend `EventEmitter` anymore.
- The `LedgerKeyring.accounts` class variable is now a `readonly Hex[]`
array.
    - The `addAccounts` method signature has been changed:
- An `amount` number parameter is now required to specify the number of
accounts to add.
- The method now returns a promise resolving to an array of `Hex`
addresses.
    - The `unlock` method now returns `Promise<Hex>`.
    - The `getAccounts` method now returns `Promise<Hex[]>`.
- The `deserialize` method now requires a `LedgerKeyringSerializedState`
typed parameter.
- The `signTransaction` method now accepts an `Hex` typed value as the
`address` parameter.
- The `signMessage` method now accepts an `Hex` typed value as the
`withAccount` parameter.
- The `signPersonalMessage` method now accepts an `Hex` typed value as
the `withAccount` parameter.
- The `signTypedData` method now accepts an `Hex` typed value as the
`withAccount` parameter.
- The `unlockAccountByAddress` method now accepts an `Hex` typed value
as the `address` parameter.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/30637?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
montelaidev pushed a commit that referenced this pull request Sep 21, 2026
The `TrezorKeyring` is being overhauled to implement the `Keyring` type
from `@metamask/utils`. Most of the changes are due to the addresses
type that is now `Hex`

```
### Changed

- **BREAKING:** `TrezorKeyring` now implements the `Keyring` type ([#194](#194))
  - The class does not extend `EventEmitter` anymore.
  - The `TrezorKeyring.accounts` class variable is now a `readonly Hex[]` array.
  - The `addAccounts` method signature has been changed
    - An `amount` number parameter is now required to specify the number of accounts to add.
    - The method now returns a promise resolving to an array of `Hex` addresses.
  - The `deserialize` method now requires a `TrezorControllerOptions` object as a parameter.
  - The `unlock` method now returns `Promise<Hex>`
  - The `getAccounts` method now returns `Promise<Hex[]>`
  - The `signTransaction` method now accepts an `Hex` typed value as the `address` parameter
  - The `signMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signPersonalMessage` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `signTypedData` method now accepts an `Hex` typed value as the `withAccount` parameter
  - The `unlockAccountByAddress` method now accepts an `Hex` typed value as the `address` parameter

### Removed

- **BREAKING:** The `exportAccount` method has been removed
```

* Fixes: #142

---------

Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
montelaidev pushed a commit that referenced this pull request Sep 21, 2026
The `LedgerKeyring` is being overhauled to implement the `Keyring` type
from `@metamask/keyring-utils`. Most of the changes are due to the
addresses type that is now `Hex`

### Changed

- **BREAKING:** `LedgerKeyring` now implements the `Keyring` type
([#194](#194))
  - The class does not extend `EventEmitter` anymore.
- The `LedgerKeyring.accounts` class variable is now a `readonly Hex[]`
array.
  - The `addAccounts` method signature has been changed
- An `amount` number parameter is now required to specify the number of
accounts to add.
- The method now returns a promise resolving to an array of `Hex`
addresses.
  - The `unlock` method now returns `Promise<Hex>`
  - The `getAccounts` method now returns `Promise<Hex[]>`
- The `deserialize` method now requires a `LedgerKeyringSerializedState`
typed parameter
- The `signTransaction` method now accepts an `Hex` typed value as the
`address` parameter
- The `signMessage` method now accepts an `Hex` typed value as the
`withAccount` parameter
- The `signPersonalMessage` method now accepts an `Hex` typed value as
the `withAccount` parameter
- The `signTypedData` method now accepts an `Hex` typed value as the
`withAccount` parameter
- The `unlockAccountByAddress` method now accepts an `Hex` typed value
as the `address` parameter

### Removed

- **BREAKING:** The `exportAccount` method has been removed

---
* Fixes: #143

---------

Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LedgerKeyring class from @metamask/eth-ledger-bridge-keyring should implement the Keyring type

2 participants