From 68d3bbb73888e715d98ace060e68326d23169bf5 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 22 Nov 2018 14:20:37 +0100 Subject: [PATCH] Fix flow --- src/actions/SignVerifyActions.js | 17 +++++++++++++---- src/reducers/SignVerifyReducer.js | 11 ++++++----- .../views/Account/SignVerify/Container.js | 13 ++++++++++++- .../Wallet/views/Account/SignVerify/index.js | 5 ++--- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/actions/SignVerifyActions.js b/src/actions/SignVerifyActions.js index c0894a66..41d3614a 100644 --- a/src/actions/SignVerifyActions.js +++ b/src/actions/SignVerifyActions.js @@ -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, diff --git a/src/reducers/SignVerifyReducer.js b/src/reducers/SignVerifyReducer.js index ea1987fa..2188dc0b 100644 --- a/src/reducers/SignVerifyReducer.js +++ b/src/reducers/SignVerifyReducer.js @@ -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 + touched: Array } 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: diff --git a/src/views/Wallet/views/Account/SignVerify/Container.js b/src/views/Wallet/views/Account/SignVerify/Container.js index e4692801..5176f206 100644 --- a/src/views/Wallet/views/Account/SignVerify/Container.js +++ b/src/views/Wallet/views/Account/SignVerify/Container.js @@ -13,11 +13,22 @@ type OwnProps = {} export type StateProps = { wallet: $ElementType, selectedAccount: $ElementType, - signature: string, +} + +type SignVerify = { + signSignature: string, + signAddress: string, + signMessage: string, + signSignature: string, + verifyAddress: string, + verifyMessage: string, + verifySignature: string, + touched: Array, } export type DispatchProps = { signVerifyActions: typeof SignVerifyActions, + signVerify: SignVerify } export type Props = StateProps & DispatchProps; diff --git a/src/views/Wallet/views/Account/SignVerify/index.js b/src/views/Wallet/views/Account/SignVerify/index.js index 7933193a..ba489856 100644 --- a/src/views/Wallet/views/Account/SignVerify/index.js +++ b/src/views/Wallet/views/Account/SignVerify/index.js @@ -69,7 +69,6 @@ class SignVerify extends Component { const { signVerifyActions, signVerify: { - signAddress, signMessage, signSignature, verifyAddress, @@ -124,7 +123,7 @@ class SignVerify extends Component { >Clear signVerifyActions.sign(signAddress, signMessage)} + onClick={() => signVerifyActions.sign(account.addressPath, signMessage)} >Sign @@ -166,7 +165,7 @@ class SignVerify extends Component {