Browse Source

Merge pull request #1609 from meriadec/fix-LL-329

Handle sqlite gaps while scanning accounts
gre-patch-1
Gaëtan Renaudeau 6 years ago
committed by GitHub
parent
commit
64edc815d3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 17
      src/helpers/libcore.js
  3. 8
      yarn.lock

2
package.json

@ -40,7 +40,7 @@
"@ledgerhq/hw-app-xrp": "^4.24.0", "@ledgerhq/hw-app-xrp": "^4.24.0",
"@ledgerhq/hw-transport": "^4.24.0", "@ledgerhq/hw-transport": "^4.24.0",
"@ledgerhq/hw-transport-node-hid": "4.24.0", "@ledgerhq/hw-transport-node-hid": "4.24.0",
"@ledgerhq/ledger-core": "2.0.0-rc.9", "@ledgerhq/ledger-core": "2.0.0-rc.10",
"@ledgerhq/live-common": "4.0.0-beta.1", "@ledgerhq/live-common": "4.0.0-beta.1",
"animated": "^0.2.2", "animated": "^0.2.2",
"async": "^2.6.1", "async": "^2.6.1",

17
src/helpers/libcore.js

@ -111,7 +111,6 @@ async function scanAccountsOnDeviceBySegwit({
// retrieve or create the wallet // retrieve or create the wallet
const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode }) const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })
const accountsCount = await wallet.getAccountCount()
// recursively scan all accounts on device on the given app // recursively scan all accounts on device on the given app
// new accounts will be created in sqlite, existing ones will be updated // new accounts will be created in sqlite, existing ones will be updated
@ -121,7 +120,6 @@ async function scanAccountsOnDeviceBySegwit({
walletName, walletName,
devicePath, devicePath,
currency, currency,
accountsCount,
accountIndex: 0, accountIndex: 0,
accounts: [], accounts: [],
onAccountScanned, onAccountScanned,
@ -202,7 +200,6 @@ async function scanNextAccount(props: {
currency: CryptoCurrency, currency: CryptoCurrency,
seedIdentifier: string, seedIdentifier: string,
derivationMode: string, derivationMode: string,
accountsCount: number,
accountIndex: number, accountIndex: number,
accounts: AccountRaw[], accounts: AccountRaw[],
onAccountScanned: AccountRaw => void, onAccountScanned: AccountRaw => void,
@ -215,7 +212,6 @@ async function scanNextAccount(props: {
walletName, walletName,
devicePath, devicePath,
currency, currency,
accountsCount,
accountIndex, accountIndex,
accounts, accounts,
onAccountScanned, onAccountScanned,
@ -225,13 +221,12 @@ async function scanNextAccount(props: {
isUnsubscribed, isUnsubscribed,
} = props } = props
// create account only if account has not been scanned yet let njsAccount
// if it has already been created, we just need to get it, and sync it try {
const hasBeenScanned = accountIndex < accountsCount njsAccount = await wallet.getAccount(accountIndex)
} catch (err) {
const njsAccount = hasBeenScanned njsAccount = await createAccount(wallet, devicePath)
? await wallet.getAccount(accountIndex) }
: await createAccount(wallet, devicePath)
if (isUnsubscribed()) return [] if (isUnsubscribed()) return []

8
yarn.lock

@ -1733,10 +1733,10 @@
dependencies: dependencies:
events "^3.0.0" events "^3.0.0"
"@ledgerhq/ledger-core@2.0.0-rc.9": "@ledgerhq/ledger-core@2.0.0-rc.10":
version "2.0.0-rc.9" version "2.0.0-rc.10"
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.9.tgz#f478f52fac0ecace8842df430bc83fa60e14483f" resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.10.tgz#55b7261924df8ed5a33fcc51fdfafc8d6a323fc4"
integrity sha512-wd+w4W/8IfhX2a4h1sM9rkKD0vfcixkbrvKa+SmKzv0WtiUx1i94rHlPLX08tbP2ubaAv/LufeT2DwFz+EcssA== integrity sha512-PbT6y8lwpVfbD5DZIH8CsOZoipNSGHY7BVHNTS+55QsQ6wAPf7sztZjZ8fk6TM0SfdbdIr7Cc5bFQ6cgljTNIA==
dependencies: dependencies:
"@ledgerhq/hw-app-btc" "^4.7.3" "@ledgerhq/hw-app-btc" "^4.7.3"
"@ledgerhq/hw-transport-node-hid" "^4.7.6" "@ledgerhq/hw-transport-node-hid" "^4.7.6"

Loading…
Cancel
Save