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:
parent
82ef098c2a
commit
efe180d432
2
.babelrc
2
.babelrc
@ -16,7 +16,7 @@
|
||||
"regenerator": true
|
||||
}],
|
||||
["module-resolver", {
|
||||
"root": ["."],
|
||||
"root": ["./src"],
|
||||
"alias": {
|
||||
"config": "./src/js/config",
|
||||
"constants": "./src/js/constants",
|
||||
|
@ -19,10 +19,10 @@
|
||||
"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",
|
||||
"flow": "flow check src/js",
|
||||
"lint": "run-p lint:*",
|
||||
"lint": "run-s lint:*",
|
||||
"lint:js": "eslint ./src/js ./webpack",
|
||||
"lint:css": "stylelint './src/js/**/*.js'",
|
||||
"test:*": "run-p test:*",
|
||||
"test:*": "run-s test:*",
|
||||
"test:unit": "jest",
|
||||
"test-unit:watch": "jest -o --watchAll"
|
||||
},
|
||||
|
@ -7,16 +7,15 @@ import * as DISCOVERY from 'actions/constants/discovery';
|
||||
import * as ACCOUNT from 'actions/constants/account';
|
||||
import * as TOKEN from 'actions/constants/token';
|
||||
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 { getNonceAsync, getBalanceAsync, getTokenBalanceAsync } from './Web3Actions';
|
||||
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 = {
|
||||
type: typeof DISCOVERY.FROM_STORAGE,
|
||||
|
@ -7,8 +7,6 @@ import * as SEND from 'actions/constants/send';
|
||||
import * as NOTIFICATION from 'actions/constants/notification';
|
||||
import * as PENDING from 'actions/constants/pendingTx';
|
||||
|
||||
import * as SendFormActions from './SendFormActions';
|
||||
import * as SessionStorageActions from './SessionStorageActions';
|
||||
import * as stateUtils from 'reducers/utils';
|
||||
|
||||
import { initialState } from 'reducers/SelectedAccountReducer';
|
||||
@ -23,6 +21,8 @@ import type {
|
||||
Dispatch,
|
||||
State,
|
||||
} from 'flowtype';
|
||||
import * as SessionStorageActions from './SessionStorageActions';
|
||||
import * as SendFormActions from './SendFormActions';
|
||||
|
||||
|
||||
export type SelectedAccountAction = {
|
||||
|
@ -8,8 +8,6 @@ import TrezorConnect from 'trezor-connect';
|
||||
import { push } from 'react-router-redux';
|
||||
import BigNumber from 'bignumber.js';
|
||||
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 SEND from 'actions/constants/send';
|
||||
|
||||
@ -36,6 +34,8 @@ import type { Token } from 'reducers/TokensReducer';
|
||||
import type { State, FeeLevel } from 'reducers/SendFormReducer';
|
||||
import type { Account } from 'reducers/AccountsReducer';
|
||||
import type { Props } from 'components/wallet/account/send';
|
||||
import * as SessionStorageActions from './SessionStorageActions';
|
||||
import { estimateGas, getGasPrice, pushTx } from './Web3Actions';
|
||||
|
||||
export type SendTxAction = {
|
||||
type: typeof SEND.TX_COMPLETE,
|
||||
@ -837,7 +837,7 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
|
||||
},
|
||||
useEmptyPassphrase: !selected.instance,
|
||||
path: address_n,
|
||||
transaction: txData
|
||||
transaction: txData,
|
||||
});
|
||||
|
||||
if (!signedTransaction || !signedTransaction.success) {
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
import * as TOKEN from 'actions/constants/token';
|
||||
import { getTokenInfoAsync, getTokenBalanceAsync } from './Web3Actions';
|
||||
|
||||
import type {
|
||||
GetState, AsyncAction, Action, Dispatch,
|
||||
@ -10,6 +9,7 @@ import type {
|
||||
import type { State, Token } from 'reducers/TokensReducer';
|
||||
import type { Account } from 'reducers/AccountsReducer';
|
||||
import type { NetworkToken } from 'reducers/LocalStorageReducer';
|
||||
import { getTokenInfoAsync, getTokenBalanceAsync } from './Web3Actions';
|
||||
|
||||
export type TokenAction = {
|
||||
type: typeof TOKEN.FROM_STORAGE,
|
||||
|
@ -10,7 +10,6 @@ import * as NOTIFICATION from 'actions/constants/notification';
|
||||
import * as WALLET from 'actions/constants/wallet';
|
||||
|
||||
import { push } from 'react-router-redux';
|
||||
import * as DiscoveryActions from './DiscoveryActions';
|
||||
import { resolveAfter } from 'utils/promiseUtils';
|
||||
|
||||
|
||||
@ -33,6 +32,7 @@ import type {
|
||||
TrezorDevice,
|
||||
RouterLocationState,
|
||||
} from 'flowtype';
|
||||
import * as DiscoveryActions from './DiscoveryActions';
|
||||
|
||||
|
||||
export type TrezorConnectAction = {
|
||||
@ -207,7 +207,7 @@ export const onSelectDevice = (device: TrezorDevice | Device): ThunkAction => (d
|
||||
// switch to initial url and reset this value
|
||||
|
||||
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) {
|
||||
dispatch(push(`/device/${device.path}/bootloader`));
|
||||
} else if (!device.features.initialized) {
|
||||
|
@ -75,8 +75,7 @@ export const toggleDeviceDropdown = (opened: boolean): WalletAction => ({
|
||||
export const clearUnavailableDevicesData = (prevState: State, device: Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||
if (!device.features) return;
|
||||
|
||||
const affectedDevices = prevState.devices.filter(d =>
|
||||
d.features && device.features
|
||||
const affectedDevices = prevState.devices.filter(d => d.features && device.features
|
||||
&& d.features.device_id === device.features.device_id
|
||||
&& d.features.passphrase_protection !== device.features.passphrase_protection);
|
||||
|
||||
|
@ -13,8 +13,6 @@ import type { TransactionStatus, TransactionReceipt } from 'web3';
|
||||
import { strip } from 'utils/ethUtils';
|
||||
import * as WEB3 from 'actions/constants/web3';
|
||||
import * as PENDING from 'actions/constants/pendingTx';
|
||||
import * as AccountsActions from './AccountsActions';
|
||||
import * as TokenActions from './TokenActions';
|
||||
|
||||
import type {
|
||||
Dispatch,
|
||||
@ -28,6 +26,8 @@ import type { PendingTx } from 'reducers/PendingTxReducer';
|
||||
import type { Web3Instance } from 'reducers/Web3Reducer';
|
||||
import type { Token } from 'reducers/TokensReducer';
|
||||
import type { NetworkToken } from 'reducers/LocalStorageReducer';
|
||||
import * as TokenActions from './TokenActions';
|
||||
import * as AccountsActions from './AccountsActions';
|
||||
|
||||
export type Web3Action = {
|
||||
type: typeof WEB3.READY,
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
|
||||
import React from 'react';
|
||||
import Preloader from './Preloader';
|
||||
import { H2 } from 'components/common/Heading';
|
||||
import Preloader from './Preloader';
|
||||
import ConnectDevice from './ConnectDevice';
|
||||
import InstallBridge from './InstallBridge';
|
||||
import LocalStorageError from './LocalStorageError';
|
||||
|
@ -5,10 +5,10 @@ import React from 'react';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import LandingPage from './LandingPage';
|
||||
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import LandingPage from './LandingPage';
|
||||
|
||||
export type StateProps = {
|
||||
localStorage: $ElementType<State, 'localStorage'>,
|
||||
|
@ -13,6 +13,11 @@ import { UI } from 'trezor-connect';
|
||||
import { default as ModalActions } from 'actions/ModalActions';
|
||||
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 InvalidPin from './InvalidPin';
|
||||
import Passphrase from './Passphrase';
|
||||
@ -22,12 +27,6 @@ import ConfirmAddress, { ConfirmUnverifiedAddress } from './ConfirmAddress';
|
||||
import RememberDevice, { ForgetDevice } from './RememberDevice';
|
||||
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 = { }
|
||||
|
||||
|
@ -6,8 +6,8 @@ import { H2 } from 'components/common/Heading';
|
||||
import Tooltip from 'rc-tooltip';
|
||||
import { QRCode } from 'react-qr-svg';
|
||||
|
||||
import SelectedAccount from '../SelectedAccount';
|
||||
import { Notification } from 'components/common/Notification';
|
||||
import SelectedAccount from '../SelectedAccount';
|
||||
|
||||
import type { Props } from './index';
|
||||
|
||||
|
@ -8,9 +8,9 @@ import { connect } from 'react-redux';
|
||||
import { default as ReceiveActions } from 'actions/ReceiveActions';
|
||||
import * as TokenActions from 'actions/TokenActions';
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import Receive from './Receive';
|
||||
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import type {
|
||||
StateProps as BaseStateProps,
|
||||
DispatchProps as BaseDispatchProps,
|
||||
|
@ -4,17 +4,17 @@ import React, { Component } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import Select from 'react-select';
|
||||
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 PendingTransactions from './PendingTransactions';
|
||||
import { FeeSelectValue, FeeSelectOption } from './FeeSelect';
|
||||
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 { Token } from 'flowtype';
|
||||
|
||||
export default class SendContainer extends Component<Props> {
|
||||
componentWillReceiveProps(newProps: Props) {
|
||||
|
@ -8,9 +8,9 @@ import { connect } from 'react-redux';
|
||||
import { default as SendFormActions } from 'actions/SendFormActions';
|
||||
import * as SessionStorageActions from 'actions/SessionStorageActions';
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import SendForm from './SendForm';
|
||||
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
|
||||
|
||||
type OwnProps = { }
|
||||
|
@ -7,14 +7,14 @@ import { Async as AsyncSelect } from 'react-select';
|
||||
import Tooltip from 'rc-tooltip';
|
||||
|
||||
import { resolveAfter } from 'utils/promiseUtils';
|
||||
import SelectedAccount from '../SelectedAccount';
|
||||
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 SummaryTokens from './SummaryTokens.js';
|
||||
import * as stateUtils from 'reducers/utils';
|
||||
|
||||
import type { Props } from './index';
|
||||
import type { NetworkToken } from 'reducers/LocalStorageReducer';
|
||||
|
||||
const StyledH2 = styled(H2)`
|
||||
padding: 20px 48px;
|
||||
|
@ -4,8 +4,8 @@
|
||||
import React from 'react';
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import type { Props as BaseProps } from './index';
|
||||
import type { Coin } from 'reducers/LocalStorageReducer';
|
||||
import type { Props as BaseProps } from './index';
|
||||
|
||||
type Props = {
|
||||
// coin: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'coin'>,
|
||||
|
@ -6,11 +6,11 @@ import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import Summary from './Summary';
|
||||
import * as SummaryActions from 'actions/SummaryActions';
|
||||
import * as TokenActions from 'actions/TokenActions';
|
||||
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import Summary from './Summary';
|
||||
import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from '../SelectedAccount';
|
||||
|
||||
type OwnProps = { }
|
||||
|
@ -10,8 +10,8 @@ import * as stateUtils from 'reducers/utils';
|
||||
import Loader from 'components/common/LoaderCircle';
|
||||
import Tooltip from 'rc-tooltip';
|
||||
|
||||
import type { Props } from './index';
|
||||
import type { TrezorDevice, Accounts } from 'flowtype';
|
||||
import type { Props } from './index';
|
||||
|
||||
const AccountSelection = (props: Props): ?React$Element<string> => {
|
||||
const selected = props.wallet.selectedDevice;
|
||||
|
@ -6,13 +6,13 @@ import * as React from 'react';
|
||||
import { Link, NavLink } from 'react-router-dom';
|
||||
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
||||
|
||||
import type { TrezorDevice } from 'flowtype';
|
||||
import { DeviceSelect, DeviceDropdown } from './DeviceSelection';
|
||||
import AccountSelection from './AccountSelection';
|
||||
import CoinSelection from './CoinSelection';
|
||||
import StickyContainer from './StickyContainer';
|
||||
|
||||
import type { Props } from './index';
|
||||
import type { TrezorDevice } from 'flowtype';
|
||||
|
||||
|
||||
type TransitionMenuProps = {
|
||||
|
@ -4,8 +4,8 @@
|
||||
import React from 'react';
|
||||
import { Link, NavLink } from 'react-router-dom';
|
||||
|
||||
import type { Props } from './index';
|
||||
import type { TrezorDevice } from 'flowtype';
|
||||
import type { Props } from './index';
|
||||
|
||||
const CoinSelection = (props: Props): React$Element<string> => {
|
||||
const { location } = props.router;
|
||||
|
@ -5,8 +5,8 @@ import React, { Component } from 'react';
|
||||
import Select from 'react-select';
|
||||
import TrezorConnect from 'trezor-connect';
|
||||
|
||||
import type { Props } from './index';
|
||||
import type { TrezorDevice } from 'flowtype';
|
||||
import type { Props } from './index';
|
||||
|
||||
export const DeviceSelect = (props: Props) => {
|
||||
const { devices } = props;
|
||||
@ -25,18 +25,16 @@ export const DeviceSelect = (props: Props) => {
|
||||
} else if (!selected.available) {
|
||||
css += ' unavailable';
|
||||
deviceStatus = 'Unavailable';
|
||||
} else {
|
||||
if (selected.type === 'acquired') {
|
||||
if (selected.status === 'occupied') {
|
||||
css += ' used-elsewhere';
|
||||
deviceStatus = 'Used in other window';
|
||||
} else if (selected.status === 'used') {
|
||||
css += ' reload-features';
|
||||
}
|
||||
} else if (selected.type === 'unacquired') {
|
||||
css += ' unacquired';
|
||||
} else if (selected.type === 'acquired') {
|
||||
if (selected.status === 'occupied') {
|
||||
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';
|
||||
}
|
||||
|
||||
if (selected.features && selected.features.major_version > 1) {
|
||||
|
@ -9,10 +9,10 @@ import { withRouter } from 'react-router-dom';
|
||||
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
||||
import { toggleDeviceDropdown } from 'actions/WalletActions';
|
||||
|
||||
import Aside from './Aside';
|
||||
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
import Aside from './Aside';
|
||||
|
||||
type OwnProps = {
|
||||
|
||||
|
@ -5,6 +5,8 @@ import * as React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
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 Footer from '../common/Footer';
|
||||
import AccountTabs from './account/AccountTabs';
|
||||
@ -14,8 +16,6 @@ import ModalContainer from '../modal';
|
||||
import Notifications from '../common/Notification';
|
||||
import Log from '../common/Log';
|
||||
|
||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||
import type { State, Dispatch } from 'flowtype';
|
||||
|
||||
type WalletContainerProps = {
|
||||
wallet: $ElementType<State, 'wallet'>,
|
||||
|
@ -14,18 +14,16 @@ type Props = {
|
||||
acquireDevice: typeof TrezorConnectActions.acquire
|
||||
}
|
||||
|
||||
const UnreadableDevice = (props: Props) => {
|
||||
return (
|
||||
<section className="acquire">
|
||||
<Notification
|
||||
title="Unreadable device"
|
||||
message="Please install bridge"
|
||||
className="error"
|
||||
cancelable={false}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
const UnreadableDevice = (props: Props) => (
|
||||
<section className="acquire">
|
||||
<Notification
|
||||
title="Unreadable device"
|
||||
message="Please install bridge"
|
||||
className="error"
|
||||
cancelable={false}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
|
||||
export default connect(
|
||||
(state: State) => ({
|
||||
|
@ -2,10 +2,10 @@
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import baseStyles from 'support/BaseStyles';
|
||||
import store from './store';
|
||||
import App from './router';
|
||||
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');
|
||||
if (root) {
|
||||
|
@ -38,26 +38,25 @@ const mergeDevices = (current: TrezorDevice, upcoming: Device | TrezorDevice): T
|
||||
instanceName: typeof upcoming.instanceName === 'string' ? upcoming.instanceName : current.instanceName,
|
||||
state: current.state,
|
||||
ts: typeof upcoming.ts === 'number' ? upcoming.ts : current.ts,
|
||||
}
|
||||
};
|
||||
|
||||
if (upcoming.type === 'acquired') {
|
||||
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
|
||||
// make sure that sensitive fields will not be changed and device will remain acquired
|
||||
return {
|
||||
type: 'acquired',
|
||||
path: upcoming.path,
|
||||
...current,
|
||||
...extended
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
...upcoming,
|
||||
features: null,
|
||||
...extended
|
||||
}
|
||||
...extended,
|
||||
};
|
||||
}
|
||||
return {
|
||||
...upcoming,
|
||||
features: null,
|
||||
...extended,
|
||||
};
|
||||
};
|
||||
|
||||
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);
|
||||
} else {
|
||||
affectedDevices = state.filter(d =>
|
||||
d.features &&
|
||||
device.features &&
|
||||
d.features.device_id === device.features.device_id);
|
||||
affectedDevices = state.filter(d => d.features
|
||||
&& device.features
|
||||
&& d.features.device_id === device.features.device_id);
|
||||
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);
|
||||
}
|
||||
@ -90,17 +88,17 @@ const addDevice = (state: State, device: Device): State => {
|
||||
instanceLabel: device.label,
|
||||
instanceName: null,
|
||||
ts: new Date().getTime(),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const newDevice: TrezorDevice = device.type === 'acquired' ? {
|
||||
...device,
|
||||
// acquiring: false,
|
||||
...extended
|
||||
...extended,
|
||||
} : {
|
||||
...device,
|
||||
features: null,
|
||||
...extended
|
||||
...extended,
|
||||
};
|
||||
|
||||
if (affectedDevices.length > 0) {
|
||||
@ -131,12 +129,11 @@ const addDevice = (state: State, device: Device): State => {
|
||||
// changedDevices.push(newDevice);
|
||||
// }
|
||||
|
||||
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d =>
|
||||
d.features && device.features &&
|
||||
d.features.passphrase_protection === device.features.passphrase_protection).map(d => {
|
||||
const extended: Object = { connected: true, available: true }
|
||||
return mergeDevices(d, { ...device, ...extended })
|
||||
});
|
||||
const changedDevices: Array<TrezorDevice> = affectedDevices.filter(d => d.features && device.features
|
||||
&& d.features.passphrase_protection === device.features.passphrase_protection).map((d) => {
|
||||
const extended: Object = { connected: true, available: true };
|
||||
return mergeDevices(d, { ...device, ...extended });
|
||||
});
|
||||
if (changedDevices.length !== affectedDevices.length) {
|
||||
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
|
||||
// or devices with the same path (TODO: should be that way?)
|
||||
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)
|
||||
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 && d.path.length > 0 && d.path === device.path));
|
||||
|
||||
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,
|
||||
available: false,
|
||||
path: '',
|
||||
}
|
||||
};
|
||||
|
||||
return device.type === 'acquired' ? {
|
||||
...device,
|
||||
...extended
|
||||
...extended,
|
||||
} : {
|
||||
...device,
|
||||
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);
|
||||
|
||||
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') {
|
||||
d.connected = false;
|
||||
d.available = false;
|
||||
@ -255,7 +251,7 @@ const onSelectedDevice = (state: State, device: ?TrezorDevice): State => {
|
||||
if (device) {
|
||||
const otherDevices: Array<TrezorDevice> = state.filter(d => d !== device);
|
||||
device.ts = new Date().getTime();
|
||||
return otherDevices.concat([ device ]);
|
||||
return otherDevices.concat([device]);
|
||||
}
|
||||
return state;
|
||||
};
|
||||
|
@ -1,26 +1,24 @@
|
||||
/* @flow */
|
||||
|
||||
|
||||
import { combineReducers } from 'redux';
|
||||
import { routerReducer } from 'react-router-redux';
|
||||
|
||||
import log from './LogReducer.js';
|
||||
import localStorage from './LocalStorageReducer.js';
|
||||
import connect from './TrezorConnectReducer.js';
|
||||
import notifications from './NotificationReducer.js';
|
||||
import modal from './ModalReducer.js';
|
||||
import web3 from './Web3Reducer.js';
|
||||
import accounts from './AccountsReducer.js';
|
||||
import selectedAccount from './SelectedAccountReducer.js';
|
||||
import sendForm from './SendFormReducer.js';
|
||||
import receive from './ReceiveReducer.js';
|
||||
import summary from './SummaryReducer.js';
|
||||
import tokens from './TokensReducer.js';
|
||||
import discovery from './DiscoveryReducer.js';
|
||||
import pending from './PendingTxReducer.js';
|
||||
import fiat from './FiatRateReducer.js';
|
||||
import wallet from './WalletReducer.js';
|
||||
import devices from './DevicesReducer.js';
|
||||
import log from 'reducers/LogReducer';
|
||||
import localStorage from 'reducers/LocalStorageReducer';
|
||||
import connect from 'reducers/TrezorConnectReducer';
|
||||
import notifications from 'reducers/NotificationReducer';
|
||||
import modal from 'reducers/ModalReducer';
|
||||
import web3 from 'reducers/Web3Reducer';
|
||||
import accounts from 'reducers/AccountsReducer';
|
||||
import selectedAccount from 'reducers/SelectedAccountReducer';
|
||||
import sendForm from 'reducers/SendFormReducer';
|
||||
import receive from 'reducers/ReceiveReducer';
|
||||
import summary from 'reducers/SummaryReducer';
|
||||
import tokens from 'reducers/TokensReducer';
|
||||
import discovery from 'reducers/DiscoveryReducer';
|
||||
import pending from 'reducers/PendingTxReducer';
|
||||
import fiat from 'reducers/FiatRateReducer';
|
||||
import wallet from 'reducers/WalletReducer';
|
||||
import devices from 'reducers/DevicesReducer';
|
||||
|
||||
const reducers = {
|
||||
router: routerReducer,
|
||||
|
@ -3,7 +3,6 @@ import { hot } from 'react-hot-loader';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { ConnectedRouter } from 'react-router-redux';
|
||||
import store, { history } from '../store';
|
||||
|
||||
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 DeviceSettingsContainer from 'components/wallet/pages/DeviceSettings';
|
||||
import WalletSettingsContainer from 'components/wallet/pages/WalletSettings';
|
||||
import store, { history } from '../store';
|
||||
|
||||
const App = () => (
|
||||
<Provider store={store}>
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* @flow */
|
||||
|
||||
|
||||
import { JSONRequest, httpRequest } from 'utils/networkUtils';
|
||||
import { resolveAfter } from 'utils/promiseUtils';
|
||||
import { READY } from 'actions/constants/localStorage';
|
||||
|
@ -5,7 +5,7 @@
|
||||
// import Promise from 'es6-promise';
|
||||
|
||||
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);
|
||||
window.setTimeout(resolve, msec, value);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user