Merge branch 'develop' into reorder-wallet-unlock

This commit is contained in:
Connor Bryan 2018-08-15 14:02:47 -05:00 committed by GitHub
commit d9084dbc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 4 deletions

View File

@ -2462,7 +2462,7 @@
{ {
"address": "0x12fCd6463E66974cF7bBC24FFC4d40d6bE458283", "address": "0x12fCd6463E66974cF7bBC24FFC4d40d6bE458283",
"symbol": "GBX", "symbol": "GBX",
"decimal": 18 "decimal": 8
}, },
{ {
"address": "0x7728dFEF5aBd468669EB7f9b48A7f70a501eD29D", "address": "0x7728dFEF5aBd468669EB7f9b48A7f70a501eD29D",

View File

@ -18,6 +18,7 @@ interface Props {
signMessageRequested: messageActions.TSignMessageRequested; signMessageRequested: messageActions.TSignMessageRequested;
signedMessage: ISignedMessage | null; signedMessage: ISignedMessage | null;
resetWallet: walletActions.TResetWallet; resetWallet: walletActions.TResetWallet;
resetMessage: messageActions.TResetMessage;
} }
interface State { interface State {
@ -35,6 +36,7 @@ export class SignMessage extends Component<Props, State> {
public componentWillUnmount() { public componentWillUnmount() {
this.props.resetWallet(); this.props.resetWallet();
this.props.resetMessage();
} }
public render() { public render() {
@ -97,6 +99,8 @@ export class SignMessage extends Component<Props, State> {
private changeWallet = () => { private changeWallet = () => {
this.props.resetWallet(); this.props.resetWallet();
this.props.resetMessage();
this.setState(initialState);
}; };
} }
@ -107,5 +111,6 @@ const mapStateToProps = (state: AppState) => ({
export default connect(mapStateToProps, { export default connect(mapStateToProps, {
signMessageRequested: messageActions.signMessageRequested, signMessageRequested: messageActions.signMessageRequested,
resetWallet: walletActions.resetWallet resetWallet: walletActions.resetWallet,
resetMessage: messageActions.resetMessage
})(SignMessage); })(SignMessage);

View File

@ -25,3 +25,10 @@ export function signMessageFailed(): types.SignMessageFailedAction {
type: types.MessageActions.SIGN_FAILED type: types.MessageActions.SIGN_FAILED
}; };
} }
export type TResetMessage = typeof resetMessage;
export function resetMessage(): types.ResetMessageAction {
return {
type: types.MessageActions.RESET
};
}

View File

@ -21,6 +21,12 @@ function signMessageFailed(state: types.MessageState): types.MessageState {
}; };
} }
function resetMessage(): types.MessageState {
return {
...INITIAL_STATE
};
}
export function messageReducer( export function messageReducer(
state: types.MessageState = INITIAL_STATE, state: types.MessageState = INITIAL_STATE,
action: types.MessageAction action: types.MessageAction
@ -30,6 +36,8 @@ export function messageReducer(
return signLocalMessageSucceeded(state, action); return signLocalMessageSucceeded(state, action);
case types.MessageActions.SIGN_FAILED: case types.MessageActions.SIGN_FAILED:
return signMessageFailed(state); return signMessageFailed(state);
case types.MessageActions.RESET:
return resetMessage();
default: default:
return state; return state;
} }

View File

@ -3,7 +3,8 @@ import { ISignedMessage } from 'libs/signing';
export enum MessageActions { export enum MessageActions {
SIGN_REQUESTED = 'MESSAGE_SIGN_REQUESTED', SIGN_REQUESTED = 'MESSAGE_SIGN_REQUESTED',
SIGN_LOCAL_SUCCEEDED = 'MESSAGE_SIGN_LOCAL_SUCCEEDED', SIGN_LOCAL_SUCCEEDED = 'MESSAGE_SIGN_LOCAL_SUCCEEDED',
SIGN_FAILED = 'MESSAGE_SIGN_FAILED' SIGN_FAILED = 'MESSAGE_SIGN_FAILED',
RESET = 'MESSAGE_RESET'
} }
export interface MessageState { export interface MessageState {
@ -24,7 +25,12 @@ export interface SignMessageFailedAction {
type: MessageActions.SIGN_FAILED; type: MessageActions.SIGN_FAILED;
} }
export interface ResetMessageAction {
type: MessageActions.RESET;
}
export type MessageAction = export type MessageAction =
| SignMessageRequestedAction | SignMessageRequestedAction
| SignLocalMessageSucceededAction | SignLocalMessageSucceededAction
| SignMessageFailedAction; | SignMessageFailedAction
| ResetMessageAction;