feat: add TrezorKeyringV2 (and OneKeyKeyringV2)#412
Merged
mathieuartu merged 22 commits intomainfrom Jan 15, 2026
Merged
Conversation
0beaae5 to
5dfac85
Compare
5dfac85 to
9d07ffc
Compare
gantunesr
reviewed
Jan 7, 2026
gantunesr
previously approved these changes
Jan 7, 2026
ccharly
reviewed
Jan 14, 2026
When using bip44:derive-path, normalize the derivation path after parsing to avoid mismatches when the input path has leading zeros in the index (e.g., 'm/44'/60'/0'/0/007' becomes 'm/44'/60'/0'/0/7'). This ensures the existing account check correctly identifies duplicate requests even when the path is specified with leading zeros. Co-authored-by: mathieu.artu <mathieu.artu@consensys.net>
ccharly
reviewed
Jan 14, 2026
- Define individual path constants (BIP44_HD_PATH_PREFIX, LEGACY_MEW_PATH, SLIP0044_TESTNET_PATH) - Create ALLOWED_HD_PATHS const array from these paths - Derive AllowedHdPath type from the const array using typeof - Use simpler regex pattern to extract prefix/index, then validate prefix with isAllowedHdPath helper - Improves consistency with legacy keyring pattern and makes allowed paths more maintainable Co-authored-by: mathieu.artu <mathieu.artu@consensys.net>
Contributor
Author
|
@cursor following commits 972590d and 913af51 (LedgerKeyringV2 now present in the branch), and knowing that your latest changes introduced those lint errors, please iron out your first pass on this comment (#412 (comment)) and make it better. Error: 44:30 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion
Error: 49:25 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion
Error: 54:31 error This assertion is unnecessary since it does not change the type of the expression @typescript-eslint/no-unnecessary-type-assertion |
|
Fixed the lint errors by removing the unnecessary Changes:
All 91 tests pass and lint now succeeds. |
TypeScript already infers template literal strings as literal types, making the 'as const' assertions redundant and triggering lint errors. Co-authored-by: mathieu.artu <mathieu.artu@consensys.net>
Similar to Ledger keyring v2 approach - use a single regex pattern that
both validates and parses the derivation path, ensuring it matches one
of the allowed Trezor HD paths:
- m/44'/60'/0'/0/{index} (BIP44 standard)
- m/44'/60'/0'/{index} (legacy MEW)
- m/44'/1'/0'/0/{index} (SLIP0044 testnet)
This removes the need for a separate ALLOWED_HD_PATHS const array and
isAllowedHdPath helper function, making the code more consistent with
the Ledger keyring v2 implementation.
Co-authored-by: mathieu.artu <mathieu.artu@consensys.net>
fb7ac91 to
6180102
Compare
ccharly
reviewed
Jan 15, 2026
ccharly
reviewed
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to: https://consensyssoftware.atlassian.net/browse/MUL-1321
Examples
Note
Implements V2 adapters over legacy hardware keyrings to expose accounts via the unified API.
TrezorKeyringV2with capabilities forbip44:derive-indexandbip44:derive-path, derivation path parsing/validation (m/44'/60'/0'/0, legacy MEW, SLIP-0044 testnet), account registry caching, and graceful behavior when the device is lockedOneKeyKeyringV2extendingTrezorKeyringV2withKeyringType.OneKeysrc/index.ts; update package deps to@metamask/keyring-apiand@metamask/account-api, tsconfig references, and README dependency graphtrezor-keyringby exposinggetIndexForAddressand refactoring path lookup; keep serialization behavior intactWritten by Cursor Bugbot for commit 3432867. This will update automatically on new commits. Configure here.