mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-29 02:18:06 +00:00
Filter log
This commit is contained in:
parent
2023157694
commit
d78381106e
@ -5,6 +5,7 @@
|
|||||||
"plugin:jest/recommended"
|
"plugin:jest/recommended"
|
||||||
],
|
],
|
||||||
"globals": {
|
"globals": {
|
||||||
|
"LOCAL": true,
|
||||||
"COMMITHASH": true
|
"COMMITHASH": true
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
|
|
||||||
import * as LOG from 'actions/constants/log';
|
import * as LOG from 'actions/constants/log';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
@ -31,7 +30,6 @@ export const toggle = (): ThunkAction => (dispatch: Dispatch, getState: GetState
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const add = (type: string, message: string): Action => {
|
|
||||||
export const add = (type: string, message: any): Action => ({
|
export const add = (type: string, message: any): Action => ({
|
||||||
type: LOG.ADD,
|
type: LOG.ADD,
|
||||||
payload: {
|
payload: {
|
||||||
|
@ -120,9 +120,7 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* global LOCAL */
|
window.__TREZOR_CONNECT_SRC = typeof window.LOCAL === 'string' ? window.LOCAL : 'https://sisyfos.trezor.io/connect/'; // eslint-disable-line no-underscore-dangle
|
||||||
// $FlowIssue LOCAL not declared
|
|
||||||
window.__TREZOR_CONNECT_SRC = typeof LOCAL === 'string' ? LOCAL : 'https://sisyfos.trezor.io/connect/'; // eslint-disable-line no-underscore-dangle
|
|
||||||
// window.__TREZOR_CONNECT_SRC = typeof LOCAL === 'string' ? LOCAL : 'https://connect.trezor.io/5/'; // eslint-disable-line no-underscore-dangle
|
// window.__TREZOR_CONNECT_SRC = typeof LOCAL === 'string' ? LOCAL : 'https://connect.trezor.io/5/'; // eslint-disable-line no-underscore-dangle
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -28,21 +30,26 @@ const Copy = styled.div`
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Footer = ({ toggle }) => (
|
const Footer = ({ opened, toggle }) => (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Copy title={COMMITHASH}>© {getYear(new Date())}</Copy>
|
<Copy title={window.COMMITHASH}>© {getYear(new Date())}</Copy>
|
||||||
<StyledLink href="http://satoshilabs.com" target="_blank" rel="noreferrer noopener" isGreen>SatoshiLabs</StyledLink>
|
<StyledLink href="http://satoshilabs.com" target="_blank" rel="noreferrer noopener" isGreen>SatoshiLabs</StyledLink>
|
||||||
<StyledLink href="/assets/tos.pdf" target="_blank" rel="noreferrer noopener" isGreen>Terms</StyledLink>
|
<StyledLink href="/assets/tos.pdf" target="_blank" rel="noreferrer noopener" isGreen>Terms</StyledLink>
|
||||||
<StyledLink onClick={toggle} isGreen>Show Log</StyledLink>
|
<StyledLink onClick={toggle} isGreen>{ opened ? 'Hide Log' : 'Show Log' }</StyledLink>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
Footer.propTypes = {
|
Footer.propTypes = {
|
||||||
|
opened: PropTypes.bool.isRequired,
|
||||||
toggle: PropTypes.func.isRequired,
|
toggle: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
opened: state.log.opened,
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
toggle: bindActionCreators(LogActions.toggle, dispatch),
|
toggle: bindActionCreators(LogActions.toggle, dispatch),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(Footer);
|
export default connect(mapStateToProps, mapDispatchToProps)(Footer);
|
||||||
|
@ -6,7 +6,7 @@ import { connect } from 'react-redux';
|
|||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
import { H2 } from 'components/Heading';
|
import { H2 } from 'components/Heading';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import Paragraph from 'components/Paragraph';
|
import P from 'components/Paragraph';
|
||||||
|
|
||||||
import * as LogActions from 'actions/LogActions';
|
import * as LogActions from 'actions/LogActions';
|
||||||
import icons from 'config/icons';
|
import icons from 'config/icons';
|
||||||
@ -55,7 +55,7 @@ const Textarea = styled.textarea`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledParagraph = styled(Paragraph)`
|
const StyledParagraph = styled(P)`
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ const Log = (props: Props): ?React$Element<string> => {
|
|||||||
<Icon size={25} color={colors.INFO_PRIMARY} icon={icons.CLOSE} />
|
<Icon size={25} color={colors.INFO_PRIMARY} icon={icons.CLOSE} />
|
||||||
</Click>
|
</Click>
|
||||||
<H2>Log</H2>
|
<H2>Log</H2>
|
||||||
<StyledParagraph>Attention: The log contains your XPUBs. Anyone with your XPUBs can see your account history.</StyledParagraph>
|
<StyledParagraph isSmaller>Attention: The log contains your XPUBs. Anyone with your XPUBs can see your account history.</StyledParagraph>
|
||||||
<Textarea value={JSON.stringify(props.log.entries)} readOnly />
|
<Textarea value={JSON.stringify(props.log.entries)} readOnly />
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
@ -174,3 +174,6 @@ export type PromiseAction<R> = ReduxPromiseAction<State, Action, R>;
|
|||||||
|
|
||||||
export type Store = ReduxStore<State, Action>;
|
export type Store = ReduxStore<State, Action>;
|
||||||
export type GetState = () => State;
|
export type GetState = () => State;
|
||||||
|
|
||||||
|
declare var LOCAL: string;
|
||||||
|
declare var COMMITHASH: string;
|
@ -1,13 +1,11 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
|
|
||||||
import * as LOG from 'actions/constants/log';
|
import * as LOG from 'actions/constants/log';
|
||||||
import type { Action } from 'flowtype';
|
import type { Action } from 'flowtype';
|
||||||
|
|
||||||
export type LogEntry = {
|
export type LogEntry = {
|
||||||
time: number;
|
time: number;
|
||||||
type: string;
|
type: string;
|
||||||
// message: string;
|
|
||||||
message: any;
|
message: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import * as LogActions from 'actions/LogActions';
|
import * as LogActions from 'actions/LogActions';
|
||||||
// import * as STORAGE from 'actions/constants/localStorage';
|
|
||||||
// import * as SEND from 'actions/constants/send';
|
|
||||||
// import { OPEN, CLOSE, ADD } from 'actions/constants/log';
|
|
||||||
import { TRANSPORT, DEVICE } from 'trezor-connect';
|
import { TRANSPORT, DEVICE } from 'trezor-connect';
|
||||||
|
import * as DISCOVERY from 'actions/constants/discovery';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
Middleware,
|
Middleware,
|
||||||
@ -12,17 +10,11 @@ import type {
|
|||||||
Action,
|
Action,
|
||||||
} from 'flowtype';
|
} from 'flowtype';
|
||||||
|
|
||||||
// const exclude: Array<string> = [
|
const actions: Array<string> = [
|
||||||
// ADD, OPEN, CLOSE,
|
|
||||||
// STORAGE.READY,
|
|
||||||
// SEND.TX_COMPLETE,
|
|
||||||
// 'web3__create',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
const include: Array<string> = [
|
|
||||||
TRANSPORT.START,
|
TRANSPORT.START,
|
||||||
DEVICE.CONNECT,
|
DEVICE.CONNECT,
|
||||||
DEVICE.DISCONNECT,
|
DEVICE.DISCONNECT,
|
||||||
|
DISCOVERY.START,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,17 +23,30 @@ const include: Array<string> = [
|
|||||||
const LogService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispatch) => (action: Action): Action => {
|
const LogService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispatch) => (action: Action): Action => {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
// if (exclude.indexOf(action.type) < 0) {
|
if (actions.indexOf(action.type) < 0) return action;
|
||||||
if (include.indexOf(action.type) >= 0) {
|
|
||||||
// api.dispatch(LogActions.add(action.type, JSON.stringify( action )));
|
|
||||||
|
|
||||||
if (action.type === TRANSPORT.START) {
|
switch (action.type) {
|
||||||
api.dispatch(LogActions.add('Transport', action.payload));
|
case TRANSPORT.START:
|
||||||
} else if (action.type === DEVICE.CONNECT) {
|
api.dispatch(LogActions.add('Transport', { type: action.payload.type, version: action.payload.version }));
|
||||||
api.dispatch(LogActions.add(action.type, action));
|
break;
|
||||||
}
|
case DEVICE.CONNECT:
|
||||||
|
api.dispatch(LogActions.add('Device connected', action.device));
|
||||||
|
break;
|
||||||
|
case DEVICE.DISCONNECT:
|
||||||
|
api.dispatch(LogActions.add('Device disconnected', action.device));
|
||||||
|
break;
|
||||||
|
case DISCOVERY.START:
|
||||||
|
api.dispatch(LogActions.add('Discovery started', action));
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (action.type === TRANSPORT.START) {
|
||||||
|
// api.dispatch(LogActions.add('Transport', action.payload));
|
||||||
|
// } else if (action.type === DEVICE.CONNECT) {
|
||||||
|
// api.dispatch(LogActions.add(action.type, action));
|
||||||
|
// }
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user