mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-28 09:58:23 +00:00
Filter log
This commit is contained in:
parent
2023157694
commit
d78381106e
@ -5,6 +5,7 @@
|
||||
"plugin:jest/recommended"
|
||||
],
|
||||
"globals": {
|
||||
"LOCAL": true,
|
||||
"COMMITHASH": true
|
||||
},
|
||||
"env": {
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* @flow */
|
||||
|
||||
|
||||
import * as LOG from 'actions/constants/log';
|
||||
|
||||
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 => ({
|
||||
type: LOG.ADD,
|
||||
payload: {
|
||||
|
@ -120,9 +120,7 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS
|
||||
});
|
||||
});
|
||||
|
||||
/* global LOCAL */
|
||||
// $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 window.LOCAL === 'string' ? window.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
|
||||
|
||||
try {
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* @flow */
|
||||
|
||||
import styled from 'styled-components';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
@ -28,21 +30,26 @@ const Copy = styled.div`
|
||||
margin-right: 20px;
|
||||
`;
|
||||
|
||||
const Footer = ({ toggle }) => (
|
||||
const Footer = ({ opened, toggle }) => (
|
||||
<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="/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>
|
||||
);
|
||||
|
||||
Footer.propTypes = {
|
||||
opened: PropTypes.bool.isRequired,
|
||||
toggle: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
opened: state.log.opened,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = 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 { H2 } from 'components/Heading';
|
||||
import Icon from 'components/Icon';
|
||||
import Paragraph from 'components/Paragraph';
|
||||
import P from 'components/Paragraph';
|
||||
|
||||
import * as LogActions from 'actions/LogActions';
|
||||
import icons from 'config/icons';
|
||||
@ -55,7 +55,7 @@ const Textarea = styled.textarea`
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledParagraph = styled(Paragraph)`
|
||||
const StyledParagraph = styled(P)`
|
||||
margin: 10px 0;
|
||||
`;
|
||||
|
||||
@ -67,7 +67,7 @@ const Log = (props: Props): ?React$Element<string> => {
|
||||
<Icon size={25} color={colors.INFO_PRIMARY} icon={icons.CLOSE} />
|
||||
</Click>
|
||||
<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 />
|
||||
</Wrapper>
|
||||
);
|
||||
|
@ -174,3 +174,6 @@ export type PromiseAction<R> = ReduxPromiseAction<State, Action, R>;
|
||||
|
||||
export type Store = ReduxStore<State, Action>;
|
||||
export type GetState = () => State;
|
||||
|
||||
declare var LOCAL: string;
|
||||
declare var COMMITHASH: string;
|
@ -1,13 +1,11 @@
|
||||
/* @flow */
|
||||
|
||||
|
||||
import * as LOG from 'actions/constants/log';
|
||||
import type { Action } from 'flowtype';
|
||||
|
||||
export type LogEntry = {
|
||||
time: number;
|
||||
type: string;
|
||||
// message: string;
|
||||
message: any;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
/* @flow */
|
||||
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 * as DISCOVERY from 'actions/constants/discovery';
|
||||
|
||||
import type {
|
||||
Middleware,
|
||||
@ -12,17 +10,11 @@ import type {
|
||||
Action,
|
||||
} from 'flowtype';
|
||||
|
||||
// const exclude: Array<string> = [
|
||||
// ADD, OPEN, CLOSE,
|
||||
// STORAGE.READY,
|
||||
// SEND.TX_COMPLETE,
|
||||
// 'web3__create',
|
||||
// ];
|
||||
|
||||
const include: Array<string> = [
|
||||
const actions: Array<string> = [
|
||||
TRANSPORT.START,
|
||||
DEVICE.CONNECT,
|
||||
DEVICE.DISCONNECT,
|
||||
DISCOVERY.START,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -31,17 +23,30 @@ const include: Array<string> = [
|
||||
const LogService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispatch) => (action: Action): Action => {
|
||||
next(action);
|
||||
|
||||
// if (exclude.indexOf(action.type) < 0) {
|
||||
if (include.indexOf(action.type) >= 0) {
|
||||
// api.dispatch(LogActions.add(action.type, JSON.stringify( action )));
|
||||
if (actions.indexOf(action.type) < 0) return action;
|
||||
|
||||
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));
|
||||
}
|
||||
switch (action.type) {
|
||||
case TRANSPORT.START:
|
||||
api.dispatch(LogActions.add('Transport', { type: action.payload.type, version: action.payload.version }));
|
||||
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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user