Updated on 2026-08-14
This commit is contained in:
parent
20c2f57407
commit
23256d93db
10 changed files with 77 additions and 42 deletions
|
|
@ -460,6 +460,7 @@
|
|||
<string name="transaction_history_contract_address">контракт: %s</string>
|
||||
<string name="transaction_history_empty_transactions">У вас еще нет транзакций</string>
|
||||
<string name="transaction_history_error_failed_to_load">Не удалось загрузить историю транзакций.\nНажмите на кнопку перезагрузки, чтобы обновить информацию.</string>
|
||||
<string name="transaction_history_multiple_addresses">Несколько адресов</string>
|
||||
<string name="transaction_history_not_supported_description">История транзакций в настоящее время не поддерживается для этого блокчейна. Но не волнуйтесь, мы работаем над этим! А пока вы можете проверить ее в обозревателе.</string>
|
||||
<string name="transaction_history_transaction_from_address">от: %s</string>
|
||||
<string name="transaction_history_transaction_to_address">на: %s</string>
|
||||
|
|
|
|||
|
|
@ -451,6 +451,7 @@
|
|||
<string name="transaction_history_contract_address">contract: %s</string>
|
||||
<string name="transaction_history_empty_transactions">You don\'t have any transactions yet</string>
|
||||
<string name="transaction_history_error_failed_to_load">Failed to load transaction history.\nClick on reload button to update the information.</string>
|
||||
<string name="transaction_history_multiple_addresses">Multiple addresses</string>
|
||||
<string name="transaction_history_not_supported_description">Transaction history is currently not supported for this blockchain. But don\'t worry, we\'re working on it! In the meantime you can check it in the explorer.</string>
|
||||
<string name="transaction_history_transaction_from_address">from: %s</string>
|
||||
<string name="transaction_history_transaction_to_address">to: %s</string>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ import com.tangem.core.ui.R
|
|||
import com.tangem.core.ui.components.CircleShimmer
|
||||
import com.tangem.core.ui.components.RectangleShimmer
|
||||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import java.util.UUID
|
||||
|
||||
|
|
@ -237,7 +239,7 @@ private fun Subtitle(state: TransactionState, modifier: Modifier = Modifier) {
|
|||
is TransactionState.Send,
|
||||
-> stringResource(
|
||||
id = R.string.transaction_history_transaction_to_address,
|
||||
state.address,
|
||||
state.address.resolveReference(),
|
||||
)
|
||||
is TransactionState.Receiving,
|
||||
is TransactionState.Receive,
|
||||
|
|
@ -245,13 +247,13 @@ private fun Subtitle(state: TransactionState, modifier: Modifier = Modifier) {
|
|||
is TransactionState.Approved,
|
||||
-> stringResource(
|
||||
id = R.string.transaction_history_transaction_from_address,
|
||||
state.address,
|
||||
state.address.resolveReference(),
|
||||
)
|
||||
is TransactionState.Swapping,
|
||||
is TransactionState.Swapped,
|
||||
-> stringResource(
|
||||
id = R.string.transaction_history_contract_address,
|
||||
state.address,
|
||||
state.address.resolveReference(),
|
||||
)
|
||||
},
|
||||
modifier = modifier,
|
||||
|
|
@ -357,49 +359,49 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
collection = listOf(
|
||||
TransactionState.Sending(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Receiving(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Approving(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Swapping(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Send(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Receive(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Approved(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
TransactionState.Swapped(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.core.ui.components.transactions.state
|
||||
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
||||
/**
|
||||
* Transaction component state
|
||||
*
|
||||
|
|
@ -20,14 +22,14 @@ sealed interface TransactionState {
|
|||
*/
|
||||
sealed class Content(
|
||||
override val txHash: String,
|
||||
open val address: String,
|
||||
open val address: TextReference,
|
||||
open val amount: String,
|
||||
open val timestamp: String,
|
||||
) : TransactionState {
|
||||
|
||||
fun copySealed(
|
||||
txHash: String = this.txHash,
|
||||
address: String = this.address,
|
||||
address: TextReference = this.address,
|
||||
amount: String = this.amount,
|
||||
timestamp: String = this.timestamp,
|
||||
): Content {
|
||||
|
|
@ -54,7 +56,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
sealed class ProcessedTransactionContent(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : Content(txHash, address, amount, timestamp)
|
||||
|
|
@ -69,7 +71,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
sealed class CompletedTransactionContent(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : Content(txHash, address, amount, timestamp)
|
||||
|
|
@ -84,7 +86,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Sending(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : ProcessedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -99,7 +101,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Receiving(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : ProcessedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -114,7 +116,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Approving(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : ProcessedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -129,7 +131,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Swapping(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : ProcessedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -144,7 +146,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Send(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : CompletedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -159,7 +161,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Receive(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : CompletedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -174,7 +176,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Approved(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : CompletedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
@ -189,7 +191,7 @@ sealed interface TransactionState {
|
|||
*/
|
||||
data class Swapped(
|
||||
override val txHash: String,
|
||||
override val address: String,
|
||||
override val address: TextReference,
|
||||
override val amount: String,
|
||||
override val timestamp: String,
|
||||
) : CompletedTransactionContent(txHash, address, amount, timestamp)
|
||||
|
|
|
|||
|
|
@ -11,12 +11,7 @@ internal class SdkTransactionHistoryItemConverter : Converter<SdkTransactionHist
|
|||
override fun convert(value: SdkTransactionHistoryItem): TxHistoryItem = TxHistoryItem(
|
||||
txHash = value.txHash,
|
||||
timestampInMillis = value.timestamp,
|
||||
direction = when (val direction = value.direction) {
|
||||
is SdkTransactionHistoryItem.TransactionDirection.Incoming ->
|
||||
TxHistoryItem.TransactionDirection.Incoming(direction.from)
|
||||
is SdkTransactionHistoryItem.TransactionDirection.Outgoing ->
|
||||
TxHistoryItem.TransactionDirection.Outgoing(direction.to)
|
||||
},
|
||||
direction = value.direction.toDomain(),
|
||||
status = when (value.status) {
|
||||
TransactionStatus.Confirmed -> TxHistoryItem.TxStatus.Confirmed
|
||||
TransactionStatus.Unconfirmed -> TxHistoryItem.TxStatus.Unconfirmed
|
||||
|
|
@ -26,4 +21,16 @@ internal class SdkTransactionHistoryItemConverter : Converter<SdkTransactionHist
|
|||
},
|
||||
amount = requireNotNull(value.amount.value) { "Transaction amount value must not be null" },
|
||||
)
|
||||
|
||||
private fun TransactionHistoryItem.TransactionDirection.toDomain() = when (this) {
|
||||
is TransactionHistoryItem.TransactionDirection.Incoming ->
|
||||
TxHistoryItem.TransactionDirection.Incoming(address.toDomain())
|
||||
is TransactionHistoryItem.TransactionDirection.Outgoing ->
|
||||
TxHistoryItem.TransactionDirection.Outgoing(address.toDomain())
|
||||
}
|
||||
|
||||
private fun TransactionHistoryItem.Address.toDomain(): TxHistoryItem.Address = when (this) {
|
||||
TransactionHistoryItem.Address.Multiple -> TxHistoryItem.Address.Multiple
|
||||
is TransactionHistoryItem.Address.Single -> TxHistoryItem.Address.Single(rawAddress = rawAddress)
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,11 @@ data class TxHistoryItem(
|
|||
val amount: BigDecimal,
|
||||
) {
|
||||
sealed interface TransactionDirection {
|
||||
data class Incoming(val from: String) : TransactionDirection
|
||||
data class Outgoing(val to: String) : TransactionDirection
|
||||
|
||||
val address: Address
|
||||
|
||||
data class Incoming(override val address: Address) : TransactionDirection
|
||||
data class Outgoing(override val address: Address) : TransactionDirection
|
||||
}
|
||||
|
||||
sealed interface TransactionType {
|
||||
|
|
@ -20,4 +23,9 @@ data class TxHistoryItem(
|
|||
}
|
||||
|
||||
enum class TxStatus { Confirmed, Unconfirmed }
|
||||
|
||||
sealed class Address {
|
||||
data class Single(val rawAddress: String) : Address()
|
||||
object Multiple : Address()
|
||||
}
|
||||
}
|
||||
|
|
@ -7,8 +7,10 @@ import com.tangem.core.ui.components.transactions.intents.TxHistoryClickIntents
|
|||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.isToday
|
||||
import com.tangem.utils.extensions.isYesterday
|
||||
|
|
@ -100,13 +102,13 @@ internal class TokenDetailsTxHistoryItemFlowConverter(
|
|||
return when (item.status) {
|
||||
TxHistoryItem.TxStatus.Confirmed -> TransactionState.Receive(
|
||||
txHash = item.txHash,
|
||||
address = direction.from.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
TxHistoryItem.TxStatus.Unconfirmed -> TransactionState.Receiving(
|
||||
txHash = item.txHash,
|
||||
address = direction.from.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
|
|
@ -120,13 +122,13 @@ internal class TokenDetailsTxHistoryItemFlowConverter(
|
|||
return when (item.status) {
|
||||
TxHistoryItem.TxStatus.Confirmed -> TransactionState.Send(
|
||||
txHash = item.txHash,
|
||||
address = direction.to.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
TxHistoryItem.TxStatus.Unconfirmed -> TransactionState.Sending(
|
||||
txHash = item.txHash,
|
||||
address = direction.to.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
|
|
@ -220,4 +222,9 @@ internal class TokenDetailsTxHistoryItemFlowConverter(
|
|||
DateTime(this.toLong(), DateTimeZone.getDefault()),
|
||||
)
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.TransactionDirection.extractAddress(): TextReference = when (val addr = address) {
|
||||
TxHistoryItem.Address.Multiple -> TextReference.Res(R.string.transaction_history_multiple_addresses)
|
||||
is TxHistoryItem.Address.Single -> TextReference.Str(addr.rawAddress.toBriefAddressFormat())
|
||||
}
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ internal object WalletPreviewData {
|
|||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Sending(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
|
|
@ -396,7 +396,7 @@ internal object WalletPreviewData {
|
|||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Sending(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = "33BddS...ga2B",
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "-0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ import com.tangem.common.Provider
|
|||
import com.tangem.core.ui.components.transactions.state.TransactionState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.feature.wallet.impl.R
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletState
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletClickIntents
|
||||
|
|
@ -115,13 +117,13 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
return when (item.status) {
|
||||
TxHistoryItem.TxStatus.Confirmed -> TransactionState.Receive(
|
||||
txHash = item.txHash,
|
||||
address = direction.from.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(blockchain = blockchain),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
TxHistoryItem.TxStatus.Unconfirmed -> TransactionState.Receiving(
|
||||
txHash = item.txHash,
|
||||
address = direction.from.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(blockchain = blockchain),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
|
|
@ -136,13 +138,13 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
return when (item.status) {
|
||||
TxHistoryItem.TxStatus.Confirmed -> TransactionState.Send(
|
||||
txHash = item.txHash,
|
||||
address = direction.to.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(blockchain = blockchain),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
TxHistoryItem.TxStatus.Unconfirmed -> TransactionState.Sending(
|
||||
txHash = item.txHash,
|
||||
address = direction.to.toBriefAddressFormat(),
|
||||
address = direction.extractAddress(),
|
||||
amount = item.amount.toCryptoCurrencyFormat(blockchain = blockchain),
|
||||
timestamp = item.getRawTimestamp(),
|
||||
)
|
||||
|
|
@ -240,4 +242,9 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
DateTime(this.toLong(), DateTimeZone.getDefault()),
|
||||
)
|
||||
}
|
||||
|
||||
private fun TxHistoryItem.TransactionDirection.extractAddress(): TextReference = when (val addr = address) {
|
||||
TxHistoryItem.Address.Multiple -> TextReference.Res(R.string.transaction_history_multiple_addresses)
|
||||
is TxHistoryItem.Address.Single -> TextReference.Str(addr.rawAddress.toBriefAddressFormat())
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ okHttp-prettyLogging = "3.1.0"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "develop-327"
|
||||
tangemBlockchainSdk = "develop-330"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-289"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue