@@ -2,15 +2,22 @@ import { Network } from '@avalabs/core-chains-sdk'
22import { Avalanche } from '@avalabs/core-wallets-sdk'
33import { Curve } from 'utils/publicKeys'
44import { LedgerAppType , LedgerDerivationPathType } from 'services/ledger/types'
5- import { AvalancheTransactionRequest } from './types'
65
76// Mock dependencies
8- jest . mock ( 'utils/api/generated/profileApi.client' , ( ) => ( {
9- postV1GetAddresses : jest . fn ( )
10- } ) , { virtual : true } )
11- jest . mock ( 'utils/api/clients/profileApiClient' , ( ) => ( {
12- profileApiClient : { }
13- } ) , { virtual : true } )
7+ jest . mock (
8+ 'utils/api/generated/profileApi.client' ,
9+ ( ) => ( {
10+ postV1GetAddresses : jest . fn ( )
11+ } ) ,
12+ { virtual : true }
13+ )
14+ jest . mock (
15+ 'utils/api/clients/profileApiClient' ,
16+ ( ) => ( {
17+ profileApiClient : { }
18+ } ) ,
19+ { virtual : true }
20+ )
1421
1522// Mock LedgerService - the default export is the service instance
1623// We need to create the mock inline so Jest can hoist it properly
@@ -45,8 +52,9 @@ jest.mock('@avalabs/hw-app-avalanche', () => {
4552} )
4653
4754// Import after mocking
48- import { LedgerWallet } from './LedgerWallet'
4955import LedgerService from 'services/ledger/LedgerService'
56+ import { AvalancheTransactionRequest } from './types'
57+ import { LedgerWallet } from './LedgerWallet'
5058
5159// Get references to the mocked functions
5260const mockOpenApp = LedgerService . openApp as jest . Mock
@@ -258,8 +266,8 @@ describe('LedgerWallet', () => {
258266 } )
259267
260268 expect ( mockSign ) . toHaveBeenCalledWith (
261- "m/44'/60'/0'" , // Account 0
262- [ '0/0' ] , // Always first address
269+ "m/44'/60'/0'" , // Account 0
270+ [ '0/0' ] , // Always first address
263271 expect . any ( Buffer ) ,
264272 undefined
265273 )
@@ -278,8 +286,8 @@ describe('LedgerWallet', () => {
278286 } )
279287
280288 expect ( mockSign ) . toHaveBeenCalledWith (
281- "m/44'/60'/1'" , // Account 1
282- [ '0/0' ] , // Always first address
289+ "m/44'/60'/1'" , // Account 1
290+ [ '0/0' ] , // Always first address
283291 expect . any ( Buffer ) ,
284292 undefined
285293 )
@@ -298,8 +306,8 @@ describe('LedgerWallet', () => {
298306 } )
299307
300308 expect ( mockSign ) . toHaveBeenCalledWith (
301- "m/44'/60'/2'" , // Account 2
302- [ '0/0' ] , // Always first address
309+ "m/44'/60'/2'" , // Account 2
310+ [ '0/0' ] , // Always first address
303311 expect . any ( Buffer ) ,
304312 undefined
305313 )
@@ -319,8 +327,8 @@ describe('LedgerWallet', () => {
319327 } )
320328
321329 expect ( mockSign ) . toHaveBeenCalledWith (
322- "m/44'/60'/5'" , // Account 5
323- [ '0/0' ] , // Still 0/0, not 0/5
330+ "m/44'/60'/5'" , // Account 5
331+ [ '0/0' ] , // Still 0/0, not 0/5
324332 expect . any ( Buffer ) ,
325333 undefined
326334 )
@@ -329,7 +337,7 @@ describe('LedgerWallet', () => {
329337 it ( 'should ignore externalIndices for C-chain transactions' , async ( ) => {
330338 const transaction : AvalancheTransactionRequest = {
331339 tx : createCChainTx ( ) as any ,
332- externalIndices : [ 3 , 5 , 7 ] // Should be ignored for C-chain
340+ externalIndices : [ 3 , 5 , 7 ] // Should be ignored for C-chain
333341 }
334342
335343 await ledgerWallet . signAvalancheTransaction ( {
@@ -341,7 +349,7 @@ describe('LedgerWallet', () => {
341349
342350 expect ( mockSign ) . toHaveBeenCalledWith (
343351 "m/44'/60'/0'" ,
344- [ '0/0' ] , // Not ['0/3', '0/5', '0/7']
352+ [ '0/0' ] , // Not ['0/3', '0/5', '0/7']
345353 expect . any ( Buffer ) ,
346354 undefined
347355 )
@@ -363,7 +371,7 @@ describe('LedgerWallet', () => {
363371 } )
364372
365373 expect ( mockSign ) . toHaveBeenCalledWith (
366- "m/44'/9000'/2'" , // Account 2
374+ "m/44'/9000'/2'" , // Account 2
367375 [ '0/0' ] ,
368376 expect . any ( Buffer ) ,
369377 undefined
@@ -384,7 +392,7 @@ describe('LedgerWallet', () => {
384392 } )
385393
386394 expect ( mockSign ) . toHaveBeenCalledWith (
387- "m/44'/9000'/3'" , // Account 3
395+ "m/44'/9000'/3'" , // Account 3
388396 [ '0/0' ] ,
389397 expect . any ( Buffer ) ,
390398 undefined
@@ -406,7 +414,7 @@ describe('LedgerWallet', () => {
406414
407415 expect ( mockSign ) . toHaveBeenCalledWith (
408416 "m/44'/9000'/0'" ,
409- [ '0/3' , '0/5' , '0/7' ] , // Multiple UTXO signing paths
417+ [ '0/3' , '0/5' , '0/7' ] , // Multiple UTXO signing paths
410418 expect . any ( Buffer ) ,
411419 undefined
412420 )
@@ -427,7 +435,7 @@ describe('LedgerWallet', () => {
427435
428436 expect ( mockSign ) . toHaveBeenCalledWith (
429437 "m/44'/9000'/0'" ,
430- [ '0/0' ] , // Default fallback
438+ [ '0/0' ] , // Default fallback
431439 expect . any ( Buffer ) ,
432440 undefined
433441 )
@@ -448,7 +456,7 @@ describe('LedgerWallet', () => {
448456
449457 expect ( mockSign ) . toHaveBeenCalledWith (
450458 "m/44'/9000'/0'" ,
451- [ '0/0' ] , // Default fallback
459+ [ '0/0' ] , // Default fallback
452460 expect . any ( Buffer ) ,
453461 undefined
454462 )
@@ -495,7 +503,7 @@ describe('LedgerWallet', () => {
495503 "m/44'/9000'/0'" ,
496504 [ '0/0' ] ,
497505 expect . any ( Buffer ) ,
498- [ '1/1' , '1/3' ] // Change paths
506+ [ '1/1' , '1/3' ] // Change paths
499507 )
500508 } )
501509
@@ -517,7 +525,7 @@ describe('LedgerWallet', () => {
517525 "m/44'/9000'/0'" ,
518526 [ '0/0' ] ,
519527 expect . any ( Buffer ) ,
520- undefined // No change paths
528+ undefined // No change paths
521529 )
522530 } )
523531
@@ -539,7 +547,7 @@ describe('LedgerWallet', () => {
539547 "m/44'/9000'/0'" ,
540548 [ '0/0' ] ,
541549 expect . any ( Buffer ) ,
542- undefined // No change paths
550+ undefined // No change paths
543551 )
544552 } )
545553 } )
@@ -609,7 +617,9 @@ describe('LedgerWallet', () => {
609617
610618 describe ( 'error handling' , ( ) => {
611619 it ( 'should throw error when connection fails' , async ( ) => {
612- mockEnsureConnection . mockRejectedValueOnce ( new Error ( 'Connection failed' ) )
620+ mockEnsureConnection . mockRejectedValueOnce (
621+ new Error ( 'Connection failed' )
622+ )
613623
614624 const mockTx = {
615625 getVM : jest . fn ( ) . mockReturnValue ( 'AVM' ) ,
0 commit comments