minor refactor on how to show error messages when the mnemonic is incorrect

pull/891/head
Ryan ZHAO 11 months ago
parent 648c3e658e
commit ae4c87a5b0

@ -85,7 +85,14 @@ struct LoadAccountScreen: View {
hexEncodedSeed = try Mnemonic.decode(mnemonic: mnemonic)
} catch {
if let decodingError = error as? Mnemonic.DecodingError {
errorString = decodingError.errorDescription
switch decodingError {
case .inputTooShort, .missingLastWord:
errorString = "recoveryPasswordErrorMessageShort".localized()
case .invalidWord, .verificationFailed:
errorString = "recoveryPasswordErrorMessageIncorrect".localized()
default:
errorString = "recoveryPasswordErrorMessageGeneric".localized()
}
} else {
errorString = "recoveryPasswordErrorMessageGeneric".localized()
}

@ -67,17 +67,6 @@ public enum Mnemonic {
public enum DecodingError : LocalizedError {
case generic, inputTooShort, missingLastWord, invalidWord, verificationFailed
public var errorDescription: String {
switch self {
case .inputTooShort:
return "recoveryPasswordErrorMessageShort".localized()
case .invalidWord:
return "recoveryPasswordErrorMessageIncorrect".localized()
default:
return "recoveryPasswordErrorMessageGeneric".localized()
}
}
}
public static func hash(hexEncodedString string: String, language: Language = .english) -> String {

Loading…
Cancel
Save