Use ApiTypes.Party instead of String in the trigger runner (#11298)

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2021-10-20 10:06:20 +02:00 committed by GitHub
parent 2267429ae1
commit 50ea92f7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 15 deletions

View File

@ -7,7 +7,7 @@ import akka.NotUsed
import akka.stream._
import akka.stream.scaladsl._
import com.daml.api.util.TimeProvider
import com.daml.ledger.api.refinements.ApiTypes.ApplicationId
import com.daml.ledger.api.refinements.ApiTypes.{ApplicationId, Party}
import com.daml.ledger.api.v1.command_submission_service.SubmitRequest
import com.daml.ledger.api.v1.commands.{Command, Commands}
import com.daml.ledger.api.v1.completion.Completion
@ -19,6 +19,7 @@ import com.daml.ledger.client.LedgerClient
import com.daml.ledger.client.services.commands.CompletionStreamElement._
import com.daml.lf.archive.Dar
import com.daml.lf.data.ImmArray
import com.daml.lf.data.Ref
import com.daml.lf.data.Ref._
import com.daml.lf.data.ScalazEqual._
import com.daml.lf.data.Time.Timestamp
@ -219,7 +220,7 @@ class Runner(
client: LedgerClient,
timeProviderType: TimeProviderType,
applicationId: ApplicationId,
party: String,
party: Party,
)(implicit loggingContext: LoggingContextOf[Trigger]) {
import Runner.{SeenMsgs, alterF}
@ -232,7 +233,7 @@ class Runner(
// message, or both.
private[this] var pendingCommandIds: Map[UUID, SeenMsgs] = Map.empty
private val transactionFilter: TransactionFilter =
TransactionFilter(Seq((party, trigger.filters)).toMap)
TransactionFilter(Seq((party.unwrap, trigger.filters)).toMap)
private[this] def logger = ContextualizedLogger get getClass
@ -260,7 +261,7 @@ class Runner(
ledgerId = client.ledgerId.unwrap,
applicationId = applicationId.unwrap,
commandId = commandUUID.toString,
party = party,
party = party.unwrap,
commands = commands,
)
logger.debug(
@ -321,7 +322,7 @@ class Runner(
client: LedgerClient,
offset: LedgerOffset,
heartbeat: Option[FiniteDuration],
party: String,
party: Party,
filter: TransactionFilter,
): Flow[SingleCommandFailure, TriggerMsg, NotUsed] = {
@ -361,7 +362,7 @@ class Runner(
submissionFailureQueue
.merge(
client.commandClient
.completionSource(List(party), offset)
.completionSource(List(party.unwrap), offset)
.mapConcat {
case CheckpointElement(_) => List()
case CompletionElement(c) => List(c)
@ -403,7 +404,10 @@ class Runner(
val createdValue: SValue = converter.fromACS(acs).orConverterException
// Setup an application expression of initialState on the ACS.
val initialState: SExpr =
makeApp(getInitialState, Array(SParty(Party.assertFromString(party)), createdValue))
makeApp(
getInitialState,
Array(SParty(Ref.Party.assertFromString(party.unwrap)), createdValue),
)
// Prepare a speedy machine for evaluating expressions.
val machine: Speedy.Machine =
Speedy.Machine.fromPureSExpr(compiledPackages, initialState)
@ -716,7 +720,7 @@ object Runner extends StrictLogging {
client: LedgerClient,
timeProviderType: TimeProviderType,
applicationId: ApplicationId,
party: String,
party: Party,
config: Compiler.Config,
)(implicit materializer: Materializer, executionContext: ExecutionContext): Future[SValue] = {
val darMap = dar.all.toMap

View File

@ -6,7 +6,7 @@ package com.daml.lf.engine.trigger
import java.nio.file.{Path, Paths}
import java.time.Duration
import com.daml.ledger.api.refinements.ApiTypes.ApplicationId
import com.daml.ledger.api.refinements.ApiTypes.{ApplicationId, Party}
import com.daml.ledger.api.tls.TlsConfiguration
import com.daml.ledger.api.tls.TlsConfigurationCli
import com.daml.platform.services.time.TimeProviderType
@ -19,7 +19,7 @@ case class RunnerConfig(
triggerIdentifier: String,
ledgerHost: String,
ledgerPort: Int,
ledgerParty: String,
ledgerParty: Party,
maxInboundMessageSize: Int,
// optional so we can detect if both --static-time and --wall-clock-time are passed.
timeProviderType: Option[TimeProviderType],
@ -59,7 +59,7 @@ object RunnerConfig {
.text("Ledger port")
opt[String]("ledger-party")
.action((t, c) => c.copy(ledgerParty = t))
.action((t, c) => c.copy(ledgerParty = Party(t)))
.text("Ledger party")
opt[Int]("max-inbound-message-size")
@ -162,7 +162,7 @@ object RunnerConfig {
triggerIdentifier = null,
ledgerHost = null,
ledgerPort = 0,
ledgerParty = null,
ledgerParty = Party(""),
maxInboundMessageSize = DefaultMaxInboundMessageSize,
timeProviderType = None,
commandTtl = Duration.ofSeconds(30L),

View File

@ -187,7 +187,7 @@ object TriggerRunnerImpl {
client,
config.ledgerConfig.timeProvider,
config.applicationId,
config.party.unwrap,
config.party,
)
(acs, offset) <- runner.queryACS()
} yield QueriedACS(runner, acs, offset)

View File

@ -10,7 +10,7 @@ import java.util.UUID
import akka.stream.scaladsl.Sink
import com.daml.bazeltools.BazelRunfiles
import com.daml.ledger.api.refinements.ApiTypes.ApplicationId
import com.daml.ledger.api.refinements.ApiTypes.{ApplicationId, Party}
import com.daml.ledger.api.v1.command_service.SubmitAndWaitRequest
import com.daml.ledger.api.v1.commands.{Command, CreateCommand, ExerciseCommand, _}
import com.daml.ledger.api.v1.event.CreatedEvent
@ -76,7 +76,7 @@ trait AbstractTriggerTest extends SandboxFixture with TestCommands {
client,
config.timeProviderType.get,
applicationId,
party,
Party(party),
)
}
}