MyCrypto/common/reducers/generateWallet.js

47 lines
914 B
JavaScript
Raw Normal View History

2017-06-26 15:27:55 -07:00
// @flow
import type PrivateKeyWallet from 'libs/wallet/privkey';
import type { GenerateWalletAction } from 'actions/generateWallet';
2017-06-26 15:27:55 -07:00
export type State = {
activeStep: string,
wallet: ?PrivateKeyWallet,
password: ?string
2017-07-01 22:49:06 -07:00
};
2017-06-26 15:27:55 -07:00
export const INITIAL_STATE: State = {
activeStep: 'password',
wallet: null,
password: null
};
export function generateWallet(
state: State = INITIAL_STATE,
action: GenerateWalletAction
): State {
switch (action.type) {
case 'GENERATE_WALLET_GENERATE_WALLET': {
return {
...state,
wallet: action.wallet,
password: action.password,
activeStep: 'download'
};
}
case 'GENERATE_WALLET_CONTINUE_TO_PAPER': {
return {
...state,
activeStep: 'paper'
};
}
case 'GENERATE_WALLET_RESET': {
return INITIAL_STATE;
}
default:
(action: empty);
return state;
}
}