Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixes recover flow when seed is corrupted #13607

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions app/common/state/ledgerState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/unit/app/common/state/ledgerStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
})