Browse Source

Fixes Flow

develop
Gaëtan Renaudeau 6 years ago
parent
commit
c3c5c9e4a4
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 4
      src/bridge/index.js
  2. 4
      src/bridge/types.js
  3. 4
      src/components/CounterValue/index.js
  4. 4
      src/components/CurrenciesStatusBanner.js
  5. 9
      src/components/DevToolsPage/AccountImporter.js
  6. 4
      src/components/OperationsList/AccountCell.js
  7. 4
      src/components/OperationsList/AmountCell.js
  8. 2
      src/components/SettingsPage/CounterValueSelect.js
  9. 4
      src/components/WithFeesAPI.js
  10. 6
      src/components/base/CurrencyBadge.js
  11. 4
      src/components/modals/AccountSettingRenderBody.js
  12. 10
      src/components/modals/AddAccounts/index.js
  13. 5
      src/reducers/settings.js

4
src/bridge/index.js

@ -1,5 +1,5 @@
// @flow
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import invariant from 'invariant'
import { USE_MOCK_DATA } from 'config/constants'
import { WalletBridge } from './types'
@ -20,7 +20,7 @@ if (USE_MOCK_DATA) {
perFamily.ethereum = mockBridge
perFamily.ripple = mockBridge
}
export const getBridgeForCurrency = (currency: Currency): WalletBridge<any> => {
export const getBridgeForCurrency = (currency: CryptoCurrency): WalletBridge<any> => {
const bridge = perFamily[currency.family]
invariant(bridge, `${currency.id} currency is not supported`)
return bridge

4
src/bridge/types.js

@ -2,7 +2,7 @@
import type { Observable } from 'rxjs'
import type { BigNumber } from 'bignumber.js'
import type { Account, Operation, Currency } from '@ledgerhq/live-common/lib/types'
import type { Account, Operation, CryptoCurrency } from '@ledgerhq/live-common/lib/types'
// a WalletBridge is implemented on renderer side.
// this is an abstraction on top of libcore / ethereumjs / ripple js / ...
@ -34,7 +34,7 @@ export interface WalletBridge<Transaction> {
// the scan can stop once all accounts are discovered.
// the function returns a Subscription and you MUST stop everything if it is unsubscribed.
// TODO return Observable
scanAccountsOnDevice(currency: Currency, deviceId: DeviceId): Observable<Account>;
scanAccountsOnDevice(currency: CryptoCurrency, deviceId: DeviceId): Observable<Account>;
// synchronize an account. meaning updating the account object with latest state.
// function receives the initialAccount object so you can actually know what the user side currently have

4
src/components/CounterValue/index.js

@ -3,7 +3,7 @@
import type { BigNumber } from 'bignumber.js'
import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency, Currency } from '@ledgerhq/live-common/lib/types'
import {
counterValueCurrencySelector,
@ -19,7 +19,7 @@ import type { State } from 'reducers'
type OwnProps = {
// wich market to query
currency: Currency,
currency: CryptoCurrency,
// when? if not given: take latest
date?: Date,

4
src/components/CurrenciesStatusBanner.js

@ -6,7 +6,7 @@ import { translate } from 'react-i18next'
import { connect } from 'react-redux'
import { createStructuredSelector } from 'reselect'
import styled from 'styled-components'
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import { colors } from 'styles/theme'
import { openURL } from 'helpers/linking'
@ -59,7 +59,7 @@ const CloseIcon = (props: *) => (
)
type Props = {
accountsCurrencies: Currency[],
accountsCurrencies: CryptoCurrency[],
dismissedBanners: string[],
dismissBanner: string => void,
currenciesStatus: CurrencyStatus[],

9
src/components/DevToolsPage/AccountImporter.js

@ -6,7 +6,7 @@ import React, { PureComponent, Fragment } from 'react'
import invariant from 'invariant'
import { connect } from 'react-redux'
import type { Currency, Account, DerivationMode } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency, Account, DerivationMode } from '@ledgerhq/live-common/lib/types'
import { decodeAccount } from 'reducers/accounts'
import { addAccount } from 'actions/accounts'
@ -37,7 +37,7 @@ type Props = {
type ImportableAccountType = {
name: string,
currency: Currency,
currency: CryptoCurrency,
derivationMode: DerivationMode,
xpub: string,
}
@ -47,7 +47,7 @@ type State = {
importableAccounts: ImportableAccountType[],
currency: ?Currency,
currency: ?CryptoCurrency,
xpub: string,
name: string,
isSegwit: boolean,
@ -72,7 +72,7 @@ const INITIAL_STATE = {
class AccountImporter extends PureComponent<Props, State> {
state = INITIAL_STATE
onChangeCurrency = currency => {
onChangeCurrency = (currency: CryptoCurrency) => {
if (currency.family !== 'bitcoin') return
this.setState({
currency,
@ -119,6 +119,7 @@ class AccountImporter extends PureComponent<Props, State> {
addToScan = () => {
const { xpub, currency, isSegwit, isUnsplit, name } = this.state
if (!currency) return
const derivationMode = isSegwit
? isUnsplit
? 'segwit_unsplit'

4
src/components/OperationsList/AccountCell.js

@ -3,7 +3,7 @@
import React, { PureComponent } from 'react'
import styled from 'styled-components'
import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react'
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import Box from 'components/base/Box'
const Cell = styled(Box).attrs({
@ -17,7 +17,7 @@ const Cell = styled(Box).attrs({
`
type Props = {
currency: Currency,
currency: CryptoCurrency,
accountName: string,
}

4
src/components/OperationsList/AmountCell.js

@ -3,7 +3,7 @@
import React, { PureComponent } from 'react'
import styled from 'styled-components'
import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/operation'
import type { Currency, Unit, Operation } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency, Unit, Operation } from '@ledgerhq/live-common/lib/types'
import Box from 'components/base/Box'
import CounterValue from 'components/CounterValue'
import FormattedVal from 'components/base/FormattedVal'
@ -18,7 +18,7 @@ const Cell = styled(Box).attrs({
type Props = {
operation: Operation,
currency: Currency,
currency: CryptoCurrency,
unit: Unit,
}

2
src/components/SettingsPage/CounterValueSelect.js

@ -15,7 +15,7 @@ const fiats = listFiatCurrencies()
// For now we take first unit, in the future we'll need to figure out something else
.map(fiat => ({
value: fiat.code,
label: `${fiat.name} - ${fiat.code}${fiat.symbol ? ` (${fiat.symbol})` : ''}`,
label: `${fiat.name} - ${fiat.code}`,
fiat,
}))

4
src/components/WithFeesAPI.js

@ -1,13 +1,13 @@
// @flow
import { Component } from 'react'
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import { getEstimatedFees } from '@ledgerhq/live-common/lib/api/Fees'
import type { Fees } from '@ledgerhq/live-common/lib/api/Fees'
// FIXME we need to abstract this out like we did for CounterValues
export default class WithFeesAPI extends Component<
{
currency: Currency,
currency: CryptoCurrency,
render: Fees => *,
renderLoading: () => *,
renderError: Error => *,

6
src/components/base/CurrencyBadge.js

@ -4,7 +4,7 @@ import React from 'react'
import styled from 'styled-components'
import { getCryptoCurrencyIcon } from '@ledgerhq/live-common/lib/react'
import type { Currency } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import { rgba } from 'styles/helpers'
@ -26,7 +26,7 @@ export function CurrencyCircleIcon({
size,
...props
}: {
currency: Currency,
currency: CryptoCurrency,
size: number,
}) {
const Icon = getCryptoCurrencyIcon(currency)
@ -37,7 +37,7 @@ export function CurrencyCircleIcon({
)
}
function CurrencyBadge({ currency, ...props }: { currency: Currency }) {
function CurrencyBadge({ currency, ...props }: { currency: CryptoCurrency }) {
return (
<Box horizontal flow={3} {...props}>
<CurrencyCircleIcon size={40} currency={currency} />

4
src/components/modals/AccountSettingRenderBody.js

@ -7,7 +7,7 @@ import { compose } from 'redux'
import get from 'lodash/get'
import { translate } from 'react-i18next'
import type { Account, Unit, Currency } from '@ledgerhq/live-common/lib/types'
import type { Account, Unit, CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common'
import { MODAL_SETTINGS_ACCOUNT, MAX_ACCOUNT_NAME_SIZE } from 'config/constants'
import { validateNameEdition } from '@ledgerhq/live-common/lib/account'
@ -327,7 +327,7 @@ export default compose(
translate(),
)(AccountSettingRenderBody)
export function InputLeft({ currency }: { currency: Currency }) {
export function InputLeft({ currency }: { currency: CryptoCurrency }) {
return (
<Box ml={2} style={{ justifyContent: 'center' }} color={currency.color}>
<CryptoCurrencyIcon currency={currency} size={16} />

10
src/components/modals/AddAccounts/index.js

@ -9,7 +9,7 @@ import { createStructuredSelector } from 'reselect'
import Track from 'analytics/Track'
import SyncSkipUnderPriority from 'components/SyncSkipUnderPriority'
import type { Currency, Account } from '@ledgerhq/live-common/lib/types'
import type { CryptoCurrency, Account } from '@ledgerhq/live-common/lib/types'
import { MODAL_ADD_ACCOUNTS } from 'config/constants'
import type { T, Device } from 'types/common'
@ -90,7 +90,7 @@ type State = {
scanStatus: ScanStatus | string,
isAppOpened: boolean,
currency: ?Currency,
currency: ?CryptoCurrency,
scannedAccounts: Account[],
checkedAccountsIds: string[],
editedNames: { [_: string]: string },
@ -100,7 +100,7 @@ type State = {
export type StepProps = DefaultStepProps & {
t: T,
currency: ?Currency,
currency: ?CryptoCurrency,
device: ?Device,
isAppOpened: boolean,
scannedAccounts: Account[],
@ -112,7 +112,7 @@ export type StepProps = DefaultStepProps & {
onGoStep1: () => void,
onCloseModal: () => void,
resetScanState: () => void,
setCurrency: (?Currency) => void,
setCurrency: (?CryptoCurrency) => void,
setAppOpened: boolean => void,
setScanStatus: (ScanStatus, ?Error) => string,
setAccountName: (Account, string) => void,
@ -164,7 +164,7 @@ class AddAccounts extends PureComponent<Props, State> {
handleCloseModal = () => this.props.closeModal(MODAL_ADD_ACCOUNTS)
handleStepChange = (step: Step) => this.setState({ stepId: step.id })
handleSetCurrency = (currency: ?Currency) => this.setState({ currency })
handleSetCurrency = (currency: ?CryptoCurrency) => this.setState({ currency })
handleSetScanStatus = (scanStatus: string, err: ?Error = null) => {
if (err) {

5
src/reducers/settings.js

@ -80,7 +80,8 @@ const INITIAL_STATE: SettingsState = {
}
function asCryptoCurrency(c: Currency): ?CryptoCurrency {
return 'id' in c ? c : null
// $FlowFixMe
return 'coinType' in c ? c : null
}
const handlers: Object = {
@ -201,7 +202,7 @@ export const areSettingsLoaded = (state: State) => state.settings.loaded
export const currencySettingsLocaleSelector = (
settings: SettingsState,
currency: Currency,
currency: CryptoCurrency,
): CurrencySettings => {
const currencySettings = settings.currenciesSettings[currency.id]
const val = { ...defaultsForCurrency(currency), ...currencySettings }

Loading…
Cancel
Save