2017-09-24 19:06:28 -07:00
|
|
|
import { GenerateWalletAction } from 'actions/generateWallet';
|
|
|
|
import { TypeKeys } from 'actions/generateWallet/constants';
|
2017-11-07 13:42:53 -05:00
|
|
|
import { IFullWallet } from 'ethereumjs-wallet';
|
2017-04-18 18:34:24 -05:00
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface State {
|
|
|
|
activeStep: string;
|
2017-11-07 13:42:53 -05:00
|
|
|
wallet?: IFullWallet | null;
|
2017-09-24 19:06:28 -07:00
|
|
|
password?: string | null;
|
|
|
|
}
|
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-09-24 19:06:28 -07:00
|
|
|
case TypeKeys.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-09-24 19:06:28 -07:00
|
|
|
case TypeKeys.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-09-24 19:06:28 -07:00
|
|
|
case TypeKeys.GENERATE_WALLET_RESET: {
|
2017-07-27 13:05:09 -04:00
|
|
|
return INITIAL_STATE;
|
2017-04-18 18:34:24 -05:00
|
|
|
}
|
2017-06-19 22:15:38 -05:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2017-04-18 18:34:24 -05:00
|
|
|
}
|