diff --git a/src/components/BalanceSummary/index.js b/src/components/BalanceSummary/index.js index da423d90..00d3d6a5 100644 --- a/src/components/BalanceSummary/index.js +++ b/src/components/BalanceSummary/index.js @@ -4,7 +4,7 @@ import React, { Fragment } from 'react' import { getFiatUnit } from '@ledgerhq/currencies' -import type { Accounts } from 'types/common' +import type { Account } from 'types/common' import Chart from 'components/base/NewChart' import Box, { Card } from 'components/base/Box' @@ -15,7 +15,7 @@ type Props = { counterValue: string, chartColor: string, chartId: string, - accounts: Accounts, + accounts: Account[], selectedTime: string, daysCount: number, renderHeader: null | Function, diff --git a/src/components/CalculateBalance.js b/src/components/CalculateBalance.js index 3ae67fc4..d64f6d0e 100644 --- a/src/components/CalculateBalance.js +++ b/src/components/CalculateBalance.js @@ -3,7 +3,7 @@ import { PureComponent } from 'react' import { connect } from 'react-redux' -import type { Accounts } from 'types/common' +import type { Account } from 'types/common' import calculateBalance from 'helpers/balance' @@ -12,7 +12,7 @@ const mapStateToProps = state => ({ }) type Props = { - accounts: Accounts, + accounts: Account[], counterValues: Object, daysCount: number, render: Function, diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index 84054e0d..da3f1ebd 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -10,7 +10,7 @@ import chunk from 'lodash/chunk' import get from 'lodash/get' import sortBy from 'lodash/sortBy' -import type { Account, Accounts, Operations, T } from 'types/common' +import type { Account, Operation, T } from 'types/common' import { getVisibleAccounts } from 'reducers/accounts' import { getCounterValue } from 'reducers/settings' @@ -41,14 +41,14 @@ const mapDispatchToProps = { type Props = { t: T, - accounts: Accounts, + accounts: Account[], push: Function, counterValue: string, } type State = { accountsChunk: Array>, - allOperations: Operations, + allOperations: Operation[], selectedTime: string, daysCount: number, } diff --git a/src/components/IsUnlocked.js b/src/components/IsUnlocked.js index 3401f45d..6994c2df 100644 --- a/src/components/IsUnlocked.js +++ b/src/components/IsUnlocked.js @@ -6,7 +6,7 @@ import { compose } from 'redux' import { translate } from 'react-i18next' import bcrypt from 'bcryptjs' -import type { Settings, Accounts, T } from 'types/common' +import type { Settings, Account, T } from 'types/common' import get from 'lodash/get' @@ -31,7 +31,7 @@ type InputValue = { } type Props = { - accounts: Accounts, + accounts: Account[], children: any, counterValue: string, fetchAccounts: Function, diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 3221c8b5..4a918db7 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -193,7 +193,7 @@ Operation.defaultProps = { type Props = { t: T, onAccountClick?: Function, - operations: Array, + operations: OperationType[], withAccounts?: boolean, minConfirmations: number, title?: string, @@ -224,7 +224,7 @@ class OperationsList extends Component { return !isEqual(this._hashCache, this.getHashCache(nextProps.operations)) } - getHashCache = (operations: Array) => operations.map(t => t.hash) + getHashCache = (operations: OperationType[]) => operations.map(t => t.hash) _hashCache = null diff --git a/src/components/SelectAccount/index.js b/src/components/SelectAccount/index.js index d698ae0c..7e5bcf9a 100644 --- a/src/components/SelectAccount/index.js +++ b/src/components/SelectAccount/index.js @@ -6,7 +6,7 @@ import { translate } from 'react-i18next' import noop from 'lodash/noop' import { getIconByCoinType } from '@ledgerhq/currencies/react' -import type { T, Accounts, Account } from 'types/common' +import type { T, Account } from 'types/common' import { getVisibleAccounts } from 'reducers/accounts' @@ -42,7 +42,7 @@ const renderItem = a => { } type Props = { - accounts: Accounts, + accounts: Account[], onChange?: () => Account | void, value?: Account | null, t: T, diff --git a/src/components/SideBar/index.js b/src/components/SideBar/index.js index 620c07a2..394a9df6 100644 --- a/src/components/SideBar/index.js +++ b/src/components/SideBar/index.js @@ -9,7 +9,7 @@ import { getIconByCoinType } from '@ledgerhq/currencies/react' import { MODAL_SEND, MODAL_RECEIVE, MODAL_ADD_ACCOUNT } from 'constants' -import type { Accounts, T } from 'types/common' +import type { Account, T } from 'types/common' import { openModal } from 'reducers/modals' import { getVisibleAccounts } from 'reducers/accounts' @@ -52,7 +52,7 @@ const PlusBtn = styled(Tabbable).attrs({ type Props = { t: T, - accounts: Accounts, + accounts: Account[], openModal: Function, } diff --git a/src/components/modals/AddAccount/ImportAccounts.js b/src/components/modals/AddAccount/ImportAccounts.js index a1b4b2e8..74554e5b 100644 --- a/src/components/modals/AddAccount/ImportAccounts.js +++ b/src/components/modals/AddAccount/ImportAccounts.js @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react' import { translate } from 'react-i18next' -import type { T, Accounts } from 'types/common' +import type { T, Account } from 'types/common' import Box from 'components/base/Box' import Button from 'components/base/Button' @@ -13,7 +13,7 @@ import Input from 'components/base/Input' type Props = { t: T, - accounts: Accounts, + accounts: Account[], onImportAccounts: Function, } diff --git a/src/components/modals/AddAccount/RestoreAccounts.js b/src/components/modals/AddAccount/RestoreAccounts.js index 73f1c502..2addc888 100644 --- a/src/components/modals/AddAccount/RestoreAccounts.js +++ b/src/components/modals/AddAccount/RestoreAccounts.js @@ -7,14 +7,14 @@ import Box from 'components/base/Box' import Button from 'components/base/Button' import Text from 'components/base/Text' -import type { Accounts } from 'types/common' +import type { Account } from 'types/common' const Container = styled(Box)` border: 1px solid ${p => p.theme.colors.alertRed}; ` type Props = { - archivedAccounts: Accounts, + archivedAccounts: Account[], updateAccount: Function, } diff --git a/src/components/modals/AddAccount/index.js b/src/components/modals/AddAccount/index.js index 98de020b..d6a668bc 100644 --- a/src/components/modals/AddAccount/index.js +++ b/src/components/modals/AddAccount/index.js @@ -12,7 +12,7 @@ import type { Currency } from '@ledgerhq/currencies' import { MODAL_ADD_ACCOUNT } from 'constants' -import type { Accounts, Device, T } from 'types/common' +import type { Account, Device, T } from 'types/common' import { closeModal } from 'reducers/modals' import { canCreateAccount, getAccounts, getArchivedAccounts } from 'reducers/accounts' @@ -117,9 +117,9 @@ const Steps = { type Step = 'chooseCurrency' | 'connectDevice' | 'inProgress' | 'listAccounts' type Props = { - accounts: Accounts, + accounts: Account[], addAccount: Function, - archivedAccounts: Accounts, + archivedAccounts: Account[], canCreateAccount: boolean, closeModal: Function, counterValues: Object, @@ -130,7 +130,7 @@ type Props = { } type State = { - accounts: Accounts, + accounts: Account[], currency: Currency | null, fetchingCounterValues: boolean, progress: null | Object, diff --git a/src/helpers/balance.js b/src/helpers/balance.js index e4d25aa1..663a6c2f 100644 --- a/src/helpers/balance.js +++ b/src/helpers/balance.js @@ -8,7 +8,7 @@ import first from 'lodash/first' import isUndefined from 'lodash/isUndefined' import last from 'lodash/last' -import type { Accounts, Account } from 'types/common' +import type { Account } from 'types/common' type DateInterval = { start: string, @@ -21,7 +21,7 @@ type BalanceHistoryDay = { } type CalculateBalance = { - accounts: Accounts, + accounts: Account[], counterValue: string, counterValues: Object, daysCount: number, @@ -100,7 +100,7 @@ export function getBalanceHistoryForAccounts({ interval, }: { counterValue: string, - accounts: Accounts, + accounts: Account[], counterValues: Object, interval: DateInterval, }): Array { diff --git a/src/helpers/btc.js b/src/helpers/btc.js index f4349ee5..3e5c7ae3 100644 --- a/src/helpers/btc.js +++ b/src/helpers/btc.js @@ -7,7 +7,7 @@ import groupBy from 'lodash/groupBy' import noop from 'lodash/noop' import uniqBy from 'lodash/uniqBy' -import type { Operations } from 'types/common' +import type { Operation } from 'types/common' const GAP_LIMIT_ADDRESSES = 20 @@ -42,7 +42,7 @@ export function computeOperation(addresses: Array) { } } -export function getBalanceByDay(operations: Operations) { +export function getBalanceByDay(operations: Operation[]) { const txsByDate = groupBy(operations, tx => { const [date] = new Date(tx.receivedAt).toISOString().split('T') return date diff --git a/src/reducers/accounts.js b/src/reducers/accounts.js index 67d44e0f..927392a6 100644 --- a/src/reducers/accounts.js +++ b/src/reducers/accounts.js @@ -10,10 +10,9 @@ import defaultsDeep from 'lodash/defaultsDeep' import { getDefaultUnitByCoinType, getCurrencyByCoinType } from '@ledgerhq/currencies' import type { State } from 'reducers' -import type { Account, Accounts } from 'types/common' - -export type AccountsState = Accounts +import type { Account } from 'types/common' +export type AccountsState = Account[] const state: AccountsState = [] function orderAccountsOperations(account: Account) { @@ -36,7 +35,7 @@ function applyDefaults(account) { const handlers: Object = { SET_ACCOUNTS: ( state: AccountsState, - { payload: accounts }: { payload: Accounts }, + { payload: accounts }: { payload: Account[] }, ): AccountsState => accounts.map(applyDefaults), ADD_ACCOUNT: ( @@ -78,15 +77,15 @@ export function getTotalBalance(state: { accounts: AccountsState }) { ) } -export function getAccounts(state: { accounts: AccountsState }): Array { +export function getAccounts(state: { accounts: AccountsState }): Account[] { return state.accounts } -export function getArchivedAccounts(state: { accounts: AccountsState }): Array { +export function getArchivedAccounts(state: { accounts: AccountsState }): Account[] { return state.accounts.filter(acc => acc.archived === true) } -export function getVisibleAccounts(state: { accounts: AccountsState }): Array { +export function getVisibleAccounts(state: { accounts: AccountsState }): Account[] { return getAccounts(state).filter(account => account.archived !== true) } @@ -127,7 +126,7 @@ export function serializeAccounts(accounts: Array) { }) } -export function deserializeAccounts(accounts: Accounts) { +export function deserializeAccounts(accounts: Account[]) { return accounts.map(account => ({ id: account.id, address: account.address, diff --git a/src/renderer/events.js b/src/renderer/events.js index f05fc56f..27b112cc 100644 --- a/src/renderer/events.js +++ b/src/renderer/events.js @@ -5,7 +5,7 @@ import objectPath from 'object-path' import debug from 'debug' import { getDefaultUnitByCoinType } from '@ledgerhq/currencies' -import type { Accounts } from 'types/common' +import type { Account } from 'types/common' import { CHECK_UPDATE_DELAY, SYNC_ACCOUNT_DELAY, SYNC_COUNTER_VALUES_DELAY } from 'constants' @@ -52,7 +52,7 @@ export function sendSyncEvent(channel: string, msgType: string, data: any): any }) } -export function startSyncAccounts(accounts: Accounts) { +export function startSyncAccounts(accounts: Account[]) { d.sync('Sync accounts - start') syncAccountsInProgress = true sendEvent('accounts', 'sync.all', { @@ -76,7 +76,7 @@ export function stopSyncAccounts() { clearTimeout(syncAccountsTimeout) } -export function startSyncCounterValues(counterValue: string, accounts: Accounts) { +export function startSyncCounterValues(counterValue: string, accounts: Account[]) { d.sync('Sync counterValues - start') sendEvent('msg', 'counterValues.sync', { diff --git a/src/types/common.js b/src/types/common.js index 1f9838d3..fee51c87 100644 --- a/src/types/common.js +++ b/src/types/common.js @@ -22,8 +22,6 @@ export type Operation = { confirmations: number, } -export type Operations = Array - // -------------------- Accounts export type AccountSettings = { @@ -43,13 +41,11 @@ export type Account = { name: string, path: string, rootPath: string, - operations: Operations, + operations: Operation[], unit: Unit, settings: AccountSettings, } -export type Accounts = Array - // -------------------- Settings export type SettingsProfile = {