Skip to content

Commit

Permalink
TrezorConnect may not fire device event
Browse files Browse the repository at this point in the history
  • Loading branch information
yushih committed Sep 5, 2023
1 parent 07ecc30 commit 8888aa6
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ export default class TrezorConnectStore
this._onTrezorUIEvent,
);

if (this.trezorEventDevice == null) {
throw new Error(`${nameof(this._checkAndStoreHWDeviceInfo)} no ${nameof(this.trezorEventDevice)}`);
}
const trezorEventDevice = this.trezorEventDevice;

/** Converts a valid hardware wallet response to a common storable format
Expand Down Expand Up @@ -231,21 +228,17 @@ export default class TrezorConnectStore

const { trezorResp, trezorEventDevice } = resp;

/** This check already done in _validateHWResponse but flow needs this */
const device = trezorEventDevice.payload;
const { features } = device;
if (features == null) {
throw new Error('Trezor device hardware info not valid');
}
const device = trezorEventDevice?.payload;
const features = device?.features;

return {
publicMasterKey: trezorResp.payload.publicKey,
hwFeatures: {
Vendor: features.vendor ?? Config.wallets.hardwareWallet.trezorT.VENDOR,
Model: features.model,
DeviceId: features.device_id || '',
Vendor: features?.vendor ?? Config.wallets.hardwareWallet.trezorT.VENDOR,
Model: features?.model ?? Config.wallets.hardwareWallet.trezorT.MODEL,
DeviceId: features?.device_id || '',
},
defaultName: device.label || '',
defaultName: device?.label || '',
};
}

Expand Down Expand Up @@ -276,13 +269,6 @@ export default class TrezorConnectStore
throw new Error('Invalid public key received from Trezor device');
}

if (trezorEventDevice == null
|| trezorEventDevice.payload == null
|| trezorEventDevice.payload.type !== 'acquired'
|| trezorEventDevice.payload.features == null) {
throw new Error('Invalid trezor device event');
}

return true;
};

Expand Down

0 comments on commit 8888aa6

Please sign in to comment.