mirror of https://github.com/trezor/trezor-wallet
parent
1ebb893487
commit
b89a825077
@ -1,25 +1,48 @@
|
||||
/* @flow */
|
||||
import TrezorConnect from 'trezor-connect';
|
||||
|
||||
import type {
|
||||
GetState,
|
||||
Dispatch,
|
||||
} from 'flowtype';
|
||||
import type { GetState, Dispatch } from 'flowtype';
|
||||
import * as NOTIFICATION from 'actions/constants/notification';
|
||||
import * as SIGN_VERIFY from './constants/signVerify';
|
||||
|
||||
export const sign = (path: Array<number>, message: string, hex: boolean = false): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
const selected = getState().wallet.selectedDevice;
|
||||
const devicePath = selected.path;
|
||||
|
||||
const device = {
|
||||
path: devicePath,
|
||||
instance: selected.instance,
|
||||
state: selected.state,
|
||||
};
|
||||
|
||||
const response = await TrezorConnect
|
||||
.ethereumSignMessage({
|
||||
device, path, hex, message, useEmptyPassphrase: selected.useEmptyPassphrase,
|
||||
});
|
||||
const response = await TrezorConnect.ethereumSignMessage({
|
||||
device,
|
||||
path,
|
||||
hex,
|
||||
message,
|
||||
useEmptyPassphrase: selected.useEmptyPassphrase,
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
if (response && response.success) {
|
||||
dispatch({
|
||||
type: SIGN_VERIFY.SIGN_SUCCESS,
|
||||
signature: response.payload.signature,
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: NOTIFICATION.ADD,
|
||||
payload: {
|
||||
type: 'error',
|
||||
title: 'Signing error',
|
||||
message: response.payload.error,
|
||||
cancelable: true,
|
||||
actions: [
|
||||
{
|
||||
label: 'Try again',
|
||||
callback: () => {
|
||||
dispatch(() => {});
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
/* @flow */
|
||||
|
||||
export const SIGN: 'send__init' = 'send__init';
|
||||
export const VERYFI: 'send__change' = 'send__change';
|
||||
export const SIGN_SUCCESS: 'sign__verify__sign__success' = 'sign__verify__sign__success';
|
||||
export const VERIFY_SUCCESS: 'sign__verify__verify__success' = 'sign__verify__verify__success';
|
Loading…
Reference in new issue