Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class EraUTxO era ⇒ AlonzoEraUTxO era where
- getSupplementalDataHashes ∷ UTxO era → TxBody era → Set DataHash
- getSpendingDatum ∷ UTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era)
- getAlonzoSpendingDatum ∷ (AlonzoEraTxWits era, AlonzoEraTxOut era, EraTx era) ⇒ UTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era)
- newtype AlonzoScriptsNeeded era = AlonzoScriptsNeeded [(PlutusPurpose AsIxItem era, ScriptHash)]
- getAlonzoScriptsNeeded ∷ (MaryEraTxBody era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → AlonzoScriptsNeeded era
- getSpendingScriptsNeeded ∷ (AlonzoEraScript era, EraTxBody era) ⇒ UTxO era → TxBody era → AlonzoScriptsNeeded era
- getRewardingScriptsNeeded ∷ (AlonzoEraScript era, EraTxBody era) ⇒ TxBody era → AlonzoScriptsNeeded era
- getMintingScriptsNeeded ∷ (AlonzoEraScript era, MaryEraTxBody era) ⇒ TxBody era → AlonzoScriptsNeeded era
- getAlonzoScriptsHashesNeeded ∷ AlonzoScriptsNeeded era → Set ScriptHash
- zipAsIxItem ∷ Foldable f ⇒ f it → (AsIxItem Word32 it → c) → [c]
- getInputDataHashesTxBody ∷ (EraTxBody era, AlonzoEraTxOut era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → ScriptsProvided era → (Set DataHash, Set TxIn)
- getAlonzoWitsVKeyNeeded ∷ ∀ era. (EraTx era, AlonzoEraTxBody era, ShelleyEraTxBody era) ⇒ CertState era → UTxO era → TxBody era → Set (KeyHash 'Witness)
Documentation
class EraUTxO era ⇒ AlonzoEraUTxO era where Source #
getSupplementalDataHashes ∷ UTxO era → TxBody era → Set DataHash Source #
Get data hashes for a transaction that are not required. Such datums are optional, but they can be added to the witness set. In a broaded terms datums corresponding to the inputs that might be spent are the required datums and the datums corresponding to the outputs and reference inputs are the supplemental datums.
getSpendingDatum ∷ UTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era) Source #
Lookup the TxIn from the Spending
ScriptPurpose and find the datum needed for
spending that input. This function will return Nothing
for all script purposes,
except spending, because only spending scripts require an extra datum.
This is similar to getDatum
function as in the spec:
getDatum :: Tx era -> UTxO era -> ScriptPurpose era -> [Data era]
getAlonzoSpendingDatum ∷ (AlonzoEraTxWits era, AlonzoEraTxOut era, EraTx era) ⇒ UTxO era → Tx era → PlutusPurpose AsItem era → Maybe (Data era) Source #
Get the Data associated with a ScriptPurpose. Only the Spending ScriptPurpose contains Data. Nothing is returned for the other kinds.
Scripts needed
newtype AlonzoScriptsNeeded era Source #
Alonzo era style ScriptsNeeded
require also a PlutusPurpose
, not only the ScriptHash
Instances
Monoid (AlonzoScriptsNeeded era) Source # | |
Defined in Cardano.Ledger.Alonzo.UTxO mempty ∷ AlonzoScriptsNeeded era Source # mappend ∷ AlonzoScriptsNeeded era → AlonzoScriptsNeeded era → AlonzoScriptsNeeded era Source # mconcat ∷ [AlonzoScriptsNeeded era] → AlonzoScriptsNeeded era Source # | |
Semigroup (AlonzoScriptsNeeded era) Source # | |
Defined in Cardano.Ledger.Alonzo.UTxO (<>) ∷ AlonzoScriptsNeeded era → AlonzoScriptsNeeded era → AlonzoScriptsNeeded era Source # sconcat ∷ NonEmpty (AlonzoScriptsNeeded era) → AlonzoScriptsNeeded era Source # stimes ∷ Integral b ⇒ b → AlonzoScriptsNeeded era → AlonzoScriptsNeeded era Source # | |
AlonzoEraScript era ⇒ Show (AlonzoScriptsNeeded era) Source # | |
Defined in Cardano.Ledger.Alonzo.UTxO | |
AlonzoEraScript era ⇒ Eq (AlonzoScriptsNeeded era) Source # | |
Defined in Cardano.Ledger.Alonzo.UTxO (==) ∷ AlonzoScriptsNeeded era → AlonzoScriptsNeeded era → Bool Source # (/=) ∷ AlonzoScriptsNeeded era → AlonzoScriptsNeeded era → Bool Source # |
getAlonzoScriptsNeeded ∷ (MaryEraTxBody era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → AlonzoScriptsNeeded 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 (txBody ^. inputsTxBodyL) 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.
getAlonzoScriptsNeeded
is an aggregation of the needed Credentials referring to
Scripts used in Utxow rule. The flip side of getAlonzoScriptsNeeded
(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.
getSpendingScriptsNeeded ∷ (AlonzoEraScript era, EraTxBody era) ⇒ UTxO era → TxBody era → AlonzoScriptsNeeded era Source #
getRewardingScriptsNeeded ∷ (AlonzoEraScript era, EraTxBody era) ⇒ TxBody era → AlonzoScriptsNeeded era Source #
getMintingScriptsNeeded ∷ (AlonzoEraScript era, MaryEraTxBody era) ⇒ TxBody era → AlonzoScriptsNeeded era Source #
Datums needed
getInputDataHashesTxBody ∷ (EraTxBody era, AlonzoEraTxOut era, AlonzoEraScript era) ⇒ UTxO era → TxBody era → ScriptsProvided era → (Set DataHash, Set TxIn) Source #
Compute two sets for all TwoPhase scripts in a Tx.
1) DataHashes for each Two phase Script in a TxIn that has a DataHash 2) TxIns that are TwoPhase scripts, and should have a DataHash but don't.
{ h | (_ → (a,_,h)) ∈ txins tx ◁ utxo, isNonNativeScriptAddress tx a}
WitsVKey needed
getAlonzoWitsVKeyNeeded ∷ ∀ era. (EraTx era, AlonzoEraTxBody era, ShelleyEraTxBody era) ⇒ CertState era → UTxO era → TxBody era → Set (KeyHash 'Witness) Source #
Just like getShelleyWitsVKeyNeeded
, but also requires reqSignerHashesTxBodyL
.
Orphan instances
EraUTxO AlonzoEra Source # | |
type ScriptsNeeded AlonzoEra = (r ∷ Type) Source # getConsumedValue ∷ PParams AlonzoEra → (Credential 'Staking → Maybe Coin) → (Credential 'DRepRole → Maybe Coin) → UTxO AlonzoEra → TxBody AlonzoEra → Value AlonzoEra Source # getProducedValue ∷ PParams AlonzoEra → (KeyHash 'StakePool → Bool) → TxBody AlonzoEra → Value AlonzoEra Source # getScriptsProvided ∷ UTxO AlonzoEra → Tx AlonzoEra → ScriptsProvided AlonzoEra Source # getScriptsNeeded ∷ UTxO AlonzoEra → TxBody AlonzoEra → ScriptsNeeded AlonzoEra Source # getScriptsHashesNeeded ∷ ScriptsNeeded AlonzoEra → Set ScriptHash Source # getWitsVKeyNeeded ∷ CertState AlonzoEra → UTxO AlonzoEra → TxBody AlonzoEra → Set (KeyHash 'Witness) Source # getMinFeeTxUtxo ∷ PParams AlonzoEra → Tx AlonzoEra → UTxO AlonzoEra → Coin Source # |