module Hydra.Cardano.Api.ReferenceScript where

import Hydra.Cardano.Api.Prelude

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

-- | Construct a 'ReferenceScript' from any given Plutus script.
--
-- NOTE: The script is treated as a 'PlutusScriptV2'
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 PlutusScriptV2 -> ScriptInAnyLang
forall lang. Script lang -> ScriptInAnyLang
toScriptInAnyLang
    (Script PlutusScriptV2 -> ScriptInAnyLang)
-> (SerialisedScript -> Script PlutusScriptV2)
-> SerialisedScript
-> ScriptInAnyLang
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlutusScriptVersion PlutusScriptV2
-> PlutusScript PlutusScriptV2 -> Script PlutusScriptV2
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
PlutusScript PlutusScriptVersion PlutusScriptV2
PlutusScriptV2
    (PlutusScript PlutusScriptV2 -> Script PlutusScriptV2)
-> (SerialisedScript -> PlutusScript PlutusScriptV2)
-> SerialisedScript
-> Script PlutusScriptV2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SerialisedScript -> PlutusScript PlutusScriptV2
forall lang. SerialisedScript -> PlutusScript lang
fromPlutusScript