2018-02-20 09:30:36 +00:00
|
|
|
/* @flow */
|
2018-07-30 10:52:13 +00:00
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
|
|
|
|
import * as ACCOUNT from '../actions/constants/account';
|
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
import type {
|
|
|
|
Action,
|
2018-05-25 09:26:36 +00:00
|
|
|
Account,
|
|
|
|
Coin,
|
|
|
|
Token,
|
2018-05-25 09:49:15 +00:00
|
|
|
PendingTx,
|
2018-05-25 09:26:36 +00:00
|
|
|
Discovery,
|
2018-07-30 10:52:13 +00:00
|
|
|
Web3Instance,
|
2018-08-14 12:56:47 +00:00
|
|
|
} from 'flowtype';
|
2018-04-16 21:19:50 +00:00
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export type State = {
|
2018-05-25 09:26:36 +00:00
|
|
|
location?: string;
|
|
|
|
|
|
|
|
account: ?Account;
|
|
|
|
network: ?Coin;
|
|
|
|
tokens: Array<Token>,
|
2018-05-25 09:49:15 +00:00
|
|
|
pending: Array<PendingTx>,
|
2018-05-25 09:26:36 +00:00
|
|
|
web3: ?Web3Instance,
|
|
|
|
discovery: ?Discovery
|
2018-02-20 09:30:36 +00:00
|
|
|
};
|
|
|
|
|
2018-05-25 09:26:36 +00:00
|
|
|
export const initialState: State = {
|
|
|
|
location: '/',
|
|
|
|
account: null,
|
|
|
|
network: null,
|
|
|
|
tokens: [],
|
2018-05-25 09:49:15 +00:00
|
|
|
pending: [],
|
2018-05-25 09:26:36 +00:00
|
|
|
web3: null,
|
2018-07-30 10:52:13 +00:00
|
|
|
discovery: null,
|
2018-05-25 09:26:36 +00:00
|
|
|
};
|
2018-02-20 09:30:36 +00:00
|
|
|
|
2018-05-25 09:26:36 +00:00
|
|
|
export default (state: State = initialState, action: Action): State => {
|
2018-02-20 09:30:36 +00:00
|
|
|
switch (action.type) {
|
2018-07-30 10:52:13 +00:00
|
|
|
case ACCOUNT.UPDATE_SELECTED_ACCOUNT:
|
2018-05-25 09:26:36 +00:00
|
|
|
return action.payload;
|
2018-02-20 09:30:36 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2018-07-30 10:52:13 +00:00
|
|
|
};
|