Updated on 2026-08-14
This commit is contained in:
parent
a829b05a4d
commit
40893754c5
3 changed files with 16 additions and 48 deletions
|
|
@ -11,31 +11,19 @@ data class P2PEthPoolBroadcastResponse(
|
|||
@Json(name = "hash")
|
||||
val hash: String,
|
||||
@Json(name = "status")
|
||||
val status: P2PEthPoolTxStatusDTO,
|
||||
val status: String,
|
||||
@Json(name = "blockNumber")
|
||||
val blockNumber: Int,
|
||||
val blockNumber: Int? = null,
|
||||
@Json(name = "transactionIndex")
|
||||
val transactionIndex: Int,
|
||||
val transactionIndex: Int? = null,
|
||||
@Json(name = "gasUsed")
|
||||
val gasUsed: String,
|
||||
val gasUsed: String? = null,
|
||||
@Json(name = "cumulativeGasUsed")
|
||||
val cumulativeGasUsed: String,
|
||||
val cumulativeGasUsed: String? = null,
|
||||
@Json(name = "effectiveGasPrice")
|
||||
val effectiveGasPrice: String?,
|
||||
val effectiveGasPrice: String? = null,
|
||||
@Json(name = "from")
|
||||
val from: String,
|
||||
@Json(name = "to")
|
||||
val to: String,
|
||||
)
|
||||
|
||||
/**
|
||||
* Transaction status from P2PEthPool API
|
||||
*/
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class P2PEthPoolTxStatusDTO {
|
||||
@Json(name = "success")
|
||||
SUCCESS,
|
||||
|
||||
@Json(name = "failed")
|
||||
FAILED,
|
||||
}
|
||||
)
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
package com.tangem.data.staking.converters.ethpool
|
||||
|
||||
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.P2PEthPoolBroadcastStatus
|
||||
import com.tangem.utils.converter.Converter
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Converter from P2PEthPool Broadcast Transaction Response to Domain model
|
||||
|
|
@ -15,21 +12,14 @@ internal object P2PEthPoolBroadcastResultConverter : Converter<P2PEthPoolBroadca
|
|||
override fun convert(value: P2PEthPoolBroadcastResponse): P2PEthPoolBroadcastResult {
|
||||
return P2PEthPoolBroadcastResult(
|
||||
hash = value.hash,
|
||||
status = convertStatus(value.status),
|
||||
status = value.status,
|
||||
blockNumber = value.blockNumber,
|
||||
transactionIndex = value.transactionIndex,
|
||||
gasUsed = value.gasUsed.toBigDecimalOrNull() ?: BigDecimal.ZERO,
|
||||
cumulativeGasUsed = value.cumulativeGasUsed.toBigDecimalOrNull() ?: BigDecimal.ZERO,
|
||||
gasUsed = value.gasUsed?.toBigDecimalOrNull(),
|
||||
cumulativeGasUsed = value.cumulativeGasUsed?.toBigDecimalOrNull(),
|
||||
effectiveGasPrice = value.effectiveGasPrice?.toBigDecimalOrNull(),
|
||||
from = value.from,
|
||||
to = value.to,
|
||||
)
|
||||
}
|
||||
|
||||
private fun convertStatus(status: P2PEthPoolTxStatusDTO): P2PEthPoolBroadcastStatus {
|
||||
return when (status) {
|
||||
P2PEthPoolTxStatusDTO.SUCCESS -> P2PEthPoolBroadcastStatus.SUCCESS
|
||||
P2PEthPoolTxStatusDTO.FAILED -> P2PEthPoolBroadcastStatus.FAILED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.domain.staking.model.ethpool
|
||||
|
||||
import com.tangem.domain.models.serialization.SerializedBigDecimal
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* P2P.org transaction broadcast result
|
||||
|
|
@ -9,21 +8,12 @@ import kotlinx.serialization.Serializable
|
|||
*/
|
||||
data class P2PEthPoolBroadcastResult(
|
||||
val hash: String,
|
||||
val status: P2PEthPoolBroadcastStatus,
|
||||
val blockNumber: Int,
|
||||
val transactionIndex: Int,
|
||||
val gasUsed: SerializedBigDecimal,
|
||||
val cumulativeGasUsed: SerializedBigDecimal,
|
||||
val status: String,
|
||||
val blockNumber: Int?,
|
||||
val transactionIndex: Int?,
|
||||
val gasUsed: SerializedBigDecimal?,
|
||||
val cumulativeGasUsed: SerializedBigDecimal?,
|
||||
val effectiveGasPrice: SerializedBigDecimal?,
|
||||
val from: String,
|
||||
val to: String,
|
||||
)
|
||||
|
||||
/**
|
||||
* Transaction broadcast status
|
||||
*/
|
||||
@Serializable
|
||||
enum class P2PEthPoolBroadcastStatus {
|
||||
SUCCESS, // Transaction confirmed successfully
|
||||
FAILED, // Transaction failed
|
||||
}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue