mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-23 08:18:17 +00:00
26 lines
754 B
TypeScript
26 lines
754 B
TypeScript
|
import { StaticNodeId } from 'types/node';
|
||
|
import { AppState } from 'features/reducers';
|
||
|
|
||
|
function getNodes(state: AppState) {
|
||
|
return state.config.nodes;
|
||
|
}
|
||
|
|
||
|
export function getStaticNodes(state: AppState) {
|
||
|
return getNodes(state).staticNodes;
|
||
|
}
|
||
|
|
||
|
export function getStaticNodeConfigs(state: AppState) {
|
||
|
return getNodes(state).staticNodes;
|
||
|
}
|
||
|
|
||
|
export const getStaticNodeConfig = (state: AppState) => {
|
||
|
const { staticNodes, selectedNode: { nodeId } } = getNodes(state);
|
||
|
|
||
|
const defaultNetwork = isStaticNodeId(state, nodeId) ? staticNodes[nodeId] : undefined;
|
||
|
return defaultNetwork;
|
||
|
};
|
||
|
|
||
|
export function isStaticNodeId(state: AppState, nodeId: string): nodeId is StaticNodeId {
|
||
|
return Object.keys(getStaticNodeConfigs(state)).includes(nodeId);
|
||
|
}
|