2018-02-20 09:30:36 +00:00
|
|
|
/* @flow */
|
2018-07-30 10:52:13 +00:00
|
|
|
|
2018-05-23 14:25:57 +00:00
|
|
|
import { UI } from 'trezor-connect';
|
2018-08-14 13:11:52 +00:00
|
|
|
import * as RECEIVE from 'actions/constants/receive';
|
|
|
|
import * as ACCOUNT from 'actions/constants/account';
|
2018-08-14 12:56:47 +00:00
|
|
|
import type { Action } from 'flowtype';
|
2018-02-20 09:30:36 +00:00
|
|
|
|
|
|
|
export type State = {
|
2019-03-04 12:33:02 +00:00
|
|
|
addressVerified: boolean,
|
|
|
|
addressUnverified: boolean,
|
|
|
|
};
|
2018-02-20 09:30:36 +00:00
|
|
|
|
|
|
|
export const initialState: State = {
|
|
|
|
addressVerified: false,
|
|
|
|
addressUnverified: false,
|
|
|
|
};
|
|
|
|
|
2018-04-23 10:20:15 +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 RECEIVE.INIT:
|
2018-02-20 09:30:36 +00:00
|
|
|
return action.state;
|
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
case ACCOUNT.DISPOSE:
|
2018-02-20 09:30:36 +00:00
|
|
|
return initialState;
|
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
case RECEIVE.SHOW_ADDRESS:
|
2018-02-20 09:30:36 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
addressVerified: true,
|
2018-07-30 10:52:13 +00:00
|
|
|
addressUnverified: false,
|
|
|
|
};
|
|
|
|
case RECEIVE.HIDE_ADDRESS:
|
2018-05-23 14:25:57 +00:00
|
|
|
return initialState;
|
2018-07-30 10:52:13 +00:00
|
|
|
|
|
|
|
case RECEIVE.SHOW_UNVERIFIED_ADDRESS:
|
2018-02-20 09:30:36 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
addressVerified: false,
|
2018-07-30 10:52:13 +00:00
|
|
|
addressUnverified: true,
|
|
|
|
};
|
2018-02-20 09:30:36 +00:00
|
|
|
|
2018-07-30 10:52:13 +00:00
|
|
|
case UI.REQUEST_BUTTON:
|
2018-05-23 14:25:57 +00:00
|
|
|
if (action.payload.code === 'ButtonRequest_Address') {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
addressVerified: true,
|
2018-07-30 10:52:13 +00:00
|
|
|
};
|
2018-05-23 14:25:57 +00:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|