From 8888aa6cc94a6bc865d97d55f9c2643ed70ba310 Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 6 Sep 2023 02:44:29 +0800 Subject: [PATCH 1/2] TrezorConnect may not fire device event --- .../app/stores/ada/TrezorConnectStore.js | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js index c34a348d6d..99796afd77 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -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 @@ -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 || '', }; } @@ -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; }; From e6b28c8c606f5ca90b598373b5f6f0bac085017e Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 8 Sep 2023 02:25:26 +0300 Subject: [PATCH 2/2] lint fixes --- packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js index 99796afd77..6996248880 100644 --- a/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js +++ b/packages/yoroi-extension/app/stores/ada/TrezorConnectStore.js @@ -246,7 +246,7 @@ export default class TrezorConnectStore _validateHWResponse: TrezorConnectionResponse => boolean = ( resp, ) => { - const { trezorResp, trezorEventDevice } = resp; + const { trezorResp } = resp; if (trezorResp && !trezorResp.success) { switch (trezorResp.payload.error) {