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 "acs" TriggerSetupArguments ActiveContracts

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 BatchTrigger s

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

BatchTrigger

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

instance HasField "heartbeat" (BatchTrigger s) (Optional RelTime)

instance HasField "initialState" (BatchTrigger s) (TriggerSetupArguments -> TriggerSetup s)

instance HasField "registeredTemplates" (BatchTrigger s) RegisteredTemplates

instance HasField "update" (BatchTrigger s) ([Message] -> TriggerRule s ())

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 "commandsInFlight" TriggerUpdateState (Map CommandId [Command])

instance HasField "contractId" Command AnyContractId

instance HasField "contractKey" Command AnyContractKey

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 "commandsInFlight" TriggerUpdateState (Map CommandId [Command])

instance HasField "pendingContracts" ACS (Map CommandId [AnyContractId])

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

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 Optional AnyTemplate  
views [InterfaceView]  

instance HasField "activeContracts" ActiveContracts [Created]

instance HasField "argument" Created (Optional AnyTemplate)

instance HasField "contractId" Created AnyContractId

instance HasField "eventId" Created EventId

instance HasField "views" Created [InterfaceView]

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" (BatchTrigger s) ([Message] -> TriggerRule s ())

instance HasField "update" (Trigger s) (Message -> TriggerRule s ())

instance HasField "updateState" (Trigger s) (Message -> TriggerUpdateA s ())

data RegisteredTemplates

AllTemplates

Listen to events for all templates known by the triggers’ runner.

RegisteredTemplates [RegisteredTemplate]

instance HasField "registeredTemplates" (BatchTrigger s) RegisteredTemplates

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

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 TriggerConfig

TriggerConfig

Field Type Description
maxInFlightCommands Int maximum number of commands that should be allowed to be in-flight at any point in time. Exceeding this value will eventually lead to the trigger run raising an InFlightCommandOverflowException exception.
maxActiveContracts Int maximum number of active contracts that we will allow to be stored Exceeding this value will lead to the trigger runner raising an ACSOverflowException exception.

instance HasField "config" (TriggerAState s) TriggerConfig

instance HasField "config" (TriggerState s) TriggerConfig

instance HasField "config" TriggerSetupArguments TriggerConfig

instance HasField "maxActiveContracts" TriggerConfig Int

instance HasField "maxInFlightCommands" TriggerConfig Int

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" (BatchTrigger s) ([Message] -> TriggerRule s ())

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" (BatchTrigger s) (TriggerSetupArguments -> TriggerSetup s)

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

instance HasField "runTriggerSetup" (TriggerSetup a) (Free TriggerF a)

data TriggerSetupArguments

TriggerSetupArguments

Field Type Description
actAs Party  
readAs [Party]  
acs ActiveContracts  
config TriggerConfig  

instance HasField "acs" TriggerSetupArguments ActiveContracts

instance HasField "actAs" TriggerSetupArguments Party

instance HasField "config" TriggerSetupArguments TriggerConfig

instance HasField "initialState" (BatchTrigger s) (TriggerSetupArguments -> TriggerSetup s)

instance HasField "readAs" TriggerSetupArguments [Party]

Functions

toAnyContractId

: Template t => ContractId t -> AnyContractId

Wrap a ContractId t in AnyContractId.

fromAnyContractId

: Template 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