hydra-tx
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Tx.IsTx

Synopsis

Documentation

class (Eq tx, Show tx, Typeable tx, FromCBOR tx, ToCBOR tx, FromJSON tx, ToJSON tx, Eq (TxIdType tx), Ord (TxIdType tx), Show (TxIdType tx), Typeable (TxIdType tx), FromJSON (TxIdType tx), ToJSON (TxIdType tx), FromCBOR (TxIdType tx), ToCBOR (TxIdType tx), FromJSONKey (TxIdType tx), ToJSONKey (TxIdType tx), Eq (TxOutType tx), Ord (TxOutType tx), Show (TxOutType tx), ToJSON (TxOutType tx), FromJSON (TxOutType tx), Eq (UTxOType tx), Show (UTxOType tx), Monoid (UTxOType tx), FromJSON (UTxOType tx), ToJSON (UTxOType tx), FromCBOR (UTxOType tx), ToCBOR (UTxOType tx)) => IsTx tx where Source #

Types of transactions that can be used by the Head protocol. The associated types and methods of this type class represent the whole interface of what the Head protocol needs from a transaction. This ensure the off-chain protocol stays fairly independent of a concrete transaction type.

Associated Types

type TxIdType tx Source #

Type which identifies a transaction

type TxOutType tx = out | out -> tx Source #

Type for individual transaction outputs.

type UTxOType tx = utxo | utxo -> tx Source #

Type for a set of unspent transaction outputs.

type ValueType tx Source #

Type representing a value on the ledger.

Methods

txId :: tx -> TxIdType tx Source #

balance :: UTxOType tx -> ValueType tx Source #

hashUTxO :: UTxOType tx -> ByteString Source #

Hash a utxo set to be able to sign (off-chain) and verify it (on-chain).

txIdBytes :: TxIdType tx -> ByteString Source #

Raw bytes identifying a transaction, as bound into snapshot signatures. Must match what the on-chain code reads out of a TxOutRef, see getSignableRepresentation.

txSpendingUTxO :: UTxOType tx -> tx Source #

utxoFromTx :: tx -> UTxOType tx Source #

Get the UTxO produced by given transaction.

outputsOfUTxO :: UTxOType tx -> [TxOutType tx] Source #

Get only the outputs in given UTxO.

withoutUTxO :: UTxOType tx -> UTxOType tx -> UTxOType tx Source #

Return the left-hand side without the right-hand side.

applyTxTo :: tx -> UTxOType tx -> UTxOType tx Source #

Apply a transaction to a UTxO via pure UTxO arithmetic, returning the post-tx UTxO. Removes the tx's inputs from the given UTxO and adds the tx's outputs. Performs no ledger validation; the caller must ensure the tx is valid against the given UTxO.

filterUTxOByOutputs :: UTxOType tx -> Set (TxOutType tx) -> UTxOType tx Source #

Filter a UTxO set keeping only entries whose output value is in the given set.

removeOneOutputFromUTxO :: TxOutType tx -> UTxOType tx -> UTxOType tx Source #

utxoToElement :: TxOutType tx -> ByteString Source #

Convert a TxOut to a ByteString element for the accumulator. This serializes the TxOut in the same way as the on-chain code does.

Instances

Instances details
IsTx Tx Source # 
Instance details

Defined in Hydra.Tx.IsTx

Associated Types

type TxIdType Tx Source #

type TxOutType Tx = (out :: Type) Source #

type UTxOType Tx = (utxo :: Type) Source #

type ValueType Tx Source #

Cardano Tx

Orphan instances

FromJSON Tx Source # 
Instance details

Methods

parseJSON :: Value -> Parser Tx

parseJSONList :: Value -> Parser [Tx]

omittedField :: Maybe Tx

FromJSON UTxO Source # 
Instance details

Methods

parseJSON :: Value -> Parser UTxO

parseJSONList :: Value -> Parser [UTxO]

omittedField :: Maybe UTxO

FromCBOR Tx Source # 
Instance details

Methods

fromCBOR :: Decoder s Tx

label :: Proxy Tx -> Text

FromCBOR UTxO Source # 
Instance details

Methods

fromCBOR :: Decoder s UTxO

label :: Proxy UTxO -> Text

ToCBOR UTxO Source # 
Instance details

Methods

toCBOR :: UTxO -> Encoding

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

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

IsShelleyBasedEra era => ToJSON (Tx era) Source # 
Instance details

Methods

toJSON :: Tx era -> Value

toEncoding :: Tx era -> Encoding

toJSONList :: [Tx era] -> Value

toEncodingList :: [Tx era] -> Encoding

omitField :: Tx era -> Bool

IsShelleyBasedEra era => ToCBOR (Tx era) Source # 
Instance details

Methods

toCBOR :: Tx era -> Encoding

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

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

Ord (TxOut CtxUTxO) Source #

Orphan Ord instance for 'TxOut CtxUTxO' using JSON encoding for comparison. Needed to use 'TxOut CtxUTxO' in Set and as 'TxOutType Tx' with the Ord constraint.

XXX: This fully serialises both operands on every comparison (including any reference script, as hex CBOR), so it is O(size of output) rather than O(1) and allocates on each call. It is kept as-is deliberately: the ordering it induces is observable through every Set/Map keyed by an output, so a cheaper key (e.g. comparing CBOR instead) would silently reorder them. cardano-ledger provides no Ord for BabbageTxOut to delegate to, so changing this needs a deliberate decision about the new ordering rather than a drop-in replacement.

Instance details

Methods

compare :: TxOut CtxUTxO -> TxOut CtxUTxO -> Ordering Source #

(<) :: TxOut CtxUTxO -> TxOut CtxUTxO -> Bool Source #

(<=) :: TxOut CtxUTxO -> TxOut CtxUTxO -> Bool Source #

(>) :: TxOut CtxUTxO -> TxOut CtxUTxO -> Bool Source #

(>=) :: TxOut CtxUTxO -> TxOut CtxUTxO -> Bool Source #

max :: TxOut CtxUTxO -> TxOut CtxUTxO -> TxOut CtxUTxO Source #

min :: TxOut CtxUTxO -> TxOut CtxUTxO -> TxOut CtxUTxO Source #