mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-30 19:00:53 +00:00
Add clear actions
This commit is contained in:
parent
e41cc22e3b
commit
43906f505c
@ -123,15 +123,22 @@ const inputChange = (name, value): ThunkAction => (dispatch: Dispatch): void =>
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const clear = (): ThunkAction => (dispatch: Dispatch): void => {
|
const clearSign = (): ThunkAction => (dispatch: Dispatch): void => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SIGN_VERIFY.CLEAR,
|
type: SIGN_VERIFY.CLEAR_SIGN,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearVerify = (): ThunkAction => (dispatch: Dispatch): void => {
|
||||||
|
dispatch({
|
||||||
|
type: SIGN_VERIFY.CLEAR_VERIFY,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
sign,
|
sign,
|
||||||
verify,
|
verify,
|
||||||
clear,
|
clearSign,
|
||||||
|
clearVerify,
|
||||||
inputChange,
|
inputChange,
|
||||||
};
|
};
|
@ -2,4 +2,5 @@
|
|||||||
export const SIGN_SUCCESS: 'sign__verify__sign__success' = 'sign__verify__sign__success';
|
export const SIGN_SUCCESS: 'sign__verify__sign__success' = 'sign__verify__sign__success';
|
||||||
export const INPUT_CHANGE: 'sign__verify__input__change' = 'sign__verify__input__change';
|
export const INPUT_CHANGE: 'sign__verify__input__change' = 'sign__verify__input__change';
|
||||||
export const TOUCH: 'sign__verify__input__touch' = 'sign__verify__input__touch';
|
export const TOUCH: 'sign__verify__input__touch' = 'sign__verify__input__touch';
|
||||||
export const CLEAR: 'sign__verify__sign__clear' = 'sign__verify__sign__clear';
|
export const CLEAR_SIGN: 'sign__verify__sign__clear' = 'sign__verify__sign__clear';
|
||||||
|
export const CLEAR_VERIFY: 'sign__verify__verify__clear' = 'sign__verify__verify__clear';
|
@ -1,6 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import type { Action } from 'flowtype';
|
import type { Action } from 'flowtype';
|
||||||
import * as SIGN_VERIFY from 'actions/constants/signVerify';
|
import * as ACTION from 'actions/constants/signVerify';
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
signAddress: string,
|
signAddress: string,
|
||||||
@ -24,13 +24,13 @@ export const initialState: State = {
|
|||||||
|
|
||||||
export default (state: State = initialState, action: Action): State => {
|
export default (state: State = initialState, action: Action): State => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case SIGN_VERIFY.SIGN_SUCCESS:
|
case ACTION.SIGN_SUCCESS:
|
||||||
return {
|
return {
|
||||||
...initialState,
|
...initialState,
|
||||||
signature: action.signature,
|
signature: action.signature,
|
||||||
};
|
};
|
||||||
|
|
||||||
case SIGN_VERIFY.TOUCH: {
|
case ACTION.TOUCH: {
|
||||||
if (!state.touched.includes(action.name)) {
|
if (!state.touched.includes(action.name)) {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@ -40,14 +40,25 @@ export default (state: State = initialState, action: Action): State => {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SIGN_VERIFY.INPUT_CHANGE: {
|
case ACTION.INPUT_CHANGE: {
|
||||||
const changes = { [action.name]: action.value };
|
const changes = { [action.name]: action.value };
|
||||||
return { ...state, ...changes };
|
return { ...state, ...changes };
|
||||||
}
|
}
|
||||||
|
|
||||||
case SIGN_VERIFY.CLEAR:
|
case ACTION.CLEAR_SIGN:
|
||||||
return {
|
return {
|
||||||
...initialState,
|
...state,
|
||||||
|
signAddress: '',
|
||||||
|
signMessage: '',
|
||||||
|
signSignature: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
case ACTION.CLEAR_VERIFY:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
verifyAddress: '',
|
||||||
|
verifyMessage: '',
|
||||||
|
verifySignature: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -56,12 +56,7 @@ type State = {
|
|||||||
|
|
||||||
class SignVerify extends Component<Props, State> {
|
class SignVerify extends Component<Props, State> {
|
||||||
handleInputChange = (event: SyntheticInputEvent<Text>) => {
|
handleInputChange = (event: SyntheticInputEvent<Text>) => {
|
||||||
const touched = true;
|
this.props.signVerifyActions.inputChange(event.target.name, event.target.value);
|
||||||
this.props.signVerifyActions.inputChange(
|
|
||||||
event.target.name,
|
|
||||||
event.target.value,
|
|
||||||
touched,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -73,19 +68,17 @@ class SignVerify extends Component<Props, State> {
|
|||||||
if (!device || !account || !discovery || !shouldRender) return <Content type={type} title={title} message={message} isLoading />;
|
if (!device || !account || !discovery || !shouldRender) return <Content type={type} title={title} message={message} isLoading />;
|
||||||
const {
|
const {
|
||||||
signVerifyActions,
|
signVerifyActions,
|
||||||
signVerify,
|
signVerify: {
|
||||||
|
signAddress,
|
||||||
|
signMessage,
|
||||||
|
signSignature,
|
||||||
|
verifyAddress,
|
||||||
|
verifyMessage,
|
||||||
|
verifySignature,
|
||||||
|
touched,
|
||||||
|
},
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
|
||||||
signAddress,
|
|
||||||
signMessage,
|
|
||||||
signSignature,
|
|
||||||
verifyAddress,
|
|
||||||
verifyMessage,
|
|
||||||
verifySignature,
|
|
||||||
touched,
|
|
||||||
} = signVerify;
|
|
||||||
console.log(touched);
|
|
||||||
return (
|
return (
|
||||||
<Content>
|
<Content>
|
||||||
<Title>Sign & Verify</Title>
|
<Title>Sign & Verify</Title>
|
||||||
|
Loading…
Reference in New Issue
Block a user