diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Speedy.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Speedy.scala index 883a78b26db2..fd12942de077 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Speedy.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Speedy.scala @@ -132,7 +132,7 @@ private[lf] object Speedy { } private[lf] def finish: PartialTransaction.Result = ptx.finish private[lf] def ptxInternal: PartialTransaction = ptx //deprecated - private[lf] def incompleteTransaction(): IncompleteTransaction = ptx.finishIncomplete + private[lf] def incompleteTransaction: IncompleteTransaction = ptx.finishIncomplete } diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/transaction/PartialTransaction.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/transaction/PartialTransaction.scala index 4d96f6a0ddfe..e5a140511126 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/transaction/PartialTransaction.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/transaction/PartialTransaction.scala @@ -273,7 +273,7 @@ private[lf] object PartialTransaction { * @param actionNodeLocations The optional locations of create/exercise/fetch/lookup nodes in pre-order. * Used by 'locationInfo()', called by 'finish()' and 'finishIncomplete()' */ -private[lf] case class PartialTransaction( +private[speedy] case class PartialTransaction( packageToTransactionVersion: Ref.PackageId => TxVersion, contractKeyUniqueness: ContractKeyUniquenessMode, submissionTime: Time.Timestamp, diff --git a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala index eaf7c8ad704a..d0b81ae8bd81 100644 --- a/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala +++ b/daml-lf/scenario-interpreter/src/main/scala/com/digitalasset/daml/lf/ScenarioRunner.scala @@ -96,8 +96,8 @@ final class ScenarioRunner( ) if (mustFail) { submitResult match { - case Commit(result, _, ptx) => - currentSubmission = Some(CurrentSubmission(location, ptx.finishIncomplete)) + case Commit(result, _, tx) => + currentSubmission = Some(CurrentSubmission(location, tx)) throw scenario.Error.MustFailSucceeded(result.richTransaction.transaction) case _: SubmissionError => ledger = ledger.insertAssertMustFail(committers, Set.empty, location) @@ -109,8 +109,8 @@ final class ScenarioRunner( currentSubmission = None ledger = result.newLedger callback(value) - case SubmissionError(err, ptx) => - currentSubmission = Some(CurrentSubmission(location, ptx.finishIncomplete)) + case SubmissionError(err, tx) => + currentSubmission = Some(CurrentSubmission(location, tx)) throw err } } @@ -193,19 +193,15 @@ object ScenarioRunner { } } - sealed trait SubmissionResult[+R] { - // TODO (MK) Temporary to leak the ptx from the submission machine - // to the parent machine. - def ptx: PartialTransaction - } + sealed trait SubmissionResult[+R] final case class Commit[R]( result: R, value: SValue, - ptx: PartialTransaction, + tx: IncompleteTransaction, ) extends SubmissionResult[R] - final case class SubmissionError(error: Error, ptx: PartialTransaction) + final case class SubmissionError(error: Error, tx: IncompleteTransaction) extends SubmissionResult[Nothing] // The interface we need from a ledger during submission. We allow abstracting over this so we can play @@ -437,18 +433,18 @@ object ScenarioRunner { val tx = if (doEnrichment) enrich(tx0) else tx0 ledger.commit(committers, readAs, location, tx, locationInfo) match { case Left(err) => - SubmissionError(err, onLedger.ptxInternal) + SubmissionError(err, onLedger.incompleteTransaction) case Right(r) => - Commit(r, resultValue, onLedger.ptxInternal) + Commit(r, resultValue, onLedger.incompleteTransaction) } case PartialTransaction.IncompleteTransaction(ptx) => throw new RuntimeException(s"Unexpected abort: $ptx") } case SResultError(err) => - SubmissionError(Error.RunnerException(err), onLedger.ptxInternal) + SubmissionError(Error.RunnerException(err), onLedger.incompleteTransaction) case SResultNeedContract(coid, tid @ _, committers, callback) => ledger.lookupContract(coid, committers, readAs, callback) match { - case Left(err) => SubmissionError(err, onLedger.ptxInternal) + case Left(err) => SubmissionError(err, onLedger.incompleteTransaction) case Right(_) => go() } case SResultNeedKey(keyWithMaintainers, committers, callback) => @@ -459,7 +455,7 @@ object ScenarioRunner { readAs, callback, ) match { - case Left(err) => SubmissionError(err, onLedger.ptxInternal) + case Left(err) => SubmissionError(err, onLedger.incompleteTransaction) case Right(_) => go() } case SResultNeedTime(callback) => diff --git a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala index f8b39b07ff95..0625a36d4cc8 100644 --- a/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala +++ b/daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ledgerinteraction/IdeLedgerClient.scala @@ -188,9 +188,8 @@ class IdeLedgerClient( } } Right(transaction.roots.toSeq.map(convRootEvent(_))) - case ScenarioRunner.SubmissionError(err, ptx) => - _currentSubmission = - Some(ScenarioRunner.CurrentSubmission(optLocation, ptx.finishIncomplete)) + case ScenarioRunner.SubmissionError(err, tx) => + _currentSubmission = Some(ScenarioRunner.CurrentSubmission(optLocation, tx)) throw err } @@ -203,8 +202,7 @@ class IdeLedgerClient( unsafeSubmit(actAs, readAs, commands, optLocation) .map({ case commit: ScenarioRunner.Commit[_] => - _currentSubmission = - Some(ScenarioRunner.CurrentSubmission(optLocation, commit.ptx.finishIncomplete)) + _currentSubmission = Some(ScenarioRunner.CurrentSubmission(optLocation, commit.tx)) Left(()) case _: ScenarioRunner.SubmissionError => _currentSubmission = None @@ -246,9 +244,8 @@ class IdeLedgerClient( ScriptLedgerClient.TransactionTree( transaction.roots.collect(Function.unlift(convEvent(_))).toList ) - case ScenarioRunner.SubmissionError(err, ptx) => - _currentSubmission = - Some(ScenarioRunner.CurrentSubmission(optLocation, ptx.finishIncomplete)) + case ScenarioRunner.SubmissionError(err, tx) => + _currentSubmission = Some(ScenarioRunner.CurrentSubmission(optLocation, tx)) throw new IllegalStateException(err) } }