@@ -11,7 +11,11 @@ import HDKey from 'hdkey';
1111
1212import type { TrezorBridge } from './trezor-bridge' ;
1313import { TrezorKeyring } from './trezor-keyring' ;
14- import { TrezorKeyringV2 } from './trezor-keyring-v2' ;
14+ import {
15+ BIP44_HD_PATH_PREFIX ,
16+ LEGACY_MEW_PATH ,
17+ TrezorKeyringV2 ,
18+ } from './trezor-keyring-v2' ;
1519
1620/**
1721 * Type alias for Trezor keyring accounts (always BIP-44 derived).
@@ -354,7 +358,9 @@ describe('TrezorKeyringV2', () => {
354358 // getAccounts should work and populate the registry
355359 const accounts = await wrapper . getAccounts ( ) ;
356360 expect ( accounts ) . toHaveLength ( 3 ) ;
357- expect ( accounts [ 0 ] ?. address ) . toBe ( EXPECTED_ACCOUNTS [ 0 ] ) ;
361+ accounts . forEach ( ( account , index ) => {
362+ expect ( account . address ) . toBe ( EXPECTED_ACCOUNTS [ index ] ) ;
363+ } ) ;
358364 } ) ;
359365 } ) ;
360366
@@ -462,33 +468,37 @@ describe('TrezorKeyringV2', () => {
462468 const { wrapper, inner } = createEmptyWrapper ( ) ;
463469
464470 const newAccounts = await wrapper . createAccounts (
465- derivePathOptions ( `m/44'/60'/0'/0 /5` ) ,
471+ derivePathOptions ( `${ BIP44_HD_PATH_PREFIX } /5` ) ,
466472 ) ;
467473 const account = getFirstAccount ( newAccounts ) ;
468474
469475 expect ( account . address ) . toBe ( EXPECTED_ACCOUNTS [ 5 ] ) ;
470476 expect ( account . options . entropy . groupIndex ) . toBe ( 5 ) ;
471- expect ( account . options . entropy . derivationPath ) . toBe ( `m/44'/60'/0'/0/5` ) ;
472- expect ( inner . hdPath ) . toBe ( `m/44'/60'/0'/0` ) ;
477+ expect ( account . options . entropy . derivationPath ) . toBe (
478+ `${ BIP44_HD_PATH_PREFIX } /5` ,
479+ ) ;
480+ expect ( inner . hdPath ) . toBe ( BIP44_HD_PATH_PREFIX ) ;
473481 } ) ;
474482
475483 it ( 'creates an account with legacy MEW path' , async ( ) => {
476484 // Create wrapper with legacy MEW path pre-set to avoid HDKey reset
477- const inner = createInnerKeyring ( `m/44'/60'/0'` ) ;
485+ const inner = createInnerKeyring ( LEGACY_MEW_PATH ) ;
478486 const wrapper = new TrezorKeyringV2 ( {
479487 legacyKeyring : inner ,
480488 entropySource,
481489 } ) ;
482490
483491 const newAccounts = await wrapper . createAccounts (
484- derivePathOptions ( `m/44'/60'/0' /3` ) ,
492+ derivePathOptions ( `${ LEGACY_MEW_PATH } /3` ) ,
485493 ) ;
486494 const account = getFirstAccount ( newAccounts ) ;
487495
488496 expect ( account . address ) . toBe ( EXPECTED_ACCOUNTS [ 3 ] ) ;
489497 expect ( account . options . entropy . groupIndex ) . toBe ( 3 ) ;
490- expect ( account . options . entropy . derivationPath ) . toBe ( `m/44'/60'/0'/3` ) ;
491- expect ( inner . hdPath ) . toBe ( `m/44'/60'/0'` ) ;
498+ expect ( account . options . entropy . derivationPath ) . toBe (
499+ `${ LEGACY_MEW_PATH } /3` ,
500+ ) ;
501+ expect ( inner . hdPath ) . toBe ( LEGACY_MEW_PATH ) ;
492502 } ) ;
493503
494504 it ( 'returns existing account if path already exists' , async ( ) => {
@@ -654,7 +664,7 @@ describe('TrezorKeyringV2', () => {
654664 describe ( 'different HD paths' , ( ) => {
655665 it ( 'uses the correct derivation path from the inner keyring' , async ( ) => {
656666 const inner = createInnerKeyring ( ) ;
657- inner . setHdPath ( `m/44'/60'/0'` ) ; // Legacy MEW path
667+ inner . setHdPath ( LEGACY_MEW_PATH ) ;
658668 inner . hdk = fakeHdKey ; // Reset after setHdPath clears it
659669 inner . setAccountToUnlock ( 0 ) ;
660670 await inner . addAccounts ( 1 ) ;
@@ -667,7 +677,9 @@ describe('TrezorKeyringV2', () => {
667677 const accounts = await wrapper . getAccounts ( ) ;
668678 const account = getFirstAccount ( accounts ) ;
669679
670- expect ( account . options . entropy . derivationPath ) . toBe ( `m/44'/60'/0'/0` ) ;
680+ expect ( account . options . entropy . derivationPath ) . toBe (
681+ `${ LEGACY_MEW_PATH } /0` ,
682+ ) ;
671683 } ) ;
672684
673685 it ( 'clears registry when switching HD paths via createAccounts' , async ( ) => {
0 commit comments