diff --git a/app/actions/TrezorActions.js b/app/actions/TrezorActions.js index 453b3ea113..76d1f2d7e8 100644 --- a/app/actions/TrezorActions.js +++ b/app/actions/TrezorActions.js @@ -24,6 +24,7 @@ import { SIGNMESSAGE_SUCCESS } from "./ControlActions"; import { getAmountFromTxInputs, getTxFromInputs } from "./TransactionActions"; +import { push as pushHistory } from "connected-react-router"; const session = require("trezor-connect").default; const { @@ -82,6 +83,7 @@ export const initTransport = async (session, debug) => { export const TRZ_CONNECT_ATTEMPT = "TRZ_CONNECT_ATTEMPT"; export const TRZ_CONNECT_FAILED = "TRZ_CONNECT_FAILED"; export const TRZ_CONNECT_SUCCESS = "TRZ_CONNECT_SUCCESS"; +export const TRZ_UDEV_ERROR = "TREZOR_UDEV_ERROR"; export const connect = () => async (dispatch, getState) => { const { @@ -97,8 +99,23 @@ export const connect = () => async (dispatch, getState) => { dispatch({ error, type: TRZ_CONNECT_FAILED }); return; }); + try { + await dispatch(getFeatures()); + } catch (err) { + dispatch({ + error: err.message, + type: TRZ_CONNECT_FAILED + }); + const needRules = await trezord.needsUdevRules(); + if (needRules.needs) { + dispatch({ type: TRZ_UDEV_ERROR }); + setTimeout(() => { + dispatch(pushHistory("/error")); + }, 1000); + } + return; + } dispatch({ type: TRZ_CONNECT_SUCCESS }); - dispatch(getFeatures()); }; export const TRZ_TREZOR_DISABLED = "TRZ_TREZOR_DISABLED"; @@ -129,7 +146,6 @@ function onChange(dispatch, getState, features) { if (device == currentDevice) return; const deviceLabel = features.label; dispatch({ deviceLabel, device, type: TRZ_SELECTEDDEVICE_CHANGED }); - dispatch(getFeatures()); } function onConnect(dispatch, getState, features) { @@ -140,7 +156,6 @@ function onConnect(dispatch, getState, features) { device = BOOTLOADER_MODE; } dispatch({ deviceLabel, device, type: TRZ_LOADDEVICE }); - dispatch(getFeatures()); return device; } @@ -330,16 +345,12 @@ async function deviceRun(dispatch, getState, fn) { export const TRZ_GETFEATURES_SUCCESS = "TRZ_GETFEATURES_SUCCESS"; export const getFeatures = () => async (dispatch, getState) => { - try { - const features = await deviceRun(dispatch, getState, async () => { - const res = await session.getFeatures(); - return res.payload; - }); - dispatch({ type: TRZ_GETFEATURES_SUCCESS, features }); - return features; - } catch (error) { - return null; - } + const features = await deviceRun(dispatch, getState, async () => { + const res = await session.getFeatures(); + return res.payload; + }); + dispatch({ type: TRZ_GETFEATURES_SUCCESS, features }); + return features; }; export const TRZ_CANCELOPERATION_SUCCESS = "TRZ_CANCELOPERATION_SUCCESS"; diff --git a/app/components/views/FatalErrorPage/FatalErrorPage.jsx b/app/components/views/FatalErrorPage/FatalErrorPage.jsx index 2bf12e7242..310eb2ea9c 100644 --- a/app/components/views/FatalErrorPage/FatalErrorPage.jsx +++ b/app/components/views/FatalErrorPage/FatalErrorPage.jsx @@ -20,6 +20,7 @@ function FatalErrorPage() { const { daemonError, walletError, + trezorUdevError, isAdvancedDaemon, shutdownApp, backToCredentials, @@ -125,6 +126,14 @@ function FatalErrorPage() {