module Hydra.Cardano.Api.StakeAddress where

import Hydra.Cardano.Api.Prelude

-- | Construct a stake address from a Plutus script.
mkScriptStakeAddress ::
  forall lang.
  IsPlutusScriptLanguage lang =>
  NetworkId ->
  PlutusScript lang ->
  StakeAddress
mkScriptStakeAddress :: forall lang.
IsPlutusScriptLanguage lang =>
NetworkId -> PlutusScript lang -> StakeAddress
mkScriptStakeAddress NetworkId
networkId PlutusScript lang
script =
  NetworkId -> StakeCredential -> StakeAddress
makeStakeAddress NetworkId
networkId (StakeCredential -> StakeAddress)
-> StakeCredential -> StakeAddress
forall a b. (a -> b) -> a -> b
$ ScriptHash -> StakeCredential
StakeCredentialByScript (ScriptHash -> StakeCredential) -> ScriptHash -> StakeCredential
forall a b. (a -> b) -> a -> b
$ Script lang -> ScriptHash
forall lang. Script lang -> ScriptHash
hashScript (Script lang -> ScriptHash) -> Script lang -> ScriptHash
forall a b. (a -> b) -> a -> b
$ PlutusScriptVersion lang -> PlutusScript lang -> Script lang
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
PlutusScript PlutusScriptVersion lang
version PlutusScript lang
script
 where
  version :: PlutusScriptVersion lang
version = forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang
plutusScriptVersion @lang