2017-09-25 02:06:28 +00:00
|
|
|
import { GenerateWalletAction } from 'actions/generateWallet';
|
|
|
|
import { TypeKeys } from 'actions/generateWallet/constants';
|
2017-11-07 18:42:53 +00:00
|
|
|
import { IFullWallet } from 'ethereumjs-wallet';
|
2017-04-18 23:34:24 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface State {
|
|
|
|
activeStep: string;
|
2017-11-07 18:42:53 +00:00
|
|
|
wallet?: IFullWallet | null;
|
2017-09-25 02:06:28 +00:00
|
|
|
password?: string | null;
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
export const INITIAL_STATE: State = {
|
2017-07-16 21:02:13 +00:00
|
|
|
activeStep: 'password',
|
|
|
|
wallet: null,
|
|
|
|
password: null
|
2017-06-20 03:15:38 +00:00
|
|
|
};
|
2017-04-18 23:34:24 +00:00
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
export function generateWallet(
|
|
|
|
state: State = INITIAL_STATE,
|
|
|
|
action: GenerateWalletAction
|
|
|
|
): State {
|
2017-06-20 03:15:38 +00:00
|
|
|
switch (action.type) {
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.GENERATE_WALLET_GENERATE_WALLET: {
|
2017-06-20 03:15:38 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-16 21:02:13 +00:00
|
|
|
wallet: action.wallet,
|
|
|
|
password: action.password,
|
|
|
|
activeStep: 'download'
|
2017-06-20 03:15:38 +00:00
|
|
|
};
|
|
|
|
}
|
2017-04-27 06:13:33 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.GENERATE_WALLET_CONTINUE_TO_PAPER: {
|
2017-06-20 03:15:38 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-16 21:02:13 +00:00
|
|
|
activeStep: 'paper'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
case TypeKeys.GENERATE_WALLET_RESET: {
|
2017-07-27 17:05:09 +00:00
|
|
|
return INITIAL_STATE;
|
2017-04-18 23:34:24 +00:00
|
|
|
}
|
2017-06-20 03:15:38 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2017-04-18 23:34:24 +00:00
|
|
|
}
|