diff --git a/app/browser/api/ledger.js b/app/browser/api/ledger.js index dc31021141b..625ecaa4261 100644 --- a/app/browser/api/ledger.js +++ b/app/browser/api/ledger.js @@ -1160,6 +1160,12 @@ const onWalletRecovery = (state, error, result) => { state = ledgerState.setInfoProp(state, 'walletQR', Immutable.Map()) state = ledgerState.setInfoProp(state, 'addresses', Immutable.Map()) + const status = ledgerState.getAboutProp(state, 'status') + + if (status === ledgerStatuses.CORRUPTED_SEED) { + state = ledgerState.setAboutProp(state, 'status', '') + } + callback(error, result) if (balanceTimeoutId) { @@ -1647,9 +1653,13 @@ const getStateInfo = (state, parsedData) => { state = ledgerState.setAboutProp(state, 'status', ledgerStatuses.IN_PROGRESS) } - let passphrase = ledgerClient.prototype.getWalletPassphrase(parsedData) - if (passphrase) { - newInfo.passphrase = passphrase.join(' ') + try { + let passphrase = ledgerClient.prototype.getWalletPassphrase(parsedData) + if (passphrase) { + newInfo.passphrase = passphrase.join(' ') + } + } catch (e) { + console.error(e) } state = ledgerState.mergeInfoProp(state, newInfo) diff --git a/app/common/state/ledgerState.js b/app/common/state/ledgerState.js index 92c3b1786f0..567e7fc7a7b 100644 --- a/app/common/state/ledgerState.js +++ b/app/common/state/ledgerState.js @@ -570,6 +570,16 @@ const ledgerState = { } return state.setIn(['ledger', 'about', prop], value) + }, + + getAboutProp: (state, prop) => { + state = validateState(state) + + if (prop == null) { + return null + } + + return state.getIn(['ledger', 'about', prop]) } } diff --git a/test/unit/app/common/state/ledgerStateTest.js b/test/unit/app/common/state/ledgerStateTest.js index eacec64d78a..b899d670e7e 100644 --- a/test/unit/app/common/state/ledgerStateTest.js +++ b/test/unit/app/common/state/ledgerStateTest.js @@ -609,4 +609,17 @@ describe('ledgerState unit test', function () { assert.deepEqual(result.toJS(), expectedState.toJS()) }) }) + + describe('getAboutProp', function () { + it('null case', function () { + const result = ledgerState.getAboutProp(defaultState) + assert.equal(result, null) + }) + + it('prop is set', function () { + const state = defaultState.setIn(['ledger', 'about', 'status'], 'corrupted') + const result = ledgerState.getAboutProp(state, 'status') + assert.equal(result, 'corrupted') + }) + }) })