Wrangle types due to webpack weirdness.

This commit is contained in:
Will O'Beirne 2018-03-07 18:45:16 -05:00
parent 02d8f4b6a1
commit efe55e108e
No known key found for this signature in database
GPG Key ID: 44C190DB5DEAF9F6
9 changed files with 45 additions and 35 deletions

View File

@ -4,12 +4,7 @@ import {
CustomNetworkAction,
TypeKeys
} from 'actions/config';
import { CustomNetworkConfig } from 'types/network';
// TODO: this doesn't accurately represent state, as
export interface State {
[customNetworkId: string]: CustomNetworkConfig;
}
import { CustomNetworksState as State } from './types';
const addCustomNetwork = (state: State, { payload }: AddCustomNetworkAction): State => ({
...state,

View File

@ -1,6 +1,7 @@
import { customNetworks, State as CustomNetworksState } from './customNetworks';
import { staticNetworks, State as StaticNetworksState } from './staticNetworks';
import { combineReducers } from 'redux';
import { customNetworks } from './customNetworks';
import { staticNetworks } from './staticNetworks';
import { StaticNetworksState, CustomNetworksState } from './types';
interface State {
customNetworks: CustomNetworksState;

View File

@ -16,9 +16,8 @@ import {
UBQ_DEFAULT
} from 'config/dpaths';
import { ConfigAction } from 'actions/config';
import { StaticNetworkIds, StaticNetworkConfig, BlockExplorerConfig } from 'types/network';
export type State = { [key in StaticNetworkIds]: StaticNetworkConfig };
import { BlockExplorerConfig } from 'types/network';
import { StaticNetworksState as State } from './types';
// Must be a website that follows the ethplorer convention of /tx/[hash] and
// address/[address] to generate the correct functions.

View File

@ -0,0 +1,10 @@
// Moving state types into their own file resolves an annoying webpack bug
// https://github.com/angular/angular-cli/issues/2034
import { StaticNetworkIds, StaticNetworkConfig, CustomNetworkConfig } from 'types/network';
export type StaticNetworksState = { [key in StaticNetworkIds]: StaticNetworkConfig };
// TODO: this doesn't accurately represent custom networks state
export interface CustomNetworksState {
[customNetworkId: string]: CustomNetworkConfig;
}

View File

@ -4,11 +4,7 @@ import {
AddCustomNodeAction,
RemoveCustomNodeAction
} from 'actions/config';
import { CustomNodeConfig } from 'types/node';
export interface State {
[customNodeId: string]: CustomNodeConfig;
}
import { CustomNodesState as State } from './types';
const addCustomNode = (state: State, { payload }: AddCustomNodeAction): State => ({
...state,

View File

@ -1,7 +1,8 @@
import { customNodes, State as CustomNodesState } from './customNodes';
import { staticNodes, State as StaticNodesState } from './staticNodes';
import { selectedNode, State as SelectedNodeState } from './selectedNode';
import { combineReducers } from 'redux';
import { customNodes } from './customNodes';
import { staticNodes } from './staticNodes';
import { selectedNode } from './selectedNode';
import { CustomNodesState, StaticNodesState, SelectedNodeState } from './types';
interface State {
customNodes: CustomNodesState;

View File

@ -6,20 +6,9 @@ import {
RemoveCustomNodeAction,
CustomNodeAction
} from 'actions/config';
import { SelectedNodeState as State } from './types';
interface NodeLoaded {
pending: false;
nodeId: string;
}
interface NodeChangePending {
pending: true;
nodeId: string;
}
export type State = NodeLoaded | NodeChangePending;
export const INITIAL_STATE: NodeLoaded = {
export const INITIAL_STATE: State = {
nodeId: 'eth_mycrypto',
pending: false
};

View File

@ -1,8 +1,6 @@
import { EtherscanNode, InfuraNode, RPCNode } from 'libs/nodes';
import { TypeKeys, NodeAction } from 'actions/config';
import { NonWeb3NodeConfigs, Web3NodeConfigs } from 'types/node';
export type State = NonWeb3NodeConfigs & Web3NodeConfigs;
import { StaticNodesState as State } from './types';
export const INITIAL_STATE: State = {
eth_mycrypto: {

View File

@ -0,0 +1,21 @@
// Moving state types into their own file resolves an annoying webpack bug
// https://github.com/angular/angular-cli/issues/2034
import { NonWeb3NodeConfigs, Web3NodeConfigs, CustomNodeConfig } from 'types/node';
export interface CustomNodesState {
[customNodeId: string]: CustomNodeConfig;
}
interface NodeLoaded {
pending: false;
nodeId: string;
}
interface NodeChangePending {
pending: true;
nodeId: string;
}
export type SelectedNodeState = NodeLoaded | NodeChangePending;
export type StaticNodesState = NonWeb3NodeConfigs & Web3NodeConfigs;