2017-12-13 11:01:37 +00:00
|
|
|
/* @flow */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import TrezorConnect, { UI, UI_EVENT } from 'trezor-connect';
|
2018-04-11 10:13:38 +00:00
|
|
|
import * as MODAL from './constants/modal';
|
2018-02-20 09:30:36 +00:00
|
|
|
import * as CONNECT from './constants/TrezorConnect';
|
2017-12-13 11:01:37 +00:00
|
|
|
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export function onPinSubmit(value: string): any {
|
2018-03-27 15:12:01 +00:00
|
|
|
TrezorConnect.uiResponse({ type: UI.RECEIVE_PIN, payload: value });
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-04-11 10:06:46 +00:00
|
|
|
type: MODAL.CLOSE
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export function onPassphraseSubmit(passphrase: string): any {
|
|
|
|
return async (dispatch, getState): Promise<void> => {
|
2018-03-27 15:12:01 +00:00
|
|
|
const resp = await TrezorConnect.uiResponse({
|
2018-02-20 09:30:36 +00:00
|
|
|
type: UI.RECEIVE_PASSPHRASE,
|
2018-03-27 15:12:01 +00:00
|
|
|
payload: {
|
2018-02-20 09:30:36 +00:00
|
|
|
value: passphrase,
|
|
|
|
save: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dispatch({
|
2018-04-11 10:06:46 +00:00
|
|
|
type: MODAL.CLOSE
|
2018-02-20 09:30:36 +00:00
|
|
|
});
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const askForRemember = (device: any) => {
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-02-20 09:30:36 +00:00
|
|
|
type: MODAL.REMEMBER,
|
|
|
|
device
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const onRememberDevice = (device: any) => {
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-02-20 09:30:36 +00:00
|
|
|
type: CONNECT.REMEMBER,
|
|
|
|
device
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const onForgetDevice = (device: any) => {
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-02-20 09:30:36 +00:00
|
|
|
type: CONNECT.FORGET,
|
|
|
|
device,
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const onForgetSingleDevice = (device: any) => {
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-02-20 09:30:36 +00:00
|
|
|
type: CONNECT.FORGET_SINGLE,
|
|
|
|
device,
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const onCancel = () => {
|
2017-12-13 11:01:37 +00:00
|
|
|
return {
|
2018-04-11 10:06:46 +00:00
|
|
|
type: MODAL.CLOSE
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const onDuplicateDevice = (device: any): any => {
|
|
|
|
return (dispatch: any, getState: any): void => {
|
2017-12-13 11:01:37 +00:00
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
dispatch( onCancel() );
|
2017-12-13 11:01:37 +00:00
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
dispatch({
|
|
|
|
type: CONNECT.DUPLICATE,
|
|
|
|
device
|
|
|
|
});
|
2017-12-13 11:01:37 +00:00
|
|
|
}
|
|
|
|
}
|