2017-06-27 02:27:55 +04:00
|
|
|
// @flow
|
2017-07-16 16:02:13 -05:00
|
|
|
import type PrivateKeyWallet from 'libs/wallet/privkey';
|
2017-07-27 13:05:09 -04:00
|
|
|
import type { GenerateWalletAction } from 'actions/generateWallet';
|
2017-04-18 18:34:24 -05:00
|
|
|
|
2017-06-27 02:27:55 +04:00
|
|
|
export type State = {
|
2017-07-16 16:02:13 -05:00
|
|
|
activeStep: string,
|
|
|
|
wallet: ?PrivateKeyWallet,
|
|
|
|
password: ?string
|
2017-07-02 00:49:06 -05:00
|
|
|
};
|
2017-06-27 02:27:55 +04:00
|
|
|
|
2017-07-27 13:05:09 -04:00
|
|
|
export const INITIAL_STATE: State = {
|
2017-07-16 16:02:13 -05:00
|
|
|
activeStep: 'password',
|
|
|
|
wallet: null,
|
|
|
|
password: null
|
2017-06-19 22:15:38 -05:00
|
|
|
};
|
2017-04-18 18:34:24 -05:00
|
|
|
|
2017-07-27 13:05:09 -04:00
|
|
|
export function generateWallet(
|
|
|
|
state: State = INITIAL_STATE,
|
|
|
|
action: GenerateWalletAction
|
|
|
|
): State {
|
2017-06-19 22:15:38 -05:00
|
|
|
switch (action.type) {
|
2017-07-27 13:05:09 -04:00
|
|
|
case 'GENERATE_WALLET_GENERATE_WALLET': {
|
2017-06-19 22:15:38 -05:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-16 16:02:13 -05:00
|
|
|
wallet: action.wallet,
|
|
|
|
password: action.password,
|
|
|
|
activeStep: 'download'
|
2017-06-19 22:15:38 -05:00
|
|
|
};
|
|
|
|
}
|
2017-04-27 01:13:33 -05:00
|
|
|
|
2017-07-27 13:05:09 -04:00
|
|
|
case 'GENERATE_WALLET_CONTINUE_TO_PAPER': {
|
2017-06-19 22:15:38 -05:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-16 16:02:13 -05:00
|
|
|
activeStep: 'paper'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-27 13:05:09 -04:00
|
|
|
case 'GENERATE_WALLET_RESET': {
|
|
|
|
return INITIAL_STATE;
|
2017-04-18 18:34:24 -05:00
|
|
|
}
|
2017-06-19 22:15:38 -05:00
|
|
|
|
|
|
|
default:
|
2017-07-27 13:05:09 -04:00
|
|
|
(action: empty);
|
2017-06-19 22:15:38 -05:00
|
|
|
return state;
|
|
|
|
}
|
2017-04-18 18:34:24 -05:00
|
|
|
}
|