Skip to content

Commit

Permalink
Merge pull request #372 from tangem/bugfix/AND_5328_ethpow_tx_parsing
Browse files Browse the repository at this point in the history
AND-5238 Fixed ETHPow transaction parsing
  • Loading branch information
Yoggam1 authored Nov 13, 2023
2 parents c286e2a + d4f3cb5 commit 0e6b0cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0e6b0cc

Please sign in to comment.