Skip to content

Commit 161ddf8

Browse files
committed
fix(suite-common): cardano discovery update device
1 parent 56e1a49 commit 161ddf8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

suite-common/wallet-core/src/discovery/discoveryThunks.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
} from './discoveryReducer';
3939
import { selectAccounts } from '../accounts/accountsReducer';
4040
import { accountsActions } from '../accounts/accountsActions';
41+
import { selectDeviceByStaticSessionId } from '../device/deviceReducer';
4142

4243
type ProgressEvent = BundleProgress<AccountInfo | null>['payload'];
4344

@@ -332,9 +333,12 @@ export const getBundleThunk = createThunk(
332333
export const getAvailableCardanoDerivationsThunk = createThunk(
333334
`${DISCOVERY_MODULE_PREFIX}/getAvailableCardanoDerivations`,
334335
async (
335-
{ deviceState, device }: { deviceState: StaticSessionId; device: TrezorDevice },
336-
{ dispatch },
336+
{ deviceState }: { deviceState: StaticSessionId },
337+
{ getState, dispatch },
337338
): Promise<('normal' | 'legacy' | 'ledger')[] | undefined> => {
339+
const device = selectDeviceByStaticSessionId(getState(), deviceState);
340+
if (!device) return;
341+
338342
// If icarus and icarus-trezor derivations return same pub key
339343
// we can skip derivation of the latter as it would discover same accounts.
340344
// 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(
353357

354358
const icarusTrezorPubKeyResult = await TrezorConnect.cardanoGetPublicKey({
355359
...commonParams,
360+
device: icarusPubKeyResult.success ? icarusPubKeyResult.device : device,
356361
derivationType: getDerivationType('legacy'),
357362
});
358363

359364
const ledgerPubKeyResult = await TrezorConnect.cardanoGetPublicKey({
360365
...commonParams,
366+
device: icarusTrezorPubKeyResult.success ? icarusTrezorPubKeyResult.device : device,
361367
derivationType: getDerivationType('ledger'),
362368
});
363369

@@ -487,7 +493,7 @@ export const startDiscoveryThunk = createThunk(
487493
) {
488494
// check if discovery of legacy (icarus-trezor) or ledger accounts is needed and update discovery accordingly
489495
availableCardanoDerivations = await dispatch(
490-
getAvailableCardanoDerivationsThunk({ deviceState, device }),
496+
getAvailableCardanoDerivationsThunk({ deviceState }),
491497
).unwrap();
492498
if (!availableCardanoDerivations) {
493499
// Edge case where getAvailableCardanoDerivations dispatches error, stops discovery and returns undefined.

suite-native/discovery/src/discoveryThunks.ts

-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ const getCardanoSupportedAccountTypesThunk = createThunk(
209209
dispatch(
210210
getAvailableCardanoDerivationsThunk({
211211
deviceState,
212-
device,
213212
}),
214213
).unwrap(),
215214
});

0 commit comments

Comments
 (0)