{-# OPTIONS_GHC -Wno-orphans #-}

-- Mirrors the equivalent V1 module in plutus-ledger-api
module Plutarch.LedgerApi.V1.Tx (
  PTxId (..),
  PTxOutRef (..),
) where

import GHC.Generics (Generic)
import Plutarch.LedgerApi.Utils (Mret)
import Plutarch.Prelude
import Plutarch.Unsafe (punsafeCoerce)
import PlutusLedgerApi.V1 qualified as Plutus

{- | Hashed with @BLAKE2b-256@.

@since 3.1.0
-}
newtype PTxId (s :: S) = PTxId (Term s (PDataRecord '["_0" ':= PByteString]))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PTxId s -> Rep (PTxId s) x)
-> (forall x. Rep (PTxId s) x -> PTxId s) -> Generic (PTxId s)
forall x. Rep (PTxId s) x -> PTxId s
forall x. PTxId s -> Rep (PTxId s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PTxId s) x -> PTxId s
forall (s :: S) x. PTxId s -> Rep (PTxId s) x
$cfrom :: forall (s :: S) x. PTxId s -> Rep (PTxId s) x
from :: forall x. PTxId s -> Rep (PTxId s) x
$cto :: forall (s :: S) x. Rep (PTxId s) x -> PTxId s
to :: forall x. Rep (PTxId s) x -> PTxId s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S). PTxId s -> Term s (PInner PTxId))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PTxId) -> (PTxId s -> Term s b) -> Term s b)
-> PlutusType PTxId
forall (s :: S). PTxId s -> Term s (PInner PTxId)
forall (s :: S) (b :: PType).
Term s (PInner PTxId) -> (PTxId 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). PTxId s -> Term s (PInner PTxId)
pcon' :: forall (s :: S). PTxId s -> Term s (PInner PTxId)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTxId) -> (PTxId s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTxId) -> (PTxId s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S). Term s (PAsData PTxId) -> Term s PTxId)
-> (forall (s :: S). Term s PTxId -> Term s PData) -> PIsData PTxId
forall (s :: S). Term s (PAsData PTxId) -> Term s PTxId
forall (s :: S). Term s PTxId -> 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 PTxId) -> Term s PTxId
pfromDataImpl :: forall (s :: S). Term s (PAsData PTxId) -> Term s PTxId
$cpdataImpl :: forall (s :: S). Term s PTxId -> Term s PData
pdataImpl :: forall (s :: S). Term s PTxId -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool)
-> PEq PTxId
forall (s :: S). Term s PTxId -> Term s PTxId -> 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 PTxId -> Term s PTxId -> Term s PBool
#== :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PTxId
PEq PTxId =>
(forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool)
-> (forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool)
-> (forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId)
-> (forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId)
-> POrd PTxId
forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool
forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId
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 PTxId -> Term s PTxId -> Term s PBool
#<= :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool
$c#< :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool
#< :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PBool
$cpmax :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId
pmax :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId
$cpmin :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId
pmin :: forall (s :: S). Term s PTxId -> Term s PTxId -> Term s PTxId
POrd
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PTxId -> Term s PString)
-> PShow PTxId
forall (s :: S). Bool -> Term s PTxId -> 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 PTxId -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PTxId -> Term s PString
PShow
    )

-- | @since 3.1.0
instance DerivePlutusType PTxId where
  type DPTStrat _ = PlutusTypeData

-- | @since WIP
deriving via
  DeriveDataPLiftable PTxId Plutus.TxId
  instance
    PLiftable PTxId

-- | @since 3.1.0
instance PTryFrom PData PTxId where
  type PTryFromExcess PData PTxId = Mret PTxId
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont s (Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
-> ((Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont s (Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
 -> ((Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
     -> Term s r)
 -> Term s r)
-> TermCont s (Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
-> ((Term s PTxId, Reduce (PTryFromExcess PData PTxId s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped <- ((Term s (PBuiltinPair PInteger (PBuiltinList PData)) -> Term s r)
 -> Term s r)
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinPair PInteger (PBuiltinList PData)) -> Term s r)
  -> Term s r)
 -> TermCont
      s (Term s (PBuiltinPair PInteger (PBuiltinList PData))))
-> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
    -> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
        -> Term s r)
    -> Term s r)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
    -> Term s r)
-> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair PInteger (PBuiltinList PData))
 -> TermCont
      s (Term s (PBuiltinPair PInteger (PBuiltinList PData))))
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall a b. (a -> b) -> a -> b
$ Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
forall (s :: S).
Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
pasConstr Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
-> Term s PData
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PData
opq
    let ix :: Term s PInteger
ix = Term s (PBuiltinPair PInteger (PBuiltinList PData) :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair PInteger (PBuiltinList PData) :--> PInteger)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s PInteger
ix Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
0)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): constructor index must be 0")
    let inner :: Term s (PBuiltinList PData)
inner = Term
  s
  (PBuiltinPair PInteger (PBuiltinList PData)
   :--> PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
  s
  (PBuiltinPair PInteger (PBuiltinList PData)
   :--> PBuiltinList PData)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> Term s (PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped
    let h :: Term s PData
h = Term s (PBuiltinList PData :--> PData)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> a)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> a)
phead Term s (PBuiltinList PData :--> PData)
-> Term s (PBuiltinList PData) -> Term s PData
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
inner
    let t :: Term s (PBuiltinList PData)
t = Term s (PBuiltinList PData :--> PBuiltinList PData)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBuiltinList a)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> list a)
ptail Term s (PBuiltinList PData :--> PBuiltinList PData)
-> Term s (PBuiltinList PData) -> Term s (PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
inner
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s (PBuiltinList PData :--> PBool)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBool)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> PBool)
pnull Term s (PBuiltinList PData :--> PBool)
-> Term s (PBuiltinList PData) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
t)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): must have exactly 1 field")
    Term s PByteString
unwrapped' <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
h (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped' Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
32)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): must be 32 bytes long")
    (Term s PTxId, Term s PTxId)
-> TermCont s (Term s PTxId, Term s PTxId)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s PTxId
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PTxId s -> Term s PTxId
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PTxId s -> Term s PTxId)
-> (Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s)
-> Term s (PDataRecord '["_0" ':= PByteString])
-> Term s PTxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s
forall (s :: S).
Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s
PTxId (Term s (PDataRecord '["_0" ':= PByteString]) -> Term s PTxId)
-> Term s (PDataRecord '["_0" ':= PByteString]) -> Term s PTxId
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PAsData PByteString
   :--> (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString]))
forall (label :: Symbol) (a :: PType) (l :: [PLabeledType])
       (s :: S).
Term
  s
  (PAsData a
   :--> (PDataRecord l :--> PDataRecord ((label ':= a) : l)))
pdcons Term
  s
  (PAsData PByteString
   :--> (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString]))
-> Term s (PAsData PByteString)
-> Term
     s (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString])
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s PByteString
unwrapped' Term s (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString])
-> Term s (PDataRecord '[])
-> Term s (PDataRecord '["_0" ':= PByteString])
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PDataRecord '[])
forall (s :: S). Term s (PDataRecord '[])
pdnil)

-- | @since 3.1.0
instance PTryFrom PData (PAsData PTxId) where
  type PTryFromExcess PData (PAsData PTxId) = Mret PTxId
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData PTxId),
     Reduce (PTryFromExcess PData (PAsData PTxId) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData PTxId),
   Reduce (PTryFromExcess PData (PAsData PTxId) s))
-> ((Term s (PAsData PTxId),
     Reduce (PTryFromExcess PData (PAsData PTxId) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData PTxId),
    Reduce (PTryFromExcess PData (PAsData PTxId) s))
 -> ((Term s (PAsData PTxId),
      Reduce (PTryFromExcess PData (PAsData PTxId) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData PTxId),
      Reduce (PTryFromExcess PData (PAsData PTxId) s))
-> ((Term s (PAsData PTxId),
     Reduce (PTryFromExcess PData (PAsData PTxId) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped <- ((Term s (PBuiltinPair PInteger (PBuiltinList PData)) -> Term s r)
 -> Term s r)
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinPair PInteger (PBuiltinList PData)) -> Term s r)
  -> Term s r)
 -> TermCont
      s (Term s (PBuiltinPair PInteger (PBuiltinList PData))))
-> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
    -> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
        -> Term s r)
    -> Term s r)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> (Term s (PBuiltinPair PInteger (PBuiltinList PData))
    -> Term s r)
-> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair PInteger (PBuiltinList PData))
 -> TermCont
      s (Term s (PBuiltinPair PInteger (PBuiltinList PData))))
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> TermCont s (Term s (PBuiltinPair PInteger (PBuiltinList PData)))
forall a b. (a -> b) -> a -> b
$ Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
forall (s :: S).
Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
pasConstr Term s (PData :--> PBuiltinPair PInteger (PBuiltinList PData))
-> Term s PData
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PData
opq
    let ix :: Term s PInteger
ix = Term s (PBuiltinPair PInteger (PBuiltinList PData) :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair PInteger (PBuiltinList PData) :--> PInteger)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s PInteger
ix Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
0)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): constructor index must be 0")
    let inner :: Term s (PBuiltinList PData)
inner = Term
  s
  (PBuiltinPair PInteger (PBuiltinList PData)
   :--> PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
  s
  (PBuiltinPair PInteger (PBuiltinList PData)
   :--> PBuiltinList PData)
-> Term s (PBuiltinPair PInteger (PBuiltinList PData))
-> Term s (PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair PInteger (PBuiltinList PData))
unwrapped
    let h :: Term s PData
h = Term s (PBuiltinList PData :--> PData)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> a)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> a)
phead Term s (PBuiltinList PData :--> PData)
-> Term s (PBuiltinList PData) -> Term s PData
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
inner
    let t :: Term s (PBuiltinList PData)
t = Term s (PBuiltinList PData :--> PBuiltinList PData)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBuiltinList a)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> list a)
ptail Term s (PBuiltinList PData :--> PBuiltinList PData)
-> Term s (PBuiltinList PData) -> Term s (PBuiltinList PData)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
inner
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s (PBuiltinList PData :--> PBool)
forall (a :: PType) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBool)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> PBool)
pnull Term s (PBuiltinList PData :--> PBool)
-> Term s (PBuiltinList PData) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList PData)
t)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): must have exactly 1 field")
    Term s PByteString
unwrapped' <- ((Term s PByteString -> Term s r) -> Term s r)
-> TermCont s (Term s PByteString)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s PByteString -> Term s r) -> Term s r)
 -> TermCont s (Term s PByteString))
-> (Term s PByteString
    -> (Term s PByteString -> Term s r) -> Term s r)
-> Term s PByteString
-> TermCont s (Term s PByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PByteString -> (Term s PByteString -> Term s r) -> Term s r
forall (s :: S) (a :: PType) (b :: PType).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s PByteString -> TermCont s (Term s PByteString))
-> Term s PByteString -> TermCont s (Term s PByteString)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PByteString) Term s PData
h (Term s (PAsData PByteString), Term s PByteString)
-> Term s PByteString
(Term s (PAsData PByteString),
 Reduce (PTryFromExcess PData (PAsData PByteString) s))
-> Term s PByteString
forall a b. (a, b) -> b
snd
    ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((() -> Term s r) -> Term s r) -> TermCont s ())
-> ((() -> Term s r) -> Term s r) -> TermCont s ()
forall a b. (a -> b) -> a -> b
$ \() -> Term s r
f ->
      Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: PType) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
        (Term s (PByteString :--> PInteger)
forall (s :: S). Term s (PByteString :--> PInteger)
plengthBS Term s (PByteString :--> PInteger)
-> Term s PByteString -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString
unwrapped' Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
32)
        (() -> Term s r
f ())
        (Term s PString -> Term s r
forall (a :: PType) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"ptryFrom(PTxId): must be 32 bytes long")
    (Term s (PAsData PTxId), Term s PTxId)
-> TermCont s (Term s (PAsData PTxId), Term s PTxId)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData PTxId)
forall (b :: PType) (a :: PType) (s :: S). Term s a -> Term s b
punsafeCoerce Term s PData
opq, PTxId s -> Term s PTxId
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PTxId s -> Term s PTxId)
-> (Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s)
-> Term s (PDataRecord '["_0" ':= PByteString])
-> Term s PTxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s
forall (s :: S).
Term s (PDataRecord '["_0" ':= PByteString]) -> PTxId s
PTxId (Term s (PDataRecord '["_0" ':= PByteString]) -> Term s PTxId)
-> Term s (PDataRecord '["_0" ':= PByteString]) -> Term s PTxId
forall a b. (a -> b) -> a -> b
$ Term
  s
  (PAsData PByteString
   :--> (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString]))
forall (label :: Symbol) (a :: PType) (l :: [PLabeledType])
       (s :: S).
Term
  s
  (PAsData a
   :--> (PDataRecord l :--> PDataRecord ((label ':= a) : l)))
pdcons Term
  s
  (PAsData PByteString
   :--> (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString]))
-> Term s (PAsData PByteString)
-> Term
     s (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString])
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PByteString -> Term s (PAsData PByteString)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s PByteString
unwrapped' Term s (PDataRecord '[] :--> PDataRecord '["_0" ':= PByteString])
-> Term s (PDataRecord '[])
-> Term s (PDataRecord '["_0" ':= PByteString])
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PDataRecord '[])
forall (s :: S). Term s (PDataRecord '[])
pdnil)

{- | Reference to a transaction output, with an index referencing which exact
output we mean.

@since 2.0.0
-}
newtype PTxOutRef (s :: S)
  = PTxOutRef
      ( Term
          s
          ( PDataRecord
              '[ "id" ':= PTxId
               , "idx" ':= PInteger
               ]
          )
      )
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PTxOutRef s -> Rep (PTxOutRef s) x)
-> (forall x. Rep (PTxOutRef s) x -> PTxOutRef s)
-> Generic (PTxOutRef s)
forall x. Rep (PTxOutRef s) x -> PTxOutRef s
forall x. PTxOutRef s -> Rep (PTxOutRef s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PTxOutRef s) x -> PTxOutRef s
forall (s :: S) x. PTxOutRef s -> Rep (PTxOutRef s) x
$cfrom :: forall (s :: S) x. PTxOutRef s -> Rep (PTxOutRef s) x
from :: forall x. PTxOutRef s -> Rep (PTxOutRef s) x
$cto :: forall (s :: S) x. Rep (PTxOutRef s) x -> PTxOutRef s
to :: forall x. Rep (PTxOutRef s) x -> PTxOutRef s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S). PTxOutRef s -> Term s (PInner PTxOutRef))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PTxOutRef) -> (PTxOutRef s -> Term s b) -> Term s b)
-> PlutusType PTxOutRef
forall (s :: S). PTxOutRef s -> Term s (PInner PTxOutRef)
forall (s :: S) (b :: PType).
Term s (PInner PTxOutRef) -> (PTxOutRef 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). PTxOutRef s -> Term s (PInner PTxOutRef)
pcon' :: forall (s :: S). PTxOutRef s -> Term s (PInner PTxOutRef)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTxOutRef) -> (PTxOutRef s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PTxOutRef) -> (PTxOutRef s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S). Term s (PAsData PTxOutRef) -> Term s PTxOutRef)
-> (forall (s :: S). Term s PTxOutRef -> Term s PData)
-> PIsData PTxOutRef
forall (s :: S). Term s (PAsData PTxOutRef) -> Term s PTxOutRef
forall (s :: S). Term s PTxOutRef -> 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 PTxOutRef) -> Term s PTxOutRef
pfromDataImpl :: forall (s :: S). Term s (PAsData PTxOutRef) -> Term s PTxOutRef
$cpdataImpl :: forall (s :: S). Term s PTxOutRef -> Term s PData
pdataImpl :: forall (s :: S). Term s PTxOutRef -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PTxOutRef -> Term s (PDataRecord (PFields PTxOutRef)))
-> PDataFields PTxOutRef
forall (s :: S).
Term s PTxOutRef -> Term s (PDataRecord (PFields PTxOutRef))
forall (a :: PType).
(forall (s :: S). Term s a -> Term s (PDataRecord (PFields a)))
-> PDataFields a
$cptoFields :: forall (s :: S).
Term s PTxOutRef -> Term s (PDataRecord (PFields PTxOutRef))
ptoFields :: forall (s :: S).
Term s PTxOutRef -> Term s (PDataRecord (PFields PTxOutRef))
PDataFields
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool)
-> PEq PTxOutRef
forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> 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 PTxOutRef -> Term s PTxOutRef -> Term s PBool
#== :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PTxOutRef
PEq PTxOutRef =>
(forall (s :: S).
 Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool)
-> (forall (s :: S).
    Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool)
-> (forall (s :: S).
    Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef)
-> (forall (s :: S).
    Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef)
-> POrd PTxOutRef
forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool
forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef
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 PTxOutRef -> Term s PTxOutRef -> Term s PBool
#<= :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool
$c#< :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool
#< :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PBool
$cpmax :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef
pmax :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef
$cpmin :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef
pmin :: forall (s :: S).
Term s PTxOutRef -> Term s PTxOutRef -> Term s PTxOutRef
POrd
    , -- | @since 2.0.0
      PTryFrom PData
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PTxOutRef -> Term s PString)
-> PShow PTxOutRef
forall (s :: S). Bool -> Term s PTxOutRef -> 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 PTxOutRef -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PTxOutRef -> Term s PString
PShow
    )

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

-- | @since WIP
deriving via
  DeriveDataPLiftable PTxOutRef Plutus.TxOutRef
  instance
    PLiftable PTxOutRef

-- | @since 3.1.0
instance PTryFrom PData (PAsData PTxOutRef)