Skip to content

Commit

Permalink
Fixes recover flow when seed is corrupted
Browse files Browse the repository at this point in the history
Resolves brave#13583

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Mar 26, 2018
1 parent 68ecb38 commit 6486e82
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
17 changes: 14 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,11 +1653,16 @@ 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)

if (info) {
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 state
}

return state.getIn(['ledger', 'about', prop])
}
}

Expand Down

0 comments on commit 6486e82

Please sign in to comment.