William O'Beirne b638b746de Custom Nodes - Final Touches (#501)
* Add warning about matching nodes, only allow one url:port combination of nodes.

* Fix up alert styling.

* Custom network form.

* Add custom network to redux store. Setup infrastructure for removal and display.

* Persist custom networks to LS, show them in display.

* Force chain id, make typing happy.

* Display custom networks in network dropdown.

* Fix form validation, purge unused custom networks.
2017-12-01 10:09:51 -06:00

61 lines
1.5 KiB
TypeScript

import {
NetworkConfig,
NetworkContract,
NodeConfig,
CustomNodeConfig,
CustomNetworkConfig
} from 'config/data';
import { INode } from 'libs/nodes/INode';
import { AppState } from 'reducers';
import { getNetworkConfigFromId } from 'utils/network';
export function getNode(state: AppState): string {
return state.config.nodeSelection;
}
export function getNodeConfig(state: AppState): NodeConfig {
return state.config.node;
}
export function getNodeLib(state: AppState): INode {
return getNodeConfig(state).lib;
}
export function getNetworkConfig(state: AppState): NetworkConfig | undefined {
return getNetworkConfigFromId(
getNodeConfig(state).network,
getCustomNetworkConfigs(state)
);
}
export function getNetworkContracts(state: AppState): NetworkContract[] | null {
const network = getNetworkConfig(state);
return network ? network.contracts : [];
}
export function getGasPriceGwei(state: AppState): number {
return state.config.gasPriceGwei;
}
export function getLanguageSelection(state: AppState): string {
return state.config.languageSelection;
}
export function getCustomNodeConfigs(state: AppState): CustomNodeConfig[] {
return state.config.customNodes;
}
export function getCustomNetworkConfigs(
state: AppState
): CustomNetworkConfig[] {
return state.config.customNetworks;
}
export function getOffline(state: AppState): boolean {
return state.config.offline;
}
export function getForceOffline(state: AppState): boolean {
return state.config.forceOffline;
}