From 5259d54bf261698992827d10df5d61ce61c0eee3 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 13 Dec 2023 16:25:00 -0400 Subject: [PATCH] Pre refactor --- .../internal/Cardano/Api/Protocol/Version.hs | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Protocol/Version.hs b/cardano-api/internal/Cardano/Api/Protocol/Version.hs index fb5aafff6d..54c01d65ad 100644 --- a/cardano-api/internal/Cardano/Api/Protocol/Version.hs +++ b/cardano-api/internal/Cardano/Api/Protocol/Version.hs @@ -58,6 +58,60 @@ protocolVersionToSbe protocolVersionToSbe CurrentProtocolVersion = ShelleyBasedEraBabbage protocolVersionToSbe ExperimentalProtocolVersion = ShelleyBasedEraConway -createSingleProtVerProxy - :: Proxy version -> SingleProtVer version -createSingleProtVerProxy _ = SingleProtVer +-- An Example +validateTxBodyContent' + :: ShelleyBasedEra era + -> TxBodyContent BuildTx era + -> Either TxBodyError () +validateTxBodyContent' sbe txBodContent@TxBodyContent { + txIns, + txInsCollateral, + txOuts, + txProtocolParams, + txMintValue, + txMetadata} = + let witnesses = collectTxBodyScriptWitnesses sbe txBodContent + languages = Set.fromList + [ toAlonzoLanguage (AnyPlutusScriptVersion v) + | (_, AnyScriptWitness (PlutusScriptWitness _ v _ _ _ _)) <- witnesses + ] + in case sbe of + ShelleyBasedEraShelley -> do + validateTxIns txIns + guardShelleyTxInsOverflow (map fst txIns) + validateTxOuts sbe txOuts + validateMetadata txMetadata + ShelleyBasedEraAllegra -> do + validateTxIns txIns + guardShelleyTxInsOverflow (map fst txIns) + validateTxOuts sbe txOuts + validateMetadata txMetadata + ShelleyBasedEraMary -> do + validateTxIns txIns + guardShelleyTxInsOverflow (map fst txIns) + validateTxOuts sbe txOuts + validateMetadata txMetadata + validateMintValue txMintValue + ShelleyBasedEraAlonzo -> do + validateTxIns txIns + guardShelleyTxInsOverflow (map fst txIns) + validateTxOuts sbe txOuts + validateMetadata txMetadata + validateMintValue txMintValue + validateTxInsCollateral txInsCollateral languages + validateProtocolParameters txProtocolParams languages + ShelleyBasedEraBabbage -> do + validateTxIns txIns + guardShelleyTxInsOverflow (map fst txIns) + validateTxOuts sbe txOuts + validateMetadata txMetadata + validateMintValue txMintValue + validateTxInsCollateral txInsCollateral languages + validateProtocolParameters txProtocolParams languages + ShelleyBasedEraConway -> do + validateTxIns txIns + validateTxOuts sbe txOuts + validateMetadata txMetadata + validateMintValue txMintValue + validateTxInsCollateral txInsCollateral languages + validateProtocolParameters txProtocolParams languages