mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2024-10-01 03:45:36 -04:00
lib: rename transactions to transactionById in Ledger
This commit is contained in:
parent
c28b40899d
commit
6cc43d2502
@ -61,7 +61,7 @@ class WalletRepository(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getTransaction(walletId: Long, txId: String): Flow<Transaction?> =
|
fun getTransaction(walletId: Long, txId: String): Flow<Transaction?> =
|
||||||
getLedger(walletId).map { it.transactions[txId] }
|
getLedger(walletId).map { it.transactionById[txId] }
|
||||||
|
|
||||||
suspend fun addWallet(
|
suspend fun addWallet(
|
||||||
moneroNetwork: MoneroNetwork,
|
moneroNetwork: MoneroNetwork,
|
||||||
|
@ -79,13 +79,13 @@ private fun walletUiState(
|
|||||||
group.sortedBy { it.subAddressIndex }.mapIndexed { index, address ->
|
group.sortedBy { it.subAddressIndex }.mapIndexed { index, address ->
|
||||||
WalletAddress(
|
WalletAddress(
|
||||||
address = address,
|
address = address,
|
||||||
used = address.isAddressUsed(ledger.transactions.values),
|
used = address.isAddressUsed(ledger.transactions),
|
||||||
isLastForAccount = index == group.size - 1,
|
isLastForAccount = index == group.size - 1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val transactions =
|
val transactions =
|
||||||
ledger.transactions.map { WalletTransaction(config.id, it.value) }
|
ledger.transactions.map { WalletTransaction(config.id, it) }
|
||||||
.sortedByDescending { it.transaction.blockTimestamp ?: Instant.MAX }
|
.sortedByDescending { it.transaction.blockTimestamp ?: Instant.MAX }
|
||||||
WalletUiState.Loaded(
|
WalletUiState.Loaded(
|
||||||
config = config,
|
config = config,
|
||||||
|
@ -41,7 +41,7 @@ object PreviewParameterData {
|
|||||||
val ledger = Ledger(
|
val ledger = Ledger(
|
||||||
publicAddress = PublicAddress.parse("4AYjQM9HoAFNUeC3cvSfgeAN89oMMpMqiByvunzSzhn97cj726rJj3x8hCbH58UnMqQJShczCxbpWRiCJQ3HCUDHLiKuo4T"),
|
publicAddress = PublicAddress.parse("4AYjQM9HoAFNUeC3cvSfgeAN89oMMpMqiByvunzSzhn97cj726rJj3x8hCbH58UnMqQJShczCxbpWRiCJQ3HCUDHLiKuo4T"),
|
||||||
accountAddresses = emptySet(),
|
accountAddresses = emptySet(),
|
||||||
transactions = transactions.associateBy { it.txId },
|
transactionById = transactions.associateBy { it.txId },
|
||||||
enotes = emptySet(),
|
enotes = emptySet(),
|
||||||
checkedAt = BlockchainTime(blockHeader = blockHeader, network = network),
|
checkedAt = BlockchainTime(blockHeader = blockHeader, network = network),
|
||||||
)
|
)
|
||||||
|
@ -5,10 +5,12 @@ package im.molly.monero
|
|||||||
data class Ledger(
|
data class Ledger(
|
||||||
val publicAddress: PublicAddress,
|
val publicAddress: PublicAddress,
|
||||||
val accountAddresses: Set<AccountAddress>,
|
val accountAddresses: Set<AccountAddress>,
|
||||||
val transactions: Map<String, Transaction>,
|
val transactionById: Map<String, Transaction>,
|
||||||
val enotes: Set<TimeLocked<Enote>>,
|
val enotes: Set<TimeLocked<Enote>>,
|
||||||
val checkedAt: BlockchainTime,
|
val checkedAt: BlockchainTime,
|
||||||
) {
|
) {
|
||||||
|
val transactions get() = transactionById.values
|
||||||
|
|
||||||
val balance: Balance = enotes.calculateBalance()
|
val balance: Balance = enotes.calculateBalance()
|
||||||
|
|
||||||
// companion object {
|
// companion object {
|
||||||
|
@ -96,7 +96,7 @@ class MoneroWallet internal constructor(
|
|||||||
val ledger = Ledger(
|
val ledger = Ledger(
|
||||||
publicAddress = publicAddress,
|
publicAddress = publicAddress,
|
||||||
accountAddresses = accountAddresses,
|
accountAddresses = accountAddresses,
|
||||||
transactions = txById,
|
transactionById = txById,
|
||||||
enotes = enotes,
|
enotes = enotes,
|
||||||
checkedAt = blockchainTime,
|
checkedAt = blockchainTime,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user