Skip to content

Commit

Permalink
a little bit of tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed May 6, 2024
1 parent 3046bf0 commit c4bd32e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,6 @@ abstract class AbstractHttpServiceIntegrationTestQueryStoreIndependent
extends QueryStoreAndAuthDependentIntegrationTest {
import HttpServiceTestFixture.accountCreateCommand
import json.JsonProtocol._
import scalaz.syntax.functor._

"query GET" - {
"empty results" in withHttpService { fixture =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ object PackageService {
}.toSet

private[http] def resolve(
a: ContractTypeId[String]
a: ContractTypeId.RequiredPkg
)(implicit makeKey: ContractTypeId.Like[CtId]): Option[ContractTypeRef[ResolvedOf[CtId]]] =
(all get makeKey(a.packageId, a.moduleName, a.entityName)).flatMap(toContractTypeRef)
}
Expand All @@ -431,7 +431,6 @@ object PackageService {
private val mapView: MapView[String, (KeyPackageName, Ref.PackageVersion)]
) {
def get(pkgId: String) = mapView.get(pkgId)
override def toString = mapView.toMap.toString
}
object PackageNameMap {
val empty = PackageNameMap(MapView.empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ object WebSocketService {
}
.map { resolveTries =>
val (resolvedWithKey, unresolved) = resolveTries
.toSet[Either[(ContractTypeRef.Resolved, LfV), domain.ContractTypeId.RequiredPkg]]
.toSet[Either[(ContractTypeRef.Resolved, LfV), RequiredPkg]]
.partitionMap(identity)
for {
resolvedWithKey <- (NonEmpty from resolvedWithKey toRightDisjunction InvalidUserInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ package domain {
}

object CreateCommand {
type RequiredPkg[+LfV] = CreateCommand[LfV, ContractTypeId.Template.RequiredPkg]

implicit val bitraverseInstance: Bitraverse[CreateCommand] = new Bitraverse[CreateCommand] {
override def bitraverseImpl[G[_]: Applicative, A, B, C, D](
fab: CreateCommand[A, B]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ class DomainJsonDecoder(
private[this] def jsValueToApiRecord(t: domain.LfType, v: JsValue) =
jsValueToApiValue(t, v) flatMap mustBeApiRecord

private[this] def resolveMetaTemplateIds[U, R <: ContractTypeId.Resolved, LfV](
meta: domain.CommandMeta[U with ContractTypeId.RequiredPkg],
private[this] def resolveMetaTemplateIds[
CtId[T] <: ContractTypeId[T] with ContractTypeId.Ops[CtId, T]
](
meta: domain.CommandMeta[CtId[String]],
jwt: Jwt,
ledgerId: LedgerApiDomain.LedgerId,
)(implicit
ec: ExecutionContext,
lc: LoggingContextOf[InstanceUUID],
): ET[domain.CommandMeta[R]] = for {
): ET[domain.CommandMeta[ContractTypeId.ResolvedOf[CtId]]] = for {
// resolve as few template IDs as possible
tpidToResolved <- {
import scalaz.std.vector._
Expand All @@ -230,10 +232,10 @@ class DomainJsonDecoder(
.traverse { ot => templateId_(ot, jwt, ledgerId) strengthL ot }
.map(_.toMap)
}
} yield meta map tpidToResolved map (_.asInstanceOf[R])
} yield meta map tpidToResolved

private def templateId_[
CtId[T] <: domain.ContractTypeId[T] with domain.ContractTypeId.Ops[CtId, T]
CtId[T] <: ContractTypeId[T] with ContractTypeId.Ops[CtId, T]
](
id: CtId[String],
jwt: Jwt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class DomainJsonEncoder(
} yield y

def encodeCreateCommand(
cmd: domain.CreateCommand[lav1.value.Record, domain.ContractTypeId.Template.RequiredPkg]
cmd: domain.CreateCommand.RequiredPkg[lav1.value.Record]
)(implicit
ev: JsonWriter[domain.CreateCommand[JsValue, domain.ContractTypeId.Template.RequiredPkg]]
ev: JsonWriter[domain.CreateCommand.RequiredPkg[JsValue]]
): JsonError \/ JsValue =
for {
x <- cmd.traversePayload(
apiRecordToJsObject(_)
): JsonError \/ domain.CreateCommand[JsValue, domain.ContractTypeId.Template.RequiredPkg]
): JsonError \/ domain.CreateCommand.RequiredPkg[JsValue]
y <- SprayJson.encode(x).liftErr(JsonError)

} yield y
Expand Down

0 comments on commit c4bd32e

Please sign in to comment.