Safe Haskell | None |
---|---|
Language | Haskell2010 |
Plutus.PAB.Core.ContractInstance.STM
Synopsis
- data BlockchainEnv = BlockchainEnv {}
- emptyBlockchainEnv :: Maybe Int -> SlotConfig -> STM BlockchainEnv
- awaitSlot :: Slot -> BlockchainEnv -> STM Slot
- awaitTime :: POSIXTime -> BlockchainEnv -> STM POSIXTime
- awaitEndpointResponse :: Request ActiveEndpoint -> InstanceState -> STM (EndpointValue Value)
- waitForTxStatusChange :: TxStatus -> TxId -> BlockchainEnv -> STM TxStatus
- waitForTxOutStatusChange :: TxOutStatus -> TxOutRef -> BlockchainEnv -> STM TxOutStatus
- currentSlot :: BlockchainEnv -> STM Slot
- data InstanceState = InstanceState {
- issEndpoints :: TVar (Map (RequestID, IterationID) OpenEndpoint)
- issStatus :: TVar Activity
- issObservableState :: TVar (Maybe Value)
- issStop :: TMVar ()
- issTxOutRefs :: TVar (Map (RequestID, IterationID) OpenTxOutSpentRequest)
- issAddressRefs :: TVar (Map (RequestID, IterationID) OpenTxOutProducedRequest)
- issYieldedExportTxs :: TVar [ExportTx]
- emptyInstanceState :: STM InstanceState
- data OpenEndpoint = OpenEndpoint {}
- data OpenTxOutProducedRequest = OpenTxOutProducedRequest {}
- data OpenTxOutSpentRequest = OpenTxOutSpentRequest {}
- clearEndpoints :: InstanceState -> STM ()
- addEndpoint :: Request ActiveEndpoint -> InstanceState -> STM ()
- addUtxoSpentReq :: Request TxOutRef -> InstanceState -> STM ()
- waitForUtxoSpent :: Request TxOutRef -> InstanceState -> STM ChainIndexTx
- addUtxoProducedReq :: Request Address -> InstanceState -> STM ()
- waitForUtxoProduced :: Request Address -> InstanceState -> STM (NonEmpty ChainIndexTx)
- setActivity :: Activity -> InstanceState -> STM ()
- setObservableState :: Value -> InstanceState -> STM ()
- openEndpoints :: InstanceState -> STM (Map (RequestID, IterationID) OpenEndpoint)
- callEndpoint :: OpenEndpoint -> EndpointValue Value -> STM ()
- finalResult :: ContractInstanceId -> InstancesState -> STM (Maybe Value)
- data Activity
- data InstancesState
- emptyInstancesState :: STM InstancesState
- insertInstance :: ContractInstanceId -> InstanceState -> InstancesState -> STM ()
- callEndpointOnInstance :: InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> STM (Maybe NotificationError)
- callEndpointOnInstanceTimeout :: TMVar () -> InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> STM (Maybe NotificationError)
- observableContractState :: ContractInstanceId -> InstancesState -> STM Value
- yieldedExportTxs :: InstanceState -> STM [ExportTx]
- instanceState :: ContractInstanceId -> InstancesState -> STM InstanceState
- instanceIDs :: InstancesState -> STM (Set ContractInstanceId)
- instancesWithStatuses :: InstancesState -> STM (Map ContractInstanceId ContractActivityStatus)
- instancesClientEnv :: InstancesState -> STM InstanceClientEnv
- data InstanceClientEnv = InstanceClientEnv {}
Documentation
data BlockchainEnv Source #
Data about the blockchain that contract instances may be interested in.
Constructors
BlockchainEnv | |
Fields
|
emptyBlockchainEnv :: Maybe Int -> SlotConfig -> 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.
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
|
emptyInstanceState :: STM InstanceState Source #
An InstanceState
value with empty 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
waitForUtxoProduced :: Request Address -> 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 :: ContractInstanceId -> InstancesState -> STM (Maybe Value) Source #
Return the final state of the contract when it is finished (possibly an error)
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
emptyInstancesState :: STM InstancesState Source #
Initialise the InstancesState
with an empty value
insertInstance :: ContractInstanceId -> InstanceState -> InstancesState -> STM () Source #
Insert an InstanceState
value into the InstancesState
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)
Constructors
InstanceClientEnv | |
Instances
Semigroup InstanceClientEnv Source # | |
Defined in Plutus.PAB.Core.ContractInstance.STM Methods (<>) :: InstanceClientEnv -> InstanceClientEnv -> InstanceClientEnv Source # sconcat :: NonEmpty InstanceClientEnv -> InstanceClientEnv Source # stimes :: Integral b => b -> InstanceClientEnv -> InstanceClientEnv Source # | |
Monoid InstanceClientEnv Source # | |
Defined in Plutus.PAB.Core.ContractInstance.STM Methods mempty :: InstanceClientEnv Source # mappend :: InstanceClientEnv -> InstanceClientEnv -> InstanceClientEnv Source # mconcat :: [InstanceClientEnv] -> InstanceClientEnv Source # |