Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Ledger.Alonzo.Tx
Description
This module exports implementations of many of the functions outlined in the Alonzo specification. The link to source of the specification https://github.com/input-output-hk/cardano-ledger/tree/master/eras/alonzo/formal-spec The most recent version of the document can be found here: https://hydra.iohk.io/job/Cardano/cardano-ledger/specs.alonzo-ledger/latest/download-by-type/doc-pdf/alonzo-changes The functions can be found in Figures in that document, and sections of this code refer to those figures.
Synopsis
- data CostModel
- getLanguageView :: forall era. HasField "_costmdls" ( PParams era) CostModels => PParams era -> Language -> LangDepView
- data Data era
- type DataHash crypto = SafeHash crypto EraIndependentData
- newtype IsValid = IsValid Bool
- hashData :: Era era => Data era -> DataHash ( Crypto era)
- nonNativeLanguages :: [ Language ]
- hashScriptIntegrity :: forall era. Era era => Set LangDepView -> Redeemers era -> TxDats era -> StrictMaybe ( ScriptIntegrityHash ( Crypto era))
- getCoin :: Era era => TxOut era -> Coin
- data EraIndependentScriptIntegrity
- data ScriptIntegrity era = ScriptIntegrity !( Redeemers era) !( TxDats era) !( Set LangDepView )
- type ScriptIntegrityHash crypto = SafeHash crypto EraIndependentScriptIntegrity
-
data
ValidatedTx
era =
ValidatedTx
{
- body :: !( TxBody era)
- wits :: !( TxWitness era)
- isValid :: ! IsValid
- auxiliaryData :: !( StrictMaybe ( AuxiliaryData era))
- txdats' :: TxWitness era -> TxDats era
- txscripts' :: TxWitness era -> Map ( ScriptHash ( Crypto era)) ( Script era)
- txrdmrs :: TxWitness era -> ( Era era, Script era ~ Script era) => Redeemers era
-
data
TxBody
era
where
- pattern TxBody :: AlonzoBody era => Set ( TxIn ( Crypto era)) -> Set ( TxIn ( Crypto era)) -> StrictSeq ( TxOut era) -> StrictSeq ( DCert ( Crypto era)) -> Wdrl ( Crypto era) -> Coin -> ValidityInterval -> StrictMaybe ( Update era) -> Set ( KeyHash ' Witness ( Crypto era)) -> Value ( Crypto era) -> StrictMaybe ( ScriptIntegrityHash ( Crypto era)) -> StrictMaybe ( AuxiliaryDataHash ( Crypto era)) -> StrictMaybe Network -> TxBody era
- totExUnits :: ( HasField "wits" ( Tx era) ( Witnesses era), HasField "txrdmrs" ( Witnesses era) ( Redeemers era)) => Tx era -> ExUnits
- isTwoPhaseScriptAddress :: forall era. ValidateScript era => ValidatedTx era -> Addr ( Crypto era) -> Bool
- minfee :: ( HasField "_minfeeA" ( PParams era) Natural , HasField "_minfeeB" ( PParams era) Natural , HasField "_prices" ( PParams era) Prices , HasField "wits" ( Tx era) ( Witnesses era), HasField "txrdmrs" ( Witnesses era) ( Redeemers era), HasField "txsize" ( Tx era) Integer ) => PParams era -> Tx era -> Coin
-
class
Indexable
elem container
where
- indexOf :: elem -> container -> StrictMaybe Word64
- fromIndex :: Word64 -> container -> StrictMaybe elem
-
data
ScriptPurpose
crypto
- = Minting !( PolicyID crypto)
- | Spending !( TxIn crypto)
- | Rewarding !( RewardAcnt crypto)
- | Certifying !( DCert crypto)
- isTwoPhaseScriptAddressFromMap :: forall era. ValidateScript era => Map ( ScriptHash ( Crypto era)) ( Script era) -> Addr ( Crypto era) -> Bool
- alonzoInputHashes :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), ValidateScript era, TxOut era ~ TxOut era) => Map ( ScriptHash ( Crypto era)) ( Script era) -> ValidatedTx era -> UTxO era -> ( Set ( DataHash ( Crypto era)), Set ( TxIn ( Crypto era)))
- txouts :: Era era => TxBody era -> UTxO era
- indexedRdmrs :: forall era tx. ( Era era, HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "wits" tx ( TxWitness era), HasField "body" tx ( TxBody era)) => tx -> ScriptPurpose ( Crypto era) -> Maybe ( Data era, ExUnits )
- rdptr :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "minted" ( TxBody era) ( Set ( ScriptHash ( Crypto era)))) => TxBody era -> ScriptPurpose ( Crypto era) -> StrictMaybe RdmrPtr
- rdptrInv :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "minted" ( TxBody era) ( Set ( ScriptHash ( Crypto era)))) => TxBody era -> RdmrPtr -> StrictMaybe ( ScriptPurpose ( Crypto era))
- getMapFromValue :: Value crypto -> Map ( PolicyID crypto) ( Map AssetName Integer )
- segwitTx :: Annotator ( TxBody era) -> Annotator ( TxWitness era) -> IsValid -> Maybe ( Annotator ( AuxiliaryData era)) -> Annotator ( ValidatedTx era)
- toCBORForSizeComputation :: ( Typeable era, ToCBOR ( TxBody era), ToCBOR ( AuxiliaryData era)) => ValidatedTx era -> Encoding
- toCBORForMempoolSubmission :: ( Typeable era, ToCBOR ( TxBody era), ToCBOR ( AuxiliaryData era)) => ValidatedTx era -> Encoding
Documentation
A language dependent cost model for the Plutus evaluator.
Note that the
EvaluationContext
is entirely dependent on the
cost model parameters (ie the
Map
Text
Integer
) and that
this type uses the smart constructor
mkCostModel
to hide the evaluation context.
Instances
getLanguageView :: forall era. HasField "_costmdls" ( PParams era) CostModels => PParams era -> Language -> LangDepView Source #
Instances
type DataHash crypto = SafeHash crypto EraIndependentData Source #
Tag indicating whether non-native scripts in this transaction are expected to validate. This is added by the block creator when constructing the block.
Instances
Eq IsValid Source # | |
Show IsValid Source # | |
Generic IsValid Source # | |
NFData IsValid Source # | |
Defined in Cardano.Ledger.Alonzo.Tx |
|
ToCBOR IsValid Source # | |
FromCBOR IsValid Source # | |
NoThunks IsValid Source # | |
type Rep IsValid Source # | |
Defined in Cardano.Ledger.Alonzo.Tx
type
Rep
IsValid
=
D1
('
MetaData
"IsValid" "Cardano.Ledger.Alonzo.Tx" "cardano-ledger-alonzo-0.1.0.0-xW3meaGVQP43dxJ76zbGD" '
True
) (
C1
('
MetaCons
"IsValid" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Bool
)))
|
nonNativeLanguages :: [ Language ] Source #
hashScriptIntegrity :: forall era. Era era => Set LangDepView -> Redeemers era -> TxDats era -> StrictMaybe ( ScriptIntegrityHash ( Crypto era)) Source #
data EraIndependentScriptIntegrity Source #
Instances
c ~ Crypto era => HasField "scriptIntegrityHash" ( TxBody era) ( StrictMaybe ( ScriptIntegrityHash c)) Source # | |
Defined in Cardano.Ledger.Alonzo.TxBody Methods getField :: TxBody era -> StrictMaybe ( ScriptIntegrityHash c) Source # |
|
( Era era, c ~ Crypto era) => HashAnnotated ( ScriptIntegrity era) EraIndependentScriptIntegrity c Source # | |
Defined in Cardano.Ledger.Alonzo.Tx Methods indexProxy :: ScriptIntegrity era -> Proxy EraIndependentScriptIntegrity Source # |
data ScriptIntegrity era Source #
A ScriptIntegrityHash is the hash of three things. The first two come from the witnesses and the last comes from the Protocol Parameters.
Constructors
ScriptIntegrity !( Redeemers era) !( TxDats era) !( Set LangDepView ) |
Instances
type ScriptIntegrityHash crypto = SafeHash crypto EraIndependentScriptIntegrity Source #
data ValidatedTx era Source #
Constructors
ValidatedTx | |
Fields
|
Instances
txscripts' :: TxWitness era -> Map ( ScriptHash ( Crypto era)) ( Script era) Source #
data TxBody era where Source #
Bundled Patterns
pattern TxBody :: AlonzoBody era => Set ( TxIn ( Crypto era)) -> Set ( TxIn ( Crypto era)) -> StrictSeq ( TxOut era) -> StrictSeq ( DCert ( Crypto era)) -> Wdrl ( Crypto era) -> Coin -> ValidityInterval -> StrictMaybe ( Update era) -> Set ( KeyHash ' Witness ( Crypto era)) -> Value ( Crypto era) -> StrictMaybe ( ScriptIntegrityHash ( Crypto era)) -> StrictMaybe ( AuxiliaryDataHash ( Crypto era)) -> StrictMaybe Network -> TxBody era |
Instances
totExUnits :: ( HasField "wits" ( Tx era) ( Witnesses era), HasField "txrdmrs" ( Witnesses era) ( Redeemers era)) => Tx era -> ExUnits Source #
isTwoPhaseScriptAddress :: forall era. ValidateScript era => ValidatedTx era -> Addr ( Crypto era) -> Bool Source #
minfee :: ( HasField "_minfeeA" ( PParams era) Natural , HasField "_minfeeB" ( PParams era) Natural , HasField "_prices" ( PParams era) Prices , HasField "wits" ( Tx era) ( Witnesses era), HasField "txrdmrs" ( Witnesses era) ( Redeemers era), HasField "txsize" ( Tx era) Integer ) => PParams era -> Tx era -> Coin Source #
class Indexable elem container where Source #
Methods
indexOf :: elem -> container -> StrictMaybe Word64 Source #
fromIndex :: Word64 -> container -> StrictMaybe elem Source #
data ScriptPurpose crypto Source #
Constructors
Minting !( PolicyID crypto) | |
Spending !( TxIn crypto) | |
Rewarding !( RewardAcnt crypto) | |
Certifying !( DCert crypto) |
Instances
isTwoPhaseScriptAddressFromMap :: forall era. ValidateScript era => Map ( ScriptHash ( Crypto era)) ( Script era) -> Addr ( Crypto era) -> Bool Source #
Compute if an Addr has the hash of a TwoPhaseScript, we can tell what kind of Script from the Hash, by looking it up in the Map
alonzoInputHashes :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), ValidateScript era, TxOut era ~ TxOut era) => Map ( ScriptHash ( Crypto era)) ( Script era) -> ValidatedTx era -> UTxO era -> ( Set ( DataHash ( Crypto era)), Set ( TxIn ( Crypto era))) Source #
txouts :: Era era => TxBody era -> UTxO era Source #
Compute the transaction outputs of a transaction.
indexedRdmrs :: forall era tx. ( Era era, HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "wits" tx ( TxWitness era), HasField "body" tx ( TxBody era)) => tx -> ScriptPurpose ( Crypto era) -> Maybe ( Data era, ExUnits ) Source #
Find the Data and ExUnits assigned to a script.
rdptr :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "minted" ( TxBody era) ( Set ( ScriptHash ( Crypto era)))) => TxBody era -> ScriptPurpose ( Crypto era) -> StrictMaybe RdmrPtr Source #
rdptrInv :: forall era. ( HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "minted" ( TxBody era) ( Set ( ScriptHash ( Crypto era)))) => TxBody era -> RdmrPtr -> StrictMaybe ( ScriptPurpose ( Crypto era)) Source #
segwitTx :: Annotator ( TxBody era) -> Annotator ( TxWitness era) -> IsValid -> Maybe ( Annotator ( AuxiliaryData era)) -> Annotator ( ValidatedTx era) Source #
toCBORForSizeComputation :: ( Typeable era, ToCBOR ( TxBody era), ToCBOR ( AuxiliaryData era)) => ValidatedTx era -> Encoding Source #
This ensures that the size of transactions from Mary is unchanged. The individual components all store their bytes; the only work we do in this function is concatenating
toCBORForMempoolSubmission :: ( Typeable era, ToCBOR ( TxBody era), ToCBOR ( AuxiliaryData era)) => ValidatedTx era -> Encoding Source #
Encode to CBOR for the purposes of transmission from node to node, or from wallet to node.
Note that this serialisation is neither the serialisation used on-chain
(where Txs are deconstructed using segwit), nor the serialisation used for
computing the transaction size (which omits the
IsValid
field for
compatibility with Mary - see
toCBORForSizeComputation
).