module Plutus.Script.Utils.V1.Address
( mkValidatorAddress
, mkValidatorCardanoAddress
, mkMintingPolicyCardanoAddress
, mkStakeValidatorCardanoAddress
) where
import Cardano.Api qualified as Script
import Plutus.Script.Utils.V1.Scripts qualified as PV1
import Plutus.V1.Ledger.Api (Address (Address), Credential (ScriptCredential), Script, Validator, getMintingPolicy,
getStakeValidator, getValidator)
{-# INLINABLE mkValidatorAddress #-}
mkValidatorAddress :: Validator -> Address
mkValidatorAddress :: Validator -> Address
mkValidatorAddress Validator
validator = Credential -> Maybe StakingCredential -> Address
Address (ValidatorHash -> Credential
ScriptCredential (Validator -> ValidatorHash
PV1.validatorHash Validator
validator)) Maybe StakingCredential
forall a. Maybe a
Nothing
mkValidatorCardanoAddress :: Script.NetworkId -> PV1.Validator -> Script.AddressInEra Script.BabbageEra
mkValidatorCardanoAddress :: NetworkId -> Validator -> AddressInEra BabbageEra
mkValidatorCardanoAddress NetworkId
networkId = NetworkId -> Script -> AddressInEra BabbageEra
toScriptAddress NetworkId
networkId (Script -> AddressInEra BabbageEra)
-> (Validator -> Script) -> Validator -> AddressInEra BabbageEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Validator -> Script
getValidator
mkMintingPolicyCardanoAddress :: Script.NetworkId -> PV1.MintingPolicy -> Script.AddressInEra Script.BabbageEra
mkMintingPolicyCardanoAddress :: NetworkId -> MintingPolicy -> AddressInEra BabbageEra
mkMintingPolicyCardanoAddress NetworkId
networkId = NetworkId -> Script -> AddressInEra BabbageEra
toScriptAddress NetworkId
networkId (Script -> AddressInEra BabbageEra)
-> (MintingPolicy -> Script)
-> MintingPolicy
-> AddressInEra BabbageEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MintingPolicy -> Script
getMintingPolicy
mkStakeValidatorCardanoAddress :: Script.NetworkId -> PV1.StakeValidator -> Script.AddressInEra Script.BabbageEra
mkStakeValidatorCardanoAddress :: NetworkId -> StakeValidator -> AddressInEra BabbageEra
mkStakeValidatorCardanoAddress NetworkId
networkId = NetworkId -> Script -> AddressInEra BabbageEra
toScriptAddress NetworkId
networkId (Script -> AddressInEra BabbageEra)
-> (StakeValidator -> Script)
-> StakeValidator
-> AddressInEra BabbageEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakeValidator -> Script
getStakeValidator
toScriptAddress :: Script.NetworkId -> Script -> Script.AddressInEra Script.BabbageEra
toScriptAddress :: NetworkId -> Script -> AddressInEra BabbageEra
toScriptAddress NetworkId
networkId Script
script = NetworkId
-> PaymentCredential
-> StakeAddressReference
-> AddressInEra BabbageEra
forall era.
IsShelleyBasedEra era =>
NetworkId
-> PaymentCredential -> StakeAddressReference -> AddressInEra era
Script.makeShelleyAddressInEra
NetworkId
networkId
( ScriptHash -> PaymentCredential
Script.PaymentCredentialByScript
(ScriptHash -> PaymentCredential)
-> (Script PlutusScriptV1 -> ScriptHash)
-> Script PlutusScriptV1
-> PaymentCredential
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Script PlutusScriptV1 -> ScriptHash
forall lang. Script lang -> ScriptHash
Script.hashScript
(Script PlutusScriptV1 -> PaymentCredential)
-> Script PlutusScriptV1 -> PaymentCredential
forall a b. (a -> b) -> a -> b
$ Script -> Script PlutusScriptV1
PV1.toCardanoApiScript Script
script)
StakeAddressReference
Script.NoStakeAddress