Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Minimal mockchain
Synopsis
- type ERA = BabbageEra StandardCrypto
- data MockChainState = MockChainState {
- mcsEnv ∷ MempoolEnv ERA
- mcsPoolState ∷ MempoolState ERA
- mcsTransactions ∷ [(Validated (Tx ERA), [ScriptContext ERA])]
- mcsDatums ∷ Map (Hash ScriptData) ScriptData
- type InitialUTXOs = [(Wallet, Coin)]
- initialState ∷ NodeParams → MockChainState
- initialStateFor ∷ NodeParams → InitialUTXOs → MockChainState
- genesisUTxO ∷ ∀ era capiEra. (EraCrypto era ~ StandardCrypto, EraTxOut era) ⇒ [(AddressInEra capiEra, Coin)] → UTxO era
- env ∷ Lens' MockChainState (MempoolEnv ERA)
- poolState ∷ Lens' MockChainState (MempoolState ERA)
- transactions ∷ Lens' MockChainState [(Validated (Tx ERA), [ScriptContext ERA])]
- utxoSet ∷ MonadMockchain m ⇒ m (UtxoSet CtxUTxO ())
- datums ∷ Lens' MockChainState (Map (Hash ScriptData) ScriptData)
- walletUtxo ∷ MonadMockchain m ⇒ Wallet → m (UtxoSet CtxUTxO ())
- fromLedgerUTxO ∷ ShelleyLedgerEra era ~ ledgerera ⇒ EraCrypto ledgerera ~ StandardCrypto ⇒ ShelleyBasedEra era → UTxO ledgerera → UTxO era
- data ExUnitsError
- _Phase1Error ∷ Prism' ExUnitsError TransactionValidityError
- _Phase2Error ∷ Prism' ExUnitsError ScriptExecutionError
- data ValidationError
- _VExUnits ∷ Prism' ValidationError ExUnitsError
- _PredicateFailures ∷ Prism' ValidationError [CollectError ERA]
- _ApplyTxFailure ∷ Prism' ValidationError (ApplyTxError ERA)
- getTxExUnits ∷ NodeParams → UTxO ERA → Tx BabbageEra → Either ExUnitsError (Map ScriptWitnessIndex ExecutionUnits)
- evaluateTx ∷ NodeParams → SlotNo → UTxO ERA → Tx BabbageEra → Either ValidationError [ScriptContext ERA]
- applyTransaction ∷ NodeParams → MockChainState → Tx BabbageEra → Either ValidationError (MockChainState, Validated (Tx ERA))
- type ScriptContext era = (ShortByteString, Language, [Data era], ExUnits, CostModel)
- fullyAppliedScript ∷ NodeParams → ScriptContext ERA → Either String (Program NamedDeBruijn DefaultUni DefaultFun ())
- data MockchainError
- newtype MockchainT m a = MockchainT (ReaderT NodeParams (StateT MockChainState (ExceptT MockchainError m)) a)
- type Mockchain a = MockchainT Identity a
- runMockchainT ∷ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError (a, MockChainState))
- runMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError (a, MockChainState)
- runMockchain0 ∷ InitialUTXOs → Mockchain a → Either MockchainError (a, MockChainState)
- evalMockchainT ∷ Functor m ⇒ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError a)
- evalMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError a
- evalMockchain0 ∷ InitialUTXOs → Mockchain a → Either MockchainError a
- execMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError MockChainState
- execMockchainT ∷ Functor m ⇒ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError MockChainState)
- execMockchain0 ∷ InitialUTXOs → Mockchain a → Either MockchainError MockChainState
- type MockchainIO a = MockchainT IO a
- runMockchainIO ∷ MockchainIO a → NodeParams → MockChainState → IO (Either MockchainError (a, MockChainState))
- runMockchain0IO ∷ InitialUTXOs → MockchainIO a → IO (Either MockchainError (a, MockChainState))
- runMockchain0IOWith ∷ InitialUTXOs → NodeParams → MockchainIO a → IO (Either MockchainError (a, MockChainState))
- evalMockchainIO ∷ MockchainIO a → NodeParams → MockChainState → IO (Either MockchainError a)
- evalMockchain0IO ∷ InitialUTXOs → MockchainIO a → IO (Either MockchainError a)
- execMockchainIO ∷ MockchainIO a → NodeParams → MockChainState → IO (Either MockchainError MockChainState)
- execMockchain0IO ∷ InitialUTXOs → MockchainIO a → IO (Either MockchainError MockChainState)
State of the mockchain
type ERA = BabbageEra StandardCrypto Source #
data MockChainState Source #
MockChainState | |
|
type InitialUTXOs = [(Wallet, Coin)] Source #
initialStateFor ∷ NodeParams → InitialUTXOs → MockChainState Source #
Initialise the MockChainState
with a list of UTxOs
genesisUTxO ∷ ∀ era capiEra. (EraCrypto era ~ StandardCrypto, EraTxOut era) ⇒ [(AddressInEra capiEra, Coin)] → UTxO era Source #
transactions ∷ Lens' MockChainState [(Validated (Tx ERA), [ScriptContext ERA])] Source #
walletUtxo ∷ MonadMockchain m ⇒ Wallet → m (UtxoSet CtxUTxO ()) Source #
The wallet's transaction outputs on the mockchain
fromLedgerUTxO ∷ ShelleyLedgerEra era ~ ledgerera ⇒ EraCrypto ledgerera ~ StandardCrypto ⇒ ShelleyBasedEra era → UTxO ledgerera → UTxO era Source #
Transaction validation
data ExUnitsError Source #
Instances
Show ExUnitsError Source # | |
Defined in Convex.MockChain |
data ValidationError Source #
Instances
Show ValidationError Source # | |
Defined in Convex.MockChain |
getTxExUnits ∷ NodeParams → UTxO ERA → Tx BabbageEra → Either ExUnitsError (Map ScriptWitnessIndex ExecutionUnits) Source #
Compute the exunits of a transaction
evaluateTx ∷ NodeParams → SlotNo → UTxO ERA → Tx BabbageEra → Either ValidationError [ScriptContext ERA] Source #
Evaluate a transaction, returning all of its script contexts.
applyTransaction ∷ NodeParams → MockChainState → Tx BabbageEra → Either ValidationError (MockChainState, Validated (Tx ERA)) Source #
Plutus scripts
type ScriptContext era = (ShortByteString, Language, [Data era], ExUnits, CostModel) Source #
All the information needed to evaluate a Plutus script: The script itself, the script language, redeemers and datums, execution units required, and the cost model.
fullyAppliedScript ∷ NodeParams → ScriptContext ERA → Either String (Program NamedDeBruijn DefaultUni DefaultFun ()) Source #
Apply the plutus script to all its arguments and return a plutus program
Mockchain implementation
data MockchainError Source #
Instances
Show MockchainError Source # | |
Defined in Convex.MockChain |
newtype MockchainT m a Source #
Instances
type Mockchain a = MockchainT Identity a Source #
runMockchainT ∷ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError (a, MockChainState)) Source #
Run the MockchainT
action with the NodeParams
from an initial state
runMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError (a, MockChainState) Source #
runMockchain0 ∷ InitialUTXOs → Mockchain a → Either MockchainError (a, MockChainState) Source #
Run the mockchain action with an initial distribution, using the default node parameters
evalMockchainT ∷ Functor m ⇒ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError a) Source #
evalMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError a Source #
evalMockchain0 ∷ InitialUTXOs → Mockchain a → Either MockchainError a Source #
execMockchain ∷ Mockchain a → NodeParams → MockChainState → Either MockchainError MockChainState Source #
execMockchainT ∷ Functor m ⇒ MockchainT m a → NodeParams → MockChainState → m (Either MockchainError MockChainState) Source #
MockchainIO
type MockchainIO a = MockchainT IO a Source #
runMockchainIO ∷ MockchainIO a → NodeParams → MockChainState → IO (Either MockchainError (a, MockChainState)) Source #
runMockchain0IO ∷ InitialUTXOs → MockchainIO a → IO (Either MockchainError (a, MockChainState)) Source #
Run the mockchain IO action with an initial distribution, using the default node parameters
runMockchain0IOWith ∷ InitialUTXOs → NodeParams → MockchainIO a → IO (Either MockchainError (a, MockChainState)) Source #
Run the mockchain IO action with an initial distribution and a given set of node params
evalMockchainIO ∷ MockchainIO a → NodeParams → MockChainState → IO (Either MockchainError a) Source #
evalMockchain0IO ∷ InitialUTXOs → MockchainIO a → IO (Either MockchainError a) Source #