Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -219,7 +220,7 @@ class Runner(
client: LedgerClient,
timeProviderType: TimeProviderType,
applicationId: ApplicationId,
party: String,
party: Party,
)(implicit loggingContext: LoggingContextOf[Trigger]) {
import Runner.{SeenMsgs, alterF}

Expand All @@ -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

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -321,7 +322,7 @@ class Runner(
client: LedgerClient,
offset: LedgerOffset,
heartbeat: Option[FiniteDuration],
party: String,
party: Party,
filter: TransactionFilter,
): Flow[SingleCommandFailure, TriggerMsg, NotUsed] = {

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -162,7 +162,7 @@ object RunnerConfig {
triggerIdentifier = null,
ledgerHost = null,
ledgerPort = 0,
ledgerParty = null,
ledgerParty = Party(""),
maxInboundMessageSize = DefaultMaxInboundMessageSize,
timeProviderType = None,
commandTtl = Duration.ofSeconds(30L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +76,7 @@ trait AbstractTriggerTest extends SandboxFixture with TestCommands {
client,
config.timeProviderType.get,
applicationId,
party,
Party(party),
)
}
}
Expand Down