-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add TrezorKeyringV2 (and OneKeyKeyringV2)
#412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0beaae5 to
5dfac85
Compare
5dfac85 to
9d07ffc
Compare
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 <[email protected]>
- 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 <[email protected]>
|
@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 <[email protected]>
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 <[email protected]>
fb7ac91 to
6180102
Compare
ccharly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 💪
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.