module Hydra.Cardano.Api.ReferenceScript where

import Hydra.Cardano.Api.Prelude

import Hydra.Cardano.Api.PlutusScript (fromPlutusScript)
import PlutusLedgerApi.V3 qualified as Plutus

-- | Construct a 'ReferenceScript' from any given Plutus script.
--
-- NOTE: The script is treated as a 'PlutusScriptV3'
mkScriptRef :: Plutus.SerialisedScript -> ReferenceScript Era
mkScriptRef :: SerialisedScript -> ReferenceScript Era
mkScriptRef =
  BabbageEraOnwards Era -> ScriptInAnyLang -> ReferenceScript Era
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards Era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra
    (ScriptInAnyLang -> ReferenceScript Era)
-> (SerialisedScript -> ScriptInAnyLang)
-> SerialisedScript
-> ReferenceScript Era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Script PlutusScriptV3 -> ScriptInAnyLang
forall lang. Script lang -> ScriptInAnyLang
toScriptInAnyLang
    (Script PlutusScriptV3 -> ScriptInAnyLang)
-> (SerialisedScript -> Script PlutusScriptV3)
-> SerialisedScript
-> ScriptInAnyLang
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlutusScriptVersion PlutusScriptV3
-> PlutusScript PlutusScriptV3 -> Script PlutusScriptV3
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
PlutusScript PlutusScriptVersion PlutusScriptV3
PlutusScriptV3
    (PlutusScript PlutusScriptV3 -> Script PlutusScriptV3)
-> (SerialisedScript -> PlutusScript PlutusScriptV3)
-> SerialisedScript
-> Script PlutusScriptV3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SerialisedScript -> PlutusScript PlutusScriptV3
forall lang. SerialisedScript -> PlutusScript lang
fromPlutusScript

-- | Construct a PlutusV3 'ReferenceScript' from any given Plutus script.
mkScriptRefV3 :: Plutus.SerialisedScript -> ReferenceScript Era
mkScriptRefV3 :: SerialisedScript -> ReferenceScript Era
mkScriptRefV3 =
  BabbageEraOnwards Era -> ScriptInAnyLang -> ReferenceScript Era
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards Era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra
    (ScriptInAnyLang -> ReferenceScript Era)
-> (SerialisedScript -> ScriptInAnyLang)
-> SerialisedScript
-> ReferenceScript Era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Script PlutusScriptV3 -> ScriptInAnyLang
forall lang. Script lang -> ScriptInAnyLang
toScriptInAnyLang
    (Script PlutusScriptV3 -> ScriptInAnyLang)
-> (SerialisedScript -> Script PlutusScriptV3)
-> SerialisedScript
-> ScriptInAnyLang
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlutusScriptVersion PlutusScriptV3
-> PlutusScript PlutusScriptV3 -> Script PlutusScriptV3
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
PlutusScript PlutusScriptVersion PlutusScriptV3
PlutusScriptV3
    (PlutusScript PlutusScriptV3 -> Script PlutusScriptV3)
-> (SerialisedScript -> PlutusScript PlutusScriptV3)
-> SerialisedScript
-> Script PlutusScriptV3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SerialisedScript -> PlutusScript PlutusScriptV3
forall lang. SerialisedScript -> PlutusScript lang
fromPlutusScript