diff --git a/common/features/config/networks/actions.ts b/common/features/config/networks/actions.ts index d389abbf..1299364a 100644 --- a/common/features/config/networks/actions.ts +++ b/common/features/config/networks/actions.ts @@ -1,11 +1,11 @@ -import { CONFIG_NETWORKS, ChangeNetworkRequestedAction } from './types'; +import * as types from './types'; export type TChangeNetworkRequested = typeof changeNetworkRequested; export function changeNetworkRequested( - payload: ChangeNetworkRequestedAction['payload'] -): ChangeNetworkRequestedAction { + payload: types.ChangeNetworkRequestedAction['payload'] +): types.ChangeNetworkRequestedAction { return { - type: CONFIG_NETWORKS.CHANGE_NETWORK_REQUESTED, + type: types.ConfigNetworksActions.CHANGE_NETWORK_REQUESTED, payload }; } diff --git a/common/features/config/networks/index.ts b/common/features/config/networks/index.ts index 94932c65..0959bab6 100644 --- a/common/features/config/networks/index.ts +++ b/common/features/config/networks/index.ts @@ -1,7 +1,14 @@ -export * from './types'; -export * from './actions'; -export * from './reducer'; -export * from './selectors'; +import * as configNetworksTypes from './types'; +import * as configNetworksActions from './actions'; +import * as configNetworksReducer from './reducer'; +import * as configNetworksSelectors from './selectors'; + +export { + configNetworksTypes, + configNetworksActions, + configNetworksReducer, + configNetworksSelectors +}; export * from './custom'; export * from './static'; diff --git a/common/features/config/networks/reducer.ts b/common/features/config/networks/reducer.ts index 4d46108d..39348178 100644 --- a/common/features/config/networks/reducer.ts +++ b/common/features/config/networks/reducer.ts @@ -1,10 +1,10 @@ import { combineReducers } from 'redux'; -import { customNetworksReducer } from './custom/reducer'; -import { staticNetworksReducer } from './static/reducer'; -import { NetworksState } from './types'; +import * as configNetworksCustomReducer from './custom/reducer'; +import * as configStaticCustomReducer from './static/reducer'; +import * as types from './types'; -export const networksReducer = combineReducers({ - customNetworks: customNetworksReducer, - staticNetworks: staticNetworksReducer +export const networksReducer = combineReducers({ + customNetworks: configNetworksCustomReducer.customNetworksReducer, + staticNetworks: configStaticCustomReducer.staticNetworksReducer }); diff --git a/common/features/config/networks/selectors.ts b/common/features/config/networks/selectors.ts index bfb29ed3..61e3c201 100644 --- a/common/features/config/networks/selectors.ts +++ b/common/features/config/networks/selectors.ts @@ -1,7 +1,7 @@ import { StaticNetworkIds } from 'types/network'; import { AppState } from 'features/reducers'; -import { getCustomNetworkConfigs } from './custom/selectors'; -import { isStaticNetworkId, getStaticNetworkConfigs } from './static/selectors'; +import * as configMetaNetworksCustomSelectors from './custom/selectors'; +import * as configMetaNetworksStaticSelectors from './static/selectors'; const getConfig = (state: AppState) => state.config; @@ -11,14 +11,18 @@ export const getStaticNetworkIds = (state: AppState): StaticNetworkIds[] => Object.keys(getNetworks(state).staticNetworks) as StaticNetworkIds[]; export const getNetworkConfigById = (state: AppState, networkId: string) => - isStaticNetworkId(state, networkId) - ? getStaticNetworkConfigs(state)[networkId] - : getCustomNetworkConfigs(state)[networkId]; + configMetaNetworksStaticSelectors.isStaticNetworkId(state, networkId) + ? configMetaNetworksStaticSelectors.getStaticNetworkConfigs(state)[networkId] + : configMetaNetworksCustomSelectors.getCustomNetworkConfigs(state)[networkId]; export const getNetworkByChainId = (state: AppState, chainId: number | string) => { const network = - Object.values(getStaticNetworkConfigs(state)).find(n => +n.chainId === +chainId) || - Object.values(getCustomNetworkConfigs(state)).find(n => +n.chainId === +chainId); + Object.values(configMetaNetworksStaticSelectors.getStaticNetworkConfigs(state)).find( + n => +n.chainId === +chainId + ) || + Object.values(configMetaNetworksCustomSelectors.getCustomNetworkConfigs(state)).find( + n => +n.chainId === +chainId + ); if (!network) { return null; } diff --git a/common/features/config/networks/static/selectors.ts b/common/features/config/networks/static/selectors.ts index 84dc5184..b2840c6c 100644 --- a/common/features/config/networks/static/selectors.ts +++ b/common/features/config/networks/static/selectors.ts @@ -4,7 +4,7 @@ import { EXTRA_PATHS } from 'config/dpaths'; import { stripWeb3Network } from 'libs/nodes'; import { StaticNetworkIds } from 'types/network'; import { AppState } from 'features/reducers'; -import { PathType } from './types'; +import * as types from './types'; function getNetworks(state: AppState) { return state.config.networks; @@ -21,7 +21,7 @@ export function isStaticNetworkId( return Object.keys(getStaticNetworkConfigs(state)).includes(stripWeb3Network(networkId)); } -export function getPaths(state: AppState, pathType: PathType): DPath[] { +export function getPaths(state: AppState, pathType: types.PathType): DPath[] { const paths = Object.values(getStaticNetworkConfigs(state)) .reduce((networkPaths: DPath[], { dPathFormats }): DPath[] => { if (dPathFormats && dPathFormats[pathType]) { diff --git a/common/features/config/networks/types.ts b/common/features/config/networks/types.ts index 4f8df867..5c467374 100644 --- a/common/features/config/networks/types.ts +++ b/common/features/config/networks/types.ts @@ -1,16 +1,16 @@ -import { CustomNetworksState } from './custom/types'; -import { StaticNetworksState } from './static/types'; +import * as configNetworksCustomTypes from './custom/types'; +import * as configNetworksStaticTypes from './static/types'; -export enum CONFIG_NETWORKS { +export enum ConfigNetworksActions { CHANGE_NETWORK_REQUESTED = 'CONFIG_NETWORK_CHANGE_NETWORK_REQUESTED' } export interface NetworksState { - customNetworks: CustomNetworksState; - staticNetworks: StaticNetworksState; + customNetworks: configNetworksCustomTypes.CustomNetworksState; + staticNetworks: configNetworksStaticTypes.StaticNetworksState; } export interface ChangeNetworkRequestedAction { - type: CONFIG_NETWORKS.CHANGE_NETWORK_REQUESTED; + type: ConfigNetworksActions.CHANGE_NETWORK_REQUESTED; payload: string; }