Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Simulation t a = PABAction t ( SimulatorState t) a
- data SimulatorState t
- type SimulatorContractHandler t = forall effs. ( Member ( Error PABError ) effs, Member ( LogMsg ( PABMultiAgentMsg t)) effs) => Eff ( ContractEffect t ': effs) ~> Eff effs
- runSimulationWith :: SimulatorEffectHandlers t -> Simulation t a -> IO ( Either PABError a)
- type SimulatorEffectHandlers t = EffectHandlers t ( SimulatorState t)
- mkSimulatorHandlers :: forall t. ( Pretty ( ContractDef t), HasDefinitions ( ContractDef t)) => Params -> SimulatorContractHandler t -> SimulatorEffectHandlers t
- addWallet :: forall t. Simulation t (Wallet, PaymentPubKeyHash)
- addWalletWith :: forall t. Maybe Ada -> Simulation t (Wallet, PaymentPubKeyHash)
- logString :: forall t effs. Member ( LogMsg ( PABMultiAgentMsg t)) effs => String -> Eff effs ()
- payToWallet :: forall t. Wallet -> Wallet -> Value -> Simulation t CardanoTx
- payToPaymentPublicKeyHash :: forall t. Wallet -> PaymentPubKeyHash -> Value -> Simulation t CardanoTx
- activateContract :: forall t. PABContract t => Wallet -> ContractDef t -> Simulation t ContractInstanceId
- callEndpointOnInstance :: forall a t. ToJSON a => ContractInstanceId -> String -> a -> Simulation t ( Maybe NotificationError)
- handleAgentThread :: forall t a. Wallet -> Maybe ContractInstanceId -> Eff ( ContractInstanceEffects t ( SimulatorState t) '[ IO ]) a -> Simulation t a
- data Activity
- stopInstance :: forall t. ContractInstanceId -> Simulation t ()
- instanceActivity :: forall t. ContractInstanceId -> Simulation t Activity
- makeBlock :: forall t effs. ( LastMember IO effs, Member ( Reader ( SimulatorState t)) effs, Member ( Reader BlockchainEnv ) effs, Member ( Reader InstancesState ) effs, Member DelayEffect effs, Member TimeEffect effs) => Eff effs ()
- instanceState :: forall t. Wallet -> ContractInstanceId -> Simulation t ( State t)
- observableState :: forall t. ContractInstanceId -> Simulation t ( STM Value )
- waitForState :: forall t a. ( Value -> Maybe a) -> ContractInstanceId -> Simulation t a
- waitForInstanceState :: forall t. ( InstanceState -> STM ( Maybe ContractActivityStatus)) -> ContractInstanceId -> Simulation t ContractActivityStatus
- waitForInstanceStateWithResult :: forall t. ContractInstanceId -> Simulation t ContractActivityStatus
- activeEndpoints :: forall t. ContractInstanceId -> Simulation t ( STM [ OpenEndpoint ])
- waitForEndpoint :: forall t. ContractInstanceId -> String -> Simulation t ()
- waitForTxStatusChange :: forall t. TxId -> Simulation t TxStatus
- waitForTxOutStatusChange :: forall t. TxOutRef -> Simulation t TxOutStatus
- currentSlot :: forall t. Simulation t ( STM Slot)
- waitUntilSlot :: forall t. Slot -> Simulation t ()
- waitNSlots :: forall t. Int -> Simulation t ()
- activeContracts :: forall t. Simulation t ( Set ContractInstanceId )
- finalResult :: forall t. ContractInstanceId -> Simulation t ( STM ( Maybe Value ))
- waitUntilFinished :: forall t. ContractInstanceId -> Simulation t ( Maybe Value )
- valueAt :: forall t. CardanoAddress -> Simulation t Value
- valueAtSTM :: forall t. CardanoAddress -> Simulation t ( STM Value )
- walletFees :: forall t. Wallet -> Simulation t Lovelace
- blockchain :: forall t. Simulation t Blockchain
- currentBalances :: forall t. Simulation t ( Map Entity Value )
- logBalances :: forall t effs. Member ( LogMsg ( PABMultiAgentMsg t)) effs => Map Entity Value -> Eff effs ()
-
data
TxCounts
=
TxCounts
{
- _txValidated :: Int
- _txMemPool :: Int
- txCounts :: forall t. Simulation t TxCounts
- txCountsSTM :: forall t. Simulation t ( STM TxCounts )
- txValidated :: Lens' TxCounts Int
- txMemPool :: Lens' TxCounts Int
- waitForValidatedTxCount :: forall t. Int -> Simulation t ()
Documentation
type Simulation t a = PABAction t ( SimulatorState t) a Source #
data SimulatorState t Source #
Run with user-defined contracts
type SimulatorContractHandler t = forall effs. ( Member ( Error PABError ) effs, Member ( LogMsg ( PABMultiAgentMsg t)) effs) => Eff ( ContractEffect t ': effs) ~> Eff effs Source #
A handler for the
ContractEffect
of
t
that can run contracts in a
simulated environment.
runSimulationWith :: SimulatorEffectHandlers t -> Simulation t a -> IO ( Either PABError a) Source #
type SimulatorEffectHandlers t = EffectHandlers t ( SimulatorState t) Source #
:: forall t. ( Pretty ( ContractDef t), HasDefinitions ( ContractDef t)) | |
=> Params | |
-> SimulatorContractHandler t |
Making calls to the contract (see
|
-> SimulatorEffectHandlers t |
Build
EffectHandlers
for running a contract in the simulator.
addWallet :: forall t. Simulation t (Wallet, PaymentPubKeyHash) Source #
Create a new wallet with a random key, give it some funds and add it to the list of simulated wallets.
addWalletWith :: forall t. Maybe Ada -> Simulation t (Wallet, PaymentPubKeyHash) Source #
Create a new wallet with a random key, give it provided funds and add it to the list of simulated wallets.
Logging
logString :: forall t effs. Member ( LogMsg ( PABMultiAgentMsg t)) effs => String -> Eff effs () Source #
Log some output to the console
Agent actions
payToWallet :: forall t. Wallet -> Wallet -> Value -> Simulation t CardanoTx Source #
Make a payment from one wallet to another
payToPaymentPublicKeyHash :: forall t. Wallet -> PaymentPubKeyHash -> Value -> Simulation t CardanoTx Source #
Make a payment from one wallet to a public key address
activateContract :: forall t. PABContract t => Wallet -> ContractDef t -> Simulation t ContractInstanceId Source #
Start a new instance of a contract
callEndpointOnInstance :: forall a t. ToJSON a => ContractInstanceId -> String -> a -> Simulation t ( Maybe NotificationError) Source #
Call a named endpoint on a contract instance
handleAgentThread :: forall t a. Wallet -> Maybe ContractInstanceId -> Eff ( ContractInstanceEffects t ( SimulatorState t) '[ IO ]) a -> Simulation t a Source #
Whether the contract instance is still waiting for an event.
Active | |
Stopped |
Instance was stopped before all requests were handled |
Done ( Maybe Value ) |
Instance finished, possibly with an error |
stopInstance :: forall t. ContractInstanceId -> Simulation t () Source #
Stop the instance.
instanceActivity :: forall t. ContractInstanceId -> Simulation t Activity Source #
The
Activity
state of the instance
Control actions
makeBlock :: forall t effs. ( LastMember IO effs, Member ( Reader ( SimulatorState t)) effs, Member ( Reader BlockchainEnv ) effs, Member ( Reader InstancesState ) effs, Member DelayEffect effs, Member TimeEffect effs) => Eff effs () Source #
Wait 1 slot length, then add a new block.
Querying the state
instanceState :: forall t. Wallet -> ContractInstanceId -> Simulation t ( State t) Source #
Get the current state of the contract instance.
observableState :: forall t. ContractInstanceId -> Simulation t ( STM Value ) Source #
An STM transaction that returns the observable state of the contract instance.
waitForState :: forall t a. ( Value -> Maybe a) -> ContractInstanceId -> Simulation t a Source #
Wait until the observable state of the instance matches a predicate.
waitForInstanceState :: forall t. ( InstanceState -> STM ( Maybe ContractActivityStatus)) -> ContractInstanceId -> Simulation t ContractActivityStatus Source #
waitForInstanceStateWithResult :: forall t. ContractInstanceId -> Simulation t ContractActivityStatus Source #
activeEndpoints :: forall t. ContractInstanceId -> Simulation t ( STM [ OpenEndpoint ]) Source #
The list of endpoints that are currently open
waitForEndpoint :: forall t. ContractInstanceId -> String -> Simulation t () Source #
Wait until the endpoint becomes active.
waitForTxStatusChange :: forall t. TxId -> Simulation t TxStatus Source #
Wait until the status of the transaction changes
waitForTxOutStatusChange :: forall t. TxOutRef -> Simulation t TxOutStatus Source #
Wait until the status of the transaction changes
currentSlot :: forall t. Simulation t ( STM Slot) Source #
waitUntilSlot :: forall t. Slot -> Simulation t () Source #
Wait until the target slot number has been reached
waitNSlots :: forall t. Int -> Simulation t () Source #
Wait for the given number of slots.
activeContracts :: forall t. Simulation t ( Set ContractInstanceId ) Source #
The set of all active contracts.
finalResult :: forall t. ContractInstanceId -> Simulation t ( STM ( Maybe Value )) Source #
The final result of the instance (waits until it is available)
waitUntilFinished :: forall t. ContractInstanceId -> Simulation t ( Maybe Value ) Source #
Wait until the contract is done, then return the error (if any)
valueAt :: forall t. CardanoAddress -> Simulation t Value Source #
The total value currently at an address
valueAtSTM :: forall t. CardanoAddress -> Simulation t ( STM Value ) Source #
The total value currently at an address
walletFees :: forall t. Wallet -> Simulation t Lovelace Source #
The fees paid by the wallet.
blockchain :: forall t. Simulation t Blockchain Source #
The entire chain (newest transactions first)
currentBalances :: forall t. Simulation t ( Map Entity Value ) Source #
Retrieve the balances of all the entities in the simulator.
logBalances :: forall t effs. Member ( LogMsg ( PABMultiAgentMsg t)) effs => Map Entity Value -> Eff effs () Source #
Write the
balances
out to the log.
Transaction counts
Statistics about the transactions that have been validated by the emulated node.
TxCounts | |
|
Instances
Eq TxCounts Source # | |
Ord TxCounts Source # | |
Defined in Plutus.PAB.Simulator |
|
Show TxCounts Source # | |
txCountsSTM :: forall t. Simulation t ( STM TxCounts ) Source #
Get an STM transaction with the
TxCounts
of the emulated blockchain
waitForValidatedTxCount :: forall t. Int -> Simulation t () Source #
Wait until at least the given number of valid transactions are on the simulated blockchain.