diff --git a/package.json b/package.json index 975c4ab5..656ebff7 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@ledgerhq/hw-transport": "^4.32.0", "@ledgerhq/hw-transport-node-hid": "^4.32.0", "@ledgerhq/ledger-core": "2.0.0-rc.14", - "@ledgerhq/live-common": "4.8.1", + "@ledgerhq/live-common": "4.12.0", "animated": "^0.2.2", "async": "^2.6.1", "axios": "^0.18.0", diff --git a/src/api/Ethereum.js b/src/api/Ethereum.js index 4542ddb6..bd7b2160 100644 --- a/src/api/Ethereum.js +++ b/src/api/Ethereum.js @@ -1,7 +1,7 @@ // @flow import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' import { BigNumber } from 'bignumber.js' -import { LedgerAPINotAvailable } from '@ledgerhq/live-common/lib/errors' +import { LedgerAPINotAvailable } from '@ledgerhq/errors' import network from './network' import { blockchainBaseURL } from './Ledger' diff --git a/src/api/Fees.js b/src/api/Fees.js index 476ea5d0..84623f88 100644 --- a/src/api/Fees.js +++ b/src/api/Fees.js @@ -2,7 +2,7 @@ import invariant from 'invariant' import LRU from 'lru-cache' import type { Currency } from '@ledgerhq/live-common/lib/types' -import { FeeEstimationFailed } from '@ledgerhq/live-common/lib/errors' +import { FeeEstimationFailed } from '@ledgerhq/errors' import { blockchainBaseURL } from './Ledger' import network from './network' diff --git a/src/api/network.js b/src/api/network.js index db0a3e5d..66504be2 100644 --- a/src/api/network.js +++ b/src/api/network.js @@ -3,11 +3,7 @@ import axios from 'axios' import { GET_CALLS_RETRY, GET_CALLS_TIMEOUT } from 'config/constants' import { retry } from 'helpers/promise' import logger from 'logger' -import { - LedgerAPIErrorWithMessage, - LedgerAPIError, - NetworkDown, -} from '@ledgerhq/live-common/lib/errors' +import { LedgerAPIErrorWithMessage, LedgerAPIError, NetworkDown } from '@ledgerhq/errors' import anonymizer from 'helpers/anonymizer' const userFriendlyError = (p: Promise, { url, method, startTime, ...rest }): Promise => diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index a337dd85..1eeeca8f 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -25,7 +25,7 @@ import { apiForCurrency } from 'api/Ethereum' import type { Tx } from 'api/Ethereum' import getAddressCommand from 'commands/getAddress' import signTransactionCommand from 'commands/signTransaction' -import { NotEnoughBalance, FeeNotLoaded, ETHAddressNonEIP } from '@ledgerhq/live-common/lib/errors' +import { NotEnoughBalance, FeeNotLoaded, ETHAddressNonEIP } from '@ledgerhq/errors' import type { EditProps, WalletBridge } from './types' type Transaction = { diff --git a/src/bridge/LibcoreBridge.js b/src/bridge/LibcoreBridge.js index 16d52909..e9d2ce8b 100644 --- a/src/bridge/LibcoreBridge.js +++ b/src/bridge/LibcoreBridge.js @@ -11,7 +11,7 @@ import libcoreSyncAccount from 'commands/libcoreSyncAccount' import libcoreSignAndBroadcast from 'commands/libcoreSignAndBroadcast' import libcoreGetFees, { extractGetFeesInputFromAccount } from 'commands/libcoreGetFees' import libcoreValidAddress from 'commands/libcoreValidAddress' -import { NotEnoughBalance, FeeNotLoaded } from '@ledgerhq/live-common/lib/errors' +import { NotEnoughBalance, FeeNotLoaded } from '@ledgerhq/errors' import type { WalletBridge, EditProps } from './types' const NOT_ENOUGH_FUNDS = 52 diff --git a/src/bridge/RippleJSBridge.js b/src/bridge/RippleJSBridge.js index c67a5a94..88f83531 100644 --- a/src/bridge/RippleJSBridge.js +++ b/src/bridge/RippleJSBridge.js @@ -32,7 +32,7 @@ import { NotEnoughBalance, FeeNotLoaded, NotEnoughBalanceBecauseDestinationNotCreated, -} from '@ledgerhq/live-common/lib/errors' +} from '@ledgerhq/errors' import type { WalletBridge, EditProps } from './types' type Transaction = { diff --git a/src/commands/firmwareRepair.js b/src/commands/firmwareRepair.js index 64009722..d990fb4b 100644 --- a/src/commands/firmwareRepair.js +++ b/src/commands/firmwareRepair.js @@ -3,12 +3,15 @@ import repair from '@ledgerhq/live-common/lib/hw/firmwareUpdate-repair' import { createCommand, Command } from 'helpers/ipc' -type Input = void +type Input = { + version: ?string, +} + type Result = { progress: number } const cmd: Command = createCommand( 'firmwareRepair', - () => repair(''), // devicePath='' HACK to not depend on a devicePath because it's dynamic + ({ version }) => repair('', version), // devicePath='' HACK to not depend on a devicePath because it's dynamic ) export default cmd diff --git a/src/commands/libcoreGetFees.js b/src/commands/libcoreGetFees.js index faebcdd0..fcedd03d 100644 --- a/src/commands/libcoreGetFees.js +++ b/src/commands/libcoreGetFees.js @@ -13,7 +13,7 @@ import { bigNumberToLibcoreAmount, getOrCreateWallet, } from 'helpers/libcore' -import { InvalidAddress } from '@ledgerhq/live-common/lib/errors' +import { InvalidAddress } from '@ledgerhq/errors' type BitcoinLikeTransaction = { // TODO we rename this Transaction concept into transactionInput diff --git a/src/commands/libcoreSignAndBroadcast.js b/src/commands/libcoreSignAndBroadcast.js index 30dd27ab..b683a58b 100644 --- a/src/commands/libcoreSignAndBroadcast.js +++ b/src/commands/libcoreSignAndBroadcast.js @@ -14,7 +14,7 @@ import { bigNumberToLibcoreAmount, getOrCreateWallet, } from 'helpers/libcore' -import { UpdateYourApp } from '@ledgerhq/live-common/lib/errors' +import { UpdateYourApp } from '@ledgerhq/errors' import withLibcore from 'helpers/withLibcore' import { createCommand, Command } from 'helpers/ipc' diff --git a/src/components/EnsureDeviceApp.js b/src/components/EnsureDeviceApp.js index 47f90e79..623166a9 100644 --- a/src/components/EnsureDeviceApp.js +++ b/src/components/EnsureDeviceApp.js @@ -23,11 +23,7 @@ import IconUsb from 'icons/Usb' import type { Device } from 'types/common' -import { - WrongDeviceForAccount, - CantOpenDevice, - UpdateYourApp, -} from '@ledgerhq/live-common/lib/errors' +import { WrongDeviceForAccount, CantOpenDevice, UpdateYourApp } from '@ledgerhq/errors' import { getCurrentDevice } from 'reducers/devices' const usbIcon = diff --git a/src/components/FeesField/BitcoinKind.js b/src/components/FeesField/BitcoinKind.js index 81c2ea9b..937e0702 100644 --- a/src/components/FeesField/BitcoinKind.js +++ b/src/components/FeesField/BitcoinKind.js @@ -8,7 +8,7 @@ import { translate } from 'react-i18next' import type { T } from 'types/common' -import { FeeNotLoaded } from '@ledgerhq/live-common/lib/errors' +import { FeeNotLoaded } from '@ledgerhq/errors' import InputCurrency from 'components/base/InputCurrency' import Select from 'components/base/Select' import type { Fees } from 'api/Fees' diff --git a/src/components/FeesField/EthereumKind.js b/src/components/FeesField/EthereumKind.js index aa02c86a..d6ef3d6d 100644 --- a/src/components/FeesField/EthereumKind.js +++ b/src/components/FeesField/EthereumKind.js @@ -4,7 +4,7 @@ import React, { Component } from 'react' import { BigNumber } from 'bignumber.js' import type { Account } from '@ledgerhq/live-common/lib/types' -import { FeeNotLoaded } from '@ledgerhq/live-common/lib/errors' +import { FeeNotLoaded } from '@ledgerhq/errors' import InputCurrency from 'components/base/InputCurrency' import type { Fees } from 'api/Fees' import WithFeesAPI from '../WithFeesAPI' diff --git a/src/components/FeesField/RippleKind.js b/src/components/FeesField/RippleKind.js index 8692cb12..acf7622e 100644 --- a/src/components/FeesField/RippleKind.js +++ b/src/components/FeesField/RippleKind.js @@ -4,7 +4,7 @@ import React, { Component } from 'react' import type { BigNumber } from 'bignumber.js' import type { Account } from '@ledgerhq/live-common/lib/types' import { apiForEndpointConfig, parseAPIValue } from 'api/Ripple' -import { FeeNotLoaded } from '@ledgerhq/live-common/lib/errors' +import { FeeNotLoaded } from '@ledgerhq/errors' import InputCurrency from 'components/base/InputCurrency' import GenericContainer from './GenericContainer' diff --git a/src/components/GenuineCheck.js b/src/components/GenuineCheck.js index 751e8720..d3487591 100644 --- a/src/components/GenuineCheck.js +++ b/src/components/GenuineCheck.js @@ -20,7 +20,7 @@ import { DeviceNotGenuineError, DeviceGenuineSocketEarlyClose, UnexpectedBootloader, -} from '@ledgerhq/live-common/lib/errors' +} from '@ledgerhq/errors' import getDeviceInfo from 'commands/getDeviceInfo' import getIsGenuine from 'commands/getIsGenuine' diff --git a/src/components/IsUnlocked.js b/src/components/IsUnlocked.js index 391599db..997ee69f 100644 --- a/src/components/IsUnlocked.js +++ b/src/components/IsUnlocked.js @@ -17,7 +17,7 @@ import { hardReset } from 'helpers/reset' import { fetchAccounts } from 'actions/accounts' import { isLocked, unlock } from 'reducers/application' -import { PasswordIncorrectError } from '@ledgerhq/live-common/lib/errors' +import { PasswordIncorrectError } from '@ledgerhq/errors' import Box from 'components/base/Box' import InputPassword from 'components/base/InputPassword' diff --git a/src/components/SettingsPage/DisablePasswordModal.js b/src/components/SettingsPage/DisablePasswordModal.js index bf5ebe61..b9613c42 100644 --- a/src/components/SettingsPage/DisablePasswordModal.js +++ b/src/components/SettingsPage/DisablePasswordModal.js @@ -1,7 +1,7 @@ // @flow import React, { PureComponent } from 'react' -import { PasswordIncorrectError } from '@ledgerhq/live-common/lib/errors' +import { PasswordIncorrectError } from '@ledgerhq/errors' import db from 'helpers/db' import Box from 'components/base/Box' diff --git a/src/components/SettingsPage/PasswordForm.js b/src/components/SettingsPage/PasswordForm.js index 396a1355..d0587fec 100644 --- a/src/components/SettingsPage/PasswordForm.js +++ b/src/components/SettingsPage/PasswordForm.js @@ -6,7 +6,7 @@ import Box from 'components/base/Box' import InputPassword from 'components/base/InputPassword' import Label from 'components/base/Label' -import { PasswordsDontMatchError } from '@ledgerhq/live-common/lib/errors' +import { PasswordsDontMatchError } from '@ledgerhq/errors' import type { T } from 'types/common' diff --git a/src/components/SettingsPage/PasswordModal.js b/src/components/SettingsPage/PasswordModal.js index 00abe296..c55e4056 100644 --- a/src/components/SettingsPage/PasswordModal.js +++ b/src/components/SettingsPage/PasswordModal.js @@ -5,7 +5,7 @@ import React, { PureComponent } from 'react' import type { T } from 'types/common' import db from 'helpers/db' -import { PasswordIncorrectError } from '@ledgerhq/live-common/lib/errors' +import { PasswordIncorrectError } from '@ledgerhq/errors' import Box from 'components/base/Box' import Button from 'components/base/Button' import { Modal, ModalContent, ModalBody, ModalTitle, ModalFooter } from 'components/base/Modal' diff --git a/src/components/SettingsPage/RepairDeviceButton.js b/src/components/SettingsPage/RepairDeviceButton.js index 1332bf3e..511bed6e 100644 --- a/src/components/SettingsPage/RepairDeviceButton.js +++ b/src/components/SettingsPage/RepairDeviceButton.js @@ -41,11 +41,11 @@ class RepairDeviceButton extends PureComponent { this.setState({ opened: false, isLoading: false, error: null, progress: 0 }) } - action = () => { + repair = (version = null) => { if (this.state.isLoading) return const { push } = this.props this.setState({ isLoading: true }) - this.sub = firmwareRepair.send().subscribe({ + this.sub = firmwareRepair.send({ version }).subscribe({ next: patch => { this.setState(patch) }, @@ -76,11 +76,10 @@ class RepairDeviceButton extends PureComponent { isOpened={opened} onClose={this.close} onReject={this.close} - onConfirm={this.action} + repair={this.repair} isLoading={isLoading} title={t('settings.repairDevice.title')} desc={t('settings.repairDevice.desc')} - confirmText={t('settings.repairDevice.button')} progress={progress} error={error} /> diff --git a/src/components/SettingsPage/sections/Help.js b/src/components/SettingsPage/sections/Help.js index 10949ceb..539d0213 100644 --- a/src/components/SettingsPage/sections/Help.js +++ b/src/components/SettingsPage/sections/Help.js @@ -73,7 +73,10 @@ class SectionHelp extends PureComponent { > - + diff --git a/src/components/base/Modal/RepairModal.js b/src/components/base/Modal/RepairModal.js index 37d00df9..a69d839c 100644 --- a/src/components/base/Modal/RepairModal.js +++ b/src/components/base/Modal/RepairModal.js @@ -3,6 +3,7 @@ import React, { PureComponent } from 'react' import { translate } from 'react-i18next' import styled from 'styled-components' +import { forceRepairChoices } from '@ledgerhq/live-common/lib/hw/firmwareUpdate-repair' import type { T } from 'types/common' @@ -11,6 +12,7 @@ import TrackPage from 'analytics/TrackPage' import Button from 'components/base/Button' import Box from 'components/base/Box' import Text from 'components/base/Text' +import Select from 'components/base/Select' import ProgressCircle from 'components/ProgressCircle' import TranslatedError from 'components/TranslatedError' import ExclamationCircleThin from 'icons/ExclamationCircleThin' @@ -129,7 +131,7 @@ type Props = { confirmText?: string, cancelText?: string, onReject: Function, - onConfirm: Function, + repair: (?string) => *, t: T, isLoading?: boolean, analyticsName: string, @@ -138,7 +140,20 @@ type Props = { error?: Error, } -class RepairModal extends PureComponent { +class RepairModal extends PureComponent { + state = { + selectedOption: forceRepairChoices[0], + } + + onChange = selectedOption => { + this.setState({ selectedOption: selectedOption || forceRepairChoices[0] }) + } + + renderOption = option => (option && this.props.t(`settings.repairDevice.${option.label}`)) || null + + renderValue = option => + (option && this.props.t(`settings.repairDevice.${option.data.label}`)) || null + render() { const { cancellable, @@ -148,7 +163,7 @@ class RepairModal extends PureComponent { confirmText, isDanger, onReject, - onConfirm, + repair, isLoading, renderIcon, t, @@ -157,8 +172,7 @@ class RepairModal extends PureComponent { error, ...props } = this.props - - const realConfirmText = confirmText || t('common.confirm') + const { selectedOption } = this.state return ( { )} + {!isLoading && !error ? ( + +