1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Ensure proper transport type is set before attempting to connect ledger wallet (#12594)

* Ensure proper transport type is set before attempting to connect ledger wallet

* Fix unit tests
This commit is contained in:
Dan J Miller 2021-11-05 13:43:29 -02:30 committed by ryanml
parent ac0f70b858
commit e740f7a436
3 changed files with 18 additions and 0 deletions

View File

@ -849,6 +849,10 @@ export default class MetamaskController extends EventEmitter {
this.attemptLedgerTransportCreation,
this,
),
establishLedgerTransportPreference: nodeify(
this.establishLedgerTransportPreference,
this,
),
// mobile
fetchInfoToSync: nodeify(this.fetchInfoToSync, this),
@ -1252,6 +1256,7 @@ export default class MetamaskController extends EventEmitter {
this.preferencesController.setAddresses(addresses);
this.selectFirstIdentity();
}
return vault;
} finally {
releaseLock();
@ -1565,6 +1570,11 @@ export default class MetamaskController extends EventEmitter {
return await keyring.attemptMakeApp();
}
async establishLedgerTransportPreference() {
const transportPreference = this.preferencesController.getLedgerTransportPreference();
return await this.setLedgerTransportPreference(transportPreference);
}
/**
* Fetch account list from a trezor device.
*

View File

@ -409,6 +409,10 @@ export function connectHardware(deviceName, page, hdPath, t) {
let accounts;
try {
const { ledgerTransportType } = getState().metamask;
if (deviceName === 'ledger') {
await promisifiedBackground.establishLedgerTransportPreference();
}
if (
deviceName === 'ledger' &&
ledgerTransportType === LEDGER_TRANSPORT_TYPES.WEBHID

View File

@ -548,6 +548,8 @@ describe('Actions', () => {
(_, __, ___, cb) => cb(),
);
background.establishLedgerTransportPreference.callsFake((cb) => cb());
actions._setBackgroundConnection(background);
await store.dispatch(
@ -563,6 +565,8 @@ describe('Actions', () => {
cb(new Error('error')),
);
background.establishLedgerTransportPreference.callsFake((cb) => cb());
actions._setBackgroundConnection(background);
const expectedActions = [