Updated on 2026-08-14
This commit is contained in:
parent
0adc8ffb49
commit
62ddda3e69
11 changed files with 201 additions and 41 deletions
|
|
@ -2,10 +2,11 @@ package com.tangem.data.blockaid
|
|||
|
||||
import com.domain.blockaid.models.dapp.CheckDAppResult
|
||||
import com.domain.blockaid.models.transaction.*
|
||||
import com.domain.blockaid.models.transaction.simultation.AmountInfo
|
||||
import com.domain.blockaid.models.transaction.simultation.ApprovedAmount
|
||||
import com.domain.blockaid.models.transaction.simultation.SimulationData
|
||||
import com.domain.blockaid.models.transaction.simultation.TokenInfo
|
||||
import com.domain.blockaid.models.transaction.simultation.AmountInfo
|
||||
import com.tangem.blockchain.extensions.hexToBigDecimal
|
||||
import com.tangem.datasource.api.common.blockaid.models.request.EvmTransactionScanRequest
|
||||
import com.tangem.datasource.api.common.blockaid.models.request.RpcData
|
||||
import com.tangem.datasource.api.common.blockaid.models.request.SolanaTransactionScanRequest
|
||||
|
|
@ -78,12 +79,14 @@ internal object BlockAidMapper {
|
|||
chainId = exposure.asset.chainId,
|
||||
logoUrl = exposure.asset.logoUrl,
|
||||
symbol = exposure.asset.symbol,
|
||||
decimals = exposure.asset.decimals,
|
||||
)
|
||||
exposure.spenders.flatMap { (_, spender) ->
|
||||
val isUnlimited = spender.isApprovedForAll == true
|
||||
val approval = spender.approval?.hexToBigDecimal()
|
||||
spender.exposure.mapNotNull { detail ->
|
||||
ApprovedAmount(
|
||||
approvedAmount = detail.value.toBigDecimalOrNull() ?: return@mapNotNull null,
|
||||
approvedAmount = approval ?: detail.value.toBigDecimalOrNull() ?: return@mapNotNull null,
|
||||
isUnlimited = isUnlimited,
|
||||
tokenInfo = tokenInfo,
|
||||
)
|
||||
|
|
@ -106,6 +109,7 @@ internal object BlockAidMapper {
|
|||
chainId = diff.asset.chainId,
|
||||
logoUrl = diff.asset.logoUrl,
|
||||
symbol = diff.asset.symbol,
|
||||
decimals = diff.asset.decimals,
|
||||
)
|
||||
diff.outTransfer.orEmpty().forEach { transfer ->
|
||||
transfer.value?.toBigDecimalOrNull()?.let { amount ->
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class BlockAidMapperTest {
|
|||
exposure = listOf(ExposureDetail(value = "1000.0", rawValue = "0x123")),
|
||||
)
|
||||
val exposure = Exposure(
|
||||
asset = Asset(chainId = 1, logoUrl = "logo", symbol = "PEPE"),
|
||||
asset = Asset(chainId = 1, logoUrl = "logo", symbol = "PEPE", decimals = 8),
|
||||
spenders = mapOf("spender" to spenderDetails),
|
||||
)
|
||||
val response = TransactionScanResponse(
|
||||
|
|
@ -74,7 +74,7 @@ class BlockAidMapperTest {
|
|||
fun `when response benign validation and success simulation then returns send receive result`() {
|
||||
val assetDiff = AssetDiff(
|
||||
assetType = "ERC20",
|
||||
asset = Asset(chainId = 1, logoUrl = "logo", symbol = "ETH"),
|
||||
asset = Asset(chainId = 1, logoUrl = "logo", symbol = "ETH", decimals = 8),
|
||||
inTransfer = listOf(Transfer(value = "2.0", rawValue = "0x1")),
|
||||
outTransfer = listOf(Transfer(value = "1.5", rawValue = "0x2")),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue