Browse Source

add new derivations & isIterable system

gre-patch-1
Gaëtan Renaudeau 6 years ago
parent
commit
b400ba7264
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 4
      package.json
  2. 4
      src/bridge/EthereumJSBridge.js
  3. 4
      src/bridge/RippleJSBridge.js
  4. 4
      src/commands/libcoreGetFees.js
  5. 4
      src/commands/libcoreScanFromXPUB.js
  6. 8
      src/commands/libcoreSignAndBroadcast.js
  7. 4
      src/commands/libcoreSyncAccount.js
  8. 4
      src/components/modals/AddAccounts/steps/03-step-import.js
  9. 2
      src/helpers/countervalues.js
  10. 20
      src/helpers/libcore.js
  11. 24
      yarn.lock

4
package.json

@ -37,11 +37,11 @@
"dependencies": {
"@ledgerhq/hw-app-btc": "4.24.0",
"@ledgerhq/hw-app-eth": "^4.24.0",
"@ledgerhq/hw-app-xrp": "^4.24.0",
"@ledgerhq/hw-app-xrp": "^4.25.0",
"@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": "4.0.0-beta.1",
"@ledgerhq/live-common": "4.1.3",
"animated": "^0.2.2",
"async": "^2.6.1",
"axios": "^0.18.0",

4
src/bridge/EthereumJSBridge.js

@ -12,6 +12,7 @@ import {
getDerivationModesForCurrency,
getDerivationScheme,
runDerivationScheme,
isIterableDerivationMode,
getMandatoryEmptyAccountSkip,
} from '@ledgerhq/live-common/lib/derivation'
import {
@ -304,7 +305,8 @@ const EthereumBridge: WalletBridge<Transaction> = {
let emptyCount = 0
const mandatoryEmptyAccountSkip = getMandatoryEmptyAccountSkip(derivationMode)
const derivationScheme = getDerivationScheme({ derivationMode, currency })
for (let index = 0; index < 255; index++) {
const stopAt = isIterableDerivationMode(derivationMode) ? 255 : 1
for (let index = 0; index < stopAt; index++) {
const freshAddressPath = runDerivationScheme(derivationScheme, currency, {
account: index,
})

4
src/bridge/RippleJSBridge.js

@ -11,6 +11,7 @@ import {
getDerivationModesForCurrency,
getDerivationScheme,
runDerivationScheme,
isIterableDerivationMode,
} from '@ledgerhq/live-common/lib/derivation'
import {
getAccountPlaceholderName,
@ -299,7 +300,8 @@ const RippleJSBridge: WalletBridge<Transaction> = {
const derivationModes = getDerivationModesForCurrency(currency)
for (const derivationMode of derivationModes) {
const derivationScheme = getDerivationScheme({ derivationMode, currency })
for (let index = 0; index < 255; index++) {
const stopAt = isIterableDerivationMode(derivationMode) ? 255 : 1
for (let index = 0; index < stopAt; index++) {
const freshAddressPath = runDerivationScheme(derivationScheme, currency, {
account: index,
})

4
src/commands/libcoreGetFees.js

@ -6,7 +6,7 @@ import withLibcore from 'helpers/withLibcore'
import { createCommand, Command } from 'helpers/ipc'
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 type { Account, DerivationMode } from '@ledgerhq/live-common/lib/types'
import {
isValidAddress,
libcoreAmountToBigNumber,
@ -26,7 +26,7 @@ type Input = {
accountIndex: number,
transaction: BitcoinLikeTransaction,
currencyId: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
}

4
src/commands/libcoreScanFromXPUB.js

@ -1,7 +1,7 @@
// @flow
import { fromPromise } from 'rxjs/observable/fromPromise'
import type { AccountRaw } from '@ledgerhq/live-common/lib/types'
import type { AccountRaw, DerivationMode } from '@ledgerhq/live-common/lib/types'
import { createCommand, Command } from 'helpers/ipc'
import withLibcore from 'helpers/withLibcore'
@ -10,7 +10,7 @@ import { scanAccountsFromXPUB } from 'helpers/libcore'
type Input = {
currencyId: string,
xpub: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
}

8
src/commands/libcoreSignAndBroadcast.js

@ -6,7 +6,7 @@ import Btc from '@ledgerhq/hw-app-btc'
import { Observable } from 'rxjs'
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 type { OperationRaw, DerivationMode, CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import { getWalletName } from '@ledgerhq/live-common/lib/account'
import {
libcoreAmountToBigNumber,
@ -27,7 +27,7 @@ type BitcoinLikeTransaction = {
type Input = {
accountId: string,
currencyId: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
xpub: string,
index: number,
@ -87,7 +87,7 @@ async function signTransaction({
hwApp: Btc,
currency: CryptoCurrency,
transaction: *,
derivationMode: string,
derivationMode: DerivationMode,
sigHashType: number,
hasTimestamp: boolean,
}) {
@ -178,7 +178,7 @@ export async function doSignAndBroadcast({
onOperationBroadcasted,
}: {
accountId: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
currency: CryptoCurrency,
xpub: string,

4
src/commands/libcoreSyncAccount.js

@ -1,6 +1,6 @@
// @flow
import type { AccountRaw } from '@ledgerhq/live-common/lib/types'
import type { AccountRaw, DerivationMode } from '@ledgerhq/live-common/lib/types'
import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies'
import { fromPromise } from 'rxjs/observable/fromPromise'
@ -12,7 +12,7 @@ type Input = {
accountId: string,
currencyId: string,
xpub: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
index: number,
}

4
src/components/modals/AddAccounts/steps/03-step-import.js

@ -144,7 +144,9 @@ class StepImport extends PureComponent<StepProps> {
})
}
},
complete: () => setScanStatus('finished'),
complete: () => {
setScanStatus('finished')
},
error: err => {
logger.critical(err)
setScanStatus('error', err)

2
src/helpers/countervalues.js

@ -14,6 +14,7 @@ import {
import logger from 'logger'
import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/currencies'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import network from '../api/network'
const pairsSelector = createSelector(
currenciesSelector,
@ -62,6 +63,7 @@ const CounterValues = createCounterValues({
pairsSelector,
setExchangePairsAction,
addExtraPollingHooks,
network,
})
let sortCache

20
src/helpers/libcore.js

@ -11,6 +11,7 @@ import {
getDerivationScheme,
isSegwitDerivationMode,
isUnsplitDerivationMode,
isIterableDerivationMode,
} from '@ledgerhq/live-common/lib/derivation'
import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/currencies'
import {
@ -26,6 +27,7 @@ import type {
AccountRaw,
OperationRaw,
OperationType,
DerivationMode,
} from '@ledgerhq/live-common/lib/types'
import type { NJSAccount, NJSOperation } from '@ledgerhq/ledger-core/src/ledgercore_doc'
@ -89,7 +91,7 @@ async function scanAccountsOnDeviceBySegwit({
currency: CryptoCurrency,
onAccountScanned: AccountRaw => void,
isUnsubscribed: () => boolean,
derivationMode: string,
derivationMode: DerivationMode,
showNewAccount: boolean,
}): Promise<AccountRaw[]> {
const isSegwit = isSegwitDerivationMode(derivationMode)
@ -201,7 +203,7 @@ async function scanNextAccount(props: {
devicePath: string,
currency: CryptoCurrency,
seedIdentifier: string,
derivationMode: string,
derivationMode: DerivationMode,
accountsCount: number,
accountIndex: number,
accounts: AccountRaw[],
@ -259,15 +261,15 @@ async function scanNextAccount(props: {
if (isUnsubscribed()) return []
const isEmpty = ops.length === 0
const isLast = ops.length === 0 || !isIterableDerivationMode(derivationMode)
if (!isEmpty || showNewAccount) {
if (!isLast || showNewAccount) {
onAccountScanned(account)
accounts.push(account)
}
// returns if the current index points on an account with no ops
if (isEmpty) {
if (isLast) {
return accounts
}
@ -292,7 +294,7 @@ export async function getOrCreateWallet(
derivationMode,
}: {
currency: CryptoCurrency,
derivationMode: string,
derivationMode: DerivationMode,
},
): NJSWallet {
const pool = core.getPoolInstance()
@ -335,7 +337,7 @@ async function buildAccountRaw({
seedIdentifier: string,
walletName: string,
currency: CryptoCurrency,
derivationMode: string,
derivationMode: DerivationMode,
accountIndex: number,
core: *,
ops: NJSOperation[],
@ -475,7 +477,7 @@ export async function syncAccount({
}: {
core: *,
xpub: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
currency: CryptoCurrency,
index: number,
@ -551,7 +553,7 @@ export async function scanAccountsFromXPUB({
core: *,
currencyId: string,
xpub: string,
derivationMode: string,
derivationMode: DerivationMode,
seedIdentifier: string,
}) {
const currency = getCryptoCurrencyById(currencyId)

24
yarn.lock

@ -1670,7 +1670,7 @@
camelcase "^5.0.0"
prettier "^1.13.7"
"@ledgerhq/hw-app-btc@4.24.0":
"@ledgerhq/hw-app-btc@4.24.0", "@ledgerhq/hw-app-btc@^4.24.0":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-btc/-/hw-app-btc-4.24.0.tgz#8889b2bc9b9583209ed24f832c96ea8d23e1dc74"
integrity sha512-OEc8UCcdAWp10PPM9Keoh8imuusmNVe2o/89ujMT5UIWOGCu7duezpsnCY11jGNxf2hyos6lezUMlUAOHBuISQ==
@ -1701,6 +1701,14 @@
"@ledgerhq/hw-transport" "^4.24.0"
bip32-path "0.4.2"
"@ledgerhq/hw-app-xrp@^4.25.0":
version "4.25.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-xrp/-/hw-app-xrp-4.25.0.tgz#d97d7e85290dd2d1ec99f85747a26145e7a7383e"
integrity sha512-kG9S8CxUFMG1hbLBiKtoPMquzlTigndDsxhoXB8oywAdbGsoCi2cufMHV2p5Bek6YlGfn5J5p49Hx5iNIf2y5Q==
dependencies:
"@ledgerhq/hw-transport" "^4.24.0"
bip32-path "0.4.2"
"@ledgerhq/hw-transport-node-hid@4.24.0":
version "4.24.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-4.24.0.tgz#8457969d66819e8f7f50d5dd96527ab26cd3787d"
@ -1745,13 +1753,17 @@
bindings "^1.3.0"
nan "^2.6.2"
"@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==
"@ledgerhq/live-common@4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-4.1.3.tgz#dbd5be04925b11b4bf646520fe01a8959554c561"
integrity sha512-4FZ6th8ZtpC0B20olsyqF9hb0VUhVkLeiO/QyWzKa+bdn7jt4PgOyUdaKbRuoW2w9UKj2qkXgIgBIaZ+l0AlJA==
dependencies:
axios "^0.18.0"
"@ledgerhq/hw-app-btc" "^4.24.0"
"@ledgerhq/hw-app-eth" "^4.24.0"
"@ledgerhq/hw-app-xrp" "^4.24.0"
"@ledgerhq/hw-transport" "^4.24.0"
bignumber.js "^7.2.1"
eip55 "^1.0.3"
invariant "^2.2.2"
lodash "^4.17.4"
node-lzw "^0.3.1"

Loading…
Cancel
Save