diff --git a/hydra-cardano-api/src/Hydra/Cardano/Api/PlutusScript.hs b/hydra-cardano-api/src/Hydra/Cardano/Api/PlutusScript.hs index 71c2949429e..d5313ddddb0 100644 --- a/hydra-cardano-api/src/Hydra/Cardano/Api/PlutusScript.hs +++ b/hydra-cardano-api/src/Hydra/Cardano/Api/PlutusScript.hs @@ -4,30 +4,12 @@ module Hydra.Cardano.Api.PlutusScript where import Hydra.Cardano.Api.Prelude -import Cardano.Ledger.Alonzo.Scripts qualified as Ledger -import Cardano.Ledger.Plutus.Language qualified as Ledger import Data.ByteString.Short qualified as SBS import PlutusLedgerApi.Common qualified as Plutus import Test.QuickCheck (listOf) -- * Type Conversions --- | Convert a cardano-ledger 'Script' into a cardano-api 'PlutusScript' --- --- NOTE: This function is unsafe in two manners: --- --- (a) If the given script is a timelock script, it throws an impure exception; --- (b) If the given script is in a wrong language, it silently coerces it. -fromLedgerScript :: - ( HasCallStack - , Ledger.AlonzoEraScript era - ) => - Ledger.AlonzoScript era -> - PlutusScript lang -fromLedgerScript = \case - Ledger.TimelockScript{} -> error "fromLedgerScript: TimelockScript" - Ledger.PlutusScript x -> Ledger.withPlutusScript x (\(Ledger.Plutus (Ledger.PlutusBinary bytes)) -> PlutusScriptSerialised bytes) - -- | Convert a serialized plutus script into a cardano-api 'PlutusScript'. fromPlutusScript :: Plutus.SerialisedScript -> PlutusScript lang fromPlutusScript = diff --git a/hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs b/hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs index 5e6284fadb0..f05a962e162 100644 --- a/hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs +++ b/hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs @@ -11,12 +11,8 @@ import Cardano.Ledger.Api ( ) import Cardano.Ledger.Babbage.Core (redeemerPointer) import Cardano.Ledger.BaseTypes (strictMaybeToMaybe) -import Cardano.Ledger.Core qualified as Ledger import Cardano.Ledger.Plutus.Data qualified as Ledger -import Data.List (find) import Data.Map qualified as Map -import Hydra.Cardano.Api.PlutusScript (fromLedgerScript) -import Hydra.Cardano.Api.PolicyId (toLedgerPolicyID, toLedgerScriptHash) import Hydra.Cardano.Api.TxIn (toLedgerTxIn) import PlutusLedgerApi.V3 qualified as Plutus @@ -31,27 +27,6 @@ findRedeemerSpending (getTxBody -> ShelleyTxBody _ body _ scriptData _ _) txIn = ptr <- strictMaybeToMaybe $ redeemerPointer body (ConwaySpending . AsItem $ toLedgerTxIn txIn) lookupRedeemer ptr scriptData -findRedeemerMinting :: - Plutus.FromData a => - Tx Era -> - PolicyId -> - Maybe a -findRedeemerMinting (getTxBody -> ShelleyTxBody _ body _ scriptData _ _) pid = do - ptr <- strictMaybeToMaybe $ redeemerPointer body (ConwayMinting . AsItem $ toLedgerPolicyID pid) - lookupRedeemer ptr scriptData - -findScriptMinting :: - forall lang. - () => - Tx Era -> - PolicyId -> - Maybe (PlutusScript lang) -findScriptMinting (getTxBody -> ShelleyTxBody _ _ scripts _ _ _) pid = do - fromLedgerScript @_ @lang - <$> find ((== needle) . Ledger.hashScript @(ShelleyLedgerEra Era)) scripts - where - needle = toLedgerScriptHash pid - -- -- Internals --