From fce5f9d36fb9990f8fa04d1bd6ece33ae3251efc Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 11 May 2018 21:01:43 +0200 Subject: [PATCH] code cleaning --- src/js/actions/DiscoveryActions.js | 14 +-- src/js/flowtype/redux_v3.x.x00.js | 138 ----------------------------- src/js/index.js | 7 +- src/js/store/index.js | 7 +- 4 files changed, 8 insertions(+), 158 deletions(-) delete mode 100644 src/js/flowtype/redux_v3.x.x00.js diff --git a/src/js/actions/DiscoveryActions.js b/src/js/actions/DiscoveryActions.js index 7812a006..b80750ef 100644 --- a/src/js/actions/DiscoveryActions.js +++ b/src/js/actions/DiscoveryActions.js @@ -288,18 +288,6 @@ const discoverAddress = (device: TrezorDevice, discoveryProcess: Discovery): Asy AccountsActions.setBalance(ethAddress, network, device.state || 'undefined', web3instance.web3.fromWei(balance.toString(), 'ether')) ); - const userTokens = []; - // const userTokens = [ - // { symbol: 'T01', address: '0x58cda554935e4a1f2acbe15f8757400af275e084' }, - // { symbol: 'Lahod', address: '0x3360d0ee34a49d9ac34dce88b000a2903f2806ee' }, - // ]; - - for (let i = 0; i < userTokens.length; i++) { - const tokenBalance: string = await getTokenBalanceAsync(web3instance.erc20, userTokens[i]); - if (discoveryProcess.interrupted) return; - dispatch( setTokenBalance(userTokens[i].address, ethAddress, tokenBalance) ) - } - const nonce: number = await getNonceAsync(web3instance.web3, ethAddress); if (discoveryProcess.interrupted) return; dispatch(AccountsActions.setNonce(ethAddress, network, device.state || 'undefined', nonce)); @@ -342,7 +330,7 @@ export const restore = (): ThunkAction => { } } - +// TODO: rename method to something intuitive // there is no discovery process but it should be // this is possible race condition when "network" was changed in url but device was not authenticated yet // try to start discovery after CONNECT.AUTH_DEVICE action diff --git a/src/js/flowtype/redux_v3.x.x00.js b/src/js/flowtype/redux_v3.x.x00.js deleted file mode 100644 index 7d18527b..00000000 --- a/src/js/flowtype/redux_v3.x.x00.js +++ /dev/null @@ -1,138 +0,0 @@ -// flow-typed signature: ba132c96664f1a05288f3eb2272a3c35 -// flow-typed version: c4bbd91cfc/redux_v3.x.x/flow_>=v0.33.x -// from : https://github.com/hmeerlo/redux-thunk-flow/blob/master/flow-typed/npm/redux_v3.x.x.js -// declare module 'redux' { - -// /* - -// S = State -// A = Action - -// */ - -// /* NEW: We create a few extra action and dispatch types */ -// declare export type ThunkAction = (dispatch: Dispatch, getState: () => S) => R; -// declare type PromiseAction = { type: string, payload: Promise }; -// declare type ThunkDispatch = (action: ThunkAction) => R; -// declare type PromiseDispatch = (action: PromiseAction) => Promise; -// declare type PlainDispatch}> = (action: A) => A; -// /* NEW: Dispatch is now a combination of these different dispatch types */ -// declare export type Dispatch = PlainDispatch & ThunkDispatch & PromiseDispatch; - -// declare export type MiddlewareAPI = { -// dispatch: Dispatch; -// getState(): S; -// }; - -// declare export type Store = { -// // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages) -// dispatch: Dispatch; -// getState(): S; -// subscribe(listener: () => void): () => void; -// replaceReducer(nextReducer: Reducer): void -// }; - -// declare type Reducer = (state: S, action: A) => S; - -// declare export type Middleware = -// (api: MiddlewareAPI) => -// (next: Dispatch) => Dispatch; - -// declare type StoreCreator = { -// (reducer: Reducer, enhancer?: StoreEnhancer): Store; -// (reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; -// }; - -// declare type StoreEnhancer = (next: StoreCreator) => StoreCreator; - -// declare function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; -// declare function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; - -// declare function applyMiddleware(...middlewares: Array>): StoreEnhancer; - -// declare type ActionCreator = (...args: Array) => A; -// declare type ActionCreators = { [key: K]: ActionCreator }; - -// declare function bindActionCreators>(actionCreator: C, dispatch: Dispatch): C; -// declare function bindActionCreators>(actionCreators: C, dispatch: Dispatch): C; - -// declare function combineReducers(reducers: O): Reducer<$ObjMap(r: Reducer) => S>, A>; - -// declare function compose(...fns: Array>): Function; - -// } - - - -// flow-typed signature: cca4916b0213065533df8335c3285a4a -// flow-typed version: cab04034e7/redux_v3.x.x/flow_>=v0.55.x - -declare module 'redux' { - - /* - - S = State - A = Action - D = Dispatch - - */ - - declare export type DispatchAPI = (action: A) => A; - // declare export type Dispatch }> = DispatchAPI; - - declare export type ThunkAction = (dispatch: Dispatch, getState: () => S) => Promise | void; - declare export type ThunkDispatch = (action: ThunkAction) => void; - - declare export type PlainDispatch}> = DispatchAPI; - /* NEW: Dispatch is now a combination of these different dispatch types */ - declare export type Dispatch = PlainDispatch & ThunkDispatch; - - // declare export type ThunkAction = (dispatch: D, getState: () => S) => Promise | void; - // declare type ThunkDispatch = (action: ThunkAction>) => void; - - declare export type MiddlewareAPI = { - dispatch: Dispatch; - getState(): S; - }; - - declare export type Store> = { - // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages) - dispatch: D; - getState(): S; - subscribe(listener: () => void): () => void; - replaceReducer(nextReducer: Reducer): void - }; - - declare export type Reducer = (state: S | void, action: A) => S; - - declare export type CombinedReducer = (state: $Shape & {} | void, action: A) => S; - - declare export type Middleware = - (api: MiddlewareAPI) => - (next: PlainDispatch) => PlainDispatch; - - declare export type StoreCreator> = { - (reducer: Reducer, enhancer?: StoreEnhancer): Store; - (reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; - }; - - declare export type StoreEnhancer> = (next: StoreCreator) => StoreCreator; - - declare export function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; - declare export function createStore(reducer: Reducer, preloadedState?: S, enhancer?: StoreEnhancer): Store; - - declare export function applyMiddleware(...middlewares: Array>): StoreEnhancer; - - declare export type ActionCreator = (...args: Array) => A; - declare export type ActionCreators = { [key: K]: ActionCreator }; - - declare export function bindActionCreators, D: DispatchAPI>(actionCreator: C, dispatch: D): C; - declare export function bindActionCreators, D: DispatchAPI>(actionCreators: C, dispatch: D): C; - // declare export function bindActionCreators, D: Dispatch>(actionCreator: C, dispatch: D): C; - // declare export function bindActionCreators, D: Dispatch>(actionCreators: C, dispatch: D): C; - - declare export function combineReducers(reducers: O): CombinedReducer<$ObjMap(r: Reducer) => S>, A>; - - declare export var compose: $Compose; - } - \ No newline at end of file diff --git a/src/js/index.js b/src/js/index.js index 4d0aae6e..59080c7a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -6,13 +6,8 @@ import { render } from 'react-dom'; import store from './store'; import router from './router'; import { onBeforeUnload } from './actions/WalletActions'; - -import Raven from 'raven-js'; - import styles from '../styles/index.less'; -Raven.config('https://497392c3ff6e46dc9e54eef123979378@sentry.io/294339').install(); - const root: ?HTMLElement = document.getElementById('root'); if (root) { render(router, root); @@ -22,5 +17,5 @@ window.onbeforeunload = () => { store.dispatch( onBeforeUnload() ); } -// workaround +// workaround for web3 // yarn add web3@^0.19.0 \ No newline at end of file diff --git a/src/js/store/index.js b/src/js/store/index.js index 35740084..42ad5585 100644 --- a/src/js/store/index.js +++ b/src/js/store/index.js @@ -10,17 +10,22 @@ import createHistory from 'history/createHashHistory'; import { createLogger } from 'redux-logger'; import reducers from '../reducers'; import services from '../services'; + +import Raven from 'raven-js'; import RavenMiddleware from 'redux-raven-middleware'; import type { Action, GetState, Store } from '../flowtype'; export const history: History = createHistory( { queryKey: false } ); +const RAVEN_KEY: string = 'https://497392c3ff6e46dc9e54eef123979378@sentry.io/294339' +Raven.config(RAVEN_KEY).install(); + const initialState: any = {}; const enhancers = []; const middleware = [ thunk, - RavenMiddleware('https://497392c3ff6e46dc9e54eef123979378@sentry.io/294339'), + RavenMiddleware(RAVEN_KEY), routerMiddleware(history) ];