diff --git a/common/Root.tsx b/common/Root.tsx index d283b1f2..811b4e16 100644 --- a/common/Root.tsx +++ b/common/Root.tsx @@ -4,7 +4,7 @@ import { Provider, connect } from 'react-redux'; import { withRouter, Switch, HashRouter, Route, BrowserRouter } from 'react-router-dom'; import { AppState } from 'features/reducers'; -import { getNetworkUnit, getTheme } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { transactionMetaActions } from 'features/transaction'; // Components import Contracts from 'containers/Tabs/Contracts'; @@ -34,8 +34,8 @@ interface OwnProps { } interface StateProps { - networkUnit: ReturnType; - theme: ReturnType; + networkUnit: ReturnType; + theme: ReturnType; } interface DispatchProps { @@ -203,8 +203,8 @@ const CaptureRouteNotFound = withRouter(({ children, location }) => { }); const mapStateToProps = (state: AppState): StateProps => ({ - networkUnit: getNetworkUnit(state), - theme: getTheme(state) + networkUnit: configSelectors.getNetworkUnit(state), + theme: configMetaSelectors.getTheme(state) }); export default connect(mapStateToProps, { diff --git a/common/components/AddressBookTable.tsx b/common/components/AddressBookTable.tsx index 1667b5f4..71663bfa 100644 --- a/common/components/AddressBookTable.tsx +++ b/common/components/AddressBookTable.tsx @@ -4,7 +4,7 @@ import classnames from 'classnames'; import translate, { translateRaw } from 'translations'; import { AppState } from 'features/reducers'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { addressBookConstants, addressBookActions, @@ -25,7 +25,7 @@ interface StateProps { entry: ReturnType; addressLabels: ReturnType; labelAddresses: ReturnType; - toChecksumAddress: ReturnType; + toChecksumAddress: ReturnType; } type Props = DispatchProps & StateProps; @@ -302,7 +302,7 @@ const mapStateToProps: MapStateToProps = state => ({ entry: addressBookSelectors.getAddressBookTableEntry(state), addressLabels: addressBookSelectors.getAddressLabels(state), labelAddresses: addressBookSelectors.getLabelAddresses(state), - toChecksumAddress: getChecksumAddressFn(state) + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }); const mapDispatchToProps: DispatchProps = { diff --git a/common/components/AddressField.tsx b/common/components/AddressField.tsx index 62af5f4d..cdb490e9 100644 --- a/common/components/AddressField.tsx +++ b/common/components/AddressField.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { donationAddressMap } from 'config'; import translate from 'translations'; import { AppState } from 'features/reducers'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { Input } from 'components/ui'; import { AddressFieldFactory } from './AddressFieldFactory'; @@ -16,7 +16,7 @@ interface OwnProps { } interface StateProps { - toChecksumAddress: ReturnType; + toChecksumAddress: ReturnType; } type Props = OwnProps & StateProps; @@ -56,5 +56,5 @@ const AddressField: React.SFC = ({ ); export default connect((state: AppState): StateProps => ({ - toChecksumAddress: getChecksumAddressFn(state) + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }))(AddressField); diff --git a/common/components/BalanceSidebar/AccountInfo.tsx b/common/components/BalanceSidebar/AccountInfo.tsx index 2dda2434..b697d0d3 100644 --- a/common/components/BalanceSidebar/AccountInfo.tsx +++ b/common/components/BalanceSidebar/AccountInfo.tsx @@ -6,7 +6,7 @@ import translate, { translateRaw } from 'translations'; import { IWallet, HardwareWallet, Balance } from 'libs/wallet'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getNetworkConfig, getOffline, getChecksumAddressFn } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { walletActions } from 'features/wallet'; import Spinner from 'components/ui/Spinner'; import { UnitDisplay, NewTabLink } from 'components/ui'; @@ -19,9 +19,9 @@ interface OwnProps { interface StateProps { balance: Balance; - network: ReturnType; - isOffline: ReturnType; - toChecksumAddress: ReturnType; + network: ReturnType; + isOffline: ReturnType; + toChecksumAddress: ReturnType; } interface State { @@ -199,9 +199,9 @@ function isHardwareWallet(wallet: IWallet): wallet is HardwareWallet { function mapStateToProps(state: AppState): StateProps { return { balance: state.wallet.balance, - network: getNetworkConfig(state), - isOffline: getOffline(state), - toChecksumAddress: getChecksumAddressFn(state) + network: configSelectors.getNetworkConfig(state), + isOffline: configMetaSelectors.getOffline(state), + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }; } const mapDispatchToProps: DispatchProps = { diff --git a/common/components/BalanceSidebar/EquivalentValues.tsx b/common/components/BalanceSidebar/EquivalentValues.tsx index bdadcc80..092615e9 100644 --- a/common/components/BalanceSidebar/EquivalentValues.tsx +++ b/common/components/BalanceSidebar/EquivalentValues.tsx @@ -10,7 +10,7 @@ import { NetworkConfig } from 'types/network'; import { Balance } from 'libs/wallet'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getOffline, getNetworkConfig } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { ratesActions } from 'features/rates'; import { walletTypes } from 'features/wallet'; import { UnitDisplay, Spinner } from 'components/ui'; @@ -324,10 +324,10 @@ function mapStateToProps(state: AppState): StateProps { return { balance: state.wallet.balance, tokenBalances: selectors.getShownTokenBalances(state, true), - network: getNetworkConfig(state), + network: configSelectors.getNetworkConfig(state), rates: state.rates.rates, ratesError: state.rates.ratesError, - isOffline: getOffline(state) + isOffline: configMetaSelectors.getOffline(state) }; } diff --git a/common/components/BalanceSidebar/TokenBalances/index.tsx b/common/components/BalanceSidebar/TokenBalances/index.tsx index 79d783cc..8a1c288b 100644 --- a/common/components/BalanceSidebar/TokenBalances/index.tsx +++ b/common/components/BalanceSidebar/TokenBalances/index.tsx @@ -5,7 +5,7 @@ import translate from 'translations'; import { Token } from 'types/network'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getAllTokens, getOffline } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { customTokensActions } from 'features/customTokens'; import { walletTypes, walletActions, walletSelectors } from 'features/wallet'; import Spinner from 'components/ui/Spinner'; @@ -111,12 +111,12 @@ function mapStateToProps(state: AppState): StateProps { return { wallet: walletSelectors.getWalletInst(state), walletConfig: walletSelectors.getWalletConfig(state), - tokens: getAllTokens(state), + tokens: configSelectors.getAllTokens(state), tokenBalances: selectors.getTokenBalances(state), tokensError: state.wallet.tokensError, isTokensLoading: state.wallet.isTokensLoading, hasSavedWalletTokens: state.wallet.hasSavedWalletTokens, - isOffline: getOffline(state) + isOffline: configMetaSelectors.getOffline(state) }; } diff --git a/common/components/ConfirmationModal/components/Body/Body.tsx b/common/components/ConfirmationModal/components/Body/Body.tsx index b11394da..765548a2 100644 --- a/common/components/ConfirmationModal/components/Body/Body.tsx +++ b/common/components/ConfirmationModal/components/Body/Body.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import translate from 'translations'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { Addresses } from './components/Addresses'; import { Amounts } from './components/Amounts'; import { Details } from './components/Details'; @@ -55,7 +55,7 @@ class BodyClass extends React.Component { const mapStateToProps = (state: AppState): StateProps => { return { - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }; }; diff --git a/common/components/ConfirmationModal/components/Body/components/Addresses.tsx b/common/components/ConfirmationModal/components/Body/components/Addresses.tsx index 27857328..2e9854c8 100644 --- a/common/components/ConfirmationModal/components/Body/components/Addresses.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Addresses.tsx @@ -6,7 +6,7 @@ import translate from 'translations'; import ERC20 from 'libs/erc20'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import arrow from 'assets/images/tail-triangle-down.svg'; import { SerializedTransaction } from 'components/renderCbs'; import { Identicon } from 'components/ui'; @@ -16,7 +16,7 @@ interface StateProps { from: ReturnType; unit: ReturnType; isToken: boolean; - toChecksumAddress: ReturnType; + toChecksumAddress: ReturnType; } const size = '3rem'; @@ -94,7 +94,7 @@ const mapStateToProps = (state: AppState): StateProps => ({ from: selectors.getFrom(state), isToken: !selectors.isEtherTransaction(state), unit: selectors.getUnit(state), - toChecksumAddress: getChecksumAddressFn(state) + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }); export const Addresses = connect(mapStateToProps)(AddressesClass); diff --git a/common/components/ConfirmationModal/components/Body/components/Amounts.tsx b/common/components/ConfirmationModal/components/Body/components/Amounts.tsx index d05637a3..dd7d9066 100644 --- a/common/components/ConfirmationModal/components/Body/components/Amounts.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Amounts.tsx @@ -5,7 +5,7 @@ import translate from 'translations'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { transactionSignTypes } from 'features/transaction'; import { UnitDisplay } from 'components/ui'; import './Amounts.scss'; @@ -112,7 +112,7 @@ class AmountsClass extends Component { const mapStateToProps = (state: AppState): StateProps => ({ ...derivedSelectors.getParamsFromSerializedTx(state), ...derivedSelectors.getAllUSDValuesFromSerializedTx(state), - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }); export const Amounts = connect(mapStateToProps)(AmountsClass); diff --git a/common/components/ConfirmationModal/components/Body/components/Details.tsx b/common/components/ConfirmationModal/components/Body/components/Details.tsx index d83b3c16..519f31ab 100644 --- a/common/components/ConfirmationModal/components/Body/components/Details.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Details.tsx @@ -6,7 +6,7 @@ import translate, { translateRaw } from 'translations'; import { NodeConfig } from 'types/node'; import { CodeBlock, Input } from 'components/ui'; import { AppState } from 'features/reducers'; -import { getNodeConfig } from 'features/config'; +import { configNodesSelectors } from 'features/config'; import { SerializedTransaction } from 'components/renderCbs'; import './Details.scss'; @@ -52,6 +52,6 @@ class DetailsClass extends Component { } } -const mapStateToProps = (state: AppState) => ({ node: getNodeConfig(state) }); +const mapStateToProps = (state: AppState) => ({ node: configNodesSelectors.getNodeConfig(state) }); export const Details = connect(mapStateToProps)(DetailsClass); diff --git a/common/components/ConfirmationModal/components/Body/components/Node.tsx b/common/components/ConfirmationModal/components/Body/components/Node.tsx index 2dfe85e7..27d0917c 100644 --- a/common/components/ConfirmationModal/components/Body/components/Node.tsx +++ b/common/components/ConfirmationModal/components/Body/components/Node.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import translate from 'translations'; import { StaticNodeConfig } from 'types/node'; import { AppState } from 'features/reducers'; -import { getNodeConfig } from 'features/config'; +import { configNodesSelectors } from 'features/config'; interface StateProps { node: StaticNodeConfig; @@ -22,5 +22,5 @@ class NodeClass extends Component { } export const Node = connect((state: AppState) => ({ - node: getNodeConfig(state) + node: configNodesSelectors.getNodeConfig(state) }))(NodeClass); diff --git a/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx b/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx index d07912cf..a8f05be1 100644 --- a/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx +++ b/common/components/ConfirmationModalTemplate/ConfirmationModalTemplate.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { translateRaw, translate } from 'translations'; import { AppState } from 'features/reducers'; -import { getLanguageSelection } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { transactionBroadcastActions, transactionSelectors } from 'features/transaction'; import { walletSelectors } from 'features/wallet'; import Modal, { IButton } from 'components/ui/Modal'; @@ -130,7 +130,7 @@ class ConfirmationModalTemplateClass extends React.Component { export const ConfirmationModalTemplate = connect( (state: AppState) => ({ transactionBroadcasting: transactionSelectors.currentTransactionBroadcasting(state), - lang: getLanguageSelection(state), + lang: configMetaSelectors.getLanguageSelection(state), walletTypes: walletSelectors.getWalletType(state) }), { diff --git a/common/components/CurrentCustomMessage.tsx b/common/components/CurrentCustomMessage.tsx index 2c6081e2..98c5b4d5 100644 --- a/common/components/CurrentCustomMessage.tsx +++ b/common/components/CurrentCustomMessage.tsx @@ -6,7 +6,7 @@ import { Token } from 'types/network'; import { ICurrentTo } from 'features/types'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import { getAllTokens } from 'features/config'; +import { configSelectors } from 'features/config'; import { walletSelectors } from 'features/wallet'; import { Address } from 'components/ui'; @@ -119,6 +119,6 @@ class CurrentCustomMessageClass extends PureComponent { export const CurrentCustomMessage = connect((state: AppState): ReduxProps => ({ currentTo: derivedSelectors.getCurrentTo(state), - tokens: getAllTokens(state), + tokens: configSelectors.getAllTokens(state), wallet: walletSelectors.getWalletInst(state) }))(CurrentCustomMessageClass); diff --git a/common/components/CustomNodeModal/CustomNodeModal.tsx b/common/components/CustomNodeModal/CustomNodeModal.tsx index 5efdb552..a522228a 100644 --- a/common/components/CustomNodeModal/CustomNodeModal.tsx +++ b/common/components/CustomNodeModal/CustomNodeModal.tsx @@ -7,12 +7,11 @@ import { CustomNetworkConfig } from 'types/network'; import { CustomNodeConfig } from 'types/node'; import { AppState } from 'features/reducers'; import { - getCustomNetworkConfigs, - getStaticNetworkConfigs, - getCustomNodeConfigs, - AddCustomNodeAction, - TAddCustomNetwork, - addCustomNetwork + configNodesCustomSelectors, + configNetworksStaticSelectors, + configNetworksCustomSelectors, + configNetworksCustomActions, + configNodesCustomTypes } from 'features/config'; import { Input, Dropdown } from 'components/ui'; import Modal, { IButton } from 'components/ui/Modal'; @@ -22,12 +21,12 @@ const CUSTOM = { label: 'Custom', value: 'custom' }; interface OwnProps { isOpen: boolean; - addCustomNode(payload: AddCustomNodeAction['payload']): void; + addCustomNode(payload: configNodesCustomTypes.AddCustomNodeAction['payload']): void; handleClose(): void; } interface DispatchProps { - addCustomNetwork: TAddCustomNetwork; + addCustomNetwork: configNetworksCustomActions.TAddCustomNetwork; } interface StateProps { @@ -447,13 +446,13 @@ class CustomNodeModal extends React.Component { } const mapStateToProps = (state: AppState): StateProps => ({ - customNetworks: getCustomNetworkConfigs(state), - customNodes: getCustomNodeConfigs(state), - staticNetworks: getStaticNetworkConfigs(state) + customNetworks: configNetworksCustomSelectors.getCustomNetworkConfigs(state), + customNodes: configNodesCustomSelectors.getCustomNodeConfigs(state), + staticNetworks: configNetworksStaticSelectors.getStaticNetworkConfigs(state) }); const mapDispatchToProps: DispatchProps = { - addCustomNetwork + addCustomNetwork: configNetworksCustomActions.addCustomNetwork }; export default connect(mapStateToProps, mapDispatchToProps)(CustomNodeModal); diff --git a/common/components/ElectronNav/ElectronNav.tsx b/common/components/ElectronNav/ElectronNav.tsx index b70172f3..36bb7baa 100644 --- a/common/components/ElectronNav/ElectronNav.tsx +++ b/common/components/ElectronNav/ElectronNav.tsx @@ -7,16 +7,16 @@ import NavigationLink from 'components/NavigationLink'; import NetworkSelect from './NetworkSelect'; import LanguageSelect from './LanguageSelect'; import NetworkStatus from './NetworkStatus'; -import { changeTheme, getTheme } from 'features/config'; +import { configMetaActions, configMetaSelectors } from 'features/config'; import { AppState } from 'features/reducers'; import './ElectronNav.scss'; interface StateProps { - theme: ReturnType; + theme: ReturnType; } interface ActionProps { - changeTheme: typeof changeTheme; + changeTheme: typeof configMetaActions.changeTheme; } type Props = StateProps & ActionProps; @@ -122,9 +122,9 @@ class ElectronNav extends React.Component { export default connect( (state: AppState) => ({ - theme: getTheme(state) + theme: configMetaSelectors.getTheme(state) }), { - changeTheme + changeTheme: configMetaActions.changeTheme } )(ElectronNav); diff --git a/common/components/ElectronNav/LanguageSelect.tsx b/common/components/ElectronNav/LanguageSelect.tsx index 078c445e..623a84ee 100644 --- a/common/components/ElectronNav/LanguageSelect.tsx +++ b/common/components/ElectronNav/LanguageSelect.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { languages } from 'config'; import { AppState } from 'features/reducers'; -import { getLanguageSelection, TChangeLanguage, changeLanguage } from 'features/config'; +import { configMetaActions, configMetaSelectors } from 'features/config'; import './LanguageSelect.scss'; interface OwnProps { @@ -16,7 +16,7 @@ interface StateProps { } interface DispatchProps { - changeLanguage: TChangeLanguage; + changeLanguage: configMetaActions.TChangeLanguage; } type Props = OwnProps & StateProps & DispatchProps; @@ -50,9 +50,9 @@ class LanguageSelect extends React.Component { export default connect( (state: AppState): StateProps => ({ - languageSelection: getLanguageSelection(state) + languageSelection: configMetaSelectors.getLanguageSelection(state) }), { - changeLanguage + changeLanguage: configMetaActions.changeLanguage } )(LanguageSelect); diff --git a/common/components/ElectronNav/NetworkSelect.tsx b/common/components/ElectronNav/NetworkSelect.tsx index 10e29e7d..4cdb0e7c 100644 --- a/common/components/ElectronNav/NetworkSelect.tsx +++ b/common/components/ElectronNav/NetworkSelect.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { connect } from 'react-redux'; -import { TAddCustomNode, AddCustomNodeAction, addCustomNode } from 'features/config'; +import { configNodesCustomTypes, configNodesCustomActions } from 'features/config'; import NetworkSelector from 'components/NetworkSelector'; import CustomNodeModal from 'components/CustomNodeModal'; @@ -10,7 +10,7 @@ interface OwnProps { } interface DispatchProps { - addCustomNode: TAddCustomNode; + addCustomNode: configNodesCustomActions.TAddCustomNode; } type Props = OwnProps & DispatchProps; @@ -50,11 +50,13 @@ class NetworkSelect extends React.Component { this.setState({ isAddingCustomNode: false }); }; - private addCustomNode = (payload: AddCustomNodeAction['payload']) => { + private addCustomNode = (payload: configNodesCustomTypes.AddCustomNodeAction['payload']) => { this.closeCustomNodeModal(); this.props.addCustomNode(payload); this.props.closePanel(); }; } -export default connect(undefined, { addCustomNode })(NetworkSelect); +export default connect(undefined, { addCustomNode: configNodesCustomActions.addCustomNode })( + NetworkSelect +); diff --git a/common/components/ElectronNav/NetworkStatus.tsx b/common/components/ElectronNav/NetworkStatus.tsx index 718f7975..2f69063d 100644 --- a/common/components/ElectronNav/NetworkStatus.tsx +++ b/common/components/ElectronNav/NetworkStatus.tsx @@ -4,7 +4,11 @@ import { connect } from 'react-redux'; import translate from 'translations'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getOffline, getNetworkConfig, isNodeChanging } from 'features/config'; +import { + configMetaSelectors, + configSelectors, + configNodesSelectedSelectors +} from 'features/config'; import './NetworkStatus.scss'; enum NETWORK_STATUS { @@ -44,7 +48,7 @@ const NetworkStatus: React.SFC = ({ isOffline, isChangingNode, netwo }; export default connect((state: AppState): StateProps => ({ - network: getNetworkConfig(state), - isOffline: getOffline(state), - isChangingNode: isNodeChanging(state) + network: configSelectors.getNetworkConfig(state), + isOffline: configMetaSelectors.getOffline(state), + isChangingNode: configNodesSelectedSelectors.isNodeChanging(state) }))(NetworkStatus); diff --git a/common/components/Footer/ThemeToggle.tsx b/common/components/Footer/ThemeToggle.tsx index 5e2fb6dc..ba7603ad 100644 --- a/common/components/Footer/ThemeToggle.tsx +++ b/common/components/Footer/ThemeToggle.tsx @@ -1,16 +1,16 @@ import React from 'react'; import { connect } from 'react-redux'; import { Theme } from 'config'; -import { getTheme, changeTheme } from 'features/config'; +import { configMetaActions, configMetaSelectors } from 'features/config'; import { AppState } from 'features/reducers'; import './ThemeToggle.scss'; interface ActionProps { - changeTheme: typeof changeTheme; + changeTheme: typeof configMetaActions.changeTheme; } interface StateProps { - theme: ReturnType; + theme: ReturnType; } type Props = ActionProps & StateProps; @@ -35,9 +35,9 @@ class ThemeToggle extends React.Component { export default connect( (state: AppState) => ({ - theme: getTheme(state) + theme: configMetaSelectors.getTheme(state) }), { - changeTheme + changeTheme: configMetaActions.changeTheme } )(ThemeToggle); diff --git a/common/components/GasLimitFieldFactory/GasLimitInputFactory.tsx b/common/components/GasLimitFieldFactory/GasLimitInputFactory.tsx index 763a8a86..f3e9ccae 100644 --- a/common/components/GasLimitFieldFactory/GasLimitInputFactory.tsx +++ b/common/components/GasLimitFieldFactory/GasLimitInputFactory.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { AppState } from 'features/reducers'; -import { getAutoGasLimitEnabled } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { transactionFieldsSelectors, transactionNetworkSelectors } from 'features/transaction'; import { CallBackProps } from 'components/GasLimitFieldFactory'; import { Query } from 'components/renderCbs'; @@ -40,5 +40,5 @@ class GasLimitInputClass extends Component { export const GasLimitInput = connect((state: AppState) => ({ gasLimit: transactionFieldsSelectors.getGasLimit(state), gasEstimationPending: transactionNetworkSelectors.getGasEstimationPending(state), - autoGasLimitEnabled: getAutoGasLimitEnabled(state) + autoGasLimitEnabled: configMetaSelectors.getAutoGasLimitEnabled(state) }))(GasLimitInputClass); diff --git a/common/components/Header/components/NetworkDropdown.tsx b/common/components/Header/components/NetworkDropdown.tsx index 92972c29..e7ea6556 100644 --- a/common/components/Header/components/NetworkDropdown.tsx +++ b/common/components/Header/components/NetworkDropdown.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { AppState } from 'features/reducers'; -import { getNodeConfig, getSelectedNodeLabel } from 'features/config'; +import { configNodesSelectors, configSelectors } from 'features/config'; import { DropdownShell } from 'components/ui'; import NetworkSelector from 'components/NetworkSelector'; import './NetworkDropdown.scss'; @@ -12,8 +12,8 @@ interface OwnProps { } interface StateProps { - node: ReturnType; - nodeLabel: ReturnType; + node: ReturnType; + nodeLabel: ReturnType; } type Props = OwnProps & StateProps; @@ -73,6 +73,6 @@ class NetworkDropdown extends React.Component { } export default connect((state: AppState): StateProps => ({ - node: getNodeConfig(state), - nodeLabel: getSelectedNodeLabel(state) + node: configNodesSelectors.getNodeConfig(state), + nodeLabel: configSelectors.getSelectedNodeLabel(state) }))(NetworkDropdown); diff --git a/common/components/Header/index.tsx b/common/components/Header/index.tsx index 6bf5332f..e07c2e0b 100644 --- a/common/components/Header/index.tsx +++ b/common/components/Header/index.tsx @@ -9,22 +9,15 @@ import { getKeyByValue } from 'utils/helpers'; import logo from 'assets/images/logo-mycrypto.svg'; import { OldDropDown } from 'components/ui'; import { - AddCustomNodeAction, - TAddCustomNetwork, - TAddCustomNode, - TChangeLanguage, - TChangeNodeRequestedOneTime, - TRemoveCustomNode, - getLanguageSelection, - getNetworkConfig, - getOffline, - isNodeChanging, - isStaticNodeId, - changeLanguage, - changeNodeRequestedOneTime, - addCustomNode, - removeCustomNode, - addCustomNetwork + configSelectors, + configMetaSelectors, + configNodesCustomActions, + configMetaActions, + configNetworksCustomActions, + configNodesSelectedActions, + configNodesSelectedSelectors, + configNodesStaticSelectors, + configNodesCustomTypes } from 'features/config'; import { AppState } from 'features/reducers'; import { transactionFieldsActions } from 'features/transaction'; @@ -39,20 +32,20 @@ interface OwnProps { } interface DispatchProps { - changeLanguage: TChangeLanguage; - changeNodeRequestedOneTime: TChangeNodeRequestedOneTime; + changeLanguage: configMetaActions.TChangeLanguage; + changeNodeRequestedOneTime: configNodesSelectedActions.TChangeNodeRequestedOneTime; setGasPriceField: transactionFieldsActions.TSetGasPriceField; - addCustomNode: TAddCustomNode; - removeCustomNode: TRemoveCustomNode; - addCustomNetwork: TAddCustomNetwork; + addCustomNode: configNodesCustomActions.TAddCustomNode; + removeCustomNode: configNodesCustomActions.TRemoveCustomNode; + addCustomNetwork: configNetworksCustomActions.TAddCustomNetwork; } interface StateProps { shouldSetNodeFromQS: boolean; network: NetworkConfig; - languageSelection: ReturnType; - isChangingNode: ReturnType; - isOffline: ReturnType; + languageSelection: ReturnType; + isChangingNode: ReturnType; + isOffline: ReturnType; } interface State { @@ -151,7 +144,7 @@ class Header extends Component { this.setState({ isAddingCustomNode: false }); }; - private addCustomNode = (payload: AddCustomNodeAction['payload']) => { + private addCustomNode = (payload: configNodesCustomTypes.AddCustomNodeAction['payload']) => { this.setState({ isAddingCustomNode: false }); this.props.addCustomNode(payload); }; @@ -168,20 +161,22 @@ const mapStateToProps: MapStateToProps = ( state, { networkParam } ): StateProps => ({ - shouldSetNodeFromQS: !!(networkParam && isStaticNodeId(state, networkParam)), - isOffline: getOffline(state), - isChangingNode: isNodeChanging(state), - languageSelection: getLanguageSelection(state), - network: getNetworkConfig(state) + shouldSetNodeFromQS: !!( + networkParam && configNodesStaticSelectors.isStaticNodeId(state, networkParam) + ), + isOffline: configMetaSelectors.getOffline(state), + isChangingNode: configNodesSelectedSelectors.isNodeChanging(state), + languageSelection: configMetaSelectors.getLanguageSelection(state), + network: configSelectors.getNetworkConfig(state) }); const mapDispatchToProps: DispatchProps = { setGasPriceField: transactionFieldsActions.setGasPriceField, - changeLanguage, - changeNodeRequestedOneTime, - addCustomNode, - removeCustomNode, - addCustomNetwork + changeLanguage: configMetaActions.changeLanguage, + changeNodeRequestedOneTime: configNodesSelectedActions.changeNodeRequestedOneTime, + addCustomNode: configNodesCustomActions.addCustomNode, + removeCustomNode: configNodesCustomActions.removeCustomNode, + addCustomNetwork: configNetworksCustomActions.addCustomNetwork }; export default connect(mapStateToProps, mapDispatchToProps)(Header); diff --git a/common/components/LogOutPrompt.tsx b/common/components/LogOutPrompt.tsx index 3774d7e0..a54fadcd 100644 --- a/common/components/LogOutPrompt.tsx +++ b/common/components/LogOutPrompt.tsx @@ -4,12 +4,12 @@ import { connect } from 'react-redux'; import translate, { translateRaw } from 'translations'; import { AppState } from 'features/reducers'; -import { TWeb3UnsetNode, web3UnsetNode } from 'features/config'; +import { configNodesStaticActions } from 'features/config'; import { walletActions } from 'features/wallet'; import Modal, { IButton } from 'components/ui/Modal'; interface DispatchProps { - web3UnsetNode: TWeb3UnsetNode; + web3UnsetNode: configNodesStaticActions.TWeb3UnsetNode; resetWallet: walletActions.TResetWallet; } @@ -92,5 +92,5 @@ function mapStateToProps(state: AppState) { export default connect(mapStateToProps, { resetWallet: walletActions.resetWallet, - web3UnsetNode + web3UnsetNode: configNodesStaticActions.web3UnsetNode })(withRouter(LogOutPromptClass)); diff --git a/common/components/NetworkSelector/NetworkSelector.tsx b/common/components/NetworkSelector/NetworkSelector.tsx index 7de21135..9022d778 100644 --- a/common/components/NetworkSelector/NetworkSelector.tsx +++ b/common/components/NetworkSelector/NetworkSelector.tsx @@ -6,14 +6,10 @@ import { NodeConfig } from 'types/node'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; import { - TChangeNodeRequested, - changeNodeRequested, - TChangeNetworkRequested, - changeNetworkRequested, - getNodeConfig, - getNetworkConfig, - getAllNodes, - getAllNetworkConfigs + configNodesSelectors, + configNodesSelectedActions, + configNetworksActions, + configSelectors } from 'features/config'; import NetworkOption from './NetworkOption'; import './NetworkSelector.scss'; @@ -34,8 +30,8 @@ interface StateProps { } interface DispatchProps { - changeNodeRequested: TChangeNodeRequested; - changeNetworkRequested: TChangeNetworkRequested; + changeNodeRequested: configNodesSelectedActions.TChangeNodeRequested; + changeNetworkRequested: configNetworksActions.TChangeNetworkRequested; } interface State { @@ -162,13 +158,13 @@ class NetworkSelector extends React.Component { export default connect( (state: AppState): StateProps => ({ - node: getNodeConfig(state), - network: getNetworkConfig(state), - allNodes: getAllNodes(state), - allNetworks: getAllNetworkConfigs(state) + node: configNodesSelectors.getNodeConfig(state), + network: configSelectors.getNetworkConfig(state), + allNodes: configSelectors.getAllNodes(state), + allNetworks: configSelectors.getAllNetworkConfigs(state) }), { - changeNodeRequested, - changeNetworkRequested + changeNodeRequested: configNodesSelectedActions.changeNodeRequested, + changeNetworkRequested: configNetworksActions.changeNetworkRequested } )(NetworkSelector); diff --git a/common/components/NetworkSelector/NodeOption.tsx b/common/components/NetworkSelector/NodeOption.tsx index 6f3f89ca..cae3440e 100644 --- a/common/components/NetworkSelector/NodeOption.tsx +++ b/common/components/NetworkSelector/NodeOption.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { connect } from 'react-redux'; import classnames from 'classnames'; import { translateRaw } from 'translations'; -import { TRemoveCustomNode, removeCustomNode } from 'features/config'; +import { configNodesCustomActions } from 'features/config'; import { NodeConfig } from 'types/node'; import './NodeOption.scss'; @@ -14,7 +14,7 @@ interface OwnProps { } interface DispatchProps { - removeCustomNode: TRemoveCustomNode; + removeCustomNode: configNodesCustomActions.TRemoveCustomNode; } type Props = OwnProps & DispatchProps; @@ -58,4 +58,6 @@ class NodeOption extends React.PureComponent { }; } -export default connect(undefined, { removeCustomNode })(NodeOption); +export default connect(undefined, { removeCustomNode: configNodesCustomActions.removeCustomNode })( + NodeOption +); diff --git a/common/components/NonceField.tsx b/common/components/NonceField.tsx index c9831642..74415b83 100644 --- a/common/components/NonceField.tsx +++ b/common/components/NonceField.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import translate from 'translations'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { transactionNetworkActions, transactionNetworkSelectors } from 'features/transaction'; import { Spinner, Input } from 'components/ui'; import Help from 'components/ui/Help'; @@ -82,7 +82,7 @@ class NonceField extends React.Component { const mapStateToProps = (state: AppState): StateProps => { return { - isOffline: getOffline(state), + isOffline: configMetaSelectors.getOffline(state), noncePending: transactionNetworkSelectors.nonceRequestPending(state) }; }; diff --git a/common/components/NonceFieldFactory/NonceInputFactory.tsx b/common/components/NonceFieldFactory/NonceInputFactory.tsx index b90f8d18..661b46b1 100644 --- a/common/components/NonceFieldFactory/NonceInputFactory.tsx +++ b/common/components/NonceFieldFactory/NonceInputFactory.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { transactionFieldsSelectors, transactionNetworkSelectors } from 'features/transaction'; import { CallbackProps } from 'components/NonceFieldFactory'; import { Query } from 'components/renderCbs'; @@ -35,6 +35,7 @@ class NonceInputFactoryClass extends Component { } export const NonceInputFactory = connect((state: AppState) => ({ - shouldDisplay: getOffline(state) || transactionNetworkSelectors.nonceRequestFailed(state), + shouldDisplay: + configMetaSelectors.getOffline(state) || transactionNetworkSelectors.nonceRequestFailed(state), nonce: transactionFieldsSelectors.getNonce(state) }))(NonceInputFactoryClass); diff --git a/common/components/SendButtonFactory/OfflineBroadcast.tsx b/common/components/SendButtonFactory/OfflineBroadcast.tsx index dde98c5b..4b5b1038 100644 --- a/common/components/SendButtonFactory/OfflineBroadcast.tsx +++ b/common/components/SendButtonFactory/OfflineBroadcast.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { NewTabLink } from 'components/ui'; interface StateProps { @@ -15,9 +15,9 @@ class OfflineBroadcastClass extends Component { } } -export const OfflineBroadcast = connect((state: AppState) => ({ offline: getOffline(state) }))( - OfflineBroadcastClass -); +export const OfflineBroadcast = connect((state: AppState) => ({ + offline: configMetaSelectors.getOffline(state) +}))(OfflineBroadcastClass); const BroadCast: React.SFC<{}> = () => (

To broadcast this transaction, paste the above into the{' '} diff --git a/common/components/SendButtonFactory/OnlineSend.tsx b/common/components/SendButtonFactory/OnlineSend.tsx index a9a9d482..896c62bf 100644 --- a/common/components/SendButtonFactory/OnlineSend.tsx +++ b/common/components/SendButtonFactory/OnlineSend.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { transactionBroadcastTypes, transactionSignActions, @@ -87,7 +87,7 @@ class OnlineSendClass extends Component { export const OnlineSend = connect( (state: AppState) => ({ - offline: getOffline(state), + offline: configMetaSelectors.getOffline(state), currentTransaction: transactionSelectors.getCurrentTransactionStatus(state), transactionBroadcasted: transactionSelectors.currentTransactionBroadcasted(state), signaturePending: derivedSelectors.signaturePending(state).isSignaturePending, diff --git a/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx b/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx index f21240ae..c59b32fd 100644 --- a/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx +++ b/common/components/TXMetaDataPanel/TXMetaDataPanel.tsx @@ -6,7 +6,7 @@ import { translateRaw } from 'translations'; import { NetworkConfig } from 'types/network'; import { Units } from 'libs/units'; import { AppState } from 'features/reducers'; -import { getOffline, getNetworkConfig } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { transactionFieldsActions, transactionFieldsSelectors, @@ -144,8 +144,8 @@ class TXMetaDataPanel extends React.Component { function mapStateToProps(state: AppState): StateProps { return { gasPrice: transactionFieldsSelectors.getGasPrice(state), - offline: getOffline(state), - network: getNetworkConfig(state) + offline: configMetaSelectors.getOffline(state), + network: configSelectors.getNetworkConfig(state) }; } diff --git a/common/components/TXMetaDataPanel/components/AdvancedGas.tsx b/common/components/TXMetaDataPanel/components/AdvancedGas.tsx index 98452d58..469a6758 100644 --- a/common/components/TXMetaDataPanel/components/AdvancedGas.tsx +++ b/common/components/TXMetaDataPanel/components/AdvancedGas.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { EAC_SCHEDULING_CONFIG } from 'libs/scheduling'; import translate, { translateRaw } from 'translations'; import { AppState } from 'features/reducers'; -import { TToggleAutoGasLimit, toggleAutoGasLimit, getAutoGasLimitEnabled } from 'features/config'; +import { configMetaActions, configMetaSelectors } from 'features/config'; import { scheduleSelectors } from 'features/schedule'; import { transactionFieldsActions, transactionSelectors } from 'features/transaction'; import { NonceField, GasLimitField, DataField } from 'components'; @@ -35,7 +35,7 @@ interface StateProps { } interface DispatchProps { - toggleAutoGasLimit: TToggleAutoGasLimit; + toggleAutoGasLimit: configMetaActions.TToggleAutoGasLimit; } interface State { @@ -183,10 +183,10 @@ class AdvancedGas extends React.Component { export default connect( (state: AppState) => ({ - autoGasLimitEnabled: getAutoGasLimitEnabled(state), + autoGasLimitEnabled: configMetaSelectors.getAutoGasLimitEnabled(state), scheduleGasPrice: scheduleSelectors.getScheduleGasPrice(state), timeBounty: scheduleSelectors.getTimeBounty(state), validGasPrice: transactionSelectors.isValidGasPrice(state) }), - { toggleAutoGasLimit } + { toggleAutoGasLimit: configMetaActions.toggleAutoGasLimit } )(AdvancedGas); diff --git a/common/components/TXMetaDataPanel/components/FeeSummary.tsx b/common/components/TXMetaDataPanel/components/FeeSummary.tsx index 5005ce34..5c92dff6 100644 --- a/common/components/TXMetaDataPanel/components/FeeSummary.tsx +++ b/common/components/TXMetaDataPanel/components/FeeSummary.tsx @@ -6,7 +6,7 @@ import classNames from 'classnames'; import { NetworkConfig } from 'types/network'; import { calcEACTotalCost } from 'libs/scheduling'; import { AppState } from 'features/reducers'; -import { getOffline, getNetworkConfig } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { gasSelectors } from 'features/gas'; import { transactionFieldsSelectors } from 'features/transaction'; import { scheduleSelectors } from 'features/schedule'; @@ -146,8 +146,8 @@ function mapStateToProps(state: AppState): ReduxStateProps { return { gasLimit: transactionFieldsSelectors.getGasLimit(state), rates: state.rates.rates, - network: getNetworkConfig(state), - isOffline: getOffline(state), + network: configSelectors.getNetworkConfig(state), + isOffline: configMetaSelectors.getOffline(state), isGasEstimating: gasSelectors.getIsEstimating(state), scheduling: scheduleSelectors.getSchedulingToggle(state).value, scheduleGasLimit: scheduleSelectors.getScheduleGasLimit(state), diff --git a/common/components/TXMetaDataPanel/components/SimpleGas.tsx b/common/components/TXMetaDataPanel/components/SimpleGas.tsx index 79fa10bb..81c04a06 100644 --- a/common/components/TXMetaDataPanel/components/SimpleGas.tsx +++ b/common/components/TXMetaDataPanel/components/SimpleGas.tsx @@ -6,7 +6,7 @@ import { gasPriceDefaults } from 'config'; import translate from 'translations'; import { Wei, fromWei } from 'libs/units'; import { AppState } from 'features/reducers'; -import { getIsWeb3Node } from 'features/config'; +import { configNodesSelectors } from 'features/config'; import { transactionFieldsActions, transactionNetworkSelectors } from 'features/transaction'; import { gasActions, gasSelectors } from 'features/gas'; import { scheduleSelectors } from 'features/schedule'; @@ -162,7 +162,7 @@ export default connect( noncePending: transactionNetworkSelectors.nonceRequestPending(state), gasLimitPending: transactionNetworkSelectors.getGasEstimationPending(state), gasLimitEstimationTimedOut: transactionNetworkSelectors.getGasLimitEstimationTimedOut(state), - isWeb3Node: getIsWeb3Node(state), + isWeb3Node: configNodesSelectors.getIsWeb3Node(state), scheduleGasPrice: scheduleSelectors.getScheduleGasPrice(state) }), { diff --git a/common/components/TransactionStatus/TransactionStatus.tsx b/common/components/TransactionStatus/TransactionStatus.tsx index 247b4c1b..4b1c677b 100644 --- a/common/components/TransactionStatus/TransactionStatus.tsx +++ b/common/components/TransactionStatus/TransactionStatus.tsx @@ -5,7 +5,7 @@ import translate from 'translations'; import { NetworkConfig } from 'types/network'; import { TransactionState } from 'types/transactions'; import { AppState } from 'features/reducers'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { transactionsActions, transactionsSelectors } from 'features/transactions'; import { Spinner } from 'components/ui'; import TransactionDataTable from './TransactionDataTable'; @@ -80,7 +80,7 @@ function mapStateToProps(state: AppState, ownProps: OwnProps): StateProps { return { tx: transactionsSelectors.getTransactionDatas(state)[txHash], - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }; } diff --git a/common/components/UnitDropDown/UnitDropDown.tsx b/common/components/UnitDropDown/UnitDropDown.tsx index ef64e621..54ac6d1f 100644 --- a/common/components/UnitDropDown/UnitDropDown.tsx +++ b/common/components/UnitDropDown/UnitDropDown.tsx @@ -5,7 +5,7 @@ import { Option } from 'react-select'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; import { transactionMetaActions } from 'features/transaction'; -import { getNetworkUnit } from 'features/config'; +import { configSelectors } from 'features/config'; import { walletTypes } from 'features/wallet'; import { Query } from 'components/renderCbs'; import { Dropdown } from 'components/ui'; @@ -58,7 +58,7 @@ function mapStateToProps(state: AppState) { tokens: selectors.getShownTokenBalances(state, true), allTokens: selectors.getTokens(state), unit: selectors.getUnit(state), - networkUnit: getNetworkUnit(state) + networkUnit: configSelectors.getNetworkUnit(state) }; } diff --git a/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx b/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx index 43c0da2a..7cce8a4a 100644 --- a/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx +++ b/common/components/WalletDecrypt/components/DeterministicWalletsModal.tsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import translate, { translateRaw } from 'translations'; import { isValidPath } from 'libs/validators'; import { AppState } from 'features/reducers'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import * as selectors from 'features/selectors'; import { deterministicWalletsTypes, @@ -31,7 +31,7 @@ interface StateProps { addressLabels: ReturnType; wallets: AppState['deterministicWallets']['wallets']; desiredToken: AppState['deterministicWallets']['desiredToken']; - network: ReturnType; + network: ReturnType; tokens: ReturnType; } @@ -342,7 +342,7 @@ function mapStateToProps(state: AppState): StateProps { addressLabels: addressBookSelectors.getAddressLabels(state), wallets: state.deterministicWallets.wallets, desiredToken: state.deterministicWallets.desiredToken, - network: getNetworkConfig(state), + network: configSelectors.getNetworkConfig(state), tokens: selectors.getTokens(state) }; } diff --git a/common/components/WalletDecrypt/components/LedgerNano.tsx b/common/components/WalletDecrypt/components/LedgerNano.tsx index 3a4ef801..4a687e19 100644 --- a/common/components/WalletDecrypt/components/LedgerNano.tsx +++ b/common/components/WalletDecrypt/components/LedgerNano.tsx @@ -6,7 +6,7 @@ import translate, { translateRaw } from 'translations'; import { LedgerWallet } from 'libs/wallet'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getNetworkConfig, getPaths, getSingleDPath } from 'features/config'; +import { configSelectors, configNetworksStaticSelectors } from 'features/config'; import { Spinner, NewTabLink, HelpLink } from 'components/ui'; import UnsupportedNetwork from './UnsupportedNetwork'; import DeterministicWalletsModal from './DeterministicWalletsModal'; @@ -172,9 +172,9 @@ class LedgerNanoSDecryptClass extends PureComponent { function mapStateToProps(state: AppState): StateProps { return { - dPath: getSingleDPath(state, SecureWalletName.LEDGER_NANO_S), - dPaths: getPaths(state, SecureWalletName.LEDGER_NANO_S), - network: getNetworkConfig(state) + dPath: configSelectors.getSingleDPath(state, SecureWalletName.LEDGER_NANO_S), + dPaths: configNetworksStaticSelectors.getPaths(state, SecureWalletName.LEDGER_NANO_S), + network: configSelectors.getNetworkConfig(state) }; } diff --git a/common/components/WalletDecrypt/components/Mnemonic.tsx b/common/components/WalletDecrypt/components/Mnemonic.tsx index a866c350..dfe338bc 100644 --- a/common/components/WalletDecrypt/components/Mnemonic.tsx +++ b/common/components/WalletDecrypt/components/Mnemonic.tsx @@ -6,7 +6,7 @@ import { InsecureWalletName } from 'config'; import translate, { translateRaw } from 'translations'; import { formatMnemonic } from 'utils/formatters'; import { AppState } from 'features/reducers'; -import { getSingleDPath, getPaths } from 'features/config'; +import { configSelectors, configNetworksStaticSelectors } from 'features/config'; import { TogglablePassword } from 'components'; import { Input } from 'components/ui'; import DeterministicWalletsModal from './DeterministicWalletsModal'; @@ -158,8 +158,8 @@ class MnemonicDecryptClass extends PureComponent { function mapStateToProps(state: AppState): StateProps { return { // Mnemonic dPath is guaranteed to always be provided - dPath: getSingleDPath(state, InsecureWalletName.MNEMONIC_PHRASE) as DPath, - dPaths: getPaths(state, InsecureWalletName.MNEMONIC_PHRASE) + dPath: configSelectors.getSingleDPath(state, InsecureWalletName.MNEMONIC_PHRASE) as DPath, + dPaths: configNetworksStaticSelectors.getPaths(state, InsecureWalletName.MNEMONIC_PHRASE) }; } diff --git a/common/components/WalletDecrypt/components/Trezor.tsx b/common/components/WalletDecrypt/components/Trezor.tsx index d7c7119d..a4e692b4 100644 --- a/common/components/WalletDecrypt/components/Trezor.tsx +++ b/common/components/WalletDecrypt/components/Trezor.tsx @@ -5,7 +5,7 @@ import { SecureWalletName, trezorReferralURL } from 'config'; import translate, { translateRaw } from 'translations'; import { TrezorWallet } from 'libs/wallet'; import { AppState } from 'features/reducers'; -import { getSingleDPath, getPaths } from 'features/config'; +import { configSelectors, configNetworksStaticSelectors } from 'features/config'; import { Spinner, NewTabLink } from 'components/ui'; import UnsupportedNetwork from './UnsupportedNetwork'; import DeterministicWalletsModal from './DeterministicWalletsModal'; @@ -150,8 +150,8 @@ class TrezorDecryptClass extends PureComponent { function mapStateToProps(state: AppState): StateProps { return { - dPath: getSingleDPath(state, SecureWalletName.TREZOR), - dPaths: getPaths(state, SecureWalletName.TREZOR) + dPath: configSelectors.getSingleDPath(state, SecureWalletName.TREZOR), + dPaths: configNetworksStaticSelectors.getPaths(state, SecureWalletName.TREZOR) }; } diff --git a/common/components/WalletDecrypt/components/UnsupportedNetwork.tsx b/common/components/WalletDecrypt/components/UnsupportedNetwork.tsx index 64e41758..2917d568 100644 --- a/common/components/WalletDecrypt/components/UnsupportedNetwork.tsx +++ b/common/components/WalletDecrypt/components/UnsupportedNetwork.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; interface StateProps { network: NetworkConfig; @@ -24,5 +24,5 @@ const UnsupportedNetwork: React.SFC = ({ walletType, network }) => { }; export default connect((state: AppState): StateProps => ({ - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }))(UnsupportedNetwork); diff --git a/common/components/WalletDecrypt/components/ViewOnly.tsx b/common/components/WalletDecrypt/components/ViewOnly.tsx index e4d085a8..73a1963f 100644 --- a/common/components/WalletDecrypt/components/ViewOnly.tsx +++ b/common/components/WalletDecrypt/components/ViewOnly.tsx @@ -5,7 +5,7 @@ import Select, { Option } from 'react-select'; import translate, { translateRaw } from 'translations'; import { AddressOnlyWallet } from 'libs/wallet'; import { AppState } from 'features/reducers'; -import { getIsValidAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { walletSelectors } from 'features/wallet'; import { Input, Identicon } from 'components/ui'; import './ViewOnly.scss'; @@ -16,7 +16,7 @@ interface OwnProps { interface StateProps { recentAddresses: ReturnType; - isValidAddress: ReturnType; + isValidAddress: ReturnType; } type Props = OwnProps & StateProps; @@ -102,5 +102,5 @@ class ViewOnlyDecryptClass extends PureComponent { export const ViewOnlyDecrypt = connect((state: AppState): StateProps => ({ recentAddresses: walletSelectors.getRecentAddresses(state), - isValidAddress: getIsValidAddressFn(state) + isValidAddress: configSelectors.getIsValidAddressFn(state) }))(ViewOnlyDecryptClass); diff --git a/common/components/ui/Address.tsx b/common/components/ui/Address.tsx index 095f553f..a4ce6a03 100644 --- a/common/components/ui/Address.tsx +++ b/common/components/ui/Address.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { IWallet } from 'libs/wallet'; import { BlockExplorerConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import NewTabLink from './NewTabLink'; interface BaseProps { @@ -14,7 +14,7 @@ interface BaseProps { } interface StateProps { - toChecksumAddress: ReturnType; + toChecksumAddress: ReturnType; } type Props = BaseProps & StateProps; @@ -39,5 +39,5 @@ export class Address extends React.PureComponent { } export default connect((state: AppState) => ({ - toChecksumAddress: getChecksumAddressFn(state) + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }))(Address); diff --git a/common/components/ui/Identicon.tsx b/common/components/ui/Identicon.tsx index 01081c2d..cfbecd7f 100644 --- a/common/components/ui/Identicon.tsx +++ b/common/components/ui/Identicon.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import makeBlockie from 'ethereum-blockies-base64'; import { AppState } from 'features/reducers'; -import { getIsValidAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import './Identicon.scss'; interface OwnProps { @@ -13,7 +13,7 @@ interface OwnProps { } interface StateProps { - isValidAddress: ReturnType; + isValidAddress: ReturnType; } type Props = OwnProps & StateProps; @@ -40,5 +40,5 @@ const Identicon: React.SFC = props => { }; export default connect((state: AppState): StateProps => ({ - isValidAddress: getIsValidAddressFn(state) + isValidAddress: configSelectors.getIsValidAddressFn(state) }))(Identicon); diff --git a/common/components/ui/UnitDisplay.tsx b/common/components/ui/UnitDisplay.tsx index 64869b5d..d3fba45c 100644 --- a/common/components/ui/UnitDisplay.tsx +++ b/common/components/ui/UnitDisplay.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { fromTokenBase, getDecimalFromEtherUnit, UnitKey, Wei, TokenValue } from 'libs/units'; import { formatNumber as format } from 'utils/formatters'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import Spinner from 'components/ui/Spinner'; interface Props { @@ -102,7 +102,7 @@ class OfflineDisplay extends React.Component { function mapStateToOfflineProps(state: AppState) { return { - offline: getOffline(state) + offline: configMetaSelectors.getOffline(state) }; } diff --git a/common/containers/TabSection/ElectronTemplate.tsx b/common/containers/TabSection/ElectronTemplate.tsx index 936d12b1..b75337f7 100644 --- a/common/containers/TabSection/ElectronTemplate.tsx +++ b/common/containers/TabSection/ElectronTemplate.tsx @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { ElectronNav } from 'components'; import OfflineTab from './OfflineTab'; import Notifications from './Notifications'; @@ -42,7 +42,7 @@ class ElectronTemplate extends Component { function mapStateToProps(state: AppState): StateProps { return { - isOffline: getOffline(state) + isOffline: configMetaSelectors.getOffline(state) }; } diff --git a/common/containers/TabSection/WebTemplate.tsx b/common/containers/TabSection/WebTemplate.tsx index 057d07e7..781c34d7 100644 --- a/common/containers/TabSection/WebTemplate.tsx +++ b/common/containers/TabSection/WebTemplate.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { makeAutoNodeName } from 'libs/nodes'; import { AppState } from 'features/reducers'; -import { getOffline, getLatestBlock } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { Footer, Header } from 'components'; import { Query } from 'components/renderCbs'; import Notifications from './Notifications'; @@ -47,8 +47,8 @@ class WebTemplate extends Component { function mapStateToProps(state: AppState): StateProps { return { - isOffline: getOffline(state), - latestBlock: getLatestBlock(state) + isOffline: configMetaSelectors.getOffline(state), + latestBlock: configMetaSelectors.getLatestBlock(state) }; } diff --git a/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx b/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx index bb71ae8a..78f52d8b 100644 --- a/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx +++ b/common/containers/Tabs/CheckTransaction/components/TxHashInput.tsx @@ -7,7 +7,7 @@ import translate from 'translations'; import { isValidTxHash } from 'libs/validators'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getIsValidAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { Input } from 'components/ui'; import './TxHashInput.scss'; @@ -18,7 +18,7 @@ interface OwnProps { interface ReduxProps { recentTxs: AppState['transactions']['recent']; - isValidAddress: ReturnType; + isValidAddress: ReturnType; } type Props = OwnProps & ReduxProps; @@ -125,5 +125,5 @@ class TxHashInput extends React.Component { export default connect((state: AppState): ReduxProps => ({ recentTxs: selectors.getRecentNetworkTransactions(state), - isValidAddress: getIsValidAddressFn(state) + isValidAddress: configSelectors.getIsValidAddressFn(state) }))(TxHashInput); diff --git a/common/containers/Tabs/CheckTransaction/index.tsx b/common/containers/Tabs/CheckTransaction/index.tsx index 528842ee..82581a1c 100644 --- a/common/containers/Tabs/CheckTransaction/index.tsx +++ b/common/containers/Tabs/CheckTransaction/index.tsx @@ -7,7 +7,7 @@ import translate from 'translations'; import { getParamFromURL } from 'utils/helpers'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { TransactionStatus as TransactionStatusComponent } from 'components'; import TabSection from 'containers/TabSection'; import TxHashInput from './components/TxHashInput'; @@ -88,5 +88,5 @@ class CheckTransaction extends React.Component { } export default connect((state: AppState): StateProps => ({ - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }))(CheckTransaction); diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx index 084ba5ed..318036ec 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx @@ -6,7 +6,7 @@ import translate from 'translations'; import { Data } from 'libs/units'; import { INode } from 'libs/nodes'; import { AppState } from 'features/reducers'; -import { getNodeLib } from 'features/config'; +import { configNodesSelectors } from 'features/config'; import { notificationsActions } from 'features/notifications'; import { transactionFieldsActions, @@ -316,7 +316,7 @@ class InteractExplorerClass extends Component { export const InteractExplorer = connect( (state: AppState) => ({ - nodeLib: getNodeLib(state), + nodeLib: configNodesSelectors.getNodeLib(state), to: transactionFieldsSelectors.getTo(state), dataExists: transactionSelectors.getDataExists(state) }), diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractForm/index.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractForm/index.tsx index 37bf7169..5c7b5ac7 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractForm/index.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractForm/index.tsx @@ -8,7 +8,7 @@ import { NetworkContract } from 'types/network'; import { isValidAbiJson } from 'libs/validators'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getNetworkContracts, getIsValidAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { setCurrentTo, TSetCurrentTo } from 'features/transaction/actions'; import { Input, TextArea, CodeBlock, Dropdown } from 'components/ui'; import { AddressFieldFactory } from 'components/AddressFieldFactory'; @@ -21,7 +21,7 @@ interface ContractOption { interface StateProps { currentTo: ReturnType; contracts: NetworkContract[]; - isValidAddress: ReturnType; + isValidAddress: ReturnType; } interface OwnProps { @@ -210,9 +210,9 @@ class InteractForm extends Component { } const mapStateToProps = (state: AppState) => ({ - contracts: getNetworkContracts(state) || [], + contracts: configSelectors.getNetworkContracts(state) || [], currentTo: selectors.getCurrentTo(state), - isValidAddress: getIsValidAddressFn(state) + isValidAddress: configSelectors.getIsValidAddressFn(state) }); export default connect(mapStateToProps, { setCurrentTo })(InteractForm); diff --git a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx index 3e63d69b..be9c1c31 100644 --- a/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx +++ b/common/containers/Tabs/SendTransaction/components/Fields/Fields.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import translate, { translateRaw } from 'translations'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getOffline, getNetworkConfig } from 'features/config'; +import { configSelectors, configMetaSelectors } from 'features/config'; import { scheduleSelectors } from 'features/schedule'; import { notificationsActions } from 'features/notifications'; import { @@ -129,9 +129,10 @@ class FieldsClass extends Component { export const Fields = connect( (state: AppState) => ({ schedulingAvailable: - getNetworkConfig(state).name === 'Kovan' && selectors.getUnit(state) === 'ETH', + configSelectors.getNetworkConfig(state).name === 'Kovan' && + selectors.getUnit(state) === 'ETH', shouldDisplay: !selectors.isAnyOfflineWithWeb3(state), - offline: getOffline(state), + offline: configMetaSelectors.getOffline(state), useScheduling: scheduleSelectors.getCurrentSchedulingToggle(state).value }), { diff --git a/common/containers/Tabs/SendTransaction/components/RecentTransactions.tsx b/common/containers/Tabs/SendTransaction/components/RecentTransactions.tsx index 93633815..da3c9511 100644 --- a/common/containers/Tabs/SendTransaction/components/RecentTransactions.tsx +++ b/common/containers/Tabs/SendTransaction/components/RecentTransactions.tsx @@ -6,7 +6,7 @@ import { NetworkConfig } from 'types/network'; import { IWallet } from 'libs/wallet'; import { AppState } from 'features/reducers'; import * as selectors from 'features/selectors'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { TransactionStatus } from 'components'; import RecentTransaction from './RecentTransaction'; import './RecentTransactions.scss'; @@ -103,5 +103,5 @@ class RecentTransactions extends React.Component { export default connect((state: AppState): StateProps => ({ recentTransactions: selectors.getRecentWalletTransactions(state), - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }))(RecentTransactions); diff --git a/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx b/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx index 6a027e71..939021bf 100644 --- a/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx +++ b/common/containers/Tabs/SendTransaction/components/RequestPayment.tsx @@ -9,7 +9,7 @@ import { buildEIP681EtherRequest, buildEIP681TokenRequest } from 'libs/values'; import { ICurrentTo, ICurrentValue } from 'features/types'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import { getNetworkConfig, isNetworkUnit } from 'features/config'; +import { configSelectors } from 'features/config'; import { transactionFieldsTypes, transactionFieldsActions, @@ -191,10 +191,10 @@ function mapStateToProps(state: AppState): StateProps { currentTo: derivedSelectors.getCurrentTo(state), currentValue: derivedSelectors.getCurrentValue(state), gasLimit: transactionFieldsSelectors.getGasLimit(state), - networkConfig: getNetworkConfig(state), + networkConfig: configSelectors.getNetworkConfig(state), decimal: transactionMetaSelectors.getDecimal(state), tokenContractAddress: derivedSelectors.getSelectedTokenContractAddress(state), - isNetworkUnit: isNetworkUnit(state, derivedSelectors.getUnit(state)) + isNetworkUnit: configSelectors.isNetworkUnit(state, derivedSelectors.getUnit(state)) }; } diff --git a/common/containers/Tabs/SendTransaction/components/WalletInfo.tsx b/common/containers/Tabs/SendTransaction/components/WalletInfo.tsx index a9c13d54..992e5764 100644 --- a/common/containers/Tabs/SendTransaction/components/WalletInfo.tsx +++ b/common/containers/Tabs/SendTransaction/components/WalletInfo.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import translate, { translateRaw } from 'translations'; import { IWallet } from 'libs/wallet'; import { AppState } from 'features/reducers'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors } from 'features/config'; import { QRCode, Modal } from 'components/ui'; import { GenerateKeystoreModal, @@ -19,7 +19,7 @@ interface OwnProps { } interface StateProps { - toChecksumAddress: ReturnType; + toChecksumAddress: ReturnType; } type Props = OwnProps & StateProps; @@ -151,5 +151,5 @@ class WalletInfo extends React.PureComponent { } export default connect((state: AppState): StateProps => ({ - toChecksumAddress: getChecksumAddressFn(state) + toChecksumAddress: configSelectors.getChecksumAddressFn(state) }))(WalletInfo); diff --git a/common/containers/Tabs/SendTransaction/index.tsx b/common/containers/Tabs/SendTransaction/index.tsx index 45174d87..40dbbd5e 100644 --- a/common/containers/Tabs/SendTransaction/index.tsx +++ b/common/containers/Tabs/SendTransaction/index.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import translate from 'translations'; import { AppState } from 'features/reducers'; -import { isNetworkUnit } from 'features/config'; +import { configSelectors } from 'features/config'; import { walletSelectors } from 'features/wallet'; import TabSection from 'containers/TabSection'; import { RedirectWithQuery } from 'components/RedirectWithQuery'; @@ -126,5 +126,5 @@ class SendTransaction extends React.Component { export default connect((state: AppState) => ({ wallet: walletSelectors.getWalletInst(state), - requestDisabled: !isNetworkUnit(state, 'ETH') + requestDisabled: !configSelectors.isNetworkUnit(state, 'ETH') }))(SendTransaction); diff --git a/common/containers/Tabs/Swap/components/CurrentRates.tsx b/common/containers/Tabs/Swap/components/CurrentRates.tsx index 20d3a952..589da4dd 100644 --- a/common/containers/Tabs/Swap/components/CurrentRates.tsx +++ b/common/containers/Tabs/Swap/components/CurrentRates.tsx @@ -20,7 +20,7 @@ import { stopLoadShapeshiftRatesSwap, TStopLoadShapeshiftRatesSwap } from 'features/swap/actions'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import bityLogoWhite from 'assets/images/logo-bity-white.svg'; import shapeshiftLogoWhite from 'assets/images/logo-shapeshift.svg'; import Spinner from 'components/ui/Spinner'; @@ -181,7 +181,7 @@ class CurrentRates extends PureComponent { function mapStateToProps(state: AppState): StateProps { return { - isOffline: getOffline(state), + isOffline: configMetaSelectors.getOffline(state), provider: state.swap.provider, bityRates: state.swap.bityRates, shapeshiftRates: state.swap.shapeshiftRates diff --git a/common/containers/Tabs/Swap/components/LiteSend/LiteSend.tsx b/common/containers/Tabs/Swap/components/LiteSend/LiteSend.tsx index dd57832d..693fd274 100644 --- a/common/containers/Tabs/Swap/components/LiteSend/LiteSend.tsx +++ b/common/containers/Tabs/Swap/components/LiteSend/LiteSend.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { NetworkConfig } from 'types/network'; import { AppState } from 'features/reducers'; import { walletSelectors } from 'features/wallet'; -import { getNetworkConfig } from 'features/config'; +import { configSelectors } from 'features/config'; import { configureLiteSend, TConfigureLiteSend } from 'features/swap/actions'; import { shouldDisplayLiteSend } from 'features/swap/selectors'; import WalletDecrypt, { DISABLE_WALLETS } from 'components/WalletDecrypt'; @@ -57,7 +57,7 @@ export const LiteSend = connect( (state: AppState) => ({ shouldDisplay: shouldDisplayLiteSend(state), isUnlocked: walletSelectors.isUnlocked(state), - network: getNetworkConfig(state) + network: configSelectors.getNetworkConfig(state) }), { configureLiteSend } )(LiteSendClass); diff --git a/common/containers/Tabs/Swap/index.tsx b/common/containers/Tabs/Swap/index.tsx index fbf302e5..3e85fb9a 100644 --- a/common/containers/Tabs/Swap/index.tsx +++ b/common/containers/Tabs/Swap/index.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { merge } from 'lodash'; import { AppState } from 'features/reducers'; -import { getOffline } from 'features/config'; +import { configMetaSelectors } from 'features/config'; import { notificationsActions } from 'features/notifications'; import { swapTypes, swapActions } from 'features/swap'; import TabSection from 'containers/TabSection'; @@ -228,7 +228,7 @@ function mapStateToProps(state: AppState) { paymentAddress: state.swap.paymentAddress, paymentId: state.swap.paymentId, xmrPaymentAddress: state.swap.xmrPaymentAddress, - isOffline: getOffline(state) + isOffline: configMetaSelectors.getOffline(state) }; } diff --git a/common/features/config/sagas.ts b/common/features/config/sagas.ts index 8632f18a..1432e484 100644 --- a/common/features/config/sagas.ts +++ b/common/features/config/sagas.ts @@ -18,7 +18,6 @@ import { import { Web3Wallet } from 'libs/wallet'; import { setupWeb3Node, Web3Service, isWeb3Node } from 'libs/nodes/web3'; import { AppState } from 'features/reducers'; - import { notificationsActions } from 'features/notifications'; import { walletTypes, walletActions } from 'features/wallet'; import * as configMetaTypes from './meta/types'; diff --git a/common/features/deterministicWallets/sagas.spec.ts b/common/features/deterministicWallets/sagas.spec.ts index 82254286..b8e3a00e 100644 --- a/common/features/deterministicWallets/sagas.spec.ts +++ b/common/features/deterministicWallets/sagas.spec.ts @@ -8,8 +8,7 @@ import { TokenValue, Wei } from 'libs/units'; import { getChecksumAddressFunction } from 'utils/formatters'; import configuredStore from 'features/store'; import * as derivedSelectors from 'features/selectors'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors, configNodesSelectors } from 'features/config'; import * as types from './types'; import * as actions from './actions'; import * as selectors from './selectors'; @@ -57,7 +56,7 @@ describe('getDeterministicWallets*', () => { const gen = sagas.getDeterministicWalletsSaga(action); it('should select getChecksumAddressFn', () => { - expect(gen.next().value).toEqual(select(getChecksumAddressFn)); + expect(gen.next().value).toEqual(select(configSelectors.getChecksumAddressFn)); }); it('should match put snapshot', () => { @@ -86,7 +85,7 @@ describe('getDeterministicWallets*', () => { const gen = sagas.getDeterministicWalletsSaga(action); it('should select getChecksumAddressFn', () => { - expect(gen.next().value).toEqual(select(getChecksumAddressFn)); + expect(gen.next().value).toEqual(select(configSelectors.getChecksumAddressFn)); }); it('should match put snapshot', () => { diff --git a/common/features/deterministicWallets/sagas.ts b/common/features/deterministicWallets/sagas.ts index 1aefb07f..f6dad654 100644 --- a/common/features/deterministicWallets/sagas.ts +++ b/common/features/deterministicWallets/sagas.ts @@ -8,8 +8,7 @@ import { INode } from 'libs/nodes/INode'; import { TokenValue } from 'libs/units'; import { Token } from 'types/network'; import * as derivedSelectors from 'features/selectors'; -import { getChecksumAddressFn } from 'features/config'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; +import { configSelectors, configNodesSelectors } from 'features/config'; import { notificationsActions } from 'features/notifications'; import * as types from './types'; import * as actions from './actions'; @@ -37,8 +36,8 @@ export function* getDeterministicWalletsSaga( return; } const wallets: types.DeterministicWalletData[] = []; - const toChecksumAddress: ReturnType = yield select( - getChecksumAddressFn + const toChecksumAddress: ReturnType = yield select( + configSelectors.getChecksumAddressFn ); for (let i = 0; i < limit; i++) { const index = i + offset; diff --git a/common/features/store.ts b/common/features/store.ts index b41f0784..545939c9 100644 --- a/common/features/store.ts +++ b/common/features/store.ts @@ -1,7 +1,7 @@ import { bindActionCreators } from 'redux'; import { shepherdProvider, getShepherdPending, getShepherdOffline } from 'libs/nodes'; -import { setOffline, setOnline, getOffline } from 'features/config'; +import { configMetaActions, configMetaSelectors } from 'features/config'; import { notificationsActions } from 'features/notifications'; import handleMetaMaskPolling, { METAMASK_POLLING_INTERVAL } from './handleMetaMaskPolling'; import configureStore from './configureStore'; @@ -16,8 +16,8 @@ window.addEventListener('load', () => { const { online, offline, lostNetworkNotif, offlineNotif, restoreNotif } = bindActionCreators( { - offline: setOffline, - online: setOnline, + offline: configMetaActions.setOffline, + online: configMetaActions.setOnline, restoreNotif: () => notificationsActions.showNotification( 'success', @@ -43,7 +43,7 @@ window.addEventListener('load', () => { store.dispatch ); - const getAppOnline = () => !getOffline(store.getState()); + const getAppOnline = () => !configMetaSelectors.getOffline(store.getState()); /** * @description Repeatedly polls itself to check for online state conflict occurs, implemented in recursive style for flexible polling times diff --git a/common/features/transaction/network/sagas.spec.ts b/common/features/transaction/network/sagas.spec.ts index 9b7bc61b..acd3b15e 100644 --- a/common/features/transaction/network/sagas.spec.ts +++ b/common/features/transaction/network/sagas.spec.ts @@ -16,9 +16,7 @@ import { cloneableGenerator, SagaIteratorClone, createMockTask } from 'redux-sag import { Wei, Nonce } from 'libs/units'; import { makeTransaction, getTransactionFields } from 'libs/transaction'; import * as derivedSelectors from 'features/selectors'; -import * as configMetaTypes from 'features/config/meta/types'; -import * as configMetaSelectors from 'features/config/meta/selectors'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; +import { configMetaTypes, configMetaSelectors, configNodesSelectors } from 'features/config'; import { walletTypes, walletSelectors } from 'features/wallet'; import { scheduleActions, scheduleSelectors } from 'features/schedule'; import { notificationsActions } from 'features/notifications'; @@ -116,7 +114,7 @@ describe('Network Sagas', () => { transactionTypes.TransactionActions.ETHER_TO_TOKEN_SWAP, transactionTypes.TransactionActions.TOKEN_TO_TOKEN_SWAP, transactionTypes.TransactionActions.TOKEN_TO_ETHER_SWAP, - configMetaTypes.CONFIG_META.TOGGLE_AUTO_GAS_LIMIT + configMetaTypes.ConfigMetaActions.TOGGLE_AUTO_GAS_LIMIT ]) ); }); diff --git a/common/features/transaction/network/sagas.ts b/common/features/transaction/network/sagas.ts index f0c19b09..f7985af7 100644 --- a/common/features/transaction/network/sagas.ts +++ b/common/features/transaction/network/sagas.ts @@ -21,9 +21,7 @@ import { makeTransaction, getTransactionFields, IHexStrTransaction } from 'libs/ import { IGetTransaction } from 'features/types'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import * as configMetaTypes from 'features/config/meta/types'; -import * as configMetaSelectors from 'features/config/meta/selectors'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; +import { configMetaTypes, configMetaSelectors, configNodesSelectors } from 'features/config'; import { walletTypes, walletSelectors } from 'features/wallet'; import { scheduleActions, scheduleSelectors } from 'features/schedule'; import { notificationsActions } from 'features/notifications'; @@ -76,7 +74,7 @@ export function* shouldEstimateGas(): SagaIterator { transactionTypes.TransactionActions.ETHER_TO_TOKEN_SWAP, transactionTypes.TransactionActions.TOKEN_TO_TOKEN_SWAP, transactionTypes.TransactionActions.TOKEN_TO_ETHER_SWAP, - configMetaTypes.CONFIG_META.TOGGLE_AUTO_GAS_LIMIT + configMetaTypes.ConfigMetaActions.TOGGLE_AUTO_GAS_LIMIT ]); const isOffline: boolean = yield select(configMetaSelectors.getOffline); diff --git a/common/features/transactions/sagas.ts b/common/features/transactions/sagas.ts index c1810885..d8e6563f 100644 --- a/common/features/transactions/sagas.ts +++ b/common/features/transactions/sagas.ts @@ -8,9 +8,7 @@ import { getTransactionFields } from 'libs/transaction'; import { NetworkConfig } from 'types/network'; import { TransactionData, TransactionReceipt, SavedTransaction } from 'types/transactions'; import { AppState } from 'features/reducers'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; -import * as configSelectors from 'features/config/selectors'; -import { getChecksumAddressFn } from 'features/config'; +import { configSelectors, configNodesSelectors } from 'features/config'; import { walletSelectors } from 'features/wallet'; import { transactionBroadcastTypes } from 'features/transaction'; import * as types from './types'; @@ -93,7 +91,7 @@ export function* getSaveableTransaction(tx: EthTx, hash: string): SagaIterator { from = wallet.getAddressString(); } } - const toChecksumAddress = yield select(getChecksumAddressFn); + const toChecksumAddress = yield select(configSelectors.getChecksumAddressFn); const savableTx: SavedTransaction = { hash, from, diff --git a/common/features/wallet/sagas.spec.ts b/common/features/wallet/sagas.spec.ts index 3728c1fa..396c386e 100644 --- a/common/features/wallet/sagas.spec.ts +++ b/common/features/wallet/sagas.spec.ts @@ -11,11 +11,14 @@ import Web3Node from 'libs/nodes/web3'; import { INode } from 'libs/nodes/INode'; import { Token } from 'types/network'; import * as derivedSelectors from 'features/selectors'; -import * as configMetaSelectors from 'features/config/meta/selectors'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; -import * as configNodesStaticActions from 'features/config/nodes/static/actions'; -import * as configNodesSelectedActions from 'features/config/nodes/selected'; -import * as configSagas from 'features/config/sagas'; +import { + configMetaSelectors, + configNodesSelectors, + configNodesStaticActions, + configNodesSelectedTypes, + configNodesSelectedActions, + configSagas +} from 'features/config'; import { notificationsActions } from 'features/notifications'; import * as types from './types'; import * as actions from './actions'; @@ -319,7 +322,7 @@ describe('unlockWeb3*', () => { it('should yield take on node change', () => { const expected = take( (action: any) => - action.type === configNodesSelectedActions.CONFIG_NODES_SELECTED.CHANGE_SUCCEEDED && + action.type === configNodesSelectedTypes.ConfigNodesSelectedActions.CHANGE_SUCCEEDED && action.payload.nodeSelection === 'web3' ); const result = data.gen.next().value; diff --git a/common/features/wallet/sagas.ts b/common/features/wallet/sagas.ts index 4cec70f7..760ee13c 100644 --- a/common/features/wallet/sagas.ts +++ b/common/features/wallet/sagas.ts @@ -19,10 +19,12 @@ import { import { loadWalletConfig, saveWalletConfig } from 'utils/localStorage'; import { AppState } from 'features/reducers'; import * as derivedSelectors from 'features/selectors'; -import * as configMetaTypes from 'features/config/meta/types'; -import * as configMetaSelectors from 'features/config/meta/selectors'; -import * as configNodesSelectors from 'features/config/nodes/selectors'; -import * as configSelectors from 'features/config/selectors'; +import { + configMetaTypes, + configMetaSelectors, + configNodesSelectors, + configSelectors +} from 'features/config'; import { notificationsActions } from 'features/notifications'; import { customTokensTypes, customTokensSelectors } from 'features/customTokens'; import * as types from './types'; @@ -313,7 +315,7 @@ export function* walletSaga(): SagaIterator { takeEvery(types.WalletActions.REFRESH_ACCOUNT_BALANCE, updateAccountBalance), takeEvery(types.WalletActions.REFRESH_TOKEN_BALANCES, retryTokenBalances), // Foreign actions - takeEvery(configMetaTypes.CONFIG_META.TOGGLE_OFFLINE, updateBalances), + takeEvery(configMetaTypes.ConfigMetaActions.TOGGLE_OFFLINE, updateBalances), takeEvery(customTokensTypes.CustomTokensActions.ADD, handleCustomTokenAdd) ]; } diff --git a/spec/pages/SendTransaction.spec.tsx b/spec/pages/SendTransaction.spec.tsx index d8792ed3..6062a3e9 100644 --- a/spec/pages/SendTransaction.spec.tsx +++ b/spec/pages/SendTransaction.spec.tsx @@ -11,7 +11,7 @@ import { configReducer } from 'features/config'; Enzyme.configure({ adapter: new Adapter() }); it('render snapshot', () => { - const testStateConfig = configReducer(undefined as any, {} as any); + const testStateConfig = configReducer.configReducer(undefined as any, {} as any); const testState = { wallet: {}, balance: {},