mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-17 15:57:21 +03:00
use WithTxValue in place of VersionedValue more broadly (#643)
* GenTransaction.WithTxValue alias * undo parts of parent dealing explicitly with serialization * use GenNode.WithTxValue more often * use Node*.WithTxValue more often
This commit is contained in:
parent
81b976b919
commit
fef8a956ee
@ -375,7 +375,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
.map(nodeId => builder.setParent(convertNodeId(nodeId)))
|
||||
|
||||
nodeInfo.node match {
|
||||
case create: N.NodeCreate[V.AbsoluteContractId, V.VersionedValue[V.AbsoluteContractId]] =>
|
||||
case create: N.NodeCreate[V.AbsoluteContractId, Tx.Value[V.AbsoluteContractId]] =>
|
||||
val createBuilder =
|
||||
Node.Create.newBuilder
|
||||
.setContractInstance(
|
||||
@ -401,7 +401,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
case ex: N.NodeExercises[
|
||||
Ledger.NodeId,
|
||||
V.AbsoluteContractId,
|
||||
V.VersionedValue[V.AbsoluteContractId]] =>
|
||||
Tx.Value[V.AbsoluteContractId]] =>
|
||||
ex.optLocation.map(loc => builder.setLocation(convertLocation(loc)))
|
||||
builder.setExercise(
|
||||
Node.Exercise.newBuilder
|
||||
@ -421,7 +421,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
.build
|
||||
)
|
||||
|
||||
case lbk: N.NodeLookupByKey[V.AbsoluteContractId, V.VersionedValue[V.AbsoluteContractId]] =>
|
||||
case lbk: N.NodeLookupByKey[V.AbsoluteContractId, Tx.Value[V.AbsoluteContractId]] =>
|
||||
lbk.optLocation.foreach(loc => builder.setLocation(convertLocation(loc)))
|
||||
val lbkBuilder = Node.LookupByKey.newBuilder
|
||||
.setTemplateId(convertIdentifier(lbk.templateId))
|
||||
@ -448,7 +448,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
.setNodeId(NodeId.newBuilder.setId(nodeId.index.toString).build)
|
||||
// FIXME(JM): consumedBy, parent, ...
|
||||
node match {
|
||||
case create: N.NodeCreate[V.ContractId, V.VersionedValue[V.ContractId]] =>
|
||||
case create: N.NodeCreate.WithTxValue[V.ContractId] =>
|
||||
val createBuilder =
|
||||
Node.Create.newBuilder
|
||||
.setContractInstance(
|
||||
@ -472,7 +472,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
.addAllStakeholders(fetch.stakeholders.map(convertParty).asJava)
|
||||
.build
|
||||
)
|
||||
case ex: N.NodeExercises[Tx.NodeId, V.ContractId, V.VersionedValue[V.ContractId]] =>
|
||||
case ex: N.NodeExercises.WithTxValue[Tx.NodeId, V.ContractId] =>
|
||||
ex.optLocation.map(loc => builder.setLocation(convertLocation(loc)))
|
||||
builder.setExercise(
|
||||
Node.Exercise.newBuilder
|
||||
@ -494,7 +494,7 @@ case class Conversions(homePackageId: Ref.PackageId) {
|
||||
.build
|
||||
)
|
||||
|
||||
case lookup: N.NodeLookupByKey[V.ContractId, V.VersionedValue[V.ContractId]] =>
|
||||
case lookup: N.NodeLookupByKey.WithTxValue[V.ContractId] =>
|
||||
lookup.optLocation.map(loc => builder.setLocation(convertLocation(loc)))
|
||||
builder.setLookupByKey({
|
||||
val builder = Node.LookupByKey.newBuilder
|
||||
|
@ -89,7 +89,7 @@ final class Engine {
|
||||
* create or an exercise choice.
|
||||
*/
|
||||
def reinterpret(
|
||||
nodes: Seq[GenNode[NodeId, ContractId, Transaction.Value[ContractId]]],
|
||||
nodes: Seq[GenNode.WithTxValue[NodeId, ContractId]],
|
||||
ledgerEffectiveTime: Time.Timestamp
|
||||
): Result[Transaction.Transaction] = {
|
||||
for {
|
||||
@ -138,7 +138,7 @@ final class Engine {
|
||||
* @param contractIdMaping a function that generates absolute contractIds
|
||||
*/
|
||||
def validatePartial(
|
||||
tx: GenTransaction[Tx.NodeId, AbsoluteContractId, Tx.Value[AbsoluteContractId]],
|
||||
tx: GenTransaction.WithTxValue[Tx.NodeId, AbsoluteContractId],
|
||||
submitter: Option[SimpleString],
|
||||
ledgerEffectiveTime: Time.Timestamp,
|
||||
requestor: Party,
|
||||
@ -293,7 +293,7 @@ final class Engine {
|
||||
|
||||
private[this] def translateTransactionRoots[Cid <: ContractId](
|
||||
commandPreprocessor: CommandPreprocessor,
|
||||
tx: GenTransaction[Transaction.NodeId, Cid, Transaction.Value[Cid]]
|
||||
tx: GenTransaction.WithTxValue[Transaction.NodeId, Cid]
|
||||
): Result[ImmArray[(Transaction.NodeId, (Type, SpeedyCommand))]] = {
|
||||
Result.sequence(tx.roots.map(id =>
|
||||
tx.nodes.get(id) match {
|
||||
|
@ -5,12 +5,12 @@ package com.digitalasset.daml.lf.engine
|
||||
|
||||
import com.digitalasset.daml.lf.data.Time
|
||||
import com.digitalasset.daml.lf.transaction.Node._
|
||||
import com.digitalasset.daml.lf.value.Value.{AbsoluteContractId, VersionedValue}
|
||||
import com.digitalasset.daml.lf.value.Value.AbsoluteContractId
|
||||
|
||||
object NodeToCommand {
|
||||
|
||||
/** a node incoming without use of internal nodeIds */
|
||||
type TranslatableNode = GenNode[_, AbsoluteContractId, VersionedValue[AbsoluteContractId]]
|
||||
type TranslatableNode = GenNode.WithTxValue[_, AbsoluteContractId]
|
||||
|
||||
import Error._
|
||||
|
||||
@ -29,17 +29,17 @@ object NodeToCommand {
|
||||
ledgerEffectiveTime: Time.Timestamp,
|
||||
workflowReference: String): Either[Error, Commands] = {
|
||||
val cmd: Either[Error, Command] = node match {
|
||||
case _: NodeFetch[AbsoluteContractId] =>
|
||||
case _: NodeFetch[_] =>
|
||||
Left(Error(s"Fetch node cannot be translated to command in: $workflowReference"))
|
||||
case _: NodeLookupByKey[AbsoluteContractId, VersionedValue[AbsoluteContractId]] =>
|
||||
case _: NodeLookupByKey[_, _] =>
|
||||
Left(Error(s"LookupByKey node cannot be translated to a command in: $workflowReference"))
|
||||
case c: NodeCreate[AbsoluteContractId, VersionedValue[AbsoluteContractId]] =>
|
||||
case c: NodeCreate.WithTxValue[AbsoluteContractId] =>
|
||||
val templateId = c.coinst.template
|
||||
val value = c.coinst.arg
|
||||
|
||||
Right(CreateCommand(templateId, value))
|
||||
|
||||
case e: NodeExercises[_, AbsoluteContractId, VersionedValue[AbsoluteContractId]] =>
|
||||
case e: NodeExercises.WithTxValue[_, AbsoluteContractId] =>
|
||||
val templateId = e.templateId
|
||||
val contractId = e.targetCoid.coid
|
||||
val argument = e.chosenValue
|
||||
|
@ -13,7 +13,7 @@ import com.digitalasset.daml.lf.value.Value._
|
||||
import scala.annotation.tailrec
|
||||
|
||||
trait PrivateLedgerData {
|
||||
def update(tx: GenTransaction[NodeId, ContractId, VersionedValue[ContractId]]): Unit
|
||||
def update(tx: GenTransaction.WithTxValue[NodeId, ContractId]): Unit
|
||||
def get(id: AbsoluteContractId): Option[ContractInst[VersionedValue[AbsoluteContractId]]]
|
||||
def toAbsoluteContractId(txCounter: Int)(cid: ContractId): AbsoluteContractId
|
||||
def transactionCounter: Int
|
||||
@ -26,7 +26,7 @@ private[engine] class InMemoryPrivateLedgerData extends PrivateLedgerData {
|
||||
new ConcurrentHashMap()
|
||||
private val txCounter: AtomicInteger = new AtomicInteger(0)
|
||||
|
||||
def update(tx: GenTransaction[NodeId, ContractId, VersionedValue[ContractId]]): Unit =
|
||||
def update(tx: GenTransaction.WithTxValue[NodeId, ContractId]): Unit =
|
||||
updateWithAbsoluteContractId(tx.mapContractId(toAbsoluteContractId(txCounter.get)))
|
||||
|
||||
def toAbsoluteContractId(txCounter: Int)(cid: ContractId): AbsoluteContractId =
|
||||
@ -36,7 +36,7 @@ private[engine] class InMemoryPrivateLedgerData extends PrivateLedgerData {
|
||||
}
|
||||
|
||||
def updateWithAbsoluteContractId(
|
||||
tx: GenTransaction[NodeId, AbsoluteContractId, VersionedValue[AbsoluteContractId]]): Unit =
|
||||
tx: GenTransaction.WithTxValue[NodeId, AbsoluteContractId]): Unit =
|
||||
this.synchronized {
|
||||
// traverse in topo order and add / remove
|
||||
@tailrec
|
||||
@ -45,14 +45,12 @@ private[engine] class InMemoryPrivateLedgerData extends PrivateLedgerData {
|
||||
case FrontStackCons(nodeId, nodeIds) =>
|
||||
val node = tx.nodes(nodeId)
|
||||
node match {
|
||||
case _: NodeFetch[AbsoluteContractId] =>
|
||||
go(nodeIds)
|
||||
case nc: NodeCreate[AbsoluteContractId, Tx.Value[AbsoluteContractId]] =>
|
||||
case nc: NodeCreate.WithTxValue[AbsoluteContractId] =>
|
||||
pcs.put(nc.coid, nc.coinst)
|
||||
go(nodeIds)
|
||||
case ne: NodeExercises[Tx.NodeId, AbsoluteContractId, Tx.Value[AbsoluteContractId]] =>
|
||||
case ne: NodeExercises.WithTxValue[Tx.NodeId, AbsoluteContractId] =>
|
||||
go(ne.children ++: nodeIds)
|
||||
case _: NodeLookupByKey[_, _] =>
|
||||
case _: NodeLookupByKey[_, _] | _: NodeFetch[_] =>
|
||||
go(nodeIds)
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class LargeTransactionTest extends WordSpec with Matchers {
|
||||
exerciseCmdTx: Transaction,
|
||||
expectedNumberOfContracts: Int): Assertion = {
|
||||
|
||||
val newContracts: List[N.GenNode[Tx.NodeId, Tx.ContractId, Tx.Value[Tx.ContractId]]] =
|
||||
val newContracts: List[N.GenNode.WithTxValue[Tx.NodeId, Tx.ContractId]] =
|
||||
firstRootNode(exerciseCmdTx) match {
|
||||
case ne: N.NodeExercises[_, _, _] => ne.children.toList.map(nid => exerciseCmdTx.nodes(nid))
|
||||
case n @ _ => fail(s"Unexpected match: $n")
|
||||
@ -280,8 +280,8 @@ class LargeTransactionTest extends WordSpec with Matchers {
|
||||
exerciseCmdTx.roots.length shouldBe 1
|
||||
exerciseCmdTx.nodes.size shouldBe 2
|
||||
|
||||
val createNode: N.GenNode[Tx.NodeId, Tx.ContractId, Tx.Value[Tx.ContractId]] = firstRootNode(
|
||||
exerciseCmdTx) match {
|
||||
val createNode
|
||||
: N.GenNode.WithTxValue[Tx.NodeId, Tx.ContractId] = firstRootNode(exerciseCmdTx) match {
|
||||
case ne: N.NodeExercises[_, _, _] => exerciseCmdTx.nodes(ne.children.head)
|
||||
case n @ _ => fail(s"Unexpected match: $n")
|
||||
}
|
||||
|
@ -70,16 +70,16 @@ object Pretty {
|
||||
// A minimal pretty-print of an update transaction node, without recursing into child nodes..
|
||||
def prettyTransactionNode(node: Transaction.Node): Doc =
|
||||
node match {
|
||||
case create: NodeCreate[ContractId, Transaction.Value[ContractId]] =>
|
||||
case create: NodeCreate.WithTxValue[ContractId] =>
|
||||
"create" &: prettyContractInst(create.coinst)
|
||||
case fetch: NodeFetch[ContractId] =>
|
||||
"fetch" &: prettyContractId(fetch.coid)
|
||||
case ex: NodeExercises[Transaction.NodeId, ContractId, Transaction.Value[ContractId]] =>
|
||||
case ex: NodeExercises.WithTxValue[Transaction.NodeId, ContractId] =>
|
||||
intercalate(text(", "), ex.actingParties.map(p => text(p.underlyingString))) &
|
||||
text("exercises") & text(ex.choiceId) + char(':') + prettyIdentifier(ex.templateId) &
|
||||
text("on") & prettyContractId(ex.targetCoid) /
|
||||
text("with") & prettyVersionedValue(false)(ex.chosenValue)
|
||||
case lbk: NodeLookupByKey[ContractId, Transaction.Value[ContractId]] =>
|
||||
case lbk: NodeLookupByKey.WithTxValue[ContractId] =>
|
||||
text("lookup by key") & prettyIdentifier(lbk.templateId) /
|
||||
text("key") & prettyKeyWithMaintainers(lbk.key) /
|
||||
(lbk.result match {
|
||||
|
@ -98,7 +98,7 @@ class SemanticTester(
|
||||
// returns the matched event and the tail of the eventIds
|
||||
def popEvent[EvTyp: ClassTag](
|
||||
what: String,
|
||||
scenarioNode: GenNode[L.NodeId, AbsoluteContractId, Tx.Value[AbsoluteContractId]],
|
||||
scenarioNode: GenNode.WithTxValue[L.NodeId, AbsoluteContractId],
|
||||
remainingLedgerEventIds: FrontStack[ledger.EventNodeId])
|
||||
: (EvTyp, FrontStack[ledger.EventNodeId]) =
|
||||
remainingLedgerEventIds match {
|
||||
@ -266,7 +266,7 @@ class SemanticTester(
|
||||
val node = richTransaction.nodes(nodeId)
|
||||
|
||||
node match {
|
||||
case nc: NodeCreate[AbsoluteContractId, Tx.Value[AbsoluteContractId]] =>
|
||||
case nc: NodeCreate.WithTxValue[AbsoluteContractId] =>
|
||||
previousMap.flatMap(m => {
|
||||
val engineArg =
|
||||
nc.coinst.arg.mapContractId(m)
|
||||
@ -274,10 +274,7 @@ class SemanticTester(
|
||||
submitCommandCheckAndUpdateMap(richTransaction.committer, cmd, m)
|
||||
})
|
||||
|
||||
case ne: NodeExercises[
|
||||
L.NodeId,
|
||||
AbsoluteContractId,
|
||||
Tx.Value[AbsoluteContractId]] =>
|
||||
case ne: NodeExercises.WithTxValue[L.NodeId, AbsoluteContractId] =>
|
||||
previousMap.flatMap(m => {
|
||||
|
||||
val engineTargetCoid = m(ne.targetCoid)
|
||||
@ -292,12 +289,8 @@ class SemanticTester(
|
||||
submitCommandCheckAndUpdateMap(richTransaction.committer, cmd, m)
|
||||
})
|
||||
|
||||
case _: NodeFetch[AbsoluteContractId] =>
|
||||
// nothing to do for fetches
|
||||
previousMap
|
||||
|
||||
case _: NodeLookupByKey[_, _] =>
|
||||
// nothing to do for lookup by key
|
||||
case _: NodeFetch[_] | _: NodeLookupByKey[_, _] =>
|
||||
// nothing to do for fetches or lookup by key
|
||||
previousMap
|
||||
}
|
||||
}
|
||||
@ -389,7 +382,7 @@ object SemanticTester {
|
||||
v.mapContractId(makeAbsoluteContractId)
|
||||
|
||||
private[this] def updatePcs(
|
||||
tx: GenTransaction[Tx.NodeId, AbsoluteContractId, Tx.Value[AbsoluteContractId]]): Unit = {
|
||||
tx: GenTransaction.WithTxValue[Tx.NodeId, AbsoluteContractId]): Unit = {
|
||||
// traverse in topo order and add / remove
|
||||
@tailrec
|
||||
def go(remaining: FrontStack[Tx.NodeId]): Unit = remaining match {
|
||||
@ -397,14 +390,12 @@ object SemanticTester {
|
||||
case FrontStackCons(nodeId, nodeIds) =>
|
||||
val node = tx.nodes(nodeId)
|
||||
node match {
|
||||
case _: NodeFetch[AbsoluteContractId] =>
|
||||
case _: NodeFetch[_] | _: NodeLookupByKey[_, _] =>
|
||||
go(nodeIds)
|
||||
case _: NodeLookupByKey[_, _] =>
|
||||
go(nodeIds)
|
||||
case nc: NodeCreate[AbsoluteContractId, Tx.Value[AbsoluteContractId]] =>
|
||||
case nc: NodeCreate.WithTxValue[AbsoluteContractId] =>
|
||||
pcs += (nc.coid -> nc.coinst)
|
||||
go(nodeIds)
|
||||
case ne: NodeExercises[Tx.NodeId, AbsoluteContractId, Tx.Value[AbsoluteContractId]] =>
|
||||
case ne: NodeExercises.WithTxValue[Tx.NodeId, AbsoluteContractId] =>
|
||||
// Note: leaking some memory here; we cannot remove consumed contracts,
|
||||
// because later post-commit validation needs to find it
|
||||
go(ne.children ++: nodeIds)
|
||||
|
@ -271,7 +271,7 @@ object ValueGenerators {
|
||||
* 1. stakeholders may not be a superset of signatories
|
||||
* 2. key's maintainers may not be a subset of signatories
|
||||
*/
|
||||
val malformedCreateNodeGen: Gen[NodeCreate[Tx.ContractId, Tx.Value[Tx.ContractId]]] = {
|
||||
val malformedCreateNodeGen: Gen[NodeCreate.WithTxValue[Tx.ContractId]] = {
|
||||
for {
|
||||
coid <- coidGen
|
||||
coinst <- contractInstanceGen
|
||||
|
@ -18,7 +18,7 @@ import scala.collection.breakOut
|
||||
|
||||
case class VersionedTransaction[Nid, Cid](
|
||||
version: TransactionVersion,
|
||||
transaction: GenTransaction[Nid, Cid, VersionedValue[Cid]]) {
|
||||
transaction: GenTransaction.WithTxValue[Nid, Cid]) {
|
||||
def mapContractId[Cid2](f: Cid => Cid2): VersionedTransaction[Nid, Cid2] = this.copy(
|
||||
transaction = transaction.mapContractIdAndValue(f, _.mapContractId(f))
|
||||
)
|
||||
@ -79,7 +79,7 @@ case class GenTransaction[Nid, Cid, +Val](
|
||||
}
|
||||
|
||||
def mapContractId[Cid2](f: Cid => Cid2)(
|
||||
implicit ev: Val <:< VersionedValue[Cid]): GenTransaction[Nid, Cid2, VersionedValue[Cid2]] = {
|
||||
implicit ev: Val <:< VersionedValue[Cid]): WithTxValue[Nid, Cid2] = {
|
||||
def g(v: Val): VersionedValue[Cid2] = v.mapContractId(f)
|
||||
this.mapContractIdAndValue(f, g)
|
||||
}
|
||||
@ -317,6 +317,8 @@ case class GenTransaction[Nid, Cid, +Val](
|
||||
}
|
||||
|
||||
object GenTransaction {
|
||||
type WithTxValue[Nid, Cid] = GenTransaction[Nid, Cid, Transaction.Value[Cid]]
|
||||
|
||||
sealed trait TraverseOrder
|
||||
case object BottomUp extends TraverseOrder // visits exercise children before the exercise node itself
|
||||
case object TopDown extends TraverseOrder // visits exercise nodes first, then their children
|
||||
@ -338,7 +340,7 @@ object Transaction {
|
||||
type Value[+Cid] = Value.VersionedValue[Cid]
|
||||
|
||||
/** Transaction nodes */
|
||||
type Node = GenNode[NodeId, ContractId, Value[ContractId]]
|
||||
type Node = GenNode.WithTxValue[NodeId, ContractId]
|
||||
|
||||
/** (Complete) transactions, which are the result of interpreting a
|
||||
* ledger-update. These transactions are consumed by either the
|
||||
@ -348,7 +350,7 @@ object Transaction {
|
||||
* divulgence of contracts.
|
||||
*
|
||||
*/
|
||||
type Transaction = GenTransaction[NodeId, ContractId, Value[ContractId]]
|
||||
type Transaction = GenTransaction.WithTxValue[NodeId, ContractId]
|
||||
|
||||
/** Errors that can happen during building transactions. */
|
||||
sealed abstract class TransactionError extends Product with Serializable
|
||||
@ -463,7 +465,7 @@ object Transaction {
|
||||
|
||||
def addToStringBuilder(
|
||||
nid: NodeId,
|
||||
node: GenNode[NodeId, ContractId, Value[ContractId]],
|
||||
node: GenNode.WithTxValue[NodeId, ContractId],
|
||||
rootPrefix: String): Unit = {
|
||||
sb.append(rootPrefix)
|
||||
.append("node ")
|
||||
@ -527,11 +529,9 @@ object Transaction {
|
||||
_ <- guard(0 <= lcoid.txnid.index)
|
||||
node <- nodes.get(lcoid.txnid)
|
||||
coinst <- node match {
|
||||
case create: NodeCreate[ContractId, Transaction.Value[ContractId]] =>
|
||||
case create: NodeCreate.WithTxValue[ContractId] =>
|
||||
Some((create.coinst, consumedBy.get(lcoid)))
|
||||
case _: NodeExercises[NodeId, ContractId, Transaction.Value[ContractId]] => None
|
||||
case _: NodeFetch[ContractId] => None
|
||||
case _: NodeLookupByKey[ContractId, Transaction.Value[ContractId]] => None
|
||||
case _: NodeExercises[_, _, _] | _: NodeFetch[_] | _: NodeLookupByKey[_, _] => None
|
||||
}
|
||||
} yield coinst
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
package com.digitalasset.ledger.backend.api
|
||||
|
||||
import com.digitalasset.daml.lf.transaction.{GenTransaction, Transaction}
|
||||
import com.digitalasset.daml.lf.value.Value.{AbsoluteContractId, VersionedValue}
|
||||
import com.digitalasset.daml.lf.value.Value.AbsoluteContractId
|
||||
|
||||
/** Version 1 of the Ledger Backend API.
|
||||
*
|
||||
@ -46,5 +46,5 @@ package object v1 {
|
||||
* [[com.digitalasset.ledger.backend.api.v1.LedgerSyncEvent.AcceptedTransaction]] event on the [[LedgerBackend.ledgerSyncEvents]]
|
||||
* stream. */
|
||||
type CommittedTransaction =
|
||||
GenTransaction[NodeId, AbsoluteContractId, VersionedValue[AbsoluteContractId]]
|
||||
GenTransaction.WithTxValue[NodeId, AbsoluteContractId]
|
||||
}
|
||||
|
@ -12,32 +12,32 @@ import scala.collection.breakOut
|
||||
|
||||
object PlatformTypes {
|
||||
|
||||
type GenTransaction[Nid, Cid] = T.GenTransaction[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type GenTransaction[Nid, Cid] = T.GenTransaction.WithTxValue[Nid, Cid]
|
||||
val GenTransaction: T.GenTransaction.type = T.GenTransaction
|
||||
|
||||
type GenNode[Nid, Cid] = N.GenNode[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type GenNode[Nid, Cid] = N.GenNode.WithTxValue[Nid, Cid]
|
||||
|
||||
type NodeCreate[Cid] = N.NodeCreate[Cid, V.VersionedValue[Cid]]
|
||||
type NodeCreate[Cid] = N.NodeCreate.WithTxValue[Cid]
|
||||
val NodeCreate: N.NodeCreate.type = N.NodeCreate
|
||||
|
||||
type NodeLookupByKey[Cid] = N.NodeLookupByKey[Cid, V.VersionedValue[Cid]]
|
||||
type NodeLookupByKey[Cid] = N.NodeLookupByKey.WithTxValue[Cid]
|
||||
val NodeLookupByKey: N.NodeLookupByKey.type = N.NodeLookupByKey
|
||||
|
||||
type NodeFetch[Cid] = N.NodeFetch[Cid]
|
||||
val NodeFetch: N.NodeFetch.type = N.NodeFetch
|
||||
|
||||
type NodeExercises[Nid, Cid] = N.NodeExercises[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type NodeExercises[Nid, Cid] = N.NodeExercises.WithTxValue[Nid, Cid]
|
||||
val NodeExercises: N.NodeExercises.type = N.NodeExercises
|
||||
|
||||
type Event[Nid, Cid] = E.Event[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type Event[Nid, Cid] = E.Event[Nid, Cid, T.Transaction.Value[Cid]]
|
||||
|
||||
type Events[Nid, Cid] = E.Event.Events[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type Events[Nid, Cid] = E.Event.Events[Nid, Cid, T.Transaction.Value[Cid]]
|
||||
val Events: E.Event.Events.type = E.Event.Events
|
||||
|
||||
type CreateEvent[Cid] = E.CreateEvent[Cid, V.VersionedValue[Cid]]
|
||||
type CreateEvent[Cid] = E.CreateEvent[Cid, T.Transaction.Value[Cid]]
|
||||
val CreateEvent: E.CreateEvent.type = E.CreateEvent
|
||||
|
||||
type ExerciseEvent[Nid, Cid] = E.ExerciseEvent[Nid, Cid, V.VersionedValue[Cid]]
|
||||
type ExerciseEvent[Nid, Cid] = E.ExerciseEvent[Nid, Cid, T.Transaction.Value[Cid]]
|
||||
val ExerciseEvent: E.ExerciseEvent.type = E.ExerciseEvent
|
||||
|
||||
def mapContractIdAndValue[Nid, Cid, Cid2](tx: GenTransaction[Nid, Cid])(
|
||||
|
@ -4,9 +4,9 @@
|
||||
package com.digitalasset.platform.server.services.transaction
|
||||
|
||||
import com.digitalasset.daml.lf.transaction.GenTransaction
|
||||
import com.digitalasset.daml.lf.value.Value.{AbsoluteContractId, VersionedValue}
|
||||
import com.digitalasset.daml.lf.value.Value.AbsoluteContractId
|
||||
|
||||
/** Bundles all data extracted from ACTs together. */
|
||||
final case class TransactionWithMeta(
|
||||
transaction: GenTransaction[String, AbsoluteContractId, VersionedValue[AbsoluteContractId]],
|
||||
transaction: GenTransaction.WithTxValue[String, AbsoluteContractId],
|
||||
meta: TransactionMeta)
|
||||
|
@ -146,7 +146,7 @@ package object v1 {
|
||||
* absolute contract identifiers.
|
||||
*/
|
||||
type CommittedTransaction =
|
||||
GenTransaction[NodeId, Value.AbsoluteContractId, Value.VersionedValue[Value.AbsoluteContractId]]
|
||||
GenTransaction.WithTxValue[NodeId, Value.AbsoluteContractId]
|
||||
|
||||
/** A contract instance with absolute contract identifiers only. */
|
||||
type AbsoluteContractInst =
|
||||
|
@ -66,7 +66,7 @@ case class ActiveContractsInMemory(
|
||||
let: Instant,
|
||||
transactionId: String,
|
||||
workflowId: String,
|
||||
transaction: GenTransaction[Nid, AbsoluteContractId, VersionedValue[AbsoluteContractId]],
|
||||
transaction: GenTransaction.WithTxValue[Nid, AbsoluteContractId],
|
||||
explicitDisclosure: Relation[Nid, Ref.Party],
|
||||
localImplicitDisclosure: Relation[Nid, Ref.Party],
|
||||
globalImplicitDisclosure: Relation[AbsoluteContractId, Ref.Party]
|
||||
@ -122,7 +122,7 @@ class ActiveContractsManager[ACS](initialState: => ACS)(implicit ACS: ACS => Act
|
||||
let: Instant,
|
||||
transactionId: String,
|
||||
workflowId: String,
|
||||
transaction: GenTransaction[Nid, AbsoluteContractId, VersionedValue[AbsoluteContractId]],
|
||||
transaction: GenTransaction.WithTxValue[Nid, AbsoluteContractId],
|
||||
explicitDisclosure: Relation[Nid, Ref.Party],
|
||||
localImplicitDisclosure: Relation[Nid, Ref.Party],
|
||||
globalImplicitDisclosure: Relation[AbsoluteContractId, Ref.Party])
|
||||
@ -151,7 +151,7 @@ class ActiveContractsManager[ACS](initialState: => ACS)(implicit ACS: ACS => Act
|
||||
case nf: N.NodeFetch[AbsoluteContractId] =>
|
||||
val absCoid = SandboxEventIdFormatter.makeAbsCoid(transactionId)(nf.coid)
|
||||
AddTransactionState(Some(acc), contractCheck(absCoid, Fetch).fold(errs)(errs + _))
|
||||
case nc: N.NodeCreate[AbsoluteContractId, VersionedValue[AbsoluteContractId]] =>
|
||||
case nc: N.NodeCreate.WithTxValue[AbsoluteContractId] =>
|
||||
val absCoid = SandboxEventIdFormatter.makeAbsCoid(transactionId)(nc.coid)
|
||||
val activeContract = ActiveContract(
|
||||
let = let,
|
||||
@ -175,10 +175,7 @@ class ActiveContractsManager[ACS](initialState: => ACS)(implicit ACS: ACS => Act
|
||||
ats.copy(acc = Some(acc.addContract(absCoid, activeContract, Some(gk))))
|
||||
}
|
||||
}
|
||||
case ne: N.NodeExercises[
|
||||
Nid,
|
||||
AbsoluteContractId,
|
||||
VersionedValue[AbsoluteContractId]] =>
|
||||
case ne: N.NodeExercises.WithTxValue[Nid, AbsoluteContractId] =>
|
||||
val absCoid = SandboxEventIdFormatter.makeAbsCoid(transactionId)(ne.targetCoid)
|
||||
ats.copy(
|
||||
errs = contractCheck(absCoid, Exercise).fold(errs)(errs + _),
|
||||
@ -191,9 +188,7 @@ class ActiveContractsManager[ACS](initialState: => ACS)(implicit ACS: ACS => Act
|
||||
acc
|
||||
})
|
||||
)
|
||||
case nlkup: N.NodeLookupByKey[
|
||||
AbsoluteContractId,
|
||||
VersionedValue[AbsoluteContractId]] =>
|
||||
case nlkup: N.NodeLookupByKey.WithTxValue[AbsoluteContractId] =>
|
||||
// NOTE(FM) we do not need to check anything, since
|
||||
// * this is a lookup, it does not matter if the key exists or not
|
||||
// * if the key exists, we have it as an internal invariant that the backing coid exists.
|
||||
|
@ -7,7 +7,7 @@ import java.time.Instant
|
||||
|
||||
import com.digitalasset.daml.lf.data.Relation.Relation
|
||||
import com.digitalasset.daml.lf.transaction.GenTransaction
|
||||
import com.digitalasset.daml.lf.value.Value.{AbsoluteContractId, VersionedValue}
|
||||
import com.digitalasset.daml.lf.value.Value.AbsoluteContractId
|
||||
import com.digitalasset.ledger.backend.api.v1.{CommandId, RejectionReason}
|
||||
|
||||
sealed abstract class LedgerEntry extends Product with Serializable {
|
||||
@ -41,7 +41,7 @@ object LedgerEntry {
|
||||
workflowId: String,
|
||||
ledgerEffectiveTime: Instant,
|
||||
recordedAt: Instant,
|
||||
transaction: GenTransaction[EventId, AbsoluteContractId, VersionedValue[AbsoluteContractId]],
|
||||
transaction: GenTransaction.WithTxValue[EventId, AbsoluteContractId],
|
||||
explicitDisclosure: Relation[EventId, Party])
|
||||
extends LedgerEntry {
|
||||
override def maybeCommandId: Option[String] = Some(commandId)
|
||||
|
Loading…
Reference in New Issue
Block a user