11import  TransportBLE  from  '@ledgerhq/react-native-hw-transport-ble' 
2+ import  Transport  from  '@ledgerhq/hw-transport' 
23import  AppAvalanche  from  '@avalabs/hw-app-avalanche' 
34import  AppSolana  from  '@ledgerhq/hw-app-solana' 
45import  {  NetworkVMType  }  from  '@avalabs/core-chains-sdk' 
@@ -17,49 +18,14 @@ import {
1718  getSolanaDerivationPath 
1819}  from  'new/features/ledger/consts' 
1920import  {  assertNotNull  }  from  'utils/assertions' 
20- 
21- export  interface  AddressInfo  { 
22-   id : string 
23-   address : string 
24-   derivationPath : string 
25-   network : string 
26- } 
27- 
28- export  interface  ExtendedPublicKey  { 
29-   path : string 
30-   key : string 
31-   chainCode : string 
32- } 
33- 
34- export  interface  PublicKeyInfo  { 
35-   key : string 
36-   derivationPath : string 
37-   curve : 'secp256k1'  |  'ed25519' 
38- } 
39- 
40- export  enum  LedgerAppType  { 
41-   AVALANCHE  =  'Avalanche' , 
42-   SOLANA  =  'Solana' , 
43-   ETHEREUM  =  'Ethereum' , 
44-   UNKNOWN  =  'Unknown' 
45- } 
46- 
47- export  const  LedgerReturnCode  =  { 
48-   SUCCESS : 0x9000 , 
49-   USER_REJECTED : 0x6985 , 
50-   APP_NOT_OPEN : 0x6a80 , 
51-   DEVICE_LOCKED : 0x5515 , 
52-   INVALID_PARAMETER : 0x6b00 , 
53-   COMMAND_NOT_ALLOWED : 0x6986 
54- }  as  const 
55- 
56- export  type  LedgerReturnCodeType  = 
57-   typeof  LedgerReturnCode [ keyof  typeof  LedgerReturnCode ] 
58- 
59- export  interface  AppInfo  { 
60-   applicationName : string 
61-   version : string 
62- } 
21+ import  { 
22+   AddressInfo , 
23+   ExtendedPublicKey , 
24+   PublicKeyInfo , 
25+   LedgerAppType , 
26+   LedgerReturnCode , 
27+   AppInfo 
28+ }  from  './types' 
6329
6430export  class  LedgerService  { 
6531  #transport: TransportBLE  |  null  =  null 
@@ -145,7 +111,7 @@ export class LedgerService {
145111
146112  // Get current app info from device 
147113  private  async  getCurrentAppInfo ( ) : Promise < AppInfo >  { 
148-     return  await  getLedgerAppInfo ( this . transport  as  any ) 
114+     return  await  getLedgerAppInfo ( this . transport  as  Transport ) 
149115  } 
150116
151117  // Map app name to our enum 
@@ -241,7 +207,7 @@ export class LedgerService {
241207    Logger . info ( 'Avalanche app detected, creating app instance...' ) 
242208
243209    // Create Avalanche app instance 
244-     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  any ) 
210+     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  Transport ) 
245211    Logger . info ( 'Avalanche app instance created' ) 
246212
247213    try  { 
@@ -361,7 +327,7 @@ export class LedgerService {
361327    try  { 
362328      // Create fresh Solana app instance 
363329      const  transport  =  await  this . getTransport ( ) 
364-       const  solanaApp  =  new  AppSolana ( transport  as  any ) 
330+       const  solanaApp  =  new  AppSolana ( transport  as  Transport ) 
365331      // Try to get a simple address to check if app is open 
366332      // Use a standard Solana derivation path 
367333      const  testPath  =  "m/44'/501'/0'" 
@@ -377,7 +343,7 @@ export class LedgerService {
377343  async  getSolanaAddress ( derivationPath : string ) : Promise < {  address : Buffer  } >  { 
378344    await  this . waitForApp ( LedgerAppType . SOLANA ) 
379345    const  transport  =  await  this . getTransport ( ) 
380-     const  solanaApp  =  new  AppSolana ( transport  as  any ) 
346+     const  solanaApp  =  new  AppSolana ( transport  as  Transport ) 
381347    return  await  solanaApp . getAddress ( derivationPath ,  false ) 
382348  } 
383349
@@ -388,7 +354,7 @@ export class LedgerService {
388354  ) : Promise < PublicKeyInfo [ ] >  { 
389355    // Create a fresh AppSolana instance for each call (like the SDK does) 
390356    const  transport  =  await  this . getTransport ( ) 
391-     const  freshSolanaApp  =  new  AppSolana ( transport  as  any ) 
357+     const  freshSolanaApp  =  new  AppSolana ( transport  as  Transport ) 
392358    const  publicKeys : PublicKeyInfo [ ]  =  [ ] 
393359
394360    try  { 
@@ -430,7 +396,7 @@ export class LedgerService {
430396      // Use the SDK function directly (like the extension does) 
431397      const  publicKey  =  await  getSolanaPublicKeyFromLedger ( 
432398        startIndex , 
433-         this . transport  as  any 
399+         this . transport  as  Transport 
434400      ) 
435401
436402      const  publicKeys : PublicKeyInfo [ ]  =  [ 
@@ -493,7 +459,7 @@ export class LedgerService {
493459    await  this . waitForApp ( LedgerAppType . AVALANCHE ) 
494460
495461    // Create Avalanche app instance 
496-     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  any ) 
462+     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  Transport ) 
497463
498464    const  publicKeys : PublicKeyInfo [ ]  =  [ ] 
499465
@@ -563,7 +529,7 @@ export class LedgerService {
563529    await  this . waitForApp ( LedgerAppType . AVALANCHE ) 
564530
565531    // Create Avalanche app instance 
566-     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  any ) 
532+     const  avalancheApp  =  new  AppAvalanche ( this . transport  as  Transport ) 
567533
568534    const  addresses : AddressInfo [ ]  =  [ ] 
569535
0 commit comments