mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-29 02:18:06 +00:00
Simplify actions with modals
This commit is contained in:
parent
f738d0be9c
commit
8ed59317c7
@ -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,
|
||||
|
@ -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';
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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 <ConfirmSignTx device={modal.device} sendForm={props.sendForm} />;
|
||||
|
||||
case 'ButtonRequest_ProtectCall':
|
||||
return <ConfirmAction />;
|
||||
|
||||
case 'ButtonRequest_Other':
|
||||
return <ConfirmAction />;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -14,8 +14,6 @@ export type StateProps = {
|
||||
wallet: $ElementType<State, 'wallet'>,
|
||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||
signature: string,
|
||||
isSignProgress: boolean,
|
||||
isVerifyProgress: boolean
|
||||
}
|
||||
|
||||
export type DispatchProps = {
|
||||
@ -28,8 +26,6 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
||||
wallet: state.wallet,
|
||||
selectedAccount: state.selectedAccount,
|
||||
signature: state.signVerifyReducer.signature,
|
||||
isSignProgress: state.signVerifyReducer.isSignProgress,
|
||||
isVerifyProgress: state.signVerifyReducer.isVerifyProgress,
|
||||
});
|
||||
|
||||
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||
|
@ -69,15 +69,6 @@ class SignVerify extends Component<Props, State> {
|
||||
};
|
||||
}
|
||||
|
||||
getAddress() {
|
||||
let result = null;
|
||||
const { selectedAccount } = this.props;
|
||||
if (selectedAccount.account && selectedAccount.account.address) {
|
||||
result = selectedAccount.account.address;
|
||||
}
|
||||
return result || 'loading...';
|
||||
}
|
||||
|
||||
handleInputChange = (event: SyntheticInputEvent<Text>) => {
|
||||
this.setState({ [event.target.name]: event.target.value });
|
||||
}
|
||||
@ -120,7 +111,7 @@ class SignVerify extends Component<Props, State> {
|
||||
<Label>Address</Label>
|
||||
<Input
|
||||
name="signAddress"
|
||||
value={this.getAddress()}
|
||||
value={account.address}
|
||||
height={50}
|
||||
type="text"
|
||||
isSmallText
|
||||
@ -156,7 +147,7 @@ class SignVerify extends Component<Props, State> {
|
||||
>Clear
|
||||
</Button>
|
||||
<StyledButton
|
||||
onClick={() => signVerifyActions.sign(this.props.selectedAccount.account.addressPath, this.state.signMessage)}
|
||||
onClick={() => signVerifyActions.sign(account.addressPath, this.state.signMessage)}
|
||||
>Sign
|
||||
</StyledButton>
|
||||
</RowButtons>
|
||||
|
Loading…
Reference in New Issue
Block a user