cardano-ledger-alonzo-1.16.0.0: Cardano ledger introducing Plutus Core
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Alonzo.Plutus.Context

Synopsis

Documentation

data LedgerTxInfo era where Source #

All information that is necessary from the ledger to construct Plutus' TxInfo.

Constructors

LedgerTxInfo 

Fields

class (PlutusLanguage l, EraPlutusContext era, EraTxLevel era, Eq (PlutusTxInfo l), Show (PlutusTxInfo l)) ⇒ EraPlutusTxInfo (l ∷ Language) era where Source #

Methods

toPlutusTxCert ∷ proxy l → ProtVerTxCert era → Either (ContextError era) (PlutusTxCert l) Source #

toPlutusScriptPurpose ∷ proxy l → ProtVerPlutusPurpose AsIxItem era → Either (ContextError era) (PlutusScriptPurpose l) Source #

toPlutusTxInfo ∷ proxy l → LedgerTxInfo era → PlutusTxInfoResult l era Source #

toPlutusArgs ∷ proxy l → ProtVerPlutusTxInfo l → PlutusPurpose AsIxItem era → Maybe (Data era) → Data era → Either (ContextError era) (PlutusArgs l) Source #

toPlutusTxInInfo ∷ proxy l → UTxO era → TxInEither (ContextError era) (PlutusTxInInfo era l) Source #

newtype PlutusTxInfoResult (l ∷ Language) era Source #

This is the helper type that captures translation of Tx to PlutusTxInfo.

It is important to note that TxInfo is always the same per Plutus version for each Tx. This invariant allows us to avoid duplicate computation by memoizing all possible PlutusTxInfos per transaction. Starting with Dijkstra era there is a slight complication introduced to this invariant where top level transaction has a different PlutusTxInfo for Guarding purpose, when compared to all other purposes. That is the reason why result is somewhat strange, namely a function from PlutusPurpose to PlutusTxInfo. It is also done this way, instead of adding ScriptPurpose as an argument to toPlutusTxInfo to preserve capability of memoization, hence nested Either

mkPlutusTxInfoFromResult ∷ ∀ era (l ∷ Language). PlutusPurpose AsPurpose era → PlutusTxInfoResult l era → Either (ContextError era) (PlutusTxInfo l) Source #

Given the prepared PlutusTxInfoResult and the purpose this function allows constructing the PlutusTxInfo, while memoizing the computation from PlutusTxInfoResult for its subsequent uses.

toPlutusTxInfoForPurpose ∷ ∀ (l ∷ Language) era proxy. EraPlutusTxInfo l era ⇒ proxy l → LedgerTxInfo era → PlutusPurpose AsPurpose era → Either (ContextError era) (PlutusTxInfo l) Source #

This is what toPlutusTxInfo would be without the intermediate PlutusTxInfoResult.

Note - Using this function totally drops any memoization of TxInfo, as such use it only for testing or tooling that doesn't care about performance.

class (AlonzoEraScript era, Eq (ContextError era), Show (ContextError era), NFData (ContextError era), EncCBOR (ContextError era), DecCBOR (ContextError era), ToJSON (ContextError era)) ⇒ EraPlutusContext era where Source #

Associated Types

type ContextError era = (r ∷ Type) | r → era Source #

data TxInfoResult era Source #

This data type family is used to memoize the results of toPlutusTxInfo, so the outcome can be shared between execution of different scripts with the same language version.

Methods

mkSupportedLanguageLanguageMaybe (SupportedLanguage era) Source #

mkTxInfoResultLedgerTxInfo era → TxInfoResult era Source #

Construct PlutusTxInfo for all supported languages in this era.

lookupTxInfoResult ∷ ∀ (l ∷ Language). EraPlutusTxInfo l era ⇒ SLanguage l → TxInfoResult era → PlutusTxInfoResult l era Source #

TxInfo for the same language can be shared between executions of every script of the same version in a single transaction.

Note - The EraPlutusTxInfo is here only to enforce this function is not called with an unsupported plutus language version.

mkPlutusWithContextPlutusScript era → ScriptHashPlutusPurpose AsIxItem era → LedgerTxInfo era → TxInfoResult era → (Data era, ExUnits) → CostModelEither (ContextError era) PlutusWithContext Source #

lookupTxInfoResultImpossible ∷ ∀ (l ∷ Language) era. (HasCallStack, EraPlutusTxInfo l era) ⇒ SLanguage l → PlutusTxInfoResult l era Source #

Helper function to use when implementing lookupTxInfoResult for plutus languages that are not supported by the era.

data SupportedLanguage era where Source #

Constructors

SupportedLanguage ∷ ∀ (l ∷ Language) era. EraPlutusTxInfo l era ⇒ SLanguage l → SupportedLanguage era 

Instances

Instances details
EraPlutusContext era ⇒ DecCBOR (SupportedLanguage era) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.Plutus.Context

Era era ⇒ EncCBOR (SupportedLanguage era) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.Plutus.Context

Show (SupportedLanguage era) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.Plutus.Context

Eq (SupportedLanguage era) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.Plutus.Context

Ord (SupportedLanguage era) Source # 
Instance details

Defined in Cardano.Ledger.Alonzo.Plutus.Context

mkSupportedPlutusScript ∷ ∀ (l ∷ Language) era. (HasCallStack, EraPlutusTxInfo l era) ⇒ Plutus l → PlutusScript era Source #

This is just like mkPlutusScript, except it is guaranteed to be total through the enforcement of support by the type system and EraPlutusTxInfo type class instances for supported plutus versions.

mkSupportedBinaryPlutusScript ∷ (HasCallStack, AlonzoEraScript era) ⇒ SupportedLanguage era → PlutusBinaryPlutusScript era Source #

This is just like mkBinaryPlutusScript, except it is guaranteed to be total through the enforcement of support by the type system and EraPlutusTxInfo type class instances (via calling `mkSupportedPlutusScript) for supported plutus versions.

Language dependent translation