1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 12:59:09 +00:00
trezor-wallet/src/reducers/ReceiveReducer.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-20 09:30:36 +00:00
/* @flow */
2018-07-30 10:52:13 +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:
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:
if (action.payload.code === 'ButtonRequest_Address') {
return {
...state,
addressVerified: true,
2018-07-30 10:52:13 +00:00
};
}
return state;
2018-02-20 09:30:36 +00:00
default:
return state;
}
2019-03-04 12:33:02 +00:00
};