// // WalletError.swift // OS Vault // // Author: Simon-Pierre Boucher // Mail: contact@spboucher.ai // import Foundation /// Typed errors for every service call. Messages never contain key material. public enum WalletError: LocalizedError, Equatable { case noVault case vaultCorrupted case wrongPassword case invalidMnemonic case invalidAddress case insufficientETHForGas(needWei: String, haveWei: String) case insufficientTokenBalance case rpc(String) case signingFailed case internalError(String) public var errorDescription: String? { switch self { case .noVault: return "No wallet exists on this Mac yet." case .vaultCorrupted: return "The vault file is damaged and cannot be read." case .wrongPassword: return "Incorrect password." case .invalidMnemonic: return "This recovery phrase is not valid. Check the words and their order." case .invalidAddress: return "This is not a valid Ethereum address." case .insufficientETHForGas(let need, let have): return "Not enough of the chain's native coin to pay gas (need ~\(need), have \(have)). Gas is always paid in the native coin, never in stablecoins." case .insufficientTokenBalance: return "Amount exceeds your token balance." case .rpc(let message): return "Network error: \(message)" case .signingFailed: return "The transaction could not be signed." case .internalError(let message): return message } } }