plutus-pab-1.2.0.0
Safe Haskell None
Language Haskell2010

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.

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

Wait for an endpoint response.

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

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 CardanoAddress -> InstanceState -> STM () Source #

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

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

State of all running contract instances

data InstancesState Source #

State of all contract instances that are currently running

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.

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

The IDs of contract instances with their statuses