Implement bank transfer app flows
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import Foundation
|
||||
|
||||
// Encrypted contacts cache backed by UserDefaults (same pattern as AccountCache).
|
||||
struct ContactsCache {
|
||||
static let shared = ContactsCache()
|
||||
private let udKey = "thijooree_contacts_v1"
|
||||
private init() {}
|
||||
|
||||
func save(_ contacts: [BankContact]) {
|
||||
guard let json = try? JSONEncoder().encode(contacts),
|
||||
let encrypted = try? CacheEncryption.shared.encryptData(json) else { return }
|
||||
UserDefaults.standard.set(encrypted, forKey: udKey)
|
||||
}
|
||||
|
||||
func load() -> [BankContact] {
|
||||
guard let encrypted = UserDefaults.standard.string(forKey: udKey),
|
||||
let json = try? CacheEncryption.shared.decryptData(encrypted),
|
||||
let contacts = try? JSONDecoder().decode([BankContact].self, from: json) else { return [] }
|
||||
return contacts
|
||||
}
|
||||
|
||||
func clear() {
|
||||
UserDefaults.standard.removeObject(forKey: udKey)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user