1
0
mirror of https://github.com/trezor/trezor-wallet synced 2025-01-24 06:51:23 +00:00

fixed conflicts after merge

This commit is contained in:
Szymon Lesisz 2018-09-12 16:59:31 +02:00
parent a6ac8239f0
commit 6354332e40
5 changed files with 37 additions and 141 deletions

View File

@ -57,11 +57,8 @@ export const setNonce = (address: string, network: string, deviceState: string,
deviceState, deviceState,
nonce, nonce,
}); });
<<<<<<< HEAD
=======
export const update = (account: Account): Action => ({ export const update = (account: Account): Action => ({
type: ACCOUNT.UPDATE, type: ACCOUNT.UPDATE,
payload: account payload: account
}); });
>>>>>>> web3 actions splitted to blockchain actions

View File

@ -150,6 +150,12 @@ const begin = (device: TrezorDevice, network: string): AsyncAction => async (dis
return; return;
} }
// check for interruption
const discoveryProcess: ?Discovery = getState().discovery.find(d => d.deviceState === device.state && d.network === network);
if (discoveryProcess && discoveryProcess.interrupted) return;
const basePath: Array<number> = response.payload.path;
// send data to reducer // send data to reducer
dispatch({ dispatch({
type: DISCOVERY.START, type: DISCOVERY.START,
@ -262,135 +268,6 @@ const finish = (device: TrezorDevice, discoveryProcess: Discovery): AsyncAction
} }
export const start = (device: TrezorDevice, network: string, ignoreCompleted?: boolean): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
const selected = getState().wallet.selectedDevice;
if (!selected) {
// TODO: throw error
console.error('Start discovery: no selected device', device);
return;
} if (selected.path !== device.path) {
console.error('Start discovery: requested device is not selected', device, selected);
return;
} if (!selected.state) {
console.warn("Start discovery: Selected device wasn't authenticated yet...");
return;
} if (selected.connected && !selected.available) {
console.warn('Start discovery: Selected device is unavailable...');
return;
}
const web3 = getState().web3.find(w3 => w3.network === network);
if (!web3) {
console.error('Start discovery: Web3 does not exist', network);
return;
}
if (!web3.web3.currentProvider.isConnected()) {
console.error('Start discovery: Web3 is not connected', network);
dispatch({
type: DISCOVERY.WAITING_FOR_BACKEND,
device,
network,
});
return;
}
const { discovery }: { discovery: State } = getState();
const discoveryProcess: ?Discovery = discovery.find(d => d.deviceState === device.state && d.network === network);
if (!selected.connected && (!discoveryProcess || !discoveryProcess.completed)) {
dispatch({
type: DISCOVERY.WAITING_FOR_DEVICE,
device,
network,
});
return;
}
if (!discoveryProcess) {
dispatch(begin(device, network));
} else if (discoveryProcess.completed && !ignoreCompleted) {
dispatch({
type: DISCOVERY.COMPLETE,
device,
network,
});
} else if (discoveryProcess.interrupted || discoveryProcess.waitingForDevice) {
// discovery cycle was interrupted
// start from beginning
dispatch(begin(device, network));
} else {
dispatch(discoverAccount(device, discoveryProcess));
}
};
begin = (device: TrezorDevice, network: string): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
const { config } = getState().localStorage;
const coinToDiscover = config.coins.find(c => c.network === network);
if (!coinToDiscover) return;
dispatch({
type: DISCOVERY.WAITING_FOR_DEVICE,
device,
network,
});
// get xpub from TREZOR
const response = await TrezorConnect.getPublicKey({
device: {
path: device.path,
instance: device.instance,
state: device.state,
},
path: coinToDiscover.bip44,
keepSession: true, // acquire and hold session
useEmptyPassphrase: !device.instance,
});
// handle TREZOR response error
if (!response.success) {
// TODO: check message
console.warn('DISCOVERY ERROR', response);
dispatch({
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Discovery error',
message: response.payload.error,
cancelable: true,
actions: [
{
label: 'Try again',
callback: () => {
dispatch(start(device, network));
},
},
],
},
});
return;
}
// check for interruption
const discoveryProcess: ?Discovery = getState().discovery.find(d => d.deviceState === device.state && d.network === network);
if (discoveryProcess && discoveryProcess.interrupted) return;
const basePath: Array<number> = response.payload.path;
// send data to reducer
dispatch({
type: DISCOVERY.START,
network: coinToDiscover.network,
device,
publicKey: response.payload.publicKey,
chainCode: response.payload.chainCode,
basePath,
});
dispatch(start(device, network));
};
export const restore = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { export const restore = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
const selected = getState().wallet.selectedDevice; const selected = getState().wallet.selectedDevice;

View File

@ -12,6 +12,7 @@ import * as SEND from 'actions/constants/send';
import { initialState } from 'reducers/SendFormReducer'; import { initialState } from 'reducers/SendFormReducer';
import { findToken } from 'reducers/TokensReducer'; import { findToken } from 'reducers/TokensReducer';
import { findDevice, getPendingAmount, getPendingNonce } from 'reducers/utils'; import { findDevice, getPendingAmount, getPendingNonce } from 'reducers/utils';
import * as stateUtils from 'reducers/utils';
import type { import type {
Dispatch, Dispatch,

View File

@ -6,13 +6,14 @@ import thunk from 'redux-thunk';
// import createHistory from 'history/createBrowserHistory'; // import createHistory from 'history/createBrowserHistory';
// import { useRouterHistory } from 'react-router'; // import { useRouterHistory } from 'react-router';
import createHistory from 'history/createHashHistory'; import createHistory from 'history/createHashHistory';
import { createLogger } from 'redux-logger';
import reducers from 'reducers'; import reducers from 'reducers';
import services from 'services'; import services from 'services';
import Raven from 'raven-js'; import Raven from 'raven-js';
import RavenMiddleware from 'redux-raven-middleware'; import RavenMiddleware from 'redux-raven-middleware';
// import type { Action, GetState, Store } from 'flowtype'; import type { Action, GetState, Store } from 'flowtype';
export const history: History = createHistory({ queryKey: false }); export const history: History = createHistory({ queryKey: false });
@ -30,12 +31,12 @@ const middleware = [
let composedEnhancers: any; let composedEnhancers: any;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// const excludeLogger = (getState: GetState, action: Action): boolean => { const excludeLogger = (getState: GetState, action: Action): boolean => {
// //'@@router/LOCATION_CHANGE' //'@@router/LOCATION_CHANGE'
// const excluded: Array<string> = ['LOG_TO_EXCLUDE', 'log__add']; const excluded: Array<string> = ['LOG_TO_EXCLUDE', 'log__add'];
// const pass: Array<string> = excluded.filter(act => action.type === act); const pass: Array<string> = excluded.filter(act => action.type === act);
// return pass.length === 0; return pass.length === 0;
// }; };
const logger = createLogger({ const logger = createLogger({
level: 'info', level: 'info',

View File

@ -2560,6 +2560,10 @@ commander@^2.11.0:
version "2.12.1" version "2.12.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.1.tgz#468635c4168d06145b9323356d1da84d14ac4a7a" resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.1.tgz#468635c4168d06145b9323356d1da84d14ac4a7a"
commander@^2.13.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970"
commander@^2.8.1: commander@^2.8.1:
version "2.17.1" version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
@ -2732,7 +2736,16 @@ cors@^2.8.1:
object-assign "^4" object-assign "^4"
vary "^1" vary "^1"
cosmiconfig@^5.0.0, cosmiconfig@^5.0.5: cosmiconfig@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-3.1.0.tgz#640a94bf9847f321800403cd273af60665c73397"
dependencies:
is-directory "^0.3.1"
js-yaml "^3.9.0"
parse-json "^3.0.0"
require-from-string "^2.0.1"
cosmiconfig@^5.0.5:
version "5.0.6" version "5.0.6"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.6.tgz#dca6cf680a0bd03589aff684700858c81abeeb39" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.6.tgz#dca6cf680a0bd03589aff684700858c81abeeb39"
dependencies: dependencies:
@ -6893,7 +6906,7 @@ mkdirp-promise@^5.0.1:
dependencies: dependencies:
mkdirp "*" mkdirp "*"
mkdirp@*, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: mkdirp@*, mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
version "0.5.1" version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies: dependencies:
@ -11223,6 +11236,13 @@ ws@^3.0.0:
safe-buffer "~5.1.0" safe-buffer "~5.1.0"
ultron "~1.1.0" ultron "~1.1.0"
ws@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-4.1.0.tgz#a979b5d7d4da68bf54efe0408967c324869a7289"
dependencies:
async-limiter "~1.0.0"
safe-buffer "~5.1.0"
ws@^5.2.0: ws@^5.2.0:
version "5.2.2" version "5.2.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f" resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f"