Browse Source

Bugfixes and polish

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
202f0b05ef
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 2
      package.json
  2. 2
      src/__mocks__/storybook-state.js
  3. 2
      src/actions/general.js
  4. 2
      src/api/Ripple.js
  5. 12
      src/bridge/EthereumJSBridge.js
  6. 12
      src/bridge/RippleJSBridge.js
  7. 4
      src/bridge/makeMockBridge.js
  8. 2
      src/commands/debugAppInfosForCurrency.js
  9. 2
      src/commands/getAddress.js
  10. 4
      src/commands/libcoreGetFees.js
  11. 6
      src/commands/libcoreSignAndBroadcast.js
  12. 2
      src/commands/libcoreSyncAccount.js
  13. 2
      src/components/AccountPage/AccountHeaderActions.js
  14. 2
      src/components/AccountPage/index.js
  15. 2
      src/components/BalanceSummary/index.js
  16. 2
      src/components/BalanceSummary/stories.js
  17. 2
      src/components/CalculateBalance.js
  18. 2
      src/components/CounterValue/stories.js
  19. 2
      src/components/CurrentAddress/index.js
  20. 4
      src/components/EnsureDeviceApp.js
  21. 2
      src/components/OperationsList/AmountCell.js
  22. 2
      src/components/OperationsList/index.js
  23. 9
      src/components/QRCodeExporter.js
  24. 2
      src/components/RecipientAddress/index.js
  25. 2
      src/components/SettingsPage/CounterValueSelect.js
  26. 6
      src/components/SettingsPage/sections/Tools.js
  27. 2
      src/components/base/Chart/handleMouseEvents.js
  28. 2
      src/components/base/Chart/stories.js
  29. 5
      src/components/base/FlipTicker/stories.js
  30. 2
      src/components/base/FormattedVal/index.js
  31. 2
      src/components/base/InputCurrency/index.js
  32. 2
      src/components/base/InputCurrency/stories.js
  33. 35
      src/components/base/QRCode/index.js
  34. 2
      src/components/modals/AccountSettingRenderBody.js
  35. 2
      src/components/modals/AddAccounts/index.js
  36. 2
      src/components/modals/AddAccounts/steps/03-step-import.js
  37. 11
      src/components/modals/Debug.js
  38. 2
      src/components/modals/OperationDetails.js
  39. 2
      src/components/modals/Receive/steps/04-step-receive-funds.js
  40. 2
      src/config/cryptocurrencies.js
  41. 3
      src/helpers/accountModel.js
  42. 2
      src/helpers/countervalues.js
  43. 66
      src/helpers/libcore.js
  44. 2
      src/reducers/settings.js
  45. 71
      yarn.lock

2
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",

2
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([

2
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,

2
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]

12
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<Transaction> = {
async function stepAddress(
index,
{ address, path: freshAddressPath, publicKey },
{ address, path: freshAddressPath },
derivationMode,
shouldSkipEmpty,
): { account?: Account, complete?: boolean } {
@ -230,7 +230,7 @@ const EthereumBridge: WalletBridge<Transaction> = {
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<Transaction> = {
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()

12
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<Transaction> = {
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 {

4
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'

2
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'

2
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'

4
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,

6
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,

2
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'

2
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'

2
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,

2
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'

2
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'

2
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,

2
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'

2
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'

4
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()

2
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'

2
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'

9
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() {

2
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'

2
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'

6
src/components/SettingsPage/sections/Tools.js

@ -25,9 +25,11 @@ class TabProfile extends PureComponent<*, *> {
renderQRCodeModal = ({ onClose }: any) => (
<ModalBody onClose={onClose} justify="center" align="center">
<ModalTitle>{'QRCode Mobile Export'}</ModalTitle>
<ModalContent flow={4}>
<ModalContent flow={2}>
<Box>Scan this animated QRCode with Ledger Live Mobile App</Box>
<QRCodeExporter />
<Box flow={2}>
<QRCodeExporter />
</Box>
</ModalContent>
</ModalBody>
)

2
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'

2
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'

5
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'

2
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'

2
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'

2
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)

35
src/components/base/QRCode/index.js

@ -23,22 +23,39 @@ class QRCode extends PureComponent<Props> {
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 <canvas style={{ cursor: 'none' }} ref={n => (this._canvas = n)} />
const { size } = this.props
const px = size * (window.devicePixelRatio || 1)
return (
<canvas
style={{ cursor: 'none', width: `${size}px`, height: `${size}px` }}
width={px}
height={px}
ref={this.canvas}
/>
)
}
}

2
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'

2
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'

2
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'

11
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,
}

2
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'

2
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'

2
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[] = [

3
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<AccountRaw, Account> = createDataModel({
}
const id = `${type}:${version}:${currencyId}:${xpubOrAddress}:${derivationMode}`
console.log({ old: raw, id, derivationMode, seedIdentifier })
return {
...raw,
id,

2
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(

66
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<AccountRaw[]> {
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

2
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'

71
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"

Loading…
Cancel
Save