From 99da86761756b63e908616783506bffed8a4095c Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 12 Sep 2018 16:27:45 +0200 Subject: [PATCH] fixed flow issues --- .flowconfig | 4 +++- src/actions/ModalActions.js | 16 ++++++++-------- src/components/modals/device/Duplicate/index.js | 2 +- src/index.js | 2 +- src/utils/promiseUtils.js | 2 +- .../components/AccountMenu/index.js | 3 +++ src/views/Wallet/index.js | 2 +- src/views/Wallet/views/AccountSend/index.js | 2 +- .../components/AccountBalance/index.js | 4 ++-- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.flowconfig b/.flowconfig index b28be239..9a632b96 100644 --- a/.flowconfig +++ b/.flowconfig @@ -7,8 +7,9 @@ .*/node_modules/redux/.* .*/node_modules/react-router/.* .*/node_modules/react-router-redux/.* +.*/node_modules/oboe/test/.* .*/_old/.* -.*/src/solidity/.* +.*/public/solidity/.* [libs] ./src/flowtype/npm/redux_v3.x.x.js @@ -41,4 +42,5 @@ module.name_mapper='^views' -> '/src/views' module.name_mapper='^data' -> '/src/data' module.name_mapper='^services' -> '/src/services' module.name_mapper='^support' -> '/src/support' +module.name_mapper='^public' -> '/public' module.system=haste diff --git a/src/actions/ModalActions.js b/src/actions/ModalActions.js index 1c0675af..cc55e4af 100644 --- a/src/actions/ModalActions.js +++ b/src/actions/ModalActions.js @@ -24,14 +24,14 @@ export const onPinSubmit = (value: string): Action => { }; }; -export const onPassphraseSubmit = (/* passphrase: string */): AsyncAction => async (dispatch: Dispatch): Promise => { - // const resp = await TrezorConnect.uiResponse({ - // type: UI.RECEIVE_PASSPHRASE, - // payload: { - // value: passphrase, - // save: true, - // }, - // }); +export const onPassphraseSubmit = (passphrase: string): AsyncAction => async (dispatch: Dispatch): Promise => { + const resp = await TrezorConnect.uiResponse({ + type: UI.RECEIVE_PASSPHRASE, + payload: { + value: passphrase, + save: true, + }, + }); dispatch({ type: MODAL.CLOSE, diff --git a/src/components/modals/device/Duplicate/index.js b/src/components/modals/device/Duplicate/index.js index 772867ce..9aeea355 100644 --- a/src/components/modals/device/Duplicate/index.js +++ b/src/components/modals/device/Duplicate/index.js @@ -12,7 +12,7 @@ import icons from 'config/icons'; import colors from 'config/colors'; import Link from 'components/Link'; -import { Props } from './index'; +import type { Props } from 'components/modals/index'; type State = { defaultName: string; diff --git a/src/index.js b/src/index.js index c6c4cbd6..dc1da114 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ import { render } from 'react-dom'; import baseStyles from 'support/BaseStyles'; import { onBeforeUnload } from 'actions/WalletActions'; import App from 'views/index'; -import store from 'store'; +import store from './store'; const root: ?HTMLElement = document.getElementById('root'); if (root) { diff --git a/src/utils/promiseUtils.js b/src/utils/promiseUtils.js index e1e992f1..48be95a1 100644 --- a/src/utils/promiseUtils.js +++ b/src/utils/promiseUtils.js @@ -4,7 +4,7 @@ // import root from 'window-or-global'; // import Promise from 'es6-promise'; -export async function resolveAfter(msec: number, value: any = null): Promise { +export async function resolveAfter(msec: number, value?: any): Promise { await new Promise((resolve) => { //root.setTimeout(resolve, msec, value); window.setTimeout(resolve, msec, value); diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index 879ea222..3b597266 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -113,6 +113,9 @@ const AccountMenu = (props: Props): ?React$Element => { const { config } = props.localStorage; const selectedCoin = config.coins.find(c => c.network === location.state.network); + + if (!selected || !selectedCoin) return; + const fiatRate = props.fiat.find(f => f.network === selectedCoin.network); const deviceAccounts: Accounts = findDeviceAccounts(accounts, selected, location.state.network); diff --git a/src/views/Wallet/index.js b/src/views/Wallet/index.js index e84feef3..07024a52 100644 --- a/src/views/Wallet/index.js +++ b/src/views/Wallet/index.js @@ -20,7 +20,7 @@ import TopNavigationAccount from './components/TopNavigationAccount'; import TopNavigationDeviceSettings from './components/TopNavigationDeviceSettings'; type WalletContainerProps = { - // wallet: $ElementType, + wallet: $ElementType, children?: React.Node } diff --git a/src/views/Wallet/views/AccountSend/index.js b/src/views/Wallet/views/AccountSend/index.js index 03a37abb..6e213606 100644 --- a/src/views/Wallet/views/AccountSend/index.js +++ b/src/views/Wallet/views/AccountSend/index.js @@ -237,7 +237,7 @@ class AccountSend extends Component { } getTokensSelectData(tokens: Array, accountNetwork: any) { - const tokensSelectData = tokens.map(t => ({ value: t.symbol, label: t.symbol })); + const tokensSelectData: Array<{ value: string, label: string }> = tokens.map(t => ({ value: t.symbol, label: t.symbol })); tokensSelectData.unshift({ value: accountNetwork.symbol, label: accountNetwork.symbol }); return tokensSelectData; diff --git a/src/views/Wallet/views/AccountSummary/components/AccountBalance/index.js b/src/views/Wallet/views/AccountSummary/components/AccountBalance/index.js index b90e8fec..17384817 100644 --- a/src/views/Wallet/views/AccountSummary/components/AccountBalance/index.js +++ b/src/views/Wallet/views/AccountSummary/components/AccountBalance/index.js @@ -97,7 +97,7 @@ class AccountBalance extends Component { let fiat = ''; if (fiatRate) { accountBalance = new BigNumber(this.props.balance); - fiatRateValue = new BigNumber(fiatRate.value); + fiatRateValue = new BigNumber(fiatRate.value).toFixed(2); fiat = accountBalance.times(fiatRateValue).toFixed(2); } @@ -127,7 +127,7 @@ class AccountBalance extends Component { {fiatRate && ( - ${fiatRateValue.toFixed(2)} + ${fiatRateValue} 1.00 {selectedCoin.symbol} )}