From 8ed59317c7e942a75e87417116227272016472dd Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Sun, 18 Nov 2018 17:35:47 +0100 Subject: [PATCH] Simplify actions with modals --- src/actions/SignVerifyActions.js | 16 +--------------- src/actions/constants/signVerify.js | 2 -- src/components/inputs/Input/index.js | 2 +- src/components/modals/index.js | 5 ++++- src/reducers/SignVerifyReducer.js | 18 +----------------- .../views/Account/SignVerify/Container.js | 4 ---- .../Wallet/views/Account/SignVerify/index.js | 13 ++----------- 7 files changed, 9 insertions(+), 51 deletions(-) diff --git a/src/actions/SignVerifyActions.js b/src/actions/SignVerifyActions.js index 57228911..2de496f6 100644 --- a/src/actions/SignVerifyActions.js +++ b/src/actions/SignVerifyActions.js @@ -7,16 +7,10 @@ import * as NOTIFICATION from 'actions/constants/notification'; import * as SIGN_VERIFY from './constants/signVerify'; export type SignVerifyAction = { - type: typeof SIGN_VERIFY.SIGN_PROGRESS, - isSignProgress: boolean -} | { type: typeof SIGN_VERIFY.SIGN_SUCCESS, signature: string } | { - type: typeof SIGN_VERIFY.VERIFY_PROGRESS, - isVerifyProgress: boolean -} | { - type: typeof SIGN_VERIFY.CLEAR + type: typeof SIGN_VERIFY.CLEAR, } export const sign = ( @@ -27,8 +21,6 @@ export const sign = ( const selected = getState().wallet.selectedDevice; if (!selected) return; - dispatch({ type: SIGN_VERIFY.SIGN_PROGRESS, isSignProgress: true }); - const response = await TrezorConnect.ethereumSignMessage({ device: { path: selected.path, @@ -41,8 +33,6 @@ export const sign = ( useEmptyPassphrase: selected.useEmptyPassphrase, }); - dispatch({ type: SIGN_VERIFY.SIGN_PROGRESS, isSignProgress: false }); - if (response && response.success) { dispatch({ type: SIGN_VERIFY.SIGN_SUCCESS, @@ -77,8 +67,6 @@ export const verify = ( const selected = getState().wallet.selectedDevice; if (!selected) return; - dispatch({ type: SIGN_VERIFY.VERIFY_PROGRESS, isVerifyProgress: true }); - const response = await TrezorConnect.ethereumVerifyMessage({ device: { path: selected.path, @@ -92,8 +80,6 @@ export const verify = ( useEmptyPassphrase: selected.useEmptyPassphrase, }); - dispatch({ type: SIGN_VERIFY.VERIFY_PROGRESS, isVerifyProgress: false }); - if (response && response.success) { dispatch({ type: NOTIFICATION.ADD, diff --git a/src/actions/constants/signVerify.js b/src/actions/constants/signVerify.js index 4bd14209..96b5d7ea 100644 --- a/src/actions/constants/signVerify.js +++ b/src/actions/constants/signVerify.js @@ -1,5 +1,3 @@ /* @flow */ export const SIGN_SUCCESS: 'sign__verify__sign__success' = 'sign__verify__sign__success'; -export const SIGN_PROGRESS: 'sign__verify__sign_progress' = 'sign__verify__sign_progress'; -export const VERIFY_PROGRESS: 'sign__verify__verify_progress' = 'sign__verify__verify_progress'; export const CLEAR: 'sign__verify__sign__clear' = 'sign__verify__sign__clear'; \ No newline at end of file diff --git a/src/components/inputs/Input/index.js b/src/components/inputs/Input/index.js index debb016b..f471b722 100644 --- a/src/components/inputs/Input/index.js +++ b/src/components/inputs/Input/index.js @@ -228,7 +228,7 @@ Input.propTypes = { sideAddons: PropTypes.arrayOf(PropTypes.node), isDisabled: PropTypes.bool, name: PropTypes.string, - isSmallText: PropTypes.string, + isSmallText: PropTypes.bool, isPartiallyHidden: PropTypes.bool, }; diff --git a/src/components/modals/index.js b/src/components/modals/index.js index 018d10d4..1af09040 100644 --- a/src/components/modals/index.js +++ b/src/components/modals/index.js @@ -65,7 +65,7 @@ const ModalWindow = styled.div` const getDeviceContextModal = (props: Props) => { const { modal, modalActions } = props; if (modal.context !== MODAL.CONTEXT_DEVICE) return null; - + console.log('modal.windowType', modal.windowType); switch (modal.windowType) { case UI.REQUEST_PIN: return ( @@ -91,6 +91,9 @@ const getDeviceContextModal = (props: Props) => { case 'ButtonRequest_SignTx': return ; + case 'ButtonRequest_ProtectCall': + return ; + case 'ButtonRequest_Other': return ; diff --git a/src/reducers/SignVerifyReducer.js b/src/reducers/SignVerifyReducer.js index 863cbda9..4ad04eef 100644 --- a/src/reducers/SignVerifyReducer.js +++ b/src/reducers/SignVerifyReducer.js @@ -3,37 +3,21 @@ import type { Action } from 'flowtype'; import * as SIGN_VERIFY from '../actions/constants/signVerify'; export type State = { - signature: string; - isSignProgress: boolean; - isVerifyProgress: boolean; + signature: string } export const initialState: State = { signature: '', - isSignProgress: false, - isVerifyProgress: false, }; export default (state: State = initialState, action: Action): State => { switch (action.type) { - case SIGN_VERIFY.SIGN_PROGRESS: - return { - ...state, - isSignProgress: action.isSignProgress, - }; - case SIGN_VERIFY.SIGN_SUCCESS: return { ...state, signature: action.signature, }; - case SIGN_VERIFY.VERIFY_PROGRESS: - return { - ...state, - isVerifyProgress: action.isVerifyProgress, - }; - case SIGN_VERIFY.CLEAR: return { ...initialState, diff --git a/src/views/Wallet/views/Account/SignVerify/Container.js b/src/views/Wallet/views/Account/SignVerify/Container.js index b023c488..4ead2cc2 100644 --- a/src/views/Wallet/views/Account/SignVerify/Container.js +++ b/src/views/Wallet/views/Account/SignVerify/Container.js @@ -14,8 +14,6 @@ export type StateProps = { wallet: $ElementType, selectedAccount: $ElementType, signature: string, - isSignProgress: boolean, - isVerifyProgress: boolean } export type DispatchProps = { @@ -28,8 +26,6 @@ const mapStateToProps: MapStateToProps = (state: St wallet: state.wallet, selectedAccount: state.selectedAccount, signature: state.signVerifyReducer.signature, - isSignProgress: state.signVerifyReducer.isSignProgress, - isVerifyProgress: state.signVerifyReducer.isVerifyProgress, }); const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ diff --git a/src/views/Wallet/views/Account/SignVerify/index.js b/src/views/Wallet/views/Account/SignVerify/index.js index b57c65f1..7d356505 100644 --- a/src/views/Wallet/views/Account/SignVerify/index.js +++ b/src/views/Wallet/views/Account/SignVerify/index.js @@ -69,15 +69,6 @@ class SignVerify extends Component { }; } - getAddress() { - let result = null; - const { selectedAccount } = this.props; - if (selectedAccount.account && selectedAccount.account.address) { - result = selectedAccount.account.address; - } - return result || 'loading...'; - } - handleInputChange = (event: SyntheticInputEvent) => { this.setState({ [event.target.name]: event.target.value }); } @@ -120,7 +111,7 @@ class SignVerify extends Component { { >Clear signVerifyActions.sign(this.props.selectedAccount.account.addressPath, this.state.signMessage)} + onClick={() => signVerifyActions.sign(account.addressPath, this.state.signMessage)} >Sign