From 8cd51f0dc2d90fff31e30e9ff4b02aac1939842c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 11 Jul 2018 16:08:04 +0200 Subject: [PATCH] Always scan at least 5 MEW address even if user left empty accounts --- src/bridge/EthereumJSBridge.js | 13 ++++++++++++- src/helpers/derivations.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index 618b8c75..48972922 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -176,6 +176,7 @@ const EthereumBridge: WalletBridge = { index, { address, path: freshAddressPath, publicKey }, isStandard, + mandatoryCount, ): { account?: Account, complete?: boolean } { const balance = await api.getAccountBalance(address) if (finished) return { complete: true } @@ -211,6 +212,10 @@ const EthereumBridge: WalletBridge = { } newAccountCount++ } + + if (index < mandatoryCount) { + return {} + } // NB for legacy addresses maybe we will continue at least for the first 10 addresses return { complete: true } } @@ -254,7 +259,13 @@ const EthereumBridge: WalletBridge = { const res = await getAddressCommand .send({ currencyId: currency.id, devicePath: deviceId, path: freshAddressPath }) .toPromise() - const r = await stepAddress(index, res, isStandard) + const r = await stepAddress( + index, + res, + isStandard, + // $FlowFixMe i know i know, not part of function + derivation.mandatoryCount || 0, + ) if (r.account) o.next(r.account) if (r.complete) { break diff --git a/src/helpers/derivations.js b/src/helpers/derivations.js index 2b74942a..8ed1748c 100644 --- a/src/helpers/derivations.js +++ b/src/helpers/derivations.js @@ -8,6 +8,7 @@ type Derivation = ({ }) => string const ethLegacyMEW: Derivation = ({ x }) => `44'/60'/0'/${x}` +ethLegacyMEW.mandatoryCount = 5 const etcLegacyMEW: Derivation = ({ x }) => `44'/60'/160720'/${x}'/0`