Skip to content

Commit

Permalink
Error out on SResultScenarioCommit in DAML script service (digital-as…
Browse files Browse the repository at this point in the history
…set#7089)

This was leftover from my first attempt at implementing the script
service by piggybagging on top of the scenario primitives. The current
implementation instead relies on the codepaths used on an actual
ledger where we get SResultFinalValue at the end so we can kill all of
this.

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Aug 11, 2020
1 parent 3c98a49 commit bbc2fe5
Showing 1 changed file with 3 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,39 +418,9 @@ class IdeClient(val compiledPackages: CompiledPackages) extends ScriptLedgerClie
result = Success(Right(results.toSeq))
}
}
case SResultScenarioCommit(value, tx, committers, callback) =>
val results: ImmArray[ScriptLedgerClient.CommandResult] = tx.roots.map { n =>
tx.nodes(n) match {
case create: NodeCreate.WithTxValue[ContractId] =>
ScriptLedgerClient.CreateResult(create.coid)
case exercise: NodeExercises.WithTxValue[_, ContractId] =>
ScriptLedgerClient.ExerciseResult(
exercise.templateId,
exercise.choiceId,
exercise.exerciseResult.get.value)
case n =>
// Root nodes can only be creates and exercises.
throw new RuntimeException(s"Unexpected node: $n")
}
}
val committer = committers.head
ScenarioLedger.commitTransaction(
committer = committer,
effectiveAt = scenarioRunner.ledger.currentTime,
optLocation = machine.commitLocation,
tx = tx,
l = scenarioRunner.ledger
) match {
case Left(fas) =>
// Capture the error and exit.
result = Failure(ScenarioErrorCommitError(fas))
case Right(commitResult) =>
scenarioRunner.ledger = commitResult.newLedger
// Run the side effects
callback(value)
// Capture the result and exit.
result = Success(Right(results.toSeq))
}
case SResultScenarioCommit(_, _, _, _) =>
result = Failure(
new RuntimeException("FATAL: Encountered scenario commit in DAML Script"))
case SResultError(err) =>
// Capture the error and exit.
result = Failure(err)
Expand Down

0 comments on commit bbc2fe5

Please sign in to comment.