mirror of https://github.com/trezor/trezor-wallet
parent
0f544f8578
commit
ca460859ac
@ -0,0 +1,25 @@
|
|||||||
|
/* @flow */
|
||||||
|
import TrezorConnect from 'trezor-connect';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
GetState,
|
||||||
|
Dispatch,
|
||||||
|
} from 'flowtype';
|
||||||
|
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
};
|
@ -0,0 +1,4 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
export const SIGN: 'send__init' = 'send__init';
|
||||||
|
export const VERYFI: 'send__change' = 'send__change';
|
@ -0,0 +1,25 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import type { Action } from 'flowtype';
|
||||||
|
import type { NetworkToken } from './LocalStorageReducer';
|
||||||
|
|
||||||
|
export type State = {
|
||||||
|
details: boolean;
|
||||||
|
selectedToken: ?NetworkToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SIGN = 'sign';
|
||||||
|
|
||||||
|
export const initialState: State = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (state: State = initialState, action: Action): State => {
|
||||||
|
switch (action.type) {
|
||||||
|
case SIGN.SUCCESS:
|
||||||
|
return initialState;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,35 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import * as SignVerifyActions from 'actions/SignVerifyActions';
|
||||||
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
|
import type { State, Dispatch } from 'flowtype';
|
||||||
|
import Component from './index';
|
||||||
|
|
||||||
|
type OwnProps = {}
|
||||||
|
|
||||||
|
export type StateProps = {
|
||||||
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
|
sendForm: $ElementType<State, 'sendForm'>,
|
||||||
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
fiat: $ElementType<State, 'fiat'>,
|
||||||
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Props = StateProps & DispatchProps;
|
||||||
|
|
||||||
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State): StateProps => ({
|
||||||
|
selectedAccount: state.selectedAccount,
|
||||||
|
sendForm: state.sendForm,
|
||||||
|
wallet: state.wallet,
|
||||||
|
fiat: state.fiat,
|
||||||
|
localStorage: state.localStorage,
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (dispatch: Dispatch): DispatchProps => ({
|
||||||
|
signVerifyActions: bindActionCreators(SignVerifyActions, dispatch),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(Component);
|
Loading…
Reference in new issue