plutus-ledger-1.1.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

newtype UtxoIndex Source #

The UTxOs of a blockchain indexed by their references.

Constructors

UtxoIndex 

Instances

Instances details
Eq UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Show UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Generic UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Associated Types

type Rep UtxoIndex :: Type -> Type Source #

Semigroup UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Monoid UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

NFData UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Methods

rnf :: UtxoIndex -> () Source #

ToJSON UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

FromJSON UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

ToSchema UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

Serialise UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep UtxoIndex Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep UtxoIndex = D1 ('MetaData "UtxoIndex" "Ledger.Index.Internal" "plutus-ledger-1.1.0.0-JskZbcPMCdRJVHaAZ0to82" 'True) (C1 ('MetaCons "UtxoIndex" 'PrefixI 'True) (S1 ('MetaSel ('Just "getIndex") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TxOutRef TxOut))))

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 :: MonadError ValidationError m => TxOutRef -> UtxoIndex -> m 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 TxOutRef

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

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 #

ToJSON ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

FromJSON ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

Pretty ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

AsValidationError ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep ValidationError Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep ValidationError = D1 ('MetaData "ValidationError" "Ledger.Index.Internal" "plutus-ledger-1.1.0.0-JskZbcPMCdRJVHaAZ0to82" 'False) (C1 ('MetaCons "TxOutRefNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef)) :+: (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))))

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 #

ToJSON ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

FromJSON ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

Pretty ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

type Rep ValidationPhase Source # 
Instance details

Defined in Ledger.Index.Internal

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

minFee :: Tx -> Value Source #

Minimum transaction fee.

maxFee :: Ada Source #

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

adjustTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Either ToCardanoError ([Ada], 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 -> Ada 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.

pubKeyTxIns :: Fold [TxIn] TxIn Source #

Filter to get only the pubkey inputs.

scriptTxIns :: Fold [TxIn] TxIn Source #

Filter to get only the script inputs.

data ExBudget Source #

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 #

ToJSON ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

FromJSON ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

NoThunks ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Pretty ExBudget 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExBudget

Methods

pretty :: ExBudget -> Doc ann Source #

prettyList :: [ExBudget] -> Doc ann Source #

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 Source #

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

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-AYZ1DL3hDMt58i5HNUtSdG" '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 Source #

Counts CPU units in picoseconds: maximum value for SatInt is 2^63 ps, or appproximately 106 days.

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 #

ToJSON ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

FromJSON ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

NoThunks ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Pretty ExCPU 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

pretty :: ExCPU -> Doc ann Source #

prettyList :: [ExCPU] -> Doc ann Source #

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 Source #

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

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-AYZ1DL3hDMt58i5HNUtSdG" 'True) (C1 ('MetaCons "ExCPU" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger)))

newtype ExMemory Source #

Counts size in machine words.

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 #

ToJSON ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

FromJSON ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

NoThunks ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Pretty ExMemory 
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Methods

pretty :: ExMemory -> Doc ann Source #

prettyList :: [ExMemory] -> Doc ann Source #

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 Source #

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

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-AYZ1DL3hDMt58i5HNUtSdG" 'True) (C1 ('MetaCons "ExMemory" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CostingInteger)))

data SatInt Source #

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

In the Num instance, we plug in our own addition, multiplication and subtraction function that perform overflow-checking.

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 #

NFData SatInt 
Instance details

Defined in Data.SatInt

Methods

rnf :: SatInt -> () Source #

ToJSON SatInt 
Instance details

Defined in Data.SatInt

FromJSON SatInt 
Instance details

Defined in Data.SatInt

Bits SatInt 
Instance details

Defined in Data.SatInt

FiniteBits SatInt 
Instance details

Defined in Data.SatInt

FromField SatInt 
Instance details

Defined in Data.SatInt

Prim SatInt 
Instance details

Defined in Data.SatInt

NoThunks SatInt 
Instance details

Defined in Data.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-AYZ1DL3hDMt58i5HNUtSdG" 'True) (C1 ('MetaCons "SI" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSatInt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))