Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-02 14:35:09 +03:00
parent a829b05a4d
commit 40893754c5
3 changed files with 16 additions and 48 deletions

View file

@ -11,31 +11,19 @@ data class P2PEthPoolBroadcastResponse(
@Json(name = "hash") @Json(name = "hash")
val hash: String, val hash: String,
@Json(name = "status") @Json(name = "status")
val status: P2PEthPoolTxStatusDTO, val status: String,
@Json(name = "blockNumber") @Json(name = "blockNumber")
val blockNumber: Int, val blockNumber: Int? = null,
@Json(name = "transactionIndex") @Json(name = "transactionIndex")
val transactionIndex: Int, val transactionIndex: Int? = null,
@Json(name = "gasUsed") @Json(name = "gasUsed")
val gasUsed: String, val gasUsed: String? = null,
@Json(name = "cumulativeGasUsed") @Json(name = "cumulativeGasUsed")
val cumulativeGasUsed: String, val cumulativeGasUsed: String? = null,
@Json(name = "effectiveGasPrice") @Json(name = "effectiveGasPrice")
val effectiveGasPrice: String?, val effectiveGasPrice: String? = null,
@Json(name = "from") @Json(name = "from")
val from: String, val from: String,
@Json(name = "to") @Json(name = "to")
val to: String, val to: String,
) )
/**
* Transaction status from P2PEthPool API
*/
@JsonClass(generateAdapter = false)
enum class P2PEthPoolTxStatusDTO {
@Json(name = "success")
SUCCESS,
@Json(name = "failed")
FAILED,
}

View file

@ -1,11 +1,8 @@
package com.tangem.data.staking.converters.ethpool package com.tangem.data.staking.converters.ethpool
import com.tangem.datasource.api.ethpool.models.response.P2PEthPoolBroadcastResponse import com.tangem.datasource.api.ethpool.models.response.P2PEthPoolBroadcastResponse
import com.tangem.datasource.api.ethpool.models.response.P2PEthPoolTxStatusDTO
import com.tangem.domain.staking.model.ethpool.P2PEthPoolBroadcastResult import com.tangem.domain.staking.model.ethpool.P2PEthPoolBroadcastResult
import com.tangem.domain.staking.model.ethpool.P2PEthPoolBroadcastStatus
import com.tangem.utils.converter.Converter import com.tangem.utils.converter.Converter
import java.math.BigDecimal
/** /**
* Converter from P2PEthPool Broadcast Transaction Response to Domain model * Converter from P2PEthPool Broadcast Transaction Response to Domain model
@ -15,21 +12,14 @@ internal object P2PEthPoolBroadcastResultConverter : Converter<P2PEthPoolBroadca
override fun convert(value: P2PEthPoolBroadcastResponse): P2PEthPoolBroadcastResult { override fun convert(value: P2PEthPoolBroadcastResponse): P2PEthPoolBroadcastResult {
return P2PEthPoolBroadcastResult( return P2PEthPoolBroadcastResult(
hash = value.hash, hash = value.hash,
status = convertStatus(value.status), status = value.status,
blockNumber = value.blockNumber, blockNumber = value.blockNumber,
transactionIndex = value.transactionIndex, transactionIndex = value.transactionIndex,
gasUsed = value.gasUsed.toBigDecimalOrNull() ?: BigDecimal.ZERO, gasUsed = value.gasUsed?.toBigDecimalOrNull(),
cumulativeGasUsed = value.cumulativeGasUsed.toBigDecimalOrNull() ?: BigDecimal.ZERO, cumulativeGasUsed = value.cumulativeGasUsed?.toBigDecimalOrNull(),
effectiveGasPrice = value.effectiveGasPrice?.toBigDecimalOrNull(), effectiveGasPrice = value.effectiveGasPrice?.toBigDecimalOrNull(),
from = value.from, from = value.from,
to = value.to, to = value.to,
) )
} }
private fun convertStatus(status: P2PEthPoolTxStatusDTO): P2PEthPoolBroadcastStatus {
return when (status) {
P2PEthPoolTxStatusDTO.SUCCESS -> P2PEthPoolBroadcastStatus.SUCCESS
P2PEthPoolTxStatusDTO.FAILED -> P2PEthPoolBroadcastStatus.FAILED
}
}
} }

View file

@ -1,7 +1,6 @@
package com.tangem.domain.staking.model.ethpool package com.tangem.domain.staking.model.ethpool
import com.tangem.domain.models.serialization.SerializedBigDecimal import com.tangem.domain.models.serialization.SerializedBigDecimal
import kotlinx.serialization.Serializable
/** /**
* P2P.org transaction broadcast result * P2P.org transaction broadcast result
@ -9,21 +8,12 @@ import kotlinx.serialization.Serializable
*/ */
data class P2PEthPoolBroadcastResult( data class P2PEthPoolBroadcastResult(
val hash: String, val hash: String,
val status: P2PEthPoolBroadcastStatus, val status: String,
val blockNumber: Int, val blockNumber: Int?,
val transactionIndex: Int, val transactionIndex: Int?,
val gasUsed: SerializedBigDecimal, val gasUsed: SerializedBigDecimal?,
val cumulativeGasUsed: SerializedBigDecimal, val cumulativeGasUsed: SerializedBigDecimal?,
val effectiveGasPrice: SerializedBigDecimal?, val effectiveGasPrice: SerializedBigDecimal?,
val from: String, val from: String,
val to: String, val to: String,
) )
/**
* Transaction broadcast status
*/
@Serializable
enum class P2PEthPoolBroadcastStatus {
SUCCESS, // Transaction confirmed successfully
FAILED, // Transaction failed
}