Safe Haskell | None |
---|---|
Language | Haskell2010 |
An index of unspent transaction outputs, and some functions for validating transactions using the index.
Synopsis
- type UtxoIndex = UTxO BabbageEra
- insert :: CardanoTx -> UtxoIndex -> UtxoIndex
- insertCollateral :: CardanoTx -> UtxoIndex -> UtxoIndex
- insertBlock :: Block -> UtxoIndex -> UtxoIndex
- initialise :: Blockchain -> UtxoIndex
- lookup :: TxIn -> UtxoIndex -> Maybe TxOut
- getCollateral :: UtxoIndex -> CardanoTx -> Value
- data ValidationError
- _TxOutRefNotFound :: Prism' ValidationError TxIn
- _ScriptFailure :: Prism' ValidationError ScriptError
- _CardanoLedgerValidationError :: Prism' ValidationError Text
- data ValidationResult
- _Success :: Prism' ValidationResult (OnChainTx, RedeemerReport)
- _FailPhase1 :: Prism' ValidationResult (CardanoTx, ValidationError)
- _FailPhase2 :: Prism' ValidationResult (OnChainTx, ValidationError, Value)
- cardanoTxFromValidationResult :: ValidationResult -> CardanoTx
- toOnChain :: ValidationResult -> Maybe OnChainTx
- getEvaluationLogs :: ValidationResult -> [Text]
- type ValidationSuccess = (RedeemerReport, Validated (Tx EmulatorEra))
- type ValidationErrorInPhase = (ValidationPhase, ValidationError)
- data ValidationPhase
- type RedeemerReport = Map RdmrPtr ([Text], ExUnits)
- maxFee :: Ada
- adjustTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> ([Lovelace], TxOut)
- minAdaTxOut :: PParams (BabbageEra StandardCrypto) -> TxOut -> Lovelace
- minAdaTxOutEstimated :: Ada
- minLovelaceTxOutEstimated :: Lovelace
- maxMinAdaTxOut :: Ada
- createGenesisTransaction :: Map CardanoAddress Value -> CardanoTx
- genesisTxIn :: TxIn
- data ExBudget = ExBudget {}
- newtype ExCPU = ExCPU CostingInteger
- newtype ExMemory = ExMemory CostingInteger
- data SatInt
Types for transaction validation based on UTXO index
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.
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
_TxOutRefNotFound :: Prism' ValidationError TxIn Source #
_ScriptFailure :: Prism' ValidationError ScriptError Source #
_CardanoLedgerValidationError :: Prism' ValidationError Text Source #
data ValidationResult Source #
FailPhase1 !CardanoTx !ValidationError | A transaction failed to validate in phase 1. |
FailPhase2 !OnChainTx !ValidationError !Value | A transaction failed to validate in phase 2. The |
Success !OnChainTx !RedeemerReport |
Instances
_Success :: Prism' ValidationResult (OnChainTx, RedeemerReport) Source #
_FailPhase1 :: Prism' ValidationResult (CardanoTx, ValidationError) Source #
_FailPhase2 :: Prism' ValidationResult (OnChainTx, ValidationError, Value) Source #
getEvaluationLogs :: ValidationResult -> [Text] Source #
Get logs from evaluating plutus scripts.
type ValidationSuccess = (RedeemerReport, Validated (Tx EmulatorEra)) Source #
data ValidationPhase Source #
Instances
Eq ValidationPhase Source # | |
Defined in Ledger.Index.Internal (==) :: ValidationPhase -> ValidationPhase -> Bool Source # (/=) :: ValidationPhase -> ValidationPhase -> Bool Source # | |
Show ValidationPhase Source # | |
Defined in Ledger.Index.Internal | |
Generic ValidationPhase Source # | |
Defined in Ledger.Index.Internal from :: ValidationPhase -> Rep ValidationPhase x Source # to :: Rep ValidationPhase x -> ValidationPhase Source # | |
FromJSON ValidationPhase Source # | |
Defined in Ledger.Index.Internal parseJSON :: Value -> Parser ValidationPhase parseJSONList :: Value -> Parser [ValidationPhase] | |
ToJSON ValidationPhase Source # | |
Defined in Ledger.Index.Internal toJSON :: ValidationPhase -> Value toEncoding :: ValidationPhase -> Encoding toJSONList :: [ValidationPhase] -> Value toEncodingList :: [ValidationPhase] -> Encoding | |
Pretty ValidationPhase Source # | |
Defined in Ledger.Index.Internal pretty :: ValidationPhase -> Doc ann # prettyList :: [ValidationPhase] -> Doc ann # | |
type Rep ValidationPhase Source # | |
type RedeemerReport = Map RdmrPtr ([Text], ExUnits) 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.
maxMinAdaTxOut :: Ada Source #
createGenesisTransaction :: Map CardanoAddress Value -> CardanoTx Source #
genesisTxIn :: TxIn Source #
cardano-ledger validation rules require the presence of inputs and we have to provide a stub TxIn for the genesis transaction.
Instances
ExCPU CostingInteger |
Instances
Eq ExCPU | |
Num ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
Ord ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
Show ExCPU | |
Generic ExCPU | |
Semigroup ExCPU | |
Monoid ExCPU | |
NFData ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
FromJSON ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory parseJSON :: Value -> Parser ExCPU parseJSONList :: Value -> Parser [ExCPU] | |
ToJSON ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
Pretty ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory | |
NoThunks ExCPU | |
Lift ExCPU | |
PrettyBy config ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory prettyBy :: config -> ExCPU -> Doc ann prettyListBy :: config -> [ExCPU] -> Doc ann | |
type Rep ExCPU | |
Defined in PlutusCore.Evaluation.Machine.ExMemory |
ExMemory CostingInteger |