{-# OPTIONS_GHC -Wno-orphans #-}

module Plutarch.LedgerApi.V1.Contexts (
  PScriptPurpose (..),
) where

import GHC.Generics (Generic)
import Plutarch.LedgerApi.V1.Credential qualified as Credential
import Plutarch.LedgerApi.V1.DCert qualified as DCert
import Plutarch.LedgerApi.V1.Tx qualified as Tx
import Plutarch.LedgerApi.Value qualified as Value
import Plutarch.Prelude
import PlutusLedgerApi.V1 qualified as Plutus

-- | @since 3.1.1
data PScriptPurpose (s :: S)
  = PMinting (Term s (PDataRecord '["_0" ':= Value.PCurrencySymbol]))
  | PSpending (Term s (PDataRecord '["_0" ':= Tx.PTxOutRef]))
  | PRewarding (Term s (PDataRecord '["_0" ':= Credential.PStakingCredential]))
  | PCertifying (Term s (PDataRecord '["_0" ':= DCert.PDCert]))
  deriving stock
    ( -- | @since 3.1.1
      (forall x. PScriptPurpose s -> Rep (PScriptPurpose s) x)
-> (forall x. Rep (PScriptPurpose s) x -> PScriptPurpose s)
-> Generic (PScriptPurpose s)
forall x. Rep (PScriptPurpose s) x -> PScriptPurpose s
forall x. PScriptPurpose s -> Rep (PScriptPurpose s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PScriptPurpose s) x -> PScriptPurpose s
forall (s :: S) x. PScriptPurpose s -> Rep (PScriptPurpose s) x
$cfrom :: forall (s :: S) x. PScriptPurpose s -> Rep (PScriptPurpose s) x
from :: forall x. PScriptPurpose s -> Rep (PScriptPurpose s) x
$cto :: forall (s :: S) x. Rep (PScriptPurpose s) x -> PScriptPurpose s
to :: forall x. Rep (PScriptPurpose s) x -> PScriptPurpose s
Generic
    )
  deriving anyclass
    ( -- | @since 3.1.1
      (forall (s :: S).
 PScriptPurpose s -> Term s (PInner PScriptPurpose))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PScriptPurpose)
    -> (PScriptPurpose s -> Term s b) -> Term s b)
-> PlutusType PScriptPurpose
forall (s :: S). PScriptPurpose s -> Term s (PInner PScriptPurpose)
forall (s :: S) (b :: PType).
Term s (PInner PScriptPurpose)
-> (PScriptPurpose 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). PScriptPurpose s -> Term s (PInner PScriptPurpose)
pcon' :: forall (s :: S). PScriptPurpose s -> Term s (PInner PScriptPurpose)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PScriptPurpose)
-> (PScriptPurpose s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PScriptPurpose)
-> (PScriptPurpose s -> Term s b) -> Term s b
PlutusType
    , -- | @since 3.1.1
      (forall (s :: S).
 Term s (PAsData PScriptPurpose) -> Term s PScriptPurpose)
-> (forall (s :: S). Term s PScriptPurpose -> Term s PData)
-> PIsData PScriptPurpose
forall (s :: S).
Term s (PAsData PScriptPurpose) -> Term s PScriptPurpose
forall (s :: S). Term s PScriptPurpose -> 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 PScriptPurpose) -> Term s PScriptPurpose
pfromDataImpl :: forall (s :: S).
Term s (PAsData PScriptPurpose) -> Term s PScriptPurpose
$cpdataImpl :: forall (s :: S). Term s PScriptPurpose -> Term s PData
pdataImpl :: forall (s :: S). Term s PScriptPurpose -> Term s PData
PIsData
    , -- | @since 3.1.1
      (forall (s :: S).
 Term s PScriptPurpose -> Term s PScriptPurpose -> Term s PBool)
-> PEq PScriptPurpose
forall (s :: S).
Term s PScriptPurpose -> Term s PScriptPurpose -> 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 PScriptPurpose -> Term s PScriptPurpose -> Term s PBool
#== :: forall (s :: S).
Term s PScriptPurpose -> Term s PScriptPurpose -> Term s PBool
PEq
    , -- | @since 3.1.1
      (forall (s :: S). Bool -> Term s PScriptPurpose -> Term s PString)
-> PShow PScriptPurpose
forall (s :: S). Bool -> Term s PScriptPurpose -> 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 PScriptPurpose -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PScriptPurpose -> Term s PString
PShow
    , -- | @since 3.1.1
      PTryFrom PData
    )

-- | @since 3.1.1
instance DerivePlutusType PScriptPurpose where
  type DPTStrat _ = PlutusTypeData

-- | @since WIP
deriving via
  DeriveDataPLiftable PScriptPurpose Plutus.ScriptPurpose
  instance
    PLiftable PScriptPurpose

-- | @since 3.1.1
instance PTryFrom PData (PAsData PScriptPurpose)