module Plutarch.LedgerApi.Value.CurrencySymbol (
PCurrencySymbol (..),
padaSymbol,
padaSymbolData,
) where
import Data.ByteString (ByteString)
import GHC.Generics (Generic)
import Generics.SOP qualified as SOP
import Plutarch.Prelude
import PlutusLedgerApi.V3 qualified as Plutus
import PlutusTx.Builtins.Internal qualified as PlutusTx
newtype PCurrencySymbol (s :: S) = PCurrencySymbol (Term s PByteString)
deriving stock
(
(forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x)
-> (forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s)
-> Generic (PCurrencySymbol s)
forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
forall (s :: S) x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
$cfrom :: forall (s :: S) x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
from :: forall x. PCurrencySymbol s -> Rep (PCurrencySymbol s) x
$cto :: forall (s :: S) x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
to :: forall x. Rep (PCurrencySymbol s) x -> PCurrencySymbol s
Generic
)
deriving anyclass
(
All SListI (Code (PCurrencySymbol s))
All SListI (Code (PCurrencySymbol s)) =>
(PCurrencySymbol s -> Rep (PCurrencySymbol s))
-> (Rep (PCurrencySymbol s) -> PCurrencySymbol s)
-> Generic (PCurrencySymbol s)
Rep (PCurrencySymbol s) -> PCurrencySymbol s
PCurrencySymbol s -> Rep (PCurrencySymbol s)
forall a.
All SListI (Code a) =>
(a -> Rep a) -> (Rep a -> a) -> Generic a
forall (s :: S). All SListI (Code (PCurrencySymbol s))
forall (s :: S). Rep (PCurrencySymbol s) -> PCurrencySymbol s
forall (s :: S). PCurrencySymbol s -> Rep (PCurrencySymbol s)
$cfrom :: forall (s :: S). PCurrencySymbol s -> Rep (PCurrencySymbol s)
from :: PCurrencySymbol s -> Rep (PCurrencySymbol s)
$cto :: forall (s :: S). Rep (PCurrencySymbol s) -> PCurrencySymbol s
to :: Rep (PCurrencySymbol s) -> PCurrencySymbol s
SOP.Generic
,
(forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol)
-> (forall (s :: S). Term s PCurrencySymbol -> Term s PData)
-> PIsData PCurrencySymbol
forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
forall (s :: S). Term s PCurrencySymbol -> Term s PData
forall (a :: S -> Type).
(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 PCurrencySymbol) -> Term s PCurrencySymbol
pfromDataImpl :: forall (s :: S).
Term s (PAsData PCurrencySymbol) -> Term s PCurrencySymbol
$cpdataImpl :: forall (s :: S). Term s PCurrencySymbol -> Term s PData
pdataImpl :: forall (s :: S). Term s PCurrencySymbol -> Term s PData
PIsData
,
(forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> PEq PCurrencySymbol
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (t :: S -> Type).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#== :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
PEq
,
PEq PCurrencySymbol
PEq PCurrencySymbol =>
(forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> (forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool)
-> (forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol)
-> (forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol)
-> POrd PCurrencySymbol
forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
forall (t :: S -> Type).
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 PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#<= :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
$c#< :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
#< :: forall (s :: S).
Term s PCurrencySymbol -> Term s PCurrencySymbol -> Term s PBool
$cpmax :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
pmax :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
$cpmin :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
pmin :: forall (s :: S).
Term s PCurrencySymbol
-> Term s PCurrencySymbol -> Term s PCurrencySymbol
POrd
,
(forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString)
-> PShow PCurrencySymbol
forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
forall (t :: S -> Type).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PCurrencySymbol -> Term s PString
PShow
)
deriving
(
(forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol))
-> (forall (s :: S) (b :: S -> Type).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b)
-> PlutusType PCurrencySymbol
forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
forall (s :: S) (b :: S -> Type).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
forall (a :: S -> Type).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: S -> Type).
Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
pcon' :: forall (s :: S).
PCurrencySymbol s -> Term s (PInner PCurrencySymbol)
$cpmatch' :: forall (s :: S) (b :: S -> Type).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: S -> Type).
Term s (PInner PCurrencySymbol)
-> (PCurrencySymbol s -> Term s b) -> Term s b
PlutusType
)
via (DeriveNewtypePlutusType PCurrencySymbol)
instance PLiftable PCurrencySymbol where
type AsHaskell PCurrencySymbol = Plutus.CurrencySymbol
type PlutusRepr PCurrencySymbol = ByteString
{-# INLINEABLE haskToRepr #-}
haskToRepr :: AsHaskell PCurrencySymbol -> PlutusRepr PCurrencySymbol
haskToRepr (Plutus.CurrencySymbol (PlutusTx.BuiltinByteString ByteString
str)) = ByteString
PlutusRepr PCurrencySymbol
str
{-# INLINEABLE reprToHask #-}
reprToHask :: PlutusRepr PCurrencySymbol
-> Either LiftError (AsHaskell PCurrencySymbol)
reprToHask = CurrencySymbol -> Either LiftError CurrencySymbol
forall a b. b -> Either a b
Right (CurrencySymbol -> Either LiftError CurrencySymbol)
-> (ByteString -> CurrencySymbol)
-> ByteString
-> Either LiftError CurrencySymbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BuiltinByteString -> CurrencySymbol
Plutus.CurrencySymbol (BuiltinByteString -> CurrencySymbol)
-> (ByteString -> BuiltinByteString)
-> ByteString
-> CurrencySymbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> BuiltinByteString
PlutusTx.BuiltinByteString
{-# INLINEABLE reprToPlut #-}
reprToPlut :: forall (s :: S).
PlutusRepr PCurrencySymbol -> PLifted s PCurrencySymbol
reprToPlut = PlutusRepr PCurrencySymbol -> PLifted s PCurrencySymbol
forall (a :: S -> Type) (s :: S).
Includes DefaultUni (PlutusRepr a) =>
PlutusRepr a -> PLifted s a
reprToPlutUni
{-# INLINEABLE plutToRepr #-}
plutToRepr :: (forall (s :: S). PLifted s PCurrencySymbol)
-> Either LiftError (PlutusRepr PCurrencySymbol)
plutToRepr = (forall (s :: S). PLifted s PCurrencySymbol)
-> Either LiftError (PlutusRepr PCurrencySymbol)
forall (a :: S -> Type).
KnownBuiltinType
(Term DeBruijn DefaultUni DefaultFun ()) (PlutusRepr a) =>
(forall (s :: S). PLifted s a) -> Either LiftError (PlutusRepr a)
plutToReprUni
instance PTryFrom PData (PAsData PCurrencySymbol)
instance PValidateData PCurrencySymbol where
pwithValidated :: forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r
pwithValidated Term s PData
opq Term s r
x =
Term s PInteger -> (Term s PInteger -> Term s r) -> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (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 :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PData :--> PByteString)
forall (s :: S). Term s (PData :--> PByteString)
pasByteStr Term s (PData :--> PByteString)
-> Term s PData -> Term s PByteString
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PData
opq) ((Term s PInteger -> Term s r) -> Term s r)
-> (Term s PInteger -> Term s r) -> Term s r
forall a b. (a -> b) -> a -> b
$ \Term s PInteger
bsSize ->
Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
((Term s PInteger
bsSize Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
forall (s :: S). Term s PInteger
pnonAdaCurrencySymbolByteSize) Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#|| (Term s PInteger
bsSize Term s PInteger -> Term s PInteger -> Term s PBool
forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s PInteger
forall (s :: S). Term s PInteger
padaCurrencySymbolByteSize))
Term s r
x
Term s r
forall (s :: S) (a :: S -> Type). Term s a
perror
pnonAdaCurrencySymbolByteSize :: forall (s :: S). Term s PInteger
pnonAdaCurrencySymbolByteSize :: forall (s :: S). Term s PInteger
pnonAdaCurrencySymbolByteSize = Term s PInteger
28
padaCurrencySymbolByteSize :: forall (s :: S). Term s PInteger
padaCurrencySymbolByteSize :: forall (s :: S). Term s PInteger
padaCurrencySymbolByteSize = Term s PInteger
0
padaSymbol :: forall (s :: S). Term s PCurrencySymbol
padaSymbol :: forall (s :: S). Term s PCurrencySymbol
padaSymbol = AsHaskell PCurrencySymbol -> Term s PCurrencySymbol
forall (a :: S -> Type) (s :: S).
PLiftable a =>
AsHaskell a -> Term s a
pconstant AsHaskell PCurrencySymbol
CurrencySymbol
Plutus.adaSymbol
padaSymbolData :: forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData :: forall (s :: S). Term s (PAsData PCurrencySymbol)
padaSymbolData = Term s PCurrencySymbol -> Term s (PAsData PCurrencySymbol)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s PCurrencySymbol
forall (s :: S). Term s PCurrencySymbol
padaSymbol