hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Model.Payment

Description

A simplistic type of transactions useful for modelling purpose. a Payment is a simple transaction type that moves some amount of ADAs between to CardanoSigningKey.

Synopsis

Documentation

newtype CardanoSigningKey Source #

New type wrapper to add Ord and Eq instances to signing keys. The inner 'SigningKey PaymentKey' is wrapped in Secret: the signingKey field never exposes the raw key, mirroring the way Hydra signing keys are handled. The accompanying ToJSON FromJSON ToCBOR / FromCBOR bans are inherited from Secret.

Constructors

CardanoSigningKey 

Fields

Instances

Instances details
Arbitrary CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

FromJSON CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

ToJSON CardanoSigningKey Source #

CardanoSigningKey wraps a Secret internally, which makes any JSON / CBOR access via the Secret value a compile-time TypeError. 'IsTx Payment' below pulls in ToJSON FromJSON ToCBOR / FromCBOR as superclasses of its transaction type, so we provide placebo instances that error at runtime if accidentally called. Payment is purely a test-model type and is never serialised in production.

Instance details

Defined in Hydra.Model.Payment

Show CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

FromCBOR CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

ToCBOR CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

Methods

toCBOR :: CardanoSigningKey -> Encoding

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

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

Eq CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

Ord CardanoSigningKey Source # 
Instance details

Defined in Hydra.Model.Payment

HasVariables CardanoSigningKey 
Instance details

Defined in Hydra.ModelSpec

Methods

getAllVariables :: CardanoSigningKey -> Set (Any Var)

data Payment Source #

A single Ada-payment only transaction in our model.

Constructors

Payment 

Instances

Instances details
FromJSON Payment Source # 
Instance details

Defined in Hydra.Model.Payment

Methods

parseJSON :: Value -> Parser Payment

parseJSONList :: Value -> Parser [Payment]

omittedField :: Maybe Payment

ToJSON Payment Source # 
Instance details

Defined in Hydra.Model.Payment

Methods

toJSON :: Payment -> Value

toEncoding :: Payment -> Encoding

toJSONList :: [Payment] -> Value

toEncodingList :: [Payment] -> Encoding

omitField :: Payment -> Bool

Generic Payment Source # 
Instance details

Defined in Hydra.Model.Payment

Associated Types

type Rep Payment :: Type -> Type Source #

Show Payment Source # 
Instance details

Defined in Hydra.Model.Payment

FromCBOR Payment Source # 
Instance details

Defined in Hydra.Model.Payment

Methods

fromCBOR :: Decoder s Payment

label :: Proxy Payment -> Text

ToCBOR Payment Source # 
Instance details

Defined in Hydra.Model.Payment

Methods

toCBOR :: Payment -> Encoding

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

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

Eq Payment Source # 
Instance details

Defined in Hydra.Model.Payment

IsTx Payment Source #

Making Payment an instance of IsTx allows us to use it with HeadLogic's messages.

Instance details

Defined in Hydra.Model.Payment

Associated Types

type TxIdType Payment

type TxOutType Payment = (out :: Type)

type UTxOType Payment = (utxo :: Type)

type ValueType Payment

Methods

txId :: Payment -> TxIdType Payment

balance :: UTxOType Payment -> ValueType Payment

hashUTxO :: UTxOType Payment -> ByteString

txIdBytes :: TxIdType Payment -> ByteString

txSpendingUTxO :: UTxOType Payment -> Payment

utxoFromTx :: Payment -> UTxOType Payment

outputsOfUTxO :: UTxOType Payment -> [TxOutType Payment]

withoutUTxO :: UTxOType Payment -> UTxOType Payment -> UTxOType Payment

applyTxTo :: Payment -> UTxOType Payment -> UTxOType Payment

filterUTxOByOutputs :: UTxOType Payment -> Set (TxOutType Payment) -> UTxOType Payment

removeOneOutputFromUTxO :: TxOutType Payment -> UTxOType Payment -> UTxOType Payment

utxoToElement :: TxOutType Payment -> ByteString

type Rep Payment Source # 
Instance details

Defined in Hydra.Model.Payment

type Rep Payment = D1 ('MetaData "Payment" "Hydra.Model.Payment" "hydra-node-2.3.0-596NbrkErqDLitHifYtGoA-tests" 'False) (C1 ('MetaCons "Payment" 'PrefixI 'True) (S1 ('MetaSel ('Just "from") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CardanoSigningKey) :*: (S1 ('MetaSel ('Just "to") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CardanoSigningKey) :*: S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))))
type TxIdType Payment Source # 
Instance details

Defined in Hydra.Model.Payment

type TxIdType Payment = Int
type TxOutType Payment Source # 
Instance details

Defined in Hydra.Model.Payment

type TxOutType Payment = (CardanoSigningKey, Value)
type UTxOType Payment Source # 
Instance details

Defined in Hydra.Model.Payment

type UTxOType Payment = [(CardanoSigningKey, Value)]
type ValueType Payment Source # 
Instance details

Defined in Hydra.Model.Payment

type ValueType Payment = Value

applyTx :: UTxOType Payment -> Payment -> UTxOType Payment Source #

genAdaValue :: Gen Value Source #

Orphans

Orphan instances

Arbitrary Value Source # 
Instance details

Methods

arbitrary :: Gen Value

shrink :: Value -> [Value]

FromCBOR Value Source # 
Instance details

Methods

fromCBOR :: Decoder s Value

label :: Proxy Value -> Text

ToCBOR Value Source # 
Instance details

Methods

toCBOR :: Value -> Encoding

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

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

Ord Value Source #

Orphan Ord instance for Cardano Value using JSON encoding for comparison. Needed to use '(CardanoSigningKey, Value)' as 'TxOutType Payment' in Set.

Instance details

Methods

compare :: Value -> Value -> Ordering Source #

(<) :: Value -> Value -> Bool Source #

(<=) :: Value -> Value -> Bool Source #

(>) :: Value -> Value -> Bool Source #

(>=) :: Value -> Value -> Bool Source #

max :: Value -> Value -> Value Source #

min :: Value -> Value -> Value Source #