MyCrypto/common/reducers/generateWallet.js
William O'Beirne 1aad9d1c21 Standardize Redux Actions / Reducers (#95)
* Convert Swap to consistent style

* Generate wallet reducer cleanup.

* Confirm empty action in swap reducer

* Union types. Fix gen wallet collision

* Fix not using all actions in reducer. Added reducer state for is fetching from bity. Added todo to make that a loader.

* Readme instructions.

* Remove common action constants.

* Bring all actions and reducers inline with readme instructions.

* Readme fixes

* address comments
2017-07-27 12:05:09 -05:00

47 lines
914 B
JavaScript

// @flow
import type PrivateKeyWallet from 'libs/wallet/privkey';
import type { GenerateWalletAction } from 'actions/generateWallet';
export type State = {
activeStep: string,
wallet: ?PrivateKeyWallet,
password: ?string
};
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;
}
}