Cache wallet balance and activity so screens show it instantly

This commit is contained in:
2026-09-25 21:58:34 +08:00
parent 2728bf161e
commit b989b0f791
3 changed files with 55 additions and 5 deletions
+14 -5
View File
@@ -18,12 +18,12 @@ struct WalletRecord: Codable, Identifiable, Equatable {
var createdAt: Date
}
enum Direction {
enum Direction: String, Codable {
case incoming
case outgoing
}
struct TransactionRecord: Identifiable {
struct TransactionRecord: Identifiable, Codable {
let id: String
let amount: String
let timestamp: Date?
@@ -44,12 +44,21 @@ struct TransactionRecord: Identifiable {
}
struct Balance {
struct Balance: Codable {
var total: String
var unlocked: String
var funded: Bool
}
/// Persisted per chain so a switch or relaunch shows the last-known state
/// instantly while the network catches up.
struct ChainCache: Codable {
var balance: Balance
var transactions: [TransactionRecord]
var accounts: [MoneroAccount]?
var savedAt: Date
}
struct SyncStatus {
var height: UInt64
var daemonHeight: UInt64
@@ -78,7 +87,7 @@ enum TransactionPriority: Int {
}
}
struct MoneroSubaddress: Identifiable {
struct MoneroSubaddress: Identifiable, Codable {
let accountIndex: Int
let index: Int
let address: String
@@ -90,7 +99,7 @@ struct MoneroSubaddress: Identifiable {
var id: String { "\(accountIndex)/\(index)" }
}
struct MoneroAccount: Identifiable {
struct MoneroAccount: Identifiable, Codable {
let index: Int
let address: String
let balance: String