From 0010442d306e4e287a0b785733f8b3b1861f8c09 Mon Sep 17 00:00:00 2001 From: meriadec Date: Sat, 27 Oct 2018 16:18:22 +0200 Subject: [PATCH 1/2] Handle sqlite gaps while scanning accounts LL-329 --- src/helpers/libcore.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/helpers/libcore.js b/src/helpers/libcore.js index 93467443..949e2318 100644 --- a/src/helpers/libcore.js +++ b/src/helpers/libcore.js @@ -111,7 +111,6 @@ async function scanAccountsOnDeviceBySegwit({ // retrieve or create the wallet const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode }) - const accountsCount = await wallet.getAccountCount() // recursively scan all accounts on device on the given app // new accounts will be created in sqlite, existing ones will be updated @@ -121,7 +120,6 @@ async function scanAccountsOnDeviceBySegwit({ walletName, devicePath, currency, - accountsCount, accountIndex: 0, accounts: [], onAccountScanned, @@ -202,7 +200,6 @@ async function scanNextAccount(props: { currency: CryptoCurrency, seedIdentifier: string, derivationMode: string, - accountsCount: number, accountIndex: number, accounts: AccountRaw[], onAccountScanned: AccountRaw => void, @@ -215,7 +212,6 @@ async function scanNextAccount(props: { walletName, devicePath, currency, - accountsCount, accountIndex, accounts, onAccountScanned, @@ -225,13 +221,12 @@ async function scanNextAccount(props: { isUnsubscribed, } = props - // create account only if account has not been scanned yet - // if it has already been created, we just need to get it, and sync it - const hasBeenScanned = accountIndex < accountsCount - - const njsAccount = hasBeenScanned - ? await wallet.getAccount(accountIndex) - : await createAccount(wallet, devicePath) + let njsAccount + try { + njsAccount = await wallet.getAccount(accountIndex) + } catch (err) { + njsAccount = await createAccount(wallet, devicePath) + } if (isUnsubscribed()) return [] From 7dc734f3fffc4926225fb3bf30650bedf2cc7da4 Mon Sep 17 00:00:00 2001 From: meriadec Date: Mon, 5 Nov 2018 10:30:53 +0100 Subject: [PATCH 2/2] Bump @ledgerhq/ledger-core to v2.0.0-rc.10 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 960a2c78..ed780b64 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@ledgerhq/hw-app-xrp": "^4.24.0", "@ledgerhq/hw-transport": "^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", "animated": "^0.2.2", "async": "^2.6.1", diff --git a/yarn.lock b/yarn.lock index 97d61a8e..44f919a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1733,10 +1733,10 @@ dependencies: events "^3.0.0" -"@ledgerhq/ledger-core@2.0.0-rc.9": - version "2.0.0-rc.9" - resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.9.tgz#f478f52fac0ecace8842df430bc83fa60e14483f" - integrity sha512-wd+w4W/8IfhX2a4h1sM9rkKD0vfcixkbrvKa+SmKzv0WtiUx1i94rHlPLX08tbP2ubaAv/LufeT2DwFz+EcssA== +"@ledgerhq/ledger-core@2.0.0-rc.10": + version "2.0.0-rc.10" + resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.10.tgz#55b7261924df8ed5a33fcc51fdfafc8d6a323fc4" + integrity sha512-PbT6y8lwpVfbD5DZIH8CsOZoipNSGHY7BVHNTS+55QsQ6wAPf7sztZjZ8fk6TM0SfdbdIr7Cc5bFQ6cgljTNIA== dependencies: "@ledgerhq/hw-app-btc" "^4.7.3" "@ledgerhq/hw-transport-node-hid" "^4.7.6"