mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
[engine] drop deprecated LenientExercise Command (#15059)
CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
89e2f4db9b
commit
3f163e8e2e
@ -5,15 +5,12 @@ package com.daml.lf
|
||||
package engine
|
||||
package preprocessing
|
||||
|
||||
import com.daml.lf.data
|
||||
import com.daml.lf.data._
|
||||
import com.daml.lf.language.{Ast, PackageInterface}
|
||||
import com.daml.lf.language.Ast
|
||||
import com.daml.lf.transaction.TransactionVersion
|
||||
import com.daml.lf.value.Value
|
||||
import com.daml.scalautil.Statement.discard
|
||||
|
||||
import scala.annotation.nowarn
|
||||
|
||||
private[lf] final class CommandPreprocessor(
|
||||
pkgInterface: language.PackageInterface,
|
||||
requireV1ContractIdSuffix: Boolean,
|
||||
@ -52,33 +49,6 @@ private[lf] final class CommandPreprocessor(
|
||||
speedy.Command.Create(templateId, arg)
|
||||
}
|
||||
|
||||
// TODO: https://github.com/digital-asset/daml/issues/12051
|
||||
// Drop this once Canton support ambiguous choices properly
|
||||
@throws[Error.Preprocessing.Error]
|
||||
@deprecated
|
||||
private def unsafePreprocessLenientExercise(
|
||||
templateId: Ref.Identifier,
|
||||
contractId: Value.ContractId,
|
||||
choiceId: Ref.ChoiceName,
|
||||
argument: Value,
|
||||
): speedy.Command =
|
||||
handleLookup(pkgInterface.lookupLenientChoice(templateId, choiceId)) match {
|
||||
case PackageInterface.ChoiceInfo.Template(choice) =>
|
||||
speedy.Command.ExerciseTemplate(
|
||||
templateId = templateId,
|
||||
contractId = valueTranslator.unsafeTranslateCid(contractId),
|
||||
choiceId = choiceId,
|
||||
argument = valueTranslator.unsafeTranslateValue(choice.argBinder._2, argument),
|
||||
)
|
||||
case PackageInterface.ChoiceInfo.Inherited(ifaceId, choice) =>
|
||||
speedy.Command.ExerciseInterface(
|
||||
interfaceId = ifaceId,
|
||||
contractId = valueTranslator.unsafeTranslateCid(contractId),
|
||||
choiceId = choiceId,
|
||||
argument = valueTranslator.unsafeTranslateValue(choice.argBinder._2, argument),
|
||||
)
|
||||
}
|
||||
|
||||
def unsafePreprocessExercise(
|
||||
typeId: data.TemplateOrInterface[Ref.Identifier, Ref.Identifier],
|
||||
contractId: Value.ContractId,
|
||||
@ -206,15 +176,12 @@ private[lf] final class CommandPreprocessor(
|
||||
|
||||
// returns the speedy translation of an Replay command.
|
||||
@throws[Error.Preprocessing.Error]
|
||||
@nowarn("msg=deprecated")
|
||||
private[preprocessing] def unsafePreprocessReplayCommand(
|
||||
cmd: command.ReplayCommand
|
||||
): speedy.Command =
|
||||
cmd match {
|
||||
case command.ReplayCommand.Create(templateId, argument) =>
|
||||
unsafePreprocessCreate(templateId, argument)
|
||||
case command.ReplayCommand.LenientExercise(typeId, coid, choiceId, argument) =>
|
||||
unsafePreprocessLenientExercise(typeId, coid, choiceId, argument)
|
||||
case command.ReplayCommand.Exercise(templateId, mbIfaceId, coid, choiceId, argument) =>
|
||||
mbIfaceId match {
|
||||
case Some(ifaceId) =>
|
||||
|
@ -215,6 +215,16 @@ private[lf] class PackageInterface(signatures: PartialFunction[PackageId, Packag
|
||||
): Either[LookupError, TemplateChoiceSignature] =
|
||||
lookupTemplateChoice(tmpName, chName, Reference.TemplateChoice(tmpName, chName))
|
||||
|
||||
private[lf] def lookupChoice(
|
||||
templateId: TypeConName,
|
||||
mbInterfaceId: Option[TypeConName],
|
||||
chName: ChoiceName,
|
||||
): Either[LookupError, TemplateChoiceSignature] =
|
||||
mbInterfaceId match {
|
||||
case None => lookupTemplateChoice(templateId, chName)
|
||||
case Some(ifaceId) => lookupInterfaceChoice(ifaceId, chName)
|
||||
}
|
||||
|
||||
private[this] def lookupInterfaceInstance(
|
||||
interfaceName: TypeConName,
|
||||
templateName: TypeConName,
|
||||
@ -287,39 +297,6 @@ private[lf] class PackageInterface(signatures: PartialFunction[PackageId, Packag
|
||||
}
|
||||
)
|
||||
|
||||
// TODO: https://github.com/digital-asset/daml/issues/12051
|
||||
// Drop this, once Canton support ambiguous choices properly
|
||||
@deprecated
|
||||
private[lf] def lookupLenientChoice(
|
||||
templateId: TypeConName,
|
||||
chName: ChoiceName,
|
||||
): Either[LookupError, PackageInterface.ChoiceInfo] = {
|
||||
lazy val context = Reference.Choice(templateId, chName)
|
||||
lookupTemplate(templateId, context).flatMap { template =>
|
||||
template.choices.get(chName) match {
|
||||
case Some(choice) =>
|
||||
Right(PackageInterface.ChoiceInfo.Template(choice))
|
||||
case None =>
|
||||
val matchingChoices = for {
|
||||
ifaceId <- template.implements.keysIterator
|
||||
iface <- lookupInterface(ifaceId, context).toSeq
|
||||
choice <- iface.choices.get(chName).iterator
|
||||
} yield PackageInterface.ChoiceInfo.Inherited(ifaceId, choice)
|
||||
matchingChoices.nextOption().toRight(LookupError(context, context))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private[lf] def lookupChoice(
|
||||
templateId: TypeConName,
|
||||
mbInterfaceId: Option[TypeConName],
|
||||
chName: ChoiceName,
|
||||
): Either[LookupError, TemplateChoiceSignature] =
|
||||
mbInterfaceId match {
|
||||
case None => lookupTemplateChoice(templateId, chName)
|
||||
case Some(ifaceId) => lookupInterfaceChoice(ifaceId, chName)
|
||||
}
|
||||
|
||||
def lookupTemplateOrInterface(
|
||||
name: TypeConName
|
||||
): Either[LookupError, TemplateOrInterface[TemplateSignature, DefInterfaceSignature]] =
|
||||
|
@ -20,16 +20,6 @@ object ReplayCommand {
|
||||
argument: Value,
|
||||
) extends ReplayCommand
|
||||
|
||||
// TODO: https://github.com/digital-asset/daml/issues/12051
|
||||
// Drop this, once Canton support ambiguous choices properly
|
||||
@deprecated("use Exercise")
|
||||
final case class LenientExercise(
|
||||
templateId: TypeConName,
|
||||
contractId: Value.ContractId,
|
||||
choiceId: ChoiceName,
|
||||
argument: Value,
|
||||
) extends ReplayCommand
|
||||
|
||||
/** Exercise a template choice, by template Id or interface Id. */
|
||||
final case class Exercise(
|
||||
templateId: TypeConName,
|
||||
|
Loading…
Reference in New Issue
Block a user