1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 01:08:27 +00:00

Fixed root path and some eslint

This commit is contained in:
Vladimir Volek 2018-08-14 16:06:34 +02:00
parent 82ef098c2a
commit efe180d432
32 changed files with 111 additions and 125 deletions

View File

@ -16,7 +16,7 @@
"regenerator": true "regenerator": true
}], }],
["module-resolver", { ["module-resolver", {
"root": ["."], "root": ["./src"],
"alias": { "alias": {
"config": "./src/js/config", "config": "./src/js/config",
"constants": "./src/js/constants", "constants": "./src/js/constants",

View File

@ -19,10 +19,10 @@
"dev:local": "webpack-dev-server --config ./webpack/config.dev.local.babel.js --mode development", "dev:local": "webpack-dev-server --config ./webpack/config.dev.local.babel.js --mode development",
"build": "rm -rf build && webpack --config ./webpack/config.prod.babel.js --progress", "build": "rm -rf build && webpack --config ./webpack/config.prod.babel.js --progress",
"flow": "flow check src/js", "flow": "flow check src/js",
"lint": "run-p lint:*", "lint": "run-s lint:*",
"lint:js": "eslint ./src/js ./webpack", "lint:js": "eslint ./src/js ./webpack",
"lint:css": "stylelint './src/js/**/*.js'", "lint:css": "stylelint './src/js/**/*.js'",
"test:*": "run-p test:*", "test:*": "run-s test:*",
"test:unit": "jest", "test:unit": "jest",
"test-unit:watch": "jest -o --watchAll" "test-unit:watch": "jest -o --watchAll"
}, },

View File

@ -7,16 +7,15 @@ import * as DISCOVERY from 'actions/constants/discovery';
import * as ACCOUNT from 'actions/constants/account'; import * as ACCOUNT from 'actions/constants/account';
import * as TOKEN from 'actions/constants/token'; import * as TOKEN from 'actions/constants/token';
import * as NOTIFICATION from 'actions/constants/notification'; import * as NOTIFICATION from 'actions/constants/notification';
import type {
ThunkAction, AsyncAction, Action, GetState, Dispatch, TrezorDevice,
} from 'flowtype';
import type { Discovery, State } from 'reducers/DiscoveryReducer';
import * as AccountsActions from './AccountsActions'; import * as AccountsActions from './AccountsActions';
import { getNonceAsync, getBalanceAsync, getTokenBalanceAsync } from './Web3Actions'; import { getNonceAsync, getBalanceAsync, getTokenBalanceAsync } from './Web3Actions';
import { setBalance as setTokenBalance } from './TokenActions'; import { setBalance as setTokenBalance } from './TokenActions';
import type {
ThunkAction, AsyncAction, Action, GetState, Dispatch, TrezorDevice,
} from 'flowtype';
import type { Discovery, State } from 'reducers/DiscoveryReducer';
export type DiscoveryAction = { export type DiscoveryAction = {
type: typeof DISCOVERY.FROM_STORAGE, type: typeof DISCOVERY.FROM_STORAGE,

View File

@ -7,8 +7,6 @@ import * as SEND from 'actions/constants/send';
import * as NOTIFICATION from 'actions/constants/notification'; import * as NOTIFICATION from 'actions/constants/notification';
import * as PENDING from 'actions/constants/pendingTx'; import * as PENDING from 'actions/constants/pendingTx';
import * as SendFormActions from './SendFormActions';
import * as SessionStorageActions from './SessionStorageActions';
import * as stateUtils from 'reducers/utils'; import * as stateUtils from 'reducers/utils';
import { initialState } from 'reducers/SelectedAccountReducer'; import { initialState } from 'reducers/SelectedAccountReducer';
@ -23,6 +21,8 @@ import type {
Dispatch, Dispatch,
State, State,
} from 'flowtype'; } from 'flowtype';
import * as SessionStorageActions from './SessionStorageActions';
import * as SendFormActions from './SendFormActions';
export type SelectedAccountAction = { export type SelectedAccountAction = {

View File

@ -8,8 +8,6 @@ import TrezorConnect from 'trezor-connect';
import { push } from 'react-router-redux'; import { push } from 'react-router-redux';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { strip } from 'utils/ethUtils'; import { strip } from 'utils/ethUtils';
import { estimateGas, getGasPrice, pushTx } from './Web3Actions';
import * as SessionStorageActions from './SessionStorageActions';
import * as NOTIFICATION from 'actions/constants/notification'; import * as NOTIFICATION from 'actions/constants/notification';
import * as SEND from 'actions/constants/send'; import * as SEND from 'actions/constants/send';
@ -36,6 +34,8 @@ import type { Token } from 'reducers/TokensReducer';
import type { State, FeeLevel } from 'reducers/SendFormReducer'; import type { State, FeeLevel } from 'reducers/SendFormReducer';
import type { Account } from 'reducers/AccountsReducer'; import type { Account } from 'reducers/AccountsReducer';
import type { Props } from 'components/wallet/account/send'; import type { Props } from 'components/wallet/account/send';
import * as SessionStorageActions from './SessionStorageActions';
import { estimateGas, getGasPrice, pushTx } from './Web3Actions';
export type SendTxAction = { export type SendTxAction = {
type: typeof SEND.TX_COMPLETE, type: typeof SEND.TX_COMPLETE,
@ -837,7 +837,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
}, },
useEmptyPassphrase: !selected.instance, useEmptyPassphrase: !selected.instance,
path: address_n, path: address_n,
transaction: txData transaction: txData,
}); });
if (!signedTransaction || !signedTransaction.success) { if (!signedTransaction || !signedTransaction.success) {

View File

@ -2,7 +2,6 @@
import * as TOKEN from 'actions/constants/token'; import * as TOKEN from 'actions/constants/token';
import { getTokenInfoAsync, getTokenBalanceAsync } from './Web3Actions';
import type { import type {
GetState, AsyncAction, Action, Dispatch, GetState, AsyncAction, Action, Dispatch,
@ -10,6 +9,7 @@ import type {
import type { State, Token } from 'reducers/TokensReducer'; import type { State, Token } from 'reducers/TokensReducer';
import type { Account } from 'reducers/AccountsReducer'; import type { Account } from 'reducers/AccountsReducer';
import type { NetworkToken } from 'reducers/LocalStorageReducer'; import type { NetworkToken } from 'reducers/LocalStorageReducer';
import { getTokenInfoAsync, getTokenBalanceAsync } from './Web3Actions';
export type TokenAction = { export type TokenAction = {
type: typeof TOKEN.FROM_STORAGE, type: typeof TOKEN.FROM_STORAGE,

View File

@ -10,7 +10,6 @@ import * as NOTIFICATION from 'actions/constants/notification';
import * as WALLET from 'actions/constants/wallet'; import * as WALLET from 'actions/constants/wallet';
import { push } from 'react-router-redux'; import { push } from 'react-router-redux';
import * as DiscoveryActions from './DiscoveryActions';
import { resolveAfter } from 'utils/promiseUtils'; import { resolveAfter } from 'utils/promiseUtils';
@ -33,6 +32,7 @@ import type {
TrezorDevice, TrezorDevice,
RouterLocationState, RouterLocationState,
} from 'flowtype'; } from 'flowtype';
import * as DiscoveryActions from './DiscoveryActions';
export type TrezorConnectAction = { export type TrezorConnectAction = {
@ -207,7 +207,7 @@ export const onSelectDevice = (device: TrezorDevice | Device): ThunkAction => (d
// switch to initial url and reset this value // switch to initial url and reset this value
if (!device.features) { if (!device.features) {
dispatch(push(`/device/${device.path}/${ device.type === 'unreadable' ? 'unreadable' : 'acquire' }`)); dispatch(push(`/device/${device.path}/${device.type === 'unreadable' ? 'unreadable' : 'acquire'}`));
} else if (device.features.bootloader_mode) { } else if (device.features.bootloader_mode) {
dispatch(push(`/device/${device.path}/bootloader`)); dispatch(push(`/device/${device.path}/bootloader`));
} else if (!device.features.initialized) { } else if (!device.features.initialized) {

View File

@ -75,8 +75,7 @@ export const toggleDeviceDropdown = (opened: boolean): WalletAction => ({
export const clearUnavailableDevicesData = (prevState: State, device: Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { export const clearUnavailableDevicesData = (prevState: State, device: Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
if (!device.features) return; if (!device.features) return;
const affectedDevices = prevState.devices.filter(d => const affectedDevices = prevState.devices.filter(d => d.features && device.features
d.features && device.features
&& d.features.device_id === device.features.device_id && d.features.device_id === device.features.device_id
&& d.features.passphrase_protection !== device.features.passphrase_protection); && d.features.passphrase_protection !== device.features.passphrase_protection);

View File

@ -13,8 +13,6 @@ import type { TransactionStatus, TransactionReceipt } from 'web3';
import { strip } from 'utils/ethUtils'; import { strip } from 'utils/ethUtils';
import * as WEB3 from 'actions/constants/web3'; import * as WEB3 from 'actions/constants/web3';
import * as PENDING from 'actions/constants/pendingTx'; import * as PENDING from 'actions/constants/pendingTx';
import * as AccountsActions from './AccountsActions';
import * as TokenActions from './TokenActions';
import type { import type {
Dispatch, Dispatch,
@ -28,6 +26,8 @@ import type { PendingTx } from 'reducers/PendingTxReducer';
import type { Web3Instance } from 'reducers/Web3Reducer'; import type { Web3Instance } from 'reducers/Web3Reducer';
import type { Token } from 'reducers/TokensReducer'; import type { Token } from 'reducers/TokensReducer';
import type { NetworkToken } from 'reducers/LocalStorageReducer'; import type { NetworkToken } from 'reducers/LocalStorageReducer';
import * as TokenActions from './TokenActions';
import * as AccountsActions from './AccountsActions';
export type Web3Action = { export type Web3Action = {
type: typeof WEB3.READY, type: typeof WEB3.READY,

View File

@ -2,8 +2,8 @@
import React from 'react'; import React from 'react';
import Preloader from './Preloader';
import { H2 } from 'components/common/Heading'; import { H2 } from 'components/common/Heading';
import Preloader from './Preloader';
import ConnectDevice from './ConnectDevice'; import ConnectDevice from './ConnectDevice';
import InstallBridge from './InstallBridge'; import InstallBridge from './InstallBridge';
import LocalStorageError from './LocalStorageError'; import LocalStorageError from './LocalStorageError';

View File

@ -5,10 +5,10 @@ import React from 'react';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import LandingPage from './LandingPage';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype'; import type { State, Dispatch } from 'flowtype';
import LandingPage from './LandingPage';
export type StateProps = { export type StateProps = {
localStorage: $ElementType<State, 'localStorage'>, localStorage: $ElementType<State, 'localStorage'>,

View File

@ -13,6 +13,11 @@ import { UI } from 'trezor-connect';
import { default as ModalActions } from 'actions/ModalActions'; import { default as ModalActions } from 'actions/ModalActions';
import { default as ReceiveActions } from 'actions/ReceiveActions'; import { default as ReceiveActions } from 'actions/ReceiveActions';
import * as RECEIVE from 'actions/constants/receive';
import * as MODAL from 'actions/constants/modal';
import * as CONNECT from 'actions/constants/TrezorConnect';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import Pin from './Pin'; import Pin from './Pin';
import InvalidPin from './InvalidPin'; import InvalidPin from './InvalidPin';
import Passphrase from './Passphrase'; import Passphrase from './Passphrase';
@ -22,12 +27,6 @@ import ConfirmAddress, { ConfirmUnverifiedAddress } from './ConfirmAddress';
import RememberDevice, { ForgetDevice } from './RememberDevice'; import RememberDevice, { ForgetDevice } from './RememberDevice';
import DuplicateDevice from './DuplicateDevice'; import DuplicateDevice from './DuplicateDevice';
import * as RECEIVE from 'actions/constants/receive';
import * as MODAL from 'actions/constants/modal';
import * as CONNECT from 'actions/constants/TrezorConnect';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
type OwnProps = { } type OwnProps = { }

View File

@ -6,8 +6,8 @@ import { H2 } from 'components/common/Heading';
import Tooltip from 'rc-tooltip'; import Tooltip from 'rc-tooltip';
import { QRCode } from 'react-qr-svg'; import { QRCode } from 'react-qr-svg';
import SelectedAccount from '../SelectedAccount';
import { Notification } from 'components/common/Notification'; import { Notification } from 'components/common/Notification';
import SelectedAccount from '../SelectedAccount';
import type { Props } from './index'; import type { Props } from './index';

View File

@ -8,9 +8,9 @@ import { connect } from 'react-redux';
import { default as ReceiveActions } from 'actions/ReceiveActions'; import { default as ReceiveActions } from 'actions/ReceiveActions';
import * as TokenActions from 'actions/TokenActions'; import * as TokenActions from 'actions/TokenActions';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import Receive from './Receive'; import Receive from './Receive';
import type { State, Dispatch } from 'flowtype';
import type { import type {
StateProps as BaseStateProps, StateProps as BaseStateProps,
DispatchProps as BaseDispatchProps, DispatchProps as BaseDispatchProps,

View File

@ -4,17 +4,17 @@ import React, { Component } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import Select from 'react-select'; import Select from 'react-select';
import { H2 } from 'components/common/Heading'; import { H2 } from 'components/common/Heading';
import { findAccountTokens } from 'reducers/TokensReducer';
import { calculate, validation } from 'actions/SendFormActions';
import { findToken } from 'reducers/TokensReducer';
import type { Token } from 'flowtype';
import AdvancedForm from './AdvancedForm'; import AdvancedForm from './AdvancedForm';
import PendingTransactions from './PendingTransactions'; import PendingTransactions from './PendingTransactions';
import { FeeSelectValue, FeeSelectOption } from './FeeSelect'; import { FeeSelectValue, FeeSelectOption } from './FeeSelect';
import SelectedAccount from '../SelectedAccount'; import SelectedAccount from '../SelectedAccount';
import { findAccountTokens } from 'reducers/TokensReducer';
import { calculate, validation } from 'actions/SendFormActions';
import { findToken } from 'reducers/TokensReducer';
import type { Props } from './index'; import type { Props } from './index';
import type { Token } from 'flowtype';
export default class SendContainer extends Component<Props> { export default class SendContainer extends Component<Props> {
componentWillReceiveProps(newProps: Props) { componentWillReceiveProps(newProps: Props) {

View File

@ -8,9 +8,9 @@ import { connect } from 'react-redux';
import { default as SendFormActions } from 'actions/SendFormActions'; import { default as SendFormActions } from 'actions/SendFormActions';
import * as SessionStorageActions from 'actions/SessionStorageActions'; import * as SessionStorageActions from 'actions/SessionStorageActions';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import SendForm from './SendForm'; import SendForm from './SendForm';
import type { State, Dispatch } from 'flowtype';
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount'; import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
type OwnProps = { } type OwnProps = { }

View File

@ -7,14 +7,14 @@ import { Async as AsyncSelect } from 'react-select';
import Tooltip from 'rc-tooltip'; import Tooltip from 'rc-tooltip';
import { resolveAfter } from 'utils/promiseUtils'; import { resolveAfter } from 'utils/promiseUtils';
import SelectedAccount from '../SelectedAccount';
import { Notification } from 'components/common/Notification'; import { Notification } from 'components/common/Notification';
import * as stateUtils from 'reducers/utils';
import type { NetworkToken } from 'reducers/LocalStorageReducer';
import SelectedAccount from '../SelectedAccount';
import SummaryDetails from './SummaryDetails.js'; import SummaryDetails from './SummaryDetails.js';
import SummaryTokens from './SummaryTokens.js'; import SummaryTokens from './SummaryTokens.js';
import * as stateUtils from 'reducers/utils';
import type { Props } from './index'; import type { Props } from './index';
import type { NetworkToken } from 'reducers/LocalStorageReducer';
const StyledH2 = styled(H2)` const StyledH2 = styled(H2)`
padding: 20px 48px; padding: 20px 48px;

View File

@ -4,8 +4,8 @@
import React from 'react'; import React from 'react';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import type { Props as BaseProps } from './index';
import type { Coin } from 'reducers/LocalStorageReducer'; import type { Coin } from 'reducers/LocalStorageReducer';
import type { Props as BaseProps } from './index';
type Props = { type Props = {
// coin: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'coin'>, // coin: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'coin'>,

View File

@ -6,11 +6,11 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import Summary from './Summary';
import * as SummaryActions from 'actions/SummaryActions'; import * as SummaryActions from 'actions/SummaryActions';
import * as TokenActions from 'actions/TokenActions'; import * as TokenActions from 'actions/TokenActions';
import type { State, Dispatch } from 'flowtype'; import type { State, Dispatch } from 'flowtype';
import Summary from './Summary';
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount'; import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
type OwnProps = { } type OwnProps = { }

View File

@ -10,8 +10,8 @@ import * as stateUtils from 'reducers/utils';
import Loader from 'components/common/LoaderCircle'; import Loader from 'components/common/LoaderCircle';
import Tooltip from 'rc-tooltip'; import Tooltip from 'rc-tooltip';
import type { Props } from './index';
import type { TrezorDevice, Accounts } from 'flowtype'; import type { TrezorDevice, Accounts } from 'flowtype';
import type { Props } from './index';
const AccountSelection = (props: Props): ?React$Element<string> => { const AccountSelection = (props: Props): ?React$Element<string> => {
const selected = props.wallet.selectedDevice; const selected = props.wallet.selectedDevice;

View File

@ -6,13 +6,13 @@ import * as React from 'react';
import { Link, NavLink } from 'react-router-dom'; import { Link, NavLink } from 'react-router-dom';
import { TransitionGroup, CSSTransition } from 'react-transition-group'; import { TransitionGroup, CSSTransition } from 'react-transition-group';
import type { TrezorDevice } from 'flowtype';
import { DeviceSelect, DeviceDropdown } from './DeviceSelection'; import { DeviceSelect, DeviceDropdown } from './DeviceSelection';
import AccountSelection from './AccountSelection'; import AccountSelection from './AccountSelection';
import CoinSelection from './CoinSelection'; import CoinSelection from './CoinSelection';
import StickyContainer from './StickyContainer'; import StickyContainer from './StickyContainer';
import type { Props } from './index'; import type { Props } from './index';
import type { TrezorDevice } from 'flowtype';
type TransitionMenuProps = { type TransitionMenuProps = {

View File

@ -4,8 +4,8 @@
import React from 'react'; import React from 'react';
import { Link, NavLink } from 'react-router-dom'; import { Link, NavLink } from 'react-router-dom';
import type { Props } from './index';
import type { TrezorDevice } from 'flowtype'; import type { TrezorDevice } from 'flowtype';
import type { Props } from './index';
const CoinSelection = (props: Props): React$Element<string> => { const CoinSelection = (props: Props): React$Element<string> => {
const { location } = props.router; const { location } = props.router;

View File

@ -5,8 +5,8 @@ import React, { Component } from 'react';
import Select from 'react-select'; import Select from 'react-select';
import TrezorConnect from 'trezor-connect'; import TrezorConnect from 'trezor-connect';
import type { Props } from './index';
import type { TrezorDevice } from 'flowtype'; import type { TrezorDevice } from 'flowtype';
import type { Props } from './index';
export const DeviceSelect = (props: Props) => { export const DeviceSelect = (props: Props) => {
const { devices } = props; const { devices } = props;
@ -25,18 +25,16 @@ export const DeviceSelect = (props: Props) => {
} else if (!selected.available) { } else if (!selected.available) {
css += ' unavailable'; css += ' unavailable';
deviceStatus = 'Unavailable'; deviceStatus = 'Unavailable';
} else { } else if (selected.type === 'acquired') {
if (selected.type === 'acquired') { if (selected.status === 'occupied') {
if (selected.status === 'occupied') { css += ' used-elsewhere';
css += ' used-elsewhere';
deviceStatus = 'Used in other window';
} else if (selected.status === 'used') {
css += ' reload-features';
}
} else if (selected.type === 'unacquired') {
css += ' unacquired';
deviceStatus = 'Used in other window'; deviceStatus = 'Used in other window';
} else if (selected.status === 'used') {
css += ' reload-features';
} }
} else if (selected.type === 'unacquired') {
css += ' unacquired';
deviceStatus = 'Used in other window';
} }
if (selected.features && selected.features.major_version > 1) { if (selected.features && selected.features.major_version > 1) {

View File

@ -9,10 +9,10 @@ import { withRouter } from 'react-router-dom';
import * as TrezorConnectActions from 'actions/TrezorConnectActions'; import * as TrezorConnectActions from 'actions/TrezorConnectActions';
import { toggleDeviceDropdown } from 'actions/WalletActions'; import { toggleDeviceDropdown } from 'actions/WalletActions';
import Aside from './Aside';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype'; import type { State, Dispatch } from 'flowtype';
import Aside from './Aside';
type OwnProps = { type OwnProps = {

View File

@ -5,6 +5,8 @@ import * as React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Route, withRouter } from 'react-router-dom'; import { Route, withRouter } from 'react-router-dom';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import Header from '../common/Header'; import Header from '../common/Header';
import Footer from '../common/Footer'; import Footer from '../common/Footer';
import AccountTabs from './account/AccountTabs'; import AccountTabs from './account/AccountTabs';
@ -14,8 +16,6 @@ import ModalContainer from '../modal';
import Notifications from '../common/Notification'; import Notifications from '../common/Notification';
import Log from '../common/Log'; import Log from '../common/Log';
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
type WalletContainerProps = { type WalletContainerProps = {
wallet: $ElementType<State, 'wallet'>, wallet: $ElementType<State, 'wallet'>,

View File

@ -14,18 +14,16 @@ type Props = {
acquireDevice: typeof TrezorConnectActions.acquire acquireDevice: typeof TrezorConnectActions.acquire
} }
const UnreadableDevice = (props: Props) => { const UnreadableDevice = (props: Props) => (
return ( <section className="acquire">
<section className="acquire"> <Notification
<Notification title="Unreadable device"
title="Unreadable device" message="Please install bridge"
message="Please install bridge" className="error"
className="error" cancelable={false}
cancelable={false} />
/> </section>
</section> );
);
};
export default connect( export default connect(
(state: State) => ({ (state: State) => ({

View File

@ -2,10 +2,10 @@
import React from 'react'; import React from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import baseStyles from 'support/BaseStyles'; import baseStyles from 'support/BaseStyles';
import store from './store';
import App from './router';
import { onBeforeUnload } from 'actions/WalletActions'; import { onBeforeUnload } from 'actions/WalletActions';
import styles from 'styles/index.less'; import 'styles/index.less';
import App from './router';
import store from './store';
const root: ?HTMLElement = document.getElementById('root'); const root: ?HTMLElement = document.getElementById('root');
if (root) { if (root) {

View File

@ -38,26 +38,25 @@ const mergeDevices = (current: TrezorDevice, upcoming: Device | TrezorDevice): T
instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName, instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName,
state: current.state, state: current.state,
ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts, ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts,
} };
if (upcoming.type === 'acquired') { if (upcoming.type === 'acquired') {
return { ...upcoming, ...extended }; return { ...upcoming, ...extended };
} else if (upcoming.type === 'unacquired' && current.features && current.state) { } if (upcoming.type === 'unacquired' && current.features && current.state) {
// corner-case: trying to merge unacquired device with acquired // corner-case: trying to merge unacquired device with acquired
// make sure that sensitive fields will not be changed and device will remain acquired // make sure that sensitive fields will not be changed and device will remain acquired
return { return {
type: 'acquired', type: 'acquired',
path: upcoming.path, path: upcoming.path,
...current, ...current,
...extended ...extended,
} };
} else {
return {
...upcoming,
features: null,
...extended
}
} }
return {
...upcoming,
features: null,
...extended,
};
}; };
const addDevice = (state: State, device: Device): State => { const addDevice = (state: State, device: Device): State => {
@ -72,10 +71,9 @@ const addDevice = (state: State, device: Device): State => {
} }
otherDevices = state.filter(d => affectedDevices.indexOf(d) === -1); otherDevices = state.filter(d => affectedDevices.indexOf(d) === -1);
} else { } else {
affectedDevices = state.filter(d => affectedDevices = state.filter(d => d.features
d.features && && device.features
device.features && && d.features.device_id === device.features.device_id);
d.features.device_id === device.features.device_id);
const unacquiredDevices = state.filter(d => d.path.length > 0 && d.path === device.path); const unacquiredDevices = state.filter(d => d.path.length > 0 && d.path === device.path);
otherDevices = state.filter(d => affectedDevices.indexOf(d) < 0 && unacquiredDevices.indexOf(d) < 0); otherDevices = state.filter(d => affectedDevices.indexOf(d) < 0 && unacquiredDevices.indexOf(d) < 0);
} }
@ -90,17 +88,17 @@ const addDevice = (state: State, device: Device): State => {
instanceLabel: device.label, instanceLabel: device.label,
instanceName: null, instanceName: null,
ts: new Date().getTime(), ts: new Date().getTime(),
} };
const newDevice: TrezorDevice = device.type === 'acquired' ? { const newDevice: TrezorDevice = device.type === 'acquired' ? {
...device, ...device,
// acquiring: false, // acquiring: false,
...extended ...extended,
} : { } : {
...device, ...device,
features: null, features: null,
...extended ...extended,
}; };
if (affectedDevices.length > 0) { if (affectedDevices.length > 0) {
@ -131,12 +129,11 @@ const addDevice = (state: State, device: Device): State => {
// changedDevices.push(newDevice); // changedDevices.push(newDevice);
// } // }
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && device.features
d.features && device.features && && d.features.passphrase_protection === device.features.passphrase_protection).map((d) => {
d.features.passphrase_protection === device.features.passphrase_protection).map(d => { const extended: Object = { connected: true, available: true };
const extended: Object = { connected: true, available: true } return mergeDevices(d, { ...device, ...extended });
return mergeDevices(d, { ...device, ...extended }) });
});
if (changedDevices.length !== affectedDevices.length) { if (changedDevices.length !== affectedDevices.length) {
changedDevices.push(newDevice); changedDevices.push(newDevice);
} }
@ -174,8 +171,7 @@ const changeDevice = (state: State, device: Device | TrezorDevice, extended: Obj
// find devices with the same device_id and passphrase_protection settings // find devices with the same device_id and passphrase_protection settings
// or devices with the same path (TODO: should be that way?) // or devices with the same path (TODO: should be that way?)
const affectedDevices: Array<TrezorDevice> = state.filter(d => const affectedDevices: Array<TrezorDevice> = state.filter(d => (d.features && device.features && d.features.device_id === device.features.device_id && d.features.passphrase_protection === device.features.passphrase_protection)
(d.features && device.features && d.features.device_id === device.features.device_id && d.features.passphrase_protection === device.features.passphrase_protection)
|| (d.features && d.path.length > 0 && d.path === device.path)); || (d.features && d.path.length > 0 && d.path === device.path));
const otherDevices: Array<TrezorDevice> = state.filter(d => affectedDevices.indexOf(d) === -1); const otherDevices: Array<TrezorDevice> = state.filter(d => affectedDevices.indexOf(d) === -1);
@ -207,15 +203,15 @@ const devicesFromStorage = (devices: Array<TrezorDevice>): State => devices.map(
connected: false, connected: false,
available: false, available: false,
path: '', path: '',
} };
return device.type === 'acquired' ? { return device.type === 'acquired' ? {
...device, ...device,
...extended ...extended,
} : { } : {
...device, ...device,
features: null, features: null,
...extended ...extended,
}; };
}); });
@ -236,7 +232,7 @@ const disconnectDevice = (state: State, device: Device): State => {
const otherDevices: State = state.filter(d => affectedDevices.indexOf(d) === -1); const otherDevices: State = state.filter(d => affectedDevices.indexOf(d) === -1);
if (affectedDevices.length > 0) { if (affectedDevices.length > 0) {
const acquiredDevices = affectedDevices.filter(d => d.features && d.state).map(d => { const acquiredDevices = affectedDevices.filter(d => d.features && d.state).map((d) => {
if (d.type === 'acquired') { if (d.type === 'acquired') {
d.connected = false; d.connected = false;
d.available = false; d.available = false;
@ -255,7 +251,7 @@ const onSelectedDevice = (state: State, device: ?TrezorDevice): State => {
if (device) { if (device) {
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== device); const otherDevices: Array<TrezorDevice> = state.filter(d => d !== device);
device.ts = new Date().getTime(); device.ts = new Date().getTime();
return otherDevices.concat([ device ]); return otherDevices.concat([device]);
} }
return state; return state;
}; };

View File

@ -1,26 +1,24 @@
/* @flow */ /* @flow */
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux'; import { routerReducer } from 'react-router-redux';
import log from './LogReducer.js'; import log from 'reducers/LogReducer';
import localStorage from './LocalStorageReducer.js'; import localStorage from 'reducers/LocalStorageReducer';
import connect from './TrezorConnectReducer.js'; import connect from 'reducers/TrezorConnectReducer';
import notifications from './NotificationReducer.js'; import notifications from 'reducers/NotificationReducer';
import modal from './ModalReducer.js'; import modal from 'reducers/ModalReducer';
import web3 from './Web3Reducer.js'; import web3 from 'reducers/Web3Reducer';
import accounts from './AccountsReducer.js'; import accounts from 'reducers/AccountsReducer';
import selectedAccount from './SelectedAccountReducer.js'; import selectedAccount from 'reducers/SelectedAccountReducer';
import sendForm from './SendFormReducer.js'; import sendForm from 'reducers/SendFormReducer';
import receive from './ReceiveReducer.js'; import receive from 'reducers/ReceiveReducer';
import summary from './SummaryReducer.js'; import summary from 'reducers/SummaryReducer';
import tokens from './TokensReducer.js'; import tokens from 'reducers/TokensReducer';
import discovery from './DiscoveryReducer.js'; import discovery from 'reducers/DiscoveryReducer';
import pending from './PendingTxReducer.js'; import pending from 'reducers/PendingTxReducer';
import fiat from './FiatRateReducer.js'; import fiat from 'reducers/FiatRateReducer';
import wallet from './WalletReducer.js'; import wallet from 'reducers/WalletReducer';
import devices from './DevicesReducer.js'; import devices from 'reducers/DevicesReducer';
const reducers = { const reducers = {
router: routerReducer, router: routerReducer,

View File

@ -3,7 +3,6 @@ import { hot } from 'react-hot-loader';
import { Route, Switch } from 'react-router-dom'; import { Route, Switch } from 'react-router-dom';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux'; import { ConnectedRouter } from 'react-router-redux';
import store, { history } from '../store';
import ErrorBoundary from 'support/ErrorBoundary'; import ErrorBoundary from 'support/ErrorBoundary';
@ -21,6 +20,7 @@ import ReceiveContainer from 'components/wallet/account/receive';
import SignVerifyContainer from 'components/wallet/account/sign/SignVerify'; import SignVerifyContainer from 'components/wallet/account/sign/SignVerify';
import DeviceSettingsContainer from 'components/wallet/pages/DeviceSettings'; import DeviceSettingsContainer from 'components/wallet/pages/DeviceSettings';
import WalletSettingsContainer from 'components/wallet/pages/WalletSettings'; import WalletSettingsContainer from 'components/wallet/pages/WalletSettings';
import store, { history } from '../store';
const App = () => ( const App = () => (
<Provider store={store}> <Provider store={store}>

View File

@ -1,6 +1,5 @@
/* @flow */ /* @flow */
import { JSONRequest, httpRequest } from 'utils/networkUtils'; import { JSONRequest, httpRequest } from 'utils/networkUtils';
import { resolveAfter } from 'utils/promiseUtils'; import { resolveAfter } from 'utils/promiseUtils';
import { READY } from 'actions/constants/localStorage'; import { READY } from 'actions/constants/localStorage';

View File

@ -5,7 +5,7 @@
// import Promise from 'es6-promise'; // import Promise from 'es6-promise';
export async function resolveAfter<T>(msec: number, value: any = null): Promise<T> { export async function resolveAfter<T>(msec: number, value: any = null): Promise<T> {
return await new Promise((resolve) => { await new Promise((resolve) => {
//root.setTimeout(resolve, msec, value); //root.setTimeout(resolve, msec, value);
window.setTimeout(resolve, msec, value); window.setTimeout(resolve, msec, value);
}); });