{-# OPTIONS_GHC -Wno-orphans #-}

-- Mirrors the equivalent V1 module in plutus-ledger api
module Plutarch.LedgerApi.V1.Credential (
  PCredential (..),
  PStakingCredential (..),
) where

import GHC.Generics (Generic)
import Plutarch.LedgerApi.V1.Crypto (PPubKeyHash)
import Plutarch.LedgerApi.V1.Scripts (PScriptHash)
import Plutarch.Prelude
import PlutusLedgerApi.V1 qualified as Plutus

-- | @since 2.0.0
data PCredential (s :: S)
  = PPubKeyCredential (Term s (PDataRecord '["_0" ':= PPubKeyHash]))
  | PScriptCredential (Term s (PDataRecord '["_0" ':= PScriptHash]))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PCredential s -> Rep (PCredential s) x)
-> (forall x. Rep (PCredential s) x -> PCredential s)
-> Generic (PCredential s)
forall x. Rep (PCredential s) x -> PCredential s
forall x. PCredential s -> Rep (PCredential s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PCredential s) x -> PCredential s
forall (s :: S) x. PCredential s -> Rep (PCredential s) x
$cfrom :: forall (s :: S) x. PCredential s -> Rep (PCredential s) x
from :: forall x. PCredential s -> Rep (PCredential s) x
$cto :: forall (s :: S) x. Rep (PCredential s) x -> PCredential s
to :: forall x. Rep (PCredential s) x -> PCredential s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S). PCredential s -> Term s (PInner PCredential))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PCredential)
    -> (PCredential s -> Term s b) -> Term s b)
-> PlutusType PCredential
forall (s :: S). PCredential s -> Term s (PInner PCredential)
forall (s :: S) (b :: PType).
Term s (PInner PCredential)
-> (PCredential s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S). PCredential s -> Term s (PInner PCredential)
pcon' :: forall (s :: S). PCredential s -> Term s (PInner PCredential)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PCredential)
-> (PCredential s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PCredential)
-> (PCredential s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s (PAsData PCredential) -> Term s PCredential)
-> (forall (s :: S). Term s PCredential -> Term s PData)
-> PIsData PCredential
forall (s :: S). Term s (PAsData PCredential) -> Term s PCredential
forall (s :: S). Term s PCredential -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PCredential) -> Term s PCredential
pfromDataImpl :: forall (s :: S). Term s (PAsData PCredential) -> Term s PCredential
$cpdataImpl :: forall (s :: S). Term s PCredential -> Term s PData
pdataImpl :: forall (s :: S). Term s PCredential -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PCredential -> Term s PCredential -> Term s PBool)
-> PEq PCredential
forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
#== :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PCredential
PEq PCredential =>
(forall (s :: S).
 Term s PCredential -> Term s PCredential -> Term s PBool)
-> (forall (s :: S).
    Term s PCredential -> Term s PCredential -> Term s PBool)
-> (forall (s :: S).
    Term s PCredential -> Term s PCredential -> Term s PCredential)
-> (forall (s :: S).
    Term s PCredential -> Term s PCredential -> Term s PCredential)
-> POrd PCredential
forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PCredential
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> POrd t
$c#<= :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
#<= :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
$c#< :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
#< :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PBool
$cpmax :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PCredential
pmax :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PCredential
$cpmin :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PCredential
pmin :: forall (s :: S).
Term s PCredential -> Term s PCredential -> Term s PCredential
POrd
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PCredential -> Term s PString)
-> PShow PCredential
forall (s :: S). Bool -> Term s PCredential -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PCredential -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PCredential -> Term s PString
PShow
    , -- | @since 2.0.0
      PTryFrom PData
    )

-- | @since 2.0.0
instance DerivePlutusType PCredential where
  type DPTStrat _ = PlutusTypeData

-- | @since WIP
deriving via
  DeriveDataPLiftable PCredential Plutus.Credential
  instance
    PLiftable PCredential

-- | @since 2.0.0
instance PTryFrom PData (PAsData PCredential)

-- | @since 2.0.0
data PStakingCredential (s :: S)
  = PStakingHash (Term s (PDataRecord '["_0" ':= PCredential]))
  | PStakingPtr
      ( Term
          s
          ( PDataRecord
              '[ "_0" ':= PInteger
               , "_1" ':= PInteger
               , "_2" ':= PInteger
               ]
          )
      )
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PStakingCredential s -> Rep (PStakingCredential s) x)
-> (forall x. Rep (PStakingCredential s) x -> PStakingCredential s)
-> Generic (PStakingCredential s)
forall x. Rep (PStakingCredential s) x -> PStakingCredential s
forall x. PStakingCredential s -> Rep (PStakingCredential s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x.
Rep (PStakingCredential s) x -> PStakingCredential s
forall (s :: S) x.
PStakingCredential s -> Rep (PStakingCredential s) x
$cfrom :: forall (s :: S) x.
PStakingCredential s -> Rep (PStakingCredential s) x
from :: forall x. PStakingCredential s -> Rep (PStakingCredential s) x
$cto :: forall (s :: S) x.
Rep (PStakingCredential s) x -> PStakingCredential s
to :: forall x. Rep (PStakingCredential s) x -> PStakingCredential s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S).
 PStakingCredential s -> Term s (PInner PStakingCredential))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PStakingCredential)
    -> (PStakingCredential s -> Term s b) -> Term s b)
-> PlutusType PStakingCredential
forall (s :: S).
PStakingCredential s -> Term s (PInner PStakingCredential)
forall (s :: S) (b :: PType).
Term s (PInner PStakingCredential)
-> (PStakingCredential s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S).
PStakingCredential s -> Term s (PInner PStakingCredential)
pcon' :: forall (s :: S).
PStakingCredential s -> Term s (PInner PStakingCredential)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PStakingCredential)
-> (PStakingCredential s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PStakingCredential)
-> (PStakingCredential s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s (PAsData PStakingCredential) -> Term s PStakingCredential)
-> (forall (s :: S). Term s PStakingCredential -> Term s PData)
-> PIsData PStakingCredential
forall (s :: S).
Term s (PAsData PStakingCredential) -> Term s PStakingCredential
forall (s :: S). Term s PStakingCredential -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PStakingCredential) -> Term s PStakingCredential
pfromDataImpl :: forall (s :: S).
Term s (PAsData PStakingCredential) -> Term s PStakingCredential
$cpdataImpl :: forall (s :: S). Term s PStakingCredential -> Term s PData
pdataImpl :: forall (s :: S). Term s PStakingCredential -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PStakingCredential
 -> Term s PStakingCredential -> Term s PBool)
-> PEq PStakingCredential
forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
#== :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PStakingCredential
PEq PStakingCredential =>
(forall (s :: S).
 Term s PStakingCredential
 -> Term s PStakingCredential -> Term s PBool)
-> (forall (s :: S).
    Term s PStakingCredential
    -> Term s PStakingCredential -> Term s PBool)
-> (forall (s :: S).
    Term s PStakingCredential
    -> Term s PStakingCredential -> Term s PStakingCredential)
-> (forall (s :: S).
    Term s PStakingCredential
    -> Term s PStakingCredential -> Term s PStakingCredential)
-> POrd PStakingCredential
forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PStakingCredential
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t)
-> POrd t
$c#<= :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
#<= :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
$c#< :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
#< :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PBool
$cpmax :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PStakingCredential
pmax :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PStakingCredential
$cpmin :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PStakingCredential
pmin :: forall (s :: S).
Term s PStakingCredential
-> Term s PStakingCredential -> Term s PStakingCredential
POrd
    , -- | @since 2.0.0
      (forall (s :: S).
 Bool -> Term s PStakingCredential -> Term s PString)
-> PShow PStakingCredential
forall (s :: S).
Bool -> Term s PStakingCredential -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S).
Bool -> Term s PStakingCredential -> Term s PString
pshow' :: forall (s :: S).
Bool -> Term s PStakingCredential -> Term s PString
PShow
    , -- | @since 2.0.0
      PTryFrom PData
    )

-- | @since 2.0.0
instance DerivePlutusType PStakingCredential where
  type DPTStrat _ = PlutusTypeData

-- | @since WIP
deriving via
  DeriveDataPLiftable PStakingCredential Plutus.StakingCredential
  instance
    PLiftable PStakingCredential

-- | @since 2.0.0
instance PTryFrom PData (PAsData PStakingCredential)