fix error logic for recovery password

pull/891/head
Ryan ZHAO 1 year ago
parent 2798e76f25
commit 216a6666cc

@ -86,9 +86,9 @@ struct LoadAccountScreen: View {
} catch { } catch {
if let decodingError = error as? Mnemonic.DecodingError { if let decodingError = error as? Mnemonic.DecodingError {
switch decodingError { switch decodingError {
case .inputTooShort, .missingLastWord: case .inputTooShort:
errorString = "recoveryPasswordErrorMessageShort".localized() errorString = "recoveryPasswordErrorMessageShort".localized()
case .invalidWord, .verificationFailed: case .invalidWord:
errorString = "recoveryPasswordErrorMessageIncorrect".localized() errorString = "recoveryPasswordErrorMessageIncorrect".localized()
default: default:
errorString = "recoveryPasswordErrorMessageGeneric".localized() errorString = "recoveryPasswordErrorMessageGeneric".localized()

@ -66,7 +66,7 @@ public enum Mnemonic {
} }
public enum DecodingError : LocalizedError { public enum DecodingError : LocalizedError {
case generic, inputTooShort, missingLastWord, invalidWord, verificationFailed case generic, inputTooShort, invalidWord, verificationFailed
} }
public static func hash(hexEncodedString string: String, language: Language = .english) -> String { public static func hash(hexEncodedString string: String, language: Language = .english) -> String {
@ -118,7 +118,7 @@ public enum Mnemonic {
// Check preconditions // Check preconditions
guard words.count >= 12 else { throw DecodingError.inputTooShort } guard words.count >= 12 else { throw DecodingError.inputTooShort }
guard words.count == 12 else { throw DecodingError.generic } guard !words.count.isMultiple(of: 3) else { throw DecodingError.generic }
// Get checksum word // Get checksum word
let checksumWord = words.popLast()! let checksumWord = words.popLast()!

Loading…
Cancel
Save