diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionHistoryProvider.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionHistoryProvider.kt index 63c4a764c..76b22b5a1 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionHistoryProvider.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/ethereum/EthereumTransactionHistoryProvider.kt @@ -60,6 +60,7 @@ internal class EthereumTransactionHistoryProvider( ?.mapNotNull { tx -> tx.toTransactionHistoryItem( walletAddress = request.address, + decimals = request.decimals, filterType = request.filterType ) } @@ -79,6 +80,7 @@ internal class EthereumTransactionHistoryProvider( private fun GetAddressResponse.Transaction.toTransactionHistoryItem( walletAddress: String, + decimals: Int, filterType: TransactionHistoryRequest.FilterType, ): TransactionHistoryItem? { val destinationType = extractDestinationType(walletAddress, this, filterType).guard { @@ -89,7 +91,7 @@ internal class EthereumTransactionHistoryProvider( Log.info { "Transaction $this doesn't contain a required value" } return null } - val amount = extractAmount(tx = this, filterType = filterType).guard { + val amount = extractAmount(tx = this, decimals = decimals, filterType = filterType).guard { Log.info { "Transaction $this doesn't contain a required value" } return null } @@ -196,6 +198,7 @@ internal class EthereumTransactionHistoryProvider( private fun extractAmount( tx: GetAddressResponse.Transaction, + decimals: Int, filterType: TransactionHistoryRequest.FilterType, ): Amount? { return when (filterType) { @@ -214,9 +217,9 @@ internal class EthereumTransactionHistoryProvider( name = transfer.name.orEmpty(), symbol = transfer.symbol.orEmpty(), contractAddress = transfer.contract.orEmpty(), - decimals = transfer.decimals, + decimals = decimals, ) - Amount(value = BigDecimal(transferValue).movePointLeft(transfer.decimals), token = token) + Amount(value = BigDecimal(transferValue).movePointLeft(decimals), token = token) } } } diff --git a/blockchain/src/main/java/com/tangem/blockchain/blockchains/tron/TronTransactionHistoryProvider.kt b/blockchain/src/main/java/com/tangem/blockchain/blockchains/tron/TronTransactionHistoryProvider.kt index d072eeb82..5ad1e44e1 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/blockchains/tron/TronTransactionHistoryProvider.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/blockchains/tron/TronTransactionHistoryProvider.kt @@ -60,7 +60,8 @@ internal class TronTransactionHistoryProvider( ?.mapNotNull { tx -> tx.toTransactionHistoryItem( walletAddress = request.address, - filterType = request.filterType + decimals = request.decimals, + filterType = request.filterType, ) } ?: emptyList() @@ -79,13 +80,14 @@ internal class TronTransactionHistoryProvider( private fun GetAddressResponse.Transaction.toTransactionHistoryItem( walletAddress: String, + decimals: Int, filterType: TransactionHistoryRequest.FilterType, ): TransactionHistoryItem? { val destinationType = extractDestinationType(this, filterType).guard { Log.info { "Transaction $this doesn't contain a required value" } return null } - val amount = extractAmount(tx = this, filterType = filterType).guard { + val amount = extractAmount(tx = this, decimals = decimals, filterType = filterType).guard { Log.info { "Transaction $this doesn't contain a required value" } return null } @@ -154,6 +156,7 @@ internal class TronTransactionHistoryProvider( private fun extractAmount( tx: GetAddressResponse.Transaction, + decimals: Int, filterType: TransactionHistoryRequest.FilterType, ): Amount? { return when (filterType) { @@ -170,9 +173,9 @@ internal class TronTransactionHistoryProvider( name = transfer.name.orEmpty(), symbol = transfer.symbol.orEmpty(), contractAddress = transfer.token.orEmpty(), - decimals = transfer.decimals, + decimals = decimals, ) - Amount(value = BigDecimal(transferValue).movePointLeft(transfer.decimals), token = token) + Amount(value = BigDecimal(transferValue).movePointLeft(decimals), token = token) } } } diff --git a/blockchain/src/main/java/com/tangem/blockchain/common/txhistory/TransactionHistoryRequest.kt b/blockchain/src/main/java/com/tangem/blockchain/common/txhistory/TransactionHistoryRequest.kt index 0ca3c334b..0da7e9c68 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/common/txhistory/TransactionHistoryRequest.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/common/txhistory/TransactionHistoryRequest.kt @@ -4,6 +4,7 @@ private const val DEFAULT_PAGING_SIZE = 20 data class TransactionHistoryRequest( val address: String, + val decimals: Int, val page: Page, val filterType: FilterType, ) { diff --git a/blockchain/src/main/java/com/tangem/blockchain/network/blockbook/network/responses/GetAddressResponse.kt b/blockchain/src/main/java/com/tangem/blockchain/network/blockbook/network/responses/GetAddressResponse.kt index c96cedb33..7570f47b7 100644 --- a/blockchain/src/main/java/com/tangem/blockchain/network/blockbook/network/responses/GetAddressResponse.kt +++ b/blockchain/src/main/java/com/tangem/blockchain/network/blockbook/network/responses/GetAddressResponse.kt @@ -54,7 +54,6 @@ data class GetAddressResponse( @Json(name = "token") val token: String?, @Json(name = "name") val name: String?, @Json(name = "symbol") val symbol: String?, - @Json(name = "decimals") val decimals: Int, @Json(name = "value") val value: String?, )