diff --git a/package.json b/package.json index 1c0cf40b..b1263029 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@ledgerhq/hw-transport": "^4.24.0", "@ledgerhq/hw-transport-node-hid": "4.24.0", "@ledgerhq/ledger-core": "2.0.0-rc.8", - "@ledgerhq/live-common": "/Users/gre/dev/ledger-live-common", + "@ledgerhq/live-common": "4.0.0-beta.1", "animated": "^0.2.2", "async": "^2.6.1", "axios": "^0.18.0", diff --git a/src/__mocks__/storybook-state.js b/src/__mocks__/storybook-state.js index 036894ec..675e36b7 100644 --- a/src/__mocks__/storybook-state.js +++ b/src/__mocks__/storybook-state.js @@ -2,7 +2,7 @@ import { genStoreState } from '@ledgerhq/live-common/lib/countervalues/mock' import { getCryptoCurrencyById, getFiatCurrencyByTicker, -} from '@ledgerhq/live-common/lib/helpers/currencies' +} from '@ledgerhq/live-common/lib/currencies' export default { countervalues: genStoreState([ diff --git a/src/actions/general.js b/src/actions/general.js index 9a133e31..1c984625 100644 --- a/src/actions/general.js +++ b/src/actions/general.js @@ -8,7 +8,7 @@ import { getOrderAccounts, } from 'reducers/settings' import { accountsSelector } from 'reducers/accounts' -import { sortAccounts } from '@ledgerhq/live-common/lib/helpers/account' +import { sortAccounts } from '@ledgerhq/live-common/lib/account' const accountsBtcBalanceSelector = createSelector( accountsSelector, diff --git a/src/api/Ripple.js b/src/api/Ripple.js index 06f359f9..2c4be71a 100644 --- a/src/api/Ripple.js +++ b/src/api/Ripple.js @@ -6,7 +6,7 @@ import { parseCurrencyUnit, getCryptoCurrencyById, formatCurrencyUnit, -} from '@ledgerhq/live-common/lib/helpers/currencies' +} from '@ledgerhq/live-common/lib/currencies' const rippleUnit = getCryptoCurrencyById('ripple').units[0] diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index f0f6ea05..9713910c 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -13,11 +13,11 @@ import { getDerivationScheme, runDerivationScheme, getMandatoryEmptyAccountSkip, -} from '@ledgerhq/live-common/lib/helpers/derivation' +} from '@ledgerhq/live-common/lib/derivation' import { getAccountPlaceholderName, getNewAccountPlaceholderName, -} from '@ledgerhq/live-common/lib/helpers/account' +} from '@ledgerhq/live-common/lib/account' import type { Account, Operation } from '@ledgerhq/live-common/lib/types' import eip55 from 'eip55' import { apiForCurrency } from 'api/Ethereum' @@ -218,7 +218,7 @@ const EthereumBridge: WalletBridge = { async function stepAddress( index, - { address, path: freshAddressPath, publicKey }, + { address, path: freshAddressPath }, derivationMode, shouldSkipEmpty, ): { account?: Account, complete?: boolean } { @@ -230,7 +230,7 @@ const EthereumBridge: WalletBridge = { if (finished) return { complete: true } const freshAddress = address - const accountId = `ethereumjs:2:${currency.id}:${address}:${publicKey}` + const accountId = `ethereumjs:2:${currency.id}:${address}:${derivationMode}` if (txs.length === 0 && balance.isZero()) { // this is an empty account @@ -305,7 +305,9 @@ const EthereumBridge: WalletBridge = { const mandatoryEmptyAccountSkip = getMandatoryEmptyAccountSkip(derivationMode) const derivationScheme = getDerivationScheme({ derivationMode, currency }) for (let index = 0; index < 255; index++) { - const freshAddressPath = runDerivationScheme(derivationScheme, { account: index }) + const freshAddressPath = runDerivationScheme(derivationScheme, currency, { + account: index, + }) const res = await getAddressCommand .send({ currencyId: currency.id, devicePath: deviceId, path: freshAddressPath }) .toPromise() diff --git a/src/bridge/RippleJSBridge.js b/src/bridge/RippleJSBridge.js index c24f1b04..d78aa36d 100644 --- a/src/bridge/RippleJSBridge.js +++ b/src/bridge/RippleJSBridge.js @@ -11,11 +11,11 @@ import { getDerivationModesForCurrency, getDerivationScheme, runDerivationScheme, -} from '@ledgerhq/live-common/lib/helpers/derivation' +} from '@ledgerhq/live-common/lib/derivation' import { getAccountPlaceholderName, getNewAccountPlaceholderName, -} from '@ledgerhq/live-common/lib/helpers/account' +} from '@ledgerhq/live-common/lib/account' import getAddress from 'commands/getAddress' import signTransaction from 'commands/signTransaction' import { @@ -300,13 +300,15 @@ const RippleJSBridge: WalletBridge = { for (const derivationMode of derivationModes) { const derivationScheme = getDerivationScheme({ derivationMode, currency }) for (let index = 0; index < 255; index++) { - const freshAddressPath = runDerivationScheme(derivationScheme, { account: index }) - const { address, publicKey } = await await getAddress + const freshAddressPath = runDerivationScheme(derivationScheme, currency, { + account: index, + }) + const { address } = await await getAddress .send({ currencyId: currency.id, devicePath: deviceId, path: freshAddressPath }) .toPromise() if (finished) return - const accountId = `ripplejs:2:${currency.id}:${address}:${publicKey}` + const accountId = `ripplejs:2:${currency.id}:${address}:${derivationMode}` let info try { diff --git a/src/bridge/makeMockBridge.js b/src/bridge/makeMockBridge.js index 8c66bdb2..93080000 100644 --- a/src/bridge/makeMockBridge.js +++ b/src/bridge/makeMockBridge.js @@ -6,11 +6,11 @@ import { genAddingOperationsInAccount, genOperation, } from '@ledgerhq/live-common/lib/mock/account' -import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/helpers/operation' +import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/operation' import Prando from 'prando' import { BigNumber } from 'bignumber.js' import type { Operation } from '@ledgerhq/live-common/lib/types' -import { validateNameEdition } from '@ledgerhq/live-common/lib/helpers/account' +import { validateNameEdition } from '@ledgerhq/live-common/lib/account' import { MOCK_DATA_SEED } from 'config/constants' import type { WalletBridge } from './types' diff --git a/src/commands/debugAppInfosForCurrency.js b/src/commands/debugAppInfosForCurrency.js index 25239a1b..1e13096a 100644 --- a/src/commands/debugAppInfosForCurrency.js +++ b/src/commands/debugAppInfosForCurrency.js @@ -1,6 +1,6 @@ // @flow -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { createCommand, Command } from 'helpers/ipc' import { fromPromise } from 'rxjs/observable/fromPromise' import { withDevice } from 'helpers/deviceAccess' diff --git a/src/commands/getAddress.js b/src/commands/getAddress.js index d2a24636..801f33e7 100644 --- a/src/commands/getAddress.js +++ b/src/commands/getAddress.js @@ -1,6 +1,6 @@ // @flow -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { createCommand, Command } from 'helpers/ipc' import { fromPromise } from 'rxjs/observable/fromPromise' import { withDevice } from 'helpers/deviceAccess' diff --git a/src/commands/libcoreGetFees.js b/src/commands/libcoreGetFees.js index c57bb193..ef66bcb2 100644 --- a/src/commands/libcoreGetFees.js +++ b/src/commands/libcoreGetFees.js @@ -4,8 +4,8 @@ import { Observable } from 'rxjs' import { BigNumber } from 'bignumber.js' import withLibcore from 'helpers/withLibcore' import { createCommand, Command } from 'helpers/ipc' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' -import { getWalletName } from '@ledgerhq/live-common/lib/helpers/account' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' +import { getWalletName } from '@ledgerhq/live-common/lib/account' import type { Account } from '@ledgerhq/live-common/lib/types' import { isValidAddress, diff --git a/src/commands/libcoreSignAndBroadcast.js b/src/commands/libcoreSignAndBroadcast.js index d6210ab2..98cd8ff5 100644 --- a/src/commands/libcoreSignAndBroadcast.js +++ b/src/commands/libcoreSignAndBroadcast.js @@ -4,10 +4,10 @@ import logger from 'logger' import { BigNumber } from 'bignumber.js' import Btc from '@ledgerhq/hw-app-btc' import { Observable } from 'rxjs' -import { isSegwitDerivationMode } from '@ledgerhq/live-common/lib/helpers/derivation' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { isSegwitDerivationMode } from '@ledgerhq/live-common/lib/derivation' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import type { OperationRaw, CryptoCurrency } from '@ledgerhq/live-common/lib/types' -import { getWalletName } from '@ledgerhq/live-common/lib/helpers/account' +import { getWalletName } from '@ledgerhq/live-common/lib/account' import { libcoreAmountToBigNumber, bigNumberToLibcoreAmount, diff --git a/src/commands/libcoreSyncAccount.js b/src/commands/libcoreSyncAccount.js index 525fe0c1..802428fa 100644 --- a/src/commands/libcoreSyncAccount.js +++ b/src/commands/libcoreSyncAccount.js @@ -1,7 +1,7 @@ // @flow import type { AccountRaw } from '@ledgerhq/live-common/lib/types' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { fromPromise } from 'rxjs/observable/fromPromise' import { createCommand, Command } from 'helpers/ipc' diff --git a/src/components/AccountPage/AccountHeaderActions.js b/src/components/AccountPage/AccountHeaderActions.js index f5e70459..cb3510dd 100644 --- a/src/components/AccountPage/AccountHeaderActions.js +++ b/src/components/AccountPage/AccountHeaderActions.js @@ -7,7 +7,7 @@ import { translate } from 'react-i18next' import styled from 'styled-components' import type { Account } from '@ledgerhq/live-common/lib/types' import Tooltip from 'components/base/Tooltip' -import { isAccountEmpty } from '@ledgerhq/live-common/lib/helpers/account' +import { isAccountEmpty } from '@ledgerhq/live-common/lib/account' import { MODAL_SEND, MODAL_RECEIVE, MODAL_SETTINGS_ACCOUNT } from 'config/constants' diff --git a/src/components/AccountPage/index.js b/src/components/AccountPage/index.js index 4404c8fa..f065da0e 100644 --- a/src/components/AccountPage/index.js +++ b/src/components/AccountPage/index.js @@ -8,7 +8,7 @@ import { Redirect } from 'react-router' import type { Currency, Account } from '@ledgerhq/live-common/lib/types' import type { T } from 'types/common' import { accountSelector } from 'reducers/accounts' -import { isAccountEmpty } from '@ledgerhq/live-common/lib/helpers/account' +import { isAccountEmpty } from '@ledgerhq/live-common/lib/account' import { counterValueCurrencySelector, localeSelector, diff --git a/src/components/BalanceSummary/index.js b/src/components/BalanceSummary/index.js index 2390b163..c3567391 100644 --- a/src/components/BalanceSummary/index.js +++ b/src/components/BalanceSummary/index.js @@ -3,7 +3,7 @@ import React, { Fragment } from 'react' import { BigNumber } from 'bignumber.js' import moment from 'moment' -import { formatShort } from '@ledgerhq/live-common/lib/helpers/currencies' +import { formatShort } from '@ledgerhq/live-common/lib/currencies' import type { Currency, Account } from '@ledgerhq/live-common/lib/types' import Chart from 'components/base/Chart' diff --git a/src/components/BalanceSummary/stories.js b/src/components/BalanceSummary/stories.js index a0141014..c9289320 100644 --- a/src/components/BalanceSummary/stories.js +++ b/src/components/BalanceSummary/stories.js @@ -4,7 +4,7 @@ import React from 'react' import { storiesOf } from '@storybook/react' import { number } from '@storybook/addon-knobs' import { translate } from 'react-i18next' -import { getFiatCurrencyByTicker } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getFiatCurrencyByTicker } from '@ledgerhq/live-common/lib/currencies' import BalanceInfos from './BalanceInfos' diff --git a/src/components/CalculateBalance.js b/src/components/CalculateBalance.js index 001e6701..84b547b8 100644 --- a/src/components/CalculateBalance.js +++ b/src/components/CalculateBalance.js @@ -6,7 +6,7 @@ import { connect } from 'react-redux' import { BigNumber } from 'bignumber.js' import type { Account } from '@ledgerhq/live-common/lib/types' -import { getBalanceHistorySum } from '@ledgerhq/live-common/lib/helpers/account' +import { getBalanceHistorySum } from '@ledgerhq/live-common/lib/account' import CounterValues from 'helpers/countervalues' import { exchangeSettingsForAccountSelector, diff --git a/src/components/CounterValue/stories.js b/src/components/CounterValue/stories.js index 8a5bce2b..34b4aa24 100644 --- a/src/components/CounterValue/stories.js +++ b/src/components/CounterValue/stories.js @@ -1,7 +1,7 @@ // @flow import React from 'react' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { storiesOf } from '@storybook/react' import { number } from '@storybook/addon-knobs' diff --git a/src/components/CurrentAddress/index.js b/src/components/CurrentAddress/index.js index e501d9ad..9b7c6dd6 100644 --- a/src/components/CurrentAddress/index.js +++ b/src/components/CurrentAddress/index.js @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react' import { Trans, translate } from 'react-i18next' import styled from 'styled-components' -import { encodeURIScheme } from '@ledgerhq/live-common/lib/helpers/currencies' +import { encodeURIScheme } from '@ledgerhq/live-common/lib/currencies' import type { Account } from '@ledgerhq/live-common/lib/types' import noop from 'lodash/noop' diff --git a/src/components/EnsureDeviceApp.js b/src/components/EnsureDeviceApp.js index af71d6cd..1d300a98 100644 --- a/src/components/EnsureDeviceApp.js +++ b/src/components/EnsureDeviceApp.js @@ -14,7 +14,7 @@ import { isSegwitDerivationMode, getDerivationScheme, runDerivationScheme, -} from '@ledgerhq/live-common/lib/helpers/derivation' +} from '@ledgerhq/live-common/lib/derivation' import DeviceInteraction from 'components/DeviceInteraction' import Text from 'components/base/Text' @@ -125,7 +125,7 @@ async function getAddressFromAccountOrCurrency(device, account, currency) { currencyId: currency.id, path: account ? account.freshAddressPath - : runDerivationScheme(getDerivationScheme({ currency, derivationMode: '' })), + : runDerivationScheme(getDerivationScheme({ currency, derivationMode: '' }), currency), segwit: account ? isSegwitDerivationMode(account.derivationMode) : false, }) .toPromise() diff --git a/src/components/OperationsList/AmountCell.js b/src/components/OperationsList/AmountCell.js index 56ca5bba..ac332fa2 100644 --- a/src/components/OperationsList/AmountCell.js +++ b/src/components/OperationsList/AmountCell.js @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react' import styled from 'styled-components' -import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/helpers/operation' +import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/operation' import type { Currency, Unit, Operation } from '@ledgerhq/live-common/lib/types' import Box from 'components/base/Box' import CounterValue from 'components/CounterValue' diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index c7e70fe4..9debc44f 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -8,7 +8,7 @@ import { translate } from 'react-i18next' import { groupAccountOperationsByDay, groupAccountsOperationsByDay, -} from '@ledgerhq/live-common/lib/helpers/account' +} from '@ledgerhq/live-common/lib/account' import type { Operation, Account } from '@ledgerhq/live-common/lib/types' diff --git a/src/components/QRCodeExporter.js b/src/components/QRCodeExporter.js index d81375d2..705ecaa6 100644 --- a/src/components/QRCodeExporter.js +++ b/src/components/QRCodeExporter.js @@ -7,7 +7,7 @@ import { connect } from 'react-redux' import { accountsSelector } from 'reducers/accounts' import { exportSettingsSelector } from 'reducers/settings' -import { encode } from '@ledgerhq/live-common/lib/bridgestream' +import { encode } from '@ledgerhq/live-common/lib/cross' import { dataToFrames } from 'qrloop/exporter' import QRCode from './base/QRCode' @@ -21,8 +21,9 @@ const mapStateToProps = createSelector( settings, exporterName: 'desktop', exporterVersion: __APP_VERSION__, - chunkSize: 120, }), + 200, + 4, ), }), ) @@ -38,12 +39,12 @@ class QRCodeExporter extends PureComponent< }, > { static defaultProps = { - size: 440, + size: 460, } state = { frame: 0, - fps: 5, + fps: 3, } componentDidMount() { diff --git a/src/components/RecipientAddress/index.js b/src/components/RecipientAddress/index.js index b8f5b74a..a35b48b2 100644 --- a/src/components/RecipientAddress/index.js +++ b/src/components/RecipientAddress/index.js @@ -4,7 +4,7 @@ import type { BigNumber } from 'bignumber.js' import React, { PureComponent, Fragment } from 'react' import styled from 'styled-components' import noop from 'lodash/noop' -import { decodeURIScheme } from '@ledgerhq/live-common/lib/helpers/currencies' +import { decodeURIScheme } from '@ledgerhq/live-common/lib/currencies' import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' import { radii } from 'styles/theme' diff --git a/src/components/SettingsPage/CounterValueSelect.js b/src/components/SettingsPage/CounterValueSelect.js index 647cbeca..028b27ce 100644 --- a/src/components/SettingsPage/CounterValueSelect.js +++ b/src/components/SettingsPage/CounterValueSelect.js @@ -3,7 +3,7 @@ import React, { Fragment, PureComponent } from 'react' import { connect } from 'react-redux' import { createStructuredSelector } from 'reselect' -import { listFiatCurrencies } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listFiatCurrencies } from '@ledgerhq/live-common/lib/currencies' import type { Currency } from '@ledgerhq/live-common/lib/types' import { setCounterValue } from 'actions/settings' import { counterValueCurrencySelector } from 'reducers/settings' diff --git a/src/components/SettingsPage/sections/Tools.js b/src/components/SettingsPage/sections/Tools.js index ca510879..334b8ee3 100644 --- a/src/components/SettingsPage/sections/Tools.js +++ b/src/components/SettingsPage/sections/Tools.js @@ -25,9 +25,11 @@ class TabProfile extends PureComponent<*, *> { renderQRCodeModal = ({ onClose }: any) => ( {'QRCode Mobile Export'} - + Scan this animated QRCode with Ledger Live Mobile App - + + + ) diff --git a/src/components/base/Chart/handleMouseEvents.js b/src/components/base/Chart/handleMouseEvents.js index 99f32a80..2eb0b8d0 100644 --- a/src/components/base/Chart/handleMouseEvents.js +++ b/src/components/base/Chart/handleMouseEvents.js @@ -5,7 +5,7 @@ import * as d3 from 'd3' import { renderToString } from 'react-dom/server' import { ThemeProvider } from 'styled-components' import { Provider } from 'react-redux' -import { getFiatCurrencyByTicker } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getFiatCurrencyByTicker } from '@ledgerhq/live-common/lib/currencies' import createStore from 'renderer/createStore' diff --git a/src/components/base/Chart/stories.js b/src/components/base/Chart/stories.js index ea324268..2047236c 100644 --- a/src/components/base/Chart/stories.js +++ b/src/components/base/Chart/stories.js @@ -2,7 +2,7 @@ import React, { Component, Fragment } from 'react' import { BigNumber } from 'bignumber.js' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import Chance from 'chance' import moment from 'moment' import { storiesOf } from '@storybook/react' diff --git a/src/components/base/FlipTicker/stories.js b/src/components/base/FlipTicker/stories.js index 17449692..cfafa761 100644 --- a/src/components/base/FlipTicker/stories.js +++ b/src/components/base/FlipTicker/stories.js @@ -4,10 +4,7 @@ import React, { Component } from 'react' import { BigNumber } from 'bignumber.js' import { storiesOf } from '@storybook/react' -import { - formatCurrencyUnit, - getFiatCurrencyByTicker, -} from '@ledgerhq/live-common/lib/helpers/currencies' +import { formatCurrencyUnit, getFiatCurrencyByTicker } from '@ledgerhq/live-common/lib/currencies' import Chance from 'chance' import Box from 'components/base/Box' diff --git a/src/components/base/FormattedVal/index.js b/src/components/base/FormattedVal/index.js index 3f6efff6..5afd4ae9 100644 --- a/src/components/base/FormattedVal/index.js +++ b/src/components/base/FormattedVal/index.js @@ -9,7 +9,7 @@ import { connect } from 'react-redux' import type { Unit } from '@ledgerhq/live-common/lib/types' import type { State } from 'reducers' -import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/helpers/currencies' +import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/currencies' import { marketIndicatorSelector, localeSelector } from 'reducers/settings' diff --git a/src/components/base/InputCurrency/index.js b/src/components/base/InputCurrency/index.js index 4dc14b80..a0d59306 100644 --- a/src/components/base/InputCurrency/index.js +++ b/src/components/base/InputCurrency/index.js @@ -4,7 +4,7 @@ import React, { PureComponent } from 'react' import { BigNumber } from 'bignumber.js' import uncontrollable from 'uncontrollable' import styled from 'styled-components' -import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/helpers/currencies' +import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/currencies' import noop from 'lodash/noop' diff --git a/src/components/base/InputCurrency/stories.js b/src/components/base/InputCurrency/stories.js index 0b0f9bed..ec451421 100644 --- a/src/components/base/InputCurrency/stories.js +++ b/src/components/base/InputCurrency/stories.js @@ -5,7 +5,7 @@ import { storiesOf } from '@storybook/react' import { action } from '@storybook/addon-actions' import { boolean } from '@storybook/addon-knobs' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import InputCurrency from 'components/base/InputCurrency' const stories = storiesOf('Components', module) diff --git a/src/components/base/QRCode/index.js b/src/components/base/QRCode/index.js index a8d034c0..7066c2b0 100644 --- a/src/components/base/QRCode/index.js +++ b/src/components/base/QRCode/index.js @@ -23,22 +23,39 @@ class QRCode extends PureComponent { this.drawQRCode() } - _canvas = null + canvas = React.createRef() drawQRCode() { const { data, size, errorCorrectionLevel } = this.props - qrcode.toCanvas(this._canvas, data, { - width: size, - margin: 0, - errorCorrectionLevel, - color: { - light: '#ffffff00', // transparent background + const { current } = this.canvas + if (!current) return + qrcode.toCanvas( + current, + data, + { + width: current.width, + margin: 0, + errorCorrectionLevel, }, - }) + () => { + // fix again the CSS because lib changes it –_– + current.style.width = `${size}px` + current.style.height = `${size}px` + }, + ) } render() { - return (this._canvas = n)} /> + const { size } = this.props + const px = size * (window.devicePixelRatio || 1) + return ( + + ) } } diff --git a/src/components/modals/AccountSettingRenderBody.js b/src/components/modals/AccountSettingRenderBody.js index 90c21665..ae029eb2 100644 --- a/src/components/modals/AccountSettingRenderBody.js +++ b/src/components/modals/AccountSettingRenderBody.js @@ -10,7 +10,7 @@ import { translate } from 'react-i18next' import type { Account, Unit, Currency } 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/helpers/account' +import { validateNameEdition } from '@ledgerhq/live-common/lib/account' import { updateAccount, removeAccount } from 'actions/accounts' import { setDataModal } from 'reducers/modals' diff --git a/src/components/modals/AddAccounts/index.js b/src/components/modals/AddAccounts/index.js index 85dd42ca..a9f8fff9 100644 --- a/src/components/modals/AddAccounts/index.js +++ b/src/components/modals/AddAccounts/index.js @@ -23,7 +23,7 @@ import { closeModal } from 'reducers/modals' import Modal from 'components/base/Modal' import Stepper from 'components/base/Stepper' -import { validateNameEdition } from '@ledgerhq/live-common/lib/helpers/account' +import { validateNameEdition } from '@ledgerhq/live-common/lib/account' import StepChooseCurrency, { StepChooseCurrencyFooter } from './steps/01-step-choose-currency' import StepConnectDevice, { StepConnectDeviceFooter } from './steps/02-step-connect-device' diff --git a/src/components/modals/AddAccounts/steps/03-step-import.js b/src/components/modals/AddAccounts/steps/03-step-import.js index 115664c3..4d2ef811 100644 --- a/src/components/modals/AddAccounts/steps/03-step-import.js +++ b/src/components/modals/AddAccounts/steps/03-step-import.js @@ -10,7 +10,7 @@ import uniq from 'lodash/uniq' import { urls } from 'config/urls' import ExternalLinkButton from 'components/base/ExternalLinkButton' import RetryButton from 'components/base/RetryButton' -import { isAccountEmpty } from '@ledgerhq/live-common/lib/helpers/account' +import { isAccountEmpty } from '@ledgerhq/live-common/lib/account' import { getBridgeForCurrency } from 'bridge' diff --git a/src/components/modals/Debug.js b/src/components/modals/Debug.js index e092c1b2..8ed42391 100644 --- a/src/components/modals/Debug.js +++ b/src/components/modals/Debug.js @@ -3,11 +3,8 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import { createStructuredSelector } from 'reselect' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' -import { - getDerivationScheme, - runDerivationScheme, -} from '@ledgerhq/live-common/lib/helpers/derivation' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' +import { getDerivationScheme, runDerivationScheme } from '@ledgerhq/live-common/lib/derivation' import Modal, { ModalBody, ModalTitle, ModalContent } from 'components/base/Modal' import { getCurrentDevice } from 'reducers/devices' import Button from 'components/base/Button' @@ -53,7 +50,7 @@ class Debug extends Component<*, *> { for (let x = 0; x < 20; x++) { const { address, path } = await getAddress .send({ - path: runDerivationScheme(derivationScheme, { account: x }), + path: runDerivationScheme(derivationScheme, currency, { account: x }), currencyId: currency.id, devicePath: device.path, }) @@ -104,7 +101,7 @@ class Debug extends Component<*, *> { derivationMode: 'segwit', }) const obj = { - path: runDerivationScheme(derivationScheme), + path: runDerivationScheme(derivationScheme, currency), currencyId: currency.id, devicePath: device.path, } diff --git a/src/components/modals/OperationDetails.js b/src/components/modals/OperationDetails.js index 81ee58c3..cd314022 100644 --- a/src/components/modals/OperationDetails.js +++ b/src/components/modals/OperationDetails.js @@ -6,7 +6,7 @@ import { openURL } from 'helpers/linking' import { translate } from 'react-i18next' import styled from 'styled-components' import moment from 'moment' -import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/helpers/operation' +import { getOperationAmountNumber } from '@ledgerhq/live-common/lib/operation' import { getAccountOperationExplorer } from '@ledgerhq/live-common/lib/explorers' import uniq from 'lodash/uniq' diff --git a/src/components/modals/Receive/steps/04-step-receive-funds.js b/src/components/modals/Receive/steps/04-step-receive-funds.js index 63502cec..59e1cf37 100644 --- a/src/components/modals/Receive/steps/04-step-receive-funds.js +++ b/src/components/modals/Receive/steps/04-step-receive-funds.js @@ -5,7 +5,7 @@ import React, { PureComponent } from 'react' import TrackPage from 'analytics/TrackPage' import getAddress from 'commands/getAddress' -import { isSegwitDerivationMode } from '@ledgerhq/live-common/lib/helpers/derivation' +import { isSegwitDerivationMode } from '@ledgerhq/live-common/lib/derivation' import Box from 'components/base/Box' import CurrentAddressForAccount from 'components/CurrentAddressForAccount' import { DisconnectedDevice, WrongDeviceForAccount } from 'config/errors' diff --git a/src/config/cryptocurrencies.js b/src/config/cryptocurrencies.js index 2667ddb7..4c6d1ea5 100644 --- a/src/config/cryptocurrencies.js +++ b/src/config/cryptocurrencies.js @@ -1,6 +1,6 @@ // @flow import memoize from 'lodash/memoize' -import { listCryptoCurrencies as listCC } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listCryptoCurrencies as listCC } from '@ledgerhq/live-common/lib/currencies' import type { CryptoCurrencyIds } from '@ledgerhq/live-common/lib/types' const supported: CryptoCurrencyIds[] = [ diff --git a/src/helpers/accountModel.js b/src/helpers/accountModel.js index 622a8bc2..dc1d20cd 100644 --- a/src/helpers/accountModel.js +++ b/src/helpers/accountModel.js @@ -3,7 +3,7 @@ * @flow */ import { BigNumber } from 'bignumber.js' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { createDataModel } from '@ledgerhq/live-common/lib/DataModel' import type { DataModel } from '@ledgerhq/live-common/lib/DataModel' import type { Account, AccountRaw, Operation } from '@ledgerhq/live-common/lib/types' @@ -73,7 +73,6 @@ const accountModel: DataModel = createDataModel({ } const id = `${type}:${version}:${currencyId}:${xpubOrAddress}:${derivationMode}` - console.log({ old: raw, id, derivationMode, seedIdentifier }) return { ...raw, id, diff --git a/src/helpers/countervalues.js b/src/helpers/countervalues.js index 1f45137c..fd5fc37e 100644 --- a/src/helpers/countervalues.js +++ b/src/helpers/countervalues.js @@ -12,7 +12,7 @@ import { intermediaryCurrency, } from 'reducers/settings' import logger from 'logger' -import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/helpers/currencies' +import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/currencies' import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' const pairsSelector = createSelector( diff --git a/src/helpers/libcore.js b/src/helpers/libcore.js index 3b76b4b1..93467443 100644 --- a/src/helpers/libcore.js +++ b/src/helpers/libcore.js @@ -7,17 +7,18 @@ import { BigNumber } from 'bignumber.js' import Btc from '@ledgerhq/hw-app-btc' import { withDevice } from 'helpers/deviceAccess' import { + getDerivationModesForCurrency, getDerivationScheme, isSegwitDerivationMode, isUnsplitDerivationMode, -} from '@ledgerhq/live-common/lib/helpers/derivation' -import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' +} from '@ledgerhq/live-common/lib/derivation' +import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies' import { encodeAccountId, getNewAccountPlaceholderName, getAccountPlaceholderName, getWalletName, -} from '@ledgerhq/live-common/lib/helpers/account' +} from '@ledgerhq/live-common/lib/account' import { SHOW_LEGACY_NEW_ACCOUNT, SYNC_TIMEOUT } from 'config/constants' import type { @@ -45,55 +46,30 @@ type Props = { isUnsubscribed: () => boolean, } +const shouldShowNewAccount = (currency, derivationMode) => + derivationMode === '' + ? !!SHOW_LEGACY_NEW_ACCOUNT || !currency.supportsSegwit + : derivationMode === 'segwit' + export async function scanAccountsOnDevice(props: Props): Promise { const { devicePath, currencyId, onAccountScanned, core, isUnsubscribed } = props const currency = getCryptoCurrencyById(currencyId) - const commonParams = { - core, - currency, - onAccountScanned, - devicePath, - isUnsubscribed, - } - let allAccounts = [] - // TODO use getDerivationModesForCurrency - // introduce an internal shouldShowNewAccount({currency, derivationMode}) - - const nonSegwitAccounts = await scanAccountsOnDeviceBySegwit({ - ...commonParams, - showNewAccount: !!SHOW_LEGACY_NEW_ACCOUNT || !currency.supportsSegwit, - derivationMode: '', - }) - allAccounts = allAccounts.concat(nonSegwitAccounts) - - if (currency.supportsSegwit) { - const segwitAccounts = await scanAccountsOnDeviceBySegwit({ - ...commonParams, - derivationMode: 'segwit', - showNewAccount: true, - }) - allAccounts = allAccounts.concat(segwitAccounts) - } - - if (currency.forkedFrom) { - const splittedAccounts = await scanAccountsOnDeviceBySegwit({ - ...commonParams, - derivationMode: 'unsplit', - showNewAccount: false, + const derivationModes = getDerivationModesForCurrency(currency) + for (let i = 0; i < derivationModes.length; i++) { + const derivationMode = derivationModes[i] + const accounts = await scanAccountsOnDeviceBySegwit({ + core, + currency, + onAccountScanned, + devicePath, + isUnsubscribed, + showNewAccount: shouldShowNewAccount(currency, derivationMode), + derivationMode, }) - allAccounts = allAccounts.concat(splittedAccounts) - - if (currency.supportsSegwit) { - const segwitAccounts = await scanAccountsOnDeviceBySegwit({ - ...commonParams, - derivationMode: 'segwit_unsplit', - showNewAccount: false, - }) - allAccounts = allAccounts.concat(segwitAccounts) - } + allAccounts = allAccounts.concat(accounts) } return allAccounts diff --git a/src/reducers/settings.js b/src/reducers/settings.js index 445f929c..a62f81a8 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -5,7 +5,7 @@ import { findCurrencyByTicker, getCryptoCurrencyById, getFiatCurrencyByTicker, -} from '@ledgerhq/live-common/lib/helpers/currencies' +} from '@ledgerhq/live-common/lib/currencies' import { listCryptoCurrencies } from 'config/cryptocurrencies' import languages from 'config/languages' import { createSelector } from 'reselect' diff --git a/yarn.lock b/yarn.lock index 5793dd1c..e076ec19 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1487,6 +1487,13 @@ core-js "^2.5.6" regenerator-runtime "^0.11.1" +"@babel/runtime@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3" + integrity sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg== + dependencies: + regenerator-runtime "^0.12.0" + "@babel/template@7.0.0-beta.44": version "7.0.0-beta.44" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" @@ -1738,23 +1745,10 @@ bindings "^1.3.0" nan "^2.6.2" -"@ledgerhq/live-common@/Users/gre/dev/ledger-live-common": - version "3.8.0" - dependencies: - axios "^0.18.0" - bignumber.js "^7.2.1" - invariant "^2.2.2" - lodash "^4.17.4" - node-lzw "^0.3.1" - numeral "^2.0.6" - prando "^3.0.1" - react "^16.4.0" - react-redux "^5.0.7" - redux "^4.0.0" - reselect "^3.0.1" - -"@ledgerhq/live-common@file:../ledger-live-common": - version "3.8.0" +"@ledgerhq/live-common@4.0.0-beta.1": + version "4.0.0-beta.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.0.0-beta.1.tgz#52ed90757761a08a5f5c9c40c1fed0cb2f1fb4ca" + integrity sha512-Ms06Za/EI8yP/4GOAziCMecqIssZbkS5tjSCgaqd1h0zHLzM6i6PvgjhJyvG5SrET6+uQVp4YM4qbo2tc6irjQ== dependencies: axios "^0.18.0" bignumber.js "^7.2.1" @@ -1764,6 +1758,7 @@ numeral "^2.0.6" prando "^3.0.1" react "^16.4.0" + react-i18next "^8.0.7" react-redux "^5.0.7" redux "^4.0.0" reselect "^3.0.1" @@ -5518,6 +5513,14 @@ create-react-class@^15.5.2, create-react-class@^15.6.2: loose-envify "^1.3.1" object-assign "^4.1.1" +create-react-context@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.3.tgz#9ec140a6914a22ef04b8b09b7771de89567cb6f3" + integrity sha512-CQBmD0+QGgTaxDL3OX1IDXYqjkp2It4RIbcb99jS6AEg27Ga+a9G3JtK6SIu0HBwPLZlmwt9F7UwWA4Bn92Rag== + dependencies: + fbjs "^0.8.0" + gud "^1.0.0" + crocket@^0.9.11: version "0.9.11" resolved "https://registry.yarnpkg.com/crocket/-/crocket-0.9.11.tgz#288fca11ef0d3dd239b62c488265f30c8edfb0c5" @@ -7707,7 +7710,7 @@ fb-watchman@^2.0.0: dependencies: bser "^2.0.0" -fbjs@^0.8.12, fbjs@^0.8.16, fbjs@^0.8.5, fbjs@^0.8.9: +fbjs@^0.8.0, fbjs@^0.8.12, fbjs@^0.8.16, fbjs@^0.8.5, fbjs@^0.8.9: version "0.8.17" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd" integrity sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90= @@ -8470,6 +8473,11 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= +gud@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" + integrity sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw== + gzip-size@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520" @@ -8696,6 +8704,13 @@ hoist-non-react-statics@1.x.x, hoist-non-react-statics@^1.2.0: resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb" integrity sha1-qkSM8JhtVcxAdzsXF0t90GbLfPs= +hoist-non-react-statics@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.0.1.tgz#fba3e7df0210eb9447757ca1a7cb607162f0a364" + integrity sha512-1kXwPsOi0OGQIZNVMPvgWJ9tSnGMiMfJdihqEzrPEXlHOBh9AAHXX/QYmAJTXztnz/K+PQ8ryCb4eGaN6HlGbQ== + dependencies: + react-is "^16.3.2" + hoist-non-react-statics@^2.3.1, hoist-non-react-statics@^2.5.0: version "2.5.5" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" @@ -13094,6 +13109,16 @@ react-i18next@^7.7.0: html-parse-stringify2 "2.0.1" prop-types "^15.6.0" +react-i18next@^8.0.7: + version "8.0.7" + resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-8.0.7.tgz#9e6ffdaa01f4454ba216fa50377a7c2ba6f1e662" + integrity sha512-oJDVe5X8QK72NYYH7/VQtopONZPcNiarlWdVuCSkn9PucQCEAOf/yRt0V2LdjC4nBY48Y20/540glwR1nlE9gA== + dependencies: + "@babel/runtime" "^7.1.2" + create-react-context "0.2.3" + hoist-non-react-statics "3.0.1" + html-parse-stringify2 "2.0.1" + react-icon-base@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/react-icon-base/-/react-icon-base-2.1.0.tgz#a196e33fdf1e7aaa1fda3aefbb68bdad9e82a79d" @@ -13126,6 +13151,11 @@ react-is@^16.3.1, react-is@^16.4.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.4.1.tgz#d624c4650d2c65dbd52c72622bbf389435d9776e" integrity sha512-xpb0PpALlFWNw/q13A+1aHeyJyLYCg0/cCHPUA43zYluZuIPHaHL3k8OBsTgQtxqW0FhyDEMvi8fZ/+7+r4OSQ== +react-is@^16.3.2: + version "16.5.2" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.5.2.tgz#e2a7b7c3f5d48062eb769fcb123505eb928722e3" + integrity sha512-hSl7E6l25GTjNEZATqZIuWOgSnpXb3kD0DVCujmg46K5zLxsbiKaaT6VO9slkSBDPZfYs30lwfJwbOFOnoEnKQ== + react-key-handler@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/react-key-handler/-/react-key-handler-1.0.1.tgz#1fc0f4f4855f506a192c2cbe9fe8cb78fc553191" @@ -13610,6 +13640,11 @@ regenerator-runtime@^0.11.0, regenerator-runtime@^0.11.1: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== +regenerator-runtime@^0.12.0: + version "0.12.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" + integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== + regenerator-transform@^0.10.0: version "0.10.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd"