diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d6e5a6b..45cb2dd 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -41,7 +41,7 @@ - This is **Kogmios**, a Kotlin client library for the Ogmios WebSocket interface - Single-module Gradle project (Kotlin DSL) targeting Java 21 -- Core tech: Kotlin 2.x, Ktor client (CIO + websockets), kotlinx-serialization, coroutines +- Core tech: Kotlin 2.x, Ktor client (CIO + websockets), Jackson, coroutines - Domain: Cardano/Ogmios JSON-WSP protocol messages mapped to typed models ## CI Pipeline Context diff --git a/build.gradle.kts b/build.gradle.kts index a86d973..bb65c84 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,16 +3,15 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { java - id("com.github.ben-manes.versions") version Versions.VERSIONS_PLUGIN + id("io.github.ben-manes.versions") version Versions.VERSIONS_PLUGIN id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT_PLUGIN kotlin("jvm") version Versions.KOTLIN - kotlin("plugin.serialization") version Versions.KOTLIN id("signing") id("com.vanniktech.maven.publish") version Versions.MAVEN_PUBLISH } group = "io.newm" -version = "2.7.1-SNAPSHOT" +version = "3.0.0-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_21 java.targetCompatibility = JavaVersion.VERSION_21 @@ -36,7 +35,10 @@ dependencies { implementation("ch.qos.logback:logback-classic:${Versions.LOGBACK}") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES}") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.COROUTINES}") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLINX_SERIALIZATION}") + implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.JACKSON}")) + implementation("com.fasterxml.jackson.core:jackson-databind") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("org.jetbrains.kotlin:kotlin-reflect:${Versions.KOTLIN}") implementation("org.apache.commons:commons-numbers-fraction:${Versions.COMMONS_NUMBERS}") @@ -126,7 +128,6 @@ tasks.withType { listOf( "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn", - "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-opt-in=kotlin.time.ExperimentalTime", ) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 275f459..0d0d51e 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,17 +1,17 @@ object Versions { - const val COMMONS_LOGGING = "1.3.5" - const val COMMONS_NUMBERS = "1.2" - const val COROUTINES = "1.10.2" + const val COMMONS_LOGGING = "1.4.0" + const val COMMONS_NUMBERS = "1.3" + const val COROUTINES = "1.11.0" const val GOOGLE_TRUTH = "1.4.5" - const val JUNIT = "6.0.2" - const val JUNIT_PLATFORM = "6.0.2" - const val KOTLIN = "2.3.0" - const val KOTLINX_SERIALIZATION = "1.10.0" + const val JUNIT = "6.1.3" + const val JUNIT_PLATFORM = "6.1.3" + const val KOTLIN = "2.4.20" + const val JACKSON = "2.22.2" const val KTLINT = "1.8.0" const val KTLINT_PLUGIN = "14.0.1" - const val KTOR = "3.4.0" - const val LOGBACK = "1.5.27" - const val MOCKK = "1.14.9" - const val MAVEN_PUBLISH = "0.36.0" - const val VERSIONS_PLUGIN = "0.53.0" + const val KTOR = "3.6.0" + const val LOGBACK = "1.6.3" + const val MOCKK = "1.14.11" + const val MAVEN_PUBLISH = "0.37.0" + const val VERSIONS_PLUGIN = "0.63.1" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60..61285a6 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37f78a6..c42672d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/kotlin/io/newm/kogmios/ClientImpl.kt b/src/main/kotlin/io/newm/kogmios/ClientImpl.kt index e93250a..4d96903 100644 --- a/src/main/kotlin/io/newm/kogmios/ClientImpl.kt +++ b/src/main/kotlin/io/newm/kogmios/ClientImpl.kt @@ -50,7 +50,6 @@ import io.newm.kogmios.protocols.messages.MsgQueryGenesisConfigResponse import io.newm.kogmios.protocols.messages.MsgQueryLiveStakeDistributionResponse import io.newm.kogmios.protocols.messages.MsgQueryNetworkStartTimeResponse import io.newm.kogmios.protocols.messages.MsgQueryProjectedRewardsResponse -import io.newm.kogmios.protocols.messages.MsgQueryProposedProtocolParametersResponse import io.newm.kogmios.protocols.messages.MsgQueryProtocolParametersResponse import io.newm.kogmios.protocols.messages.MsgQueryRewardAccountSummariesResponse import io.newm.kogmios.protocols.messages.MsgQueryStakePoolsResponse @@ -78,10 +77,8 @@ import io.newm.kogmios.protocols.model.StakePool import io.newm.kogmios.protocols.model.fault.InternalErrorFault import io.newm.kogmios.protocols.model.fault.StringFaultData import io.newm.kogmios.protocols.model.result.HealthResult -import io.newm.kogmios.serializers.BigFractionSerializer -import io.newm.kogmios.serializers.BigIntegerSerializer +import io.newm.kogmios.serializers.OgmiosJson import java.io.IOException -import java.math.BigInteger import java.util.concurrent.ConcurrentHashMap import kotlin.coroutines.CoroutineContext import kotlin.coroutines.cancellation.CancellationException @@ -104,9 +101,6 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withTimeout -import kotlinx.serialization.json.Json -import kotlinx.serialization.modules.SerializersModule -import org.apache.commons.numbers.fraction.BigFraction import org.slf4j.LoggerFactory internal class ClientImpl( @@ -159,7 +153,7 @@ internal class ClientImpl( return Frame.Text( when (value) { is JsonRpcRequest -> { - json.encodeToString(value).also { + OgmiosJson.mapper.writeValueAsString(value).also { // temporary while we need to figure out how all the requests look log.debug("sending: {}", it) } @@ -186,7 +180,7 @@ internal class ClientImpl( val jsonString = (content as Frame.Text).readText() log.debug("received: {}", jsonString) return try { - json.decodeFromString(jsonString) + OgmiosJson.mapper.readValue(jsonString, JsonRpcResponse::class.java) } catch (e: Throwable) { // This should never happen unless WE have made an error in our parsers somewhere. val idRegex = @@ -539,20 +533,6 @@ internal class ClientImpl( } } - override suspend fun proposedProtocolParameters(timeoutMs: Long): MsgQueryProposedProtocolParametersResponse { - assertConnected() - val message = - MsgQuery( - method = MsgQuery.METHOD_QUERY_LEDGER_STATE_PROPOSED_PROTOCOL_PARAMETERS, - ) - sendQueue.send(message) - return coroutineScope { - withTimeout(timeoutMs) { - message.completableDeferred.await() as MsgQueryProposedProtocolParametersResponse - } - } - } - override suspend fun liveStakeDistribution(timeoutMs: Long): MsgQueryLiveStakeDistributionResponse { assertConnected() val message = @@ -602,7 +582,7 @@ internal class ClientImpl( override suspend fun health(): HealthResult { val response = httpClient.get("http://$websocketHost:$websocketPort/health") val jsonBody = response.bodyAsText() - return json.decodeFromString(jsonBody) + return OgmiosJson.mapper.readValue(jsonBody, HealthResult::class.java) } override suspend fun acquireMempool(timeoutMs: Long): MsgAcquireMempoolResponse { @@ -764,20 +744,4 @@ internal class ClientImpl( override val coroutineContext: CoroutineContext by lazy { job + Dispatchers.IO + DefaultCoroutineExceptionHandler(log) } - - companion object { - internal val json = - Json { - // classDiscriminator = "type" - encodeDefaults = true - explicitNulls = true - ignoreUnknownKeys = true - isLenient = true - serializersModule = - SerializersModule { - contextual(BigInteger::class, BigIntegerSerializer) - contextual(BigFraction::class, BigFractionSerializer) - } - } - } } diff --git a/src/main/kotlin/io/newm/kogmios/StateQueryClient.kt b/src/main/kotlin/io/newm/kogmios/StateQueryClient.kt index f97e861..4e86316 100644 --- a/src/main/kotlin/io/newm/kogmios/StateQueryClient.kt +++ b/src/main/kotlin/io/newm/kogmios/StateQueryClient.kt @@ -13,7 +13,6 @@ import io.newm.kogmios.protocols.messages.MsgQueryGenesisConfigResponse import io.newm.kogmios.protocols.messages.MsgQueryLiveStakeDistributionResponse import io.newm.kogmios.protocols.messages.MsgQueryNetworkStartTimeResponse import io.newm.kogmios.protocols.messages.MsgQueryProjectedRewardsResponse -import io.newm.kogmios.protocols.messages.MsgQueryProposedProtocolParametersResponse import io.newm.kogmios.protocols.messages.MsgQueryProtocolParametersResponse import io.newm.kogmios.protocols.messages.MsgQueryRewardAccountSummariesResponse import io.newm.kogmios.protocols.messages.MsgQueryStakePoolsResponse @@ -108,11 +107,6 @@ interface StateQueryClient : Client { timeoutMs: Long = LONG_REQUEST_TIMEOUT_MS ): MsgQueryProjectedRewardsResponse - /** - * Get proposed protocol parameters for update, if any. - */ - suspend fun proposedProtocolParameters(timeoutMs: Long = DEFAULT_REQUEST_TIMEOUT_MS): MsgQueryProposedProtocolParametersResponse - /** * Get the current stake pool distribution. This request may be quite long, use with care. */ diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcErrorResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcErrorResponse.kt index 638e3de..28dfafe 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcErrorResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcErrorResponse.kt @@ -1,19 +1,20 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonIgnore import io.newm.kogmios.protocols.model.fault.Fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient /** * Container for an error response from Ogmios */ -@Serializable data class JsonRpcErrorResponse( - @SerialName("error") + @param:JsonProperty(value = "error", required = true) + @get:JsonProperty("error") val error: Fault, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, - @Transient + @get:JsonIgnore val cause: Throwable? = null, ) : JsonRpcResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcRequest.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcRequest.kt index 05b7038..8d2d444 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcRequest.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcRequest.kt @@ -1,25 +1,19 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonIgnore import io.newm.kogmios.protocols.Const.JSONRPC_VERSION import kotlinx.coroutines.CompletableDeferred -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient /** * Base class for all Ogmios requests */ -@Serializable sealed class JsonRpcRequest { - @SerialName("jsonrpc") val jsonrpc: String = JSONRPC_VERSION - @SerialName("method") abstract val method: String - @SerialName("id") abstract val id: String - @Transient + @get:JsonIgnore val completableDeferred: CompletableDeferred = CompletableDeferred() } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcResponse.kt index eff8869..6fe7c76 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcResponse.kt @@ -1,18 +1,12 @@ package io.newm.kogmios.protocols.messages import io.newm.kogmios.protocols.Const.JSONRPC_VERSION -import io.newm.kogmios.serializers.JsonRpcResponseSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Base class for all Ogmios responses. */ -@Serializable(with = JsonRpcResponseSerializer::class) sealed class JsonRpcResponse { - @SerialName("jsonrpc") val jsonrpc: String = JSONRPC_VERSION - @SerialName("id") abstract val id: String } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcSuccessResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcSuccessResponse.kt index 3676d2b..367c835 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcSuccessResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/JsonRpcSuccessResponse.kt @@ -1,17 +1,12 @@ package io.newm.kogmios.protocols.messages -import io.newm.kogmios.protocols.model.result.IgnoredOgmiosResult +import com.fasterxml.jackson.annotation.JsonTypeInfo import io.newm.kogmios.protocols.model.result.OgmiosResult -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient -import kotlinx.serialization.json.JsonClassDiscriminator /** * Container for a success response from Ogmios */ -@Serializable -@JsonClassDiscriminator("method") -sealed class JsonRpcSuccessResponse( - @Transient - open val result: OgmiosResult = IgnoredOgmiosResult, -) : JsonRpcResponse() +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "method") +sealed class JsonRpcSuccessResponse : JsonRpcResponse() { + abstract val result: OgmiosResult +} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquire.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquire.kt index bc14430..bcc8fb0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquire.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquire.kt @@ -1,21 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.PointOrOrigin -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable + import java.util.UUID /** * Acquire a ledger state for the Local State Query miniprotocol. If you don't specify a ChainPoint argument, * the ledger tip will be acquired. */ -@Serializable + data class MsgAcquire( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("params") + @param:JsonProperty(value = "params", required = true) + @get:JsonProperty("params") val params: PointOrOrigin, - @SerialName("id") override val id: String = "$METHOD_NAME: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempool.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempool.kt index 9f5d45e..52f3103 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempool.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempool.kt @@ -1,17 +1,13 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Acquire a mempool snapshot */ -@Serializable + data class MsgAcquireMempool( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempoolResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempoolResponse.kt index f06c757..22b13af 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempoolResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireMempoolResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.AcquireMempoolResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after an AwaitAcquire message is sent. */ -@Serializable -@SerialName(MsgAcquireMempool.METHOD_NAME) + +@JsonTypeName(MsgAcquireMempool.METHOD_NAME) data class MsgAcquireMempoolResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: AcquireMempoolResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireResponse.kt index 61c0872..225fbb1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgAcquireResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.AcquireResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after an acquire message is sent. */ -@Serializable -@SerialName(MsgAcquire.METHOD_NAME) + +@JsonTypeName(MsgAcquire.METHOD_NAME) data class MsgAcquireResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: AcquireResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTx.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTx.kt index 4b03d04..6960e39 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTx.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTx.kt @@ -1,19 +1,18 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.util.UUID /** * Evaluate the costs for a transaction */ -@Serializable + data class MsgEvaluateTx( - @SerialName("method") override val method: String = METHOD_EVALUATE_TX, - @SerialName("params") + @param:JsonProperty(value = "params", required = true) + @get:JsonProperty("params") val params: SubmitOrEvalTx, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTxResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTxResponse.kt index 398092e..fece308 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTxResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgEvaluateTxResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.EvaluateTxResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a MsgEvaluateTx message is sent. */ -@Serializable -@SerialName(MsgEvaluateTx.METHOD_EVALUATE_TX) + +@JsonTypeName(MsgEvaluateTx.METHOD_EVALUATE_TX) data class MsgEvaluateTxResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: EvaluateTxResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersect.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersect.kt index 1756768..31106b0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersect.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersect.kt @@ -1,20 +1,20 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.FindIntersect -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable + import java.util.UUID /** * Acquire a point of intersection for syncing the blockchain */ -@Serializable + data class MsgFindIntersect( - @SerialName("method") override val method: String = METHOD_FIND_INTERSECTION, - @SerialName("params") + @param:JsonProperty(value = "params", required = true) + @get:JsonProperty("params") val params: FindIntersect, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersectResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersectResponse.kt index 3aa0b77..79ffedc 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersectResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgFindIntersectResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.IntersectionFoundResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a MsgFindIntersect message is sent. */ -@Serializable -@SerialName(MsgFindIntersect.METHOD_FIND_INTERSECTION) + +@JsonTypeName(MsgFindIntersect.METHOD_FIND_INTERSECTION) data class MsgFindIntersectResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: IntersectionFoundResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransaction.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransaction.kt index 5091285..876be21 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransaction.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransaction.kt @@ -1,19 +1,18 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.util.UUID /** * Check whether the mempool snapshot has a given transaction in it. */ -@Serializable + data class MsgHasTransaction( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("params") + @param:JsonProperty(value = "params", required = true) + @get:JsonProperty("params") val params: HasTransaction, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { @@ -21,8 +20,8 @@ data class MsgHasTransaction( } } -@Serializable data class HasTransaction( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransactionResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransactionResponse.kt index 16e85b4..fb45b8c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransactionResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgHasTransactionResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.BooleanResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a hasTransaction mempool message is sent. */ -@Serializable -@SerialName(MsgHasTransaction.METHOD_NAME) + +@JsonTypeName(MsgHasTransaction.METHOD_NAME) data class MsgHasTransactionResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: BooleanResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlock.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlock.kt index 5167ea4..94e5b59 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlock.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlock.kt @@ -1,17 +1,13 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Request the next block when syncing the blockchain. */ -@Serializable + data class MsgNextBlock( - @SerialName("method") override val method: String = METHOD_NEXT_BLOCK, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlockResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlockResponse.kt index d77c7c5..21b964e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlockResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextBlockResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.NextBlockResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a nextBlock message is sent. */ -@Serializable -@SerialName(MsgNextBlock.METHOD_NEXT_BLOCK) + +@JsonTypeName(MsgNextBlock.METHOD_NEXT_BLOCK) data class MsgNextBlockResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: NextBlockResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransaction.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransaction.kt index 58bf6b0..f13e0df 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransaction.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransaction.kt @@ -1,19 +1,14 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Request the Next transaction from the mempool snapshot */ -@Serializable + data class MsgNextTransaction( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("params") val params: Fields = Fields(), - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { @@ -21,8 +16,6 @@ data class MsgNextTransaction( } } -@Serializable data class Fields( - @SerialName("fields") val fields: String = "all", ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransactionResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransactionResponse.kt index fc46914..c71ced3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransactionResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgNextTransactionResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.TxResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a nextTransaction mempool message is sent. */ -@Serializable -@SerialName(MsgNextTransaction.METHOD_NAME) + +@JsonTypeName(MsgNextTransaction.METHOD_NAME) data class MsgNextTransactionResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: TxResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQuery.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQuery.kt index 6de6418..0da0b82 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQuery.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQuery.kt @@ -1,20 +1,20 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.Params -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable + import java.util.UUID /** * Message sent to query various ledger state items. */ -@Serializable + data class MsgQuery( - @SerialName("method") + @param:JsonProperty(value = "method", required = true) + @get:JsonProperty("method") override val method: String, - @SerialName("params") val params: Params? = null, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { @@ -28,7 +28,6 @@ data class MsgQuery( const val METHOD_QUERY_LEDGER_STATE_LIVE_STAKE_DISTRIBUTION = "queryLedgerState/liveStakeDistribution" const val METHOD_QUERY_LEDGER_STATE_PROJECTED_REWARDS = "queryLedgerState/projectedRewards" const val METHOD_QUERY_LEDGER_STATE_PROTOCOL_PARAMETERS = "queryLedgerState/protocolParameters" - const val METHOD_QUERY_LEDGER_STATE_PROPOSED_PROTOCOL_PARAMETERS = "queryLedgerState/proposedProtocolParameters" const val METHOD_QUERY_LEDGER_STATE_REWARD_ACCOUNT_SUMMARIES = "queryLedgerState/rewardAccountSummaries" const val METHOD_QUERY_LEDGER_STATE_REWARDS_PROVENANCE = "queryLedgerState/rewardsProvenance" const val METHOD_QUERY_LEDGER_STATE_STAKE_POOLS = "queryLedgerState/stakePools" diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryBlockHeightResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryBlockHeightResponse.kt index 30d52b2..2eb8543 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryBlockHeightResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryBlockHeightResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.LongResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryNetworkBlockHeight message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_NETWORK_BLOCK_HEIGHT) + +@JsonTypeName(MsgQuery.METHOD_QUERY_NETWORK_BLOCK_HEIGHT) data class MsgQueryBlockHeightResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: LongResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEpochResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEpochResponse.kt index 2c458eb..4b87ec6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEpochResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEpochResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.LongResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateEpoch message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_EPOCH) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_EPOCH) data class MsgQueryEpochResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: LongResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraStartResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraStartResponse.kt index 7528b62..f4bed6b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraStartResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraStartResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.Bound -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateEraStart message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_ERA_START) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_ERA_START) data class MsgQueryEraStartResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: Bound, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraSummariesResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraSummariesResponse.kt index 643f96f..53007e2 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraSummariesResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryEraSummariesResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.EraSummariesResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateEraSummaries message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_ERA_SUMMARIES) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_ERA_SUMMARIES) data class MsgQueryEraSummariesResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: EraSummariesResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryGenesisConfigResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryGenesisConfigResponse.kt index 17bec4b..74203e1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryGenesisConfigResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryGenesisConfigResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.GenesisConfigResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryNetworkGenesisConfiguration message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_NETWORK_GENESIS_CONFIGURATION) + +@JsonTypeName(MsgQuery.METHOD_QUERY_NETWORK_GENESIS_CONFIGURATION) data class MsgQueryGenesisConfigResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: GenesisConfigResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryLiveStakeDistributionResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryLiveStakeDistributionResponse.kt index 4cfe885..a2c15fe 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryLiveStakeDistributionResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryLiveStakeDistributionResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.LiveStakeDistributionResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateLiveStakeDistribution message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_LIVE_STAKE_DISTRIBUTION) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_LIVE_STAKE_DISTRIBUTION) data class MsgQueryLiveStakeDistributionResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: LiveStakeDistributionResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryNetworkStartTimeResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryNetworkStartTimeResponse.kt index fd9beda..d8b4c87 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryNetworkStartTimeResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryNetworkStartTimeResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.InstantResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryNetworkStartTime message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_NETWORK_START_TIME) + +@JsonTypeName(MsgQuery.METHOD_QUERY_NETWORK_START_TIME) data class MsgQueryNetworkStartTimeResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: InstantResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProjectedRewardsResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProjectedRewardsResponse.kt index 4a402be..28587d1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProjectedRewardsResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProjectedRewardsResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.ProjectedRewardsResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateProjectedRewards message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_PROJECTED_REWARDS) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_PROJECTED_REWARDS) data class MsgQueryProjectedRewardsResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: ProjectedRewardsResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProposedProtocolParametersResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProposedProtocolParametersResponse.kt deleted file mode 100644 index 03a2d92..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProposedProtocolParametersResponse.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.newm.kogmios.protocols.messages - -import io.newm.kogmios.protocols.model.result.ProposedProtocolParametersResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -/** - * Response that comes back from Ogmios after a queryLedgerStateProposedProtocolParameters message is sent. - */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_PROPOSED_PROTOCOL_PARAMETERS) -data class MsgQueryProposedProtocolParametersResponse( - @SerialName("result") - override val result: ProposedProtocolParametersResult, - @SerialName("id") - override val id: String, -) : JsonRpcSuccessResponse(result) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProtocolParametersResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProtocolParametersResponse.kt index 5ce4854..a4d6dba 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProtocolParametersResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryProtocolParametersResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.ProtocolParametersResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateProtocolParameters message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_PROTOCOL_PARAMETERS) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_PROTOCOL_PARAMETERS) data class MsgQueryProtocolParametersResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: ProtocolParametersResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryRewardAccountSummariesResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryRewardAccountSummariesResponse.kt index 6b9aba6..8aca00b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryRewardAccountSummariesResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryRewardAccountSummariesResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.RewardAccountSummariesResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateRewardAccountSummaries message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_REWARD_ACCOUNT_SUMMARIES) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_REWARD_ACCOUNT_SUMMARIES) data class MsgQueryRewardAccountSummariesResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: RewardAccountSummariesResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryStakePoolsResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryStakePoolsResponse.kt index 51dcec5..efe19aa 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryStakePoolsResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryStakePoolsResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.StakePoolsResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateStakePools message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_STAKE_POOLS) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_STAKE_POOLS) data class MsgQueryStakePoolsResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: StakePoolsResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryTipResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryTipResponse.kt index ce10975..95d89c8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryTipResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryTipResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.TipResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryNetworkTip message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_NETWORK_TIP) + +@JsonTypeName(MsgQuery.METHOD_QUERY_NETWORK_TIP) data class MsgQueryTipResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: TipResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryUtxoResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryUtxoResponse.kt index e46c80f..b86e6a8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryUtxoResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgQueryUtxoResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.UtxoResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a queryLedgerStateUtxo message is sent. */ -@Serializable -@SerialName(MsgQuery.METHOD_QUERY_LEDGER_STATE_UTXO) + +@JsonTypeName(MsgQuery.METHOD_QUERY_LEDGER_STATE_UTXO) data class MsgQueryUtxoResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: UtxoResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgRelease.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgRelease.kt index 16d442e..82d85ec 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgRelease.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgRelease.kt @@ -1,17 +1,13 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Release the Acquired ledger state for the Local State Query miniprotocol. */ -@Serializable + data class MsgRelease( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempool.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempool.kt index 89ccd77..3686a94 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempool.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempool.kt @@ -1,17 +1,13 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Release mempool snapshot */ -@Serializable + data class MsgReleaseMempool( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempoolResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempoolResponse.kt index d88c787..3412be7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempoolResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseMempoolResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.ReleaseMempoolResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a release mempool message is sent. */ -@Serializable -@SerialName(MsgReleaseMempool.METHOD_NAME) + +@JsonTypeName(MsgReleaseMempool.METHOD_NAME) data class MsgReleaseMempoolResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: ReleaseMempoolResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseResponse.kt index 4808c2c..426bed5 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgReleaseResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.ReleaseResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a release message is sent. */ -@Serializable -@SerialName(MsgRelease.METHOD_NAME) + +@JsonTypeName(MsgRelease.METHOD_NAME) data class MsgReleaseResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: ReleaseResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, -) : JsonRpcSuccessResponse(result) +) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempool.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempool.kt index 38c6546..36f0dcd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempool.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempool.kt @@ -1,17 +1,13 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.util.UUID /** * Check the mempool size and capacity values */ -@Serializable + data class MsgSizeOfMempool( - @SerialName("method") override val method: String = METHOD_NAME, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempoolResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempoolResponse.kt index a43aeac..f7b37ba 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempoolResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSizeOfMempoolResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.SizeOfMempoolResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a sizeOfMempool message is sent. */ -@Serializable -@SerialName(MsgSizeOfMempool.METHOD_NAME) + +@JsonTypeName(MsgSizeOfMempool.METHOD_NAME) data class MsgSizeOfMempoolResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: SizeOfMempoolResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTx.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTx.kt index 931df54..1fd6d8d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTx.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTx.kt @@ -1,19 +1,18 @@ package io.newm.kogmios.protocols.messages -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.util.UUID /** * Submit a transaction to the node's mempool. */ -@Serializable + data class MsgSubmitTx( - @SerialName("method") override val method: String = METHOD_SUBMIT_TX, - @SerialName("params") + @param:JsonProperty(value = "params", required = true) + @get:JsonProperty("params") val params: SubmitOrEvalTx, - @SerialName("id") override val id: String = "$method: ${UUID.randomUUID()}", ) : JsonRpcRequest() { companion object { @@ -21,14 +20,14 @@ data class MsgSubmitTx( } } -@Serializable data class SubmitOrEvalTx( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Cbor, ) -@Serializable data class Cbor( - @SerialName("cbor") + @param:JsonProperty(value = "cbor", required = true) + @get:JsonProperty("cbor") val cbor: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTxResponse.kt b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTxResponse.kt index e7ce3af..a9b78eb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTxResponse.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/messages/MsgSubmitTxResponse.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.messages +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.result.SubmitTxResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Response that comes back from Ogmios after a submitTx message is sent. */ -@Serializable -@SerialName(MsgSubmitTx.METHOD_SUBMIT_TX) + +@JsonTypeName(MsgSubmitTx.METHOD_SUBMIT_TX) data class MsgSubmitTxResponse( - @SerialName("result") + @param:JsonProperty(value = "result", required = true) + @get:JsonProperty("result") override val result: SubmitTxResult, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, ) : JsonRpcSuccessResponse() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Ada.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Ada.kt index db1498a..7d39a14 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Ada.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Ada.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Ada( - @SerialName("ada") + @param:JsonProperty(value = "ada", required = true) + @get:JsonProperty("ada") val ada: Lovelace, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/AdaRewardsInput.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/AdaRewardsInput.kt index 3c6b5f4..953352e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/AdaRewardsInput.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/AdaRewardsInput.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable class AdaRewardsInput( - @SerialName("ada") + @param:JsonProperty(value = "ada", required = true) + @get:JsonProperty("ada") val ada: Lovelace, ) : ProjectedRewardsInput diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/AlonzoGenesisProtocolParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/AlonzoGenesisProtocolParameters.kt index 5b6451a..f59bb0b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/AlonzoGenesisProtocolParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/AlonzoGenesisProtocolParameters.kt @@ -1,24 +1,30 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class AlonzoGenesisProtocolParameters( - @SerialName("minUtxoDepositCoefficient") + @param:JsonProperty(value = "minUtxoDepositCoefficient", required = true) + @get:JsonProperty("minUtxoDepositCoefficient") val minUtxoDepositCoefficient: Long, - @SerialName("collateralPercentage") + @param:JsonProperty(value = "collateralPercentage", required = true) + @get:JsonProperty("collateralPercentage") val collateralPercentage: Long, - @SerialName("plutusCostModels") + @param:JsonProperty(value = "plutusCostModels", required = true) + @get:JsonProperty("plutusCostModels") val plutusCostModels: PlutusCostModels, - @SerialName("maxCollateralInputs") + @param:JsonProperty(value = "maxCollateralInputs", required = true) + @get:JsonProperty("maxCollateralInputs") val maxCollateralInputs: Long, - @SerialName("maxExecutionUnitsPerBlock") + @param:JsonProperty(value = "maxExecutionUnitsPerBlock", required = true) + @get:JsonProperty("maxExecutionUnitsPerBlock") val maxExecutionUnitsPerBlock: ExecutionUnits, - @SerialName("maxExecutionUnitsPerTransaction") + @param:JsonProperty(value = "maxExecutionUnitsPerTransaction", required = true) + @get:JsonProperty("maxExecutionUnitsPerTransaction") val maxExecutionUnitsPerTransaction: ExecutionUnits, - @SerialName("maxValueSize") + @param:JsonProperty(value = "maxValueSize", required = true) + @get:JsonProperty("maxValueSize") val maxValueSize: BytesSize, - @SerialName("scriptExecutionPrices") + @param:JsonProperty(value = "scriptExecutionPrices", required = true) + @get:JsonProperty("scriptExecutionPrices") val scriptExecutionPrices: ExecutionPrices, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Asset.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Asset.kt index ef32f43..04cd9a2 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Asset.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Asset.kt @@ -1,17 +1,17 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class Asset( - @SerialName("policyId") + @param:JsonProperty(value = "policyId", required = true) + @get:JsonProperty("policyId") val policyId: String, - @SerialName("name") + @param:JsonProperty(value = "name", required = true) + @get:JsonProperty("name") val name: String, - @Contextual - @SerialName("quantity") + @param:JsonProperty(value = "quantity", required = true) + @get:JsonProperty("quantity") val quantity: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Blake2bDigestCredential.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Blake2bDigestCredential.kt index fef0d58..4cbf720 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Blake2bDigestCredential.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Blake2bDigestCredential.kt @@ -1,9 +1,10 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.Blake2bDigestCredentialSerializer -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue -@Serializable(with = Blake2bDigestCredentialSerializer::class) -class Blake2bDigestCredential( - val digest: String, -) : ProjectedRewardsInput +class Blake2bDigestCredential + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val digest: String, + ) : ProjectedRewardsInput diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Block.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Block.kt index 3755df4..076e665 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Block.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Block.kt @@ -1,21 +1,13 @@ package io.newm.kogmios.protocols.model +import com.fasterxml.jackson.annotation.JsonTypeInfo -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator - -@Serializable -@JsonClassDiscriminator("type") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") sealed interface Block { - @SerialName("era") val era: String - @SerialName("id") val id: String - @SerialName("ancestor") val ancestor: String - @SerialName("height") val height: Long } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockBFT.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockBFT.kt index 1a2387c..296a540 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockBFT.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockBFT.kt @@ -1,31 +1,42 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@SerialName("bft") +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeName("bft") data class BlockBFT( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") override val era: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, - @SerialName("ancestor") + @param:JsonProperty(value = "ancestor", required = true) + @get:JsonProperty("ancestor") override val ancestor: String, - @SerialName("height") + @param:JsonProperty(value = "height", required = true) + @get:JsonProperty("height") override val height: Long, - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("size") + @param:JsonProperty(value = "size", required = true) + @get:JsonProperty("size") val size: BytesSize, - @SerialName("transactions") + @param:JsonProperty(value = "transactions", required = true) + @get:JsonProperty("transactions") val transactions: List, - @SerialName("operationalCertificates") + @param:JsonProperty(value = "operationalCertificates", required = true) + @get:JsonProperty("operationalCertificates") val operationalCertificates: List, - @SerialName("protocol") + @param:JsonProperty(value = "protocol", required = true) + @get:JsonProperty("protocol") val protocol: Protocol, - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: VerificationKey, - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: VerificationKey, ) : Block diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockEBB.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockEBB.kt index af2531d..ac25135 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockEBB.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockEBB.kt @@ -1,17 +1,21 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@SerialName("ebb") +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeName("ebb") data class BlockEBB( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") override val era: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, - @SerialName("ancestor") + @param:JsonProperty(value = "ancestor", required = true) + @get:JsonProperty("ancestor") override val ancestor: String, - @SerialName("height") + @param:JsonProperty(value = "height", required = true) + @get:JsonProperty("height") override val height: Long, ) : Block diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockPraos.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockPraos.kt index e5dd31d..1ee3b4e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/BlockPraos.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/BlockPraos.kt @@ -1,29 +1,37 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@SerialName("praos") +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeName("praos") data class BlockPraos( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") override val era: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") override val id: String, - @SerialName("ancestor") + @param:JsonProperty(value = "ancestor", required = true) + @get:JsonProperty("ancestor") override val ancestor: String, - @SerialName("nonce") val nonce: Nonce? = null, - @SerialName("height") + @param:JsonProperty(value = "height", required = true) + @get:JsonProperty("height") override val height: Long, - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("size") + @param:JsonProperty(value = "size", required = true) + @get:JsonProperty("size") val size: BytesSize, - @SerialName("transactions") + @param:JsonProperty(value = "transactions", required = true) + @get:JsonProperty("transactions") val transactions: List, - @SerialName("protocol") + @param:JsonProperty(value = "protocol", required = true) + @get:JsonProperty("protocol") val protocol: ProtocolVersion, - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: IssuerPraos, ) : Block diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/BytesSize.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/BytesSize.kt index 01a9e91..aa328d3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/BytesSize.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/BytesSize.kt @@ -1,11 +1,11 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class BytesSize( - @Contextual + @param:JsonProperty(value = "bytes", required = true) + @get:JsonProperty("bytes") val bytes: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/CardanoEra.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/CardanoEra.kt index a0f1d86..f02f652 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/CardanoEra.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/CardanoEra.kt @@ -1,28 +1,26 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonNames +import com.fasterxml.jackson.annotation.JsonAlias -@Serializable enum class CardanoEra { - @JsonNames("byron") + @JsonAlias("byron") BYRON, - @JsonNames("shelley") + @JsonAlias("shelley") SHELLEY, - @JsonNames("allegra") + @JsonAlias("allegra") ALLEGRA, - @JsonNames("mary") + @JsonAlias("mary") MARY, - @JsonNames("alonzo") + @JsonAlias("alonzo") ALONZO, - @JsonNames("babbage") + @JsonAlias("babbage") BABBAGE, - @JsonNames("conway") + @JsonAlias("conway") CONWAY, } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Certificate.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Certificate.kt index 1acfbaa..9437318 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Certificate.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Certificate.kt @@ -1,191 +1,196 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + import org.apache.commons.numbers.fraction.BigFraction -@Serializable -@JsonClassDiscriminator("type") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") sealed interface Certificate -@Serializable -@SerialName("stakeDelegation") +@JsonTypeName("stakeDelegation") data class StakeDelegationCertificate( - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, - @SerialName("credential") + @param:JsonProperty(value = "credential", required = true) + @get:JsonProperty("credential") val credential: String, - @SerialName("stakePool") val stakePool: StakePool? = null, - @SerialName("delegateRepresentative") val delegateRepresentative: DelegateRepresentative? = null, ) : Certificate -@Serializable -@SerialName("stakeCredentialRegistration") +@JsonTypeName("stakeCredentialRegistration") data class StakeCredentialRegistrationCertificate( - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, - @SerialName("credential") + @param:JsonProperty(value = "credential", required = true) + @get:JsonProperty("credential") val credential: String, - @SerialName("deposit") val deposit: Ada? = null, ) : Certificate -@Serializable -@SerialName("stakeCredentialDeregistration") +@JsonTypeName("stakeCredentialDeregistration") data class StakeCredentialDeregistrationCertificate( - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, - @SerialName("credential") + @param:JsonProperty(value = "credential", required = true) + @get:JsonProperty("credential") val credential: String, - @SerialName("deposit") val deposit: Ada? = null, ) : Certificate -@Serializable -@SerialName("stakePoolRegistration") +@JsonTypeName("stakePoolRegistration") data class StakePoolRegistrationCertificate( - @SerialName("stakePool") + @param:JsonProperty(value = "stakePool", required = true) + @get:JsonProperty("stakePool") val stakePool: StakePoolRegistration, ) : Certificate -@Serializable data class StakePoolRegistration( - // bech32 encoding of a pool's verification key - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - // base16 encoding of a pool's verification key - @SerialName("vrfVerificationKeyHash") + @param:JsonProperty(value = "vrfVerificationKeyHash", required = true) + @get:JsonProperty("vrfVerificationKeyHash") val vrfVerificationKeyHash: String, - @SerialName("owners") + @param:JsonProperty(value = "owners", required = true) + @get:JsonProperty("owners") val owners: List, - @SerialName("cost") + @param:JsonProperty(value = "cost", required = true) + @get:JsonProperty("cost") val cost: Ada, - @SerialName("margin") - @Contextual + @param:JsonProperty(value = "margin", required = true) + @get:JsonProperty("margin") val margin: BigFraction, - @SerialName("pledge") + @param:JsonProperty(value = "pledge", required = true) + @get:JsonProperty("pledge") val pledge: Ada, - @SerialName("rewardAccount") + @param:JsonProperty(value = "rewardAccount", required = true) + @get:JsonProperty("rewardAccount") val rewardAccount: String, - @SerialName("metadata") val metadata: AnchorMetadata? = null, - @SerialName("relays") + @param:JsonProperty(value = "relays", required = true) + @get:JsonProperty("relays") val relays: List, ) -@Serializable data class AnchorMetadata( - @SerialName("hash") + @param:JsonProperty(value = "hash", required = true) + @get:JsonProperty("hash") val hash: String, - @SerialName("url") + @param:JsonProperty(value = "url", required = true) + @get:JsonProperty("url") val url: String, ) -@Serializable -@SerialName("stakePoolRetirement") +@JsonTypeName("stakePoolRetirement") data class StakePoolRetirementCertificate( - @SerialName("stakePool") + @param:JsonProperty(value = "stakePool", required = true) + @get:JsonProperty("stakePool") val stakePool: PoolRetirement, ) : Certificate -@Serializable data class PoolRetirement( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("retirementEpoch") + @param:JsonProperty(value = "retirementEpoch", required = true) + @get:JsonProperty("retirementEpoch") val retirementEpoch: Long, ) -@Serializable -@SerialName("genesisDelegation") +@JsonTypeName("genesisDelegation") data class GenesisDelegationCertificate( - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: IdHashWithVrf, - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: IdHash, ) : Certificate -@Serializable data class GenesisDelegation( - @SerialName("delegateKeyHash") + @param:JsonProperty(value = "delegateKeyHash", required = true) + @get:JsonProperty("delegateKeyHash") val delegateKeyHash: String, - @SerialName("verificationKeyHash") + @param:JsonProperty(value = "verificationKeyHash", required = true) + @get:JsonProperty("verificationKeyHash") val verificationKeyHash: String, - @SerialName("vrfVerificationKeyHash") + @param:JsonProperty(value = "vrfVerificationKeyHash", required = true) + @get:JsonProperty("vrfVerificationKeyHash") val vrfVerificationKeyHash: String, ) -@Serializable -@SerialName("constitutionalCommitteeDelegation") +@JsonTypeName("constitutionalCommitteeDelegation") data class ConstitutionalCommitteeDelegationCertificate( - @SerialName("member") + @param:JsonProperty(value = "member", required = true) + @get:JsonProperty("member") val member: IdHash, - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: ConstitutionalCommitteeDelegate, ) : Certificate -@Serializable -@JsonClassDiscriminator("status") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "status") sealed interface ConstitutionalCommitteeDelegate -@Serializable -@SerialName("authorized") +@JsonTypeName("authorized") data class AuthorizedConstitutionalCommitteeDelegate( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, ) : ConstitutionalCommitteeDelegate -@Serializable -@SerialName("resigned") +@JsonTypeName("resigned") data class ResignedConstitutionalCommitteeDelegate( - @SerialName("metadata") val metadata: AnchorMetadata? = null, ) : ConstitutionalCommitteeDelegate -@Serializable -@SerialName("none") +@JsonTypeName("none") data object NoneConstitutionalCommitteeDelegate : ConstitutionalCommitteeDelegate -@Serializable -@SerialName("constitutionalCommitteeRetirement") +@JsonTypeName("constitutionalCommitteeRetirement") data class ConstitutionalCommitteeRetirementCertificate( - @SerialName("member") + @param:JsonProperty(value = "member", required = true) + @get:JsonProperty("member") val member: IdHash, - @SerialName("metadata") val metadata: AnchorMetadata? = null, ) : Certificate -@Serializable -@SerialName("delegateRepresentativeRegistration") +@JsonTypeName("delegateRepresentativeRegistration") data class DelegateRepresentativeRegistrationCertificate( - @SerialName("delegateRepresentative") + @param:JsonProperty(value = "delegateRepresentative", required = true) + @get:JsonProperty("delegateRepresentative") val delegateRepresentative: DelegateRepresentative, - @SerialName("deposit") + @param:JsonProperty(value = "deposit", required = true) + @get:JsonProperty("deposit") val deposit: Ada, - @SerialName("metadata") val metadata: AnchorMetadata? = null, ) : Certificate -@Serializable -@SerialName("delegateRepresentativeUpdate") +@JsonTypeName("delegateRepresentativeUpdate") data class DelegateRepresentativeUpdateCertificate( - @SerialName("delegateRepresentative") + @param:JsonProperty(value = "delegateRepresentative", required = true) + @get:JsonProperty("delegateRepresentative") val delegateRepresentative: DelegateRepresentative, - @SerialName("metadata") val metadata: AnchorMetadata? = null, ) : Certificate -@Serializable -@SerialName("delegateRepresentativeRetirement") +@JsonTypeName("delegateRepresentativeRetirement") data class DelegateRepresentativeRetirementCertificate( - @SerialName("delegateRepresentative") + @param:JsonProperty(value = "delegateRepresentative", required = true) + @get:JsonProperty("delegateRepresentative") val delegateRepresentative: DelegateRepresentative, - @SerialName("deposit") + @param:JsonProperty(value = "deposit", required = true) + @get:JsonProperty("deposit") val deposit: Ada, ) : Certificate diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/CertifiedVrf.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/CertifiedVrf.kt index 38e20a6..e5cbd75 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/CertifiedVrf.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/CertifiedVrf.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class CertifiedVrf( - @SerialName("output") + @param:JsonProperty(value = "output", required = true) + @get:JsonProperty("output") val output: String, - @SerialName("proof") + @param:JsonProperty(value = "proof", required = true) + @get:JsonProperty("proof") val proof: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ConstitutionalCommitteeVotingThresholds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ConstitutionalCommitteeVotingThresholds.kt index f501d31..f4214ae 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ConstitutionalCommitteeVotingThresholds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ConstitutionalCommitteeVotingThresholds.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ConstitutionalCommitteeVotingThresholds( - @SerialName("default") - @Contextual + @param:JsonProperty(value = "default", required = true) + @get:JsonProperty("default") val default: BigFraction, - @SerialName("stateOfNoConfidence") - @Contextual + @param:JsonProperty(value = "stateOfNoConfidence", required = true) + @get:JsonProperty("stateOfNoConfidence") val stateOfNoConfidence: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitution.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitution.kt index f5d5a3f..03d6b95 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitution.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitution.kt @@ -1,13 +1,12 @@ package io.newm.kogmios.protocols.model +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.fault.MetadataHash -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class ConwayConstitution( - @SerialName("guardrails") val guardrails: MetadataHash? = null, - @SerialName("metadata") + @param:JsonProperty(value = "metadata", required = true) + @get:JsonProperty("metadata") val metadata: AnchorMetadata, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommittee.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommittee.kt index dcf3812..eabbd88 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommittee.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommittee.kt @@ -1,15 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ConwayConstitutionalCommittee( - @SerialName("members") + @param:JsonProperty(value = "members", required = true) + @get:JsonProperty("members") val members: List, - @Contextual - @SerialName("quorum") + @param:JsonProperty(value = "quorum", required = true) + @get:JsonProperty("quorum") val quorum: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommitteeMember.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommitteeMember.kt index 1afe80b..5a9f210 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommitteeMember.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayConstitutionalCommitteeMember.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ConwayConstitutionalCommitteeMember( - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("mandate") + @param:JsonProperty(value = "mandate", required = true) + @get:JsonProperty("mandate") val mandate: Mandate, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayGenesisProtocolParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayGenesisProtocolParameters.kt index d04e869..6ef8d39 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayGenesisProtocolParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ConwayGenesisProtocolParameters.kt @@ -1,24 +1,30 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ConwayGenesisProtocolParameters( - @SerialName("stakePoolVotingThresholds") + @param:JsonProperty(value = "stakePoolVotingThresholds", required = true) + @get:JsonProperty("stakePoolVotingThresholds") val stakePoolVotingThresholds: StakePoolVotingThresholds, - @SerialName("constitutionalCommitteeMinSize") + @param:JsonProperty(value = "constitutionalCommitteeMinSize", required = true) + @get:JsonProperty("constitutionalCommitteeMinSize") val constitutionalCommitteeMinSize: Long, - @SerialName("constitutionalCommitteeMaxTermLength") + @param:JsonProperty(value = "constitutionalCommitteeMaxTermLength", required = true) + @get:JsonProperty("constitutionalCommitteeMaxTermLength") val constitutionalCommitteeMaxTermLength: Long, - @SerialName("governanceActionLifetime") + @param:JsonProperty(value = "governanceActionLifetime", required = true) + @get:JsonProperty("governanceActionLifetime") val governanceActionLifetime: Long, - @SerialName("governanceActionDeposit") + @param:JsonProperty(value = "governanceActionDeposit", required = true) + @get:JsonProperty("governanceActionDeposit") val governanceActionDeposit: Ada, - @SerialName("delegateRepresentativeVotingThresholds") + @param:JsonProperty(value = "delegateRepresentativeVotingThresholds", required = true) + @get:JsonProperty("delegateRepresentativeVotingThresholds") val delegateRepresentativeVotingThresholds: DelegateRepresentativeVotingThresholds, - @SerialName("delegateRepresentativeDeposit") + @param:JsonProperty(value = "delegateRepresentativeDeposit", required = true) + @get:JsonProperty("delegateRepresentativeDeposit") val delegateRepresentativeDeposit: Ada, - @SerialName("delegateRepresentativeMaxIdleTime") + @param:JsonProperty(value = "delegateRepresentativeMaxIdleTime", required = true) + @get:JsonProperty("delegateRepresentativeMaxIdleTime") val delegateRepresentativeMaxIdleTime: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentative.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentative.kt index 0d94322..743ddbe 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentative.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentative.kt @@ -1,24 +1,26 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("type") +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") sealed interface DelegateRepresentative -@Serializable -@SerialName("registered") +@JsonTypeName("registered") data class DelegateRepresentativeRegistered( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") + val from: String, ) : DelegateRepresentative -@Serializable -@SerialName("noConfidence") +@JsonTypeName("noConfidence") data object DelegateRepresentativeNoConfidence : DelegateRepresentative -@Serializable -@SerialName("abstain") +@JsonTypeName("abstain") data object DelegateRepresentativeAbstain : DelegateRepresentative diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentativeVotingThresholds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentativeVotingThresholds.kt index d3f53a9..73236e2 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentativeVotingThresholds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/DelegateRepresentativeVotingThresholds.kt @@ -1,26 +1,26 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class DelegateRepresentativeVotingThresholds( - @SerialName("noConfidence") - @Contextual + @param:JsonProperty(value = "noConfidence", required = true) + @get:JsonProperty("noConfidence") val noConfidence: BigFraction, - @SerialName("constitution") - @Contextual + @param:JsonProperty(value = "constitution", required = true) + @get:JsonProperty("constitution") val constitution: BigFraction, - @SerialName("constitutionalCommittee") + @param:JsonProperty(value = "constitutionalCommittee", required = true) + @get:JsonProperty("constitutionalCommittee") val constitutionalCommittee: ConstitutionalCommitteeVotingThresholds, - @SerialName("hardForkInitiation") - @Contextual + @param:JsonProperty(value = "hardForkInitiation", required = true) + @get:JsonProperty("hardForkInitiation") val hardForkInitiation: BigFraction, - @SerialName("protocolParametersUpdate") + @param:JsonProperty(value = "protocolParametersUpdate", required = true) + @get:JsonProperty("protocolParametersUpdate") val protocolParametersUpdate: ProtocolParametersUpdateThresholds, - @SerialName("treasuryWithdrawals") - @Contextual + @param:JsonProperty(value = "treasuryWithdrawals", required = true) + @get:JsonProperty("treasuryWithdrawals") val treasuryWithdrawals: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/EraParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/EraParameters.kt index 41e8602..4166805 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/EraParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/EraParameters.kt @@ -1,14 +1,13 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class EraParameters( - @SerialName("epochLength") + @param:JsonProperty(value = "epochLength", required = true) + @get:JsonProperty("epochLength") val epochLength: Long, - @SerialName("slotLength") + @param:JsonProperty(value = "slotLength", required = true) + @get:JsonProperty("slotLength") val slotLength: Milliseconds, - @SerialName("safeZone") val safeZone: Long? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/EraSummary.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/EraSummary.kt index f0caadd..91821d8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/EraSummary.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/EraSummary.kt @@ -1,11 +1,17 @@ package io.newm.kogmios.protocols.model +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.result.Bound -import kotlinx.serialization.Serializable -@Serializable data class EraSummary( + @param:JsonProperty(value = "start", required = true) + @get:JsonProperty("start") val start: Bound, + @param:JsonProperty(value = "end", required = true) + @get:JsonProperty("end") val end: Bound?, + @param:JsonProperty(value = "parameters", required = true) + @get:JsonProperty("parameters") val parameters: EraParameters, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionPrices.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionPrices.kt index e2060bd..7898a5f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionPrices.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionPrices.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ExecutionPrices( - @Contextual - @SerialName("memory") + @param:JsonProperty(value = "memory", required = true) + @get:JsonProperty("memory") val memory: BigFraction, - @Contextual - @SerialName("cpu") + @param:JsonProperty(value = "cpu", required = true) + @get:JsonProperty("cpu") val cpu: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionUnits.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionUnits.kt index 6b094b4..74a0f2d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionUnits.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ExecutionUnits.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class ExecutionUnits( - @Contextual - @SerialName("memory") + @param:JsonProperty(value = "memory", required = true) + @get:JsonProperty("memory") val memory: BigInteger, - @Contextual - @SerialName("cpu") + @param:JsonProperty(value = "cpu", required = true) + @get:JsonProperty("cpu") val cpu: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/FindIntersect.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/FindIntersect.kt index a49df39..ebc90bb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/FindIntersect.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/FindIntersect.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class FindIntersect( - @SerialName("points") + @param:JsonProperty(value = "points", required = true) + @get:JsonProperty("points") val points: List, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegate.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegate.kt index da0e9cf..58bfeac 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegate.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegate.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GenesisDelegate( - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: IdHash, - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: IdHashWithVrf ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegationConfig.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegationConfig.kt index 4228d26..ac51b41 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegationConfig.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GenesisDelegationConfig.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GenesisDelegationConfig( - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: VerificationKey, - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: VerificationKey, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceAction.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceAction.kt index 119c680..f93cee9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceAction.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceAction.kt @@ -1,109 +1,107 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + import org.apache.commons.numbers.fraction.BigFraction -@Serializable -@JsonClassDiscriminator("type") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") sealed interface GovernanceAction -@Serializable -@SerialName("protocolParametersUpdate") +@JsonTypeName("protocolParametersUpdate") data class ProtocolParametersUpdateGovernanceAction( - @SerialName("ancestor") val ancestor: UtxoInput? = null, - @SerialName("parameters") + @param:JsonProperty(value = "parameters", required = true) + @get:JsonProperty("parameters") val parameters: ProposedProtocolParameters, - @SerialName("guardrails") val guardrails: GuardrailsHash? = null, ) : GovernanceAction -@Serializable -@SerialName("hardForkInitiation") +@JsonTypeName("hardForkInitiation") data class HardForkInitiationGovernanceAction( - @SerialName("ancestor") val ancestor: UtxoInput? = null, - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: Version, ) : GovernanceAction -@Serializable -@SerialName("treasuryTransfer") +@JsonTypeName("treasuryTransfer") data class TreasuryTransferGovernanceAction( - @SerialName("source") + @param:JsonProperty(value = "source", required = true) + @get:JsonProperty("source") val source: String, - @SerialName("target") + @param:JsonProperty(value = "target", required = true) + @get:JsonProperty("target") val target: String, - @SerialName("value") + @param:JsonProperty(value = "value", required = true) + @get:JsonProperty("value") val value: Ada, ) : GovernanceAction -@Serializable -@SerialName("treasuryWithdrawals") +@JsonTypeName("treasuryWithdrawals") data class TreasuryWithdrawalsGovernanceAction( - @SerialName("withdrawals") + @param:JsonProperty(value = "withdrawals", required = true) + @get:JsonProperty("withdrawals") val withdrawals: Map, - @SerialName("guardrails") val guardrails: GuardrailsHash? = null, ) : GovernanceAction -@Serializable -@SerialName("constitutionalCommittee") +@JsonTypeName("constitutionalCommittee") data class ConstitutionalCommitteeGovernanceAction( - @SerialName("ancestor") val ancestor: UtxoInput? = null, - @SerialName("members") + @param:JsonProperty(value = "members", required = true) + @get:JsonProperty("members") val members: ConstitutionalCommitteeMembers, - @SerialName("quorum") - @Contextual + @param:JsonProperty(value = "quorum", required = true) + @get:JsonProperty("quorum") val quorum: BigFraction, ) : GovernanceAction -@Serializable data class ConstitutionalCommitteeMembers( - @SerialName("added") + @param:JsonProperty(value = "added", required = true) + @get:JsonProperty("added") val added: List, - @SerialName("removed") + @param:JsonProperty(value = "removed", required = true) + @get:JsonProperty("removed") val removed: List, ) -@Serializable data class AddedConstitutionalCommitteeMember( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("from") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") val from: String, - @SerialName("mandate") + @param:JsonProperty(value = "mandate", required = true) + @get:JsonProperty("mandate") val mandate: Mandate, ) -@Serializable data class Mandate( - @SerialName("epoch") + @param:JsonProperty(value = "epoch", required = true) + @get:JsonProperty("epoch") val epoch: Long, ) -@Serializable -@SerialName("constitution") +@JsonTypeName("constitution") data class ConstitutionGovernanceAction( - @SerialName("ancestor") val ancestor: UtxoInput? = null, - @SerialName("guardrails") + @param:JsonProperty(value = "guardrails", required = true) + @get:JsonProperty("guardrails") val guardrails: GuardrailsHash?, - @SerialName("metadata") + @param:JsonProperty(value = "metadata", required = true) + @get:JsonProperty("metadata") val metadata: AnchorMetadata, ) : GovernanceAction -@Serializable -@SerialName("noConfidence") +@JsonTypeName("noConfidence") data class NoConfidenceGovernanceAction( - @SerialName("ancestor") val ancestor: UtxoInput? = null, ) : GovernanceAction -@Serializable -@SerialName("information") +@JsonTypeName("information") data object InformationGovernanceAction : GovernanceAction diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposal.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposal.kt index 877ef70..070fcd3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposal.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposal.kt @@ -1,16 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GovernanceProposal( - @SerialName("deposit") val deposit: Ada? = null, - @SerialName("returnAccount") val returnAccount: String? = null, - @SerialName("anchor") val anchor: AnchorMetadata? = null, - @SerialName("action") + @param:JsonProperty(value = "action", required = true) + @get:JsonProperty("action") val action: GovernanceAction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposalReference.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposalReference.kt index da4a843..7376c79 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposalReference.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceProposalReference.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GovernanceProposalReference( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Transaction, - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Int, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVote.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVote.kt index f08790a..81eeb08 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVote.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVote.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GovernanceVote( - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: Voter, - @SerialName("anchor") val anchor: AnchorMetadata? = null, - @SerialName("vote") + @param:JsonProperty(value = "vote", required = true) + @get:JsonProperty("vote") val vote: Vote, - @SerialName("proposal") val proposal: UtxoOutputReference? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVoter.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVoter.kt index 4f48170..cb2350a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVoter.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceVoter.kt @@ -1,45 +1,55 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("role") +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "role", + visible = true, +) sealed interface GovernanceVoter -@Serializable -@SerialName("genesisDelegate") +@JsonTypeName("genesisDelegate") data class GovernanceVoterGenesisDelegate( - @SerialName("role") + @param:JsonProperty(value = "role", required = true) + @get:JsonProperty("role") val role: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : GovernanceVoter -@Serializable -@SerialName("constitutionalCommittee") +@JsonTypeName("constitutionalCommittee") data class GovernanceVoterConstitutionalCommittee( - @SerialName("role") + @param:JsonProperty(value = "role", required = true) + @get:JsonProperty("role") val role: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : GovernanceVoter -@Serializable -@SerialName("delegateRepresentative") +@JsonTypeName("delegateRepresentative") data class GovernanceVoterDelegateRepresentative( - @SerialName("role") + @param:JsonProperty(value = "role", required = true) + @get:JsonProperty("role") val role: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : GovernanceVoter -@Serializable -@SerialName("stakePoolOperator") +@JsonTypeName("stakePoolOperator") data class GovernanceVoterStakePoolOperator( - @SerialName("role") + @param:JsonProperty(value = "role", required = true) + @get:JsonProperty("role") val role: String, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : GovernanceVoter diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/GuardrailsHash.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/GuardrailsHash.kt index 34a18e8..9b80add 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/GuardrailsHash.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/GuardrailsHash.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class GuardrailsHash( - @SerialName("hash") + @param:JsonProperty(value = "hash", required = true) + @get:JsonProperty("hash") val hash: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/IdHash.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/IdHash.kt index 89b9cb7..cae0fb8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/IdHash.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/IdHash.kt @@ -1,12 +1,10 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class IdHash( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("from") val from: String? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/IdHashWithVrf.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/IdHashWithVrf.kt index 2a25cba..130d720 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/IdHashWithVrf.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/IdHashWithVrf.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class IdHashWithVrf( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("vrfVerificationKeyHash") + @param:JsonProperty(value = "vrfVerificationKeyHash", required = true) + @get:JsonProperty("vrfVerificationKeyHash") val vrfVerificationKeyHash: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/IssuerPraos.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/IssuerPraos.kt index 1e2af5e..c0589a7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/IssuerPraos.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/IssuerPraos.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class IssuerPraos( - @SerialName("verificationKey") + @param:JsonProperty(value = "verificationKey", required = true) + @get:JsonProperty("verificationKey") val verificationKey: String, - @SerialName("vrfVerificationKey") + @param:JsonProperty(value = "vrfVerificationKey", required = true) + @get:JsonProperty("vrfVerificationKey") val vrfVerificationKey: String, - @SerialName("operationalCertificate") + @param:JsonProperty(value = "operationalCertificate", required = true) + @get:JsonProperty("operationalCertificate") val operationalCertificate: OperationalCertificatePraos, - @SerialName("leaderValue") + @param:JsonProperty(value = "leaderValue", required = true) + @get:JsonProperty("leaderValue") val leaderValue: CertifiedVrf, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Kes.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Kes.kt index b2a392a..1ef290e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Kes.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Kes.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Kes( - @SerialName("period") + @param:JsonProperty(value = "period", required = true) + @get:JsonProperty("period") val period: Long, - @SerialName("verificationKey") + @param:JsonProperty(value = "verificationKey", required = true) + @get:JsonProperty("verificationKey") val verificationKey: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Label.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Label.kt index 47757e1..7850c12 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Label.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Label.kt @@ -1,12 +1,6 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable data class Label( - @SerialName("cbor") val cbor: String? = null, - @SerialName("json") val json: MetadataValue? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Lovelace.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Lovelace.kt index 398f107..baf7221 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Lovelace.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Lovelace.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class Lovelace( - @Contextual - @SerialName("lovelace") + @param:JsonProperty(value = "lovelace", required = true) + @get:JsonProperty("lovelace") val lovelace: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataResult.kt index 256bc28..8794f6c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataResult.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class MetadataResult( - @SerialName("url") + @param:JsonProperty(value = "url", required = true) + @get:JsonProperty("url") val url: String, - @SerialName("hash") + @param:JsonProperty(value = "hash", required = true) + @get:JsonProperty("hash") val hash: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataValue.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataValue.kt index 5eac653..ddf493b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataValue.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/MetadataValue.kt @@ -1,126 +1,45 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.ClientImpl -import kotlinx.serialization.Contextual -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonContentPolymorphicSerializer -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.decodeFromJsonElement -import kotlinx.serialization.json.jsonArray -import kotlinx.serialization.json.jsonObject +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable(with = MetadataValueSerializer::class) sealed interface MetadataValue -@Serializable(with = MetadataMapSerializer::class) class MetadataMap : MetadataValue, MutableMap by mutableMapOf() { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is MetadataMap) return false - return true - } + override fun equals(other: Any?): Boolean = this === other || other is MetadataMap override fun hashCode(): Int = javaClass.hashCode() - override fun toString(): String = "MetadataMap(${this.entries.joinToString { entry -> "{${entry.key}:${entry.value}}" }})" + override fun toString(): String = "MetadataMap(${entries.joinToString { "{${it.key}:${it.value}}" }})" } -@Serializable(with = MetadataListSerializer::class) class MetadataList : MetadataValue, MutableList by mutableListOf() { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is MetadataList) return false - return true - } + override fun equals(other: Any?): Boolean = this === other || other is MetadataList override fun hashCode(): Int = javaClass.hashCode() - override fun toString(): String = "MetadataList([${this.joinToString { metadataValue -> metadataValue.toString() }}])" + override fun toString(): String = "MetadataList([${joinToString()}])" } -@Serializable data class MetadataString( - val string: String + @param:JsonProperty(value = "string", required = true) + @get:JsonProperty("string") + val string: String, ) : MetadataValue -@Serializable data class MetadataInteger( - @Contextual val int: BigInteger + @param:JsonProperty(value = "int", required = true) + @get:JsonProperty("int") + val int: BigInteger, ) : MetadataValue -@Serializable data class MetadataBytes( - val bytes: String + @param:JsonProperty(value = "bytes", required = true) + @get:JsonProperty("bytes") + val bytes: String, ) : MetadataValue - -object MetadataMapSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("MetadataMap") - - override fun deserialize(decoder: Decoder): MetadataMap { - require(decoder is JsonDecoder) - val metadataMap = MetadataMap() - val mapJsonElement = decoder.decodeJsonElement() - mapJsonElement.jsonObject["map"]?.jsonArray?.forEach { mapItemJsonElement -> - val key: MetadataValue = ClientImpl.json.decodeFromJsonElement(mapItemJsonElement.jsonObject["k"]!!) - val value: MetadataValue = ClientImpl.json.decodeFromJsonElement(mapItemJsonElement.jsonObject["v"]!!) - metadataMap[key] = value - } - return metadataMap - } - - override fun serialize( - encoder: Encoder, - value: MetadataMap - ) { - } -} - -object MetadataListSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("MetadataList") - - override fun deserialize(decoder: Decoder): MetadataList { - require(decoder is JsonDecoder) - val metadataList = MetadataList() - val listJsonElement = decoder.decodeJsonElement() - listJsonElement.jsonObject["list"]?.jsonArray?.forEach { listItemJsonElement -> - val item: MetadataValue = ClientImpl.json.decodeFromJsonElement(listItemJsonElement) - metadataList.add(item) - } - return metadataList - } - - override fun serialize( - encoder: Encoder, - value: MetadataList - ) { - } -} - -object MetadataValueSerializer : JsonContentPolymorphicSerializer(MetadataValue::class) { - override fun selectDeserializer(element: JsonElement): DeserializationStrategy = - if ("map" in element.jsonObject) { - MetadataMap.serializer() - } else if ("list" in element.jsonObject) { - MetadataList.serializer() - } else if ("string" in element.jsonObject) { - MetadataString.serializer() - } else if ("int" in element.jsonObject) { - MetadataInteger.serializer() - } else if ("bytes" in element.jsonObject) { - MetadataBytes.serializer() - } else { - throw IllegalStateException("No serializer found!: $element") - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Milliseconds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Milliseconds.kt index 6ad82ec..21adda9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Milliseconds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Milliseconds.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class Milliseconds( - @SerialName("milliseconds") - @Contextual + @param:JsonProperty(value = "milliseconds", required = true) + @get:JsonProperty("milliseconds") val milliseconds: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/MinFeeReferenceScripts.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/MinFeeReferenceScripts.kt index 94f3bae..a4e8904 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/MinFeeReferenceScripts.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/MinFeeReferenceScripts.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class MinFeeReferenceScripts( - @SerialName("range") + @param:JsonProperty(value = "range", required = true) + @get:JsonProperty("range") val range: Int, - @SerialName("base") + @param:JsonProperty(value = "base", required = true) + @get:JsonProperty("base") val base: Double, - @SerialName("multiplier") + @param:JsonProperty(value = "multiplier", required = true) + @get:JsonProperty("multiplier") val multiplier: Double, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/NonMyopicMemberRewardsResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/NonMyopicMemberRewardsResult.kt index 702b734..17531a3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/NonMyopicMemberRewardsResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/NonMyopicMemberRewardsResult.kt @@ -1,7 +1,3 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.NonMyopicMemberRewardsResultSerializer -import kotlinx.serialization.Serializable - -@Serializable(with = NonMyopicMemberRewardsResultSerializer::class) class NonMyopicMemberRewardsResult : LinkedHashMap() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Nonce.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Nonce.kt index 8af8c4c..8fc1720 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Nonce.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Nonce.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Nonce( - @SerialName("proof") + @param:JsonProperty(value = "proof", required = true) + @get:JsonProperty("proof") val proof: String, - @SerialName("output") + @param:JsonProperty(value = "output", required = true) + @get:JsonProperty("output") val output: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/OpCert.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/OpCert.kt index e504b49..277a246 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/OpCert.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/OpCert.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class OpCert( - @SerialName("hotVk") + @param:JsonProperty(value = "hotVk", required = true) + @get:JsonProperty("hotVk") val hotVk: String, - @SerialName("count") + @param:JsonProperty(value = "count", required = true) + @get:JsonProperty("count") val count: Int, - @SerialName("kesPeriod") + @param:JsonProperty(value = "kesPeriod", required = true) + @get:JsonProperty("kesPeriod") val kesPeriod: Int, - @SerialName("sigma") + @param:JsonProperty(value = "sigma", required = true) + @get:JsonProperty("sigma") val sigma: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificate.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificate.kt index facf9af..c256973 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificate.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificate.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class OperationalCertificate( - @SerialName("issuer") + @param:JsonProperty(value = "issuer", required = true) + @get:JsonProperty("issuer") val issuer: VerificationKey, - @SerialName("delegate") + @param:JsonProperty(value = "delegate", required = true) + @get:JsonProperty("delegate") val delegate: VerificationKey, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificatePraos.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificatePraos.kt index c84ccd4..07c01d0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificatePraos.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/OperationalCertificatePraos.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class OperationalCertificatePraos( - @SerialName("count") + @param:JsonProperty(value = "count", required = true) + @get:JsonProperty("count") val count: Long, - @SerialName("kes") + @param:JsonProperty(value = "kes", required = true) + @get:JsonProperty("kes") val kes: Kes, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Origin.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Origin.kt index a4cd614..691df9d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Origin.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Origin.kt @@ -1,11 +1,7 @@ package io.newm.kogmios.protocols.model import io.newm.kogmios.protocols.Const.ORIGIN -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class Origin( - @SerialName("point") val point: String = ORIGIN, ) : PointOrOrigin() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/OriginString.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/OriginString.kt index c6d17ec..52c96dc 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/OriginString.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/OriginString.kt @@ -1,10 +1,11 @@ package io.newm.kogmios.protocols.model +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue import io.newm.kogmios.protocols.Const -import io.newm.kogmios.protocols.model.serializers.OriginStringSerializer -import kotlinx.serialization.Serializable -@Serializable(with = OriginStringSerializer::class) -data class OriginString( - val origin: String = Const.ORIGIN, -) : PointDetailOrOrigin() +data class OriginString + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val origin: String = Const.ORIGIN, + ) : PointDetailOrOrigin() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Params.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Params.kt index b29b0e7..85a12cf 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Params.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Params.kt @@ -1,7 +1,3 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.QuerySerializer -import kotlinx.serialization.Serializable - -@Serializable(with = QuerySerializer::class) abstract class Params diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsChainTip.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsChainTip.kt index e981a66..acd2c87 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsChainTip.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsChainTip.kt @@ -1,10 +1,5 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable data class ParamsChainTip( - @SerialName("query") val query: String = "chainTip", ) : Params() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsGenesisConfig.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsGenesisConfig.kt index 45e6016..781f074 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsGenesisConfig.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsGenesisConfig.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ParamsGenesisConfig( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") val era: String, ) : Params() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsPoolParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsPoolParameters.kt index 310618d..c5930e1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsPoolParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsPoolParameters.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ParamsPoolParameters( - @SerialName("stakePools") + @param:JsonProperty(value = "stakePools", required = true) + @get:JsonProperty("stakePools") val stakePools: List, ) : Params() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsProjectedRewards.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsProjectedRewards.kt index 2cd1596..3ed7548 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsProjectedRewards.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsProjectedRewards.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ParamsProjectedRewards( - @SerialName("stake") + @param:JsonProperty(value = "stake", required = true) + @get:JsonProperty("stake") val stake: List, - @SerialName("scripts") + @param:JsonProperty(value = "scripts", required = true) + @get:JsonProperty("scripts") val scripts: List, - @SerialName("keys") + @param:JsonProperty(value = "keys", required = true) + @get:JsonProperty("keys") val keys: List, ) : Params() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsRewardAccountSummaries.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsRewardAccountSummaries.kt index 946dd7b..25f4c6d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsRewardAccountSummaries.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsRewardAccountSummaries.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ParamsRewardAccountSummaries( - @SerialName("keys") + @param:JsonProperty(value = "keys", required = true) + @get:JsonProperty("keys") val keys: List, ) : Params() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsUtxo.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsUtxo.kt index e01f570..0a204cb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsUtxo.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ParamsUtxo.kt @@ -1,19 +1,17 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable sealed class ParamsUtxo : Params() -@Serializable data class ParamsUtxoByOutputReferences( - @SerialName("outputReferences") + @param:JsonProperty(value = "outputReferences", required = true) + @get:JsonProperty("outputReferences") val outputReferences: List, ) : ParamsUtxo() -@Serializable data class ParamsUtxoByAddresses( - @SerialName("addresses") + @param:JsonProperty(value = "addresses", required = true) + @get:JsonProperty("addresses") val addresses: List, ) : ParamsUtxo() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PlutusCostModels.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PlutusCostModels.kt index d0c5ded..f07ad15 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PlutusCostModels.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PlutusCostModels.kt @@ -1,16 +1,17 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class PlutusCostModels( - @SerialName("plutus:v1") - val plutusV1: List<@Contextual BigInteger>? = null, - @SerialName("plutus:v2") - val plutusV2: List<@Contextual BigInteger>? = null, - @SerialName("plutus:v3") - val plutusV3: List<@Contextual BigInteger>? = null, + @param:JsonProperty("plutus:v1") + @get:JsonProperty("plutus:v1") + val plutusV1: List? = null, + @param:JsonProperty("plutus:v2") + @get:JsonProperty("plutus:v2") + val plutusV2: List? = null, + @param:JsonProperty("plutus:v3") + @get:JsonProperty("plutus:v3") + val plutusV3: List? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Point.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Point.kt index 32dcfb7..e23126b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Point.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Point.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Point( - @SerialName("point") + @param:JsonProperty(value = "point", required = true) + @get:JsonProperty("point") val point: PointDetail, ) : PointOrOrigin() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetail.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetail.kt index 5d2e7af..2c1948d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetail.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetail.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class PointDetail( - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : PointDetailOrOrigin() diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetailOrOrigin.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetailOrOrigin.kt index a85b9a6..178b5fd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetailOrOrigin.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PointDetailOrOrigin.kt @@ -1,7 +1,3 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.PointDetailOrOriginSerializer -import kotlinx.serialization.Serializable - -@Serializable(with = PointDetailOrOriginSerializer::class) abstract class PointDetailOrOrigin diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PointOrOrigin.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PointOrOrigin.kt index 56cd29b..4489586 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PointOrOrigin.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PointOrOrigin.kt @@ -1,7 +1,3 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.PointOrOriginSerializer -import kotlinx.serialization.Serializable - -@Serializable(with = PointOrOriginSerializer::class) abstract class PointOrOrigin diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PoolDistribution.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PoolDistribution.kt index 07e5a43..0776acf 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PoolDistribution.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PoolDistribution.kt @@ -1,15 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class PoolDistribution( - @SerialName("stake") - @Contextual + @param:JsonProperty(value = "stake", required = true) + @get:JsonProperty("stake") val stake: BigFraction, - @SerialName("vrf") + @param:JsonProperty(value = "vrf", required = true) + @get:JsonProperty("vrf") val vrf: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/PoolResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/PoolResult.kt index db5708a..3ef3e31 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/PoolResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/PoolResult.kt @@ -1,29 +1,20 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class PoolResult( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("vrfVerificationKeyHash") - val vrfVerificationKeyHash: String, - @SerialName("pledge") - val pledge: Ada, - @SerialName("cost") - val cost: Ada, - @Contextual - @SerialName("margin") - val margin: BigFraction, - @SerialName("rewardAccount") - val rewardAccount: String, - @SerialName("owners") - val owners: List, - @SerialName("relays") - val relays: List?, - @SerialName("metadata") - val metadata: MetadataResult, + val vrfVerificationKeyHash: String? = null, + val pledge: Ada? = null, + val cost: Ada? = null, + val stake: Ada? = null, + val margin: BigFraction? = null, + val rewardAccount: String? = null, + val owners: List? = null, + val relays: List? = null, + val metadata: MetadataResult? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ProjectedRewardsInput.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ProjectedRewardsInput.kt index 3826b79..f3b8d47 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ProjectedRewardsInput.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ProjectedRewardsInput.kt @@ -1,6 +1,3 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Serializable - -@Serializable sealed interface ProjectedRewardsInput diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ProposedProtocolParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ProposedProtocolParameters.kt index 50cf50c..552f112 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ProposedProtocolParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ProposedProtocolParameters.kt @@ -1,95 +1,43 @@ package io.newm.kogmios.protocols.model import java.math.BigInteger -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ProposedProtocolParameters( - @Contextual - @SerialName("minFeeCoefficient") val minFeeCoefficient: BigInteger? = null, - @SerialName("minFeeConstant") val minFeeConstant: Ada? = null, - @SerialName("minFeeReferenceScripts") val minFeeReferenceScripts: MinFeeReferenceScripts? = null, - @Contextual - @SerialName("minUtxoDepositCoefficient") val minUtxoDepositCoefficient: BigInteger? = null, - @SerialName("minUtxoDepositConstant") val minUtxoDepositConstant: Ada? = null, - @SerialName("maxBlockBodySize") val maxBlockBodySize: BytesSize? = null, - @SerialName("maxBlockHeaderSize") val maxBlockHeaderSize: BytesSize? = null, - @SerialName("maxTransactionSize") val maxTransactionSize: BytesSize? = null, - @SerialName("maxReferenceScriptsSize") val maxReferenceScriptsSize: BytesSize? = null, - @SerialName("maxValueSize") val maxValueSize: BytesSize? = null, - @SerialName("extraEntropy") val extraEntropy: String? = null, - @SerialName("stakeCredentialDeposit") val stakeCredentialDeposit: Ada? = null, - @SerialName("stakePoolDeposit") val stakePoolDeposit: Ada? = null, - @Contextual - @SerialName("stakePoolRetirementEpochBound") val stakePoolRetirementEpochBound: BigInteger? = null, - @Contextual - @SerialName("stakePoolPledgeInfluence") val stakePoolPledgeInfluence: BigFraction? = null, - @SerialName("minStakePoolCost") val minStakePoolCost: Ada? = null, - @Contextual - @SerialName("desiredNumberOfStakePools") val desiredNumberOfStakePools: BigInteger? = null, - @Contextual - @SerialName("federatedBlockProductionRatio") val federatedBlockProductionRatio: BigFraction? = null, - @Contextual - @SerialName("monetaryExpansion") val monetaryExpansion: BigFraction? = null, - @Contextual - @SerialName("treasuryExpansion") val treasuryExpansion: BigFraction? = null, - @Contextual - @SerialName("collateralPercentage") val collateralPercentage: BigInteger? = null, - @Contextual - @SerialName("maxCollateralInputs") val maxCollateralInputs: BigInteger? = null, - @SerialName("plutusCostModels") val plutusCostModels: PlutusCostModels? = null, - @SerialName("scriptExecutionPrices") val scriptExecutionPrices: ExecutionPrices? = null, - @SerialName("maxExecutionUnitsPerTransaction") val maxExecutionUnitsPerTransaction: ExecutionUnits? = null, - @SerialName("maxExecutionUnitsPerBlock") val maxExecutionUnitsPerBlock: ExecutionUnits? = null, - @SerialName("stakePoolVotingThresholds") val stakePoolVotingThresholds: StakePoolVotingThresholds? = null, - @SerialName("constitutionalCommitteeMinSize") - @Contextual val constitutionalCommitteeMinSize: BigInteger? = null, - @SerialName("constitutionalCommitteeMaxTermLength") - @Contextual val constitutionalCommitteeMaxTermLength: BigInteger? = null, - @SerialName("governanceActionLifetime") - @Contextual val governanceActionLifetime: BigInteger? = null, - @SerialName("governanceActionDeposit") val governanceActionDeposit: Ada? = null, - @SerialName("delegateRepresentativeVotingThresholds") val delegateRepresentativeVotingThresholds: DelegateRepresentativeVotingThresholds? = null, - @SerialName("delegateRepresentativeDeposit") val delegateRepresentativeDeposit: Ada? = null, - @SerialName("delegateRepresentativeMaxIdleTime") - @Contextual val delegateRepresentativeMaxIdleTime: BigInteger? = null, - @SerialName("version") val version: Version? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Protocol.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Protocol.kt index e3785a9..0a16ee9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Protocol.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Protocol.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Protocol( - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: Version, - @SerialName("software") + @param:JsonProperty(value = "software", required = true) + @get:JsonProperty("software") val software: Software, - @SerialName("update") + @param:JsonProperty(value = "update", required = true) + @get:JsonProperty("update") val update: Update, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolParametersUpdateThresholds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolParametersUpdateThresholds.kt index 2b5c093..3169aec 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolParametersUpdateThresholds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolParametersUpdateThresholds.kt @@ -1,22 +1,20 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ProtocolParametersUpdateThresholds( - @SerialName("network") - @Contextual + @param:JsonProperty(value = "network", required = true) + @get:JsonProperty("network") val network: BigFraction, - @SerialName("economic") - @Contextual + @param:JsonProperty(value = "economic", required = true) + @get:JsonProperty("economic") val economic: BigFraction, - @SerialName("technical") - @Contextual + @param:JsonProperty(value = "technical", required = true) + @get:JsonProperty("technical") val technical: BigFraction, - @SerialName("governance") - @Contextual + @param:JsonProperty(value = "governance", required = true) + @get:JsonProperty("governance") val governance: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolUpdate.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolUpdate.kt index 8b4d327..78565bb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolUpdate.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolUpdate.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ProtocolUpdate( - @SerialName("epoch") + @param:JsonProperty(value = "epoch", required = true) + @get:JsonProperty("epoch") val epoch: Long, - @SerialName("proposal") + @param:JsonProperty(value = "proposal", required = true) + @get:JsonProperty("proposal") val proposal: Map, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolVersion.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolVersion.kt index 91918a5..076cc6a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolVersion.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ProtocolVersion.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ProtocolVersion( - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: Version, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/RedeemerPointer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/RedeemerPointer.kt index e81ee57..e9bafb3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/RedeemerPointer.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/RedeemerPointer.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class RedeemerPointer( - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Int, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/RelayResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/RelayResult.kt index 4cb6bde..1799609 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/RelayResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/RelayResult.kt @@ -1,29 +1,27 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("type") +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") sealed interface RelayResult -@Serializable -@SerialName("hostname") +@JsonTypeName("hostname") data class HostnameRelayResult( - @SerialName("hostname") + @param:JsonProperty(value = "hostname", required = true) + @get:JsonProperty("hostname") val hostname: String, - @SerialName("port") val port: Int? = null, ) : RelayResult -@Serializable -@SerialName("ipAddress") +@JsonTypeName("ipAddress") data class IpAddressRelayResult( - @SerialName("ipv4") val ipv4: String? = null, - @SerialName("ipv6") val ipv6: String? = null, - @SerialName("port") + @param:JsonProperty(value = "port", required = true) + @get:JsonProperty("port") val port: Int, ) : RelayResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/RewardAccountSummary.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/RewardAccountSummary.kt index baffe9b..9789b0a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/RewardAccountSummary.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/RewardAccountSummary.kt @@ -1,12 +1,20 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class RewardAccountSummary( - @SerialName("delegate") - val delegate: StakePool, - @SerialName("rewards") + @param:JsonProperty(value = "from", required = true) + @get:JsonProperty("from") + val from: String, + @param:JsonProperty(value = "credential", required = true) + @get:JsonProperty("credential") + val credential: String, + @param:JsonProperty(value = "rewards", required = true) + @get:JsonProperty("rewards") val rewards: Ada, + @param:JsonProperty(value = "deposit", required = true) + @get:JsonProperty("deposit") + val deposit: Ada, + val stakePool: StakePool? = null, + val delegateRepresentative: DelegateRepresentative? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Script.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Script.kt index ad1cafe..b284618 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Script.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Script.kt @@ -1,88 +1,42 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator -import java.math.BigInteger +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("language") +import com.fasterxml.jackson.annotation.JsonTypeInfo +import com.fasterxml.jackson.annotation.JsonTypeName +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import io.newm.kogmios.serializers.DeepJsonNodeSerializer + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "language") sealed interface Script -@Serializable -@SerialName("native") +@JsonTypeName("native") data class ScriptNative( - @SerialName("json") - val json: ScriptNativeDetail, - @SerialName("cbor") + @get:JsonSerialize(using = DeepJsonNodeSerializer::class) + val json: JsonNode, val cbor: String? = null, -) : Script +) : Script { + override fun toString(): String = "ScriptNative(json=, cbor=$cbor)" +} -@Serializable -@SerialName("plutus:v1") +@JsonTypeName("plutus:v1") data class ScriptPlutusV1( - @SerialName("cbor") val cbor: String + @param:JsonProperty(value = "cbor", required = true) + @get:JsonProperty("cbor") + val cbor: String, ) : Script -@Serializable -@SerialName("plutus:v2") +@JsonTypeName("plutus:v2") data class ScriptPlutusV2( - @SerialName("cbor") val cbor: String + @param:JsonProperty(value = "cbor", required = true) + @get:JsonProperty("cbor") + val cbor: String, ) : Script -@Serializable -@SerialName("plutus:v3") +@JsonTypeName("plutus:v3") data class ScriptPlutusV3( - @SerialName("cbor") val cbor: String + @param:JsonProperty(value = "cbor", required = true) + @get:JsonProperty("cbor") + val cbor: String, ) : Script - -@Serializable -@JsonClassDiscriminator("clause") -sealed interface ScriptNativeDetail - -@Serializable -@SerialName("signature") -data class ScriptNativeDetailSignature( - @SerialName("from") - val from: String -) : ScriptNativeDetail - -@Serializable -@SerialName("before") -data class ScriptNativeDetailBefore( - @Contextual - @SerialName("slot") - val slot: BigInteger, -) : ScriptNativeDetail - -@Serializable -@SerialName("after") -data class ScriptNativeDetailAfter( - @Contextual - @SerialName("slot") - val after: BigInteger, -) : ScriptNativeDetail - -@Serializable -@SerialName("all") -data class ScriptNativeDetailAll( - @SerialName("from") - val from: List -) : ScriptNativeDetail - -@Serializable -@SerialName("any") -data class ScriptNativeDetailAny( - @SerialName("from") - val from: List -) : ScriptNativeDetail - -@Serializable -@SerialName("some") -data class ScriptNativeDetailSome( - @SerialName("atLeast") - val atLeast: Long, - @SerialName("from") - val from: List -) : ScriptNativeDetail diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ScriptPurpose.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ScriptPurpose.kt index cfb142e..9d0d8d1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ScriptPurpose.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ScriptPurpose.kt @@ -1,45 +1,55 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("purpose") +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "purpose", + visible = true, +) sealed interface ScriptPurpose -@Serializable -@SerialName("spend") +@JsonTypeName("spend") data class ScriptPurposeSpend( - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, - @SerialName("outputReference") + @param:JsonProperty(value = "outputReference", required = true) + @get:JsonProperty("outputReference") val outputReference: UtxoOutputReference, ) : ScriptPurpose -@Serializable -@SerialName("mint") +@JsonTypeName("mint") data class ScriptPurposeMint( - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, - @SerialName("policy") + @param:JsonProperty(value = "policy", required = true) + @get:JsonProperty("policy") val policy: String, ) : ScriptPurpose -@Serializable -@SerialName("publish") +@JsonTypeName("publish") data class ScriptPurposePublish( - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, - @SerialName("certificate") + @param:JsonProperty(value = "certificate", required = true) + @get:JsonProperty("certificate") val certificate: Certificate, ) : ScriptPurpose -@Serializable -@SerialName("withdraw") +@JsonTypeName("withdraw") data class ScriptPurposeWithdraw( - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, - @SerialName("rewardAccount") + @param:JsonProperty(value = "rewardAccount", required = true) + @get:JsonProperty("rewardAccount") val rewardAccount: String, ) : ScriptPurpose diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Seconds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Seconds.kt index c0cc218..d3932c3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Seconds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Seconds.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class Seconds( - @SerialName("seconds") - @Contextual + @param:JsonProperty(value = "seconds", required = true) + @get:JsonProperty("seconds") val seconds: BigInteger, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisProtocolParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisProtocolParameters.kt index bc8e35e..c5608af 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisProtocolParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisProtocolParameters.kt @@ -1,48 +1,59 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ShelleyGenesisProtocolParameters( - @SerialName("minFeeCoefficient") + @param:JsonProperty(value = "minFeeCoefficient", required = true) + @get:JsonProperty("minFeeCoefficient") val minFeeCoefficient: Int, - @SerialName("minFeeConstant") + @param:JsonProperty(value = "minFeeConstant", required = true) + @get:JsonProperty("minFeeConstant") val minFeeConstant: Ada, - @SerialName("maxBlockBodySize") + @param:JsonProperty(value = "maxBlockBodySize", required = true) + @get:JsonProperty("maxBlockBodySize") val maxBlockBodySize: BytesSize, - @SerialName("maxBlockHeaderSize") + @param:JsonProperty(value = "maxBlockHeaderSize", required = true) + @get:JsonProperty("maxBlockHeaderSize") val maxBlockHeaderSize: BytesSize, - @SerialName("maxTransactionSize") + @param:JsonProperty(value = "maxTransactionSize", required = true) + @get:JsonProperty("maxTransactionSize") val maxTransactionSize: BytesSize, - @SerialName("stakeCredentialDeposit") + @param:JsonProperty(value = "stakeCredentialDeposit", required = true) + @get:JsonProperty("stakeCredentialDeposit") val stakeCredentialDeposit: Ada, - @SerialName("stakePoolDeposit") + @param:JsonProperty(value = "stakePoolDeposit", required = true) + @get:JsonProperty("stakePoolDeposit") val stakePoolDeposit: Ada, - @SerialName("stakePoolRetirementEpochBound") + @param:JsonProperty(value = "stakePoolRetirementEpochBound", required = true) + @get:JsonProperty("stakePoolRetirementEpochBound") val stakePoolRetirementEpochBound: Int, - @SerialName("desiredNumberOfStakePools") + @param:JsonProperty(value = "desiredNumberOfStakePools", required = true) + @get:JsonProperty("desiredNumberOfStakePools") val desiredNumberOfStakePools: Int, - @SerialName("stakePoolPledgeInfluence") - @Contextual + @param:JsonProperty(value = "stakePoolPledgeInfluence", required = true) + @get:JsonProperty("stakePoolPledgeInfluence") val stakePoolPledgeInfluence: BigFraction, - @SerialName("monetaryExpansion") - @Contextual + @param:JsonProperty(value = "monetaryExpansion", required = true) + @get:JsonProperty("monetaryExpansion") val monetaryExpansion: BigFraction, - @SerialName("treasuryExpansion") - @Contextual + @param:JsonProperty(value = "treasuryExpansion", required = true) + @get:JsonProperty("treasuryExpansion") val treasuryExpansion: BigFraction, - @SerialName("federatedBlockProductionRatio") - @Contextual + @param:JsonProperty(value = "federatedBlockProductionRatio", required = true) + @get:JsonProperty("federatedBlockProductionRatio") val federatedBlockProductionRatio: BigFraction, - @SerialName("extraEntropy") + @param:JsonProperty(value = "extraEntropy", required = true) + @get:JsonProperty("extraEntropy") val extraEntropy: String, - @SerialName("minUtxoDepositConstant") + @param:JsonProperty(value = "minUtxoDepositConstant", required = true) + @get:JsonProperty("minUtxoDepositConstant") val minUtxoDepositConstant: Ada, - @SerialName("minUtxoDepositCoefficient") + @param:JsonProperty(value = "minUtxoDepositCoefficient", required = true) + @get:JsonProperty("minUtxoDepositCoefficient") val minUtxoDepositCoefficient: Int, - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: Version, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisStakePools.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisStakePools.kt index f7f7bd8..8dad979 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisStakePools.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ShelleyGenesisStakePools.kt @@ -1,13 +1,14 @@ package io.newm.kogmios.protocols.model +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.result.StakePoolsResult -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class ShelleyGenesisStakePools( - @SerialName("stakePools") + @param:JsonProperty(value = "stakePools", required = true) + @get:JsonProperty("stakePools") val stakePools: StakePoolsResult, - @SerialName("delegators") + @param:JsonProperty(value = "delegators", required = true) + @get:JsonProperty("delegators") val delegators: Map, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Signatory.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Signatory.kt index f9785df..72697fa 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Signatory.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Signatory.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Signatory( - @SerialName("key") + @param:JsonProperty(value = "key", required = true) + @get:JsonProperty("key") val key: String, - @SerialName("signature") + @param:JsonProperty(value = "signature", required = true) + @get:JsonProperty("signature") val signature: String, - @SerialName("chainCode") val chainCode: String? = null, - @SerialName("addressAttributes") val addressAttributes: String? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Software.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Software.kt index c706334..2e83bd1 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Software.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Software.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Software( - @SerialName("appName") + @param:JsonProperty(value = "appName", required = true) + @get:JsonProperty("appName") val appName: String, - @SerialName("number") + @param:JsonProperty(value = "number", required = true) + @get:JsonProperty("number") val number: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePool.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePool.kt index 056f5ad..ae37bbe 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePool.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePool.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class StakePool( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolProtocolParametersUpdateThresholds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolProtocolParametersUpdateThresholds.kt index 481219d..8d57526 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolProtocolParametersUpdateThresholds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolProtocolParametersUpdateThresholds.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class StakePoolProtocolParametersUpdateThresholds( - @SerialName("security") - @Contextual + @param:JsonProperty(value = "security", required = true) + @get:JsonProperty("security") val security: BigFraction, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolVotingThresholds.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolVotingThresholds.kt index b4fe181..0bde7ec 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolVotingThresholds.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/StakePoolVotingThresholds.kt @@ -1,20 +1,20 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class StakePoolVotingThresholds( - @SerialName("noConfidence") - @Contextual + @param:JsonProperty(value = "noConfidence", required = true) + @get:JsonProperty("noConfidence") val noConfidence: BigFraction, - @SerialName("constitutionalCommittee") + @param:JsonProperty(value = "constitutionalCommittee", required = true) + @get:JsonProperty("constitutionalCommittee") val constitutionalCommittee: ConstitutionalCommitteeVotingThresholds, - @SerialName("hardForkInitiation") - @Contextual + @param:JsonProperty(value = "hardForkInitiation", required = true) + @get:JsonProperty("hardForkInitiation") val hardForkInitiation: BigFraction, - @SerialName("protocolParametersUpdate") + @param:JsonProperty(value = "protocolParametersUpdate", required = true) + @get:JsonProperty("protocolParametersUpdate") val protocolParametersUpdate: StakePoolProtocolParametersUpdateThresholds, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Tip.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Tip.kt index 464da78..f3114e5 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Tip.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Tip.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Tip( - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("height") + @param:JsonProperty(value = "height", required = true) + @get:JsonProperty("height") val height: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Transaction.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Transaction.kt index 4c3d077..871f2d9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Transaction.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Transaction.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Transaction( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/TransactionMetadata.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/TransactionMetadata.kt index 319f050..bcff548 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/TransactionMetadata.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/TransactionMetadata.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class TransactionMetadata( - @SerialName("hash") + @param:JsonProperty(value = "hash", required = true) + @get:JsonProperty("hash") val hash: String, - @SerialName("labels") + @param:JsonProperty(value = "labels", required = true) + @get:JsonProperty("labels") val labels: Map, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Tx.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Tx.kt index 0a35a4f..e04593c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Tx.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Tx.kt @@ -1,60 +1,45 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger -@Serializable data class Tx( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("spends") + @param:JsonProperty(value = "spends", required = true) + @get:JsonProperty("spends") val spends: String, - @SerialName("inputs") + @param:JsonProperty(value = "inputs", required = true) + @get:JsonProperty("inputs") val inputs: List, - @SerialName("references") val references: List? = null, - @SerialName("collaterals") val collaterals: List? = null, - @SerialName("totalCollateral") val totalCollateral: Ada? = null, - @SerialName("collateralReturn") val collateralReturn: UtxoOutput? = null, - @SerialName("outputs") + @param:JsonProperty(value = "outputs", required = true) + @get:JsonProperty("outputs") val outputs: List, - @SerialName("certificates") val certificates: List? = null, - @SerialName("withdrawals") val withdrawals: Map? = null, - @SerialName("fee") + @param:JsonProperty(value = "fee", required = true) + @get:JsonProperty("fee") val fee: Ada, - @SerialName("validityInterval") val validityInterval: ValidityInterval? = null, - @SerialName("mint") - val mint: Map>? = null, - @SerialName("network") + val mint: Map>? = null, val network: String? = null, - @SerialName("scriptIntegrityHash") val scriptIntegrityHash: String? = null, - @SerialName("requiredExtraSignatories") val requiredExtraSignatories: List? = null, - @SerialName("requiredExtraScripts") val requiredExtraScripts: List? = null, - @SerialName("proposals") val proposals: List? = null, - @SerialName("votes") val votes: List? = null, - @SerialName("metadata") val metadata: TransactionMetadata? = null, - @SerialName("signatories") + @param:JsonProperty(value = "signatories", required = true) + @get:JsonProperty("signatories") val signatories: List, - @SerialName("scripts") val scripts: Map? = null, - @SerialName("datums") val datums: Map? = null, - @SerialName("redeemers") val redeemers: List? = null, - @SerialName("cbor") val cbor: String? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/TxRedeemer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/TxRedeemer.kt index 976e237..51ab3ea 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/TxRedeemer.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/TxRedeemer.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class TxRedeemer( - @SerialName("executionUnits") + @param:JsonProperty(value = "executionUnits", required = true) + @get:JsonProperty("executionUnits") val executionUnits: ExecutionUnits, - @SerialName("redeemer") + @param:JsonProperty(value = "redeemer", required = true) + @get:JsonProperty("redeemer") val redeemer: String, - @SerialName("validator") + @param:JsonProperty(value = "validator", required = true) + @get:JsonProperty("validator") val validator: Validator, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/TxShelleyBootstrap.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/TxShelleyBootstrap.kt index 348d34d..779d942 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/TxShelleyBootstrap.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/TxShelleyBootstrap.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class TxShelleyBootstrap( - @SerialName("signature") + @param:JsonProperty(value = "signature", required = true) + @get:JsonProperty("signature") val signature: String, - @SerialName("key") + @param:JsonProperty(value = "key", required = true) + @get:JsonProperty("key") val key: String, - @SerialName("chainCode") + @param:JsonProperty(value = "chainCode", required = true) + @get:JsonProperty("chainCode") val chainCode: String?, - @SerialName("addressAttributes") + @param:JsonProperty(value = "addressAttributes", required = true) + @get:JsonProperty("addressAttributes") val addressAttributes: String?, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParameters.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParameters.kt index 4bfdab3..6c01141 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParameters.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParameters.kt @@ -1,53 +1,60 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import org.apache.commons.numbers.fraction.BigFraction import java.math.BigInteger -@Serializable data class UpdatableParameters( - @SerialName("scriptVersion") + @param:JsonProperty(value = "scriptVersion", required = true) + @get:JsonProperty("scriptVersion") val scriptVersion: Int, - @SerialName("slotDuration") + @param:JsonProperty(value = "slotDuration", required = true) + @get:JsonProperty("slotDuration") val slotDuration: Long, - @SerialName("maxBlockBodySize") + @param:JsonProperty(value = "maxBlockBodySize", required = true) + @get:JsonProperty("maxBlockBodySize") val maxBlockBodySize: BytesSize, - @SerialName("maxBlockHeaderSize") + @param:JsonProperty(value = "maxBlockHeaderSize", required = true) + @get:JsonProperty("maxBlockHeaderSize") val maxBlockHeaderSize: BytesSize, - @SerialName("maxTransactionSize") + @param:JsonProperty(value = "maxTransactionSize", required = true) + @get:JsonProperty("maxTransactionSize") val maxTransactionSize: BytesSize, - @SerialName("maxUpdateProposalSize") + @param:JsonProperty(value = "maxUpdateProposalSize", required = true) + @get:JsonProperty("maxUpdateProposalSize") val maxUpdateProposalSize: BytesSize, - @SerialName("multiPartyComputationThreshold") - @Contextual + @param:JsonProperty(value = "multiPartyComputationThreshold", required = true) + @get:JsonProperty("multiPartyComputationThreshold") val multiPartyComputationThreshold: BigFraction, - @SerialName("heavyDelegationThreshold") - @Contextual + @param:JsonProperty(value = "heavyDelegationThreshold", required = true) + @get:JsonProperty("heavyDelegationThreshold") val heavyDelegationThreshold: BigFraction, - @SerialName("updateVoteThreshold") - @Contextual + @param:JsonProperty(value = "updateVoteThreshold", required = true) + @get:JsonProperty("updateVoteThreshold") val updateVoteThreshold: BigFraction, - @SerialName("updateProposalThreshold") - @Contextual + @param:JsonProperty(value = "updateProposalThreshold", required = true) + @get:JsonProperty("updateProposalThreshold") val updateProposalThreshold: BigFraction, - @SerialName("updateProposalTimeToLive") + @param:JsonProperty(value = "updateProposalTimeToLive", required = true) + @get:JsonProperty("updateProposalTimeToLive") val updateProposalTimeToLive: Long, - @SerialName("unlockStakeEpoch") - @Contextual + @param:JsonProperty(value = "unlockStakeEpoch", required = true) + @get:JsonProperty("unlockStakeEpoch") val unlockStakeEpoch: BigInteger, - @SerialName("softForkInitThreshold") - @Contextual + @param:JsonProperty(value = "softForkInitThreshold", required = true) + @get:JsonProperty("softForkInitThreshold") val softForkInitThreshold: BigFraction, - @SerialName("softForkMinThreshold") - @Contextual + @param:JsonProperty(value = "softForkMinThreshold", required = true) + @get:JsonProperty("softForkMinThreshold") val softForkMinThreshold: BigFraction, - @SerialName("softForkDecrementThreshold") - @Contextual + @param:JsonProperty(value = "softForkDecrementThreshold", required = true) + @get:JsonProperty("softForkDecrementThreshold") val softForkDecrementThreshold: BigFraction, - @SerialName("minFeeConstant") + @param:JsonProperty(value = "minFeeConstant", required = true) + @get:JsonProperty("minFeeConstant") val minFeeConstant: Ada, - @SerialName("minFeeCoefficient") + @param:JsonProperty(value = "minFeeCoefficient", required = true) + @get:JsonProperty("minFeeCoefficient") val minFeeCoefficient: Int, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParametersProposal.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParametersProposal.kt index 90dee82..e796405 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParametersProposal.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdatableParametersProposal.kt @@ -1,51 +1,23 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class UpdatableParametersProposal( - @SerialName("scriptVersion") val scriptVersion: Int? = null, - @SerialName("slotDuration") val slotDuration: Long? = null, - @SerialName("maxBlockBodySize") val maxBlockBodySize: BytesSize? = null, - @SerialName("maxBlockHeaderSize") val maxBlockHeaderSize: BytesSize? = null, - @SerialName("maxTransactionSize") val maxTransactionSize: BytesSize? = null, - @SerialName("maxUpdateProposalSize") val maxUpdateProposalSize: BytesSize? = null, - @SerialName("multiPartyComputationThreshold") - @Contextual val multiPartyComputationThreshold: BigFraction? = null, - @SerialName("heavyDelegationThreshold") - @Contextual val heavyDelegationThreshold: BigFraction? = null, - @SerialName("updateVoteThreshold") - @Contextual val updateVoteThreshold: BigFraction? = null, - @SerialName("updateProposalThreshold") - @Contextual val updateProposalThreshold: BigFraction? = null, - @SerialName("updateProposalTimeToLive") val updateProposalTimeToLive: Long? = null, - @SerialName("unlockStakeEpoch") val unlockStakeEpoch: Long? = null, - @SerialName("softForkInitThreshold") - @Contextual val softForkInitThreshold: BigFraction? = null, - @SerialName("softForkMinThreshold") - @Contextual val softForkMinThreshold: BigFraction? = null, - @SerialName("softForkDecrementThreshold") - @Contextual val softForkDecrementThreshold: BigFraction? = null, - @SerialName("minFeeConstant") val minFeeConstant: Ada? = null, - @SerialName("minFeeCoefficient") val minFeeCoefficient: Int? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Update.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Update.kt index 376cb50..2dd6392 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Update.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Update.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Update( - @SerialName("proposal") + @param:JsonProperty(value = "proposal", required = true) + @get:JsonProperty("proposal") val proposal: UpdateProposal, - @SerialName("votes") + @param:JsonProperty(value = "votes", required = true) + @get:JsonProperty("votes") val votes: List, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposal.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposal.kt index 7107528..6e5943d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposal.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposal.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UpdateProposal( - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: Version, - @SerialName("software") + @param:JsonProperty(value = "software", required = true) + @get:JsonProperty("software") val software: Software, - @SerialName("parameters") + @param:JsonProperty(value = "parameters", required = true) + @get:JsonProperty("parameters") val parameters: UpdatableParametersProposal, - @SerialName("metadata") + @param:JsonProperty(value = "metadata", required = true) + @get:JsonProperty("metadata") val metadata: Map, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposalId.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposalId.kt index 33b69fb..f4740bd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposalId.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateProposalId.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UpdateProposalId( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateVote.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateVote.kt index ad7b7be..6399494 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateVote.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UpdateVote.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UpdateVote( - @SerialName("voter") + @param:JsonProperty(value = "voter", required = true) + @get:JsonProperty("voter") val voter: VerificationKey, - @SerialName("proposal") + @param:JsonProperty(value = "proposal", required = true) + @get:JsonProperty("proposal") val proposal: UpdateProposalId, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoInput.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoInput.kt index ce1ca62..f2b4677 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoInput.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoInput.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UtxoInput( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Transaction, - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutput.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutput.kt index 00c7da3..f420e43 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutput.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutput.kt @@ -1,18 +1,15 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UtxoOutput( - @SerialName("address") + @param:JsonProperty(value = "address", required = true) + @get:JsonProperty("address") val address: String, - @SerialName("value") + @param:JsonProperty(value = "value", required = true) + @get:JsonProperty("value") val value: UtxoOutputValue, - @SerialName("datumHash") val datumHash: String? = null, - @SerialName("datum") val datum: String? = null, - @SerialName("script") val script: Script? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputReference.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputReference.kt index f06e40f..cd2a2a7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputReference.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputReference.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class UtxoOutputReference( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Transaction, - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputValue.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputValue.kt index 010b486..2307af9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputValue.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/UtxoOutputValue.kt @@ -1,13 +1,10 @@ package io.newm.kogmios.protocols.model -import io.newm.kogmios.protocols.model.serializers.UtxoOutputValueSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable(with = UtxoOutputValueSerializer::class) data class UtxoOutputValue( - @SerialName("ada") + @param:JsonProperty(value = "ada", required = true) + @get:JsonProperty("ada") val ada: Ada, - @SerialName("assets") val assets: List? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Validator.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Validator.kt index efc4d0e..9fc24e8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Validator.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Validator.kt @@ -1,12 +1,12 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Validator( - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Int, - @SerialName("purpose") + @param:JsonProperty(value = "purpose", required = true) + @get:JsonProperty("purpose") val purpose: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/ValidityInterval.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/ValidityInterval.kt index 8f87512..909e777 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/ValidityInterval.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/ValidityInterval.kt @@ -1,16 +1,8 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable import java.math.BigInteger -@Serializable data class ValidityInterval( - @SerialName("invalidBefore") - @Contextual val invalidBefore: BigInteger? = null, - @SerialName("invalidAfter") - @Contextual val invalidAfter: BigInteger? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/VerificationKey.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/VerificationKey.kt index ead7657..c9b6c00 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/VerificationKey.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/VerificationKey.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class VerificationKey( - @SerialName("verificationKey") + @param:JsonProperty(value = "verificationKey", required = true) + @get:JsonProperty("verificationKey") val verificationKey: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Version.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Version.kt index 13e4544..4bb83d9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Version.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Version.kt @@ -1,14 +1,13 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Version( - @SerialName("major") + @param:JsonProperty(value = "major", required = true) + @get:JsonProperty("major") val major: Int, - @SerialName("minor") + @param:JsonProperty(value = "minor", required = true) + @get:JsonProperty("minor") val minor: Int, - @SerialName("patch") val patch: Int? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Vote.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Vote.kt index 8b2c9d3..e0cdc18 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Vote.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Vote.kt @@ -1,16 +1,14 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable enum class Vote { - @SerialName("yes") + @JsonProperty("yes") YES, - @SerialName("no") + @JsonProperty("no") NO, - @SerialName("abstain") + @JsonProperty("abstain") ABSTAIN, } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/Voter.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/Voter.kt index 79e35d5..bcc5a58 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/Voter.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/Voter.kt @@ -1,37 +1,38 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@JsonClassDiscriminator("role") +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "role") sealed interface Voter -@Serializable -@SerialName("genesisDelegate") +@JsonTypeName("genesisDelegate") data class GenesisDelegateVoter( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : Voter -@Serializable -@SerialName("constitutionalCommittee") +@JsonTypeName("constitutionalCommittee") data class ConstitutionalCommitteeVoter( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : Voter -@Serializable -@SerialName("delegateRepresentative") +@JsonTypeName("delegateRepresentative") data class DelegateRepresentativeVoter( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : Voter -@Serializable -@SerialName("stakePoolOperator") +@JsonTypeName("stakePoolOperator") data class StakePoolOperatorVoter( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : Voter diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/VoterReference.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/VoterReference.kt index 024cbe6..3c5f554 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/VoterReference.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/VoterReference.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class VoterReference( - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/BootstrapAttributesTooLargeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/BootstrapAttributesTooLargeFault.kt index a2f8070..ddd3f64 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/BootstrapAttributesTooLargeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/BootstrapAttributesTooLargeFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutput -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Some output associated with legacy / bootstrap (a.k.a. Byron) addresses have attributes that are too large. The field 'data.bootstrapOutputs' lists all affected outputs. */ -@Serializable -@SerialName("3126") + +@JsonTypeName("3126") data class BootstrapAttributesTooLargeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: BootstrapAttributesTooLargeFaultData, ) : Fault -@Serializable data class BootstrapAttributesTooLargeFaultData( - @SerialName("bootstrapOutputs") + @param:JsonProperty(value = "bootstrapOutputs", required = true) + @get:JsonProperty("bootstrapOutputs") val bootstrapOutputs: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CannotCreateEvaluationContextFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CannotCreateEvaluationContextFault.kt index 1041b8f..3c30d22 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CannotCreateEvaluationContextFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CannotCreateEvaluationContextFault.kt @@ -1,20 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction is malformed or missing information; making evaluation impossible. */ -@Serializable -@SerialName("3004") + +@JsonTypeName("3004") data class CannotCreateEvaluationContextFault( + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: CannotCreateEvaluationContextFaultData, ) : Fault -@Serializable data class CannotCreateEvaluationContextFaultData( + @param:JsonProperty(value = "reason", required = true) + @get:JsonProperty("reason") val reason: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CollateralLockedByScriptFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CollateralLockedByScriptFault.kt index 3a0b998..3a8c9e6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CollateralLockedByScriptFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CollateralLockedByScriptFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Invalid choice of collateral: an input provided for collateral is locked by script. Collateral inputs must be spendable, and the ledger must be able to assert their validity during the first phase of validations (a.k.a phase-1). This discards any input locked by a Plutus script to be used as collateral. Note that for some reason inputs locked by native scripts are also excluded from candidates collateral. The field 'data.unsuitableCollateralInputs' lists all the problematic output references. */ -@Serializable -@SerialName("3129") + +@JsonTypeName("3129") data class CollateralLockedByScriptFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: CollateralLockedByScriptFaultData, ) : Fault -@Serializable data class CollateralLockedByScriptFaultData( - @SerialName("unsuitableCollateralInputs") + @param:JsonProperty(value = "unsuitableCollateralInputs", required = true) + @get:JsonProperty("unsuitableCollateralInputs") val unsuitableCollateralInputs: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ConflictingCommitteeUpdateFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ConflictingCommitteeUpdateFault.kt index f9dd131..36a5992 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ConflictingCommitteeUpdateFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ConflictingCommitteeUpdateFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.VoterReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains an invalid governance action: it tries to both add members to the committee and remove some of those same members. The field 'data.conflictingMembers' indicates which members are found on both sides. */ -@Serializable -@SerialName("3156") + +@JsonTypeName("3156") data class ConflictingCommitteeUpdateFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ConflictingCommitteeUpdateFaultData, ) : Fault -@Serializable data class ConflictingCommitteeUpdateFaultData( - @SerialName("conflictingMembers") + @param:JsonProperty(value = "conflictingMembers", required = true) + @get:JsonProperty("conflictingMembers") val conflictingMembers: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialAlreadyRegisteredFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialAlreadyRegisteredFault.kt index 6c6a231..cc8b684 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialAlreadyRegisteredFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialAlreadyRegisteredFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Trying to re-register some already known credentials. Stake credentials can only be registered once. This is true for both keys and scripts. The field 'data.knownCredential' points to an already known credential that's being re-registered by this transaction. */ -@Serializable -@SerialName("3145") + +@JsonTypeName("3145") data class CredentialAlreadyRegisteredFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: CredentialAlreadyRegisteredFaultData, ) : Fault -@Serializable data class CredentialAlreadyRegisteredFaultData( - @SerialName("knownCredential") + @param:JsonProperty(value = "knownCredential", required = true) + @get:JsonProperty("knownCredential") val knownCredential: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialDepositMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialDepositMismatchFault.kt index 0c47b47..59ed125 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialDepositMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/CredentialDepositMismatchFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The deposit specified in a stake credential registration (for delegation or governance) does not match the current value set by protocol parameters. The field 'data.expectedDeposit', when present, indicates the deposit amount as currently expected by ledger. */ -@Serializable -@SerialName("3151") + +@JsonTypeName("3151") data class CredentialDepositMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: CredentialDepositMismatchFaultData, ) : Fault -@Serializable data class CredentialDepositMismatchFaultData( - @SerialName("providedDeposit") + @param:JsonProperty(value = "providedDeposit", required = true) + @get:JsonProperty("providedDeposit") val providedDeposit: Ada, - @SerialName("expectedDeposit") + @param:JsonProperty(value = "expectedDeposit", required = true) + @get:JsonProperty("expectedDeposit") val expectedDeposit: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepAlreadyRegisteredFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepAlreadyRegisteredFault.kt index 0f4a178..abde0e4 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepAlreadyRegisteredFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepAlreadyRegisteredFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.DelegateRepresentative -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Trying to re-register some already known delegate representative. Delegate representatives can only be registered once. The field 'data.knownDelegateRepresentatives' points to an already known credential that's being re-registered by this transaction. */ -@Serializable -@SerialName("3152") + +@JsonTypeName("3152") data class DRepAlreadyRegisteredFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: DRepAlreadyRegisteredFaultData, ) : Fault -@Serializable data class DRepAlreadyRegisteredFaultData( - @SerialName("knownDelegateRepresentative") + @param:JsonProperty(value = "knownDelegateRepresentative", required = true) + @get:JsonProperty("knownDelegateRepresentative") val knownDelegateRepresentative: DelegateRepresentative, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepNotRegisteredFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepNotRegisteredFault.kt index 402d27e..ce0ac38 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepNotRegisteredFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/DRepNotRegisteredFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.DelegateRepresentative -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction references an unknown delegate representative. To delegate to a representative, it must first register as such. This may be done in the same transaction or in an earlier transaction but cannot happen retro-actively. The field 'data.unknownDelegateRepresentative' indicates what credential is used without being registered. */ -@Serializable -@SerialName("3153") + +@JsonTypeName("3153") data class DRepNotRegisteredFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: DRepNotRegisteredFaultData, ) : Fault -@Serializable data class DRepNotRegisteredFaultData( - @SerialName("unknownDelegateRepresentative") + @param:JsonProperty(value = "unknownDelegateRepresentative", required = true) + @get:JsonProperty("unknownDelegateRepresentative") val unknownDelegateRepresentative: DelegateRepresentative, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EmptyInputSetFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EmptyInputSetFault.kt index d7ddb3b..28d9b6b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EmptyInputSetFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EmptyInputSetFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Transaction must have at least one input, but this one has an empty input set. One input is necessary to prevent replayability of transactions, as it piggybacks on the unique spendable property of UTxO. */ -@Serializable -@SerialName("3121") + +@JsonTypeName("3121") data class EmptyInputSetFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EraMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EraMismatchFault.kt index 0157ce1..6656ce9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EraMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EraMismatchFault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The era of the transaction does not match the era of the ledger. */ -@Serializable -@SerialName("3005") + +@JsonTypeName("3005") data class EraMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: EraMismatchFaultData, ) : Fault -@Serializable data class EraMismatchFaultData( - @SerialName("queryEra") + @param:JsonProperty(value = "queryEra", required = true) + @get:JsonProperty("queryEra") val queryEra: String, - @SerialName("ledgerEra") + @param:JsonProperty(value = "ledgerEra", required = true) + @get:JsonProperty("ledgerEra") val ledgerEra: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EvaluateTransactionDeserializationErrorFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EvaluateTransactionDeserializationErrorFault.kt index e83ad2c..a16d6e5 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EvaluateTransactionDeserializationErrorFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/EvaluateTransactionDeserializationErrorFault.kt @@ -1,25 +1,39 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@SerialName("-32602") +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeName("-32602") data class EvaluateTransactionDeserializationErrorFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: EvaluateTransactionDeserializationError, ) : Fault -@Serializable data class EvaluateTransactionDeserializationError( + @param:JsonProperty(value = "shelley", required = true) + @get:JsonProperty("shelley") val shelley: String, + @param:JsonProperty(value = "allegra", required = true) + @get:JsonProperty("allegra") val allegra: String, + @param:JsonProperty(value = "mary", required = true) + @get:JsonProperty("mary") val mary: String, + @param:JsonProperty(value = "alonzo", required = true) + @get:JsonProperty("alonzo") val alonzo: String, + @param:JsonProperty(value = "babbage", required = true) + @get:JsonProperty("babbage") val babbage: String, + @param:JsonProperty(value = "conway", required = true) + @get:JsonProperty("conway") val conway: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExecutionUnitsTooLargeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExecutionUnitsTooLargeFault.kt index b1ce803..6c1dd96 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExecutionUnitsTooLargeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExecutionUnitsTooLargeFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.ExecutionUnits -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction execution budget for scripts execution is above the allowed limit. The protocol limits the amount of execution that a single transaction can do. This limit is set by a protocol parameter. The field 'data.maximumExecutionUnits' indicates the current limit and the field 'data.providedExecutionUnits' indicates how much the transaction requires. */ -@Serializable -@SerialName("3134") + +@JsonTypeName("3134") data class ExecutionUnitsTooLargeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ExecutionUnitsTooLargeFaultData, ) : Fault -@Serializable data class ExecutionUnitsTooLargeFaultData( - @SerialName("providedExecutionUnits") + @param:JsonProperty(value = "providedExecutionUnits", required = true) + @get:JsonProperty("providedExecutionUnits") val providedExecutionUnits: ExecutionUnits, - @SerialName("maximumExecutionUnits") + @param:JsonProperty(value = "maximumExecutionUnits", required = true) + @get:JsonProperty("maximumExecutionUnits") val maximumExecutionUnits: ExecutionUnits, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousDatumsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousDatumsFault.kt index 0419d39..8a2573a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousDatumsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousDatumsFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction failed because it contains datums not associated with any script or output. This could be because you've left some orphan datum behind, because you've listed the wrong inputs in the transaction or because you've just forgotten to include a datum associated with an input. Either way, the field 'data.extraneousDatums' contains a set of data hashes for these extraneous datums. */ -@Serializable -@SerialName("3112") + +@JsonTypeName("3112") data class ExtraneousDatumsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ExtraneousDatumsFaultData, ) : Fault -@Serializable data class ExtraneousDatumsFaultData( - @SerialName("extraneousDatums") + @param:JsonProperty(value = "extraneousDatums", required = true) + @get:JsonProperty("extraneousDatums") val extraneousDatums: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousRedeemersFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousRedeemersFault.kt index a2d8902..88dc613 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousRedeemersFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousRedeemersFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.RedeemerPointer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Extraneous (non-required) redeemers found in the transaction. There are some redeemers that aren't pointing to any script. This could be because you've left some orphan redeemer behind, because they are pointing at the wrong thing or because you forgot to include their associated validator. Either way, the field 'data.extraneousRedeemers' lists the different orphan redeemer pointers. */ -@Serializable -@SerialName("3110") + +@JsonTypeName("3110") data class ExtraneousRedeemersFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ExtraneousRedeemersFaultData, ) : Fault -@Serializable data class ExtraneousRedeemersFaultData( - @SerialName("extraneousRedeemers") + @param:JsonProperty(value = "extraneousRedeemers", required = true) + @get:JsonProperty("extraneousRedeemers") val extraneousRedeemers: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousScriptsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousScriptsFault.kt index b1774bf..f068a8d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousScriptsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ExtraneousScriptsFault.kt @@ -1,25 +1,29 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * This fault is returned when the transaction contains scripts that are not required for the * transaction to be valid. */ -@Serializable -@SerialName("3104") + +@JsonTypeName("3104") data class ExtraneousScriptsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ExtraneousScriptsFaultData, ) : Fault -@Serializable data class ExtraneousScriptsFaultData( - @SerialName("extraneousScripts") + @param:JsonProperty(value = "extraneousScripts", required = true) + @get:JsonProperty("extraneousScripts") val extraneousScripts: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailedToAcquirePointFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailedToAcquirePointFault.kt index df0ef75..01b609a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailedToAcquirePointFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailedToAcquirePointFault.kt @@ -1,18 +1,22 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Unable to acquire the ledger state at the request point. */ -@Serializable -@SerialName("2000") + +@JsonTypeName("2000") data class FailedToAcquirePointFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: StringFaultData, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailingNativeScriptsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailingNativeScriptsFault.kt index 7a112c9..cd774c5 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailingNativeScriptsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FailingNativeScriptsFault.kt @@ -1,21 +1,24 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable -@SerialName("3103") +import com.fasterxml.jackson.annotation.JsonTypeName + +@JsonTypeName("3103") data class FailingNativeScriptsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: FailingNativeScriptsFaultData, ) : Fault -@Serializable data class FailingNativeScriptsFaultData( - @SerialName("failingNativeScripts") + @param:JsonProperty(value = "failingNativeScripts", required = true) + @get:JsonProperty("failingNativeScripts") val failingNativeScripts: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/Fault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/Fault.kt index 99904a5..8110b27 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/Fault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/Fault.kt @@ -1,18 +1,16 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonTypeInfo -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator - -@Serializable -@JsonClassDiscriminator("code") +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "code", + visible = true, +) sealed interface Fault { - @SerialName("code") val code: Long - @SerialName("message") val message: String - @SerialName("data") val data: FaultData? } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FaultData.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FaultData.kt index 10a1c58..5c03e79 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FaultData.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/FaultData.kt @@ -1,6 +1,3 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.Serializable - -@Serializable sealed interface FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ForbiddenWithdrawalFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ForbiddenWithdrawalFault.kt index 7f2bca1..de086ff 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ForbiddenWithdrawalFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ForbiddenWithdrawalFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction is attempting to withdraw rewards from stake credentials that do not engage in on-chain governance. Credentials must be associated with a delegate representative (registered, abstain or noConfidence) before associated rewards can be withdrawn. The field 'data.marginalizedCredentials' lists all the affected credentials. */ -@Serializable -@SerialName("3150") + +@JsonTypeName("3150") data class ForbiddenWithdrawalFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ForbiddenWithdrawalFaultData, ) : Fault -@Serializable data class ForbiddenWithdrawalFaultData( - @SerialName("marginalizedCredentials") + @param:JsonProperty(value = "marginalizedCredentials", required = true) + @get:JsonProperty("marginalizedCredentials") val marginalizedCredentials: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/GovernanceProposalDepositMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/GovernanceProposalDepositMismatchFault.kt index 007cb83..43daa99 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/GovernanceProposalDepositMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/GovernanceProposalDepositMismatchFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * There's a mismatch between the proposal deposit amount declared in the transaction and the one expected by the ledger. The deposit is actually configured by a protocol parameter. The field 'data.expectedDeposit' indicates the current configuration and amount expected by the ledger. The field 'data.providedDeposit' is a reminder of the what was set in the submitted transaction. */ -@Serializable -@SerialName("3155") + +@JsonTypeName("3155") data class GovernanceProposalDepositMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: GovernanceProposalDepositMismatchFaultData, ) : Fault -@Serializable data class GovernanceProposalDepositMismatchFaultData( - @SerialName("providedDeposit") + @param:JsonProperty(value = "providedDeposit", required = true) + @get:JsonProperty("providedDeposit") val providedDeposit: Ada, - @SerialName("expectedDeposit") + @param:JsonProperty(value = "expectedDeposit", required = true) + @get:JsonProperty("expectedDeposit") val expectedDeposit: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompatibleEraFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompatibleEraFault.kt index 2bea88e..7d75e33 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompatibleEraFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompatibleEraFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Returned when trying to evaluate execution units of a pre-Alonzo transaction. Note that this isn't possible with Ogmios because transactions are always de-serialized as Alonzo transactions. */ -@Serializable -@SerialName("3000") + +@JsonTypeName("3000") data class IncompatibleEraFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: IncompatibleEraFaultData, ) : Fault -@Serializable data class IncompatibleEraFaultData( - @SerialName("incompatibleEra") + @param:JsonProperty(value = "incompatibleEra", required = true) + @get:JsonProperty("incompatibleEra") val incompatibleEra: String ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompleteWithdrawalsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompleteWithdrawalsFault.kt index 9756a50..e79619c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompleteWithdrawalsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IncompleteWithdrawalsFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains incomplete or invalid rewards withdrawals. When present, rewards withdrawals must consume rewards in full, there cannot be any leftover. The field 'data.incompleteWithdrawals' contains a map of withdrawals and their current rewards balance. */ -@Serializable -@SerialName("3141") + +@JsonTypeName("3141") data class IncompleteWithdrawalsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: IncompleteWithdrawalsFaultData, ) : Fault -@Serializable data class IncompleteWithdrawalsFaultData( - @SerialName("incompleteWithdrawals") + @param:JsonProperty(value = "incompleteWithdrawals", required = true) + @get:JsonProperty("incompleteWithdrawals") val incompleteWithdrawals: Map, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientCollateralFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientCollateralFault.kt index ee61212..5fff749 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientCollateralFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientCollateralFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Insufficient collateral value for Plutus scripts in the transaction. Indeed, when executing scripts, you must provide a collateral amount which minimum is a percentage of the total execution budget for the transaction. The exact percentage is given by a protocol parameter. The field 'data.providedCollateral' indicates the amount currently provided as collateral in the transaction, whereas 'data.minimumRequiredCollateral' indicates the minimum amount expected by the ledger */ -@Serializable -@SerialName("3128") + +@JsonTypeName("3128") data class InsufficientCollateralFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: InsufficientCollateralFaultData, ) : Fault -@Serializable data class InsufficientCollateralFaultData( - @SerialName("providedCollateral") + @param:JsonProperty(value = "providedCollateral", required = true) + @get:JsonProperty("providedCollateral") val providedCollateral: Ada, - @SerialName("minimumRequiredCollateral") + @param:JsonProperty(value = "minimumRequiredCollateral", required = true) + @get:JsonProperty("minimumRequiredCollateral") val minimumRequiredCollateral: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientlyFundedOutputsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientlyFundedOutputsFault.kt index 94da2a8..f4e7a4d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientlyFundedOutputsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InsufficientlyFundedOutputsFault.kt @@ -1,34 +1,40 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada import io.newm.kogmios.protocols.model.UtxoOutput -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Some outputs have an insufficient amount of Ada attached to them. In fact, any new output created in a system must pay for the resources it occupies. Because user-created assets are worthless (from the point of view of the protocol), those resources must be paid in the form of a Ada deposit. The exact depends on the size of the serialized output: the more assets, the higher the amount. The field 'data.insufficientlyFundedOutputs.[].output' contains a list of all transaction outputs that are insufficiently funded. Starting from the Babbage era, the field 'data.insufficientlyFundedOutputs.[].minimumRequiredValue' indicates the required amount of Lovelace (1e6 Lovelace = 1 Ada) needed for each output. */ -@Serializable -@SerialName("3125") + +@JsonTypeName("3125") data class InsufficientlyFundedOutputsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: InsufficientlyFundedOutputsFaultData, ) : Fault -@Serializable data class InsufficientlyFundedOutputsFaultData( - @SerialName("insufficientlyFundedOutputs") + @param:JsonProperty(value = "insufficientlyFundedOutputs", required = true) + @get:JsonProperty("insufficientlyFundedOutputs") val insufficientlyFundedOutputs: List, ) : FaultData -@Serializable data class InsufficientlyFundedOutput( - @SerialName("output") + @param:JsonProperty(value = "output", required = true) + @get:JsonProperty("output") val output: UtxoOutput, - @SerialName("minimumRequiredValue") + @param:JsonProperty(value = "minimumRequiredValue", required = true) + @get:JsonProperty("minimumRequiredValue") val minimumRequiredValue: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalErrorFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalErrorFault.kt index 752af7e..120f52a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalErrorFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalErrorFault.kt @@ -1,18 +1,22 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Internal error. */ -@Serializable -@SerialName("-1") + +@JsonTypeName("-1") data class InternalErrorFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: StringFaultData, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalLedgerTypeConversionErrorFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalLedgerTypeConversionErrorFault.kt index 09698d8..159f6ec 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalLedgerTypeConversionErrorFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InternalLedgerTypeConversionErrorFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Whoopsie, the ledger failed to upgrade an data-type from an earlier era into data of a newer era. If you ever run into this, please report the issue as you've likely discoverd a critical bug... */ -@Serializable -@SerialName("3999") + +@JsonTypeName("3999") data class InternalLedgerTypeConversionErrorFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IntersectionNotFoundFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IntersectionNotFoundFault.kt index 91cbff2..575c46b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IntersectionNotFoundFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/IntersectionNotFoundFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Tip -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * No intersection found with the requested points. */ -@Serializable -@SerialName("1000") + +@JsonTypeName("1000") data class IntersectionNotFoundFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: IntersectionNotFoundFaultData, ) : Fault -@Serializable data class IntersectionNotFoundFaultData( - @SerialName("tip") + @param:JsonProperty(value = "tip", required = true) + @get:JsonProperty("tip") val tip: Tip, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidCommitteeUpdateFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidCommitteeUpdateFault.kt index a94a05c..4646776 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidCommitteeUpdateFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidCommitteeUpdateFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.VoterReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains an invalid governance action: it tries to add new members to the constitutional committee with a retirement epoch in the past. The field 'data.alreadyRetiredMembers' indicates the faulty members that would otherwise be already retired. */ -@Serializable -@SerialName("3157") + +@JsonTypeName("3157") data class InvalidCommitteeUpdateFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: InvalidCommitteeUpdateFaultData, ) : Fault -@Serializable data class InvalidCommitteeUpdateFaultData( - @SerialName("alreadyRetiredMembers") + @param:JsonProperty(value = "alreadyRetiredMembers", required = true) + @get:JsonProperty("alreadyRetiredMembers") val alreadyRetiredMembers: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidGenesisDelegationFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidGenesisDelegationFault.kt index f101273..3940602 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidGenesisDelegationFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidGenesisDelegationFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Invalid or unauthorized genesis delegation. The genesis delegate is unknown, invalid or already in use. */ -@Serializable -@SerialName("3148") + +@JsonTypeName("3148") data class InvalidGenesisDelegationFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMIRTransferFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMIRTransferFault.kt index 1ae42cd..487989e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMIRTransferFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMIRTransferFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Invalid MIR transfer. The resulting delta is likely negative. */ -@Serializable -@SerialName("3149") + +@JsonTypeName("3149") data class InvalidMIRTransferFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMetadataFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMetadataFault.kt index cd947d5..3b1a2ff 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMetadataFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidMetadataFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Invalid metadatum found in transaction metadata. Metadata byte strings must be no longer than 64-bytes and text strings must be no longer than 64 bytes once UTF-8-encoded. Some metadatum in the transaction infringe this rule. */ -@Serializable -@SerialName("3108") + +@JsonTypeName("3108") data class InvalidMetadataFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidOrMissingPreviousProposalsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidOrMissingPreviousProposalsFault.kt index b2d2a02..58e5db7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidOrMissingPreviousProposalsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidOrMissingPreviousProposalsFault.kt @@ -1,36 +1,41 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.AnchorMetadata import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains invalid or missing reference to previous (ratified) governance proposals. Indeed, some governance proposals such as protocol parameters update or consitutional committee change must point to last action of the same purpose that was ratified. The field 'data.invalidOrMissingPreviousProposals' contains a list of submitted actions that are missing details. For each item, we provide the anchor of the corresponding proposal, the type of previous proposal that is expected and the invalid proposal reference if relevant. */ -@Serializable -@SerialName("3159") + +@JsonTypeName("3159") data class InvalidOrMissingPreviousProposalsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: InvalidOrMissingPreviousProposalsFaultData, ) : Fault -@Serializable data class InvalidOrMissingPreviousProposalsFaultData( - @SerialName("invalidOrMissingPreviousProposals") + @param:JsonProperty(value = "invalidOrMissingPreviousProposals", required = true) + @get:JsonProperty("invalidOrMissingPreviousProposals") val invalidOrMissingPreviousProposals: List, ) : FaultData -@Serializable data class InvalidOrMissingPreviousProposal( - @SerialName("anchor") + @param:JsonProperty(value = "anchor", required = true) + @get:JsonProperty("anchor") val anchor: AnchorMetadata, - @SerialName("type") + @param:JsonProperty(value = "type", required = true) + @get:JsonProperty("type") val type: String, - @SerialName("invalidPreviousProposal") val invalidPreviousProposal: UtxoOutputReference? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidProtocolParametersUpdateFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidProtocolParametersUpdateFault.kt index 7cb4208..a71e4cb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidProtocolParametersUpdateFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidProtocolParametersUpdateFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction contains an invalid or unauthorized protocol parameters update. This operation is reserved to genesis key holders. */ -@Serializable -@SerialName("3139") + +@JsonTypeName("3139") data class InvalidProtocolParametersUpdateFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidSignatoriesFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidSignatoriesFault.kt index 6540920..56fb0ad 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidSignatoriesFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/InvalidSignatoriesFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some signatures are invalid. Only the serialised transaction *body*, without metadata or witnesses, must be signed. */ -@Serializable -@SerialName("3100") + +@JsonTypeName("3100") data class InvalidSignatoriesFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: InvalidSignatoriesFaultData, ) : Fault -@Serializable data class InvalidSignatoriesFaultData( - @SerialName("invalidSignatories") + @param:JsonProperty(value = "invalidSignatories", required = true) + @get:JsonProperty("invalidSignatories") val invalidSignatories: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MalformedScriptsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MalformedScriptsFault.kt index 9b76972..6f05a52 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MalformedScriptsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MalformedScriptsFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some Plutus scripts in the witness set or in an output are invalid. Scripts must be well-formed flat-encoded Plutus scripts, CBOR-encoded. Yes, there's a double binary encoding. The outer-most encoding is therefore just a plain CBOR bytestring. Note that some tools such as the cardano-cli triple encode scripts for some reasons, resulting in a double outer-most CBOR encoding. Make sure that your script are correctly encoded. The field 'data.malformedScripts' lists the hash digests of all the problematic scripts. */ -@Serializable -@SerialName("3116") + +@JsonTypeName("3116") data class MalformedScriptsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MalformedScriptsFaultData, ) : Fault -@Serializable data class MalformedScriptsFaultData( - @SerialName("malformedScripts") + @param:JsonProperty(value = "malformedScripts", required = true) + @get:JsonProperty("malformedScripts") val malformedScripts: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashMismatchFault.kt index cd337ff..2f84d02 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashMismatchFault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * There's a mismatch between the provided metadata hash digest and the one computed from the actual metadata. The two must match exactly. The field 'data.provided.hash' references the provided hash as found in the transaction body, whereas 'data.computed.hash' contains the one the ledger computed from the actual metadata. */ -@Serializable -@SerialName("3107") + +@JsonTypeName("3107") data class MetadataHashMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MetadataHashMismatchFaultData, ) : Fault -@Serializable data class MetadataHashMismatchFaultData( - @SerialName("provided") + @param:JsonProperty(value = "provided", required = true) + @get:JsonProperty("provided") val provided: MetadataHash, - @SerialName("computed") + @param:JsonProperty(value = "computed", required = true) + @get:JsonProperty("computed") val computed: MetadataHash, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashTooLargeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashTooLargeFault.kt index 67ae62a..1cfa3f9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashTooLargeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MetadataHashTooLargeFault.kt @@ -1,28 +1,34 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.BytesSize import io.newm.kogmios.protocols.model.StakePool -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Some hash digest of (optional) stake pool metadata is too long. When registering, stake pools can supply an external metadata file and a hash digest of the content. The hashing algorithm is left open but the output digest must be smaller than 32 bytes. The field 'data.infringingStakePool' indicates which stake pool has an invalid metadata hash and 'data.computedMetadataHashSize' documents the computed hash size. */ -@Serializable -@SerialName("3144") + +@JsonTypeName("3144") data class MetadataHashTooLargeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MetadataHashTooLargeFaultData, ) : Fault -@Serializable data class MetadataHashTooLargeFaultData( - @SerialName("infringingStakePool") + @param:JsonProperty(value = "infringingStakePool", required = true) + @get:JsonProperty("infringingStakePool") val infringingStakePool: StakePool, - @SerialName("computedMetadataHashSize") + @param:JsonProperty(value = "computedMetadataHashSize", required = true) + @get:JsonProperty("computedMetadataHashSize") val computedMetadataHashSize: BytesSize, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MintingOrBurningAdaFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MintingOrBurningAdaFault.kt index cefcc05..e5f88dd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MintingOrBurningAdaFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MintingOrBurningAdaFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction is attempting to mint or burn Ada tokens. That is, fortunately, not allowed by the ledger. */ -@Serializable -@SerialName("3127") + +@JsonTypeName("3127") data class MintingOrBurningAdaFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCollateralInputsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCollateralInputsFault.kt index 4063e81..0c2dfd7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCollateralInputsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCollateralInputsFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction doesn't provide any collateral inputs but it must. Indeed, when executing scripts, you must provide a collateral amount which is collected by the ledger in case of script execution failure. That collateral serves as a compensation for nodes that aren't thus able to collect normal fees set on the transaction. Note that ledger validations are split in two phases. The first phase regards pretty much every validation outside of script executions. Anything from the first phase doesn't require a collateral and will not consume the collateral in case of failure because they require little computing resources. Besides, in principle, any client application or wallet will prevent you from submitting an invalid transaction to begin with. */ -@Serializable -@SerialName("3132") + +@JsonTypeName("3132") data class MissingCollateralInputsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCostModelsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCostModelsFault.kt index 8c5a298..82da5ec 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCostModelsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingCostModelsFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * It seems like the transaction is using a Plutus version for which there's no available cost model yet. This could be because that language version is known of the ledger but hasn't yet been enabled through hard-fork. The field 'data.missingCostModels' lists all the languages for which a cost model is missing. */ -@Serializable -@SerialName("3115") + +@JsonTypeName("3115") data class MissingCostModelsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingCostModelsFaultData, ) : Fault -@Serializable data class MissingCostModelsFaultData( - @SerialName("missingCostModels") + @param:JsonProperty(value = "missingCostModels", required = true) + @get:JsonProperty("missingCostModels") val missingCostModels: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingDatumsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingDatumsFault.kt index 7d06c52..ecf99e9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingDatumsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingDatumsFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Transaction failed because some Plutus scripts are missing their associated datums. 'data.missingDatums' contains a set of data hashes for the missing datums. Ensure all Plutus scripts have an associated datum in the transaction's witness set or, are provided through inline datums in reference inputs. */ -@Serializable -@SerialName("3111") + +@JsonTypeName("3111") data class MissingDatumsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingDatumsFaultData, ) : Fault -@Serializable data class MissingDatumsFaultData( - @SerialName("missingDatums") + @param:JsonProperty(value = "missingDatums", required = true) + @get:JsonProperty("missingDatums") val missingDatums: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataFault.kt index 92899a7..4b95e63 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * No metadata corresponding to a specified metadata hash. It appears that you might have forgotten to attach metadata to a transaction, yet included a hash digest of them in the transaction body? The field 'data.metadata.hash' contains the orphan hash found in the body. */ -@Serializable -@SerialName("3106") + +@JsonTypeName("3106") data class MissingMetadataFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingMetadataFaultData, ) : Fault -@Serializable data class MissingMetadataFaultData( - @SerialName("metadata") + @param:JsonProperty(value = "metadata", required = true) + @get:JsonProperty("metadata") val metadata: MetadataHash, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataHashFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataHashFault.kt index f860fe2..a0e2fe6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataHashFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingMetadataHashFault.kt @@ -1,32 +1,36 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Missing required metadata hash in the transaction body. * If the transaction includes metadata, then it must also include a hash digest of these serialised metadata in its body to prevent malicious actors from tempering with the data. * The field 'data.metadata.hash' contains the expected missing hash digest of the metadata found in the transaction. */ -@Serializable -@SerialName("3105") + +@JsonTypeName("3105") data class MissingMetadataHashFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingMetadataHashFaultData, ) : Fault -@Serializable data class MissingMetadataHashFaultData( - @SerialName("metadata") + @param:JsonProperty(value = "metadata", required = true) + @get:JsonProperty("metadata") val metadata: MetadataHash, ) : FaultData -@Serializable data class MetadataHash( - @SerialName("hash") + @param:JsonProperty(value = "hash", required = true) + @get:JsonProperty("hash") val hash: String, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingRedeemersFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingRedeemersFault.kt index cd9f5ed..657a1a5 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingRedeemersFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingRedeemersFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.ScriptPurpose -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Missing required redeemer(s) for Plutus scripts. There are validators needed for the transaction that do not have an associated redeemer. Redeemer are provided when trying to execute the validation logic of a script (e.g. when spending from an input locked by a script, or minting assets from a Plutus monetary policy. The field 'data.missingRedeemers' lists the different purposes for which a redeemer hasn't been provided. */ -@Serializable -@SerialName("3109") + +@JsonTypeName("3109") data class MissingRedeemersFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingRedeemersFaultData, ) : Fault -@Serializable data class MissingRedeemersFaultData( - @SerialName("missingRedeemers") + @param:JsonProperty(value = "missingRedeemers", required = true) + @get:JsonProperty("missingRedeemers") val missingRedeemers: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScripts2Fault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScripts2Fault.kt index 53fa395..e1fad3b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScripts2Fault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScripts2Fault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Validator -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * An associated script witness is missing. Indeed, any script used in a transaction (when spending, minting, withdrawing or publishing certificates) must be provided in full with the transaction. * Scripts must therefore be added either to the witness set or provided as a reference inputs should you use Plutus V2+ and a format from Babbage and beyond. */ -@Serializable -@SerialName("3011") + +@JsonTypeName("3011") data class MissingScripts2Fault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingScripts2FaultData, ) : Fault -@Serializable data class MissingScripts2FaultData( - @SerialName("missingScripts") + @param:JsonProperty(value = "missingScripts", required = true) + @get:JsonProperty("missingScripts") val missingScripts: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScriptsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScriptsFault.kt index a7a14a7..c34f833 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScriptsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingScriptsFault.kt @@ -1,25 +1,29 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some script witnesses are missing. Indeed, any script used in a transaction (when spending, minting, withdrawing or publishing certificates) must be provided in full with the transaction. * Scripts must therefore be added either to the witness set or provided as a reference inputs should you use Plutus V2+ and a format from Babbage and beyond. */ -@Serializable -@SerialName("3102") + +@JsonTypeName("3102") data class MissingScriptsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingScriptsFaultData, ) : Fault -@Serializable data class MissingScriptsFaultData( - @SerialName("missingScripts") + @param:JsonProperty(value = "missingScripts", required = true) + @get:JsonProperty("missingScripts") val missingScripts: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingSignatoriesFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingSignatoriesFault.kt index 47973f3..c0b0da4 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingSignatoriesFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MissingSignatoriesFault.kt @@ -1,25 +1,29 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some signatures are missing. A signed transaction must carry signatures for all inputs locked by verification keys or a native script. * Transaction may also need signatures for each required extra signatories often required by Plutus Scripts. */ -@Serializable -@SerialName("3101") + +@JsonTypeName("3101") data class MissingSignatoriesFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: MissingSignatoriesFaultData, ) : Fault -@Serializable data class MissingSignatoriesFaultData( - @SerialName("missingSignatories") + @param:JsonProperty(value = "missingSignatories", required = true) + @get:JsonProperty("missingSignatories") val missingSignatories: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MustAcquireMempoolFirstFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MustAcquireMempoolFirstFault.kt index 5245bc7..7310352 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MustAcquireMempoolFirstFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/MustAcquireMempoolFirstFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Must acquire a mempool snapshot prior to performing any query. */ -@Serializable -@SerialName("4000") + +@JsonTypeName("4000") data class MustAcquireMempoolFirstFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NetworkMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NetworkMismatchFault.kt index 7184024..bde7261 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NetworkMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NetworkMismatchFault.kt @@ -1,28 +1,32 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some discriminated entities in the transaction are configured for another network. In fact, payment addresses, stake addresses and stake pool registration certificates are bound to a specific network identifier. This identifier must match the network you're trying to submit them to. Since the Alonzo era, transactions themselves may also contain a network identifier. The field 'data.expectedNetwork' indicates what is the currrently expected network. The field 'data.discriminatedType' indicates what type of entity is causing an issue here. And 'data.invalidEntities' lists all the culprits found in the transaction. The latter isn't present when the transaction's network identifier itself is wrong. */ -@Serializable -@SerialName("3124") + +@JsonTypeName("3124") data class NetworkMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: NetworkMismatchFaultData, ) : Fault -@Serializable data class NetworkMismatchFaultData( - @SerialName("expectedNetwork") + @param:JsonProperty(value = "expectedNetwork", required = true) + @get:JsonProperty("expectedNetwork") val expectedNetwork: String, - @SerialName("discriminatedType") + @param:JsonProperty(value = "discriminatedType", required = true) + @get:JsonProperty("discriminatedType") val discriminatedType: String, - @SerialName("invalidEntities") val invalidEntities: List? = null, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NodeTipTooOldFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NodeTipTooOldFault.kt index 617b96b..2484fd3 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NodeTipTooOldFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NodeTipTooOldFault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Happens when attempting to evaluate execution units on a node that isn't enough synchronized. */ -@Serializable -@SerialName("3003") + +@JsonTypeName("3003") data class NodeTipTooOldFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: NodeTipTooOldFaultData, ) : Fault -@Serializable data class NodeTipTooOldFaultData( - @SerialName("minimumRequiredEra") + @param:JsonProperty(value = "minimumRequiredEra", required = true) + @get:JsonProperty("minimumRequiredEra") val minimumRequiredEra: String, - @SerialName("currentNodeEra") + @param:JsonProperty(value = "currentNodeEra", required = true) + @get:JsonProperty("currentNodeEra") val currentNodeEra: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonAdaCollateralFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonAdaCollateralFault.kt index 0faaaef..2b6fa3f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonAdaCollateralFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonAdaCollateralFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputValue -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * One of the input provided as collateral carries something else than Ada tokens. Only Ada can be used as collateral. Since the Babbage era, you also have the option to set a 'collateral return' or 'collateral change' output in order to send the surplus non-Ada tokens to it. Regardless, the field 'data.unsuitableCollateralValue' indicates the actual collateral value found by the ledger */ -@Serializable -@SerialName("3133") + +@JsonTypeName("3133") data class NonAdaCollateralFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: NonAdaCollateralFaultData, ) : Fault -@Serializable data class NonAdaCollateralFaultData( - @SerialName("unsuitableCollateralValue") + @param:JsonProperty(value = "unsuitableCollateralValue", required = true) + @get:JsonProperty("unsuitableCollateralValue") val unsuitableCollateralValue: UtxoOutputValue, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonEmptyRewardAccountFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonEmptyRewardAccountFault.kt index f974bf5..b40c0cf 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonEmptyRewardAccountFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/NonEmptyRewardAccountFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Trying to unregister stake credentials associated to a non empty reward account. You must empty the reward account first (or do it as part of the same transaction) to proceed. The field 'data.nonEmptyRewardAccountBalance' indicates how much Lovelace is left in the account. */ -@Serializable -@SerialName("3147") + +@JsonTypeName("3147") data class NonEmptyRewardAccountFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: NonEmptyRewardAccountFaultData, ) : Fault -@Serializable data class NonEmptyRewardAccountFaultData( - @SerialName("nonEmptyRewardAccountBalance") + @param:JsonProperty(value = "nonEmptyRewardAccountBalance", required = true) + @get:JsonProperty("nonEmptyRewardAccountBalance") val nonEmptyRewardAccountBalance: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OrphanScriptInputsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OrphanScriptInputsFault.kt index 1e3e435..20efb67 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OrphanScriptInputsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OrphanScriptInputsFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Transaction failed because some Plutus scripts are missing their associated datums. 'data.missingDatums' contains a set of data hashes for the missing datums. Ensure all Plutus scripts have an associated datum in the transaction's witness set or, are provided through inline datums in reference inputs. */ -@Serializable -@SerialName("3114") + +@JsonTypeName("3114") data class OrphanScriptInputsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: OrphanScriptInputsFaultData, ) : Fault -@Serializable data class OrphanScriptInputsFaultData( - @SerialName("orphanScriptInputs") + @param:JsonProperty(value = "orphanScriptInputs", required = true) + @get:JsonProperty("orphanScriptInputs") val orphanScriptInputs: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OutsideOfValidityIntervalFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OutsideOfValidityIntervalFault.kt index b8ddbe6..60f5657 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OutsideOfValidityIntervalFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OutsideOfValidityIntervalFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.ValidityInterval -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction is outside of its validity interval. It was either submitted too early or too late. A transaction that has a lower validity bound can only be accepted by the ledger (and make it to the mempool) if the ledger's current slot is greater than the specified bound. The upper bound works similarly, as a time to live. The field 'data.currentSlot' contains the current slot as known of the ledger (this may be different from the current network slot if the ledger is still catching up). The field 'data.validityInterval' is a reminder of the validity interval provided with the transaction. */ -@Serializable -@SerialName("3118") + +@JsonTypeName("3118") data class OutsideOfValidityIntervalFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: OutsideOfValidityIntervalFaultData, ) : Fault -@Serializable data class OutsideOfValidityIntervalFaultData( - @SerialName("validityInterval") + @param:JsonProperty(value = "validityInterval", required = true) + @get:JsonProperty("validityInterval") val validityInterval: ValidityInterval, - @SerialName("currentSlot") + @param:JsonProperty(value = "currentSlot", required = true) + @get:JsonProperty("currentSlot") val currentSlot: Long, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OverlappingAdditionalUtxoFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OverlappingAdditionalUtxoFault.kt index 23cc211..1b79c0c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OverlappingAdditionalUtxoFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/OverlappingAdditionalUtxoFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Happens when providing an additional UTXO set which overlaps with the UTXO on-chain. */ -@Serializable -@SerialName("3002") + +@JsonTypeName("3002") data class OverlappingAdditionalUtxoFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: OverlappingAdditionalUtxoFaultData, ) : Fault -@Serializable data class OverlappingAdditionalUtxoFaultData( - @SerialName("overlappingOutputReferences") + @param:JsonProperty(value = "overlappingOutputReferences", required = true) + @get:JsonProperty("overlappingOutputReferences") val overlappingOutputReferences: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/RetirementTooLateFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/RetirementTooLateFault.kt index fae847b..c2901e8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/RetirementTooLateFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/RetirementTooLateFault.kt @@ -1,28 +1,34 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * A stake pool retirement certificate is trying to retire too late in the future. Indeed, there's a maximum delay for stake pool retirement, controlled by a protocol parameter. The field 'data.currentEpoch' indicates the current epoch known of the ledger, 'data.declaredEpoch' refers to the epoch declared in the retirement certificate and 'data.firstInvalidEpoch' is the first epoch considered invalid (too far) for retirement */ -@Serializable -@SerialName("3142") + +@JsonTypeName("3142") data class RetirementTooLateFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: RetirementTooLateFaultData, ) : Fault -@Serializable data class RetirementTooLateFaultData( - @SerialName("currentEpoch") + @param:JsonProperty(value = "currentEpoch", required = true) + @get:JsonProperty("currentEpoch") val currentEpoch: Long, - @SerialName("declaredEpoch") + @param:JsonProperty(value = "declaredEpoch", required = true) + @get:JsonProperty("declaredEpoch") val declaredEpoch: Long, - @SerialName("firstInvalidEpoch") + @param:JsonProperty(value = "firstInvalidEpoch", required = true) + @get:JsonProperty("firstInvalidEpoch") val firstInvalidEpoch: Long, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptExecutionFailureFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptExecutionFailureFault.kt index 94ce2ad..45bcbbd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptExecutionFailureFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptExecutionFailureFault.kt @@ -1,25 +1,28 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Validator -import io.newm.kogmios.protocols.model.serializers.ScriptExecutionFailureFaultDataSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * One or more script execution terminated with an error. */ -@Serializable -@SerialName("3010") + +@JsonTypeName("3010") data class ScriptExecutionFailureFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ScriptExecutionFailureFaultData, ) : Fault -@Serializable(with = ScriptExecutionFailureFaultDataSerializer::class) class ScriptExecutionFailureFaultData : ArrayList(), FaultData { @@ -33,10 +36,11 @@ class ScriptExecutionFailureFaultData : override fun hashCode(): Int = super.hashCode() } -@Serializable data class ScriptExecutionFailureFaultDataItem( - @SerialName("validator") + @param:JsonProperty(value = "validator", required = true) + @get:JsonProperty("validator") val validator: Validator, - @SerialName("error") + @param:JsonProperty(value = "error", required = true) + @get:JsonProperty("error") val error: Fault, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptIntegrityHashMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptIntegrityHashMismatchFault.kt index f150433..baf48a6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptIntegrityHashMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ScriptIntegrityHashMismatchFault.kt @@ -1,26 +1,27 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction failed because the provided script integrity hash doesn't match the computed one. This is crucial for ensuring the integrity of cost models and Plutus version used during script execution. The field 'data.providedScriptIntegrity' correspond to what was given, if any, and 'data.computedScriptIntegrity' is what was expected. If the latter is null, this means you shouldn't have included a script integrity hash to begin with. */ -@Serializable -@SerialName("3113") + +@JsonTypeName("3113") data class ScriptIntegrityHashMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ScriptIntegrityHashMismatchFaultData, ) : Fault -@Serializable data class ScriptIntegrityHashMismatchFaultData( - @SerialName("providedScriptIntegrity") val providedScriptIntegrity: String? = null, - @SerialName("computedScriptIntegrity") val computedScriptIntegrity: String? = null, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/SpendsMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/SpendsMismatchFault.kt index 19bebc4..2b38589 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/SpendsMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/SpendsMismatchFault.kt @@ -1,26 +1,29 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Invalid transaction submitted as valid, or vice-versa. Since Alonzo, the ledger may allow invalid transactions to be submitted and included on-chain, provided that they leave a collateral value as compensation. This prevent certain class of attacks. As a consequence, transactions now have a validity tag with them. Your transaction did not match what that validity tag is stating. The field 'data.declaredSpending' indicates what the transaction is supposed to consume (collaterals or inputs) and the field 'data.mismatchReason' provides more information about the mismatch. + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") */ -@Serializable -@SerialName("3136") + +@JsonTypeName("3136") data class SpendsMismatchFault( - @SerialName("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: SpendsMismatchFaultData, ) : Fault -@Serializable data class SpendsMismatchFaultData( - @SerialName("declaredSpending") val declaredSpending: String? = null, - @SerialName("mismatchReason") + @param:JsonProperty(value = "mismatchReason", required = true) + @get:JsonProperty("mismatchReason") val mismatchReason: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StakePoolCostTooLowFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StakePoolCostTooLowFault.kt index 1eaa0a8..0f2e87d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StakePoolCostTooLowFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StakePoolCostTooLowFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Stake pool cost declared in a registration or update certificate are below the allowed minimum. The minimum cost of a stake pool is fixed by a protocol parameter. The 'data.minimumStakePoolCost' field holds the current value of that parameter whereas 'data.declaredStakePoolCost' indicates which amount was declared. */ -@Serializable -@SerialName("3143") + +@JsonTypeName("3143") data class StakePoolCostTooLowFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: StakePoolCostTooLowFaultData, ) : Fault -@Serializable data class StakePoolCostTooLowFaultData( - @SerialName("minimumStakePoolCost") + @param:JsonProperty(value = "minimumStakePoolCost", required = true) + @get:JsonProperty("minimumStakePoolCost") val minimumStakePoolCost: Ada, - @SerialName("declaredStakePoolCost") + @param:JsonProperty(value = "declaredStakePoolCost", required = true) + @get:JsonProperty("declaredStakePoolCost") val declaredStakePoolCost: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StringFaultData.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StringFaultData.kt index a1f0dbd..9fbc8f2 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StringFaultData.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/StringFaultData.kt @@ -1,9 +1,10 @@ package io.newm.kogmios.protocols.model.fault -import io.newm.kogmios.protocols.model.serializers.StringFaultDataSerializer -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue -@Serializable(with = StringFaultDataSerializer::class) -data class StringFaultData( - val value: String, -) : FaultData +data class StringFaultData + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val value: String, + ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TooManyCollateralInputsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TooManyCollateralInputsFault.kt index c31b7fa..3f5ec3a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TooManyCollateralInputsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TooManyCollateralInputsFault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction contains too many collateral inputs. The maximum number of collateral inputs is constrained by a protocol parameter. The field 'data.maximumCollateralInputs' contains the current value of that parameter, and 'data.countedCollateralInputs' indicates how many inputs were actually found in your transaction. */ -@Serializable -@SerialName("3131") + +@JsonTypeName("3131") data class TooManyCollateralInputsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: TooManyCollateralInputsFaultData, ) : Fault -@Serializable data class TooManyCollateralInputsFaultData( - @SerialName("maximumCollateralInputs") + @param:JsonProperty(value = "maximumCollateralInputs", required = true) + @get:JsonProperty("maximumCollateralInputs") val maximumCollateralInputs: Long, - @SerialName("countedCollateralInputs") + @param:JsonProperty(value = "countedCollateralInputs", required = true) + @get:JsonProperty("countedCollateralInputs") val countedCollateralInputs: Long, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TotalCollateralMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TotalCollateralMismatchFault.kt index c98bfed..b815a8b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TotalCollateralMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TotalCollateralMismatchFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * There's a mismatch between the declared total collateral amount, and the value computed from the inputs and outputs. These must match exactly. The field 'data.declaredTotalCollateral' reports the amount declared in the transaction whereas 'data.computedTotalCollateral' refers to the amount actually computed. */ -@Serializable -@SerialName("3135") + +@JsonTypeName("3135") data class TotalCollateralMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: TotalCollateralMismatchFaultData, ) : Fault -@Serializable data class TotalCollateralMismatchFaultData( - @SerialName("declaredTotalCollateral") + @param:JsonProperty(value = "declaredTotalCollateral", required = true) + @get:JsonProperty("declaredTotalCollateral") val declaredTotalCollateral: Ada, - @SerialName("computedTotalCollateral") + @param:JsonProperty(value = "computedTotalCollateral", required = true) + @get:JsonProperty("computedTotalCollateral") val computedTotalCollateral: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionFeeTooSmallFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionFeeTooSmallFault.kt index 6789d81..90513be 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionFeeTooSmallFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionFeeTooSmallFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Insufficient fee! The transaction doesn't not contain enough fee to cover the minimum required by the protocol. Note that fee depends on (a) a flat cost fixed by the protocol, (b) the size of the serialized transaction, (c) the budget allocated for Plutus script execution. The field 'data.minimumRequiredFee' indicates the minimum required fee whereas 'data.providedFee' refers to the fee currently supplied with the transaction. */ -@Serializable -@SerialName("3122") + +@JsonTypeName("3122") data class TransactionFeeTooSmallFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: TransactionFeeTooSmallFaultData, ) : Fault -@Serializable data class TransactionFeeTooSmallFaultData( - @SerialName("minimumRequiredFee") + @param:JsonProperty(value = "minimumRequiredFee", required = true) + @get:JsonProperty("minimumRequiredFee") val minimumRequiredFee: Ada, - @SerialName("providedFee") + @param:JsonProperty(value = "providedFee", required = true) + @get:JsonProperty("providedFee") val providedFee: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionTooLargeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionTooLargeFault.kt index 5468e5e..09804bc 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionTooLargeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TransactionTooLargeFault.kt @@ -1,28 +1,34 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.BytesSize -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Transaction failed because it exceeds the maximum size allowed by the protocol. Indeed, once serialized, transactions must be under a bytes limit specified by a protocol parameter. The field 'data.measuredTransactionSize' indicates the actual measured size of your serialized transaction, whereas 'data.maximumTransactionSize' indicates the current maximum size enforced by the ledger. */ -@Serializable -@SerialName("3119") + +@JsonTypeName("3119") data class TransactionTooLargeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: TransactionTooLargeFaultData, ) : Fault -@Serializable data class TransactionTooLargeFaultData( - @SerialName("measuredTransactionSize") + @param:JsonProperty(value = "measuredTransactionSize", required = true) + @get:JsonProperty("measuredTransactionSize") val measuredTransactionSize: BytesSize, - @SerialName("maximumTransactionSize") + @param:JsonProperty(value = "maximumTransactionSize", required = true) + @get:JsonProperty("maximumTransactionSize") val maximumTransactionSize: BytesSize, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TreasuryWithdrawalMismatchFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TreasuryWithdrawalMismatchFault.kt index 9f17d25..6ab60c9 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TreasuryWithdrawalMismatchFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/TreasuryWithdrawalMismatchFault.kt @@ -1,28 +1,34 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction is trying to withdraw more funds than specified in a governance action! The field 'data.providedWithdrawal' indicates the amount specified in the transaction, whereas 'data.computedWithdrawal' is the actual amount as computed by the ledger. */ -@Serializable -@SerialName("3158") + +@JsonTypeName("3158") data class TreasuryWithdrawalMismatchFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: TreasuryWithdrawalMismatchFaultData, ) : Fault -@Serializable data class TreasuryWithdrawalMismatchFaultData( - @SerialName("providedWithdrawal") + @param:JsonProperty(value = "providedWithdrawal", required = true) + @get:JsonProperty("providedWithdrawal") val providedWithdrawal: Ada, - @SerialName("computedWithdrawal") + @param:JsonProperty(value = "computedWithdrawal", required = true) + @get:JsonProperty("computedWithdrawal") val computedWithdrawal: Ada, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnauthorizedVotes.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnauthorizedVotes.kt index f111f28..e1eb8ea 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnauthorizedVotes.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnauthorizedVotes.kt @@ -1,34 +1,40 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.GovernanceVoter import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains votes from unauthorized voters. The field 'data.unauthorizedVotes' indicates the faulty voters and the action they attempted to incorrectly vote for. */ -@Serializable -@SerialName("3137") + +@JsonTypeName("3137") data class UnauthorizedVotesFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnauthorizedVotesFaultData, ) : Fault -@Serializable data class UnauthorizedVotesFaultData( - @SerialName("unauthorizedVotes") + @param:JsonProperty(value = "unauthorizedVotes", required = true) + @get:JsonProperty("unauthorizedVotes") val unauthorizedVotes: List, ) : FaultData -@Serializable data class UnauthorizedVote( - @SerialName("proposal") + @param:JsonProperty(value = "proposal", required = true) + @get:JsonProperty("proposal") val proposal: UtxoOutputReference, - @SerialName("voter") + @param:JsonProperty(value = "voter", required = true) + @get:JsonProperty("voter") val voter: GovernanceVoter, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnforseeableSlotFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnforseeableSlotFault.kt index aba0d2e..7401102 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnforseeableSlotFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnforseeableSlotFault.kt @@ -1,27 +1,30 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import java.math.BigInteger /** * One of the transaction validity bound is outside any foreseeable future. The vision of the ledger in the future is limited because the ledger cannot guarantee that the chain will not hard-fork into a version of the protocol working with a different set of parameters (or even, working with the same consensus protocol). However, the protocol cannot fork in less than `k` blocks, where `k` is the security parameter of the chain. Plus, Ouroboros Praos ensures that there are at least `k` blocks produced in a window of 3 * k / f slots, where `f` is the density parameter, also known as the active slot coefficient. Short story short, you can only set validity interval in a short timespan, which is around ~36h in the future on Mainnet at the moment of writing this error message. The field 'data.unforeseeableSlot' indicates the slot which couldn't be converted to a POSIX time due to hard fork uncertainty. */ -@Serializable -@SerialName("3130") + +@JsonTypeName("3130") data class UnforseeableSlotFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnforseeableSlotFaultData, ) : Fault -@Serializable data class UnforseeableSlotFaultData( - @SerialName("unforeseeableSlot") - @Contextual + @param:JsonProperty(value = "unforeseeableSlot", required = true) + @get:JsonProperty("unforeseeableSlot") val unforeseeableSlot: BigInteger, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownConstitutionalCommitteeMemberFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownConstitutionalCommitteeMemberFault.kt index de0c191..bbb0ccc 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownConstitutionalCommitteeMemberFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownConstitutionalCommitteeMemberFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.VoterReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction references an unknown constitutional committee member. This can be either because that member does not actually exist or because it was registered but has resigned. The field 'data.unknownConstitutionalCommitteeMember' indicates what credential is unknown. */ -@Serializable -@SerialName("3154") + +@JsonTypeName("3154") data class UnknownConstitutionalCommitteeMemberFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnknownConstitutionalCommitteeMemberFaultData, ) : Fault -@Serializable data class UnknownConstitutionalCommitteeMemberFaultData( - @SerialName("unknownConstitutionalCommitteeMember") + @param:JsonProperty(value = "unknownConstitutionalCommitteeMember", required = true) + @get:JsonProperty("unknownConstitutionalCommitteeMember") val unknownConstitutionalCommitteeMember: VoterReference, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownCredentialFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownCredentialFault.kt index 4a85a60..f868a6e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownCredentialFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownCredentialFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction references an unknown stake credential. For example, to delegate to a stake pool, you must first register the stake key or script used for delegation. This may be done in the same transaction or in an earlier transaction but cannot happen retro-actively. The field 'data.unknownCredential' indicates what credential is used without being registered. */ -@Serializable -@SerialName("3146") + +@JsonTypeName("3146") data class UnknownCredentialFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnknownCredentialFaultData, ) : Fault -@Serializable data class UnknownCredentialFaultData( - @SerialName("unknownCredential") + @param:JsonProperty(value = "unknownCredential", required = true) + @get:JsonProperty("unknownCredential") val unknownCredential: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownGovernanceProposalsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownGovernanceProposalsFault.kt index 47bc01c..da78e9d 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownGovernanceProposalsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownGovernanceProposalsFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.GovernanceProposalReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Reference(s) to unknown governance proposals found in transaction. This may be because you've indicated a wrong identifier or because the proposal hasn't yet been submitted on-chain. Note that the order in which transactions are submitted matters. The field 'data.unknownProposals' tells you about the unknown references. */ -@Serializable -@SerialName("3138") + +@JsonTypeName("3138") data class UnknownGovernanceProposalsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnknownGovernanceProposalsFaultData, ) : Fault -@Serializable data class UnknownGovernanceProposalsFaultData( - @SerialName("unknownProposals") + @param:JsonProperty(value = "unknownProposals", required = true) + @get:JsonProperty("unknownProposals") val unknownProposals: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownOutputReferencesFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownOutputReferencesFault.kt index 7eec2ea..46377f0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownOutputReferencesFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownOutputReferencesFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The transaction contains unknown UTxO references as inputs. This can happen if the inputs you're trying to spend have already been spent, or if you've simply referred to non-existing UTxO altogether. The field 'data.unknownOutputReferences' indicates all unknown inputs. */ -@Serializable -@SerialName("3117") + +@JsonTypeName("3117") data class UnknownOutputReferencesFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnknownOutputReferencesFaultData, ) : Fault -@Serializable data class UnknownOutputReferencesFaultData( - @SerialName("unknownOutputReferences") + @param:JsonProperty(value = "unknownOutputReferences", required = true) + @get:JsonProperty("unknownOutputReferences") val unknownOutputReferences: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownStakePoolFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownStakePoolFault.kt index e50ff94..41ce6b7 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownStakePoolFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnknownStakePoolFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction references an unknown stake pool as a target for delegation or update. Double-check the pool id mentioned in 'data.unknownStakePool'. Note also that order in which transactions are submitted matters; if you're trying to register a pool and delegate to it in one go, make sure to submit transactions in the right order. */ -@Serializable -@SerialName("3140") + +@JsonTypeName("3140") data class UnknownStakePoolFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnknownStakePoolFaultData, ) : Fault -@Serializable data class UnknownStakePoolFaultData( - @SerialName("unknownStakePool") + @param:JsonProperty(value = "unknownStakePool", required = true) + @get:JsonProperty("unknownStakePool") val unknownStakePool: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnrecognizedCertificateTypeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnrecognizedCertificateTypeFault.kt index a82f1e2..5d2e797 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnrecognizedCertificateTypeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnrecognizedCertificateTypeFault.kt @@ -1,18 +1,20 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Unrecognized certificate type. This error is a placeholder due to how internal data-types are modeled. If you ever run into this, please report the issue as you've likely discoverd a critical bug... */ -@Serializable -@SerialName("3998") + +@JsonTypeName("3998") data class UnrecognizedCertificateTypeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") override val data: FaultData? = null, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsuitableOutputReferenceFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsuitableOutputReferenceFault.kt index bcd6fe1..f6f367c 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsuitableOutputReferenceFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsuitableOutputReferenceFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputReference -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * */ -@Serializable -@SerialName("3013") + +@JsonTypeName("3013") data class UnsuitableOutputReferenceFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnsuitableOutputReferenceFaultData, ) : Fault -@Serializable data class UnsuitableOutputReferenceFaultData( - @SerialName("outputReference") + @param:JsonProperty(value = "outputReference", required = true) + @get:JsonProperty("outputReference") val outputReference: UtxoOutputReference, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsupportedEraFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsupportedEraFault.kt index cd0a4b2..89c37d8 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsupportedEraFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/UnsupportedEraFault.kt @@ -1,24 +1,28 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Returned when trying to evaluate execution units of an era that is now considered too old and is no longer supported. This can solved by using a more recent transaction format. */ -@Serializable -@SerialName("3001") + +@JsonTypeName("3001") data class UnsupportedEraFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnsupportedEraFaultData, ) : Fault -@Serializable data class UnsupportedEraFaultData( - @SerialName("unsupportedEra") + @param:JsonProperty(value = "unsupportedEra", required = true) + @get:JsonProperty("unsupportedEra") val unsupportedEra: String, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValidationFailureFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValidationFailureFault.kt index b904e87..9cad9cb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValidationFailureFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValidationFailureFault.kt @@ -1,26 +1,31 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * Some of the (V1) scripts failed to evaluate to a positive outcome. */ -@Serializable -@SerialName("3012") + +@JsonTypeName("3012") data class ValidationFailureFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ValidationFailureFaultData, ) : Fault -@Serializable data class ValidationFailureFaultData( - @SerialName("validationError") + @param:JsonProperty(value = "validationError", required = true) + @get:JsonProperty("validationError") val validationError: String, - @SerialName("traces") + @param:JsonProperty(value = "traces", required = true) + @get:JsonProperty("traces") val traces: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueNotConservedFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueNotConservedFault.kt index 3c26e66..d0185df 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueNotConservedFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueNotConservedFault.kt @@ -1,27 +1,33 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutputValue -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * In and out value not conserved. The transaction must *exactly* balance: every input must be accounted for. There are various things counting as 'in balance': (a) the total value locked by inputs (or collateral inputs in case of a failing script), (b) rewards coming from withdrawals and (c) return deposits from stake credential or pool de-registration. In a similar fashion, various things count towards the 'out balance': (a) the total value assigned to each transaction output, (b) the fee and (c) any deposit for stake credential or pool registration. The field 'data.valueConsumed' contains the total 'in balance', and 'data.valueProduced' indicates the total amount counting as 'out balance'. */ -@Serializable -@SerialName("3123") + +@JsonTypeName("3123") data class ValueNotConservedFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ValueNotConservedFaultData, ) : Fault -@Serializable data class ValueNotConservedFaultData( - @SerialName("valueConsumed") + @param:JsonProperty(value = "valueConsumed", required = true) + @get:JsonProperty("valueConsumed") val valueConsumed: UtxoOutputValue, - @SerialName("valueProduced") + @param:JsonProperty(value = "valueProduced", required = true) + @get:JsonProperty("valueProduced") val valueProduced: UtxoOutputValue, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueTooLargeFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueTooLargeFault.kt index 5d93c52..253b88e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueTooLargeFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/ValueTooLargeFault.kt @@ -1,25 +1,30 @@ package io.newm.kogmios.protocols.model.fault +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.UtxoOutput -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * Some output values in the transaction are too large. Once serialized, values must be below a certain threshold. That threshold sits around 4 KB during the Mary era, and was then made configurable as a protocol parameter in later era. The field 'data.excessivelyLargeOutputs' lists all transaction outputs with values that are above the limit. */ -@Serializable -@SerialName("3120") + +@JsonTypeName("3120") data class ValueTooLargeFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: ValueTooLargeFaultData, ) : Fault -@Serializable data class ValueTooLargeFaultData( - @SerialName("excessivelyLargeOutputs") + @param:JsonProperty(value = "excessivelyLargeOutputs", required = true) + @get:JsonProperty("excessivelyLargeOutputs") val excessivelyLargeOutputs: List, ) : FaultData diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/VotingOnExpiredActionsFault.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/VotingOnExpiredActionsFault.kt index 119f83c..1be642a 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/fault/VotingOnExpiredActionsFault.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/fault/VotingOnExpiredActionsFault.kt @@ -1,18 +1,22 @@ package io.newm.kogmios.protocols.model.fault -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName /** * The transaction contains votes for an expired proposal. The field 'data.unauthorizedVotes' indicates the faulty voters and the proposal they attempted to vote for. */ -@Serializable -@SerialName("3160") + +@JsonTypeName("3160") data class VotingOnExpiredActionsFault( - @SerialName("code") + @param:JsonProperty(value = "code", required = true) + @get:JsonProperty("code") override val code: Long, - @SerialName("message") + @param:JsonProperty(value = "message", required = true) + @get:JsonProperty("message") override val message: String, - @SerialName("data") + @param:JsonProperty(value = "data", required = true) + @get:JsonProperty("data") override val data: UnauthorizedVotesFaultData, ) : Fault diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireMempoolResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireMempoolResult.kt index 3fc53af..821a27f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireMempoolResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireMempoolResult.kt @@ -1,18 +1,18 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty + import java.math.BigInteger /** * A mempool snapshot has been successfully acquired at a given slot. */ -@Serializable + data class AcquireMempoolResult( - @SerialName("acquired") + @param:JsonProperty(value = "acquired", required = true) + @get:JsonProperty("acquired") val acquired: String, - @Contextual - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: BigInteger, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireResult.kt index 2f28c1a..e2ce839 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/AcquireResult.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.PointDetail -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * A point has been successfully acquired for querying the ledger state. */ -@Serializable + data class AcquireResult( - @SerialName("acquired") + @param:JsonProperty(value = "acquired", required = true) + @get:JsonProperty("acquired") val acquired: String, - @SerialName("point") + @param:JsonProperty(value = "point", required = true) + @get:JsonProperty("point") val point: PointDetail, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/BooleanResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/BooleanResult.kt index 99eae84..afb97ff 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/BooleanResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/BooleanResult.kt @@ -1,9 +1,10 @@ package io.newm.kogmios.protocols.model.result -import io.newm.kogmios.protocols.model.serializers.BooleanResultSerializer -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue -@Serializable(with = BooleanResultSerializer::class) -data class BooleanResult( - val value: Boolean -) : OgmiosResult +data class BooleanResult + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val value: Boolean, + ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/Bound.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/Bound.kt index 1274fd1..42d63cd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/Bound.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/Bound.kt @@ -1,15 +1,17 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.Seconds -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class Bound( - @SerialName("time") + @param:JsonProperty(value = "time", required = true) + @get:JsonProperty("time") val time: Seconds, - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("epoch") + @param:JsonProperty(value = "epoch", required = true) + @get:JsonProperty("epoch") val epoch: Long, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/EraSummariesResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/EraSummariesResult.kt index 16168aa..a4a6bae 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/EraSummariesResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/EraSummariesResult.kt @@ -1,10 +1,7 @@ package io.newm.kogmios.protocols.model.result import io.newm.kogmios.protocols.model.EraSummary -import io.newm.kogmios.protocols.model.serializers.EraSummariesResultSerializer -import kotlinx.serialization.Serializable -@Serializable(with = EraSummariesResultSerializer::class) class EraSummariesResult : ArrayList(), OgmiosResult { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/EvaluateTxResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/EvaluateTxResult.kt index 5aa2cd4..3c6806f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/EvaluateTxResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/EvaluateTxResult.kt @@ -1,12 +1,10 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.ExecutionUnits import io.newm.kogmios.protocols.model.Validator -import io.newm.kogmios.protocols.model.serializers.EvaluateTxResultSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable(with = EvaluateTxResultSerializer::class) class EvaluateTxResult : ArrayList(), OgmiosResult { @@ -20,10 +18,11 @@ class EvaluateTxResult : override fun hashCode(): Int = super.hashCode() } -@Serializable data class EvaluateTx( - @SerialName("validator") + @param:JsonProperty(value = "validator", required = true) + @get:JsonProperty("validator") val validator: Validator, - @SerialName("budget") + @param:JsonProperty(value = "budget", required = true) + @get:JsonProperty("budget") val budget: ExecutionUnits, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/GenesisConfigResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/GenesisConfigResult.kt index d7852c5..bf76900 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/GenesisConfigResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/GenesisConfigResult.kt @@ -1,5 +1,11 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeInfo + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Ada import io.newm.kogmios.protocols.model.AlonzoGenesisProtocolParameters import io.newm.kogmios.protocols.model.ConwayConstitution @@ -11,100 +17,124 @@ import io.newm.kogmios.protocols.model.Milliseconds import io.newm.kogmios.protocols.model.ShelleyGenesisProtocolParameters import io.newm.kogmios.protocols.model.ShelleyGenesisStakePools import io.newm.kogmios.protocols.model.UpdatableParameters -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator + import org.apache.commons.numbers.fraction.BigFraction import java.math.BigInteger import kotlin.time.Instant -@Serializable -@JsonClassDiscriminator("era") +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "era", + visible = true, +) sealed interface GenesisConfigResult : OgmiosResult -@Serializable -@SerialName("byron") +@JsonTypeName("byron") data class ByronGenesisConfigResult( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") val era: String, - @SerialName("genesisKeyHashes") + @param:JsonProperty(value = "genesisKeyHashes", required = true) + @get:JsonProperty("genesisKeyHashes") val genesisKeyHashes: List, - @SerialName("genesisDelegations") + @param:JsonProperty(value = "genesisDelegations", required = true) + @get:JsonProperty("genesisDelegations") val genesisDelegations: Map, - @SerialName("startTime") + @param:JsonProperty(value = "startTime", required = true) + @get:JsonProperty("startTime") val startTime: Instant, - @SerialName("initialFunds") + @param:JsonProperty(value = "initialFunds", required = true) + @get:JsonProperty("initialFunds") val initialFunds: Map, - @SerialName("initialVouchers") + @param:JsonProperty(value = "initialVouchers", required = true) + @get:JsonProperty("initialVouchers") val initialVouchers: Map, - @SerialName("securityParameter") - @Contextual + @param:JsonProperty(value = "securityParameter", required = true) + @get:JsonProperty("securityParameter") val securityParameter: BigInteger, - @SerialName("networkMagic") + @param:JsonProperty(value = "networkMagic", required = true) + @get:JsonProperty("networkMagic") val networkMagic: Long, - @SerialName("updatableParameters") + @param:JsonProperty(value = "updatableParameters", required = true) + @get:JsonProperty("updatableParameters") val updatableParameters: UpdatableParameters, ) : GenesisConfigResult -@Serializable -@SerialName("shelley") +@JsonTypeName("shelley") data class ShelleyGenesisConfigResult( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") val era: String, - @SerialName("startTime") + @param:JsonProperty(value = "startTime", required = true) + @get:JsonProperty("startTime") val startTime: Instant, - @SerialName("networkMagic") + @param:JsonProperty(value = "networkMagic", required = true) + @get:JsonProperty("networkMagic") val networkMagic: Long, - @SerialName("network") + @param:JsonProperty(value = "network", required = true) + @get:JsonProperty("network") val network: String, - @SerialName("activeSlotsCoefficient") - @Contextual + @param:JsonProperty(value = "activeSlotsCoefficient", required = true) + @get:JsonProperty("activeSlotsCoefficient") val activeSlotsCoefficient: BigFraction, - @SerialName("securityParameter") - @Contextual + @param:JsonProperty(value = "securityParameter", required = true) + @get:JsonProperty("securityParameter") val securityParameter: BigInteger, - @SerialName("epochLength") + @param:JsonProperty(value = "epochLength", required = true) + @get:JsonProperty("epochLength") val epochLength: Long, - @SerialName("slotsPerKesPeriod") + @param:JsonProperty(value = "slotsPerKesPeriod", required = true) + @get:JsonProperty("slotsPerKesPeriod") val slotsPerKesPeriod: Long, - @SerialName("maxKesEvolutions") + @param:JsonProperty(value = "maxKesEvolutions", required = true) + @get:JsonProperty("maxKesEvolutions") val maxKesEvolutions: Long, - @SerialName("slotLength") + @param:JsonProperty(value = "slotLength", required = true) + @get:JsonProperty("slotLength") val slotLength: Milliseconds, - @SerialName("updateQuorum") + @param:JsonProperty(value = "updateQuorum", required = true) + @get:JsonProperty("updateQuorum") val updateQuorum: Long, - @SerialName("maxLovelaceSupply") - @Contextual + @param:JsonProperty(value = "maxLovelaceSupply", required = true) + @get:JsonProperty("maxLovelaceSupply") val maxLovelaceSupply: BigInteger, - @SerialName("initialParameters") + @param:JsonProperty(value = "initialParameters", required = true) + @get:JsonProperty("initialParameters") val initialParameters: ShelleyGenesisProtocolParameters, - @SerialName("initialDelegates") + @param:JsonProperty(value = "initialDelegates", required = true) + @get:JsonProperty("initialDelegates") val initialDelegates: List, - @SerialName("initialFunds") + @param:JsonProperty(value = "initialFunds", required = true) + @get:JsonProperty("initialFunds") val initialFunds: Map, - @SerialName("initialStakePools") + @param:JsonProperty(value = "initialStakePools", required = true) + @get:JsonProperty("initialStakePools") val initialStakePools: ShelleyGenesisStakePools, ) : GenesisConfigResult -@Serializable -@SerialName("alonzo") +@JsonTypeName("alonzo") data class AlonzoGenesisConfigResult( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") val era: String, - @SerialName("updatableParameters") + @param:JsonProperty(value = "updatableParameters", required = true) + @get:JsonProperty("updatableParameters") val updatableParameters: AlonzoGenesisProtocolParameters, ) : GenesisConfigResult -@Serializable -@SerialName("conway") +@JsonTypeName("conway") data class ConwayGenesisConfigResult( - @SerialName("era") + @param:JsonProperty(value = "era", required = true) + @get:JsonProperty("era") val era: String, - @SerialName("constitution") + @param:JsonProperty(value = "constitution", required = true) + @get:JsonProperty("constitution") val constitution: ConwayConstitution, - @SerialName("constitutionalCommittee") + @param:JsonProperty(value = "constitutionalCommittee", required = true) + @get:JsonProperty("constitutionalCommittee") val constitutionalCommittee: ConwayConstitutionalCommittee, - @SerialName("updatableParameters") + @param:JsonProperty(value = "updatableParameters", required = true) + @get:JsonProperty("updatableParameters") val updatableParameters: ConwayGenesisProtocolParameters, ) : GenesisConfigResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/HealthResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/HealthResult.kt index abb5691..c3a58c4 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/HealthResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/HealthResult.kt @@ -1,32 +1,42 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.CardanoEra -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class HealthResult( - @SerialName("connectionStatus") + @param:JsonProperty(value = "connectionStatus", required = true) + @get:JsonProperty("connectionStatus") val connectionStatus: String, - @SerialName("currentEpoch") + @param:JsonProperty(value = "currentEpoch", required = true) + @get:JsonProperty("currentEpoch") val currentEpoch: Long, - @SerialName("currentEra") + @param:JsonProperty(value = "currentEra", required = true) + @get:JsonProperty("currentEra") val currentEra: CardanoEra, - @SerialName("lastKnownTip") + @param:JsonProperty(value = "lastKnownTip", required = true) + @get:JsonProperty("lastKnownTip") val lastKnownTip: LastKnownTip, - @SerialName("lastTipUpdate") + @param:JsonProperty(value = "lastTipUpdate", required = true) + @get:JsonProperty("lastTipUpdate") val lastTipUpdate: String, - @SerialName("metrics") + @param:JsonProperty(value = "metrics", required = true) + @get:JsonProperty("metrics") val metrics: Metrics, - @SerialName("network") + @param:JsonProperty(value = "network", required = true) + @get:JsonProperty("network") val network: String, - @SerialName("networkSynchronization") + @param:JsonProperty(value = "networkSynchronization", required = true) + @get:JsonProperty("networkSynchronization") val networkSynchronization: Double, - @SerialName("slotInEpoch") + @param:JsonProperty(value = "slotInEpoch", required = true) + @get:JsonProperty("slotInEpoch") val slotInEpoch: Long, - @SerialName("startTime") + @param:JsonProperty(value = "startTime", required = true) + @get:JsonProperty("startTime") val startTime: String, - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: String ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/IgnoredOgmiosResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/IgnoredOgmiosResult.kt deleted file mode 100644 index a96febc..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/IgnoredOgmiosResult.kt +++ /dev/null @@ -1,9 +0,0 @@ -package io.newm.kogmios.protocols.model.result - -/** - * Once I knew only darkness and stillness... - * my life was without past or future... - * but a little word from the fingers of another fell into my hand that clutched at emptiness, - * and my heart leaped to the rapture of living. - */ -data object IgnoredOgmiosResult : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/InstantResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/InstantResult.kt index e1be068..14d299e 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/InstantResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/InstantResult.kt @@ -1,10 +1,11 @@ package io.newm.kogmios.protocols.model.result -import io.newm.kogmios.protocols.model.serializers.InstantResultSerializer +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue import kotlin.time.Instant -import kotlinx.serialization.Serializable -@Serializable(with = InstantResultSerializer::class) -data class InstantResult( - val value: Instant -) : OgmiosResult +data class InstantResult + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val value: Instant, + ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/IntersectionFoundResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/IntersectionFoundResult.kt index 9d144ed..9ea95dc 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/IntersectionFoundResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/IntersectionFoundResult.kt @@ -1,17 +1,19 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.PointDetailOrOrigin import io.newm.kogmios.protocols.model.Tip -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * An intersection has been found between the requested points. */ -@Serializable + data class IntersectionFoundResult( - @SerialName("intersection") + @param:JsonProperty(value = "intersection", required = true) + @get:JsonProperty("intersection") val intersection: PointDetailOrOrigin, - @SerialName("tip") + @param:JsonProperty(value = "tip", required = true) + @get:JsonProperty("tip") val tip: Tip, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LastKnownTip.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LastKnownTip.kt index 8a6b201..b08b7e4 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LastKnownTip.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LastKnownTip.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class LastKnownTip( - @SerialName("height") + @param:JsonProperty(value = "height", required = true) + @get:JsonProperty("height") val height: Long, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LiveStakeDistributionResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LiveStakeDistributionResult.kt index 23c7225..b02b81f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LiveStakeDistributionResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LiveStakeDistributionResult.kt @@ -1,10 +1,7 @@ package io.newm.kogmios.protocols.model.result import io.newm.kogmios.protocols.model.PoolDistribution -import io.newm.kogmios.protocols.model.serializers.LiveStakeDistributionResultSerializer -import kotlinx.serialization.Serializable -@Serializable(with = LiveStakeDistributionResultSerializer::class) class LiveStakeDistributionResult : LinkedHashMap(), OgmiosResult { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LongResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LongResult.kt index 86bca5d..3812c62 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/LongResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/LongResult.kt @@ -1,9 +1,10 @@ package io.newm.kogmios.protocols.model.result -import io.newm.kogmios.protocols.model.serializers.LongResultSerializer -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonValue -@Serializable(with = LongResultSerializer::class) -data class LongResult( - val value: Long -) : OgmiosResult +data class LongResult + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + constructor( + @get:JsonValue val value: Long, + ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/Metrics.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/Metrics.kt index 03cb4c3..4ebd43b 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/Metrics.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/Metrics.kt @@ -1,20 +1,24 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class Metrics( - @SerialName("activeConnections") + @param:JsonProperty(value = "activeConnections", required = true) + @get:JsonProperty("activeConnections") val activeConnections: Int, - @SerialName("runtimeStats") + @param:JsonProperty(value = "runtimeStats", required = true) + @get:JsonProperty("runtimeStats") val runtimeStats: RuntimeStats, - @SerialName("sessionDurations") + @param:JsonProperty(value = "sessionDurations", required = true) + @get:JsonProperty("sessionDurations") val sessionDurations: SessionDurations, - @SerialName("totalConnections") + @param:JsonProperty(value = "totalConnections", required = true) + @get:JsonProperty("totalConnections") val totalConnections: Long, - @SerialName("totalMessages") + @param:JsonProperty(value = "totalMessages", required = true) + @get:JsonProperty("totalMessages") val totalMessages: Long, - @SerialName("totalUnrouted") + @param:JsonProperty(value = "totalUnrouted", required = true) + @get:JsonProperty("totalUnrouted") val totalUnrouted: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/NextBlockResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/NextBlockResult.kt index 0d25f09..a93ec37 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/NextBlockResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/NextBlockResult.kt @@ -1,8 +1,5 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonTypeInfo -import kotlinx.serialization.Serializable -import kotlinx.serialization.json.JsonClassDiscriminator - -@Serializable -@JsonClassDiscriminator("direction") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "direction") sealed interface NextBlockResult : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProjectedRewardsResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProjectedRewardsResult.kt index 2306b33..32f4bbd 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProjectedRewardsResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProjectedRewardsResult.kt @@ -1,10 +1,7 @@ package io.newm.kogmios.protocols.model.result import io.newm.kogmios.protocols.model.NonMyopicMemberRewardsResult -import io.newm.kogmios.protocols.model.serializers.ProjectedRewardsResultSerializer -import kotlinx.serialization.Serializable -@Serializable(with = ProjectedRewardsResultSerializer::class) class ProjectedRewardsResult : LinkedHashMap(), OgmiosResult { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProposedProtocolParametersResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProposedProtocolParametersResult.kt deleted file mode 100644 index 0e7ba8c..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProposedProtocolParametersResult.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.newm.kogmios.protocols.model.result - -import io.newm.kogmios.protocols.model.ProposedProtocolParameters -import io.newm.kogmios.protocols.model.serializers.ProposedProtocolParametersResultSerializer -import kotlinx.serialization.Serializable - -@Serializable(with = ProposedProtocolParametersResultSerializer::class) -class ProposedProtocolParametersResult : - ArrayList(), - OgmiosResult { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is ProposedProtocolParametersResult) return false - if (!super.equals(other)) return false - return true - } - - override fun hashCode(): Int = super.hashCode() -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProtocolParametersResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProtocolParametersResult.kt index 402dd2d..b1e98b0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProtocolParametersResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ProtocolParametersResult.kt @@ -1,5 +1,7 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.Ada import io.newm.kogmios.protocols.model.BytesSize import io.newm.kogmios.protocols.model.ExecutionPrices @@ -7,76 +9,81 @@ import io.newm.kogmios.protocols.model.ExecutionUnits import io.newm.kogmios.protocols.model.MinFeeReferenceScripts import io.newm.kogmios.protocols.model.PlutusCostModels import java.math.BigInteger -import kotlinx.serialization.Contextual -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable + import org.apache.commons.numbers.fraction.BigFraction -@Serializable data class ProtocolParametersResult( - @Contextual - @SerialName("minFeeCoefficient") + @param:JsonProperty(value = "minFeeCoefficient", required = true) + @get:JsonProperty("minFeeCoefficient") val minFeeCoefficient: BigInteger, - @SerialName("minFeeConstant") + @param:JsonProperty(value = "minFeeConstant", required = true) + @get:JsonProperty("minFeeConstant") val minFeeConstant: Ada, - @SerialName("minFeeReferenceScripts") val minFeeReferenceScripts: MinFeeReferenceScripts? = null, - @Contextual - @SerialName("minUtxoDepositCoefficient") + @param:JsonProperty(value = "minUtxoDepositCoefficient", required = true) + @get:JsonProperty("minUtxoDepositCoefficient") val minUtxoDepositCoefficient: BigInteger, - @Contextual - @SerialName("minUtxoDepositConstant") + @param:JsonProperty(value = "minUtxoDepositConstant", required = true) + @get:JsonProperty("minUtxoDepositConstant") val minUtxoDepositConstant: Ada, - @SerialName("maxBlockBodySize") + @param:JsonProperty(value = "maxBlockBodySize", required = true) + @get:JsonProperty("maxBlockBodySize") val maxBlockBodySize: BytesSize, - @SerialName("maxBlockHeaderSize") + @param:JsonProperty(value = "maxBlockHeaderSize", required = true) + @get:JsonProperty("maxBlockHeaderSize") val maxBlockHeaderSize: BytesSize, - @SerialName("maxTransactionSize") + @param:JsonProperty(value = "maxTransactionSize", required = true) + @get:JsonProperty("maxTransactionSize") val maxTransactionSize: BytesSize, - @SerialName("maxReferenceScriptsSize") val maxReferenceScriptsSize: BytesSize? = null, - @SerialName("maxValueSize") + @param:JsonProperty(value = "maxValueSize", required = true) + @get:JsonProperty("maxValueSize") val maxValueSize: BytesSize, - @SerialName("extraEntropy") val extraEntropy: String? = null, - @SerialName("stakeCredentialDeposit") + @param:JsonProperty(value = "stakeCredentialDeposit", required = true) + @get:JsonProperty("stakeCredentialDeposit") val stakeCredentialDeposit: Ada, - @SerialName("stakePoolDeposit") + @param:JsonProperty(value = "stakePoolDeposit", required = true) + @get:JsonProperty("stakePoolDeposit") val stakePoolDeposit: Ada, - @Contextual - @SerialName("stakePoolRetirementEpochBound") + @param:JsonProperty(value = "stakePoolRetirementEpochBound", required = true) + @get:JsonProperty("stakePoolRetirementEpochBound") val stakePoolRetirementEpochBound: BigInteger, - @Contextual - @SerialName("stakePoolPledgeInfluence") + @param:JsonProperty(value = "stakePoolPledgeInfluence", required = true) + @get:JsonProperty("stakePoolPledgeInfluence") val stakePoolPledgeInfluence: BigFraction, - @SerialName("minStakePoolCost") + @param:JsonProperty(value = "minStakePoolCost", required = true) + @get:JsonProperty("minStakePoolCost") val minStakePoolCost: Ada, - @Contextual - @SerialName("desiredNumberOfStakePools") + @param:JsonProperty(value = "desiredNumberOfStakePools", required = true) + @get:JsonProperty("desiredNumberOfStakePools") val desiredNumberOfStakePools: BigInteger, - @Contextual - @SerialName("federatedBlockProductionRatio") val federatedBlockProductionRatio: BigFraction? = null, - @SerialName("monetaryExpansion") - @Contextual + @param:JsonProperty(value = "monetaryExpansion", required = true) + @get:JsonProperty("monetaryExpansion") val monetaryExpansion: BigFraction, - @SerialName("treasuryExpansion") - @Contextual + @param:JsonProperty(value = "treasuryExpansion", required = true) + @get:JsonProperty("treasuryExpansion") val treasuryExpansion: BigFraction, - @Contextual - @SerialName("collateralPercentage") + @param:JsonProperty(value = "collateralPercentage", required = true) + @get:JsonProperty("collateralPercentage") val collateralPercentage: BigInteger, - @Contextual - @SerialName("maxCollateralInputs") + @param:JsonProperty(value = "maxCollateralInputs", required = true) + @get:JsonProperty("maxCollateralInputs") val maxCollateralInputs: BigInteger, - @SerialName("plutusCostModels") + @param:JsonProperty(value = "plutusCostModels", required = true) + @get:JsonProperty("plutusCostModels") val plutusCostModels: PlutusCostModels, - @SerialName("scriptExecutionPrices") + @param:JsonProperty(value = "scriptExecutionPrices", required = true) + @get:JsonProperty("scriptExecutionPrices") val scriptExecutionPrices: ExecutionPrices, - @SerialName("maxExecutionUnitsPerTransaction") + @param:JsonProperty(value = "maxExecutionUnitsPerTransaction", required = true) + @get:JsonProperty("maxExecutionUnitsPerTransaction") val maxExecutionUnitsPerTransaction: ExecutionUnits, - @SerialName("maxExecutionUnitsPerBlock") + @param:JsonProperty(value = "maxExecutionUnitsPerBlock", required = true) + @get:JsonProperty("maxExecutionUnitsPerBlock") val maxExecutionUnitsPerBlock: ExecutionUnits, - @SerialName("version") + @param:JsonProperty(value = "version", required = true) + @get:JsonProperty("version") val version: io.newm.kogmios.protocols.model.Version, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseMempoolResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseMempoolResult.kt index 1b70384..56e5251 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseMempoolResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseMempoolResult.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ReleaseMempoolResult( - @SerialName("released") + @param:JsonProperty(value = "released", required = true) + @get:JsonProperty("released") val released: String, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseResult.kt index 56fe395..2765e18 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/ReleaseResult.kt @@ -1,10 +1,9 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class ReleaseResult( - @SerialName("released") + @param:JsonProperty(value = "released", required = true) + @get:JsonProperty("released") val released: String, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RewardAccountSummariesResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RewardAccountSummariesResult.kt index 19f6f37..3acf909 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RewardAccountSummariesResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RewardAccountSummariesResult.kt @@ -1,12 +1,9 @@ package io.newm.kogmios.protocols.model.result import io.newm.kogmios.protocols.model.RewardAccountSummary -import io.newm.kogmios.protocols.model.serializers.RewardAccountSummariesResultSerializer -import kotlinx.serialization.Serializable -@Serializable(with = RewardAccountSummariesResultSerializer::class) class RewardAccountSummariesResult : - LinkedHashMap(), + ArrayList(), OgmiosResult { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollBackward.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollBackward.kt index 1c1c579..1d5a83f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollBackward.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollBackward.kt @@ -1,18 +1,22 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.PointDetailOrOrigin import io.newm.kogmios.protocols.model.Tip -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The blockchain has been rolled back to the specified point. */ -@Serializable -@SerialName("backward") + +@JsonTypeName("backward") data class RollBackward( - @SerialName("point") + @param:JsonProperty(value = "point", required = true) + @get:JsonProperty("point") val point: PointDetailOrOrigin, - @SerialName("tip") + @param:JsonProperty(value = "tip", required = true) + @get:JsonProperty("tip") val tip: Tip ) : NextBlockResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollForward.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollForward.kt index ef34837..0a0d796 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollForward.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RollForward.kt @@ -1,18 +1,22 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.model.Block import io.newm.kogmios.protocols.model.Tip -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable /** * The next block has been received. */ -@Serializable -@SerialName("forward") + +@JsonTypeName("forward") data class RollForward( - @SerialName("tip") + @param:JsonProperty(value = "tip", required = true) + @get:JsonProperty("tip") val tip: Tip, - @SerialName("block") + @param:JsonProperty(value = "block", required = true) + @get:JsonProperty("block") val block: Block ) : NextBlockResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RuntimeStats.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RuntimeStats.kt index be19df9..c7c6593 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/RuntimeStats.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/RuntimeStats.kt @@ -1,16 +1,18 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class RuntimeStats( - @SerialName("cpuTime") + @param:JsonProperty(value = "cpuTime", required = true) + @get:JsonProperty("cpuTime") val cpuTime: Long, - @SerialName("currentHeapSize") + @param:JsonProperty(value = "currentHeapSize", required = true) + @get:JsonProperty("currentHeapSize") val currentHeapSize: Long, - @SerialName("gcCpuTime") + @param:JsonProperty(value = "gcCpuTime", required = true) + @get:JsonProperty("gcCpuTime") val gcCpuTime: Long, - @SerialName("maxHeapSize") + @param:JsonProperty(value = "maxHeapSize", required = true) + @get:JsonProperty("maxHeapSize") val maxHeapSize: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SessionDurations.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SessionDurations.kt index edb34da..7815612 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SessionDurations.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SessionDurations.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import com.fasterxml.jackson.annotation.JsonProperty -@Serializable data class SessionDurations( - @SerialName("max") + @param:JsonProperty(value = "max", required = true) + @get:JsonProperty("max") val max: Double, - @SerialName("mean") + @param:JsonProperty(value = "mean", required = true) + @get:JsonProperty("mean") val mean: Double, - @SerialName("min") + @param:JsonProperty(value = "min", required = true) + @get:JsonProperty("min") val min: Double, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SizeOfMempoolResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SizeOfMempoolResult.kt index e6da68a..601e4f6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SizeOfMempoolResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SizeOfMempoolResult.kt @@ -1,21 +1,23 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.BytesSize -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class SizeOfMempoolResult( - @SerialName("maxCapacity") + @param:JsonProperty(value = "maxCapacity", required = true) + @get:JsonProperty("maxCapacity") val maxCapacity: BytesSize, - @SerialName("currentSize") + @param:JsonProperty(value = "currentSize", required = true) + @get:JsonProperty("currentSize") val currentSize: BytesSize, - @SerialName("transactions") + @param:JsonProperty(value = "transactions", required = true) + @get:JsonProperty("transactions") val transactions: TransactionCount, ) : OgmiosResult -@Serializable data class TransactionCount( - @SerialName("count") + @param:JsonProperty(value = "count", required = true) + @get:JsonProperty("count") val count: Long, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/StakePoolsResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/StakePoolsResult.kt index 1ff1c96..a605edb 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/StakePoolsResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/StakePoolsResult.kt @@ -1,10 +1,7 @@ package io.newm.kogmios.protocols.model.result import io.newm.kogmios.protocols.model.PoolResult -import io.newm.kogmios.protocols.model.serializers.StakePoolsResultSerializer -import kotlinx.serialization.Serializable -@Serializable(with = StakePoolsResultSerializer::class) class StakePoolsResult : LinkedHashMap(), OgmiosResult { diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/StringArrayOgmiosResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/StringArrayOgmiosResult.kt index 6610026..24e2506 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/StringArrayOgmiosResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/StringArrayOgmiosResult.kt @@ -1,8 +1,5 @@ package io.newm.kogmios.protocols.model.result -import kotlinx.serialization.Serializable - -@Serializable class StringArrayOgmiosResult( val value: List ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SubmitTxResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SubmitTxResult.kt index a7f2712..7b740a6 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/SubmitTxResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/SubmitTxResult.kt @@ -1,11 +1,11 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.Transaction -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class SubmitTxResult( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Transaction, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/TipResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/TipResult.kt index 6a679f7..ec70a1f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/TipResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/TipResult.kt @@ -1,14 +1,15 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.PointDetail -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable data class TipResult( - @SerialName("slot") + @param:JsonProperty(value = "slot", required = true) + @get:JsonProperty("slot") val slot: Long, - @SerialName("id") + @param:JsonProperty(value = "id", required = true) + @get:JsonProperty("id") val id: String, ) : OgmiosResult { fun toPointDetail(): PointDetail = PointDetail(slot, id) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/TxResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/TxResult.kt index beb5b59..a2e572f 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/TxResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/TxResult.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonTypeName + import io.newm.kogmios.protocols.messages.MsgNextTransaction import io.newm.kogmios.protocols.model.Tx -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable -@SerialName(MsgNextTransaction.METHOD_NAME) +@JsonTypeName(MsgNextTransaction.METHOD_NAME) data class TxResult( - @SerialName("transaction") val transaction: Tx? = null, ) : OgmiosResult diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/result/UtxoResult.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/result/UtxoResult.kt index dad2a19..9d18770 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/result/UtxoResult.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/result/UtxoResult.kt @@ -1,13 +1,11 @@ package io.newm.kogmios.protocols.model.result +import com.fasterxml.jackson.annotation.JsonProperty + import io.newm.kogmios.protocols.model.Script import io.newm.kogmios.protocols.model.Transaction import io.newm.kogmios.protocols.model.UtxoOutputValue -import io.newm.kogmios.protocols.model.serializers.UtxoResultSerializer -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable -@Serializable(with = UtxoResultSerializer::class) class UtxoResult : ArrayList(), OgmiosResult { @@ -21,20 +19,20 @@ class UtxoResult : override fun hashCode(): Int = super.hashCode() } -@Serializable data class UtxoResultItem( - @SerialName("transaction") + @param:JsonProperty(value = "transaction", required = true) + @get:JsonProperty("transaction") val transaction: Transaction, - @SerialName("index") + @param:JsonProperty(value = "index", required = true) + @get:JsonProperty("index") val index: Int, - @SerialName("address") + @param:JsonProperty(value = "address", required = true) + @get:JsonProperty("address") val address: String, - @SerialName("value") + @param:JsonProperty(value = "value", required = true) + @get:JsonProperty("value") val value: UtxoOutputValue, - @SerialName("datumHash") val datumHash: String? = null, - @SerialName("datum") val datum: String? = null, - @SerialName("script") val script: Script? = null, ) diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/AssetSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/AssetSerializer.kt deleted file mode 100644 index 53ba37d..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/AssetSerializer.kt +++ /dev/null @@ -1,43 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.Asset -import io.newm.kogmios.serializers.BigIntegerSerializer -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object AssetSerializer : KSerializer> { - private val delegateMapSerializer = MapSerializer(String.serializer(), BigIntegerSerializer) - - override fun deserialize(decoder: Decoder): List = - delegateMapSerializer.deserialize(decoder).map { (policyAndName, quantity) -> - val policyAndNameParts = policyAndName.split('.') - val policyId = policyAndNameParts[0] - val name = - if (policyAndNameParts.size == 2) { - policyAndNameParts[1] - } else { - "" - } - Asset( - policyId = policyId, - name = name, - quantity = quantity, - ) - } - - override val descriptor: SerialDescriptor = SerialDescriptor("List", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: List - ) { - delegateMapSerializer.serialize( - encoder, - value.associate { asset -> Pair("${asset.policyId}.${asset.name}", asset.quantity) }, - ) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/Blake2bDigestCredentialSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/Blake2bDigestCredentialSerializer.kt deleted file mode 100644 index 96d951f..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/Blake2bDigestCredentialSerializer.kt +++ /dev/null @@ -1,27 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.Blake2bDigestCredential -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.jsonPrimitive - -object Blake2bDigestCredentialSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("Blake2bDigestCredential") - - override fun deserialize(decoder: Decoder): Blake2bDigestCredential { - require(decoder is JsonDecoder) - val element = decoder.decodeJsonElement() - return Blake2bDigestCredential(element.jsonPrimitive.content) - } - - override fun serialize( - encoder: Encoder, - value: Blake2bDigestCredential - ) { - encoder.encodeString(value.digest) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/BooleanResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/BooleanResultSerializer.kt deleted file mode 100644 index a79a8ab..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/BooleanResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.BooleanResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.boolean -import kotlinx.serialization.json.jsonPrimitive - -object BooleanResultSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("BooleanResult") - - override fun deserialize(decoder: Decoder): BooleanResult { - require(decoder is JsonDecoder) - val element = decoder.decodeJsonElement() - return BooleanResult(element.jsonPrimitive.boolean) - } - - override fun serialize( - encoder: Encoder, - value: BooleanResult - ) { - encoder.encodeBoolean(value.value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EraSummariesResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EraSummariesResultSerializer.kt deleted file mode 100644 index af14d60..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EraSummariesResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.EraSummary -import io.newm.kogmios.protocols.model.result.EraSummariesResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object EraSummariesResultSerializer : KSerializer { - private val delegateListSerializer = ListSerializer(EraSummary.serializer()) - - override fun deserialize(decoder: Decoder): EraSummariesResult = - EraSummariesResult().also { - it.addAll(delegateListSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("EraSummariesResult", delegateListSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: EraSummariesResult - ) { - delegateListSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EvaluateTxResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EvaluateTxResultSerializer.kt deleted file mode 100644 index 57cdc00..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/EvaluateTxResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.EvaluateTx -import io.newm.kogmios.protocols.model.result.EvaluateTxResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object EvaluateTxResultSerializer : KSerializer { - private val delegateListSerializer = ListSerializer(EvaluateTx.serializer()) - - override fun deserialize(decoder: Decoder): EvaluateTxResult = - EvaluateTxResult().also { - it.addAll(delegateListSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("EvaluateTxResult", delegateListSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: EvaluateTxResult - ) { - delegateListSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/HasTransactionResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/HasTransactionResultSerializer.kt deleted file mode 100644 index 4829636..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/HasTransactionResultSerializer.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -object HasTransactionResultSerializer diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/InstantResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/InstantResultSerializer.kt deleted file mode 100644 index 8fc8ae6..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/InstantResultSerializer.kt +++ /dev/null @@ -1,26 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.InstantResult -import kotlin.time.Instant -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder - -object InstantResultSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("InstantResult") - - override fun deserialize(decoder: Decoder): InstantResult { - require(decoder is JsonDecoder) - return InstantResult(Instant.parse(decoder.decodeString())) - } - - override fun serialize( - encoder: Encoder, - value: InstantResult - ) { - encoder.encodeString(value.value.toString()) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LiveStakeDistributionResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LiveStakeDistributionResultSerializer.kt deleted file mode 100644 index 045da5f..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LiveStakeDistributionResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.PoolDistribution -import io.newm.kogmios.protocols.model.result.LiveStakeDistributionResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object LiveStakeDistributionResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), PoolDistribution.serializer()) - - override fun deserialize(decoder: Decoder): LiveStakeDistributionResult = - LiveStakeDistributionResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("LiveStakeDistributionResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: LiveStakeDistributionResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LongResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LongResultSerializer.kt deleted file mode 100644 index dd14b7b..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/LongResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.LongResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.jsonPrimitive -import kotlinx.serialization.json.long - -object LongResultSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("LongResult") - - override fun deserialize(decoder: Decoder): LongResult { - require(decoder is JsonDecoder) - val element = decoder.decodeJsonElement() - return LongResult(element.jsonPrimitive.long) - } - - override fun serialize( - encoder: Encoder, - value: LongResult - ) { - encoder.encodeLong(value.value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/MetadataValueSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/MetadataValueSerializer.kt new file mode 100644 index 0000000..5547039 --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/MetadataValueSerializer.kt @@ -0,0 +1,95 @@ +package io.newm.kogmios.protocols.model.serializers + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import io.newm.kogmios.protocols.model.MetadataBytes +import io.newm.kogmios.protocols.model.MetadataInteger +import io.newm.kogmios.protocols.model.MetadataList +import io.newm.kogmios.protocols.model.MetadataMap +import io.newm.kogmios.protocols.model.MetadataString +import io.newm.kogmios.protocols.model.MetadataValue + +internal class MetadataValueDeserializer : StdDeserializer(MetadataValue::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): MetadataValue { + val node = context.readTree(parser) + val target = + when { + node.has("map") -> MetadataMap::class.java + node.has("list") -> MetadataList::class.java + node.has("string") -> MetadataString::class.java + node.has("int") -> MetadataInteger::class.java + node.has("bytes") -> MetadataBytes::class.java + else -> return context.reportInputMismatch(MetadataValue::class.java, "unknown metadata value") + } + return context.readTreeAsValue(node, target) + } +} + +internal class MetadataMapDeserializer : StdDeserializer(MetadataMap::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): MetadataMap { + val node = context.readTree(parser) + val result = MetadataMap() + node.path("map").forEach { entry -> + val key = context.readTreeAsValue(entry.path("k"), MetadataValue::class.java) + val value = context.readTreeAsValue(entry.path("v"), MetadataValue::class.java) + result[key] = value + } + return result + } +} + +internal class MetadataListDeserializer : StdDeserializer(MetadataList::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): MetadataList { + val node = context.readTree(parser) + return MetadataList().apply { + node.path("list").forEach { add(context.readTreeAsValue(it, MetadataValue::class.java)) } + } + } +} + +internal class MetadataMapSerializer : JsonSerializer() { + override fun serialize( + value: MetadataMap, + generator: JsonGenerator, + serializers: SerializerProvider + ) { + generator.writeStartObject() + generator.writeArrayFieldStart("map") + value.forEach { (key, item) -> + generator.writeStartObject() + generator.writeObjectField("k", key) + generator.writeObjectField("v", item) + generator.writeEndObject() + } + generator.writeEndArray() + generator.writeEndObject() + } +} + +internal class MetadataListSerializer : JsonSerializer() { + override fun serialize( + value: MetadataList, + generator: JsonGenerator, + serializers: SerializerProvider + ) { + generator.writeStartObject() + generator.writeArrayFieldStart("list") + value.forEach(generator::writeObject) + generator.writeEndArray() + generator.writeEndObject() + } +} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/NonMyopicMemberRewardsResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/NonMyopicMemberRewardsResultSerializer.kt deleted file mode 100644 index 637ed5b..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/NonMyopicMemberRewardsResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.Ada -import io.newm.kogmios.protocols.model.NonMyopicMemberRewardsResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object NonMyopicMemberRewardsResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), Ada.serializer()) - - override fun deserialize(decoder: Decoder): NonMyopicMemberRewardsResult = - NonMyopicMemberRewardsResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("NonMyopicMemberRewardsResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: NonMyopicMemberRewardsResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/OriginStringSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/OriginStringSerializer.kt deleted file mode 100644 index e71c4df..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/OriginStringSerializer.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.OriginString -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder - -object OriginStringSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("Origin") - - override fun deserialize(decoder: Decoder): OriginString { - require(decoder is JsonDecoder) - return OriginString(decoder.decodeString()) - } - - override fun serialize( - encoder: Encoder, - value: OriginString - ) { - encoder.encodeString(value.origin) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginDeserializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginDeserializer.kt new file mode 100644 index 0000000..5af40c0 --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginDeserializer.kt @@ -0,0 +1,23 @@ +package io.newm.kogmios.protocols.model.serializers + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import io.newm.kogmios.protocols.model.OriginString +import io.newm.kogmios.protocols.model.PointDetail +import io.newm.kogmios.protocols.model.PointDetailOrOrigin + +internal class PointDetailOrOriginDeserializer : StdDeserializer(PointDetailOrOrigin::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): PointDetailOrOrigin { + val node = context.readTree(parser) + return if (node.isObject) { + context.readTreeAsValue(node, PointDetail::class.java) + } else { + context.readTreeAsValue(node, OriginString::class.java) + } + } +} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginSerializer.kt deleted file mode 100644 index 9906974..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointDetailOrOriginSerializer.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.PointDetail -import io.newm.kogmios.protocols.model.PointDetailOrOrigin -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.json.JsonContentPolymorphicSerializer -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.JsonObject - -object PointDetailOrOriginSerializer : - JsonContentPolymorphicSerializer(PointDetailOrOrigin::class) { - override fun selectDeserializer(element: JsonElement): DeserializationStrategy = - when (element) { - is JsonObject -> PointDetail.serializer() - else -> OriginStringSerializer - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginDeserializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginDeserializer.kt new file mode 100644 index 0000000..dca19b0 --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginDeserializer.kt @@ -0,0 +1,23 @@ +package io.newm.kogmios.protocols.model.serializers + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import io.newm.kogmios.protocols.model.Origin +import io.newm.kogmios.protocols.model.Point +import io.newm.kogmios.protocols.model.PointOrOrigin + +internal class PointOrOriginDeserializer : StdDeserializer(PointOrOrigin::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): PointOrOrigin { + val node = context.readTree(parser) + return if (node.path("point").isObject) { + context.readTreeAsValue(node, Point::class.java) + } else { + context.readTreeAsValue(node, Origin::class.java) + } + } +} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginSerializer.kt deleted file mode 100644 index 50d94de..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/PointOrOriginSerializer.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.Origin -import io.newm.kogmios.protocols.model.Point -import io.newm.kogmios.protocols.model.PointOrOrigin -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.json.JsonContentPolymorphicSerializer -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.jsonObject - -object PointOrOriginSerializer : JsonContentPolymorphicSerializer(PointOrOrigin::class) { - override fun selectDeserializer(element: JsonElement): DeserializationStrategy = - if (element.jsonObject["point"]?.jsonObject?.let { "slot" in it } == true) { - Point.serializer() - } else { - Origin.serializer() - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProjectedRewardsResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProjectedRewardsResultSerializer.kt deleted file mode 100644 index 044b0fd..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProjectedRewardsResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.NonMyopicMemberRewardsResult -import io.newm.kogmios.protocols.model.result.ProjectedRewardsResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object ProjectedRewardsResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), NonMyopicMemberRewardsResult.serializer()) - - override fun deserialize(decoder: Decoder): ProjectedRewardsResult = - ProjectedRewardsResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("ProjectedRewardsResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: ProjectedRewardsResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProposedProtocolParametersResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProposedProtocolParametersResultSerializer.kt deleted file mode 100644 index 9378887..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ProposedProtocolParametersResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.ProposedProtocolParameters -import io.newm.kogmios.protocols.model.result.ProposedProtocolParametersResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object ProposedProtocolParametersResultSerializer : KSerializer { - private val delegateListSerializer = ListSerializer(ProposedProtocolParameters.serializer()) - - override fun deserialize(decoder: Decoder): ProposedProtocolParametersResult = - ProposedProtocolParametersResult().also { - it.addAll(delegateListSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("ProposedProtocolParametersResult", delegateListSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: ProposedProtocolParametersResult - ) { - delegateListSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryDelegationsAndRewardsResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryDelegationsAndRewardsResultSerializer.kt deleted file mode 100644 index 85308b5..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryDelegationsAndRewardsResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.RewardAccountSummary -import io.newm.kogmios.protocols.model.result.RewardAccountSummariesResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object QueryDelegationsAndRewardsResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), RewardAccountSummary.serializer()) - - override fun deserialize(decoder: Decoder): RewardAccountSummariesResult = - RewardAccountSummariesResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("QueryDelegationsAndRewardsResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: RewardAccountSummariesResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryPoolParametersResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryPoolParametersResultSerializer.kt deleted file mode 100644 index 9bdc05f..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryPoolParametersResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.PoolResult -import io.newm.kogmios.protocols.model.result.StakePoolsResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object QueryPoolParametersResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), PoolResult.serializer()) - - override fun deserialize(decoder: Decoder): StakePoolsResult = - StakePoolsResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("QueryPoolParametersResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: StakePoolsResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QuerySerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QuerySerializer.kt deleted file mode 100644 index 85a86b1..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QuerySerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.Params -import io.newm.kogmios.protocols.model.ParamsChainTip -import io.newm.kogmios.protocols.model.ParamsPoolParameters -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.json.JsonContentPolymorphicSerializer -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.JsonPrimitive -import kotlinx.serialization.json.contentOrNull -import kotlinx.serialization.json.jsonObject - -object QuerySerializer : JsonContentPolymorphicSerializer(Params::class) { - override fun selectDeserializer(element: JsonElement): DeserializationStrategy = - when ((element.jsonObject["query"] as? JsonPrimitive)?.contentOrNull) { - "chainTip" -> { - ParamsChainTip.serializer() - } - - else -> { - if (element.jsonObject["query"]?.jsonObject?.let { "poolParameters" in it } == true) { - ParamsPoolParameters.serializer() - } else { - Params.serializer() - } - } - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryStakeDistributionResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryStakeDistributionResultSerializer.kt deleted file mode 100644 index 49ce5f7..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/QueryStakeDistributionResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.PoolDistribution -import io.newm.kogmios.protocols.model.result.LiveStakeDistributionResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object QueryStakeDistributionResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), PoolDistribution.serializer()) - - override fun deserialize(decoder: Decoder): LiveStakeDistributionResult = - LiveStakeDistributionResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("QueryStakeDistributionResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: LiveStakeDistributionResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/RewardAccountSummariesResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/RewardAccountSummariesResultSerializer.kt deleted file mode 100644 index 7dac625..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/RewardAccountSummariesResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.RewardAccountSummary -import io.newm.kogmios.protocols.model.result.RewardAccountSummariesResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object RewardAccountSummariesResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), RewardAccountSummary.serializer()) - - override fun deserialize(decoder: Decoder): RewardAccountSummariesResult = - RewardAccountSummariesResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("RewardAccountSummariesResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: RewardAccountSummariesResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ScriptExecutionFailureFaultDataSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ScriptExecutionFailureFaultDataSerializer.kt deleted file mode 100644 index 0d77efc..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/ScriptExecutionFailureFaultDataSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.fault.ScriptExecutionFailureFaultData -import io.newm.kogmios.protocols.model.fault.ScriptExecutionFailureFaultDataItem -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object ScriptExecutionFailureFaultDataSerializer : KSerializer { - private val delegateListSerializer = ListSerializer(ScriptExecutionFailureFaultDataItem.serializer()) - - override fun deserialize(decoder: Decoder): ScriptExecutionFailureFaultData = - ScriptExecutionFailureFaultData().also { - it.addAll(delegateListSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("EraSummariesResult", delegateListSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: ScriptExecutionFailureFaultData - ) { - delegateListSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StakePoolsResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StakePoolsResultSerializer.kt deleted file mode 100644 index 1f97bf7..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StakePoolsResultSerializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.PoolResult -import io.newm.kogmios.protocols.model.result.StakePoolsResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object StakePoolsResultSerializer : KSerializer { - private val delegateMapSerializer = MapSerializer(String.serializer(), PoolResult.serializer()) - - override fun deserialize(decoder: Decoder): StakePoolsResult = - StakePoolsResult().also { - it.putAll(delegateMapSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("StakePoolsResult", delegateMapSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: StakePoolsResult - ) { - delegateMapSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringArrayQueryResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringArrayQueryResultSerializer.kt deleted file mode 100644 index be18240..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringArrayQueryResultSerializer.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.StringArrayOgmiosResult -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.encoding.encodeCollection -import kotlinx.serialization.json.JsonDecoder -import kotlinx.serialization.json.jsonArray -import kotlinx.serialization.json.jsonPrimitive - -object StringArrayQueryResultSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("StringArrayQueryResult") - - override fun deserialize(decoder: Decoder): StringArrayOgmiosResult { - require(decoder is JsonDecoder) - val element = decoder.decodeJsonElement() - return StringArrayOgmiosResult(element.jsonArray.map { it.jsonPrimitive.content }) - } - - override fun serialize( - encoder: Encoder, - value: StringArrayOgmiosResult - ) { - encoder.encodeCollection(descriptor, value.value) { _, s -> - encoder.encodeString(s) - } - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringFaultDataSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringFaultDataSerializer.kt deleted file mode 100644 index a1c9d15..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/StringFaultDataSerializer.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.fault.StringFaultData -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder - -object StringFaultDataSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("StringFaultData") - - override fun deserialize(decoder: Decoder): StringFaultData { - require(decoder is JsonDecoder) - return StringFaultData(decoder.decodeString()) - } - - override fun serialize( - encoder: Encoder, - value: StringFaultData - ) { - encoder.encodeString(value.value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoOutputValueSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoOutputValueSerializer.kt index ab17cb9..82642e0 100644 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoOutputValueSerializer.kt +++ b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoOutputValueSerializer.kt @@ -1,51 +1,55 @@ package io.newm.kogmios.protocols.model.serializers +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import io.newm.kogmios.protocols.model.Ada import io.newm.kogmios.protocols.model.Asset import io.newm.kogmios.protocols.model.Lovelace import io.newm.kogmios.protocols.model.UtxoOutputValue -import io.newm.kogmios.serializers.BigIntegerSerializer -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.MapSerializer -import kotlinx.serialization.builtins.serializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonDecoder +import java.math.BigInteger -object UtxoOutputValueSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("UtxoOutputValue") - - private val delegateMapSerializer = - MapSerializer(String.serializer(), MapSerializer(String.serializer(), BigIntegerSerializer)) - - override fun deserialize(decoder: Decoder): UtxoOutputValue { - require(decoder is JsonDecoder) - val elements = delegateMapSerializer.deserialize(decoder) - val adaMap = elements["ada"] ?: throw IllegalStateException("ada value not found in UtxoOutputValue") - val lovelace = adaMap["lovelace"] ?: throw IllegalStateException("lovelace value not found in UtxoOutputValue") +internal class UtxoOutputValueDeserializer : StdDeserializer(UtxoOutputValue::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): UtxoOutputValue { + val node = context.readTree(parser) + val lovelaceNode = node.path("ada").path("lovelace") + if (lovelaceNode.isMissingNode) { + return context.reportInputMismatch(UtxoOutputValue::class.java, "ada.lovelace is required") + } val assets = - elements.entries.filterNot { it.key == "ada" }.flatMap { policy -> - val policyId = policy.key - policy.value.map { - Asset( - policyId = policyId, - name = it.key, - quantity = it.value - ) - } - } - return UtxoOutputValue( - ada = Ada(Lovelace(lovelace)), - assets = assets - ) + node + .fields() + .asSequence() + .filterNot { it.key == "ada" } + .flatMap { (policyId, quantities) -> + quantities.fields().asSequence().map { (name, quantity) -> + Asset(policyId, name, context.readTreeAsValue(quantity, BigInteger::class.java)) + } + }.toList() + return UtxoOutputValue(Ada(Lovelace(context.readTreeAsValue(lovelaceNode, BigInteger::class.java))), assets) } +} +internal class UtxoOutputValueSerializer : JsonSerializer() { override fun serialize( - encoder: Encoder, - value: UtxoOutputValue + value: UtxoOutputValue, + generator: JsonGenerator, + serializers: SerializerProvider ) { - // not implemented + generator.writeStartObject() + generator.writeObjectField("ada", value.ada.ada) + value.assets.orEmpty().groupBy(Asset::policyId).forEach { (policyId, assets) -> + generator.writeObjectFieldStart(policyId) + assets.forEach { generator.writeObjectField(it.name, it.quantity) } + generator.writeEndObject() + } + generator.writeEndObject() } } diff --git a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoResultSerializer.kt b/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoResultSerializer.kt deleted file mode 100644 index 7c84b71..0000000 --- a/src/main/kotlin/io/newm/kogmios/protocols/model/serializers/UtxoResultSerializer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package io.newm.kogmios.protocols.model.serializers - -import io.newm.kogmios.protocols.model.result.UtxoResult -import io.newm.kogmios.protocols.model.result.UtxoResultItem -import kotlinx.serialization.KSerializer -import kotlinx.serialization.builtins.ListSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -object UtxoResultSerializer : KSerializer { - private val delegateListSerializer = ListSerializer(UtxoResultItem.serializer()) - - override fun deserialize(decoder: Decoder): UtxoResult = - UtxoResult().also { - it.addAll(delegateListSerializer.deserialize(decoder)) - } - - override val descriptor: SerialDescriptor = - SerialDescriptor("UtxoResult", delegateListSerializer.descriptor) - - override fun serialize( - encoder: Encoder, - value: UtxoResult - ) { - delegateListSerializer.serialize(encoder, value) - } -} diff --git a/src/main/kotlin/io/newm/kogmios/serializers/BigFractionSerializer.kt b/src/main/kotlin/io/newm/kogmios/serializers/BigFractionSerializer.kt index ff2da79..7cb32e1 100644 --- a/src/main/kotlin/io/newm/kogmios/serializers/BigFractionSerializer.kt +++ b/src/main/kotlin/io/newm/kogmios/serializers/BigFractionSerializer.kt @@ -1,38 +1,44 @@ package io.newm.kogmios.serializers -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import org.apache.commons.numbers.fraction.BigFraction +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import java.math.BigDecimal +import java.math.BigInteger +import org.apache.commons.numbers.fraction.BigFraction -object BigFractionSerializer : KSerializer { - override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("io.newm.kogmios.serializers.BigFractionSerializer", PrimitiveKind.STRING) - +internal object BigFractionSerializer : JsonSerializer() { override fun serialize( - encoder: Encoder, - value: BigFraction + value: BigFraction, + generator: JsonGenerator, + serializers: SerializerProvider ) { - val rationalString = value.toString().replace(" ", "") - encoder.encodeString(rationalString) + generator.writeString(value.toString().replace(" ", "")) } +} - override fun deserialize(decoder: Decoder): BigFraction { - val decodedString = decoder.decodeString() - return if ('/' in decodedString) { - // decode rational like "3/4" - BigFraction.parse(decodedString) - } else { - // decode decimal like "0.75" - val bigDecimal = BigDecimal(decodedString) - val scale = bigDecimal.scale() - val denominator = BigDecimal.TEN.pow(scale).toBigIntegerExact() - val numerator = bigDecimal.movePointRight(scale).toBigIntegerExact() - BigFraction.of(numerator, denominator) +internal object BigFractionDeserializer : StdDeserializer(BigFraction::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): BigFraction { + val value = parser.valueAsString + return try { + if ('/' in value) { + BigFraction.parse(value) + } else { + val decimal = BigDecimal(value) + if (decimal.scale() >= 0) { + BigFraction.of(decimal.unscaledValue(), BigInteger.TEN.pow(decimal.scale())) + } else { + BigFraction.of(decimal.unscaledValue().multiply(BigInteger.TEN.pow(-decimal.scale())), BigInteger.ONE) + } + } + } catch (exception: RuntimeException) { + throw context.weirdStringException(value, BigFraction::class.java, exception.message) } } } diff --git a/src/main/kotlin/io/newm/kogmios/serializers/BigIntegerSerializer.kt b/src/main/kotlin/io/newm/kogmios/serializers/BigIntegerSerializer.kt deleted file mode 100644 index 48d87b8..0000000 --- a/src/main/kotlin/io/newm/kogmios/serializers/BigIntegerSerializer.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.newm.kogmios.serializers - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonEncoder -import kotlinx.serialization.json.JsonUnquotedLiteral -import java.math.BigInteger - -object BigIntegerSerializer : KSerializer { - override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.math.BigInteger", PrimitiveKind.LONG) - - override fun serialize( - encoder: Encoder, - value: BigInteger - ) { - val bdString = value.toString(10) - - if (encoder is JsonEncoder) { - encoder.encodeJsonElement(JsonUnquotedLiteral(bdString)) - } else { - encoder.encodeString(bdString) - } - } - - override fun deserialize(decoder: Decoder): BigInteger = BigInteger(decoder.decodeString(), 10) -} diff --git a/src/main/kotlin/io/newm/kogmios/serializers/DeepJsonNodeSerializer.kt b/src/main/kotlin/io/newm/kogmios/serializers/DeepJsonNodeSerializer.kt new file mode 100644 index 0000000..677f668 --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/serializers/DeepJsonNodeSerializer.kt @@ -0,0 +1,19 @@ +package io.newm.kogmios.serializers + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider + +internal class DeepJsonNodeSerializer : JsonSerializer() { + override fun serialize( + value: JsonNode, + generator: JsonGenerator, + serializers: SerializerProvider + ) { + value.traverse(generator.codec).use { parser -> + parser.nextToken() + generator.copyCurrentStructure(parser) + } + } +} diff --git a/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseDeserializer.kt b/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseDeserializer.kt new file mode 100644 index 0000000..2c2757d --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseDeserializer.kt @@ -0,0 +1,23 @@ +package io.newm.kogmios.serializers + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import io.newm.kogmios.protocols.messages.JsonRpcErrorResponse +import io.newm.kogmios.protocols.messages.JsonRpcResponse +import io.newm.kogmios.protocols.messages.JsonRpcSuccessResponse + +internal class JsonRpcResponseDeserializer : StdDeserializer(JsonRpcResponse::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): JsonRpcResponse { + val node = context.readTree(parser) + return if (node.has("error")) { + context.readTreeAsValue(node, JsonRpcErrorResponse::class.java) + } else { + context.readTreeAsValue(node, JsonRpcSuccessResponse::class.java) + } + } +} diff --git a/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseSerializer.kt b/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseSerializer.kt deleted file mode 100644 index fd34a3f..0000000 --- a/src/main/kotlin/io/newm/kogmios/serializers/JsonRpcResponseSerializer.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.newm.kogmios.serializers - -import io.newm.kogmios.protocols.messages.JsonRpcErrorResponse -import io.newm.kogmios.protocols.messages.JsonRpcResponse -import io.newm.kogmios.protocols.messages.JsonRpcSuccessResponse -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.json.JsonContentPolymorphicSerializer -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.jsonObject - -object JsonRpcResponseSerializer : JsonContentPolymorphicSerializer(JsonRpcResponse::class) { - override fun selectDeserializer(element: JsonElement): DeserializationStrategy = - if ("error" in element.jsonObject) { - JsonRpcErrorResponse.serializer() - } else { - JsonRpcSuccessResponse.serializer() - } -} diff --git a/src/main/kotlin/io/newm/kogmios/serializers/OgmiosJson.kt b/src/main/kotlin/io/newm/kogmios/serializers/OgmiosJson.kt new file mode 100644 index 0000000..e80ce45 --- /dev/null +++ b/src/main/kotlin/io/newm/kogmios/serializers/OgmiosJson.kt @@ -0,0 +1,109 @@ +package io.newm.kogmios.serializers + +import com.fasterxml.jackson.core.JsonFactory +import com.fasterxml.jackson.core.StreamReadConstraints +import com.fasterxml.jackson.core.StreamWriteConstraints +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import com.fasterxml.jackson.module.kotlin.KotlinFeature +import com.fasterxml.jackson.module.kotlin.KotlinModule +import io.newm.kogmios.protocols.messages.JsonRpcResponse +import io.newm.kogmios.protocols.model.MetadataList +import io.newm.kogmios.protocols.model.MetadataMap +import io.newm.kogmios.protocols.model.MetadataValue +import io.newm.kogmios.protocols.model.PointDetailOrOrigin +import io.newm.kogmios.protocols.model.PointOrOrigin +import io.newm.kogmios.protocols.model.UtxoOutputValue +import io.newm.kogmios.protocols.model.serializers.MetadataListDeserializer +import io.newm.kogmios.protocols.model.serializers.MetadataListSerializer +import io.newm.kogmios.protocols.model.serializers.MetadataMapDeserializer +import io.newm.kogmios.protocols.model.serializers.MetadataMapSerializer +import io.newm.kogmios.protocols.model.serializers.MetadataValueDeserializer +import io.newm.kogmios.protocols.model.serializers.PointDetailOrOriginDeserializer +import io.newm.kogmios.protocols.model.serializers.PointOrOriginDeserializer +import io.newm.kogmios.protocols.model.serializers.UtxoOutputValueDeserializer +import io.newm.kogmios.protocols.model.serializers.UtxoOutputValueSerializer +import io.newm.kogmios.protocols.model.result.LongResult +import kotlin.time.Instant +import org.apache.commons.numbers.fraction.BigFraction + +internal object OgmiosJson { + private val module = + SimpleModule().apply { + addSerializer(BigFraction::class.java, BigFractionSerializer) + addDeserializer(BigFraction::class.java, BigFractionDeserializer) + addSerializer(Instant::class.java, InstantSerializer) + addDeserializer(Instant::class.java, InstantDeserializer) + addDeserializer(LongResult::class.java, LongResultDeserializer) + addDeserializer(JsonRpcResponse::class.java, JsonRpcResponseDeserializer()) + addDeserializer(PointDetailOrOrigin::class.java, PointDetailOrOriginDeserializer()) + addDeserializer(PointOrOrigin::class.java, PointOrOriginDeserializer()) + addSerializer(UtxoOutputValue::class.java, UtxoOutputValueSerializer()) + addDeserializer(UtxoOutputValue::class.java, UtxoOutputValueDeserializer()) + addDeserializer(MetadataValue::class.java, MetadataValueDeserializer()) + addSerializer(MetadataMap::class.java, MetadataMapSerializer()) + addDeserializer(MetadataMap::class.java, MetadataMapDeserializer()) + addSerializer(MetadataList::class.java, MetadataListSerializer()) + addDeserializer(MetadataList::class.java, MetadataListDeserializer()) + } + + val mapper = + JsonMapper + .builder( + JsonFactory + .builder() + .streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(16_384).build()) + .streamWriteConstraints(StreamWriteConstraints.builder().maxNestingDepth(16_384).build()) + .build(), + ).addModule(module) + .addModule( + KotlinModule + .Builder() + .enable(KotlinFeature.StrictNullChecks) + .enable(KotlinFeature.SingletonSupport) + .enable(KotlinFeature.KotlinPropertyNameAsImplicitName) + .build(), + ).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) + .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS) + .disable(DeserializationFeature.ACCEPT_FLOAT_AS_INT) + .enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS) + .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) + .build() +} + +private object InstantSerializer : JsonSerializer() { + override fun serialize( + value: Instant, + generator: JsonGenerator, + serializers: SerializerProvider + ) { + generator.writeString(value.toString()) + } +} + +private object InstantDeserializer : StdDeserializer(Instant::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): Instant = + try { + Instant.parse(parser.valueAsString) + } catch (exception: IllegalArgumentException) { + throw context.weirdStringException(parser.valueAsString, Instant::class.java, exception.message) + } +} + +private object LongResultDeserializer : StdDeserializer(LongResult::class.java) { + override fun deserialize( + parser: JsonParser, + context: DeserializationContext + ): LongResult = LongResult(parser.longValue) +} diff --git a/src/test/kotlin/io/newm/kogmios/protocols/chainsync/ChainSyncTest.kt b/src/test/kotlin/io/newm/kogmios/protocols/chainsync/ChainSyncTest.kt index f99ec32..d1da35f 100644 --- a/src/test/kotlin/io/newm/kogmios/protocols/chainsync/ChainSyncTest.kt +++ b/src/test/kotlin/io/newm/kogmios/protocols/chainsync/ChainSyncTest.kt @@ -5,13 +5,12 @@ import ch.qos.logback.classic.Logger import com.google.common.truth.Truth.assertThat import io.newm.kogmios.Client.Companion.DEFAULT_REQUEST_TIMEOUT_MS import io.newm.kogmios.Client.Companion.INFINITE_REQUEST_TIMEOUT_MS -import io.newm.kogmios.ClientImpl import io.newm.kogmios.createChainSyncClient import io.newm.kogmios.exception.KogmiosException import io.newm.kogmios.protocols.model.BlockPraos import io.newm.kogmios.protocols.model.OriginString import io.newm.kogmios.protocols.model.PointDetail -import io.newm.kogmios.protocols.model.TransactionMetadata +import io.newm.kogmios.protocols.model.ScriptNative import io.newm.kogmios.protocols.model.fault.IntersectionNotFoundFault import io.newm.kogmios.protocols.model.result.IntersectionFoundResult import io.newm.kogmios.protocols.model.result.RollBackward @@ -412,6 +411,54 @@ class ChainSyncTest { Unit } + @Test + fun `test RequestNext crash reproduction`() = + runBlocking { + createChainSyncClient( + websocketHost = TEST_HOST, + websocketPort = TEST_PORT, + secure = TEST_SECURE, + ).use { client -> + val connectResult = client.connect() + assertThat(connectResult).isTrue() + assertThat(client.isConnected).isTrue() + + val response = + client.findIntersect( + listOf( + PointDetail( + slot = 133883282L, + id = "0581b5b8d6aba5ff6f54281855dbd8b9181c5c8fea066cef1d76bb013ef2ab14", + ), + ), + ) + assertThat(response.result).isInstanceOf(IntersectionFoundResult::class.java) + assertThat((response.result.intersection as PointDetail).slot).isEqualTo(133883282L) + + assertThat(client.nextBlock().result).isInstanceOf(RollBackward::class.java) + val rollForward = client.nextBlock().result as RollForward + val block = rollForward.block as BlockPraos + assertThat(block.slot).isEqualTo(133883340L) + val transaction = + block.transactions.single { + it.id == "f90dce5765108da976abdbb9fc618f9a6ffd9fa4d93b2f288eed1808545424c9" + } + val script = + transaction.scripts!! + .getValue("ff3efca65569f6b0b868a3d34abdb1ad8eccf745e0da71fa94fb4f18") as ScriptNative + var node = script.json + var nestedAllClauses = 0 + while (node.path("clause").textValue() == "all") { + node = node.path("from")[0] + nestedAllClauses++ + } + assertThat(nestedAllClauses).isEqualTo(5_383) + assertThat(node.path("clause").textValue()).isEqualTo("signature") + assertThat(node.path("from").textValue()) + .isEqualTo("ba386209c0f81f9570b6feb45cedc2649144440157677c720bfd314a") + } + } + @Disabled("Disabled by default since it requires continuous running to sync the chain.") @Test fun `test blockchain sync`() = @@ -490,8 +537,6 @@ class ChainSyncTest { percent, ), ) - // val blockJsonString = ClientImpl.json.encodeToString(rollForward.block) - // log.info("Block: $blockJsonString") lastLogged = now } } @@ -499,70 +544,4 @@ class ChainSyncTest { } } } - - @Test - fun `test metadata deserialize`() = - runBlocking { - val metadataJsonString = - """ - { - "hash": "9742d8fbd7c04941c51f87f27948d39ddf30f4507cd4e29eba0df13eaac8edc5", - "labels": - { - "674": - { - "json": { - "map": - [ - { - "k": - { - "string": "msg" - }, - "v": - { - "list": - [ - { - "string": "Minted some nice tokens for you there" - }, - { - "int": 42 - } - ] - } - }, - { - "k": - { - "bytes": "deadbeefcafebabe" - }, - "v": - { - "map": - [ - { - "k": - { - "string": "favorite_number" - }, - "v": - { - "int": 79223372036854775807 - } - } - ] - } - } - ] - } - } - }, - "scripts": - [] - } - """.trimIndent() - val txMetadata: TransactionMetadata = ClientImpl.json.decodeFromString(metadataJsonString) - println(txMetadata) - } } diff --git a/src/test/kotlin/io/newm/kogmios/protocols/statequery/StateQueryTest.kt b/src/test/kotlin/io/newm/kogmios/protocols/statequery/StateQueryTest.kt index 4fe250c..17f09d3 100644 --- a/src/test/kotlin/io/newm/kogmios/protocols/statequery/StateQueryTest.kt +++ b/src/test/kotlin/io/newm/kogmios/protocols/statequery/StateQueryTest.kt @@ -323,12 +323,9 @@ class StateQueryTest { val response = client.rewardAccountSummaries(listOf(stakeHash)) assertThat(response).isNotNull() assertThat(response.result).isInstanceOf(RewardAccountSummariesResult::class.java) - assertThat(response.result.size).isEqualTo(1) - assertThat(response.result[stakeHash]!!.delegate.id).isEqualTo("pool1lgd9u8nshsh60asqszepfaalt2c5c5w6fvc85xne9st3g3fwtvm") - assertThat( - response.result[stakeHash]!! - .rewards.ada.lovelace - ).isEqualTo(BigInteger.ZERO) + val summary = response.result.single { it.credential == stakeHash && it.from == "verificationKey" } + assertThat(summary.credential).isEqualTo(stakeHash) + assertThat(summary.from).isEqualTo("verificationKey") } } @@ -537,28 +534,6 @@ class StateQueryTest { } } - @Test - fun `test query proposedProtocolParameters`() = - runBlocking { - createStateQueryClient( - websocketHost = TEST_HOST, - websocketPort = TEST_PORT, - secure = TEST_SECURE, - ).use { client -> - val connectResult = client.connect() - assertThat(connectResult).isTrue() - assertThat(client.isConnected).isTrue() - - val response = client.proposedProtocolParameters() - assertThat(response).isNotNull() - assertThat( - response.result - ).isInstanceOf(io.newm.kogmios.protocols.model.result.ProposedProtocolParametersResult::class.java) - // FIXME: We don't currently have a way to test until they change a param on preprod. Then we'll - // have to implement the correct response object. - } - } - @Test fun `test query liveStakeDistribution`() = runBlocking { diff --git a/src/test/kotlin/io/newm/kogmios/serializers/OgmiosJsonTest.kt b/src/test/kotlin/io/newm/kogmios/serializers/OgmiosJsonTest.kt new file mode 100644 index 0000000..3cb87fa --- /dev/null +++ b/src/test/kotlin/io/newm/kogmios/serializers/OgmiosJsonTest.kt @@ -0,0 +1,455 @@ +package io.newm.kogmios.serializers + +import com.fasterxml.jackson.core.exc.StreamConstraintsException +import com.fasterxml.jackson.databind.JsonMappingException +import com.fasterxml.jackson.databind.JsonNode +import com.google.common.truth.Truth.assertThat +import io.newm.kogmios.protocols.messages.Cbor +import io.newm.kogmios.protocols.messages.JsonRpcErrorResponse +import io.newm.kogmios.protocols.messages.JsonRpcResponse +import io.newm.kogmios.protocols.messages.MsgAcquire +import io.newm.kogmios.protocols.messages.MsgFindIntersect +import io.newm.kogmios.protocols.messages.MsgNextBlockResponse +import io.newm.kogmios.protocols.messages.MsgNextTransaction +import io.newm.kogmios.protocols.messages.MsgQuery +import io.newm.kogmios.protocols.messages.MsgQueryBlockHeightResponse +import io.newm.kogmios.protocols.messages.MsgQueryProjectedRewardsResponse +import io.newm.kogmios.protocols.messages.MsgQueryUtxoResponse +import io.newm.kogmios.protocols.messages.MsgQueryRewardAccountSummariesResponse +import io.newm.kogmios.protocols.messages.MsgQueryStakePoolsResponse +import io.newm.kogmios.protocols.messages.MsgSubmitTx +import io.newm.kogmios.protocols.messages.SubmitOrEvalTx +import io.newm.kogmios.protocols.model.Asset +import io.newm.kogmios.protocols.model.Certificate +import io.newm.kogmios.protocols.model.DelegateRepresentative +import io.newm.kogmios.protocols.model.DelegateRepresentativeAbstain +import io.newm.kogmios.protocols.model.DelegateRepresentativeRegistered +import io.newm.kogmios.protocols.model.ExecutionPrices +import io.newm.kogmios.protocols.model.result.GenesisConfigResult +import io.newm.kogmios.protocols.model.GovernanceAction +import io.newm.kogmios.protocols.model.GovernanceVoter +import io.newm.kogmios.protocols.model.GovernanceVoterGenesisDelegate +import io.newm.kogmios.protocols.model.InformationGovernanceAction +import io.newm.kogmios.protocols.model.MetadataBytes +import io.newm.kogmios.protocols.model.MetadataInteger +import io.newm.kogmios.protocols.model.MetadataList +import io.newm.kogmios.protocols.model.MetadataMap +import io.newm.kogmios.protocols.model.MetadataString +import io.newm.kogmios.protocols.model.Origin +import io.newm.kogmios.protocols.model.ProtocolParametersUpdateGovernanceAction +import io.newm.kogmios.protocols.model.OriginString +import io.newm.kogmios.protocols.model.Script +import io.newm.kogmios.protocols.model.ScriptNative +import io.newm.kogmios.protocols.model.ScriptPlutusV1 +import io.newm.kogmios.protocols.model.ScriptPlutusV2 +import io.newm.kogmios.protocols.model.ScriptPlutusV3 +import io.newm.kogmios.protocols.model.ScriptPurpose +import io.newm.kogmios.protocols.model.ScriptPurposeSpend +import io.newm.kogmios.protocols.model.StakeDelegationCertificate +import io.newm.kogmios.protocols.model.TransactionMetadata +import io.newm.kogmios.protocols.model.TxShelleyBootstrap +import io.newm.kogmios.protocols.model.UtxoOutputValue +import io.newm.kogmios.protocols.model.Voter +import io.newm.kogmios.protocols.model.result.AlonzoGenesisConfigResult +import io.newm.kogmios.protocols.model.result.HealthResult +import io.newm.kogmios.protocols.model.result.InstantResult +import io.newm.kogmios.protocols.model.result.RollForward +import io.newm.kogmios.protocols.model.fault.Fault +import io.newm.kogmios.protocols.model.fault.InternalErrorFault +import io.newm.kogmios.protocols.model.fault.ScriptExecutionFailureFault +import java.math.BigInteger +import kotlin.time.Instant +import org.apache.commons.numbers.fraction.BigFraction +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +class OgmiosJsonTest { + private val mapper = OgmiosJson.mapper + + @Test + fun `deep native scripts survive response decoding logging and encoding`() { + val depth = 5_383 + val nativeScript = deepNativeScript(depth) + val json = + buildString { + append("""{"jsonrpc":"2.0","result":{"tip":{"slot":133883340,"id":"tip","height":5183974},"block":{"era":"conway","id":"block","ancestor":"parent","height":5183974,"slot":133883340,"size":{"bytes":1},"transactions":[{"id":"tx","spends":"inputs","inputs":[],"outputs":[{"address":"addr","value":{"ada":{"lovelace":0}},"script":{"language":"native","json":""") + append(nativeScript) + append("""}}],"fee":{"ada":{"lovelace":0}},"signatories":[],"scripts":{"script":{"language":"native","json":""") + append(nativeScript) + append("""}}}],"protocol":{"version":{"major":8,"minor":0}},"issuer":{"verificationKey":"vk","vrfVerificationKey":"vrf","operationalCertificate":{"count":1,"kes":{"period":1,"verificationKey":"kes"}},"leaderValue":{"output":"out","proof":"proof"}},"type":"praos"},"direction":"forward"},"method":"nextBlock","id":"id"}""") + } + + val response = mapper.readValue(json, JsonRpcResponse::class.java) as MsgNextBlockResponse + val result = response.result as RollForward + val transaction = result.block + .let { it as io.newm.kogmios.protocols.model.BlockPraos } + .transactions + .single() + val witness = transaction.scripts!!.getValue("script") as ScriptNative + val output = transaction.outputs.single().script as ScriptNative + + assertDeepSignature(witness.json, depth) + assertDeepSignature(output.json, depth) + response.toString() + + val roundTrip = mapper.readValue(mapper.writeValueAsString(response), JsonRpcResponse::class.java) as MsgNextBlockResponse + val roundTripScript = + ((roundTrip.result as RollForward).block as io.newm.kogmios.protocols.model.BlockPraos) + .transactions + .single() + .scripts!! + .getValue("script") as ScriptNative + assertDeepSignature(roundTripScript.json, depth) + } + + @Test + fun `parsing beyond configured depth fails without overflowing the stack`() { + val input = "[".repeat(16_385) + "0" + "]".repeat(16_385) + + val exception = assertThrows { mapper.readTree(input) } + + assertThat(exception).hasMessageThat().contains("16384") + } + + @Test + fun `requests preserve their JSON wire contracts`() { + val requests = + listOf( + MsgFindIntersect( + params = io.newm.kogmios.protocols.model + .FindIntersect(listOf(OriginString())), + id = "find" + ), + MsgAcquire(params = Origin(), id = "acquire"), + MsgQuery(method = MsgQuery.METHOD_QUERY_NETWORK_TIP, params = null, id = "query"), + MsgNextTransaction(id = "next"), + MsgSubmitTx(params = SubmitOrEvalTx(Cbor("deadbeef")), id = "submit"), + ).associateBy { it.id }.mapValues { mapper.valueToTree(it.value) } + + assertThat( + requests + .getValue("find") + .path("params") + .path("points")[0] + .textValue() + ).isEqualTo("origin") + assertThat( + requests + .getValue("acquire") + .path("params") + .path("point") + .textValue() + ).isEqualTo("origin") + assertThat(requests.getValue("query").has("params")).isTrue() + assertThat(requests.getValue("query").path("params").isNull).isTrue() + assertThat( + requests + .getValue("next") + .path("params") + .path("fields") + .textValue() + ).isEqualTo("all") + assertThat( + requests + .getValue("submit") + .path("params") + .path("transaction") + .path("cbor") + .textValue() + ).isEqualTo("deadbeef") + requests.values.forEach { + assertThat(it.has("type")).isFalse() + assertThat(it.has("completableDeferred")).isFalse() + assertThat(it.has("cause")).isFalse() + assertThat(it.path("jsonrpc").textValue()).isEqualTo("2.0") + } + } + + @Test + fun `responses and discriminated models dispatch by visible and virtual tags`() { + val success = + mapper.readValue( + """{"jsonrpc":"2.0","result":42,"id":"ok","method":"queryNetwork/blockHeight"}""", + JsonRpcResponse::class.java, + ) + assertThat(success).isInstanceOf(MsgQueryBlockHeightResponse::class.java) + assertThat((success as MsgQueryBlockHeightResponse).result.value).isEqualTo(42) + + val error = + mapper.readValue( + """{"jsonrpc":"2.0","result":42,"error":{"message":"bad","data":"raw","code":-1},"id":"error","method":"queryNetwork/blockHeight"}""", + JsonRpcResponse::class.java, + ) + assertThat(error).isInstanceOf(JsonRpcErrorResponse::class.java) + assertThat((error as JsonRpcErrorResponse).error).isInstanceOf(InternalErrorFault::class.java) + + val nestedFault = + mapper.readValue( + """{"message":"failed","data":[{"validator":{"index":0,"purpose":"spend"},"error":{"message":"inner","data":"raw","code":-1}}],"code":3010}""", + Fault::class.java, + ) + assertThat(nestedFault).isInstanceOf(ScriptExecutionFailureFault::class.java) + assertThat((nestedFault as ScriptExecutionFailureFault).data.single().error).isInstanceOf(InternalErrorFault::class.java) + + assertThrows { + mapper.readValue("""{"result":1,"method":"unknown","id":"x"}""", JsonRpcResponse::class.java) + } + assertThrows { + mapper.readValue("""{"type":"unknown"}""", io.newm.kogmios.protocols.model.Block::class.java) + } + + val voter = mapper.readValue("""{"id":"voter","role":"genesisDelegate"}""", GovernanceVoter::class.java) + assertThat(voter).isInstanceOf(GovernanceVoterGenesisDelegate::class.java) + assertThat((voter as GovernanceVoterGenesisDelegate).role).isEqualTo("genesisDelegate") + val voterJson = mapper.valueToTree(voter) + assertThat(voterJson.fieldNames().asSequence().count { it == "role" }).isEqualTo(1) + + val virtualVoter = mapper.readValue("""{"id":"voter","role":"stakePoolOperator"}""", Voter::class.java) + assertThat( + mapper + .valueToTree(virtualVoter) + .fieldNames() + .asSequence() + .count { it == "role" } + ).isEqualTo(1) + + val purpose = + mapper.readValue( + """{"outputReference":{"transaction":{"id":"tx"},"index":0},"purpose":"spend"}""", + ScriptPurpose::class.java, + ) + assertThat(purpose).isInstanceOf(ScriptPurposeSpend::class.java) + assertThat((purpose as ScriptPurposeSpend).purpose).isEqualTo("spend") + + val genesis = + mapper.readValue( + """{"updatableParameters":{"minUtxoDepositCoefficient":1,"collateralPercentage":2,"plutusCostModels":{},"maxCollateralInputs":3,"maxExecutionUnitsPerBlock":{"memory":4,"cpu":5},"maxExecutionUnitsPerTransaction":{"memory":6,"cpu":7},"maxValueSize":{"bytes":8},"scriptExecutionPrices":{"memory":"1/2","cpu":"0.25"}},"era":"alonzo"}""", + GenesisConfigResult::class.java, + ) + assertThat(genesis).isInstanceOf(AlonzoGenesisConfigResult::class.java) + assertThat((genesis as AlonzoGenesisConfigResult).era).isEqualTo("alonzo") + + assertThat(mapper.readValue("""{"type":"information"}""", GovernanceAction::class.java)) + .isSameInstanceAs(InformationGovernanceAction) + val protocolParametersUpdate = + mapper.readValue( + """{"type":"protocolParametersUpdate","parameters":{"minFeeCoefficient":44}}""", + GovernanceAction::class.java, + ) as ProtocolParametersUpdateGovernanceAction + assertThat(protocolParametersUpdate.parameters.minFeeCoefficient).isEqualTo(BigInteger.valueOf(44)) + assertThat(mapper.readValue("""{"from":"stake","credential":"cred","type":"stakeDelegation"}""", Certificate::class.java)) + .isInstanceOf(StakeDelegationCertificate::class.java) + assertThat(mapper.readValue("""{"type":"abstain"}""", DelegateRepresentative::class.java)) + .isSameInstanceAs(DelegateRepresentativeAbstain) + + val scripts = + listOf( + """{"language":"native","json":{"clause":"signature","from":"key"}}""" to ScriptNative::class.java, + """{"cbor":"01","language":"plutus:v1"}""" to ScriptPlutusV1::class.java, + """{"language":"plutus:v2","cbor":"02"}""" to ScriptPlutusV2::class.java, + """{"cbor":"03","language":"plutus:v3"}""" to ScriptPlutusV3::class.java, + ) + scripts.forEach { (json, type) -> assertThat(mapper.readValue(json, Script::class.java)).isInstanceOf(type) } + } + + @Test + fun `Ogmios 6 14 reward summaries preserve identity delegation and exact values`() { + val credential = "3a8c70eba78fb47c5a017e38b04254b4e9545b4619cce2aa6b7143b3" + val huge = BigInteger("922337203685477580812345") + val response = + mapper.readValue( + """{"jsonrpc":"2.0","method":"queryLedgerState/rewardAccountSummaries","result":[{"from":"verificationKey","credential":"$credential","stakePool":{"id":"pool1lgd9u8nshsh60asqszepfaalt2c5c5w6fvc85xne9st3g3fwtvm"},"rewards":{"ada":{"lovelace":0}},"deposit":{"ada":{"lovelace":2000000}}},{"from":"script","credential":"$credential","delegateRepresentative":{"type":"registered","id":"11111111111111111111111111111111111111111111111111111111","from":"script"},"rewards":{"ada":{"lovelace":$huge}},"deposit":{"ada":{"lovelace":1}}},{"from":"verificationKey","credential":"both","stakePool":{"id":"pool-both"},"delegateRepresentative":{"type":"abstain"},"rewards":{"ada":{"lovelace":2}},"deposit":{"ada":{"lovelace":3}}},{"from":"verificationKey","credential":"no-confidence","delegateRepresentative":{"type":"noConfidence"},"rewards":{"ada":{"lovelace":4}},"deposit":{"ada":{"lovelace":5}}},{"from":"verificationKey","credential":"neither","rewards":{"ada":{"lovelace":6}},"deposit":{"ada":{"lovelace":7}}}],"id":"compat-reward"}""", + JsonRpcResponse::class.java, + ) as MsgQueryRewardAccountSummariesResponse + + assertThat(response.result.map { it.from to it.credential }) + .containsExactly( + "verificationKey" to credential, + "script" to credential, + "verificationKey" to "both", + "verificationKey" to "no-confidence", + "verificationKey" to "neither", + ).inOrder() + val captured = response.result[0] + assertThat(captured.stakePool!!.id).isEqualTo("pool1lgd9u8nshsh60asqszepfaalt2c5c5w6fvc85xne9st3g3fwtvm") + assertThat(captured.rewards.ada.lovelace).isEqualTo(BigInteger.ZERO) + assertThat(captured.deposit.ada.lovelace).isEqualTo(BigInteger.valueOf(2_000_000)) + assertThat(captured.delegateRepresentative).isNull() + val script = response.result[1] + assertThat(script.stakePool).isNull() + assertThat(script.rewards.ada.lovelace).isEqualTo(huge) + assertThat(script.delegateRepresentative).isInstanceOf(DelegateRepresentativeRegistered::class.java) + assertThat((script.delegateRepresentative as DelegateRepresentativeRegistered).from).isEqualTo("script") + assertThat(response.result[2].stakePool!!.id).isEqualTo("pool-both") + assertThat(response.result[2].delegateRepresentative).isSameInstanceAs(DelegateRepresentativeAbstain) + assertThat(response.result[3].delegateRepresentative) + .isSameInstanceAs(io.newm.kogmios.protocols.model.DelegateRepresentativeNoConfidence) + assertThat(response.result[4].stakePool).isNull() + assertThat(response.result[4].delegateRepresentative).isNull() + + val empty = + mapper.readValue( + """{"jsonrpc":"2.0","method":"queryLedgerState/rewardAccountSummaries","result":[],"id":"empty"}""", + JsonRpcResponse::class.java, + ) as MsgQueryRewardAccountSummariesResponse + assertThat(empty.result).isEmpty() + + listOf( + """{"from":"verificationKey","rewards":{"ada":{"lovelace":0}},"deposit":{"ada":{"lovelace":0}}}""", + """{"credential":"$credential","rewards":{"ada":{"lovelace":0}},"deposit":{"ada":{"lovelace":0}}}""", + ).forEach { entry -> + assertThrows { + mapper.readValue( + """{"jsonrpc":"2.0","method":"queryLedgerState/rewardAccountSummaries","result":[$entry],"id":"invalid"}""", + JsonRpcResponse::class.java, + ) + } + } + assertThrows { + mapper.readValue( + """{"type":"registered","id":"11111111111111111111111111111111111111111111111111111111"}""", + DelegateRepresentative::class.java, + ) + } + + val certificate = + mapper.readValue( + """{"type":"stakeDelegation","from":"verificationKey","credential":"$credential","delegateRepresentative":{"type":"registered","id":"11111111111111111111111111111111111111111111111111111111","from":"verificationKey"}}""", + Certificate::class.java, + ) as StakeDelegationCertificate + assertThat((certificate.delegateRepresentative as DelegateRepresentativeRegistered).from) + .isEqualTo("verificationKey") + } + + @Test + fun `Ogmios 6 14 sparse stake pool views retain ids and optional stake`() { + val response = + mapper.readValue( + """{"jsonrpc":"2.0","method":"queryLedgerState/stakePools","result":{"retired":{"id":"pool-retired","stake":{"ada":{"lovelace":123}}},"id-only":{"id":"pool-id-only"}},"id":"pools"}""", + JsonRpcResponse::class.java, + ) as MsgQueryStakePoolsResponse + + val retired = response.result.getValue("retired") + assertThat(retired.id).isEqualTo("pool-retired") + assertThat(retired.stake!!.ada.lovelace).isEqualTo(BigInteger.valueOf(123)) + assertThat(retired.vrfVerificationKeyHash).isNull() + assertThat(retired.pledge).isNull() + assertThat(retired.cost).isNull() + assertThat(retired.margin).isNull() + assertThat(retired.rewardAccount).isNull() + assertThat(retired.owners).isNull() + assertThat(retired.relays).isNull() + assertThat(retired.metadata).isNull() + val idOnly = response.result.getValue("id-only") + assertThat(idOnly.id).isEqualTo("pool-id-only") + assertThat(idOnly.stake).isNull() + + assertThrows { + mapper.readValue( + """{"jsonrpc":"2.0","method":"queryLedgerState/stakePools","result":{"invalid":{"stake":{"ada":{"lovelace":1}}}},"id":"invalid"}""", + JsonRpcResponse::class.java, + ) + } + } + + @Test + fun `transformed values scalars collections and required fields retain fidelity`() { + val projected = + mapper.readValue( + """{"result":{"stake1":{"pool1":{"ada":{"lovelace":7}}}},"method":"queryLedgerState/projectedRewards","id":"projected"}""", + JsonRpcResponse::class.java, + ) as MsgQueryProjectedRewardsResponse + assertThat( + projected.result + .getValue("stake1") + .getValue("pool1") + .ada.lovelace + ).isEqualTo(BigInteger.valueOf(7)) + + val huge = BigInteger("922337203685477580812345") + val utxo = + mapper.readValue( + """{"result":[{"transaction":{"id":"tx"},"index":0,"address":"addr","value":{"ada":{"lovelace":1},"policy":{"":$huge}},"script":{"language":"plutus:v1","cbor":"01"}}],"method":"queryLedgerState/utxo","id":"utxo"}""", + JsonRpcResponse::class.java, + ) as MsgQueryUtxoResponse + assertThat( + utxo.result + .single() + .value.assets!! + .single() + ).isEqualTo(Asset("policy", "", huge)) + assertThat(utxo.result.single().script).isInstanceOf(ScriptPlutusV1::class.java) + + val valueJson = mapper.writeValueAsString(utxo.result.single().value) + val valueTree = mapper.readTree(valueJson) + assertThat(valueTree.path("ada").path("lovelace").bigIntegerValue()).isEqualTo(BigInteger.ONE) + assertThat(valueTree.path("policy").path("").bigIntegerValue()).isEqualTo(huge) + assertThat(valueTree.has("assets")).isFalse() + val valueRoundTrip = mapper.readValue(valueJson, UtxoOutputValue::class.java) + assertThat(valueRoundTrip.assets!!.single().quantity).isEqualTo(huge) + + assertThat(mapper.readValue("\"3/4\"", BigFraction::class.java)).isEqualTo(BigFraction.of(3, 4)) + assertThat(mapper.readValue("\"0.75\"", BigFraction::class.java)).isEqualTo(BigFraction.of(3, 4)) + assertThat(mapper.readValue("\"1E+3\"", BigFraction::class.java)).isEqualTo(BigFraction.of(1000)) + val prices = mapper.readValue("""{"memory":"1/3","cpu":"0.2"}""", ExecutionPrices::class.java) + assertThat(prices.cpu).isEqualTo(BigFraction.of(1, 5)) + + val instant = mapper.readValue("\"2024-01-02T03:04:05Z\"", InstantResult::class.java) + assertThat(instant.value).isEqualTo(Instant.parse("2024-01-02T03:04:05Z")) + assertThat(mapper.writeValueAsString(instant)).isEqualTo("\"2024-01-02T03:04:05Z\"") + + val health = + mapper.readValue( + """{"connectionStatus":"connected","currentEpoch":1,"currentEra":"conway","lastKnownTip":{"height":2,"id":"tip","slot":3},"lastTipUpdate":"now","metrics":{"activeConnections":1,"runtimeStats":{"cpuTime":1,"currentHeapSize":2,"gcCpuTime":3,"maxHeapSize":4},"sessionDurations":{"max":1,"mean":1,"min":1},"totalConnections":1,"totalMessages":2,"totalUnrouted":0},"network":"preprod","networkSynchronization":1.0,"slotInEpoch":4,"startTime":"then","version":"1"}""", + HealthResult::class.java, + ) + assertThat(health.currentEra.name).isEqualTo("CONWAY") + assertThat(mapper.writeValueAsString(health)).contains("\"currentEra\":\"CONWAY\"") + + val nullable = mapper.readValue("""{"signature":"s","key":"k","chainCode":null,"addressAttributes":null}""", TxShelleyBootstrap::class.java) + assertThat(nullable.chainCode).isNull() + assertThrows { + mapper.readValue("""{"signature":"s","key":"k","addressAttributes":null}""", TxShelleyBootstrap::class.java) + } + } + + @Test + fun `metadata tagged values round trip with nested exact integers`() { + val json = + """{"hash":"hash","labels":{"674":{"json":{"map":[{"k":{"string":"msg"},"v":{"list":[{"string":"hello"},{"int":42}]}},{"k":{"bytes":"deadbeef"},"v":{"map":[{"k":{"string":"favorite_number"},"v":{"int":79223372036854775807}}]}}]}}},"scripts":[]}""" + val metadata = mapper.readValue(json, TransactionMetadata::class.java) + val root = metadata.labels.getValue("674").json as MetadataMap + val list = root[MetadataString("msg")] as MetadataList + assertThat((list[0] as MetadataString).string).isEqualTo("hello") + assertThat((list[1] as MetadataInteger).int).isEqualTo(BigInteger.valueOf(42)) + val nested = root[MetadataBytes("deadbeef")] as MetadataMap + assertThat((nested[MetadataString("favorite_number")] as MetadataInteger).int) + .isEqualTo(BigInteger("79223372036854775807")) + + val roundTrip = mapper.readValue(mapper.writeValueAsString(metadata), TransactionMetadata::class.java) + val roundTripRoot = roundTrip.labels.getValue("674").json as MetadataMap + assertThat(((roundTripRoot[MetadataBytes("deadbeef")] as MetadataMap)[MetadataString("favorite_number")] as MetadataInteger).int) + .isEqualTo(BigInteger("79223372036854775807")) + } + + private fun deepNativeScript(depth: Int): String = + buildString { + repeat(depth) { append("""{"clause":"all","from":[""") } + append("""{"clause":"signature","from":"ba386209c0f81f9570b6feb45cedc2649144440157677c720bfd314a"}""") + repeat(depth) { append("]}") } + } + + private fun assertDeepSignature( + root: JsonNode, + depth: Int + ) { + var node = root + repeat(depth) { + assertThat(node.path("clause").textValue()).isEqualTo("all") + node = node.path("from")[0] + } + assertThat(node.path("clause").textValue()).isEqualTo("signature") + assertThat(node.path("from").textValue()) + .isEqualTo("ba386209c0f81f9570b6feb45cedc2649144440157677c720bfd314a") + } +}