mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-29 10:28:08 +00:00
Merge pull request #230 from trezor/fix/wallet-type-empty-passphrase
Fix/wallet type empty passphrase
This commit is contained in:
commit
cc18d18e4c
@ -25,7 +25,19 @@ export const onPinSubmit = (value: string): Action => {
|
||||
};
|
||||
};
|
||||
|
||||
export const onPassphraseSubmit = (passphrase: string): AsyncAction => async (dispatch: Dispatch): Promise<void> => {
|
||||
export const onPassphraseSubmit = (passphrase: string): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
const { modal } = getState();
|
||||
if (modal.context !== MODAL.CONTEXT_DEVICE) return;
|
||||
|
||||
if (passphrase === '') {
|
||||
// set standard wallet type if passphrase is blank
|
||||
dispatch({
|
||||
type: CONNECT.UPDATE_WALLET_TYPE,
|
||||
device: modal.device,
|
||||
hidden: false,
|
||||
});
|
||||
}
|
||||
|
||||
await TrezorConnect.uiResponse({
|
||||
type: UI.RECEIVE_PASSPHRASE,
|
||||
payload: {
|
||||
@ -106,15 +118,16 @@ export const onDeviceConnect = (device: Device): ThunkAction => (dispatch: Dispa
|
||||
}
|
||||
};
|
||||
|
||||
export const onWalletTypeRequest = (device: TrezorDevice, hidden: boolean, state: ?string): ThunkAction => (dispatch: Dispatch): void => {
|
||||
export const onWalletTypeRequest = (hidden: boolean): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||
const { modal } = getState();
|
||||
if (modal.context !== MODAL.CONTEXT_DEVICE) return;
|
||||
dispatch({
|
||||
type: MODAL.CLOSE,
|
||||
});
|
||||
dispatch({
|
||||
type: CONNECT.RECEIVE_WALLET_TYPE,
|
||||
device,
|
||||
device: modal.device,
|
||||
hidden,
|
||||
state,
|
||||
});
|
||||
};
|
||||
|
||||
@ -129,7 +142,6 @@ export const gotoExternalWallet = (id: string, url: string): ThunkAction => (dis
|
||||
export default {
|
||||
onPinSubmit,
|
||||
onPassphraseSubmit,
|
||||
// askForRemember,
|
||||
onRememberDevice,
|
||||
onForgetDevice,
|
||||
onForgetSingleDevice,
|
||||
|
@ -78,10 +78,9 @@ export type TrezorConnectAction = {
|
||||
type: typeof CONNECT.REQUEST_WALLET_TYPE,
|
||||
device: TrezorDevice
|
||||
} | {
|
||||
type: typeof CONNECT.RECEIVE_WALLET_TYPE,
|
||||
type: typeof CONNECT.RECEIVE_WALLET_TYPE | typeof CONNECT.UPDATE_WALLET_TYPE,
|
||||
device: TrezorDevice,
|
||||
hidden: boolean,
|
||||
state: ?string,
|
||||
};
|
||||
|
||||
declare var LOCAL: ?string;
|
||||
|
@ -30,3 +30,4 @@ export const STOP_ACQUIRING: 'connect__stop_acquiring' = 'connect__stop_acquirin
|
||||
|
||||
export const REQUEST_WALLET_TYPE: 'connect__request_wallet_type' = 'connect__request_wallet_type';
|
||||
export const RECEIVE_WALLET_TYPE: 'connect__receive_wallet_type' = 'connect__receive_wallet_type';
|
||||
export const UPDATE_WALLET_TYPE: 'connect__update_wallet_type' = 'connect__update_wallet_type';
|
@ -91,18 +91,14 @@ class WalletType extends PureComponent<Props> {
|
||||
keyboardHandler(event: KeyboardEvent): void {
|
||||
if (event.keyCode === 13) {
|
||||
event.preventDefault();
|
||||
this.changeType(false);
|
||||
this.props.onWalletTypeRequest(false);
|
||||
}
|
||||
}
|
||||
|
||||
keyboardHandler: (event: KeyboardEvent) => void;
|
||||
|
||||
changeType(hidden: boolean, state: ?string) {
|
||||
this.props.onWalletTypeRequest(this.props.device, hidden, state);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { device, onCancel } = this.props;
|
||||
const { device, onCancel, onWalletTypeRequest } = this.props;
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
@ -122,7 +118,7 @@ class WalletType extends PureComponent<Props> {
|
||||
Standard Wallet
|
||||
</Header>
|
||||
<P isSmaller>Continue to access your standard wallet.</P>
|
||||
<StyledButton onClick={() => this.changeType(false, device.state)}>Go to your standard wallet</StyledButton>
|
||||
<StyledButton onClick={() => onWalletTypeRequest(false)}>Go to your standard wallet</StyledButton>
|
||||
</Content>
|
||||
<Content>
|
||||
<Tooltip
|
||||
@ -146,7 +142,7 @@ class WalletType extends PureComponent<Props> {
|
||||
Hidden Wallet
|
||||
</Header>
|
||||
<P isSmaller>You will be asked to enter your passphrase to unlock your hidden wallet.</P>
|
||||
<StyledButton isWhite onClick={() => this.changeType(true, device.state)}>Go to your hidden wallet</StyledButton>
|
||||
<StyledButton isWhite onClick={() => onWalletTypeRequest(true)}>Go to your hidden wallet</StyledButton>
|
||||
</Content>
|
||||
</Wrapper>
|
||||
);
|
||||
|
@ -317,6 +317,7 @@ export default function devices(state: State = initialState, action: Action): St
|
||||
return onSelectedDevice(state, action.device);
|
||||
|
||||
case CONNECT.RECEIVE_WALLET_TYPE:
|
||||
case CONNECT.UPDATE_WALLET_TYPE:
|
||||
return onChangeWalletType(state, action.device, action.hidden);
|
||||
|
||||
default:
|
||||
|
@ -105,22 +105,22 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
||||
api.dispatch(SendFormActionActions.observe(prevState, action));
|
||||
}
|
||||
} else {
|
||||
switch (action.type) {
|
||||
case CONNECT.AUTH_DEVICE:
|
||||
// selected device did changed
|
||||
// try to restore discovery after device authentication
|
||||
api.dispatch(DiscoveryActions.restore());
|
||||
break;
|
||||
case CONNECT.RECEIVE_WALLET_TYPE:
|
||||
if (action.state) {
|
||||
api.dispatch(RouterActions.selectFirstAvailableDevice(true));
|
||||
}
|
||||
api.dispatch(TrezorConnectActions.authorizeDevice());
|
||||
break;
|
||||
default: break;
|
||||
// no changes in common values
|
||||
if (action.type === CONNECT.RECEIVE_WALLET_TYPE) {
|
||||
if (action.device.state) {
|
||||
// redirect to root view (Dashboard) if device was authenticated before
|
||||
api.dispatch(RouterActions.selectFirstAvailableDevice(true));
|
||||
}
|
||||
api.dispatch(TrezorConnectActions.authorizeDevice());
|
||||
}
|
||||
if (action.type === CONNECT.AUTH_DEVICE) {
|
||||
// selected device did changed
|
||||
// try to restore discovery after device authentication
|
||||
api.dispatch(DiscoveryActions.restore());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// even if "selectedDevice" didn't change because it was updated on DEVICE.CHANGED before DEVICE.CONNECT action
|
||||
// try to restore discovery
|
||||
if (action.type === DEVICE.CONNECT) {
|
||||
|
Loading…
Reference in New Issue
Block a user