plutus-pab-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.PAB.Core.ContractInstance.STM

Synopsis

Documentation

data BlockchainEnv Source #

Data about the blockchain that contract instances may be interested in.

Constructors

BlockchainEnv 

Fields

awaitSlot :: Slot -> BlockchainEnv -> STM Slot Source #

Wait until the current slot is greater than or equal to the target slot, then return the current slot.

awaitTime :: POSIXTime -> BlockchainEnv -> STM POSIXTime Source #

Wait until the current time is greater than or equal to the target time, then return the current time.

waitForTxStatusChange :: TxStatus -> TxId -> BlockchainEnv -> STM TxStatus Source #

Wait for the status of a transaction to change.

waitForTxOutStatusChange :: TxOutStatus -> TxOutRef -> BlockchainEnv -> STM TxOutStatus Source #

Wait for the status of a transaction output to change.

currentSlot :: BlockchainEnv -> STM Slot Source #

The current slot number

State of a contract instance

data InstanceState Source #

The state of an active contract instance.

Constructors

InstanceState 

Fields

data OpenEndpoint Source #

An open endpoint that can be responded to.

Constructors

OpenEndpoint 

Fields

data OpenTxOutProducedRequest Source #

Constructors

OpenTxOutProducedRequest 

Fields

data OpenTxOutSpentRequest Source #

A TxOutRef that a contract instance is watching

Constructors

OpenTxOutSpentRequest 

Fields

clearEndpoints :: InstanceState -> STM () Source #

Empty the list of open enpoints that can be called on the instance

addEndpoint :: Request ActiveEndpoint -> InstanceState -> STM () Source #

Add an active endpoint to the instance's list of active endpoints.

addUtxoSpentReq :: Request TxOutRef -> InstanceState -> STM () Source #

Add a new OpenTxOutSpentRequest to the instance's list of utxo spent requests

addUtxoProducedReq :: Request Address -> InstanceState -> STM () Source #

Add a new OpenTxOutProducedRequest to the instance's list of utxo produced requests

setActivity :: Activity -> InstanceState -> STM () Source #

Set the Activity of the instance

setObservableState :: Value -> InstanceState -> STM () Source #

Write a new value into the contract instance's observable state.

openEndpoints :: InstanceState -> STM (Map (RequestID, IterationID) OpenEndpoint) Source #

The list of all endpoints that can be called on the instance

callEndpoint :: OpenEndpoint -> EndpointValue Value -> STM () Source #

Call an endpoint with a JSON value.

finalResult :: ContractInstanceId -> InstancesState -> STM (Maybe Value) Source #

Return the final state of the contract when it is finished (possibly an error)

data Activity Source #

Whether the contract instance is still waiting for an event.

Constructors

Active 
Stopped

Instance was stopped before all requests were handled

Done (Maybe Value)

Instance finished, possibly with an error

Instances

Instances details
Eq Activity Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.STM

Show Activity Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.STM

State of all running contract instances

data InstancesState Source #

State of all contract instances that are currently running

emptyInstancesState :: STM InstancesState Source #

Initialise the InstancesState with an empty value

callEndpointOnInstance :: InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> STM (Maybe NotificationError) Source #

Call an endpoint on a contract instance. Fail immediately if the endpoint is not active.

callEndpointOnInstanceTimeout :: TMVar () -> InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> STM (Maybe NotificationError) Source #

Call an endpoint on a contract instance. If the endpoint is not active, wait until the TMVar is filled, then fail. (if the endpoint becomes active in the meantime it will be called)

observableContractState :: ContractInstanceId -> InstancesState -> STM Value Source #

Get the observable state of the contract instance. Blocks if the state is not available yet.

yieldedExportTxs :: InstanceState -> STM [ExportTx] Source #

The list of all partial txs that need to be balanced on the instance.

instanceState :: ContractInstanceId -> InstancesState -> STM InstanceState Source #

The InstanceState of the contract instance. Retries of the state can't be found in the map.

instanceIDs :: InstancesState -> STM (Set ContractInstanceId) Source #

The IDs of all contract instances

instancesWithStatuses :: InstancesState -> STM (Map ContractInstanceId ContractActivityStatus) Source #

The IDs of contract instances with their statuses

data InstanceClientEnv Source #

Events that the contract instances are waiting for, indexed by keys that are readily available in the node client (ie. that can be produced from just a block without any additional information)