From d36dbf0dfbf45b64185e5b54aba0444d6e1ada88 Mon Sep 17 00:00:00 2001 From: Yurii Shynbuiev - IOHK Date: Tue, 24 Oct 2023 17:02:30 +0700 Subject: [PATCH] feat: migrate docker image of the agent to Java 21 (#758) Signed-off-by: Yurii Shynbuiev Signed-off-by: Anton Baliasnikov Signed-off-by: Pat Losoponkul Co-authored-by: Anton Baliasnikov Co-authored-by: Pat Losoponkul --- .github/docker/Dockerfile | 12 +++++++----- .github/workflows/build-test-docker.yml | 6 +++--- .github/workflows/unit-tests-common.yml | 2 +- build.sbt | 4 ++-- .../atala/connect/core/model/ConnectionRecord.scala | 9 ++++++++- .../repository/ConnectionRepositorySpecSuite.scala | 8 +++++--- .../event/notification/EventNotificationConfig.scala | 8 ++++++-- infrastructure/local/.env | 2 +- .../pollux/core/model/IssueCredentialRecord.scala | 8 ++++++++ .../atala/pollux/core/model/PresentationRecord.scala | 11 ++++++++++- .../repository/CredentialRepositorySpecSuite.scala | 2 +- .../repository/PresentationRepositorySpecSuite.scala | 2 +- .../pollux/sql/model/db/CredentialDefinition.scala | 4 ++++ .../atala/pollux/sql/model/db/CredentialSchema.scala | 5 +++++ .../pollux/sql/model/db/VerificationPolicy.scala | 4 +++- .../sql/CredentialDefinitionSqlIntegrationSpec.scala | 2 +- .../sql/CredentialSchemaSqlIntegrationSpec.scala | 2 +- .../sql/VerificationPolicySqlIntegrationSpec.scala | 2 +- .../atala/pollux/vc/jwt/JWTVerificationTest.scala | 6 +++++- .../io/iohk/atala/agent/walletapi/model/Entity.scala | 12 +++++++++--- .../io/iohk/atala/agent/walletapi/model/Wallet.scala | 9 +++++++-- project/build.properties | 2 +- 22 files changed, 90 insertions(+), 32 deletions(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index 0966ec3fb9..3b363f384a 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM openjdk:22-jdk-slim RUN apt-get update && \ apt-get install --no-install-recommends --yes \ @@ -8,10 +8,10 @@ RUN apt-get update && \ unzip=6.* \ zip=3.* \ jq=1.* \ - python3=3.10.* \ - python3-pip=22.* \ - python3-setuptools=59.6.* \ - python3-wheel=0.37.* \ + python3=3.11.* \ + python3-pip=23.* \ + python3-setuptools=66.* \ + python3-wheel=0.38.* \ gnupg=2.2.* \ default-jre=2:1.* \ build-essential=12.* && \ @@ -23,3 +23,5 @@ RUN apt-get update && \ apt-get install --no-install-recommends --yes \ sbt=1.4.* \ && rm -rf /var/lib/apt/lists/* + +CMD [ "/bin/bash" ] diff --git a/.github/workflows/build-test-docker.yml b/.github/workflows/build-test-docker.yml index 3d9432b2ab..3fe693f62d 100644 --- a/.github/workflows/build-test-docker.yml +++ b/.github/workflows/build-test-docker.yml @@ -13,7 +13,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: agent-ci-ubuntu-22-jdk-11 + IMAGE_NAME: ci-debian-jdk-22 jobs: build-and-push-image: @@ -55,6 +55,6 @@ jobs: context: .github/docker push: true tags: | - "ghcr.io/input-output-hk/${{ env.IMAGE_NAME }}:latest" - "ghcr.io/input-output-hk/${{ env.IMAGE_NAME }}:main" + "ghcr.io/hyperledger-labs/${{ env.IMAGE_NAME }}:latest" + "ghcr.io/hyperledger-labs/${{ env.IMAGE_NAME }}:main" labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/unit-tests-common.yml b/.github/workflows/unit-tests-common.yml index 8f02e5b22d..26c0ec134d 100644 --- a/.github/workflows/unit-tests-common.yml +++ b/.github/workflows/unit-tests-common.yml @@ -19,7 +19,7 @@ jobs: name: "Build and unit tests for ${{ inputs.component-name }}" runs-on: self-hosted container: - image: ghcr.io/input-output-hk/agent-ci-ubuntu-22-jdk-11:0.1.0 + image: ghcr.io/hyperledger-labs/ci-debian-jdk-22:0.1.0 volumes: - /nix:/nix credentials: diff --git a/build.sbt b/build.sbt index 11d6307fd0..0f04fe823d 100644 --- a/build.sbt +++ b/build.sbt @@ -201,7 +201,6 @@ lazy val D_Castor = new { D.circeCore, D.circeGeneric, D.circeParser, - prismCrypto, prismIdentity, scalaUri ) @@ -789,7 +788,8 @@ lazy val prismAgentServer = project Docker / dockerUsername := Some("input-output-hk"), Docker / dockerRepository := Some("ghcr.io"), dockerExposedPorts := Seq(8080, 8085, 8090), - dockerBaseImage := "openjdk:11", + // Official docker image for openjdk 21 with curl and bash + dockerBaseImage := "openjdk:21-jdk", buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion), buildInfoPackage := "io.iohk.atala.agent.server.buildinfo", Compile / packageDoc / publishArtifact := false diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala index b7d3f29036..b2c7964664 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala @@ -5,6 +5,7 @@ import io.iohk.atala.mercury.protocol.connection.{ConnectionRequest, ConnectionR import io.iohk.atala.mercury.protocol.invitation.v2.Invitation import java.time.Instant +import java.time.temporal.ChronoUnit import java.util.UUID /** @param id @@ -38,7 +39,13 @@ case class ConnectionRecord( metaRetries: Int, metaNextRetry: Option[Instant], metaLastFailure: Option[String] -) +) { + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): ConnectionRecord = copy( + createdAt = createdAt.truncatedTo(unit), + updatedAt = updatedAt.map(_.truncatedTo(unit)), + metaNextRetry = metaNextRetry.map(_.truncatedTo(unit)) + ) +} object ConnectionRecord { enum Role: diff --git a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala index 0049d0e990..0955c19297 100644 --- a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala +++ b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala @@ -8,9 +8,11 @@ import io.iohk.atala.mercury.protocol.connection.{ConnectionRequest, ConnectionR import io.iohk.atala.mercury.protocol.invitation.v2.Invitation import io.iohk.atala.shared.models.{WalletAccessContext, WalletId} import zio.test.* +import zio.test.Assertion.* import zio.{Cause, Exit, ZIO, ZLayer} import java.time.Instant +import java.time.temporal.ChronoUnit import java.util.UUID object ConnectionRepositorySpecSuite { @@ -19,7 +21,7 @@ object ConnectionRepositorySpecSuite { private def connectionRecord = ConnectionRecord( UUID.randomUUID, - Instant.now, + Instant.now.truncatedTo(ChronoUnit.MICROS), None, UUID.randomUUID().toString, None, @@ -34,9 +36,9 @@ object ConnectionRepositorySpecSuite { None, None, maxRetries, - Some(Instant.now), + Some(Instant.now.truncatedTo(ChronoUnit.MICROS)), None - ) + ).withTruncatedTimestamp() private def connectionRequest = ConnectionRequest( from = DidId("did:prism:aaa"), diff --git a/event-notification/src/main/scala/io/iohk/atala/event/notification/EventNotificationConfig.scala b/event-notification/src/main/scala/io/iohk/atala/event/notification/EventNotificationConfig.scala index b15bc647b5..39ce4108c9 100644 --- a/event-notification/src/main/scala/io/iohk/atala/event/notification/EventNotificationConfig.scala +++ b/event-notification/src/main/scala/io/iohk/atala/event/notification/EventNotificationConfig.scala @@ -7,6 +7,7 @@ import zio.* import java.net.URL import java.time.Instant import java.util.UUID +import java.time.temporal.ChronoUnit final case class EventNotificationConfig( id: UUID, @@ -14,7 +15,10 @@ final case class EventNotificationConfig( url: URL, customHeaders: Map[String, String], createdAt: Instant -) +) { + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): EventNotificationConfig = + copy(createdAt = createdAt.truncatedTo(unit)) +} object EventNotificationConfig { def apply(walletId: WalletId, url: URL, customHeaders: Map[String, String] = Map.empty): EventNotificationConfig = @@ -24,7 +28,7 @@ object EventNotificationConfig { url = url, customHeaders = customHeaders, createdAt = Instant.now - ) + ).withTruncatedTimestamp() def applyWallet(url: URL, customHeaders: Map[String, String]): URIO[WalletAccessContext, EventNotificationConfig] = ZIO.serviceWith[WalletAccessContext](ctx => apply(ctx.walletId, url, customHeaders)) diff --git a/infrastructure/local/.env b/infrastructure/local/.env index 00710460b2..a40f9fe1cb 100644 --- a/infrastructure/local/.env +++ b/infrastructure/local/.env @@ -1,3 +1,3 @@ -PRISM_AGENT_VERSION=1.16.0 +PRISM_AGENT_VERSION=1.17.0 PRISM_NODE_VERSION=2.2.1 VAULT_DEV_ROOT_TOKEN_ID=root diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala index b867373281..a232e39848 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala @@ -13,6 +13,7 @@ import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata import io.iohk.atala.pollux.core.model.IssueCredentialRecord.* import java.time.Instant +import java.time.temporal.ChronoUnit import java.util.UUID final case class IssueCredentialRecord( @@ -57,7 +58,14 @@ final case class IssueCredentialRecord( case CredentialFormat.AnonCreds => (IssueCredentialIssuedFormat.Anoncred, data) } + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): IssueCredentialRecord = + copy( + createdAt = createdAt.truncatedTo(unit), + updatedAt = updatedAt.map(_.truncatedTo(unit)), + metaNextRetry = metaNextRetry.map(_.truncatedTo(unit)), + ) } + final case class ValidIssuedCredentialRecord( id: DidCommID, issuedCredentialRaw: Option[String], diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/PresentationRecord.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/PresentationRecord.scala index eb2a93d15f..60f35f11ae 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/PresentationRecord.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/PresentationRecord.scala @@ -4,7 +4,9 @@ import io.iohk.atala.mercury.protocol.presentproof.ProposePresentation import io.iohk.atala.mercury.protocol.presentproof.RequestPresentation import io.iohk.atala.mercury.protocol.presentproof.Presentation import io.iohk.atala.mercury.model.DidId + import java.time.Instant +import java.time.temporal.ChronoUnit final case class PresentationRecord( id: DidCommID, @@ -24,7 +26,14 @@ final case class PresentationRecord( metaRetries: Int, metaNextRetry: Option[Instant], metaLastFailure: Option[String], -) +) { + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): PresentationRecord = + copy( + createdAt = createdAt.truncatedTo(unit), + updatedAt = updatedAt.map(_.truncatedTo(unit)), + metaNextRetry = metaNextRetry.map(_.truncatedTo(unit)), + ) +} object PresentationRecord { diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/CredentialRepositorySpecSuite.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/CredentialRepositorySpecSuite.scala index 21219a6366..b363446d36 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/CredentialRepositorySpecSuite.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/CredentialRepositorySpecSuite.scala @@ -39,7 +39,7 @@ object CredentialRepositorySpecSuite { metaRetries = maxRetries, metaNextRetry = Some(Instant.now()), metaLastFailure = None, - ) + ).withTruncatedTimestamp() private def requestCredential = RequestCredential( from = DidId("did:prism:aaa"), diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/PresentationRepositorySpecSuite.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/PresentationRepositorySpecSuite.scala index f81e509345..f1e0ed5b7d 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/PresentationRepositorySpecSuite.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/repository/PresentationRepositorySpecSuite.scala @@ -34,7 +34,7 @@ object PresentationRepositorySpecSuite { metaRetries = maxRetries, metaNextRetry = Some(Instant.now()), metaLastFailure = None, - ) + ).withTruncatedTimestamp() private def requestPresentation = RequestPresentation( from = DidId("did:prism:aaa"), diff --git a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialDefinition.scala b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialDefinition.scala index c9ef7e5ceb..224c0a81c9 100644 --- a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialDefinition.scala +++ b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialDefinition.scala @@ -8,6 +8,7 @@ import io.iohk.atala.pollux.core.model.schema.{CorrectnessProof, Definition} import io.iohk.atala.shared.models.WalletId import java.time.OffsetDateTime +import java.time.temporal.ChronoUnit import java.util.UUID case class CredentialDefinition( @@ -29,6 +30,9 @@ case class CredentialDefinition( walletId: WalletId ) { lazy val uniqueConstraintKey = author + name + version + + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): CredentialDefinition = + copy(authored = authored.truncatedTo(unit)) } object CredentialDefinition { diff --git a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialSchema.scala b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialSchema.scala index afe7066033..54e4dfde32 100644 --- a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialSchema.scala +++ b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/CredentialSchema.scala @@ -8,6 +8,7 @@ import io.iohk.atala.pollux.core.model.schema.Schema import io.iohk.atala.shared.models.WalletId import java.time.OffsetDateTime +import java.time.temporal.ChronoUnit import java.util.UUID case class CredentialSchema( @@ -24,6 +25,10 @@ case class CredentialSchema( walletId: WalletId ) { lazy val uniqueConstraintKey = author + name + version + + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): CredentialSchema = + copy(authored = authored.truncatedTo(unit)) + } object CredentialSchema { diff --git a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/VerificationPolicy.scala b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/VerificationPolicy.scala index b64bd515b1..fbc8120a2c 100644 --- a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/VerificationPolicy.scala +++ b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/model/db/VerificationPolicy.scala @@ -75,7 +75,9 @@ object VerificationPolicySql extends DoobieContext.Postgres(SnakeCase) { def getVerificationPolicyConstrains(fk_ids: Seq[UUID]) = run( quote( - query[VerificationPolicyConstraint].filter(vpc => liftQuery(fk_ids).contains(vpc.fk_id)) + query[VerificationPolicyConstraint] + .filter(vpc => liftQuery(fk_ids).contains(vpc.fk_id)) + .sortBy(_.index)(Ord.asc) ) ) diff --git a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialDefinitionSqlIntegrationSpec.scala b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialDefinitionSqlIntegrationSpec.scala index e959135ce6..8e4b55443f 100644 --- a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialDefinitionSqlIntegrationSpec.scala +++ b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialDefinitionSqlIntegrationSpec.scala @@ -110,7 +110,7 @@ object CredentialDefinitionSqlIntegrationSpec extends ZIOSpecDefault with Postgr signatureType = signatureType, supportRevocation = supportRevocation, walletId = walletId - ) + ).withTruncatedTimestamp() private val unique = mutable.Set.empty[String] val credentialDefinitionUnique = for { diff --git a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialSchemaSqlIntegrationSpec.scala b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialSchemaSqlIntegrationSpec.scala index 58f8b59100..02d8009d62 100644 --- a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialSchemaSqlIntegrationSpec.scala +++ b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/CredentialSchemaSqlIntegrationSpec.scala @@ -88,7 +88,7 @@ object CredentialSchemaSqlIntegrationSpec extends ZIOSpecDefault, PostgresTestCo authored = authored, tags = tags, walletId = walletId - ) + ).withTruncatedTimestamp() private val unique = mutable.Set.empty[String] val schemaUnique = for { diff --git a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/VerificationPolicySqlIntegrationSpec.scala b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/VerificationPolicySqlIntegrationSpec.scala index fb75706797..665815dc2e 100644 --- a/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/VerificationPolicySqlIntegrationSpec.scala +++ b/pollux/lib/sql-doobie/src/test/scala/io/iohk/atala/pollux/sql/VerificationPolicySqlIntegrationSpec.scala @@ -286,7 +286,7 @@ object VerificationPolicySqlIntegrationSpec extends ZIOSpecDefault, PostgresTest name <- name description <- description constraints <- Gen - .setOfBounded(min = 1, max = 10)(verificationPolicyConstraint) + .setOfBounded(min = 2, max = 10)(verificationPolicyConstraint) .map(_.toVector) } yield VerificationPolicy.make( name = name, diff --git a/pollux/lib/vc-jwt/src/test/scala/io/iohk/atala/pollux/vc/jwt/JWTVerificationTest.scala b/pollux/lib/vc-jwt/src/test/scala/io/iohk/atala/pollux/vc/jwt/JWTVerificationTest.scala index 99ae747e12..fe16e9ef64 100644 --- a/pollux/lib/vc-jwt/src/test/scala/io/iohk/atala/pollux/vc/jwt/JWTVerificationTest.scala +++ b/pollux/lib/vc-jwt/src/test/scala/io/iohk/atala/pollux/vc/jwt/JWTVerificationTest.scala @@ -1,7 +1,8 @@ package io.iohk.atala.pollux.vc.jwt -import com.nimbusds.jose.jwk.{Curve, ECKey} +import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton import com.nimbusds.jose.jwk.gen.ECKeyGenerator +import com.nimbusds.jose.jwk.{Curve, ECKey} import io.circe.* import io.circe.syntax.* import io.iohk.atala.castor.core.model.did.VerificationRelationship @@ -10,10 +11,13 @@ import zio.* import zio.test.* import zio.test.Assertion.* +import java.security.Security import java.time.Instant object JWTVerificationTest extends ZIOSpecDefault { + Security.insertProviderAt(BouncyCastleProviderSingleton.getInstance(), 2) + case class IssuerWithKey(issuer: Issuer, key: ECKey) private def createUser(did: DID): IssuerWithKey = { diff --git a/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Entity.scala b/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Entity.scala index 08f87d76eb..1f88ba1e65 100644 --- a/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Entity.scala +++ b/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Entity.scala @@ -4,6 +4,7 @@ import io.iohk.atala.shared.models.{WalletAccessContext, WalletId} import zio.{ULayer, ZLayer} import java.time.Instant +import java.time.temporal.ChronoUnit import java.util.UUID trait BaseEntity { @@ -12,6 +13,8 @@ trait BaseEntity { case class Entity(id: UUID, name: String, walletId: UUID, createdAt: Instant, updatedAt: Instant) extends BaseEntity { def withUpdatedAt(updatedAt: Instant = Instant.now()): Entity = copy(updatedAt = updatedAt) + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): Entity = + copy(createdAt = createdAt.truncatedTo(unit), updatedAt.truncatedTo(unit)) } object Entity { @@ -19,10 +22,13 @@ object Entity { val ZeroWalletId: UUID = WalletId.default.toUUID def apply(id: UUID, name: String, walletId: UUID): Entity = - Entity(id, name, walletId, Instant.now(), Instant.now()) + Entity(id, name, walletId, Instant.now(), Instant.now()).withTruncatedTimestamp() + def apply(name: String, walletId: UUID): Entity = - apply(UUID.randomUUID(), name, walletId, Instant.now(), Instant.now()) - def apply(name: String): Entity = Entity(UUID.randomUUID(), name, ZeroWalletId, Instant.now(), Instant.now()) + apply(UUID.randomUUID(), name, walletId, Instant.now(), Instant.now()).withTruncatedTimestamp() + + def apply(name: String): Entity = + Entity(UUID.randomUUID(), name, ZeroWalletId, Instant.now(), Instant.now()).withTruncatedTimestamp() val Default = Entity( diff --git a/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Wallet.scala b/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Wallet.scala index ed4dfd9af6..6e22772f13 100644 --- a/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Wallet.scala +++ b/prism-agent/service/wallet-api/src/main/scala/io/iohk/atala/agent/walletapi/model/Wallet.scala @@ -3,6 +3,7 @@ package io.iohk.atala.agent.walletapi.model import io.iohk.atala.shared.models.WalletId import java.time.Instant +import java.time.temporal.ChronoUnit final case class Wallet( id: WalletId, @@ -11,6 +12,10 @@ final case class Wallet( updatedAt: Instant ) { def withUpdatedAt(updatedAt: Instant): Wallet = copy(updatedAt = updatedAt) + def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): Wallet = copy( + createdAt = createdAt.truncatedTo(unit), + updatedAt = updatedAt.truncatedTo(unit) + ) } object Wallet { @@ -21,8 +26,8 @@ object Wallet { name = name, createdAt = now, updatedAt = now, - ) + ).withTruncatedTimestamp() } - def apply(name: String): Wallet = apply(name, WalletId.random) + def apply(name: String): Wallet = apply(name, WalletId.random).withTruncatedTimestamp() } diff --git a/project/build.properties b/project/build.properties index 8b9a0b0ab0..e8a1e246e8 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.0 +sbt.version=1.9.7