Skip to content

Commit 68ef984

Browse files
fix: STUD-481 - Fix newm-chain deserialization error
1 parent 3b3b3c6 commit 68ef984

12 files changed

Lines changed: 64 additions & 116 deletions

File tree

.github/workflows/ktlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
distribution: 'zulu'
1818
java-version: '21'
1919
- run: |
20-
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.5.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
20+
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.6.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
2121
- name: run ktlint
2222
run: |
2323
ktlint --reporter=checkstyle,output=build/ktlint-report.xml

build.gradle.kts

Lines changed: 33 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2-
import org.hibernate.build.publish.auth.maven.MavenRepoAuthPlugin
32
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
43

54
plugins {
@@ -8,18 +7,12 @@ plugins {
87
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT_PLUGIN
98
kotlin("jvm") version Versions.KOTLIN
109
kotlin("plugin.serialization") version Versions.KOTLIN
11-
id("maven-publish")
1210
id("signing")
13-
id("org.hibernate.build.maven-repo-auth") version Versions.MAVEN_REPO_AUTH_PLUGIN apply false
14-
}
15-
16-
if (!project.hasProperty("isGithubActions")) {
17-
// only use this plugin if we're running locally, not on github.
18-
apply<MavenRepoAuthPlugin>()
11+
id("com.vanniktech.maven.publish") version Versions.MAVEN_PUBLISH
1912
}
2013

2114
group = "io.newm"
22-
version = "2.5.0-SNAPSHOT"
15+
version = "2.5.1-SNAPSHOT"
2316

2417
java.sourceCompatibility = JavaVersion.VERSION_21
2518
java.targetCompatibility = JavaVersion.VERSION_21
@@ -44,7 +37,6 @@ dependencies {
4437
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES}")
4538
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.COROUTINES}")
4639
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLINX_SERIALIZATION}")
47-
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.KOTLINX_DATETIME}")
4840

4941
implementation("org.apache.commons:commons-numbers-fraction:${Versions.COMMONS_NUMBERS}")
5042

@@ -61,86 +53,42 @@ ktlint {
6153
version.set(Versions.KTLINT)
6254
}
6355

64-
tasks {
65-
66-
val sourcesJar by registering(Jar::class) {
67-
archiveClassifier.set("sources")
68-
dependsOn("classes")
69-
from(sourceSets["main"].allSource)
70-
}
71-
72-
val javadocJar by registering(Jar::class) {
73-
archiveClassifier.set("javadoc")
74-
dependsOn("javadoc")
75-
from("${layout.buildDirectory}/javadoc")
76-
}
77-
78-
artifacts {
79-
archives(javadocJar)
80-
archives(sourcesJar)
81-
}
82-
83-
assemble {
84-
dependsOn("sourcesJar", "javadocJar")
85-
}
56+
signing {
57+
useGpgCmd()
8658
}
8759

88-
publishing {
89-
repositories {
90-
maven {
91-
name = "ossrh"
92-
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
93-
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
94-
if (project.hasProperty("release")) {
95-
setUrl(releasesRepoUrl)
96-
} else {
97-
setUrl(snapshotsRepoUrl)
60+
mavenPublishing {
61+
publishToMavenCentral()
62+
signAllPublications()
63+
coordinates("io.newm", "kogmios", version.toString())
64+
pom {
65+
name.set("Kogmios")
66+
description.set("Kotlin Wrapper for Ogmios")
67+
url.set("https://github.com/projectNEWM/kogmios")
68+
licenses {
69+
license {
70+
name.set("Apache 2.0")
71+
url.set("https://github.com/projectNEWM/kogmios/blob/master/LICENSE")
72+
distribution.set("https://github.com/projectNEWM/kogmios/blob/master/LICENSE")
9873
}
9974
}
100-
}
101-
publications {
102-
create<MavenPublication>("mavenKotlin") {
103-
from(components["kotlin"])
104-
artifact(tasks["sourcesJar"])
105-
artifact(tasks["javadocJar"])
106-
107-
pom {
108-
groupId = "io.newm"
109-
artifactId = "kogmios"
110-
111-
name.set("Kogmios")
112-
description.set("Kotlin Wrapper for Ogmios")
113-
url.set("https://github.com/projectNEWM/kogmios")
114-
licenses {
115-
license {
116-
name.set("Apache 2.0")
117-
url.set("https://github.com/projectNEWM/kogmios/blob/master/LICENSE")
118-
}
119-
}
120-
developers {
121-
developer {
122-
id.set("AndrewWestberg")
123-
name.set("Andrew Westberg")
124-
email.set("andrewwestberg@gmail.com")
125-
organization.set("NEWM")
126-
organizationUrl.set("https://newm.io")
127-
}
128-
}
129-
scm {
130-
connection.set("scm:git:git://github.com/projectNEWM/kogmios.git")
131-
developerConnection.set("scm:git:ssh://github.com/projectNEWM/kogmios.git")
132-
url.set("https://github.com/projectNEWM/kogmios")
133-
}
75+
developers {
76+
developer {
77+
id.set("AndrewWestberg")
78+
name.set("Andrew Westberg")
79+
email.set("andrewwestberg@gmail.com")
80+
organization.set("NEWM")
81+
organizationUrl.set("https://newm.io")
13482
}
13583
}
84+
scm {
85+
connection.set("scm:git:git://github.com/projectNEWM/kogmios.git")
86+
developerConnection.set("scm:git:ssh://github.com/projectNEWM/kogmios.git")
87+
url.set("https://github.com/projectNEWM/kogmios")
88+
}
13689
}
13790
}
13891

139-
signing {
140-
useGpgCmd()
141-
sign(publishing.publications["mavenKotlin"])
142-
}
143-
14492
fun isNonStable(version: String): Boolean {
14593
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
14694
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
@@ -153,17 +101,17 @@ tasks.withType<Test> {
153101
}
154102

155103
tasks.withType<DependencyUpdatesTask> {
156-
// Example 1: reject all non stable versions
104+
// Example 1: reject all non stable versions
157105
rejectVersionIf {
158106
isNonStable(candidate.version)
159107
}
160108

161-
// Example 2: disallow release candidates as upgradable versions from stable versions
109+
// Example 2: disallow release candidates as upgradable versions from stable versions
162110
rejectVersionIf {
163111
isNonStable(candidate.version) && !isNonStable(currentVersion)
164112
}
165113

166-
// Example 3: using the full syntax
114+
// Example 3: using the full syntax
167115
resolutionStrategy {
168116
componentSelection {
169117
all {
@@ -193,6 +141,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
193141
"-opt-in=kotlin.RequiresOptIn",
194142
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
195143
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
144+
"-opt-in=kotlin.time.ExperimentalTime",
196145
)
197146
jvmTarget.set(JvmTarget.JVM_21)
198147
}

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ object Versions {
33
const val COMMONS_NUMBERS = "1.2"
44
const val COROUTINES = "1.10.2"
55
const val GOOGLE_TRUTH = "1.4.4"
6-
const val JUNIT = "5.12.1"
7-
const val JUNIT_PLATFORM = "1.12.1"
8-
const val KOTLIN = "2.1.20"
9-
const val KOTLINX_DATETIME = "0.6.2"
10-
const val KOTLINX_SERIALIZATION = "1.8.1"
11-
const val KTLINT = "1.5.0"
12-
const val KTLINT_PLUGIN = "12.2.0"
13-
const val KTOR = "3.1.2"
6+
const val JUNIT = "5.13.3"
7+
const val JUNIT_PLATFORM = "1.13.3"
8+
const val KOTLIN = "2.2.0"
9+
const val KOTLINX_SERIALIZATION = "1.9.0"
10+
const val KTLINT = "1.6.0"
11+
const val KTLINT_PLUGIN = "13.0.0"
12+
const val KTOR = "3.2.2"
1413
const val LOGBACK = "1.5.18"
15-
const val MAVEN_REPO_AUTH_PLUGIN = "3.0.4"
16-
const val MOCKK = "1.14.0"
14+
const val MOCKK = "1.14.4"
15+
const val MAVEN_PUBLISH = "0.34.0"
1716
const val VERSIONS_PLUGIN = "0.52.0"
1817
}

gradle/wrapper/gradle-wrapper.jar

122 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/io/newm/kogmios/protocols/model/GovernanceAction.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data class ProtocolParametersUpdateGovernanceAction(
1818
@SerialName("parameters")
1919
val parameters: ProposedProtocolParameters,
2020
@SerialName("guardrails")
21-
val guardrails: GuardrailsHash?,
21+
val guardrails: GuardrailsHash? = null,
2222
) : GovernanceAction
2323

2424
@Serializable
@@ -47,14 +47,14 @@ data class TreasuryWithdrawalsGovernanceAction(
4747
@SerialName("withdrawals")
4848
val withdrawals: Map<String, Ada>,
4949
@SerialName("guardrails")
50-
val guardrails: GuardrailsHash?,
50+
val guardrails: GuardrailsHash? = null,
5151
) : GovernanceAction
5252

5353
@Serializable
5454
@SerialName("constitutionalCommittee")
5555
data class ConstitutionalCommitteeGovernanceAction(
5656
@SerialName("ancestor")
57-
val ancestor: UtxoInput,
57+
val ancestor: UtxoInput? = null,
5858
@SerialName("members")
5959
val members: ConstitutionalCommitteeMembers,
6060
@SerialName("quorum")

src/main/kotlin/io/newm/kogmios/protocols/model/result/GenesisConfigResult.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import io.newm.kogmios.protocols.model.Milliseconds
1111
import io.newm.kogmios.protocols.model.ShelleyGenesisProtocolParameters
1212
import io.newm.kogmios.protocols.model.ShelleyGenesisStakePools
1313
import io.newm.kogmios.protocols.model.UpdatableParameters
14-
import kotlinx.datetime.Instant
1514
import kotlinx.serialization.Contextual
1615
import kotlinx.serialization.SerialName
1716
import kotlinx.serialization.Serializable
1817
import kotlinx.serialization.json.JsonClassDiscriminator
1918
import org.apache.commons.numbers.fraction.BigFraction
2019
import java.math.BigInteger
20+
import kotlin.time.Instant
2121

2222
@Serializable
2323
@JsonClassDiscriminator("era")

src/main/kotlin/io/newm/kogmios/protocols/model/result/InstantResult.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.newm.kogmios.protocols.model.result
22

33
import io.newm.kogmios.protocols.model.serializers.InstantResultSerializer
4-
import kotlinx.datetime.Instant
4+
import kotlin.time.Instant
55
import kotlinx.serialization.Serializable
66

77
@Serializable(with = InstantResultSerializer::class)

src/main/kotlin/io/newm/kogmios/protocols/model/serializers/InstantResultSerializer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.newm.kogmios.protocols.model.serializers
22

33
import io.newm.kogmios.protocols.model.result.InstantResult
4-
import kotlinx.datetime.serializers.InstantIso8601Serializer
4+
import kotlin.time.Instant
55
import kotlinx.serialization.KSerializer
66
import kotlinx.serialization.descriptors.SerialDescriptor
77
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
@@ -14,13 +14,13 @@ object InstantResultSerializer : KSerializer<InstantResult> {
1414

1515
override fun deserialize(decoder: Decoder): InstantResult {
1616
require(decoder is JsonDecoder)
17-
return InstantResult(InstantIso8601Serializer.deserialize(decoder))
17+
return InstantResult(Instant.parse(decoder.decodeString()))
1818
}
1919

2020
override fun serialize(
2121
encoder: Encoder,
2222
value: InstantResult
2323
) {
24-
InstantIso8601Serializer.serialize(encoder, value.value)
24+
encoder.encodeString(value.value.toString())
2525
}
2626
}

0 commit comments

Comments
 (0)