hydra-node-0.20.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Ledger.Simple

Description

A mock implementation of a ledger using very simple UTxO transactions.

These transactions have a very simplified representation of unspent transaction outputs being just integers, but already have inputs and outputs. Transactions are validated against the current state of the ledger, so that one transaction could at some point be invalid, then becomes valid because some inputs it consumes are now available.

NOTE: There is no notion of time in this ledger, so transactions validation will never depend on the L1 slot.

Synopsis

Simple transactions

data SimpleTx Source #

Simple transaction. A transaction is a SimpleId, a list of inputs and a list of outputs, and it has no time validity.

Constructors

SimpleTx 

Fields

Instances

Instances details
Arbitrary SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

FromJSON SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

parseJSON :: Value -> Parser SimpleTx

parseJSONList :: Value -> Parser [SimpleTx]

omittedField :: Maybe SimpleTx

ToJSON SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

toJSON :: SimpleTx -> Value

toEncoding :: SimpleTx -> Encoding

toJSONList :: [SimpleTx] -> Value

toEncodingList :: [SimpleTx] -> Encoding

omitField :: SimpleTx -> Bool

Generic SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type Rep SimpleTx :: Type -> Type Source #

Show SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

FromCBOR SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

fromCBOR :: Decoder s SimpleTx

label :: Proxy SimpleTx -> Text

ToCBOR SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

toCBOR :: SimpleTx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SimpleTx -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SimpleTx] -> Size

Eq SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Ord SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

IsChainState SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type ChainStateType SimpleTx = (c :: Type)

Methods

chainStateSlot :: ChainStateType SimpleTx -> ChainSlot

IsTx SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type TxIdType SimpleTx

type TxOutType SimpleTx = (out :: Type)

type UTxOType SimpleTx = (utxo :: Type)

type ValueType SimpleTx

Methods

txId :: SimpleTx -> TxIdType SimpleTx

balance :: UTxOType SimpleTx -> ValueType SimpleTx

hashUTxO :: UTxOType SimpleTx -> ByteString

txSpendingUTxO :: UTxOType SimpleTx -> SimpleTx

utxoFromTx :: SimpleTx -> UTxOType SimpleTx

outputsOfUTxO :: UTxOType SimpleTx -> [TxOutType SimpleTx]

withoutUTxO :: UTxOType SimpleTx -> UTxOType SimpleTx -> UTxOType SimpleTx

type Rep SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type Rep SimpleTx = D1 ('MetaData "SimpleTx" "Hydra.Ledger.Simple" "hydra-node-0.20.0-5pXAEiXeWsXH8K4KfwlMxW" 'False) (C1 ('MetaCons "SimpleTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "txSimpleId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SimpleId) :*: (S1 ('MetaSel ('Just "txInputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType SimpleTx)) :*: S1 ('MetaSel ('Just "txOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType SimpleTx)))))
type ChainStateType SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type ChainStateType SimpleTx = SimpleChainState
type TxIdType SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type TxIdType SimpleTx = SimpleId
type TxOutType SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type TxOutType SimpleTx = SimpleTxOut
type UTxOType SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type UTxOType SimpleTx = Set SimpleTxOut
type ValueType SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

type ValueType SimpleTx = Int

newtype SimpleTxOut Source #

A single output of a SimpleTx having an integer identity and sole value.

Constructors

SimpleTxOut 

Instances

Instances details
Arbitrary SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

FromJSON SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

parseJSON :: Value -> Parser SimpleTxOut

parseJSONList :: Value -> Parser [SimpleTxOut]

omittedField :: Maybe SimpleTxOut

ToJSON SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

toJSON :: SimpleTxOut -> Value

toEncoding :: SimpleTxOut -> Encoding

toJSONList :: [SimpleTxOut] -> Value

toEncodingList :: [SimpleTxOut] -> Encoding

omitField :: SimpleTxOut -> Bool

Generic SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type Rep SimpleTxOut :: Type -> Type Source #

Num SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Show SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

FromCBOR SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

fromCBOR :: Decoder s SimpleTxOut

label :: Proxy SimpleTxOut -> Text

ToCBOR SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Methods

toCBOR :: SimpleTxOut -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SimpleTxOut -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SimpleTxOut] -> Size

Eq SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

Ord SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

type Rep SimpleTxOut Source # 
Instance details

Defined in Hydra.Ledger.Simple

type Rep SimpleTxOut = D1 ('MetaData "SimpleTxOut" "Hydra.Ledger.Simple" "hydra-node-0.20.0-5pXAEiXeWsXH8K4KfwlMxW" 'True) (C1 ('MetaCons "SimpleTxOut" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSimpleTxOut") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Integer)))

Simple chain state

newtype SimpleChainState Source #

Constructors

SimpleChainState 

Fields

Instances

Instances details
Arbitrary SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

FromJSON SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

ToJSON SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

Generic SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type Rep SimpleChainState :: Type -> Type Source #

Show SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

Eq SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

type Rep SimpleChainState Source # 
Instance details

Defined in Hydra.Ledger.Simple

type Rep SimpleChainState = D1 ('MetaData "SimpleChainState" "Hydra.Ledger.Simple" "hydra-node-0.20.0-5pXAEiXeWsXH8K4KfwlMxW" 'True) (C1 ('MetaCons "SimpleChainState" 'PrefixI 'True) (S1 ('MetaSel ('Just "slot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot)))

A simple ledger

Builders

utxoRefs :: [Integer] -> UTxOType SimpleTx Source #

Generators