Module Daml.Trigger.LowLevel

Typeclasses

class HasTime m => ActionTrigger m where

Low-level trigger actions.

liftTF
: TriggerF a -> m a

instance ActionTrigger (TriggerRule s)

instance ActionTrigger TriggerSetup

Data Types

data ActiveContracts

ActiveContracts

Field Type Description
activeContracts [Created]  

instance HasField “activeContracts” ActiveContracts [Created]

instance HasField “initialState” (Trigger s) (Party -> [Party] -> ActiveContracts -> TriggerSetup s)

data AnyContractId

This type represents the contract id of an unknown template. You can use fromAnyContractId to check which template it corresponds to.

instance Eq AnyContractId

instance Ord AnyContractId

instance Show AnyContractId

instance HasField “activeContracts” ACS (Map TemplateTypeRep (Map AnyContractId AnyTemplate))

instance HasField “contractId” AnyContractId (ContractId ())

instance HasField “contractId” Archived AnyContractId

instance HasField “contractId” Command AnyContractId

instance HasField “contractId” Created AnyContractId

instance HasField “pendingContracts” ACS (Map CommandId [AnyContractId])

instance HasField “pendingContracts” (TriggerAState s) (Map CommandId [AnyContractId])

instance HasField “templateId” AnyContractId TemplateTypeRep

data Archived

The data in an Archived event.

Archived

Field Type Description
eventId EventId  
contractId AnyContractId  

instance Eq Archived

instance Show Archived

instance HasField “contractId” Archived AnyContractId

instance HasField “eventId” Archived EventId

data Command

A ledger API command. To construct a command use createCmd and exerciseCmd.

CreateCommand

Field Type Description
templateArg AnyTemplate  

ExerciseCommand

Field Type Description
contractId AnyContractId  
choiceArg AnyChoice  

CreateAndExerciseCommand

Field Type Description
templateArg AnyTemplate  
choiceArg AnyChoice  

ExerciseByKeyCommand

Field Type Description
tplTypeRep TemplateTypeRep  
contractKey AnyContractKey  
choiceArg AnyChoice  

instance HasField “choiceArg” Command AnyChoice

instance HasField “commands” Commands [Command]

instance HasField “commandsInFlight” (TriggerAState s) (Map CommandId [Command])

instance HasField “commandsInFlight” (TriggerState s) (Map CommandId [Command])

instance HasField “contractId” Command AnyContractId

instance HasField “contractKey” Command AnyContractKey

instance HasField “runTriggerUpdateA” (TriggerUpdateA s a) ((Map CommandId [Command], ACS, [Party]) -> State s a)

instance HasField “templateArg” Command AnyTemplate

instance HasField “tplTypeRep” Command TemplateTypeRep

data CommandId

CommandId Text

instance Eq CommandId

instance Ord CommandId

instance Show CommandId

instance HasField “commandId” Commands CommandId

instance HasField “commandId” Completion CommandId

instance HasField “commandId” Transaction (Optional CommandId)

instance HasField “commandsInFlight” (TriggerAState s) (Map CommandId [Command])

instance HasField “commandsInFlight” (TriggerState s) (Map CommandId [Command])

instance HasField “pendingContracts” ACS (Map CommandId [AnyContractId])

instance HasField “pendingContracts” (TriggerAState s) (Map CommandId [AnyContractId])

instance HasField “runTriggerUpdateA” (TriggerUpdateA s a) ((Map CommandId [Command], ACS, [Party]) -> State s a)

data Commands

A set of commands that are submitted as a single transaction.

Commands

Field Type Description
commandId CommandId  
commands [Command]  

instance HasField “commandId” Commands CommandId

instance HasField “commands” Commands [Command]

data Completion

A completion message. Note that you will only get completions for commands emitted from the trigger. Contrary to the ledger API completion stream, this also includes synchronous failures.

Completion

Field Type Description
commandId CommandId  
status CompletionStatus  

instance Show Completion

instance HasField “commandId” Completion CommandId

instance HasField “status” Completion CompletionStatus

data CompletionStatus

Failed

Field Type Description
status Int  
message Text  

Succeeded

Field Type Description
transactionId TransactionId  

instance Show CompletionStatus

instance HasField “message” CompletionStatus Text

instance HasField “status” Completion CompletionStatus

instance HasField “status” CompletionStatus Int

instance HasField “transactionId” CompletionStatus TransactionId

data Created

The data in a Created event.

Created

Field Type Description
eventId EventId  
contractId AnyContractId  
argument AnyTemplate  

instance HasField “activeContracts” ActiveContracts [Created]

instance HasField “argument” Created AnyTemplate

instance HasField “contractId” Created AnyContractId

instance HasField “eventId” Created EventId

data Event

An event in a transaction. This definition should be kept consistent with the object EventVariant defined in triggers/runner/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Converter.scala

CreatedEvent Created

ArchivedEvent Archived

instance HasField “events” Transaction [Event]

data EventId

EventId Text

instance Eq EventId

instance Show EventId

instance HasField “eventId” Archived EventId

instance HasField “eventId” Created EventId

data Message

Either a transaction or a completion. This definition should be kept consistent with the object MessageVariant defined in triggers/runner/src/main/scala/com/digitalasset/daml/lf/engine/trigger/Converter.scala

MTransaction Transaction

MCompletion Completion

MHeartbeat

instance HasField “update” (Trigger s) (Message -> TriggerRule s ())

instance HasField “updateState” (Trigger s) (Message -> TriggerUpdateA s ())

data RegisteredTemplates

AllInDar

Listen to events for all templates in the given DAR.

RegisteredTemplates [RegisteredTemplate]

instance HasField “registeredTemplates” (Trigger s) RegisteredTemplates

instance HasField “registeredTemplates” (Trigger s) RegisteredTemplates

data Transaction

Transaction

Field Type Description
transactionId TransactionId  
commandId Optional CommandId  
events [Event]  

instance HasField “commandId” Transaction (Optional CommandId)

instance HasField “events” Transaction [Event]

instance HasField “transactionId” Transaction TransactionId

data TransactionId

TransactionId Text

instance Eq TransactionId

instance Show TransactionId

instance HasField “transactionId” CompletionStatus TransactionId

instance HasField “transactionId” Transaction TransactionId

data Trigger s

Trigger is (approximately) a left-fold over Message with an accumulator of type s.

Trigger

Field Type Description
initialState Party -> [Party] -> ActiveContracts -> TriggerSetup s  
update Message -> TriggerRule s ()  
registeredTemplates RegisteredTemplates  
heartbeat Optional RelTime  

instance HasField “heartbeat” (Trigger s) (Optional RelTime)

instance HasField “initialState” (Trigger s) (Party -> [Party] -> ActiveContracts -> TriggerSetup s)

instance HasField “registeredTemplates” (Trigger s) RegisteredTemplates

instance HasField “update” (Trigger s) (Message -> TriggerRule s ())

data TriggerRule s a

TriggerRule

Field Type Description
runTriggerRule StateT s (Free TriggerF) a  

instance ActionTrigger (TriggerRule s)

instance Functor (TriggerRule s)

instance ActionState s (TriggerRule s)

instance HasTime (TriggerRule s)

instance Action (TriggerRule s)

instance Applicative (TriggerRule s)

instance HasField “runTriggerA” (TriggerA s a) (ACS -> TriggerRule (TriggerAState s) a)

instance HasField “runTriggerRule” (TriggerRule s a) (StateT s (Free TriggerF) a)

instance HasField “update” (Trigger s) (Message -> TriggerRule s ())

data TriggerSetup a

TriggerSetup

Field Type Description
runTriggerSetup Free TriggerF a  

instance ActionTrigger TriggerSetup

instance Functor TriggerSetup

instance HasTime TriggerSetup

instance Action TriggerSetup

instance Applicative TriggerSetup

instance HasField “initialState” (Trigger s) (Party -> [Party] -> ActiveContracts -> TriggerSetup s)

instance HasField “runTriggerSetup” (TriggerSetup a) (Free TriggerF a)

Functions

toAnyContractId

: TemplateOrInterface t => ContractId t -> AnyContractId

Wrap a ContractId t in AnyContractId.

fromAnyContractId

: TemplateOrInterface t => AnyContractId -> Optional (ContractId t)

Check if a AnyContractId corresponds to the given template or return None otherwise.

fromCreated

: Template t => Created -> Optional (EventId, ContractId t, t)

Check if a Created event corresponds to the given template.

fromArchived

: Template t => Archived -> Optional (EventId, ContractId t)

Check if an Archived event corresponds to the given template.

registeredTemplate
: Template t => RegisteredTemplate
createCmd

: Template t => t -> Command

Create a contract of the given template.

exerciseCmd

: Choice t c r => ContractId t -> c -> Command

Exercise the given choice.

createAndExerciseCmd

: (Template t, Choice t c r) => t -> c -> Command

Create a contract of the given template and immediately exercise the given choice on it.

exerciseByKeyCmd
: (Choice t c r, TemplateKey t k) => k -> c -> Command
fromCreate

: Template t => Command -> Optional t

Check if the command corresponds to a create command for the given template.

fromCreateAndExercise

: (Template t, Choice t c r) => Command -> Optional (t, c)

Check if the command corresponds to a create and exercise command for the given template.

fromExercise

: Choice t c r => Command -> Optional (ContractId t, c)

Check if the command corresponds to an exercise command for the given template.

fromExerciseByKey

: (Choice t c r, TemplateKey t k) => Command -> Optional (k, c)

Check if the command corresponds to an exercise by key command for the given template.

execStateT
: Functor m => StateT s m a -> s -> m s
zoom
: Functor m => (t -> s) -> (t -> s -> t) -> StateT s m a -> StateT t m a
simulateRule

: TriggerRule s a -> Time -> s -> (s, [Commands], a)

Run a rule without running it. May lose information from the rule; meant for testing purposes only.

submitCommands
: ActionTrigger m => [Command] -> m CommandId