{-# LANGUAGE GADTs #-}
module Cardano.Api.Internal.Experimental.Witness.AnyWitness
(
AnyWitness (..)
, getAnyWitnessScript
, getAnyWitnessPlutusLanguage
, getAnyWitnessScriptData
)
where
import Cardano.Api.Internal.Eon.AlonzoEraOnwards
import Cardano.Api.Internal.Eon.ShelleyBasedEra
( ShelleyBasedEra (..)
, ShelleyLedgerEra
, forShelleyBasedEraInEon
)
import Cardano.Api.Internal.Experimental.Plutus.Script
import Cardano.Api.Internal.Experimental.Plutus.ScriptWitness
import Cardano.Api.Internal.Experimental.Simple.Script
( SimpleScript (SimpleScript)
, SimpleScriptOrReferenceInput (..)
)
import Cardano.Api.Internal.ScriptData
import Cardano.Api.Ledger qualified as L
import Cardano.Ledger.Alonzo.Scripts qualified as L
import Cardano.Ledger.Babbage.Scripts qualified as L
import Cardano.Ledger.Conway.Scripts qualified as L
import Cardano.Ledger.Core qualified as L
import Cardano.Ledger.Plutus.Data qualified as L
import Cardano.Ledger.Plutus.Language qualified as L
import GHC.Exts
data AnyWitness era where
AnyKeyWitnessPlaceholder :: AnyWitness era
AnySimpleScriptWitness :: SimpleScriptOrReferenceInput era -> AnyWitness era
AnyPlutusScriptWitness :: PlutusScriptWitness lang purpose era -> AnyWitness era
getAnyWitnessPlutusLanguage :: AnyWitness era -> Maybe L.Language
getAnyWitnessPlutusLanguage :: forall era. AnyWitness era -> Maybe Language
getAnyWitnessPlutusLanguage AnyWitness era
AnyKeyWitnessPlaceholder = Maybe Language
forall a. Maybe a
Nothing
getAnyWitnessPlutusLanguage (AnySimpleScriptWitness SimpleScriptOrReferenceInput era
_) = Maybe Language
forall a. Maybe a
Nothing
getAnyWitnessPlutusLanguage (AnyPlutusScriptWitness PlutusScriptWitness lang purpose era
swit) = Language -> Maybe Language
forall a. a -> Maybe a
Just (Language -> Maybe Language) -> Language -> Maybe Language
forall a b. (a -> b) -> a -> b
$ PlutusScriptWitness lang purpose era -> Language
forall (lang :: Language) (purpose :: PlutusScriptPurpose) era.
PlutusScriptWitness lang purpose era -> Language
getPlutusScriptWitnessLanguage PlutusScriptWitness lang purpose era
swit
getAnyWitnessSimpleScript
:: AnyWitness (ShelleyLedgerEra era) -> Maybe (L.NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript :: forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyKeyWitnessPlaceholder = Maybe (NativeScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessSimpleScript (AnySimpleScriptWitness SimpleScriptOrReferenceInput (ShelleyLedgerEra era)
simpleScriptOrRefInput) =
case SimpleScriptOrReferenceInput (ShelleyLedgerEra era)
simpleScriptOrRefInput of
SScript (SimpleScript NativeScript (ShelleyLedgerEra era)
simpleScript) -> NativeScript (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
forall a. a -> Maybe a
Just NativeScript (ShelleyLedgerEra era)
simpleScript
SReferenceScript{} -> Maybe (NativeScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessSimpleScript (AnyPlutusScriptWitness PlutusScriptWitness lang purpose (ShelleyLedgerEra era)
_) = Maybe (NativeScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessPlutusScript
:: AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (L.PlutusScript (ShelleyLedgerEra era))
getAnyWitnessPlutusScript :: forall era.
AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
getAnyWitnessPlutusScript AlonzoEraOnwards era
_ AnyWitness (ShelleyLedgerEra era)
AnyKeyWitnessPlaceholder = Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessPlutusScript AlonzoEraOnwards era
_ (AnySimpleScriptWitness SimpleScriptOrReferenceInput (ShelleyLedgerEra era)
_) = Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessPlutusScript
AlonzoEraOnwards era
eon
( AnyPlutusScriptWitness
(PlutusScriptWitness SLanguage lang
l (PScript (PlutusScriptInEra PlutusRunnable lang
plutusScriptRunnable)) PlutusScriptDatum lang purpose
_ ScriptRedeemer
_ ExecutionUnits
_)
) = SLanguage lang
-> AlonzoEraOnwards era
-> PlutusRunnable lang
-> Maybe (PlutusScript (ShelleyLedgerEra era))
forall (lang :: Language) era.
SLanguage lang
-> AlonzoEraOnwards era
-> PlutusRunnable lang
-> Maybe (PlutusScript (ShelleyLedgerEra era))
fromPlutusRunnable SLanguage lang
l AlonzoEraOnwards era
eon PlutusRunnable lang
plutusScriptRunnable
getAnyWitnessPlutusScript AlonzoEraOnwards era
_ (AnyPlutusScriptWitness (PlutusScriptWitness SLanguage lang
_ (PReferenceScript{}) PlutusScriptDatum lang purpose
_ ScriptRedeemer
_ ExecutionUnits
_)) =
Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessScriptData
:: AlonzoEraOnwards era -> AnyWitness (ShelleyLedgerEra era) -> L.TxDats (ShelleyLedgerEra era)
getAnyWitnessScriptData :: forall era.
AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
getAnyWitnessScriptData AlonzoEraOnwards era
eon AnyWitness (ShelleyLedgerEra era)
AnyKeyWitnessPlaceholder = AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon TxDats (ShelleyLedgerEra era)
AlonzoEraOnwardsConstraints era => TxDats (ShelleyLedgerEra era)
forall a. Monoid a => a
mempty
getAnyWitnessScriptData AlonzoEraOnwards era
eon AnySimpleScriptWitness{} = AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon TxDats (ShelleyLedgerEra era)
AlonzoEraOnwardsConstraints era => TxDats (ShelleyLedgerEra era)
forall a. Monoid a => a
mempty
getAnyWitnessScriptData AlonzoEraOnwards era
eon (AnyPlutusScriptWitness (PlutusScriptWitness SLanguage lang
l PlutusScriptOrReferenceInput lang (ShelleyLedgerEra era)
_ PlutusScriptDatum lang purpose
scriptDatum ScriptRedeemer
_ ExecutionUnits
_)) =
let alonzoSdat :: Maybe (Data (ShelleyLedgerEra era))
alonzoSdat = AlonzoEraOnwards era
-> SLanguage lang
-> PlutusScriptDatum lang purpose
-> Maybe (Data (ShelleyLedgerEra era))
forall era (lang :: Language) (purpose :: PlutusScriptPurpose).
AlonzoEraOnwards era
-> SLanguage lang
-> PlutusScriptDatum lang purpose
-> Maybe (Data (ShelleyLedgerEra era))
toAlonzoDatum AlonzoEraOnwards era
eon SLanguage lang
l PlutusScriptDatum lang purpose
scriptDatum
in AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon ((AlonzoEraOnwardsConstraints era => TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era))
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
case Maybe (Data (ShelleyLedgerEra era))
alonzoSdat of
Maybe (Data (ShelleyLedgerEra era))
Nothing -> AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon TxDats (ShelleyLedgerEra era)
AlonzoEraOnwardsConstraints era => TxDats (ShelleyLedgerEra era)
forall a. Monoid a => a
mempty
Just Data (ShelleyLedgerEra era)
d -> AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon ((AlonzoEraOnwardsConstraints era => TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era))
-> (AlonzoEraOnwardsConstraints era =>
TxDats (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ Map DataHash (Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era. Era era => Map DataHash (Data era) -> TxDats era
L.TxDats (Map DataHash (Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era))
-> Map DataHash (Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ [Item (Map DataHash (Data (ShelleyLedgerEra era)))]
-> Map DataHash (Data (ShelleyLedgerEra era))
forall l. IsList l => [Item l] -> l
fromList [(Data (ShelleyLedgerEra era) -> DataHash
forall era. Data era -> DataHash
L.hashData Data (ShelleyLedgerEra era)
d, Data (ShelleyLedgerEra era)
d)]
getAnyWitnessScript
:: ShelleyBasedEra era -> AnyWitness (ShelleyLedgerEra era) -> Maybe (L.Script (ShelleyLedgerEra era))
getAnyWitnessScript :: forall era.
ShelleyBasedEra era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (Script (ShelleyLedgerEra era))
getAnyWitnessScript ShelleyBasedEra era
_ AnyWitness (ShelleyLedgerEra era)
AnyKeyWitnessPlaceholder = Maybe (Script (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getAnyWitnessScript ShelleyBasedEra era
era ss :: AnyWitness (ShelleyLedgerEra era)
ss@(AnySimpleScriptWitness{}) =
case ShelleyBasedEra era
era of
ShelleyBasedEra era
ShelleyBasedEraShelley -> AnyWitness (ShelleyLedgerEra ShelleyEra)
-> Maybe (NativeScript (ShelleyLedgerEra ShelleyEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra ShelleyEra)
ss
ShelleyBasedEra era
ShelleyBasedEraAllegra -> AnyWitness (ShelleyLedgerEra AllegraEra)
-> Maybe (NativeScript (ShelleyLedgerEra AllegraEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra AllegraEra)
ss
ShelleyBasedEra era
ShelleyBasedEraMary -> AnyWitness (ShelleyLedgerEra MaryEra)
-> Maybe (NativeScript (ShelleyLedgerEra MaryEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra MaryEra)
ss
ShelleyBasedEra era
ShelleyBasedEraAlonzo -> Timelock AlonzoEra -> AlonzoScript AlonzoEra
forall era. Timelock era -> AlonzoScript era
L.TimelockScript (Timelock AlonzoEra -> AlonzoScript AlonzoEra)
-> Maybe (Timelock AlonzoEra) -> Maybe (AlonzoScript AlonzoEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnyWitness (ShelleyLedgerEra AlonzoEra)
-> Maybe (NativeScript (ShelleyLedgerEra AlonzoEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra AlonzoEra)
ss
ShelleyBasedEra era
ShelleyBasedEraBabbage -> Timelock BabbageEra -> AlonzoScript BabbageEra
forall era. Timelock era -> AlonzoScript era
L.TimelockScript (Timelock BabbageEra -> AlonzoScript BabbageEra)
-> Maybe (Timelock BabbageEra) -> Maybe (AlonzoScript BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnyWitness (ShelleyLedgerEra BabbageEra)
-> Maybe (NativeScript (ShelleyLedgerEra BabbageEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra BabbageEra)
ss
ShelleyBasedEra era
ShelleyBasedEraConway -> Timelock ConwayEra -> AlonzoScript ConwayEra
forall era. Timelock era -> AlonzoScript era
L.TimelockScript (Timelock ConwayEra -> AlonzoScript ConwayEra)
-> Maybe (Timelock ConwayEra) -> Maybe (AlonzoScript ConwayEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnyWitness (ShelleyLedgerEra ConwayEra)
-> Maybe (NativeScript (ShelleyLedgerEra ConwayEra))
forall era.
AnyWitness (ShelleyLedgerEra era)
-> Maybe (NativeScript (ShelleyLedgerEra era))
getAnyWitnessSimpleScript AnyWitness (ShelleyLedgerEra era)
AnyWitness (ShelleyLedgerEra ConwayEra)
ss
getAnyWitnessScript ShelleyBasedEra era
era ps :: AnyWitness (ShelleyLedgerEra era)
ps@(AnyPlutusScriptWitness{}) =
ShelleyBasedEra era
-> Maybe (Script (ShelleyLedgerEra era))
-> (AlonzoEraOnwards era -> Maybe (Script (ShelleyLedgerEra era)))
-> Maybe (Script (ShelleyLedgerEra era))
forall (eon :: * -> *) era a.
Eon eon =>
ShelleyBasedEra era -> a -> (eon era -> a) -> a
forShelleyBasedEraInEon ShelleyBasedEra era
era Maybe (Script (ShelleyLedgerEra era))
forall a. Maybe a
Nothing ((AlonzoEraOnwards era -> Maybe (Script (ShelleyLedgerEra era)))
-> Maybe (Script (ShelleyLedgerEra era)))
-> (AlonzoEraOnwards era -> Maybe (Script (ShelleyLedgerEra era)))
-> Maybe (Script (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ \AlonzoEraOnwards era
aEon ->
case AlonzoEraOnwards era
aEon of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo -> PlutusScript AlonzoEra -> AlonzoScript AlonzoEra
forall era. PlutusScript era -> AlonzoScript era
L.PlutusScript (PlutusScript AlonzoEra -> AlonzoScript AlonzoEra)
-> Maybe (PlutusScript AlonzoEra) -> Maybe (AlonzoScript AlonzoEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
forall era.
AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
getAnyWitnessPlutusScript AlonzoEraOnwards era
aEon AnyWitness (ShelleyLedgerEra era)
ps
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage -> PlutusScript BabbageEra -> AlonzoScript BabbageEra
forall era. PlutusScript era -> AlonzoScript era
L.PlutusScript (PlutusScript BabbageEra -> AlonzoScript BabbageEra)
-> Maybe (PlutusScript BabbageEra)
-> Maybe (AlonzoScript BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
forall era.
AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
getAnyWitnessPlutusScript AlonzoEraOnwards era
aEon AnyWitness (ShelleyLedgerEra era)
ps
AlonzoEraOnwards era
AlonzoEraOnwardsConway -> PlutusScript ConwayEra -> AlonzoScript ConwayEra
forall era. PlutusScript era -> AlonzoScript era
L.PlutusScript (PlutusScript ConwayEra -> AlonzoScript ConwayEra)
-> Maybe (PlutusScript ConwayEra) -> Maybe (AlonzoScript ConwayEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
forall era.
AlonzoEraOnwards era
-> AnyWitness (ShelleyLedgerEra era)
-> Maybe (PlutusScript (ShelleyLedgerEra era))
getAnyWitnessPlutusScript AlonzoEraOnwards era
aEon AnyWitness (ShelleyLedgerEra era)
ps
fromPlutusRunnable
:: L.SLanguage lang
-> AlonzoEraOnwards era
-> L.PlutusRunnable lang
-> Maybe (L.PlutusScript (ShelleyLedgerEra era))
fromPlutusRunnable :: forall (lang :: Language) era.
SLanguage lang
-> AlonzoEraOnwards era
-> PlutusRunnable lang
-> Maybe (PlutusScript (ShelleyLedgerEra era))
fromPlutusRunnable SLanguage lang
L.SPlutusV1 AlonzoEraOnwards era
eon PlutusRunnable lang
runnable =
case AlonzoEraOnwards era
eon of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript AlonzoEra -> Maybe (PlutusScript AlonzoEra)
forall a. a -> Maybe a
Just (PlutusScript AlonzoEra -> Maybe (PlutusScript AlonzoEra))
-> PlutusScript AlonzoEra -> Maybe (PlutusScript AlonzoEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV1 -> PlutusScript AlonzoEra
L.AlonzoPlutusV1 Plutus lang
Plutus 'PlutusV1
plutusScript
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra)
forall a. a -> Maybe a
Just (PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra))
-> PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV1 -> PlutusScript BabbageEra
L.BabbagePlutusV1 Plutus lang
Plutus 'PlutusV1
plutusScript
AlonzoEraOnwards era
AlonzoEraOnwardsConway ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a. a -> Maybe a
Just (PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra))
-> PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV1 -> PlutusScript ConwayEra
L.ConwayPlutusV1 Plutus lang
Plutus 'PlutusV1
plutusScript
fromPlutusRunnable SLanguage lang
L.SPlutusV2 AlonzoEraOnwards era
eon PlutusRunnable lang
runnable =
case AlonzoEraOnwards era
eon of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo -> Maybe (PlutusScript AlonzoEra)
Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra)
forall a. a -> Maybe a
Just (PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra))
-> PlutusScript BabbageEra -> Maybe (PlutusScript BabbageEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV2 -> PlutusScript BabbageEra
L.BabbagePlutusV2 Plutus lang
Plutus 'PlutusV2
plutusScript
AlonzoEraOnwards era
AlonzoEraOnwardsConway ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a. a -> Maybe a
Just (PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra))
-> PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV2 -> PlutusScript ConwayEra
L.ConwayPlutusV2 Plutus lang
Plutus 'PlutusV2
plutusScript
fromPlutusRunnable SLanguage lang
L.SPlutusV3 AlonzoEraOnwards era
eon PlutusRunnable lang
runnable =
case AlonzoEraOnwards era
eon of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo -> Maybe (PlutusScript AlonzoEra)
Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage -> Maybe (PlutusScript BabbageEra)
Maybe (PlutusScript (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
AlonzoEraOnwards era
AlonzoEraOnwardsConway ->
let plutusScript :: Plutus lang
plutusScript = PlutusRunnable lang -> Plutus lang
forall (l :: Language). PlutusRunnable l -> Plutus l
L.plutusFromRunnable PlutusRunnable lang
runnable
in PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a. a -> Maybe a
Just (PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra))
-> PlutusScript ConwayEra -> Maybe (PlutusScript ConwayEra)
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV3 -> PlutusScript ConwayEra
L.ConwayPlutusV3 Plutus lang
Plutus 'PlutusV3
plutusScript
toAlonzoDatum
:: AlonzoEraOnwards era
-> L.SLanguage lang
-> PlutusScriptDatum lang purpose
-> Maybe (L.Data (ShelleyLedgerEra era))
toAlonzoDatum :: forall era (lang :: Language) (purpose :: PlutusScriptPurpose).
AlonzoEraOnwards era
-> SLanguage lang
-> PlutusScriptDatum lang purpose
-> Maybe (Data (ShelleyLedgerEra era))
toAlonzoDatum AlonzoEraOnwards era
eon SLanguage lang
l PlutusScriptDatum lang purpose
d =
let mHashableData :: Maybe ScriptRedeemer
mHashableData = SLanguage lang
-> PlutusScriptDatum lang purpose -> Maybe ScriptRedeemer
forall (lang :: Language) (purpose :: PlutusScriptPurpose).
SLanguage lang
-> PlutusScriptDatum lang purpose -> Maybe ScriptRedeemer
getPlutusDatum SLanguage lang
l PlutusScriptDatum lang purpose
d
in case Maybe ScriptRedeemer
mHashableData of
Just ScriptRedeemer
h -> Data (ShelleyLedgerEra era) -> Maybe (Data (ShelleyLedgerEra era))
forall a. a -> Maybe a
Just (Data (ShelleyLedgerEra era)
-> Maybe (Data (ShelleyLedgerEra era)))
-> Data (ShelleyLedgerEra era)
-> Maybe (Data (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => Data (ShelleyLedgerEra era))
-> Data (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
eon ((AlonzoEraOnwardsConstraints era => Data (ShelleyLedgerEra era))
-> Data (ShelleyLedgerEra era))
-> (AlonzoEraOnwardsConstraints era => Data (ShelleyLedgerEra era))
-> Data (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ ScriptRedeemer -> Data (ShelleyLedgerEra era)
forall ledgerera. Era ledgerera => ScriptRedeemer -> Data ledgerera
toAlonzoData ScriptRedeemer
h
Maybe ScriptRedeemer
Nothing -> Maybe (Data (ShelleyLedgerEra era))
forall a. Maybe a
Nothing
getPlutusDatum
:: L.SLanguage lang -> PlutusScriptDatum lang purpose -> Maybe HashableScriptData
getPlutusDatum :: forall (lang :: Language) (purpose :: PlutusScriptPurpose).
SLanguage lang
-> PlutusScriptDatum lang purpose -> Maybe ScriptRedeemer
getPlutusDatum SLanguage lang
L.SPlutusV1 (SpendingScriptDatum PlutusScriptDatumF lang 'SpendingScript
d) = ScriptRedeemer -> Maybe ScriptRedeemer
forall a. a -> Maybe a
Just ScriptRedeemer
PlutusScriptDatumF lang 'SpendingScript
d
getPlutusDatum SLanguage lang
L.SPlutusV2 (SpendingScriptDatum PlutusScriptDatumF lang 'SpendingScript
d) = ScriptRedeemer -> Maybe ScriptRedeemer
forall a. a -> Maybe a
Just ScriptRedeemer
PlutusScriptDatumF lang 'SpendingScript
d
getPlutusDatum SLanguage lang
L.SPlutusV3 (SpendingScriptDatum PlutusScriptDatumF lang 'SpendingScript
d) = Maybe ScriptRedeemer
PlutusScriptDatumF lang 'SpendingScript
d
getPlutusDatum SLanguage lang
_ PlutusScriptDatum lang purpose
InlineDatum = Maybe ScriptRedeemer
forall a. Maybe a
Nothing
getPlutusDatum SLanguage lang
_ PlutusScriptDatum lang purpose
NoScriptDatum = Maybe ScriptRedeemer
forall a. Maybe a
Nothing