plutus-ledger-0.1.0.0: Wallet API
Safe HaskellNone
LanguageHaskell2010

Ledger.Typed.Tx

Description

Typed transaction inputs and outputs. This module defines typed versions of various ledger types. The ultimate goal is to make sure that the script types attached to inputs and outputs line up, to avoid type errors at validation time.

Synopsis

Documentation

data TypedScriptTxIn a Source #

A TxIn tagged by two phantom types: a list of the types of the data scripts in the transaction; and the connection type of the input.

makeTypedScriptTxIn :: forall inn. (ToData (RedeemerType inn), ToData (DatumType inn)) => TypedValidator inn -> RedeemerType inn -> TypedScriptTxOutRef inn -> TypedScriptTxIn inn Source #

Create a TypedScriptTxIn from a correctly-typed validator, redeemer, and output ref.

newtype PubKeyTxIn Source #

A public-key TxIn. We need this to be sure that it is not a script input.

Constructors

PubKeyTxIn 

Fields

Instances

Instances details
Eq PubKeyTxIn Source # 
Instance details

Defined in Ledger.Typed.Tx

Generic PubKeyTxIn Source # 
Instance details

Defined in Ledger.Typed.Tx

Associated Types

type Rep PubKeyTxIn :: Type -> Type Source #

ToJSON PubKeyTxIn Source # 
Instance details

Defined in Ledger.Typed.Tx

FromJSON PubKeyTxIn Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep PubKeyTxIn Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep PubKeyTxIn = D1 ('MetaData "PubKeyTxIn" "Ledger.Typed.Tx" "plutus-ledger-0.1.0.0-BAhdPNOPbMF52ZvZJtxBkz" 'True) (C1 ('MetaCons "PubKeyTxIn" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPubKeyTxIn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxIn)))

data TypedScriptTxOut a Source #

A TxOut tagged by a phantom type: and the connection type of the output.

makeTypedScriptTxOut :: forall out. (ToData (DatumType out), FromData (DatumType out)) => TypedValidator out -> DatumType out -> Value -> TypedScriptTxOut out Source #

Create a TypedScriptTxOut from a correctly-typed data script, an address, and a value.

newtype PubKeyTxOut Source #

A public-key TxOut. We need this to be sure that it is not a script output.

Constructors

PubKeyTxOut 

Fields

Instances

Instances details
Eq PubKeyTxOut Source # 
Instance details

Defined in Ledger.Typed.Tx

Generic PubKeyTxOut Source # 
Instance details

Defined in Ledger.Typed.Tx

Associated Types

type Rep PubKeyTxOut :: Type -> Type Source #

ToJSON PubKeyTxOut Source # 
Instance details

Defined in Ledger.Typed.Tx

FromJSON PubKeyTxOut Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep PubKeyTxOut Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep PubKeyTxOut = D1 ('MetaData "PubKeyTxOut" "Ledger.Typed.Tx" "plutus-ledger-0.1.0.0-BAhdPNOPbMF52ZvZJtxBkz" 'True) (C1 ('MetaCons "PubKeyTxOut" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPubKeyTxOut") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOut)))

data WrongOutTypeError Source #

Instances

Instances details
Eq WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

Ord WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

Show WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

Generic WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

Associated Types

type Rep WrongOutTypeError :: Type -> Type Source #

ToJSON WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

FromJSON WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep WrongOutTypeError Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep WrongOutTypeError = D1 ('MetaData "WrongOutTypeError" "Ledger.Typed.Tx" "plutus-ledger-0.1.0.0-BAhdPNOPbMF52ZvZJtxBkz" 'False) (C1 ('MetaCons "ExpectedScriptGotPubkey" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExpectedPubkeyGotScript" 'PrefixI 'False) (U1 :: Type -> Type))

data ConnectionError Source #

An error we can get while trying to type an existing transaction part.

Instances

Instances details
Eq ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

Ord ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

Show ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

Generic ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

Associated Types

type Rep ConnectionError :: Type -> Type Source #

ToJSON ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

FromJSON ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

Pretty ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep ConnectionError Source # 
Instance details

Defined in Ledger.Typed.Tx

type Rep ConnectionError = D1 ('MetaData "ConnectionError" "Ledger.Typed.Tx" "plutus-ledger-0.1.0.0-BAhdPNOPbMF52ZvZJtxBkz" 'False) (((C1 ('MetaCons "WrongValidatorAddress" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Address) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Address)) :+: C1 ('MetaCons "WrongOutType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WrongOutTypeError))) :+: (C1 ('MetaCons "WrongInType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxInType)) :+: C1 ('MetaCons "MissingInType" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "WrongValidatorType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "WrongRedeemerType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinData))) :+: (C1 ('MetaCons "WrongDatumType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinData)) :+: (C1 ('MetaCons "NoDatum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash)) :+: C1 ('MetaCons "UnknownRef" 'PrefixI 'False) (U1 :: Type -> Type)))))

checkValidatorAddress :: forall a m. MonadError ConnectionError m => TypedValidator a -> Address -> m () Source #

Checks that the given validator hash is consistent with the actual validator.

checkRedeemer :: forall inn m. (FromData (RedeemerType inn), MonadError ConnectionError m) => TypedValidator inn -> Redeemer -> m (RedeemerType inn) Source #

Checks that the given redeemer script has the right type.

checkDatum :: forall a m. (FromData (DatumType a), MonadError ConnectionError m) => TypedValidator a -> Datum -> m (DatumType a) Source #

Checks that the given datum has the right type.

typeScriptTxIn :: forall inn m. (FromData (RedeemerType inn), ToData (RedeemerType inn), FromData (DatumType inn), ToData (DatumType inn), MonadError ConnectionError m) => (TxOutRef -> Maybe ChainIndexTxOut) -> TypedValidator inn -> TxIn -> m (TypedScriptTxIn inn) Source #

Create a TypedScriptTxIn from an existing TxIn by checking the types of its parts.

typePubKeyTxIn :: forall m. MonadError ConnectionError m => TxIn -> m PubKeyTxIn Source #

Create a PubKeyTxIn from an existing TxIn by checking that it has the right payment type.

typeScriptTxOut :: forall out m. (FromData (DatumType out), ToData (DatumType out), MonadError ConnectionError m) => TypedValidator out -> TxOutRef -> ChainIndexTxOut -> m (TypedScriptTxOut out) Source #

Create a TypedScriptTxOut from an existing TxOut by checking the types of its parts.

typeScriptTxOutRef :: forall out m. (FromData (DatumType out), ToData (DatumType out), MonadError ConnectionError m) => (TxOutRef -> Maybe ChainIndexTxOut) -> TypedValidator out -> TxOutRef -> m (TypedScriptTxOutRef out) Source #

Create a TypedScriptTxOut from an existing TxOut by checking the types of its parts. To do this we need to cross-reference against the validator script and be able to look up the TxOut to which this reference points.

typePubKeyTxOut :: forall m. MonadError ConnectionError m => TxOut -> m PubKeyTxOut Source #

Create a PubKeyTxOUt from an existing TxOut by checking that it has the right payment type.

Orphan instances