cardano-ledger-alonzo-0.1.0.0: Cardano ledger introducing Plutus Core
Safe Haskell None
Language Haskell2010

Cardano.Ledger.Alonzo.PlutusScriptApi

Synopsis

Documentation

getSpendingTxIn :: ScriptPurpose crypto -> Maybe ( TxIn crypto) Source #

Only the Spending ScriptPurpose contains TxIn

getDatumAlonzo :: forall era tx. ( HasField "datahash" ( TxOut era) ( StrictMaybe ( DataHash ( Crypto era))), HasField "wits" tx ( TxWitness era)) => tx -> UTxO era -> ScriptPurpose ( Crypto era) -> Maybe ( Data era) Source #

Get the Data associated with a ScriptPurpose. Only the Spending ScriptPurpose contains Data. The null list is returned for the other kinds.

evalScripts :: forall era tx. ( Era era, Show ( Script era), HasField "body" tx ( TxBody era), HasField "wits" tx ( TxWitness era), HasField "vldt" ( TxBody era) ValidityInterval ) => ProtVer -> tx -> [( ShortByteString , Language , [ Data era], ExUnits , CostModel )] -> ScriptResult Source #

evaluate a list of scripts, All scripts in the list must be True. There are two kinds of scripts, evaluate each kind using the appropriate mechanism.

scriptsNeededFromBody :: forall era. ( 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)))) => UTxO era -> TxBody era -> [( ScriptPurpose ( Crypto era), ScriptHash ( Crypto era))] Source #

Uses of inputs in ‘txscripts’ and ‘neededScripts’ There are currently 3 sets of inputs (spending, collateral, reference). A particular TxInput can appear in more than one of the sets. Even in all three at the same, but that may not be a really useful case. Inputs are where you find scripts with the Spending purpose.

1) Collateral inputs are only spent if phase two fails. Their corresponding TxOut can only have Key (not Script) Pay credentials, so ‘neededScripts’ does not look there. 2) Reference inputs are not spent in the current Tx, unless that same input also appears in one of the other sets. If that is not the case, their credentials are never needed, so anyone can access the inline datums and scripts in their corresponding TxOut, without needing any authorizing credentials. So ‘neededScripts’ does not look there. 3) Spending inputs are always spent. So their Pay credentials are always needed.

Collect information (purpose and ScriptHash) about all the Credentials that refer to scripts that will be needed to run in a TxBody in the Utxow rule. Note there may be credentials that cannot be run, so are not collected. In Babbage, reference inputs, fit that description. Purposes include 1) Spending (payment script credentials, but NOT staking scripts) in the Addr of a TxOut, pointed to by some input that needs authorization. Be sure (getField @"inputs" txb) gets all such inputs. In some Eras there may be multiple sets of inputs, which ones should be included? Currently that is only the spending inputs. Because collateral inputs can only have key-locked credentials, and reference inputs are never authorized. That might not always be the case. 2) Rewarding (Withdrawals), 3) Minting (minted field), and 4) Certifying (Delegating) scripts.

scriptsNeeded is an aggregation of the needed Credentials referring to Scripts used in Utxow rule. The flip side of scriptsNeeded (which collects script hashes) is txscripts which finds the actual scripts. We maintain an invariant that every script credential refers to some actual script. This is tested in the test function validateMissingScripts in the Utxow rule.

data CollectError crypto Source #

When collecting inputs for twophase scripts, 3 things can go wrong.

Instances

Instances details
Eq ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

Show ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

Generic ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

Associated Types

type Rep ( CollectError crypto) :: Type -> Type Source #

Crypto crypto => ToCBOR ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

Crypto crypto => FromCBOR ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

NoThunks ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

type Rep ( CollectError crypto) Source #
Instance details

Defined in Cardano.Ledger.Alonzo.PlutusScriptApi

collectTwoPhaseScriptInputs :: forall era. ( Era era, ExtendedUTxO era, Script era ~ Script era, HasField "_costmdls" ( PParams era) CostModels , HasField "wdrls" ( TxBody era) ( Wdrl ( Crypto era)), HasField "certs" ( TxBody era) ( StrictSeq ( DCert ( Crypto era))), HasField "inputs" ( TxBody era) ( Set ( TxIn ( Crypto era))), HasField "wits" ( Tx era) ( TxWitness era)) => EpochInfo ( Either Text ) -> SystemStart -> PParams era -> Tx era -> UTxO era -> Either [ CollectError ( Crypto era)] [( ShortByteString , Language , [ Data era], ExUnits , CostModel )] Source #

Collect the inputs for twophase scripts. If any script can't find ist data return a list of CollectError, if all goes well return a list of quadruples with the inputs. Previous PredicateFailure tests should ensure we find Data for every script, BUT the consequences of not finding Data means scripts can get dropped, so things might validate that shouldn't. So we double check that every Script has its Data, and if that is not the case, a PredicateFailure is raised in the Utxos rule.