MyCrypto/common/reducers/message.ts
Maciej Hirsz cf59688896 Enable Parity Signer Message Signing (#1663)
* Enable Parity Signer to sign messages

* Verify that message signature is correct

* Type systems are awesome :)
2018-04-25 19:36:29 -05:00

36 lines
849 B
TypeScript

import { MessageAction, SignLocalMessageSucceededAction, TypeKeys } from 'actions/message';
import { ISignedMessage } from 'libs/signing';
export interface State {
signed?: ISignedMessage | null;
}
export const INITIAL_STATE: State = {
signed: null
};
function signLocalMessageSucceeded(state: State, action: SignLocalMessageSucceededAction): State {
return {
...state,
signed: action.payload
};
}
function signMessageFailed(state: State): State {
return {
...state,
signed: null
};
}
export function message(state: State = INITIAL_STATE, action: MessageAction): State {
switch (action.type) {
case TypeKeys.SIGN_LOCAL_MESSAGE_SUCCEEDED:
return signLocalMessageSucceeded(state, action);
case TypeKeys.SIGN_MESSAGE_FAILED:
return signMessageFailed(state);
default:
return state;
}
}