lib: rename transactions to transactionById in Ledger

This commit is contained in:
Oscar Mira 2024-02-28 11:11:38 +01:00
parent c28b40899d
commit 6cc43d2502
5 changed files with 8 additions and 6 deletions

View File

@ -61,7 +61,7 @@ class WalletRepository(
}
fun getTransaction(walletId: Long, txId: String): Flow<Transaction?> =
getLedger(walletId).map { it.transactions[txId] }
getLedger(walletId).map { it.transactionById[txId] }
suspend fun addWallet(
moneroNetwork: MoneroNetwork,

View File

@ -79,13 +79,13 @@ private fun walletUiState(
group.sortedBy { it.subAddressIndex }.mapIndexed { index, address ->
WalletAddress(
address = address,
used = address.isAddressUsed(ledger.transactions.values),
used = address.isAddressUsed(ledger.transactions),
isLastForAccount = index == group.size - 1,
)
}
}
val transactions =
ledger.transactions.map { WalletTransaction(config.id, it.value) }
ledger.transactions.map { WalletTransaction(config.id, it) }
.sortedByDescending { it.transaction.blockTimestamp ?: Instant.MAX }
WalletUiState.Loaded(
config = config,

View File

@ -41,7 +41,7 @@ object PreviewParameterData {
val ledger = Ledger(
publicAddress = PublicAddress.parse("4AYjQM9HoAFNUeC3cvSfgeAN89oMMpMqiByvunzSzhn97cj726rJj3x8hCbH58UnMqQJShczCxbpWRiCJQ3HCUDHLiKuo4T"),
accountAddresses = emptySet(),
transactions = transactions.associateBy { it.txId },
transactionById = transactions.associateBy { it.txId },
enotes = emptySet(),
checkedAt = BlockchainTime(blockHeader = blockHeader, network = network),
)

View File

@ -5,10 +5,12 @@ package im.molly.monero
data class Ledger(
val publicAddress: PublicAddress,
val accountAddresses: Set<AccountAddress>,
val transactions: Map<String, Transaction>,
val transactionById: Map<String, Transaction>,
val enotes: Set<TimeLocked<Enote>>,
val checkedAt: BlockchainTime,
) {
val transactions get() = transactionById.values
val balance: Balance = enotes.calculateBalance()
// companion object {

View File

@ -96,7 +96,7 @@ class MoneroWallet internal constructor(
val ledger = Ledger(
publicAddress = publicAddress,
accountAddresses = accountAddresses,
transactions = txById,
transactionById = txById,
enotes = enotes,
checkedAt = blockchainTime,
)