Safe Haskell | None |
---|---|
Language | Haskell2010 |
Transaction validation using 'cardano-ledger-specs'
Synopsis
- type EmulatorBlock = [Validated (Tx EmulatorEra)]
- data EmulatedLedgerState = EmulatedLedgerState {
- _ledgerEnv :: !(MempoolEnv EmulatorEra)
- _memPoolState :: !(MempoolState EmulatorEra)
- _currentBlock :: !EmulatorBlock
- _previousBlocks :: ![EmulatorBlock]
- newtype Coin = Coin {}
- newtype SlotNo = SlotNo {}
- type EmulatorEra = BabbageEra StandardCrypto
- type CardanoLedgerError = Either ValidationErrorInPhase ToCardanoError
- initialState :: Params -> EmulatedLedgerState
- hasValidationErrors :: Params -> SlotNo -> UtxoIndex -> Tx BabbageEra -> ValidationResult
- makeTransactionBody :: Params -> UTxO EmulatorEra -> CardanoBuildTx -> Either CardanoLedgerError (TxBody BabbageEra)
- validateCardanoTx :: Params -> Slot -> UtxoIndex -> CardanoTx -> ValidationResult
- unsafeMakeValid :: CardanoTx -> OnChainTx
- makeBlock :: EmulatedLedgerState -> EmulatedLedgerState
- setSlot :: SlotNo -> EmulatedLedgerState -> EmulatedLedgerState
- nextSlot :: EmulatedLedgerState -> EmulatedLedgerState
- newtype UTxO era = UTxO {
- unUTxO :: Map (TxIn (Crypto era)) (TxOut era)
- setUtxo :: UTxO EmulatorEra -> EmulatedLedgerState -> EmulatedLedgerState
- ledgerEnv :: Lens' EmulatedLedgerState (MempoolEnv EmulatorEra)
- memPoolState :: Lens' EmulatedLedgerState (MempoolState EmulatorEra)
- currentBlock :: Lens' EmulatedLedgerState EmulatorBlock
- previousBlocks :: Lens' EmulatedLedgerState [EmulatorBlock]
- emulatorGlobals :: Params -> Globals
Documentation
type EmulatorBlock = [Validated (Tx EmulatorEra)] Source #
data EmulatedLedgerState Source #
State of the ledger with configuration, mempool, and the blockchain.
EmulatedLedgerState | |
|
Instances
Instances
Enum Coin | |
Eq Coin | |
Ord Coin | |
Show Coin | |
Generic Coin | |
Semigroup Coin | |
Monoid Coin | |
NFData Coin | |
Defined in Cardano.Ledger.Coin | |
FromJSON Coin | |
Defined in Cardano.Ledger.Coin parseJSON :: Value -> Parser Coin parseJSONList :: Value -> Parser [Coin] | |
ToJSON Coin | |
Defined in Cardano.Ledger.Coin | |
NoThunks Coin | |
ToCBOR Coin | |
Defined in Cardano.Ledger.Coin encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy Coin -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Coin] -> Size | |
FromCBOR Coin | |
Compactible Coin | |
Defined in Cardano.Ledger.Coin data CompactForm Coin | |
DecodeNonNegative Coin | |
Defined in Cardano.Ledger.Val decodeNonNegative :: Decoder s Coin | |
DecodeMint Coin | |
Defined in Cardano.Ledger.Val decodeMint :: Decoder s Coin | |
Val Coin | |
Abelian Coin | |
Defined in Cardano.Ledger.Coin | |
HeapWords Coin | |
Defined in Cardano.Ledger.Coin | |
Group Coin | |
PartialOrd Coin | |
EncodeMint Coin | |
Defined in Cardano.Ledger.Val encodeMint :: Coin -> Encoding | |
HasField "txfee" (TxBody era) Coin | |
Defined in Cardano.Ledger.ShelleyMA.TxBody | |
HasField "txfee" (TxBody era) Coin | |
Defined in Cardano.Ledger.Shelley.TxBody | |
HasField "txfee" (TxBody era) Coin | |
Defined in Cardano.Ledger.Babbage.TxBody | |
HasField "txfee" (TxBody era) Coin | |
Defined in Cardano.Ledger.Alonzo.TxBody | |
HasField "totalCollateral" (TxBody era) (StrictMaybe Coin) | |
Defined in Cardano.Ledger.Babbage.TxBody | |
Eq (CompactForm Coin) | |
Show (CompactForm Coin) | |
NFData (CompactForm Coin) | |
Defined in Cardano.Ledger.Coin | |
NoThunks (CompactForm Coin) | |
ToCBOR (CompactForm Coin) | |
Defined in Cardano.Ledger.Coin toCBOR :: CompactForm Coin -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (CompactForm Coin) -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [CompactForm Coin] -> Size | |
FromCBOR (CompactForm Coin) | |
HeapWords (CompactForm Coin) | |
Defined in Cardano.Ledger.Coin | |
Prim (CompactForm Coin) | |
Defined in Cardano.Ledger.Coin sizeOf# :: CompactForm Coin -> Int# alignment# :: CompactForm Coin -> Int# indexByteArray# :: ByteArray# -> Int# -> CompactForm Coin readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CompactForm Coin #) writeByteArray# :: MutableByteArray# s -> Int# -> CompactForm Coin -> State# s -> State# s setByteArray# :: MutableByteArray# s -> Int# -> Int# -> CompactForm Coin -> State# s -> State# s indexOffAddr# :: Addr# -> Int# -> CompactForm Coin readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, CompactForm Coin #) writeOffAddr# :: Addr# -> Int# -> CompactForm Coin -> State# s -> State# s setOffAddr# :: Addr# -> Int# -> Int# -> CompactForm Coin -> State# s -> State# s | |
type Rep Coin | |
Defined in Cardano.Ledger.Coin | |
newtype CompactForm Coin | |
Defined in Cardano.Ledger.Coin |
Instances
Bounded SlotNo | |
Enum SlotNo | |
Defined in Cardano.Slotting.Slot succ :: SlotNo -> SlotNo Source # pred :: SlotNo -> SlotNo Source # toEnum :: Int -> SlotNo Source # fromEnum :: SlotNo -> Int Source # enumFrom :: SlotNo -> [SlotNo] Source # enumFromThen :: SlotNo -> SlotNo -> [SlotNo] Source # enumFromTo :: SlotNo -> SlotNo -> [SlotNo] Source # enumFromThenTo :: SlotNo -> SlotNo -> SlotNo -> [SlotNo] Source # | |
Eq SlotNo | |
Num SlotNo | |
Defined in Cardano.Slotting.Slot | |
Ord SlotNo | |
Defined in Cardano.Slotting.Slot | |
Show SlotNo | |
Generic SlotNo | |
NFData SlotNo | |
Defined in Cardano.Slotting.Slot | |
Serialise SlotNo | |
Defined in Cardano.Slotting.Slot encodeList :: [SlotNo] -> Encoding decodeList :: Decoder s [SlotNo] | |
FromJSON SlotNo | |
Defined in Cardano.Slotting.Slot parseJSON :: Value -> Parser SlotNo parseJSONList :: Value -> Parser [SlotNo] | |
ToJSON SlotNo | |
Defined in Cardano.Slotting.Slot toEncoding :: SlotNo -> Encoding toJSONList :: [SlotNo] -> Value toEncodingList :: [SlotNo] -> Encoding | |
NoThunks SlotNo | |
ToCBOR SlotNo | |
Defined in Cardano.Slotting.Slot encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SlotNo -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SlotNo] -> Size | |
FromCBOR SlotNo | |
HasField "ttl" (TxBody era) SlotNo | |
Defined in Cardano.Ledger.Shelley.TxBody | |
HasHeader block => Anchorable (WithOrigin SlotNo) (Anchor block) block | |
Defined in Ouroboros.Network.AnchoredFragment asAnchor :: block -> Anchor block getAnchorMeasure :: Proxy block -> Anchor block -> WithOrigin SlotNo | |
Anchorable (WithOrigin SlotNo) (HeaderState blk) (HeaderState blk) | |
Defined in Ouroboros.Consensus.HeaderValidation asAnchor :: HeaderState blk -> HeaderState blk getAnchorMeasure :: Proxy (HeaderState blk) -> HeaderState blk -> WithOrigin SlotNo | |
GetTip l => Anchorable (WithOrigin SlotNo) (Checkpoint l) (Checkpoint l) | |
Defined in Ouroboros.Consensus.Storage.LedgerDB.InMemory asAnchor :: Checkpoint l -> Checkpoint l getAnchorMeasure :: Proxy (Checkpoint l) -> Checkpoint l -> WithOrigin SlotNo | |
Embed (StakeCreds era) (Map (Credential 'Staking era) SlotNo) | |
Defined in Cardano.Ledger.Shelley.TxBody | |
HasExp (StakeCreds era) (Map (Credential 'Staking era) SlotNo) | |
Defined in Cardano.Ledger.Shelley.TxBody | |
type Rep SlotNo | |
Defined in Cardano.Slotting.Slot |
type EmulatorEra = BabbageEra StandardCrypto Source #
The default era for the emulator
type CardanoLedgerError = Either ValidationErrorInPhase ToCardanoError Source #
initialState :: Params -> EmulatedLedgerState Source #
Initial ledger state for a distribution
hasValidationErrors :: Params -> SlotNo -> UtxoIndex -> Tx BabbageEra -> ValidationResult Source #
makeTransactionBody :: Params -> UTxO EmulatorEra -> CardanoBuildTx -> Either CardanoLedgerError (TxBody BabbageEra) Source #
validateCardanoTx :: Params -> Slot -> UtxoIndex -> CardanoTx -> ValidationResult Source #
unsafeMakeValid :: CardanoTx -> OnChainTx Source #
Modifying the state
makeBlock :: EmulatedLedgerState -> EmulatedLedgerState Source #
Make a block with all transactions that have been validated in the current block, add the block to the blockchain, and empty the current block.
setSlot :: SlotNo -> EmulatedLedgerState -> EmulatedLedgerState Source #
Set the slot number
nextSlot :: EmulatedLedgerState -> EmulatedLedgerState Source #
Increase the slot number by one
Instances
(Eq (TxOut era), Crypto (Crypto era)) => Eq (UTxO era) | |
(Show (TxOut era), Crypto (Crypto era)) => Show (UTxO era) | |
Generic (UTxO era) | |
Semigroup (UTxO era) | |
Crypto (Crypto era) => Monoid (UTxO era) | |
(Era era, NFData (TxOut era)) => NFData (UTxO era) | |
Defined in Cardano.Ledger.Shelley.UTxO | |
Default (UTxO era) | |
Defined in Cardano.Ledger.Shelley.UTxO | |
TransUTxO NoThunks era => NoThunks (UTxO era) | |
(Era era, ToCBOR (TxOut era)) => ToCBOR (UTxO era) | |
Defined in Cardano.Ledger.Shelley.UTxO toCBOR :: UTxO era -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (UTxO era) -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [UTxO era] -> Size | |
(FromCBOR (TxOut era), Era era) => FromCBOR (UTxO era) | |
(Crypto (Crypto era), FromSharedCBOR (TxOut era), Share (TxOut era) ~ Interns (Credential 'Staking (Crypto era))) => FromSharedCBOR (UTxO era) | |
type Rep (UTxO era) | |
Defined in Cardano.Ledger.Shelley.UTxO type Rep (UTxO era) = D1 ('MetaData "UTxO" "Cardano.Ledger.Shelley.UTxO" "cardano-ledger-shelley-0.1.0.0-IAEP382Vf9o9lj3qcjJd5h" 'True) (C1 ('MetaCons "UTxO" 'PrefixI 'True) (S1 ('MetaSel ('Just "unUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map (TxIn (Crypto era)) (TxOut era))))) | |
type Share (UTxO era) | |
type TranslationError (AllegraEra c) UTxO | |
Defined in Cardano.Ledger.Allegra.Translation | |
type TranslationError (MaryEra c) UTxO | |
Defined in Cardano.Ledger.Mary.Translation | |
type TranslationError (AlonzoEra c) UTxO | |
Defined in Cardano.Ledger.Alonzo.Translation | |
type TranslationError (BabbageEra c) UTxO | |
Defined in Cardano.Ledger.Babbage.Translation |
setUtxo :: UTxO EmulatorEra -> EmulatedLedgerState -> EmulatedLedgerState Source #
Set the utxo
Lenses
ledgerEnv :: Lens' EmulatedLedgerState (MempoolEnv EmulatorEra) Source #
memPoolState :: Lens' EmulatedLedgerState (MempoolState EmulatorEra) Source #
currentBlock :: Lens' EmulatedLedgerState EmulatorBlock Source #
previousBlocks :: Lens' EmulatedLedgerState [EmulatorBlock] Source #
Etc.
emulatorGlobals :: Params -> Globals Source #
A sensible default Globals
value for the emulator