Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4ee267f
feat: add TrezorKeyringV2 (wip)
mathieuartu Dec 11, 2025
e1f95bd
feat: add onekeyv2 wrapper
mathieuartu Dec 11, 2025
07af7ec
fix: reset coverage thresholds
mathieuartu Dec 15, 2025
fa7b362
fix: update coverage thresholds
mathieuartu Dec 15, 2025
2940a89
fix: update CHANGELOG
mathieuartu Dec 15, 2025
9d07ffc
fix: type constraint
mathieuartu Jan 6, 2026
e8e2d73
fix: deserialize issue
mathieuartu Jan 6, 2026
ad5ae06
feat: align logic with latest LedgerKeyringV2 findings
mathieuartu Jan 8, 2026
df14a76
fix: lint issue
mathieuartu Jan 8, 2026
65cd1a0
fix: address cursor PR feedback
mathieuartu Jan 8, 2026
92a41fa
fix: address cursor feedbacks
mathieuartu Jan 12, 2026
6e2aa22
fix: address PR feedbacks
mathieuartu Jan 14, 2026
caa9eb3
fix: normalize derivation path to avoid leading zeros mismatch
cursoragent Jan 14, 2026
972590d
refactor: use ALLOWED_HD_PATHS const for deriving AllowedHdPath type
cursoragent Jan 15, 2026
913af51
Merge branch 'main' into feat/trezor-keyring-v2
mathieuartu Jan 15, 2026
3b41ba2
fix: remove unnecessary 'as const' assertions from HD path constants
cursoragent Jan 15, 2026
34a7e9e
refactor: use specific regex pattern for Trezor path validation
cursoragent Jan 15, 2026
6180102
fix: manually address PR feedback
mathieuartu Jan 15, 2026
bf8a46f
fix: change index for path UT
mathieuartu Jan 15, 2026
ad6515d
fix: address PR feedbacks
mathieuartu Jan 15, 2026
bb65ac5
fix: change path prefix const names + add testnet path prefix UT
mathieuartu Jan 15, 2026
3432867
Merge branch 'main' into feat/trezor-keyring-v2
mathieuartu Jan 15, 2026
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ linkStyle default opacity:0.5
eth_qr_keyring --> keyring_utils;
eth_simple_keyring --> keyring_api;
eth_simple_keyring --> keyring_utils;
eth_trezor_keyring --> keyring_api;
eth_trezor_keyring --> keyring_utils;
eth_trezor_keyring --> account_api;
keyring_internal_api --> keyring_api;
keyring_internal_api --> keyring_utils;
keyring_internal_snap_client --> keyring_api;
Expand Down
6 changes: 6 additions & 0 deletions packages/keyring-eth-trezor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `TrezorKeyringV2` and `OneKeyKeyringV2` classes implementing `KeyringV2` interface ([#412](https://github.com/MetaMask/accounts/pull/412))
- Wraps legacy `TrezorKeyring` and `OneKeyKeyring` to expose accounts via the unified `KeyringV2` API and the `KeyringAccount` type.
- Extends `EthKeyringWrapper` for common Ethereum logic.

## [9.0.0]

### Changed
Expand Down
8 changes: 4 additions & 4 deletions packages/keyring-eth-trezor/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 52.38,
functions: 91.22,
lines: 90.15,
statements: 90.35,
branches: 59.58,
functions: 92.95,
lines: 93.15,
statements: 93.25,
},
},
});
4 changes: 3 additions & 1 deletion packages/keyring-eth-trezor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"@ethereumjs/tx": "^5.4.0",
"@ethereumjs/util": "^9.1.0",
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/keyring-api": "workspace:^",
"@metamask/keyring-utils": "workspace:^",
"@metamask/utils": "^11.1.0",
"@trezor/connect-plugin-ethereum": "^9.0.5",
"@trezor/connect-web": "^9.6.0",
Expand All @@ -59,8 +61,8 @@
"@ethereumjs/common": "^4.4.0",
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/account-api": "workspace:^",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-utils": "workspace:^",
"@ts-bridge/cli": "^0.6.3",
"@types/ethereumjs-tx": "^1.0.1",
"@types/hdkey": "^2.0.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/keyring-eth-trezor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './trezor-keyring';
export * from './trezor-keyring-v2';
export * from './onekey-keyring';
export * from './onekey-keyring-v2';
export type * from './trezor-bridge';
export * from './trezor-connect-bridge';
63 changes: 63 additions & 0 deletions packages/keyring-eth-trezor/src/onekey-keyring-v2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { KeyringType } from '@metamask/keyring-api';

import { OneKeyKeyring } from './onekey-keyring';
import { OneKeyKeyringV2 } from './onekey-keyring-v2';
import type { TrezorBridge } from './trezor-bridge';
import { TrezorKeyringV2 } from './trezor-keyring-v2';

const entropySource = 'onekey-device-id-123';

/**
* Get a mock bridge for the OneKeyKeyring.
*
* @returns A mock bridge.
*/
function getMockBridge(): TrezorBridge {
return {
init: jest.fn(),
dispose: jest.fn(),
getPublicKey: jest.fn(),
ethereumSignTransaction: jest.fn(),
ethereumSignMessage: jest.fn(),
ethereumSignTypedData: jest.fn(),
model: undefined,
} as unknown as TrezorBridge;
}

describe('OneKeyKeyringV2', () => {
const createInnerKeyring = (): OneKeyKeyring => {
return new OneKeyKeyring({ bridge: getMockBridge() });
};

describe('constructor', () => {
it('extends TrezorKeyringV2', () => {
const inner = createInnerKeyring();
const wrapper = new OneKeyKeyringV2({
legacyKeyring: inner,
entropySource,
});

expect(wrapper).toBeInstanceOf(TrezorKeyringV2);
});

it('sets the type to OneKey', () => {
const inner = createInnerKeyring();
const wrapper = new OneKeyKeyringV2({
legacyKeyring: inner,
entropySource,
});

expect(wrapper.type).toBe(KeyringType.OneKey);
});

it('stores the entropy source', () => {
const inner = createInnerKeyring();
const wrapper = new OneKeyKeyringV2({
legacyKeyring: inner,
entropySource,
});

expect(wrapper.entropySource).toBe(entropySource);
});
});
});
28 changes: 28 additions & 0 deletions packages/keyring-eth-trezor/src/onekey-keyring-v2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { KeyringType, type EntropySourceId } from '@metamask/keyring-api';

import type { OneKeyKeyring } from './onekey-keyring';
import { TrezorKeyringV2 } from './trezor-keyring-v2';

/**
* Options for creating a OneKeyKeyringV2 instance.
*/
export type OneKeyKeyringV2Options = {
legacyKeyring: OneKeyKeyring;
entropySource: EntropySourceId;
};

/**
* Concrete {@link KeyringV2} adapter for {@link OneKeyKeyring}.
*
* This wrapper extends {@link TrezorKeyringV2} since OneKeyKeyring extends
* TrezorKeyring. The only difference is the keyring type identifier.
*/
export class OneKeyKeyringV2 extends TrezorKeyringV2 {
constructor(options: OneKeyKeyringV2Options) {
super({
legacyKeyring: options.legacyKeyring,
entropySource: options.entropySource,
type: KeyringType.OneKey,
});
}
}
Loading
Loading