diff --git a/src/js/actions/DiscoveryActions.js b/src/js/actions/DiscoveryActions.js index 7807af2b..8a5d26bc 100644 --- a/src/js/actions/DiscoveryActions.js +++ b/src/js/actions/DiscoveryActions.js @@ -322,7 +322,7 @@ export const restore = (): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { const selected = findSelectedDevice(getState().connect); - if (selected && selected.connected && !selected.unacquired) { + if (selected && selected.connected && selected.features) { const discoveryProcess: ?Discovery = getState().discovery.find(d => d.deviceState === selected.state && d.waitingForDevice); if (discoveryProcess) { dispatch( start(selected, discoveryProcess.network) ); diff --git a/src/js/actions/TrezorConnectActions.js b/src/js/actions/TrezorConnectActions.js index 69be2f75..02c830ad 100644 --- a/src/js/actions/TrezorConnectActions.js +++ b/src/js/actions/TrezorConnectActions.js @@ -80,15 +80,6 @@ export type TrezorConnectAction = { } | { type: typeof CONNECT.DEVICE_FROM_STORAGE, payload: Array -} | { - type: typeof CONNECT.START_ACQUIRING, - device: TrezorDevice -} | { - type: typeof CONNECT.STOP_ACQUIRING, - device: TrezorDevice -} | { - type: typeof CONNECT.ACQUIRED, - device: TrezorDevice }; @@ -293,7 +284,6 @@ export const getSelectedDeviceState = (): AsyncAction => { if (selected && selected.connected && selected.features - && !selected.acquiring && !selected.state) { const response = await TrezorConnect.getDeviceState({ @@ -389,47 +379,13 @@ export function acquire(): AsyncAction { const selected: ?TrezorDevice = findSelectedDevice(getState().connect); if (!selected) return; - // const saved = getState().connect.devices.map(d => { - // if (d.state) { - // return { - // instance: d.instance, - // state: d.state - // } - // } else { - // return null; - // } - // }); - - //const response = await __acquire(selected.path, selected.instance); - - dispatch({ - type: CONNECT.START_ACQUIRING, - device: selected - }); - const response = await TrezorConnect.getFeatures({ device: { path: selected.path, } }); - const selected2: ?TrezorDevice = findSelectedDevice(getState().connect); - if (!selected2) return; - const s: TrezorDevice = selected2; - - dispatch({ - type: CONNECT.STOP_ACQUIRING, - device: selected2 - }); - - if (response && response.success) { - dispatch({ - type: CONNECT.ACQUIRED, - device: selected2 - }); - } else { - // TODO: handle invalid pin? - + if (!response.success) { dispatch({ type: NOTIFICATION.ADD, payload: { @@ -451,18 +407,6 @@ export function acquire(): AsyncAction { } } -export const forgetDevice = (device: TrezorDevice): ThunkAction => { - return (dispatch: Dispatch, getState: GetState): void => { - // find accounts associated with this device - // const accounts: Array = getState().accounts.find(a => a.deviceState === device.state); - - - // find discovery processes associated with this device - // const discovery: Array = getState().discovery.find(d => d.deviceState === device.state); - - } -} - export const gotoDeviceSettings = (device: TrezorDevice): ThunkAction => { return (dispatch: Dispatch, getState: GetState): void => { if (device.features) { diff --git a/src/js/actions/constants/TrezorConnect.js b/src/js/actions/constants/TrezorConnect.js index 44982797..4c016d30 100644 --- a/src/js/actions/constants/TrezorConnect.js +++ b/src/js/actions/constants/TrezorConnect.js @@ -20,10 +20,6 @@ export const FORGET_SINGLE: 'connect__forget_single' = 'connect__forget_single'; export const DISCONNECT_REQUEST: 'connect__disconnect_request' = 'connect__disconnect_request'; export const REMEMBER: 'connect__remember' = 'connect__remember'; -export const START_ACQUIRING: 'connect__start_acquiring' = 'connect__start_acquiring'; -export const STOP_ACQUIRING: 'connect__stop_acquiring' = 'connect__stop_acquiring'; -export const ACQUIRED: 'connect__device_acquired' = 'connect__device_acquired'; - export const TRY_TO_DUPLICATE: 'connect__try_to_duplicate' = 'connect__try_to_duplicate'; export const DUPLICATE: 'connect__duplicate' = 'connect__duplicate'; diff --git a/src/js/components/wallet/aside/Aside.js b/src/js/components/wallet/aside/Aside.js index 8e45affe..332d3394 100644 --- a/src/js/components/wallet/aside/Aside.js +++ b/src/js/components/wallet/aside/Aside.js @@ -46,18 +46,6 @@ const Aside = (props: Props): React$Element => if (location.pathname === '/' || !selected) return (); - // TODO - // if (selectedDevice.unacquired) { - // return ( - // - // ); - // } - let menu =
; if (props.deviceDropdownOpened) { diff --git a/src/js/components/wallet/aside/DeviceSelection.js b/src/js/components/wallet/aside/DeviceSelection.js index 8ce60e6c..425b6187 100644 --- a/src/js/components/wallet/aside/DeviceSelection.js +++ b/src/js/components/wallet/aside/DeviceSelection.js @@ -154,7 +154,7 @@ export class DeviceDropdown extends Component { if (selected.isUsedElsewhere) { deviceMenuItems.push({ type: "reload", label: "Renew session" }); } else if (selected.featuresNeedsReload) { - deviceMenuItems.push({ type: "reload", label: "Reload device" }); + deviceMenuItems.push({ type: "reload", label: "Renew session" }); } deviceMenuItems.push({ type: "settings", label: "Device settings" }); diff --git a/src/js/flowtype/index.js b/src/js/flowtype/index.js index 4210c5b9..8a914a62 100644 --- a/src/js/flowtype/index.js +++ b/src/js/flowtype/index.js @@ -43,9 +43,9 @@ import type { import type { RouterAction, LocationState } from 'react-router-redux'; export type TrezorDevice = { - remember: boolean; - connected: boolean; - available: boolean; // device cannot be used because of features.passphrase_protection is different then expected (saved) + remember: boolean; // device should be remembered + connected: boolean; // device is connected + available: boolean; // device cannot be used because of features.passphrase_protection is different then expected path: string; label: string; state: ?string; @@ -54,23 +54,6 @@ export type TrezorDevice = { instanceName: ?string; features?: Features; unacquired?: boolean; - acquiring: boolean; - isUsedElsewhere?: boolean; - featuresNeedsReload?: boolean; - ts: number; -} - -export type AcquiredDevice = { - remember: boolean; - connected: boolean; - available: boolean; // device cannot be used because of features.passphrase_protection is different then expected (saved) - path: string; - label: string; - state: string; - instance: ?number; - instanceLabel: string; - features: Features; - acquiring: boolean; isUsedElsewhere?: boolean; featuresNeedsReload?: boolean; ts: number; diff --git a/src/js/flowtype/trezor-connect.js b/src/js/flowtype/trezor-connect.js index 1ac79c18..cb13d712 100644 --- a/src/js/flowtype/trezor-connect.js +++ b/src/js/flowtype/trezor-connect.js @@ -9,14 +9,14 @@ declare module 'trezor-connect' { DISCONNECT: 'device__disconnect', DISCONNECT_UNACQUIRED: 'device__disconnect_unacquired', - ACQUIRE: 'device__acquire', // remove? internal - RELEASE: 'device__release', // internal - ACQUIRED: 'device__acquired', - RELEASED: 'device__released', // internal - USED_ELSEWHERE: 'device__used_elsewhere', // internal + // ACQUIRE: 'device__acquire', // remove? internal + // RELEASE: 'device__release', // internal + // ACQUIRED: 'device__acquired', + // RELEASED: 'device__released', // internal + // USED_ELSEWHERE: 'device__used_elsewhere', // internal CHANGED: 'device__changed', - LOADING: 'device__loading', // internal + // LOADING: 'device__loading', // internal // trezor-link events BUTTON: 'button', diff --git a/src/js/reducers/TrezorConnectReducer.js b/src/js/reducers/TrezorConnectReducer.js index 0e737b44..12af17c9 100644 --- a/src/js/reducers/TrezorConnectReducer.js +++ b/src/js/reducers/TrezorConnectReducer.js @@ -128,7 +128,6 @@ const mergeDevices = (current: TrezorDevice, upcoming: Object): TrezorDevice => instanceLabel, instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName, state: current.state, - acquiring: typeof upcoming.acquiring === 'boolean' ? upcoming.acquiring : current.acquiring, ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts, } // corner-case: trying to merge unacquired device with acquired @@ -281,8 +280,6 @@ const disconnectDevice = (state: State, device: Device): State => { d.available = false; d.isUsedElsewhere = false; d.featuresNeedsReload = false; - d.acquiring = false; - //if (d.remember) d.path = ''; return d; })); @@ -432,9 +429,6 @@ export default function connect(state: State = initialState, action: Action): St case CONNECT.AUTH_DEVICE : return setDeviceState(state, action); - case CONNECT.START_ACQUIRING : - case CONNECT.STOP_ACQUIRING : - return changeDevice(state, { ...action.device, acquiring: action.type === CONNECT.START_ACQUIRING } ); case CONNECT.REMEMBER : return changeDevice(state, { ...action.device, path: '', remember: true } ); diff --git a/src/js/services/TrezorConnectService.js b/src/js/services/TrezorConnectService.js index a87a0a0f..0b9e302b 100644 --- a/src/js/services/TrezorConnectService.js +++ b/src/js/services/TrezorConnectService.js @@ -56,11 +56,8 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa }); } else if (action.type === DEVICE.DISCONNECT) { api.dispatch( TrezorConnectActions.deviceDisconnect(action.device) ); - } else if (action.type === CONNECT.REMEMBER_REQUEST) { - api.dispatch(ModalActions.onRememberRequest(prevModalState)); - } else if (action.type === CONNECT.FORGET) { //api.dispatch( TrezorConnectActions.forgetDevice(action.device) ); api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() ); @@ -75,15 +72,6 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa } else { api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() ); } - } else if (action.type === DEVICE.CHANGED) { - // selected device was previously unacquired, but now it's acquired - // we need to change route - // if (prevState.selectedDevice) { - // if (action.device.features && action.device.path === prevState.selectedDevice.id) { - // //console.log("REDIR HERE!", action.device) - // //api.dispatch( TrezorConnectActions.onSelectDevice(action.device) ); - // } - // } } else if (action.type === DEVICE.CONNECT || action.type === DEVICE.CONNECT_UNACQUIRED) { api.dispatch( DiscoveryActions.restore() ); @@ -109,7 +97,6 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa api.dispatch( DiscoveryActions.check() ); } else if (action.type === CONNECT.DUPLICATE) { api.dispatch( TrezorConnectActions.selectDuplicatedDevice() ); - // } else if (action.type === CONNECT.ACQUIRED || action.type === CONNECT.SELECT_DEVICE) { } else if (action.type === CONNECT.SELECT_DEVICE) { api.dispatch( TrezorConnectActions.getSelectedDeviceState() ); } else if (action.type === CONNECT.COIN_CHANGED) {