plutus-ledger-1.2.0.0: Wallet API
Safe HaskellNone
LanguageHaskell2010

Ledger.Index

Description

An index of unspent transaction outputs, and some functions for validating transactions using the index.

Synopsis

Types for transaction validation based on UTXO index

type UtxoIndex = UTxO BabbageEra Source #

The UTxOs of a blockchain indexed by their references.

insert :: CardanoTx -> UtxoIndex -> UtxoIndex Source #

Update the index for the addition of a transaction.

insertCollateral :: CardanoTx -> UtxoIndex -> UtxoIndex Source #

Update the index for the addition of only the collateral inputs of a failed transaction.

insertBlock :: Block -> UtxoIndex -> UtxoIndex Source #

Update the index for the addition of a block.

initialise :: Blockchain -> UtxoIndex Source #

Create an index of all UTxOs on the chain.

lookup :: TxIn -> UtxoIndex -> Maybe TxOut Source #

Find an unspent transaction output by the TxOutRef that spends it.

data ValidationError Source #

A reason why a transaction is invalid.

Constructors

TxOutRefNotFound TxIn

The transaction output consumed by a transaction input could not be found (either because it was already spent, or because there was no transaction with the given hash on the blockchain).

ScriptFailure ScriptError

For pay-to-script outputs: evaluation of the validator script failed.

CardanoLedgerValidationError Text

An error from Cardano.Ledger validation

MaxCollateralInputsExceeded

Balancing failed, it needed more than the maximum number of collateral inputs

Instances

Instances details
Eq ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Show ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Generic ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Associated Types

type Rep ValidationError :: Type -> Type Source #

FromJSON ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

parseJSON :: Value -> Parser ValidationError

parseJSONList :: Value -> Parser [ValidationError]

ToJSON ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

toJSON :: ValidationError -> Value

toEncoding :: ValidationError -> Encoding

toJSONList :: [ValidationError] -> Value

toEncodingList :: [ValidationError] -> Encoding

Pretty ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

pretty :: ValidationError -> Doc ann #

prettyList :: [ValidationError] -> Doc ann #

type Rep ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep ValidationError = D1 ('MetaData "ValidationError" "Ledger.Index.Internal" "plutus-ledger-1.2.0.0-8dOSOspdVv7Hd909lHBnfn" 'False) ((C1 ('MetaCons "TxOutRefNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxIn)) :+: C1 ('MetaCons "ScriptFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ScriptError))) :+: (C1 ('MetaCons "CardanoLedgerValidationError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "MaxCollateralInputsExceeded" 'PrefixI 'False) (U1 :: Type -> Type)))

data ValidationResult Source #

Constructors

FailPhase1 !CardanoTx !ValidationError

A transaction failed to validate in phase 1.

FailPhase2 !OnChainTx !ValidationError !Value

A transaction failed to validate in phase 2. The Value indicates the amount of collateral stored in the transaction.

Success !OnChainTx !RedeemerReport 

Instances

Instances details
Eq ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Show ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Generic ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Associated Types

type Rep ValidationResult :: Type -> Type Source #

FromJSON ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

parseJSON :: Value -> Parser ValidationResult

parseJSONList :: Value -> Parser [ValidationResult]

ToJSON ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Pretty ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

pretty :: ValidationResult -> Doc ann #

prettyList :: [ValidationResult] -> Doc ann #

type Rep ValidationResult Source # 
Instance details

Defined in Ledger.Index.Internal

getEvaluationLogs :: ValidationResult -> [Text] Source #

Get logs from evaluating plutus scripts.

data ValidationPhase Source #

Constructors

Phase1 
Phase2 

Instances

Instances details
Eq ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Show ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Generic ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Associated Types

type Rep ValidationPhase :: Type -> Type Source #

FromJSON ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

parseJSON :: Value -> Parser ValidationPhase

parseJSONList :: Value -> Parser [ValidationPhase]

ToJSON ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

toJSON :: ValidationPhase -> Value

toEncoding :: ValidationPhase -> Encoding

toJSONList :: [ValidationPhase] -> Value

toEncodingList :: [ValidationPhase] -> Encoding

Pretty ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

pretty :: ValidationPhase -> Doc ann #

prettyList :: [ValidationPhase] -> Doc ann #

type Rep ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep ValidationPhase = D1 ('MetaData "ValidationPhase" "Ledger.Index.Internal" "plutus-ledger-1.2.0.0-8dOSOspdVv7Hd909lHBnfn" 'False) (C1 ('MetaCons "Phase1" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Phase2" 'PrefixI 'False) (U1 :: Type -> Type))

type RedeemerReport = Map RdmrPtr ([Text], ExUnits) Source #

maxFee :: Ada Source #

TODO Should be calculated based on the maximum script size permitted on the Cardano blockchain.

adjustTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> ([Lovelace], TxOut) Source #

Adjust a single transaction output so it contains at least the minimum amount of Ada and return the adjustment (if any) and the updated TxOut.

minAdaTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Lovelace Source #

Exact computation of the mimimum Ada required for a given TxOut. TODO: Should be moved to cardano-api-extended once created

minAdaTxOutEstimated :: Ada Source #

Provide a reasonable estimate of the mimimum of Ada required for a TxOut.

An exact estimate of the the mimimum of Ada in a TxOut is determined by two things: - the PParams, more precisely its coinPerUTxOWord parameter. - the size of the TxOut. In many situations though, we need to determine a plausible value for the minimum of Ada needed for a TxOut without knowing much of the TxOut. This function provides a value big enough to balance UTxOs without a large inlined data (larger than a hash) nor a complex val with a lot of minted values. It's superior to the lowest minimum needed for an UTxO, as the lowest value require no datum. An estimate of the minimum required Ada for each tx output.

genesisTxIn :: TxIn Source #

cardano-ledger validation rules require the presence of inputs and we have to provide a stub TxIn for the genesis transaction.

data ExBudget #

Constructors

ExBudget 

Instances

Instances details
Eq ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Show ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Generic ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Associated Types

type Rep ExBudget :: Type -> Type Source #

Semigroup ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Monoid ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

NFData ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

rnf :: ExBudget -> () Source #

FromJSON ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

parseJSON :: Value -> Parser ExBudget

parseJSONList :: Value -> Parser [ExBudget]

ToJSON ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

toJSON :: ExBudget -> Value

toEncoding :: ExBudget -> Encoding

toJSONList :: [ExBudget] -> Value

toEncodingList :: [ExBudget] -> Encoding

Pretty ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

pretty :: ExBudget -> Doc ann #

prettyList :: [ExBudget] -> Doc ann #

NoThunks ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

noThunks :: Context -> ExBudget -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> ExBudget -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy ExBudget -> String

Lift ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

PrettyBy config ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

prettyBy :: config -> ExBudget -> Doc ann

prettyListBy :: config -> [ExBudget] -> Doc ann

type Rep ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

type Rep ExBudget = D1 ('MetaData "ExBudget" "PlutusCore.Evaluation.Machine.ExBudget" "plutus-core-1.0.0.1-6wMiyL0yerXJu56t8zBoKx" 'False) (C1 ('MetaCons "ExBudget" 'PrefixI 'True) (S1 ('MetaSel ('Just "exBudgetCPU") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 ExCPU) :*: S1 ('MetaSel ('Just "exBudgetMemory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 ExMemory)))

newtype ExCPU #

Constructors

ExCPU CostingInteger 

Instances

Instances details
Eq ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

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

(/=) :: ExCPU -> ExCPU -> Bool Source #

Num ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Ord ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Show ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Generic ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Associated Types

type Rep ExCPU :: Type -> Type Source #

Methods

from :: ExCPU -> Rep ExCPU x Source #

to :: Rep ExCPU x -> ExCPU Source #

Semigroup ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Monoid ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

NFData ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

rnf :: ExCPU -> () Source #

FromJSON ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

parseJSON :: Value -> Parser ExCPU

parseJSONList :: Value -> Parser [ExCPU]

ToJSON ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

toJSON :: ExCPU -> Value

toEncoding :: ExCPU -> Encoding

toJSONList :: [ExCPU] -> Value

toEncodingList :: [ExCPU] -> Encoding

Pretty ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

pretty :: ExCPU -> Doc ann #

prettyList :: [ExCPU] -> Doc ann #

NoThunks ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

noThunks :: Context -> ExCPU -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> ExCPU -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy ExCPU -> String

Lift ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

PrettyBy config ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

prettyBy :: config -> ExCPU -> Doc ann

prettyListBy :: config -> [ExCPU] -> Doc ann

type Rep ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

type Rep ExCPU = D1 ('MetaData "ExCPU" "PlutusCore.Evaluation.Machine.ExMemory" "plutus-core-1.0.0.1-6wMiyL0yerXJu56t8zBoKx" 'True) (C1 ('MetaCons "ExCPU" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger)))

newtype ExMemory #

Constructors

ExMemory CostingInteger 

Instances

Instances details
Eq ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Num ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Ord ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Show ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Generic ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Associated Types

type Rep ExMemory :: Type -> Type Source #

Semigroup ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Monoid ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

NFData ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

rnf :: ExMemory -> () Source #

FromJSON ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

parseJSON :: Value -> Parser ExMemory

parseJSONList :: Value -> Parser [ExMemory]

ToJSON ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

toJSON :: ExMemory -> Value

toEncoding :: ExMemory -> Encoding

toJSONList :: [ExMemory] -> Value

toEncodingList :: [ExMemory] -> Encoding

Pretty ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

pretty :: ExMemory -> Doc ann #

prettyList :: [ExMemory] -> Doc ann #

NoThunks ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

noThunks :: Context -> ExMemory -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> ExMemory -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy ExMemory -> String

ExMemoryUsage ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Lift ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

PrettyBy config ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

prettyBy :: config -> ExMemory -> Doc ann

prettyListBy :: config -> [ExMemory] -> Doc ann

type Rep ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

type Rep ExMemory = D1 ('MetaData "ExMemory" "PlutusCore.Evaluation.Machine.ExMemory" "plutus-core-1.0.0.1-6wMiyL0yerXJu56t8zBoKx" 'True) (C1 ('MetaCons "ExMemory" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger)))

data SatInt #

Instances

Instances details
Bounded SatInt 
Instance details

Defined in Data.SatInt

Enum SatInt 
Instance details

Defined in Data.SatInt

Eq SatInt 
Instance details

Defined in Data.SatInt

Integral SatInt 
Instance details

Defined in Data.SatInt

Num SatInt 
Instance details

Defined in Data.SatInt

Ord SatInt 
Instance details

Defined in Data.SatInt

Read SatInt 
Instance details

Defined in Data.SatInt

Real SatInt 
Instance details

Defined in Data.SatInt

Show SatInt 
Instance details

Defined in Data.SatInt

Generic SatInt 
Instance details

Defined in Data.SatInt

Associated Types

type Rep SatInt :: Type -> Type Source #

Bits SatInt 
Instance details

Defined in Data.SatInt

FiniteBits SatInt 
Instance details

Defined in Data.SatInt

NFData SatInt 
Instance details

Defined in Data.SatInt

Methods

rnf :: SatInt -> () Source #

Prim SatInt 
Instance details

Defined in Data.SatInt

FromJSON SatInt 
Instance details

Defined in Data.SatInt

Methods

parseJSON :: Value -> Parser SatInt

parseJSONList :: Value -> Parser [SatInt]

ToJSON SatInt 
Instance details

Defined in Data.SatInt

Methods

toJSON :: SatInt -> Value

toEncoding :: SatInt -> Encoding

toJSONList :: [SatInt] -> Value

toEncodingList :: [SatInt] -> Encoding

NoThunks SatInt 
Instance details

Defined in Data.SatInt

Methods

noThunks :: Context -> SatInt -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> SatInt -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy SatInt -> String

FromField SatInt 
Instance details

Defined in Data.SatInt

Methods

parseField :: Field -> Parser SatInt

ExMemoryUsage SatInt 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Lift SatInt 
Instance details

Defined in Data.SatInt

type Rep SatInt 
Instance details

Defined in Data.SatInt

type Rep SatInt = D1 ('MetaData "SatInt" "Data.SatInt" "plutus-core-1.0.0.1-6wMiyL0yerXJu56t8zBoKx" 'True) (C1 ('MetaCons "SI" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSatInt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))