Updated on 2026-08-14
This commit is contained in:
parent
aa2439e3fa
commit
e803ab0d7d
12 changed files with 103 additions and 24 deletions
|
|
@ -85,7 +85,7 @@ internal object BlockAidMapper {
|
|||
from.exposures,
|
||||
)
|
||||
!from.traces.isNullOrEmpty() -> mapNftSendReceiveTransaction(from.traces)
|
||||
else -> SimulationResult.FailedToSimulate
|
||||
else -> SimulationResult.Success(data = SimulationData.NoWalletChangesDetected)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,15 +94,15 @@ internal object BlockAidMapper {
|
|||
val tokenInfo = TokenInfo(
|
||||
chainId = exposure.asset.chainId,
|
||||
logoUrl = exposure.asset.logoUrl,
|
||||
symbol = exposure.asset.symbol,
|
||||
decimals = exposure.asset.decimals,
|
||||
symbol = exposure.asset.symbol ?: "",
|
||||
decimals = exposure.asset.decimals ?: 0,
|
||||
)
|
||||
exposure.spenders.flatMap { (_, spender) ->
|
||||
val isUnlimited = spender.isApprovedForAll == true
|
||||
val approval = spender.approval?.hexToBigDecimal()
|
||||
spender.exposure.mapNotNull { detail ->
|
||||
spender.exposure.map { detail ->
|
||||
ApprovedAmount(
|
||||
approvedAmount = detail.value.toBigDecimalOrNull() ?: approval ?: return@mapNotNull null,
|
||||
approvedAmount = detail.value?.toBigDecimalOrNull() ?: approval ?: 1.toBigDecimal(),
|
||||
isUnlimited = isUnlimited,
|
||||
tokenInfo = tokenInfo,
|
||||
)
|
||||
|
|
@ -112,7 +112,7 @@ internal object BlockAidMapper {
|
|||
return if (!amounts.isNullOrEmpty()) {
|
||||
SimulationResult.Success(SimulationData.Approve(amounts))
|
||||
} else {
|
||||
SimulationResult.FailedToSimulate
|
||||
SimulationResult.Success(SimulationData.NoWalletChangesDetected)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,8 +124,8 @@ internal object BlockAidMapper {
|
|||
val token = TokenInfo(
|
||||
chainId = diff.asset.chainId,
|
||||
logoUrl = diff.asset.logoUrl,
|
||||
symbol = diff.asset.symbol,
|
||||
decimals = diff.asset.decimals,
|
||||
symbol = diff.asset.symbol ?: "",
|
||||
decimals = diff.asset.decimals ?: 0,
|
||||
)
|
||||
diff.outTransfer.orEmpty().forEach { transfer ->
|
||||
transfer.value?.toBigDecimalOrNull()?.let { amount ->
|
||||
|
|
@ -142,7 +142,7 @@ internal object BlockAidMapper {
|
|||
return if (sendInfo.isNotEmpty() || receiveInfo.isNotEmpty()) {
|
||||
SimulationResult.Success(SimulationData.SendAndReceive(send = sendInfo, receive = receiveInfo))
|
||||
} else {
|
||||
SimulationResult.FailedToSimulate
|
||||
SimulationResult.Success(SimulationData.NoWalletChangesDetected)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ internal object BlockAidMapper {
|
|||
return if (!sendInfo.isNullOrEmpty()) {
|
||||
SimulationResult.Success(SimulationData.SendAndReceive(send = sendInfo, receive = listOf()))
|
||||
} else {
|
||||
SimulationResult.FailedToSimulate
|
||||
SimulationResult.Success(SimulationData.NoWalletChangesDetected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ class BlockAidMapperTest {
|
|||
|
||||
val result = mapper.mapToDomain(response)
|
||||
Truth.assertThat(result.validation).isEqualTo(ValidationResult.FAILED_TO_VALIDATE)
|
||||
Truth.assertThat(result.simulation is SimulationResult.FailedToSimulate).isTrue()
|
||||
Truth.assertThat(result.simulation is SimulationResult.Success).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -160,6 +160,6 @@ class BlockAidMapperTest {
|
|||
)
|
||||
|
||||
val result = mapper.mapToDomain(txResponse)
|
||||
Truth.assertThat(result.simulation is SimulationResult.FailedToSimulate).isTrue()
|
||||
Truth.assertThat(result.simulation is SimulationResult.Success).isTrue()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue