mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-01 04:38:15 +00:00
Fix flow
This commit is contained in:
parent
43906f505c
commit
68d3bbb738
@ -8,9 +8,18 @@ import * as SIGN_VERIFY from './constants/signVerify';
|
|||||||
|
|
||||||
export type SignVerifyAction = {
|
export type SignVerifyAction = {
|
||||||
type: typeof SIGN_VERIFY.SIGN_SUCCESS,
|
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 = (
|
const sign = (
|
||||||
@ -36,7 +45,7 @@ const sign = (
|
|||||||
if (response && response.success) {
|
if (response && response.success) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SIGN_VERIFY.SIGN_SUCCESS,
|
type: SIGN_VERIFY.SIGN_SUCCESS,
|
||||||
signature: response.payload.signature,
|
signSignature: response.payload.signature,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch({
|
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({
|
dispatch({
|
||||||
type: SIGN_VERIFY.INPUT_CHANGE,
|
type: SIGN_VERIFY.INPUT_CHANGE,
|
||||||
name,
|
name,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import type { Action } from 'flowtype';
|
import type { Action } from 'flowtype';
|
||||||
|
|
||||||
import * as ACTION from 'actions/constants/signVerify';
|
import * as ACTION from 'actions/constants/signVerify';
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
@ -9,7 +10,7 @@ export type State = {
|
|||||||
verifyAddress: string,
|
verifyAddress: string,
|
||||||
verifyMessage: string,
|
verifyMessage: string,
|
||||||
verifySignature: string,
|
verifySignature: string,
|
||||||
touched: Array<String>
|
touched: Array<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
@ -26,8 +27,8 @@ export default (state: State = initialState, action: Action): State => {
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ACTION.SIGN_SUCCESS:
|
case ACTION.SIGN_SUCCESS:
|
||||||
return {
|
return {
|
||||||
...initialState,
|
...state,
|
||||||
signature: action.signature,
|
signSignature: action.signSignature,
|
||||||
};
|
};
|
||||||
|
|
||||||
case ACTION.TOUCH: {
|
case ACTION.TOUCH: {
|
||||||
@ -41,8 +42,8 @@ export default (state: State = initialState, action: Action): State => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case ACTION.INPUT_CHANGE: {
|
case ACTION.INPUT_CHANGE: {
|
||||||
const changes = { [action.name]: action.value };
|
const change = { [action.name]: action.value };
|
||||||
return { ...state, ...changes };
|
return { ...state, ...change };
|
||||||
}
|
}
|
||||||
|
|
||||||
case ACTION.CLEAR_SIGN:
|
case ACTION.CLEAR_SIGN:
|
||||||
|
@ -13,11 +13,22 @@ type OwnProps = {}
|
|||||||
export type StateProps = {
|
export type StateProps = {
|
||||||
wallet: $ElementType<State, 'wallet'>,
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
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 = {
|
export type DispatchProps = {
|
||||||
signVerifyActions: typeof SignVerifyActions,
|
signVerifyActions: typeof SignVerifyActions,
|
||||||
|
signVerify: SignVerify
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
|
@ -69,7 +69,6 @@ class SignVerify extends Component<Props, State> {
|
|||||||
const {
|
const {
|
||||||
signVerifyActions,
|
signVerifyActions,
|
||||||
signVerify: {
|
signVerify: {
|
||||||
signAddress,
|
|
||||||
signMessage,
|
signMessage,
|
||||||
signSignature,
|
signSignature,
|
||||||
verifyAddress,
|
verifyAddress,
|
||||||
@ -124,7 +123,7 @@ class SignVerify extends Component<Props, State> {
|
|||||||
>Clear
|
>Clear
|
||||||
</Button>
|
</Button>
|
||||||
<StyledButton
|
<StyledButton
|
||||||
onClick={() => signVerifyActions.sign(signAddress, signMessage)}
|
onClick={() => signVerifyActions.sign(account.addressPath, signMessage)}
|
||||||
>Sign
|
>Sign
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</RowButtons>
|
</RowButtons>
|
||||||
@ -166,7 +165,7 @@ class SignVerify extends Component<Props, State> {
|
|||||||
</Row>
|
</Row>
|
||||||
<RowButtons>
|
<RowButtons>
|
||||||
<Button
|
<Button
|
||||||
onClick={signVerifyActions.clearSign}
|
onClick={signVerifyActions.clearVerify}
|
||||||
isWhite
|
isWhite
|
||||||
>Clear
|
>Clear
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user