mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
parent
40e994bd46
commit
0654f9978c
@ -79,6 +79,7 @@ hj_scalacopts = lf_scalacopts + [
|
||||
"//libs-scala/ports",
|
||||
"//libs-scala/resources",
|
||||
"//libs-scala/scala-utils",
|
||||
"//libs-scala/struct-json",
|
||||
"@maven//:io_dropwizard_metrics_metrics_core",
|
||||
],
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ import scalaz.{-\/, NonEmptyList, \/-}
|
||||
import spray.json._
|
||||
import spray.json.derived.Discriminator
|
||||
import scalaz.syntax.tag._
|
||||
import com.daml.struct.json.StructJsonFormat
|
||||
|
||||
object JsonProtocol extends JsonProtocolLow {
|
||||
|
||||
|
@ -69,6 +69,7 @@ compile_deps = [
|
||||
"//libs-scala/scala-utils",
|
||||
"//libs-scala/timer-utils",
|
||||
"//libs-scala/nameof",
|
||||
"//libs-scala/struct-json",
|
||||
"@maven//:com_google_guava_guava",
|
||||
"@maven//:com_zaxxer_HikariCP",
|
||||
"@maven//:io_dropwizard_metrics_metrics_core",
|
||||
@ -97,7 +98,6 @@ scala_compile_deps = [
|
||||
"@maven//:org_playframework_anorm_anorm_tokenizer",
|
||||
"@maven//:org_scalaz_scalaz_core",
|
||||
"@maven//:io_spray_spray_json",
|
||||
"@maven//:com_thesamet_scalapb_scalapb_json4s",
|
||||
]
|
||||
|
||||
runtime_deps = [
|
||||
|
@ -11,9 +11,9 @@ import com.daml.lf.data.Time.Timestamp
|
||||
import com.daml.platform.apiserver.meteringreport.MeteringReport._
|
||||
import com.google.protobuf.struct.Struct
|
||||
import com.google.protobuf.timestamp.{Timestamp => ProtoTimestamp}
|
||||
import scalapb.json4s.JsonFormat
|
||||
import spray.json.enrichAny
|
||||
import HmacSha256.Key
|
||||
import com.daml.struct.json.StructJsonFormat
|
||||
|
||||
class MeteringReportGenerator(participantId: Ref.ParticipantId, key: Key) {
|
||||
|
||||
@ -57,7 +57,7 @@ class MeteringReportGenerator(participantId: Ref.ParticipantId, key: Key) {
|
||||
)
|
||||
|
||||
JcsSigner.sign(report, key).map { signedReport =>
|
||||
JsonFormat.parser.fromJsonString[Struct](signedReport.toJson.compactPrint)
|
||||
StructJsonFormat.read(signedReport.toJson)
|
||||
}
|
||||
}
|
||||
|
||||
|
34
libs-scala/struct-json/BUILD.bazel
Normal file
34
libs-scala/struct-json/BUILD.bazel
Normal file
@ -0,0 +1,34 @@
|
||||
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
load(
|
||||
"//bazel_tools:scala.bzl",
|
||||
"da_scala_library",
|
||||
"da_scala_test_suite",
|
||||
)
|
||||
|
||||
da_scala_library(
|
||||
name = "struct-json",
|
||||
srcs = glob(["src/main/scala/**/*.scala"]),
|
||||
scala_deps = [
|
||||
"@maven//:com_thesamet_scalapb_lenses",
|
||||
"@maven//:com_thesamet_scalapb_scalapb_runtime",
|
||||
"@maven//:io_spray_spray_json",
|
||||
],
|
||||
tags = ["maven_coordinates=com.daml:struct-json:__VERSION__"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [],
|
||||
)
|
||||
|
||||
da_scala_test_suite(
|
||||
name = "struct-json-test",
|
||||
srcs = glob(["src/test/scala/**/*.scala"]),
|
||||
scala_deps = [
|
||||
"@maven//:com_thesamet_scalapb_lenses",
|
||||
"@maven//:com_thesamet_scalapb_scalapb_runtime",
|
||||
"@maven//:io_spray_spray_json",
|
||||
],
|
||||
deps = [
|
||||
":struct-json",
|
||||
],
|
||||
)
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package com.daml.http.json
|
||||
package com.daml.struct.json
|
||||
|
||||
import com.google.protobuf.struct.Struct
|
||||
import spray.json.{
|
||||
@ -15,7 +15,7 @@ import spray.json.{
|
||||
RootJsonFormat,
|
||||
}
|
||||
|
||||
private[json] object StructJsonFormat extends RootJsonFormat[Struct] {
|
||||
object StructJsonFormat extends RootJsonFormat[Struct] {
|
||||
|
||||
import com.google.protobuf.struct
|
||||
import com.google.protobuf.struct.Value.Kind
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package com.daml.http.json
|
||||
package com.daml.struct.json
|
||||
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import org.scalatest.wordspec.AnyWordSpec
|
@ -265,6 +265,8 @@
|
||||
type: jar-scala
|
||||
- target: //libs-scala/nameof:nameof
|
||||
type: jar-scala
|
||||
- target: //libs-scala/struct-json:struct-json
|
||||
type: jar-scala
|
||||
- target: //ledger/error:error
|
||||
type: jar-scala
|
||||
- target: //ledger/error:error-test-lib
|
||||
|
Loading…
Reference in New Issue
Block a user