1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-01 04:38:15 +00:00
This commit is contained in:
Vladimir Volek 2018-11-22 14:20:37 +01:00
parent 43906f505c
commit 68d3bbb738
4 changed files with 33 additions and 13 deletions

View File

@ -8,9 +8,18 @@ import * as SIGN_VERIFY from './constants/signVerify';
export type SignVerifyAction = {
type: typeof SIGN_VERIFY.SIGN_SUCCESS,
signature: string
signSignature: string
} | {
type: typeof SIGN_VERIFY.CLEAR,
type: typeof SIGN_VERIFY.CLEAR_SIGN,
} | {
type: typeof SIGN_VERIFY.CLEAR_VERIFY,
} | {
type: typeof SIGN_VERIFY.INPUT_CHANGE,
name: string,
value: string
} | {
type: typeof SIGN_VERIFY.TOUCH,
name: string,
}
const sign = (
@ -36,7 +45,7 @@ const sign = (
if (response && response.success) {
dispatch({
type: SIGN_VERIFY.SIGN_SUCCESS,
signature: response.payload.signature,
signSignature: response.payload.signature,
});
} else {
dispatch({
@ -111,7 +120,7 @@ const verify = (
}
};
const inputChange = (name, value): ThunkAction => (dispatch: Dispatch): void => {
const inputChange = (name: string, value: string): ThunkAction => (dispatch: Dispatch): void => {
dispatch({
type: SIGN_VERIFY.INPUT_CHANGE,
name,

View File

@ -1,5 +1,6 @@
/* @flow */
import type { Action } from 'flowtype';
import * as ACTION from 'actions/constants/signVerify';
export type State = {
@ -9,7 +10,7 @@ export type State = {
verifyAddress: string,
verifyMessage: string,
verifySignature: string,
touched: Array<String>
touched: Array<string>
}
export const initialState: State = {
@ -26,8 +27,8 @@ export default (state: State = initialState, action: Action): State => {
switch (action.type) {
case ACTION.SIGN_SUCCESS:
return {
...initialState,
signature: action.signature,
...state,
signSignature: action.signSignature,
};
case ACTION.TOUCH: {
@ -41,8 +42,8 @@ export default (state: State = initialState, action: Action): State => {
}
case ACTION.INPUT_CHANGE: {
const changes = { [action.name]: action.value };
return { ...state, ...changes };
const change = { [action.name]: action.value };
return { ...state, ...change };
}
case ACTION.CLEAR_SIGN:

View File

@ -13,11 +13,22 @@ type OwnProps = {}
export type StateProps = {
wallet: $ElementType<State, 'wallet'>,
selectedAccount: $ElementType<State, 'selectedAccount'>,
signature: string,
}
type SignVerify = {
signSignature: string,
signAddress: string,
signMessage: string,
signSignature: string,
verifyAddress: string,
verifyMessage: string,
verifySignature: string,
touched: Array<string>,
}
export type DispatchProps = {
signVerifyActions: typeof SignVerifyActions,
signVerify: SignVerify
}
export type Props = StateProps & DispatchProps;

View File

@ -69,7 +69,6 @@ class SignVerify extends Component<Props, State> {
const {
signVerifyActions,
signVerify: {
signAddress,
signMessage,
signSignature,
verifyAddress,
@ -124,7 +123,7 @@ class SignVerify extends Component<Props, State> {
>Clear
</Button>
<StyledButton
onClick={() => signVerifyActions.sign(signAddress, signMessage)}
onClick={() => signVerifyActions.sign(account.addressPath, signMessage)}
>Sign
</StyledButton>
</RowButtons>
@ -166,7 +165,7 @@ class SignVerify extends Component<Props, State> {
</Row>
<RowButtons>
<Button
onClick={signVerifyActions.clearSign}
onClick={signVerifyActions.clearVerify}
isWhite
>Clear
</Button>