@@ -38,6 +38,7 @@ import {
38
38
} from './discoveryReducer' ;
39
39
import { selectAccounts } from '../accounts/accountsReducer' ;
40
40
import { accountsActions } from '../accounts/accountsActions' ;
41
+ import { selectDeviceByStaticSessionId } from '../device/deviceReducer' ;
41
42
42
43
type ProgressEvent = BundleProgress < AccountInfo | null > [ 'payload' ] ;
43
44
@@ -332,9 +333,12 @@ export const getBundleThunk = createThunk(
332
333
export const getAvailableCardanoDerivationsThunk = createThunk (
333
334
`${ DISCOVERY_MODULE_PREFIX } /getAvailableCardanoDerivations` ,
334
335
async (
335
- { deviceState, device } : { deviceState : StaticSessionId ; device : TrezorDevice } ,
336
- { dispatch } ,
336
+ { deviceState } : { deviceState : StaticSessionId } ,
337
+ { getState , dispatch } ,
337
338
) : Promise < ( 'normal' | 'legacy' | 'ledger' ) [ ] | undefined > => {
339
+ const device = selectDeviceByStaticSessionId ( getState ( ) , deviceState ) ;
340
+ if ( ! device ) return ;
341
+
338
342
// If icarus and icarus-trezor derivations return same pub key
339
343
// we can skip derivation of the latter as it would discover same accounts.
340
344
// Ledger derivation will always result in different pub key except in shamir where all derivations are the same
@@ -353,11 +357,13 @@ export const getAvailableCardanoDerivationsThunk = createThunk(
353
357
354
358
const icarusTrezorPubKeyResult = await TrezorConnect . cardanoGetPublicKey ( {
355
359
...commonParams ,
360
+ device : icarusPubKeyResult . success ? icarusPubKeyResult . device : device ,
356
361
derivationType : getDerivationType ( 'legacy' ) ,
357
362
} ) ;
358
363
359
364
const ledgerPubKeyResult = await TrezorConnect . cardanoGetPublicKey ( {
360
365
...commonParams ,
366
+ device : icarusTrezorPubKeyResult . success ? icarusTrezorPubKeyResult . device : device ,
361
367
derivationType : getDerivationType ( 'ledger' ) ,
362
368
} ) ;
363
369
@@ -487,7 +493,7 @@ export const startDiscoveryThunk = createThunk(
487
493
) {
488
494
// check if discovery of legacy (icarus-trezor) or ledger accounts is needed and update discovery accordingly
489
495
availableCardanoDerivations = await dispatch (
490
- getAvailableCardanoDerivationsThunk ( { deviceState, device } ) ,
496
+ getAvailableCardanoDerivationsThunk ( { deviceState } ) ,
491
497
) . unwrap ( ) ;
492
498
if ( ! availableCardanoDerivations ) {
493
499
// Edge case where getAvailableCardanoDerivations dispatches error, stops discovery and returns undefined.
0 commit comments