1
0
mirror of https://github.com/trezor/trezor-wallet synced 2025-01-23 06:21:06 +00:00
trezor-wallet/src/js/actions/ModalActions.js

76 lines
1.5 KiB
JavaScript
Raw Normal View History

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 {
TrezorConnect.uiResponse({ type: UI.RECEIVE_PIN, payload: value });
2017-12-13 11:01:37 +00:00
return {
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> => {
const resp = await TrezorConnect.uiResponse({
2018-02-20 09:30:36 +00:00
type: UI.RECEIVE_PASSPHRASE,
payload: {
2018-02-20 09:30:36 +00:00
value: passphrase,
save: true
}
});
dispatch({
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 {
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
}
}