mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
Transport error + reconnect proper view in landingpage
This commit is contained in:
parent
c268c16649
commit
1e316ea9d2
@ -55,12 +55,12 @@ export const init = (): any => {
|
||||
|
||||
try {
|
||||
await TrezorConnect.init({
|
||||
transportReconnect: false,
|
||||
// connectSrc: 'https://localhost:8088/',
|
||||
connectSrc: 'https://sisyfos.trezor.io/',
|
||||
debug: false,
|
||||
transportReconnect: true,
|
||||
connectSrc: 'https://localhost:8088/',
|
||||
// connectSrc: 'https://sisyfos.trezor.io/',
|
||||
debug: true,
|
||||
popup: false,
|
||||
// webusb: false
|
||||
webusb: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
@ -89,6 +89,9 @@ export const postInit = (): any => {
|
||||
// // dispatch( remove(device) );
|
||||
// }
|
||||
|
||||
TrezorConnect.off(DEVICE.CONNECT, handleDeviceConnect);
|
||||
TrezorConnect.off(DEVICE.CONNECT_UNACQUIRED, handleDeviceConnect);
|
||||
|
||||
TrezorConnect.on(DEVICE.CONNECT, handleDeviceConnect);
|
||||
TrezorConnect.on(DEVICE.CONNECT_UNACQUIRED, handleDeviceConnect);
|
||||
|
||||
@ -159,14 +162,22 @@ export function onSelectDevice(device: any): any {
|
||||
}
|
||||
|
||||
// TODO: as TrezorConnect method
|
||||
const __getDeviceState = async (path, instance): Promise<any> => {
|
||||
return await TrezorConnect.getPublicKey({
|
||||
const __getDeviceState = async (path, instance, state): Promise<any> => {
|
||||
// return await TrezorConnect.getPublicKey({
|
||||
// device: {
|
||||
// path,
|
||||
// instance
|
||||
// },
|
||||
// path: "m/1'/0'/0'",
|
||||
// confirmation: false
|
||||
// });
|
||||
|
||||
return await TrezorConnect.getDeviceState({
|
||||
device: {
|
||||
path,
|
||||
instance
|
||||
instance,
|
||||
state
|
||||
},
|
||||
// selectedDevice: path,
|
||||
instance: instance,
|
||||
path: "m/1'/0'/0'",
|
||||
confirmation: false
|
||||
});
|
||||
@ -216,13 +227,13 @@ export const getSelectedDeviceState = (): any => {
|
||||
&& !selected.acquiring
|
||||
&& !selected.state) {
|
||||
|
||||
const response = await __getDeviceState(selected.path, selected.instance);
|
||||
const response = await __getDeviceState(selected.path, selected.instance, selected.state);
|
||||
|
||||
if (response && response.success) {
|
||||
dispatch({
|
||||
type: CONNECT.AUTH_DEVICE,
|
||||
device: selected,
|
||||
state: response.payload.xpub
|
||||
state: response.payload.state
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
|
@ -7,7 +7,8 @@ import TrezorConnect from 'trezor-connect';
|
||||
export default class InstallBridge extends Component {
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.props.transport.indexOf('webusb') >= 0)
|
||||
const transport = this.props.transport;
|
||||
if (transport && transport.type.indexOf('webusb') >= 0)
|
||||
TrezorConnect.renderWebUSBButton();
|
||||
}
|
||||
|
||||
@ -16,7 +17,8 @@ export default class InstallBridge extends Component {
|
||||
let connectClaim = 'Connect TREZOR to continue';
|
||||
let and = null;
|
||||
let bridgeClaim = null;
|
||||
if (this.props.transport.indexOf('webusb') >= 0) {
|
||||
const transport = this.props.transport;
|
||||
if (transport && transport.type.indexOf('webusb') >= 0) {
|
||||
webusb = <button className="trezor-webusb-button">Check for devices</button>;
|
||||
connectClaim = 'Connect TREZOR';
|
||||
and = <p>and</p>;
|
||||
|
@ -52,18 +52,18 @@ export default (props: any): any => {
|
||||
className="error"
|
||||
/>);
|
||||
css += ' config-error';
|
||||
} else if (!browserState.supported) {
|
||||
} else if (browserState.supported === false) {
|
||||
css += ' browser-not-supported'
|
||||
body = <BrowserNotSupported />;
|
||||
} else if (connectError || bridgeRoute) {
|
||||
css += ' install-bridge';
|
||||
body = <InstallBridge browserState={ props.connect.browserState } />;
|
||||
} else {
|
||||
} else if (web3.length > 0 && devices.length < 1) {
|
||||
css += ' connect-device';
|
||||
body = <ConnectDevice transport={ transport } />;
|
||||
}
|
||||
|
||||
if (notification || (web3.length > 0 && devices.length < 1)) {
|
||||
if (notification || body) {
|
||||
return (
|
||||
<div className={ css }>
|
||||
<Header />
|
||||
|
@ -16,6 +16,7 @@ export default class Receive extends AbstractAccount {
|
||||
const _render = (props: any): any => {
|
||||
|
||||
const {
|
||||
network,
|
||||
deviceState,
|
||||
accountIndex,
|
||||
addressVerified,
|
||||
|
@ -27,6 +27,9 @@ export default class AbstractAccount extends Component {
|
||||
}
|
||||
|
||||
const device = this.props.devices.find(d => d.state === state.deviceState);
|
||||
if (!device) {
|
||||
return (<section>Device with state {state.deviceState} not found</section>);
|
||||
}
|
||||
const discovery = props.discovery.find(d => d.deviceState === device.state && d.network === state.network);
|
||||
const account = props.accounts.find(a => a.deviceState === state.deviceState && a.index === state.accountIndex && a.network === state.network);
|
||||
|
||||
|
@ -144,12 +144,13 @@ export const DeviceSelect = (props: any): any => {
|
||||
}
|
||||
|
||||
console.log("DEVSEL", props)
|
||||
const disabled: boolean = (devices && devices.length <= 1 && transport && transport.type.indexOf('webusb') < 0);
|
||||
|
||||
return (
|
||||
<Value
|
||||
className="device-select"
|
||||
onClick={ handleMenuClick }
|
||||
disabled={ (devices && devices.length <= 1 && transport.indexOf('webusb') < 0) }
|
||||
disabled={ disabled }
|
||||
value={ selected }
|
||||
opened={ props.deviceDropdownOpened }
|
||||
onOpen={ () => props.toggleDeviceDropdown(true) }
|
||||
@ -167,10 +168,9 @@ export class DeviceDropdown extends Component {
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.props.connect.transport.indexOf('webusb') >= 0)
|
||||
const transport: any = this.props.connect.transport;
|
||||
if (transport && transport.type.indexOf('webusb') >= 0)
|
||||
TrezorConnect.renderWebUSBButton();
|
||||
|
||||
console.log("RENDER USB BUTTON")
|
||||
}
|
||||
|
||||
mouseDownHandler(event: MouseEvent): void {
|
||||
@ -198,8 +198,8 @@ export class DeviceDropdown extends Component {
|
||||
componentDidMount(): void {
|
||||
window.addEventListener('mousedown', this.mouseDownHandler, false);
|
||||
// window.addEventListener('blur', this.blurHandler, false);
|
||||
|
||||
if (this.props.connect.transport.indexOf('webusb') >= 0)
|
||||
const transport: any = this.props.connect.transport;
|
||||
if (transport && transport.type.indexOf('webusb') >= 0)
|
||||
TrezorConnect.renderWebUSBButton();
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ export class DeviceDropdown extends Component {
|
||||
const selected = findSelectedDevice(this.props.connect);
|
||||
|
||||
let webUsbButton = null;
|
||||
if (transport.indexOf('webusb') >= 0) {
|
||||
if (transport && transport.type.indexOf('webusb') >= 0) {
|
||||
webUsbButton = <button className="trezor-webusb-button">Check for devices</button>;
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,15 @@ const mergeDevices = (current: TrezorDevice, upcoming: Object): TrezorDevice =>
|
||||
}
|
||||
}
|
||||
|
||||
if (upcoming.features && current.features) {
|
||||
console.log("CZEKIN PASS PROT");
|
||||
if (upcoming.features.passphrase_protection !== current.features.passphrase_protection) {
|
||||
// device settings has been changed, reset state
|
||||
dev.state = null;
|
||||
console.log("RESTETTTT STATE!");
|
||||
}
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@ -155,14 +164,16 @@ const setDeviceState = (state: State, action: any): State => {
|
||||
//const affectedDevice: ?TrezorDevice = state.devices.find(d => d.path === action.device.path && d.instance === action.device.instance);
|
||||
const index: number = state.devices.findIndex(d => d.path === action.device.path && d.instance === action.device.instance);
|
||||
if (index > -1) {
|
||||
const changedDevice: TrezorDevice = {
|
||||
...newState.devices[index],
|
||||
state: action.state
|
||||
};
|
||||
newState.devices[index] = changedDevice;
|
||||
//newState.selectedDevice = changedDevice;
|
||||
console.warn("APGREDJS", newState.devices[index].state)
|
||||
// device could already have own state from firmware, do not override it
|
||||
if (!newState.devices[index].state) {
|
||||
const changedDevice: TrezorDevice = {
|
||||
...newState.devices[index],
|
||||
state: action.state
|
||||
};
|
||||
newState.devices[index] = changedDevice;
|
||||
}
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
|
||||
@ -307,7 +318,6 @@ export default function connect(state: State = initialState, action: any): any {
|
||||
browserState: action.payload.browser
|
||||
}
|
||||
|
||||
|
||||
case CONNECT.DUPLICATE :
|
||||
return duplicate(state, action.device);
|
||||
|
||||
@ -327,7 +337,8 @@ export default function connect(state: State = initialState, action: any): any {
|
||||
case TRANSPORT.START :
|
||||
return {
|
||||
...state,
|
||||
transport: action.payload
|
||||
transport: action.payload,
|
||||
error: null
|
||||
}
|
||||
|
||||
case TRANSPORT.ERROR :
|
||||
|
@ -26,6 +26,8 @@ const TrezorConnectService = (store: any) => (next: any) => (action: any) => {
|
||||
|
||||
} else if (action.type === TRANSPORT.ERROR) {
|
||||
store.dispatch( push('/') );
|
||||
} else if (action.type === TRANSPORT.START && store.getState().web3.length > 0 && prevState.devices.length > 0) {
|
||||
store.dispatch( TrezorConnectActions.postInit() );
|
||||
} else if (action.type === TRANSPORT.UNREADABLE) {
|
||||
store.dispatch({
|
||||
type: NOTIFICATION.ADD,
|
||||
|
Loading…
Reference in New Issue
Block a user