mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 03:08:30 +00:00
Remove START & STOP_ACQUIRING action
This commit is contained in:
parent
a5b6e20525
commit
ae4b27d968
@ -322,7 +322,7 @@ export const restore = (): ThunkAction => {
|
|||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const selected = findSelectedDevice(getState().connect);
|
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);
|
const discoveryProcess: ?Discovery = getState().discovery.find(d => d.deviceState === selected.state && d.waitingForDevice);
|
||||||
if (discoveryProcess) {
|
if (discoveryProcess) {
|
||||||
dispatch( start(selected, discoveryProcess.network) );
|
dispatch( start(selected, discoveryProcess.network) );
|
||||||
|
@ -80,15 +80,6 @@ export type TrezorConnectAction = {
|
|||||||
} | {
|
} | {
|
||||||
type: typeof CONNECT.DEVICE_FROM_STORAGE,
|
type: typeof CONNECT.DEVICE_FROM_STORAGE,
|
||||||
payload: Array<TrezorDevice>
|
payload: Array<TrezorDevice>
|
||||||
} | {
|
|
||||||
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
|
if (selected
|
||||||
&& selected.connected
|
&& selected.connected
|
||||||
&& selected.features
|
&& selected.features
|
||||||
&& !selected.acquiring
|
|
||||||
&& !selected.state) {
|
&& !selected.state) {
|
||||||
|
|
||||||
const response = await TrezorConnect.getDeviceState({
|
const response = await TrezorConnect.getDeviceState({
|
||||||
@ -389,47 +379,13 @@ export function acquire(): AsyncAction {
|
|||||||
const selected: ?TrezorDevice = findSelectedDevice(getState().connect);
|
const selected: ?TrezorDevice = findSelectedDevice(getState().connect);
|
||||||
if (!selected) return;
|
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({
|
const response = await TrezorConnect.getFeatures({
|
||||||
device: {
|
device: {
|
||||||
path: selected.path,
|
path: selected.path,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const selected2: ?TrezorDevice = findSelectedDevice(getState().connect);
|
if (!response.success) {
|
||||||
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?
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: NOTIFICATION.ADD,
|
type: NOTIFICATION.ADD,
|
||||||
payload: {
|
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<any> = getState().accounts.find(a => a.deviceState === device.state);
|
|
||||||
|
|
||||||
|
|
||||||
// find discovery processes associated with this device
|
|
||||||
// const discovery: Array<any> = getState().discovery.find(d => d.deviceState === device.state);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const gotoDeviceSettings = (device: TrezorDevice): ThunkAction => {
|
export const gotoDeviceSettings = (device: TrezorDevice): ThunkAction => {
|
||||||
return (dispatch: Dispatch, getState: GetState): void => {
|
return (dispatch: Dispatch, getState: GetState): void => {
|
||||||
if (device.features) {
|
if (device.features) {
|
||||||
|
@ -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 DISCONNECT_REQUEST: 'connect__disconnect_request' = 'connect__disconnect_request';
|
||||||
export const REMEMBER: 'connect__remember' = 'connect__remember';
|
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 TRY_TO_DUPLICATE: 'connect__try_to_duplicate' = 'connect__try_to_duplicate';
|
||||||
export const DUPLICATE: 'connect__duplicate' = 'connect__duplicate';
|
export const DUPLICATE: 'connect__duplicate' = 'connect__duplicate';
|
||||||
|
|
||||||
|
@ -46,18 +46,6 @@ const Aside = (props: Props): React$Element<typeof StickyContainer | string> =>
|
|||||||
|
|
||||||
if (location.pathname === '/' || !selected) return (<aside></aside>);
|
if (location.pathname === '/' || !selected) return (<aside></aside>);
|
||||||
|
|
||||||
// TODO
|
|
||||||
// if (selectedDevice.unacquired) {
|
|
||||||
// return (
|
|
||||||
// <aside>
|
|
||||||
// <div className="transition-container"></div>
|
|
||||||
// <a className="help" href="https://trezor.io/support/" target="_blank" rel="noreferrer noopener">
|
|
||||||
// Need help?
|
|
||||||
// </a>
|
|
||||||
// </aside>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
let menu = <section></section>;
|
let menu = <section></section>;
|
||||||
|
|
||||||
if (props.deviceDropdownOpened) {
|
if (props.deviceDropdownOpened) {
|
||||||
|
@ -154,7 +154,7 @@ export class DeviceDropdown extends Component<Props> {
|
|||||||
if (selected.isUsedElsewhere) {
|
if (selected.isUsedElsewhere) {
|
||||||
deviceMenuItems.push({ type: "reload", label: "Renew session" });
|
deviceMenuItems.push({ type: "reload", label: "Renew session" });
|
||||||
} else if (selected.featuresNeedsReload) {
|
} 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" });
|
deviceMenuItems.push({ type: "settings", label: "Device settings" });
|
||||||
|
@ -43,9 +43,9 @@ import type {
|
|||||||
import type { RouterAction, LocationState } from 'react-router-redux';
|
import type { RouterAction, LocationState } from 'react-router-redux';
|
||||||
|
|
||||||
export type TrezorDevice = {
|
export type TrezorDevice = {
|
||||||
remember: boolean;
|
remember: boolean; // device should be remembered
|
||||||
connected: boolean;
|
connected: boolean; // device is connected
|
||||||
available: boolean; // device cannot be used because of features.passphrase_protection is different then expected (saved)
|
available: boolean; // device cannot be used because of features.passphrase_protection is different then expected
|
||||||
path: string;
|
path: string;
|
||||||
label: string;
|
label: string;
|
||||||
state: ?string;
|
state: ?string;
|
||||||
@ -54,23 +54,6 @@ export type TrezorDevice = {
|
|||||||
instanceName: ?string;
|
instanceName: ?string;
|
||||||
features?: Features;
|
features?: Features;
|
||||||
unacquired?: boolean;
|
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;
|
isUsedElsewhere?: boolean;
|
||||||
featuresNeedsReload?: boolean;
|
featuresNeedsReload?: boolean;
|
||||||
ts: number;
|
ts: number;
|
||||||
|
@ -9,14 +9,14 @@ declare module 'trezor-connect' {
|
|||||||
DISCONNECT: 'device__disconnect',
|
DISCONNECT: 'device__disconnect',
|
||||||
DISCONNECT_UNACQUIRED: 'device__disconnect_unacquired',
|
DISCONNECT_UNACQUIRED: 'device__disconnect_unacquired',
|
||||||
|
|
||||||
ACQUIRE: 'device__acquire', // remove? internal
|
// ACQUIRE: 'device__acquire', // remove? internal
|
||||||
RELEASE: 'device__release', // internal
|
// RELEASE: 'device__release', // internal
|
||||||
ACQUIRED: 'device__acquired',
|
// ACQUIRED: 'device__acquired',
|
||||||
RELEASED: 'device__released', // internal
|
// RELEASED: 'device__released', // internal
|
||||||
USED_ELSEWHERE: 'device__used_elsewhere', // internal
|
// USED_ELSEWHERE: 'device__used_elsewhere', // internal
|
||||||
CHANGED: 'device__changed',
|
CHANGED: 'device__changed',
|
||||||
|
|
||||||
LOADING: 'device__loading', // internal
|
// LOADING: 'device__loading', // internal
|
||||||
|
|
||||||
// trezor-link events
|
// trezor-link events
|
||||||
BUTTON: 'button',
|
BUTTON: 'button',
|
||||||
|
@ -128,7 +128,6 @@ const mergeDevices = (current: TrezorDevice, upcoming: Object): TrezorDevice =>
|
|||||||
instanceLabel,
|
instanceLabel,
|
||||||
instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName,
|
instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName,
|
||||||
state: current.state,
|
state: current.state,
|
||||||
acquiring: typeof upcoming.acquiring === 'boolean' ? upcoming.acquiring : current.acquiring,
|
|
||||||
ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts,
|
ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts,
|
||||||
}
|
}
|
||||||
// corner-case: trying to merge unacquired device with acquired
|
// corner-case: trying to merge unacquired device with acquired
|
||||||
@ -281,8 +280,6 @@ const disconnectDevice = (state: State, device: Device): State => {
|
|||||||
d.available = false;
|
d.available = false;
|
||||||
d.isUsedElsewhere = false;
|
d.isUsedElsewhere = false;
|
||||||
d.featuresNeedsReload = false;
|
d.featuresNeedsReload = false;
|
||||||
d.acquiring = false;
|
|
||||||
//if (d.remember)
|
|
||||||
d.path = '';
|
d.path = '';
|
||||||
return d;
|
return d;
|
||||||
}));
|
}));
|
||||||
@ -432,9 +429,6 @@ export default function connect(state: State = initialState, action: Action): St
|
|||||||
|
|
||||||
case CONNECT.AUTH_DEVICE :
|
case CONNECT.AUTH_DEVICE :
|
||||||
return setDeviceState(state, action);
|
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 :
|
case CONNECT.REMEMBER :
|
||||||
return changeDevice(state, { ...action.device, path: '', remember: true } );
|
return changeDevice(state, { ...action.device, path: '', remember: true } );
|
||||||
|
|
||||||
|
@ -56,11 +56,8 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa
|
|||||||
});
|
});
|
||||||
} else if (action.type === DEVICE.DISCONNECT) {
|
} else if (action.type === DEVICE.DISCONNECT) {
|
||||||
api.dispatch( TrezorConnectActions.deviceDisconnect(action.device) );
|
api.dispatch( TrezorConnectActions.deviceDisconnect(action.device) );
|
||||||
|
|
||||||
} else if (action.type === CONNECT.REMEMBER_REQUEST) {
|
} else if (action.type === CONNECT.REMEMBER_REQUEST) {
|
||||||
|
|
||||||
api.dispatch(ModalActions.onRememberRequest(prevModalState));
|
api.dispatch(ModalActions.onRememberRequest(prevModalState));
|
||||||
|
|
||||||
} else if (action.type === CONNECT.FORGET) {
|
} else if (action.type === CONNECT.FORGET) {
|
||||||
//api.dispatch( TrezorConnectActions.forgetDevice(action.device) );
|
//api.dispatch( TrezorConnectActions.forgetDevice(action.device) );
|
||||||
api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() );
|
api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() );
|
||||||
@ -75,15 +72,6 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa
|
|||||||
} else {
|
} else {
|
||||||
api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() );
|
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) {
|
} else if (action.type === DEVICE.CONNECT || action.type === DEVICE.CONNECT_UNACQUIRED) {
|
||||||
|
|
||||||
api.dispatch( DiscoveryActions.restore() );
|
api.dispatch( DiscoveryActions.restore() );
|
||||||
@ -109,7 +97,6 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa
|
|||||||
api.dispatch( DiscoveryActions.check() );
|
api.dispatch( DiscoveryActions.check() );
|
||||||
} else if (action.type === CONNECT.DUPLICATE) {
|
} else if (action.type === CONNECT.DUPLICATE) {
|
||||||
api.dispatch( TrezorConnectActions.selectDuplicatedDevice() );
|
api.dispatch( TrezorConnectActions.selectDuplicatedDevice() );
|
||||||
// } else if (action.type === CONNECT.ACQUIRED || action.type === CONNECT.SELECT_DEVICE) {
|
|
||||||
} else if (action.type === CONNECT.SELECT_DEVICE) {
|
} else if (action.type === CONNECT.SELECT_DEVICE) {
|
||||||
api.dispatch( TrezorConnectActions.getSelectedDeviceState() );
|
api.dispatch( TrezorConnectActions.getSelectedDeviceState() );
|
||||||
} else if (action.type === CONNECT.COIN_CHANGED) {
|
} else if (action.type === CONNECT.COIN_CHANGED) {
|
||||||
|
Loading…
Reference in New Issue
Block a user