From d4f3cb532db651510745581801e6ebb4cb8fb869 Mon Sep 17 00:00:00 2001 From: Doston Kamalov Date: Mon, 13 Nov 2023 18:23:00 +0500 Subject: [PATCH] AND-5238 Fixed ETHPow transaction parsing --- .../ethereum/EthereumTransactionHistoryProvider.kt | 8 ++++---- .../blockbook/network/responses/GetAddressResponse.kt | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) 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 2f56b3374..8255250e3 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 @@ -142,7 +142,7 @@ internal class EthereumTransactionHistoryProvider( .equals(walletAddress, ignoreCase = true) is TransactionHistoryRequest.FilterType.Contract -> transaction.tokenTransfers - .firstOrNull { filterType.address.equals(it.contract, true) } + .firstOrNull { filterType.address.equals(it.contract, true) || filterType.address.equals(it.token, ignoreCase = true) } ?.from.equals(walletAddress, ignoreCase = true) } } @@ -171,7 +171,7 @@ internal class EthereumTransactionHistoryProvider( is TransactionHistoryRequest.FilterType.Contract -> { val transfer = tx.tokenTransfers - .firstOrNull { filterType.address.equals(it.contract, ignoreCase = true) } + .firstOrNull { filterType.address.equals(it.contract, ignoreCase = true) || filterType.address.equals(it.token, ignoreCase = true) } .guard { return null } val isOutgoing = transfer.from == walletAddress TransactionHistoryItem.DestinationType.Single( @@ -207,13 +207,13 @@ internal class EthereumTransactionHistoryProvider( is TransactionHistoryRequest.FilterType.Contract -> { val transfer = tx.tokenTransfers - .firstOrNull { filterType.address.equals(it.contract, ignoreCase = true) } + .firstOrNull { filterType.address.equals(it.contract, ignoreCase = true) || filterType.address.equals(it.token, ignoreCase = true) } .guard { return null } val transferValue = transfer.value ?: "0" val token = Token( name = transfer.name.orEmpty(), symbol = transfer.symbol.orEmpty(), - contractAddress = transfer.contract, + contractAddress = transfer.contract ?: transfer.token ?: "", decimals = transfer.decimals, ) Amount(value = BigDecimal(transferValue).movePointLeft(transfer.decimals), token = token) 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 c2d7cf78a..baeba1251 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 @@ -45,7 +45,8 @@ data class GetAddressResponse( @Json(name = "type") val type: String?, @Json(name = "from") val from: String, @Json(name = "to") val to: String, - @Json(name = "contract") val contract: String, + @Json(name = "contract") val contract: String?, + @Json(name = "token") val token: String?, @Json(name = "name") val name: String?, @Json(name = "symbol") val symbol: String?, @Json(name = "decimals") val decimals: Int,