plutus-pab-1.2.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

emptyBlockchainEnv :: Maybe Int -> Params -> STM BlockchainEnv Source #

Initialise an empty BlockchainEnv value

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.

awaitEndpointResponse :: Request ActiveEndpoint -> InstanceState -> STM (EndpointValue Value) Source #

Wait for an endpoint response.

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

Wait for the status of a transaction to change.

updateTxChangesR :: Either (TVar (UtxoIndex TxIdState)) (IORef TCSIndex) -> (TCSIndex -> IO TCSIndex) -> IO () Source #

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

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

  • oepName :: ActiveEndpoint

    Name of the endpoint

  • oepResponse :: TMVar (EndpointValue Value)

    A place to write the response to.

data OpenTxOutProducedRequest Source #

Constructors

OpenTxOutProducedRequest 

Fields

  • otxAddress :: CardanoAddress

    Address that the contract instance is watching (TODO: Should be ViewAddress -- SCP-2628)

  • otxProducingTxns :: TMVar (NonEmpty ChainIndexTx)

    A place to write the producing transactions to

data OpenTxOutSpentRequest Source #

A TxOutRef that a contract instance is watching

Constructors

OpenTxOutSpentRequest 

Fields

  • osrOutRef :: TxOutRef

    The TxOutRef that the instance is watching

  • osrSpendingTx :: TMVar ChainIndexTx

    A place to write the spending transaction to

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

waitForUtxoSpent :: Request TxOutRef -> InstanceState -> STM ChainIndexTx Source #

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

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

waitForUtxoProduced :: Request CardanoAddress -> InstanceState -> STM (NonEmpty ChainIndexTx) Source #

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 :: InstanceState -> 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 :: IO InstancesState Source #

Initialise the InstancesState with an empty value

callEndpointOnInstance :: InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> IO (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 -> IO (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 :: InstanceState -> 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 -> IO (Maybe InstanceState) Source #

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

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

The IDs of all contract instances

instancesWithStatuses :: InstancesState -> IO (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)