{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
{-# OPTIONS_GHC -fno-spec-constr #-}
{-# OPTIONS_GHC -fno-specialise #-}
module Plutus.V1.Ledger.Value(
CurrencySymbol(..)
, currencySymbol
, mpsSymbol
, currencyMPSHash
, adaSymbol
, TokenName(..)
, tokenName
, toString
, adaToken
, AssetClass(..)
, assetClass
, assetClassValue
, assetClassValueOf
, Value(..)
, singleton
, valueOf
, scale
, symbols
, geq
, gt
, leq
, lt
, isZero
, split
, unionWith
, flattenValue
) where
import Prelude qualified as Haskell
import Control.DeepSeq (NFData)
import Data.ByteString qualified as BS
import Data.Data
import Data.List qualified (sortBy)
import Data.String (IsString (fromString))
import Data.Text (Text)
import Data.Text qualified as Text
import Data.Text.Encoding qualified as E
import GHC.Generics (Generic)
import GHC.Show (showList__)
import Plutus.V1.Ledger.Bytes (LedgerBytes (LedgerBytes), encodeByteString)
import Plutus.V1.Ledger.Scripts
import PlutusTx qualified as PlutusTx
import PlutusTx.AssocMap qualified as Map
import PlutusTx.Lift (makeLift)
import PlutusTx.Ord qualified as Ord
import PlutusTx.Prelude as PlutusTx hiding (sort)
import PlutusTx.These
import Prettyprinter
import Prettyprinter.Extras
newtype CurrencySymbol = CurrencySymbol { CurrencySymbol -> BuiltinByteString
unCurrencySymbol :: PlutusTx.BuiltinByteString }
deriving (String -> CurrencySymbol
(String -> CurrencySymbol) -> IsString CurrencySymbol
forall a. (String -> a) -> IsString a
fromString :: String -> CurrencySymbol
$cfromString :: String -> CurrencySymbol
IsString, Int -> CurrencySymbol -> ShowS
[CurrencySymbol] -> ShowS
CurrencySymbol -> String
(Int -> CurrencySymbol -> ShowS)
-> (CurrencySymbol -> String)
-> ([CurrencySymbol] -> ShowS)
-> Show CurrencySymbol
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CurrencySymbol] -> ShowS
$cshowList :: [CurrencySymbol] -> ShowS
show :: CurrencySymbol -> String
$cshow :: CurrencySymbol -> String
showsPrec :: Int -> CurrencySymbol -> ShowS
$cshowsPrec :: Int -> CurrencySymbol -> ShowS
Haskell.Show, [CurrencySymbol] -> Doc ann
CurrencySymbol -> Doc ann
(forall ann. CurrencySymbol -> Doc ann)
-> (forall ann. [CurrencySymbol] -> Doc ann)
-> Pretty CurrencySymbol
forall ann. [CurrencySymbol] -> Doc ann
forall ann. CurrencySymbol -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [CurrencySymbol] -> Doc ann
$cprettyList :: forall ann. [CurrencySymbol] -> Doc ann
pretty :: CurrencySymbol -> Doc ann
$cpretty :: forall ann. CurrencySymbol -> Doc ann
Pretty) via LedgerBytes
deriving stock ((forall x. CurrencySymbol -> Rep CurrencySymbol x)
-> (forall x. Rep CurrencySymbol x -> CurrencySymbol)
-> Generic CurrencySymbol
forall x. Rep CurrencySymbol x -> CurrencySymbol
forall x. CurrencySymbol -> Rep CurrencySymbol x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CurrencySymbol x -> CurrencySymbol
$cfrom :: forall x. CurrencySymbol -> Rep CurrencySymbol x
Generic, Typeable CurrencySymbol
DataType
Constr
Typeable CurrencySymbol
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CurrencySymbol)
-> (CurrencySymbol -> Constr)
-> (CurrencySymbol -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CurrencySymbol))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CurrencySymbol))
-> ((forall b. Data b => b -> b)
-> CurrencySymbol -> CurrencySymbol)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r)
-> (forall u.
(forall d. Data d => d -> u) -> CurrencySymbol -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CurrencySymbol -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol)
-> Data CurrencySymbol
CurrencySymbol -> DataType
CurrencySymbol -> Constr
(forall b. Data b => b -> b) -> CurrencySymbol -> CurrencySymbol
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CurrencySymbol
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> CurrencySymbol -> u
forall u. (forall d. Data d => d -> u) -> CurrencySymbol -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CurrencySymbol
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CurrencySymbol)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CurrencySymbol)
$cCurrencySymbol :: Constr
$tCurrencySymbol :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
gmapMp :: (forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
gmapM :: (forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CurrencySymbol -> m CurrencySymbol
gmapQi :: Int -> (forall d. Data d => d -> u) -> CurrencySymbol -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CurrencySymbol -> u
gmapQ :: (forall d. Data d => d -> u) -> CurrencySymbol -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CurrencySymbol -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r
gmapT :: (forall b. Data b => b -> b) -> CurrencySymbol -> CurrencySymbol
$cgmapT :: (forall b. Data b => b -> b) -> CurrencySymbol -> CurrencySymbol
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CurrencySymbol)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CurrencySymbol)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CurrencySymbol)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CurrencySymbol)
dataTypeOf :: CurrencySymbol -> DataType
$cdataTypeOf :: CurrencySymbol -> DataType
toConstr :: CurrencySymbol -> Constr
$ctoConstr :: CurrencySymbol -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CurrencySymbol
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CurrencySymbol
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol
$cp1Data :: Typeable CurrencySymbol
Data)
deriving newtype (CurrencySymbol -> CurrencySymbol -> Bool
(CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool) -> Eq CurrencySymbol
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CurrencySymbol -> CurrencySymbol -> Bool
$c/= :: CurrencySymbol -> CurrencySymbol -> Bool
== :: CurrencySymbol -> CurrencySymbol -> Bool
$c== :: CurrencySymbol -> CurrencySymbol -> Bool
Haskell.Eq, Eq CurrencySymbol
Eq CurrencySymbol
-> (CurrencySymbol -> CurrencySymbol -> Ordering)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> CurrencySymbol)
-> (CurrencySymbol -> CurrencySymbol -> CurrencySymbol)
-> Ord CurrencySymbol
CurrencySymbol -> CurrencySymbol -> Bool
CurrencySymbol -> CurrencySymbol -> Ordering
CurrencySymbol -> CurrencySymbol -> CurrencySymbol
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
$cmin :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
max :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
$cmax :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
>= :: CurrencySymbol -> CurrencySymbol -> Bool
$c>= :: CurrencySymbol -> CurrencySymbol -> Bool
> :: CurrencySymbol -> CurrencySymbol -> Bool
$c> :: CurrencySymbol -> CurrencySymbol -> Bool
<= :: CurrencySymbol -> CurrencySymbol -> Bool
$c<= :: CurrencySymbol -> CurrencySymbol -> Bool
< :: CurrencySymbol -> CurrencySymbol -> Bool
$c< :: CurrencySymbol -> CurrencySymbol -> Bool
compare :: CurrencySymbol -> CurrencySymbol -> Ordering
$ccompare :: CurrencySymbol -> CurrencySymbol -> Ordering
$cp1Ord :: Eq CurrencySymbol
Haskell.Ord, CurrencySymbol -> CurrencySymbol -> Bool
(CurrencySymbol -> CurrencySymbol -> Bool) -> Eq CurrencySymbol
forall a. (a -> a -> Bool) -> Eq a
== :: CurrencySymbol -> CurrencySymbol -> Bool
$c== :: CurrencySymbol -> CurrencySymbol -> Bool
Eq, Eq CurrencySymbol
Eq CurrencySymbol
-> (CurrencySymbol -> CurrencySymbol -> Ordering)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> Bool)
-> (CurrencySymbol -> CurrencySymbol -> CurrencySymbol)
-> (CurrencySymbol -> CurrencySymbol -> CurrencySymbol)
-> Ord CurrencySymbol
CurrencySymbol -> CurrencySymbol -> Bool
CurrencySymbol -> CurrencySymbol -> Ordering
CurrencySymbol -> CurrencySymbol -> CurrencySymbol
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
$cmin :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
max :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
$cmax :: CurrencySymbol -> CurrencySymbol -> CurrencySymbol
>= :: CurrencySymbol -> CurrencySymbol -> Bool
$c>= :: CurrencySymbol -> CurrencySymbol -> Bool
> :: CurrencySymbol -> CurrencySymbol -> Bool
$c> :: CurrencySymbol -> CurrencySymbol -> Bool
<= :: CurrencySymbol -> CurrencySymbol -> Bool
$c<= :: CurrencySymbol -> CurrencySymbol -> Bool
< :: CurrencySymbol -> CurrencySymbol -> Bool
$c< :: CurrencySymbol -> CurrencySymbol -> Bool
compare :: CurrencySymbol -> CurrencySymbol -> Ordering
$ccompare :: CurrencySymbol -> CurrencySymbol -> Ordering
$cp1Ord :: Eq CurrencySymbol
Ord, CurrencySymbol -> BuiltinData
(CurrencySymbol -> BuiltinData) -> ToData CurrencySymbol
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: CurrencySymbol -> BuiltinData
$ctoBuiltinData :: CurrencySymbol -> BuiltinData
PlutusTx.ToData, BuiltinData -> Maybe CurrencySymbol
(BuiltinData -> Maybe CurrencySymbol) -> FromData CurrencySymbol
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe CurrencySymbol
$cfromBuiltinData :: BuiltinData -> Maybe CurrencySymbol
PlutusTx.FromData, BuiltinData -> CurrencySymbol
(BuiltinData -> CurrencySymbol) -> UnsafeFromData CurrencySymbol
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> CurrencySymbol
$cunsafeFromBuiltinData :: BuiltinData -> CurrencySymbol
PlutusTx.UnsafeFromData)
deriving anyclass (CurrencySymbol -> ()
(CurrencySymbol -> ()) -> NFData CurrencySymbol
forall a. (a -> ()) -> NFData a
rnf :: CurrencySymbol -> ()
$crnf :: CurrencySymbol -> ()
NFData)
{-# INLINABLE mpsSymbol #-}
mpsSymbol :: MintingPolicyHash -> CurrencySymbol
mpsSymbol :: MintingPolicyHash -> CurrencySymbol
mpsSymbol (MintingPolicyHash BuiltinByteString
h) = BuiltinByteString -> CurrencySymbol
CurrencySymbol BuiltinByteString
h
{-# INLINABLE currencyMPSHash #-}
currencyMPSHash :: CurrencySymbol -> MintingPolicyHash
currencyMPSHash :: CurrencySymbol -> MintingPolicyHash
currencyMPSHash (CurrencySymbol BuiltinByteString
h) = BuiltinByteString -> MintingPolicyHash
MintingPolicyHash BuiltinByteString
h
{-# INLINABLE currencySymbol #-}
currencySymbol :: BS.ByteString -> CurrencySymbol
currencySymbol :: ByteString -> CurrencySymbol
currencySymbol = BuiltinByteString -> CurrencySymbol
CurrencySymbol (BuiltinByteString -> CurrencySymbol)
-> (ByteString -> BuiltinByteString)
-> ByteString
-> CurrencySymbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
PlutusTx.toBuiltin
newtype TokenName = TokenName { TokenName -> BuiltinByteString
unTokenName :: PlutusTx.BuiltinByteString }
deriving stock ((forall x. TokenName -> Rep TokenName x)
-> (forall x. Rep TokenName x -> TokenName) -> Generic TokenName
forall x. Rep TokenName x -> TokenName
forall x. TokenName -> Rep TokenName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TokenName x -> TokenName
$cfrom :: forall x. TokenName -> Rep TokenName x
Generic, Typeable TokenName
DataType
Constr
Typeable TokenName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenName -> c TokenName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenName)
-> (TokenName -> Constr)
-> (TokenName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenName))
-> ((forall b. Data b => b -> b) -> TokenName -> TokenName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r)
-> (forall u. (forall d. Data d => d -> u) -> TokenName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> TokenName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName)
-> Data TokenName
TokenName -> DataType
TokenName -> Constr
(forall b. Data b => b -> b) -> TokenName -> TokenName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenName -> c TokenName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenName
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TokenName -> u
forall u. (forall d. Data d => d -> u) -> TokenName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenName -> c TokenName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenName)
$cTokenName :: Constr
$tTokenName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> TokenName -> m TokenName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName
gmapMp :: (forall d. Data d => d -> m d) -> TokenName -> m TokenName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName
gmapM :: (forall d. Data d => d -> m d) -> TokenName -> m TokenName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenName -> m TokenName
gmapQi :: Int -> (forall d. Data d => d -> u) -> TokenName -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TokenName -> u
gmapQ :: (forall d. Data d => d -> u) -> TokenName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TokenName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenName -> r
gmapT :: (forall b. Data b => b -> b) -> TokenName -> TokenName
$cgmapT :: (forall b. Data b => b -> b) -> TokenName -> TokenName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c TokenName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenName)
dataTypeOf :: TokenName -> DataType
$cdataTypeOf :: TokenName -> DataType
toConstr :: TokenName -> Constr
$ctoConstr :: TokenName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenName -> c TokenName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenName -> c TokenName
$cp1Data :: Typeable TokenName
Data)
deriving newtype (TokenName -> TokenName -> Bool
(TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool) -> Eq TokenName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TokenName -> TokenName -> Bool
$c/= :: TokenName -> TokenName -> Bool
== :: TokenName -> TokenName -> Bool
$c== :: TokenName -> TokenName -> Bool
Haskell.Eq, Eq TokenName
Eq TokenName
-> (TokenName -> TokenName -> Ordering)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> TokenName)
-> (TokenName -> TokenName -> TokenName)
-> Ord TokenName
TokenName -> TokenName -> Bool
TokenName -> TokenName -> Ordering
TokenName -> TokenName -> TokenName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TokenName -> TokenName -> TokenName
$cmin :: TokenName -> TokenName -> TokenName
max :: TokenName -> TokenName -> TokenName
$cmax :: TokenName -> TokenName -> TokenName
>= :: TokenName -> TokenName -> Bool
$c>= :: TokenName -> TokenName -> Bool
> :: TokenName -> TokenName -> Bool
$c> :: TokenName -> TokenName -> Bool
<= :: TokenName -> TokenName -> Bool
$c<= :: TokenName -> TokenName -> Bool
< :: TokenName -> TokenName -> Bool
$c< :: TokenName -> TokenName -> Bool
compare :: TokenName -> TokenName -> Ordering
$ccompare :: TokenName -> TokenName -> Ordering
$cp1Ord :: Eq TokenName
Haskell.Ord, TokenName -> TokenName -> Bool
(TokenName -> TokenName -> Bool) -> Eq TokenName
forall a. (a -> a -> Bool) -> Eq a
== :: TokenName -> TokenName -> Bool
$c== :: TokenName -> TokenName -> Bool
Eq, Eq TokenName
Eq TokenName
-> (TokenName -> TokenName -> Ordering)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> Bool)
-> (TokenName -> TokenName -> TokenName)
-> (TokenName -> TokenName -> TokenName)
-> Ord TokenName
TokenName -> TokenName -> Bool
TokenName -> TokenName -> Ordering
TokenName -> TokenName -> TokenName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TokenName -> TokenName -> TokenName
$cmin :: TokenName -> TokenName -> TokenName
max :: TokenName -> TokenName -> TokenName
$cmax :: TokenName -> TokenName -> TokenName
>= :: TokenName -> TokenName -> Bool
$c>= :: TokenName -> TokenName -> Bool
> :: TokenName -> TokenName -> Bool
$c> :: TokenName -> TokenName -> Bool
<= :: TokenName -> TokenName -> Bool
$c<= :: TokenName -> TokenName -> Bool
< :: TokenName -> TokenName -> Bool
$c< :: TokenName -> TokenName -> Bool
compare :: TokenName -> TokenName -> Ordering
$ccompare :: TokenName -> TokenName -> Ordering
$cp1Ord :: Eq TokenName
Ord, TokenName -> BuiltinData
(TokenName -> BuiltinData) -> ToData TokenName
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: TokenName -> BuiltinData
$ctoBuiltinData :: TokenName -> BuiltinData
PlutusTx.ToData, BuiltinData -> Maybe TokenName
(BuiltinData -> Maybe TokenName) -> FromData TokenName
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe TokenName
$cfromBuiltinData :: BuiltinData -> Maybe TokenName
PlutusTx.FromData, BuiltinData -> TokenName
(BuiltinData -> TokenName) -> UnsafeFromData TokenName
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> TokenName
$cunsafeFromBuiltinData :: BuiltinData -> TokenName
PlutusTx.UnsafeFromData)
deriving anyclass (TokenName -> ()
(TokenName -> ()) -> NFData TokenName
forall a. (a -> ()) -> NFData a
rnf :: TokenName -> ()
$crnf :: TokenName -> ()
NFData)
deriving [TokenName] -> Doc ann
TokenName -> Doc ann
(forall ann. TokenName -> Doc ann)
-> (forall ann. [TokenName] -> Doc ann) -> Pretty TokenName
forall ann. [TokenName] -> Doc ann
forall ann. TokenName -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [TokenName] -> Doc ann
$cprettyList :: forall ann. [TokenName] -> Doc ann
pretty :: TokenName -> Doc ann
$cpretty :: forall ann. TokenName -> Doc ann
Pretty via (PrettyShow TokenName)
instance IsString TokenName where
fromString :: String -> TokenName
fromString = Text -> TokenName
fromText (Text -> TokenName) -> (String -> Text) -> String -> TokenName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack
{-# INLINABLE tokenName #-}
tokenName :: BS.ByteString -> TokenName
tokenName :: ByteString -> TokenName
tokenName = BuiltinByteString -> TokenName
TokenName (BuiltinByteString -> TokenName)
-> (ByteString -> BuiltinByteString) -> ByteString -> TokenName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
PlutusTx.toBuiltin
fromText :: Text -> TokenName
fromText :: Text -> TokenName
fromText = ByteString -> TokenName
tokenName (ByteString -> TokenName)
-> (Text -> ByteString) -> Text -> TokenName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
E.encodeUtf8
fromTokenName :: (BS.ByteString -> r) -> (Text -> r) -> TokenName -> r
fromTokenName :: (ByteString -> r) -> (Text -> r) -> TokenName -> r
fromTokenName ByteString -> r
handleBytestring Text -> r
handleText (TokenName BuiltinByteString
bs) = (UnicodeException -> r)
-> (Text -> r) -> Either UnicodeException Text -> r
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\UnicodeException
_ -> ByteString -> r
handleBytestring (ByteString -> r) -> ByteString -> r
forall a b. (a -> b) -> a -> b
$ BuiltinByteString -> ByteString
forall arep a. FromBuiltin arep a => arep -> a
PlutusTx.fromBuiltin BuiltinByteString
bs) Text -> r
handleText (Either UnicodeException Text -> r)
-> Either UnicodeException Text -> r
forall a b. (a -> b) -> a -> b
$ ByteString -> Either UnicodeException Text
E.decodeUtf8' (BuiltinByteString -> ByteString
forall arep a. FromBuiltin arep a => arep -> a
PlutusTx.fromBuiltin BuiltinByteString
bs)
asBase16 :: BS.ByteString -> Text
asBase16 :: ByteString -> Text
asBase16 ByteString
bs = [Text] -> Text
Text.concat [Item [Text]
"0x", ByteString -> Text
encodeByteString ByteString
bs]
quoted :: Text -> Text
quoted :: Text -> Text
quoted Text
s = [Text] -> Text
Text.concat [Item [Text]
"\"", Item [Text]
Text
s, Item [Text]
"\""]
toString :: TokenName -> Haskell.String
toString :: TokenName -> String
toString = Text -> String
Text.unpack (Text -> String) -> (TokenName -> Text) -> TokenName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> Text) -> (Text -> Text) -> TokenName -> Text
forall r. (ByteString -> r) -> (Text -> r) -> TokenName -> r
fromTokenName ByteString -> Text
asBase16 Text -> Text
forall a. a -> a
id
instance Haskell.Show TokenName where
show :: TokenName -> String
show = Text -> String
Text.unpack (Text -> String) -> (TokenName -> Text) -> TokenName -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> Text) -> (Text -> Text) -> TokenName -> Text
forall r. (ByteString -> r) -> (Text -> r) -> TokenName -> r
fromTokenName ByteString -> Text
asBase16 Text -> Text
quoted
{-# INLINABLE adaSymbol #-}
adaSymbol :: CurrencySymbol
adaSymbol :: CurrencySymbol
adaSymbol = BuiltinByteString -> CurrencySymbol
CurrencySymbol BuiltinByteString
emptyByteString
{-# INLINABLE adaToken #-}
adaToken :: TokenName
adaToken :: TokenName
adaToken = BuiltinByteString -> TokenName
TokenName BuiltinByteString
emptyByteString
newtype AssetClass = AssetClass { AssetClass -> (CurrencySymbol, TokenName)
unAssetClass :: (CurrencySymbol, TokenName) }
deriving stock ((forall x. AssetClass -> Rep AssetClass x)
-> (forall x. Rep AssetClass x -> AssetClass) -> Generic AssetClass
forall x. Rep AssetClass x -> AssetClass
forall x. AssetClass -> Rep AssetClass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetClass x -> AssetClass
$cfrom :: forall x. AssetClass -> Rep AssetClass x
Generic, Typeable AssetClass
DataType
Constr
Typeable AssetClass
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AssetClass -> c AssetClass)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AssetClass)
-> (AssetClass -> Constr)
-> (AssetClass -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AssetClass))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c AssetClass))
-> ((forall b. Data b => b -> b) -> AssetClass -> AssetClass)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r)
-> (forall u. (forall d. Data d => d -> u) -> AssetClass -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> AssetClass -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass)
-> Data AssetClass
AssetClass -> DataType
AssetClass -> Constr
(forall b. Data b => b -> b) -> AssetClass -> AssetClass
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AssetClass -> c AssetClass
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AssetClass
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AssetClass -> u
forall u. (forall d. Data d => d -> u) -> AssetClass -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AssetClass
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AssetClass -> c AssetClass
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AssetClass)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AssetClass)
$cAssetClass :: Constr
$tAssetClass :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
gmapMp :: (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
gmapM :: (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AssetClass -> m AssetClass
gmapQi :: Int -> (forall d. Data d => d -> u) -> AssetClass -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AssetClass -> u
gmapQ :: (forall d. Data d => d -> u) -> AssetClass -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AssetClass -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AssetClass -> r
gmapT :: (forall b. Data b => b -> b) -> AssetClass -> AssetClass
$cgmapT :: (forall b. Data b => b -> b) -> AssetClass -> AssetClass
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AssetClass)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AssetClass)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AssetClass)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AssetClass)
dataTypeOf :: AssetClass -> DataType
$cdataTypeOf :: AssetClass -> DataType
toConstr :: AssetClass -> Constr
$ctoConstr :: AssetClass -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AssetClass
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AssetClass
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AssetClass -> c AssetClass
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AssetClass -> c AssetClass
$cp1Data :: Typeable AssetClass
Data)
deriving newtype (AssetClass -> AssetClass -> Bool
(AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool) -> Eq AssetClass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetClass -> AssetClass -> Bool
$c/= :: AssetClass -> AssetClass -> Bool
== :: AssetClass -> AssetClass -> Bool
$c== :: AssetClass -> AssetClass -> Bool
Haskell.Eq, Eq AssetClass
Eq AssetClass
-> (AssetClass -> AssetClass -> Ordering)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> AssetClass)
-> (AssetClass -> AssetClass -> AssetClass)
-> Ord AssetClass
AssetClass -> AssetClass -> Bool
AssetClass -> AssetClass -> Ordering
AssetClass -> AssetClass -> AssetClass
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AssetClass -> AssetClass -> AssetClass
$cmin :: AssetClass -> AssetClass -> AssetClass
max :: AssetClass -> AssetClass -> AssetClass
$cmax :: AssetClass -> AssetClass -> AssetClass
>= :: AssetClass -> AssetClass -> Bool
$c>= :: AssetClass -> AssetClass -> Bool
> :: AssetClass -> AssetClass -> Bool
$c> :: AssetClass -> AssetClass -> Bool
<= :: AssetClass -> AssetClass -> Bool
$c<= :: AssetClass -> AssetClass -> Bool
< :: AssetClass -> AssetClass -> Bool
$c< :: AssetClass -> AssetClass -> Bool
compare :: AssetClass -> AssetClass -> Ordering
$ccompare :: AssetClass -> AssetClass -> Ordering
$cp1Ord :: Eq AssetClass
Haskell.Ord, Int -> AssetClass -> ShowS
[AssetClass] -> ShowS
AssetClass -> String
(Int -> AssetClass -> ShowS)
-> (AssetClass -> String)
-> ([AssetClass] -> ShowS)
-> Show AssetClass
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetClass] -> ShowS
$cshowList :: [AssetClass] -> ShowS
show :: AssetClass -> String
$cshow :: AssetClass -> String
showsPrec :: Int -> AssetClass -> ShowS
$cshowsPrec :: Int -> AssetClass -> ShowS
Haskell.Show, AssetClass -> AssetClass -> Bool
(AssetClass -> AssetClass -> Bool) -> Eq AssetClass
forall a. (a -> a -> Bool) -> Eq a
== :: AssetClass -> AssetClass -> Bool
$c== :: AssetClass -> AssetClass -> Bool
Eq, Eq AssetClass
Eq AssetClass
-> (AssetClass -> AssetClass -> Ordering)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> Bool)
-> (AssetClass -> AssetClass -> AssetClass)
-> (AssetClass -> AssetClass -> AssetClass)
-> Ord AssetClass
AssetClass -> AssetClass -> Bool
AssetClass -> AssetClass -> Ordering
AssetClass -> AssetClass -> AssetClass
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AssetClass -> AssetClass -> AssetClass
$cmin :: AssetClass -> AssetClass -> AssetClass
max :: AssetClass -> AssetClass -> AssetClass
$cmax :: AssetClass -> AssetClass -> AssetClass
>= :: AssetClass -> AssetClass -> Bool
$c>= :: AssetClass -> AssetClass -> Bool
> :: AssetClass -> AssetClass -> Bool
$c> :: AssetClass -> AssetClass -> Bool
<= :: AssetClass -> AssetClass -> Bool
$c<= :: AssetClass -> AssetClass -> Bool
< :: AssetClass -> AssetClass -> Bool
$c< :: AssetClass -> AssetClass -> Bool
compare :: AssetClass -> AssetClass -> Ordering
$ccompare :: AssetClass -> AssetClass -> Ordering
$cp1Ord :: Eq AssetClass
Ord, AssetClass -> BuiltinData
(AssetClass -> BuiltinData) -> ToData AssetClass
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: AssetClass -> BuiltinData
$ctoBuiltinData :: AssetClass -> BuiltinData
PlutusTx.ToData, BuiltinData -> Maybe AssetClass
(BuiltinData -> Maybe AssetClass) -> FromData AssetClass
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe AssetClass
$cfromBuiltinData :: BuiltinData -> Maybe AssetClass
PlutusTx.FromData, BuiltinData -> AssetClass
(BuiltinData -> AssetClass) -> UnsafeFromData AssetClass
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> AssetClass
$cunsafeFromBuiltinData :: BuiltinData -> AssetClass
PlutusTx.UnsafeFromData)
deriving anyclass (AssetClass -> ()
(AssetClass -> ()) -> NFData AssetClass
forall a. (a -> ()) -> NFData a
rnf :: AssetClass -> ()
$crnf :: AssetClass -> ()
NFData)
deriving [AssetClass] -> Doc ann
AssetClass -> Doc ann
(forall ann. AssetClass -> Doc ann)
-> (forall ann. [AssetClass] -> Doc ann) -> Pretty AssetClass
forall ann. [AssetClass] -> Doc ann
forall ann. AssetClass -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [AssetClass] -> Doc ann
$cprettyList :: forall ann. [AssetClass] -> Doc ann
pretty :: AssetClass -> Doc ann
$cpretty :: forall ann. AssetClass -> Doc ann
Pretty via (PrettyShow (CurrencySymbol, TokenName))
{-# INLINABLE assetClass #-}
assetClass :: CurrencySymbol -> TokenName -> AssetClass
assetClass :: CurrencySymbol -> TokenName -> AssetClass
assetClass CurrencySymbol
s TokenName
t = (CurrencySymbol, TokenName) -> AssetClass
AssetClass (CurrencySymbol
s, TokenName
t)
newtype Value = Value { Value -> Map CurrencySymbol (Map TokenName Integer)
getValue :: Map.Map CurrencySymbol (Map.Map TokenName Integer) }
deriving stock ((forall x. Value -> Rep Value x)
-> (forall x. Rep Value x -> Value) -> Generic Value
forall x. Rep Value x -> Value
forall x. Value -> Rep Value x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Value x -> Value
$cfrom :: forall x. Value -> Rep Value x
Generic, Typeable Value
DataType
Constr
Typeable Value
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Value -> c Value)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Value)
-> (Value -> Constr)
-> (Value -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Value))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value))
-> ((forall b. Data b => b -> b) -> Value -> Value)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r)
-> (forall u. (forall d. Data d => d -> u) -> Value -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Value -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Value -> m Value)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Value -> m Value)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Value -> m Value)
-> Data Value
Value -> DataType
Value -> Constr
(forall b. Data b => b -> b) -> Value -> Value
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Value -> c Value
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Value
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Value -> u
forall u. (forall d. Data d => d -> u) -> Value -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Value -> m Value
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Value -> m Value
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Value
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Value -> c Value
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Value)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value)
$cValue :: Constr
$tValue :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Value -> m Value
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Value -> m Value
gmapMp :: (forall d. Data d => d -> m d) -> Value -> m Value
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Value -> m Value
gmapM :: (forall d. Data d => d -> m d) -> Value -> m Value
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Value -> m Value
gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Value -> u
gmapQ :: (forall d. Data d => d -> u) -> Value -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Value -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r
gmapT :: (forall b. Data b => b -> b) -> Value -> Value
$cgmapT :: (forall b. Data b => b -> b) -> Value -> Value
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Value)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Value)
dataTypeOf :: Value -> DataType
$cdataTypeOf :: Value -> DataType
toConstr :: Value -> Constr
$ctoConstr :: Value -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Value
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Value
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Value -> c Value
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Value -> c Value
$cp1Data :: Typeable Value
Data)
deriving anyclass (Value -> ()
(Value -> ()) -> NFData Value
forall a. (a -> ()) -> NFData a
rnf :: Value -> ()
$crnf :: Value -> ()
NFData)
deriving newtype (Value -> BuiltinData
(Value -> BuiltinData) -> ToData Value
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: Value -> BuiltinData
$ctoBuiltinData :: Value -> BuiltinData
PlutusTx.ToData, BuiltinData -> Maybe Value
(BuiltinData -> Maybe Value) -> FromData Value
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe Value
$cfromBuiltinData :: BuiltinData -> Maybe Value
PlutusTx.FromData, BuiltinData -> Value
(BuiltinData -> Value) -> UnsafeFromData Value
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> Value
$cunsafeFromBuiltinData :: BuiltinData -> Value
PlutusTx.UnsafeFromData)
deriving [Value] -> Doc ann
Value -> Doc ann
(forall ann. Value -> Doc ann)
-> (forall ann. [Value] -> Doc ann) -> Pretty Value
forall ann. [Value] -> Doc ann
forall ann. Value -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [Value] -> Doc ann
$cprettyList :: forall ann. [Value] -> Doc ann
pretty :: Value -> Doc ann
$cpretty :: forall ann. Value -> Doc ann
Pretty via (PrettyShow Value)
instance Haskell.Show Value where
showsPrec :: Int -> Value -> ShowS
showsPrec Int
d Value
v =
Bool -> ShowS -> ShowS
Haskell.showParen (Int
d Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
Haskell.== Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
Haskell.showString String
"Value " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> ShowS -> ShowS
Haskell.showParen Bool
True (((CurrencySymbol, Map TokenName Integer) -> ShowS)
-> Map CurrencySymbol (Map TokenName Integer) -> ShowS
forall k v. ((k, v) -> ShowS) -> Map k v -> ShowS
showsMap ((Map TokenName Integer -> ShowS)
-> (CurrencySymbol, Map TokenName Integer) -> ShowS
forall a t. Show a => (t -> ShowS) -> (a, t) -> ShowS
showPair (((TokenName, Integer) -> ShowS) -> Map TokenName Integer -> ShowS
forall k v. ((k, v) -> ShowS) -> Map k v -> ShowS
showsMap (TokenName, Integer) -> ShowS
forall a. Show a => a -> ShowS
Haskell.shows)) Map CurrencySymbol (Map TokenName Integer)
rep))
where Value Map CurrencySymbol (Map TokenName Integer)
rep = Value -> Value
normalizeValue Value
v
showsMap :: ((k, v) -> ShowS) -> Map k v -> ShowS
showsMap (k, v) -> ShowS
sh Map k v
m = String -> ShowS
Haskell.showString String
"Map " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((k, v) -> ShowS) -> [(k, v)] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showList__ (k, v) -> ShowS
sh (Map k v -> [(k, v)]
forall k v. Map k v -> [(k, v)]
Map.toList Map k v
m)
showPair :: (t -> ShowS) -> (a, t) -> ShowS
showPair t -> ShowS
s (a
x,t
y) = Bool -> ShowS -> ShowS
Haskell.showParen Bool
True (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ a -> ShowS
forall a. Show a => a -> ShowS
Haskell.shows a
x ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
Haskell.showString String
"," ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> ShowS
s t
y
normalizeValue :: Value -> Value
normalizeValue :: Value -> Value
normalizeValue = Map CurrencySymbol (Map TokenName Integer) -> Value
Value (Map CurrencySymbol (Map TokenName Integer) -> Value)
-> (Value -> Map CurrencySymbol (Map TokenName Integer))
-> Value
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(CurrencySymbol, Map TokenName Integer)]
-> Map CurrencySymbol (Map TokenName Integer)
forall k v. [(k, v)] -> Map k v
Map.fromList ([(CurrencySymbol, Map TokenName Integer)]
-> Map CurrencySymbol (Map TokenName Integer))
-> (Value -> [(CurrencySymbol, Map TokenName Integer)])
-> Value
-> Map CurrencySymbol (Map TokenName Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)]
forall a. Ord a => [a] -> [a]
sort ([(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)])
-> (Value -> [(CurrencySymbol, Map TokenName Integer)])
-> Value
-> [(CurrencySymbol, Map TokenName Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map TokenName Integer -> Bool)
-> [(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)]
forall b a. (b -> Bool) -> [(a, b)] -> [(a, b)]
filterRange (Map TokenName Integer -> Map TokenName Integer -> Bool
forall a. Eq a => a -> a -> Bool
/=Map TokenName Integer
forall k v. Map k v
Map.empty)
([(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)])
-> (Value -> [(CurrencySymbol, Map TokenName Integer)])
-> Value
-> [(CurrencySymbol, Map TokenName Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map TokenName Integer -> Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)]
forall t b a. (t -> b) -> [(a, t)] -> [(a, b)]
mapRange Map TokenName Integer -> Map TokenName Integer
normalizeTokenMap ([(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, Map TokenName Integer)])
-> (Value -> [(CurrencySymbol, Map TokenName Integer)])
-> Value
-> [(CurrencySymbol, Map TokenName Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map CurrencySymbol (Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)]
forall k v. Map k v -> [(k, v)]
Map.toList (Map CurrencySymbol (Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)])
-> (Value -> Map CurrencySymbol (Map TokenName Integer))
-> Value
-> [(CurrencySymbol, Map TokenName Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Map CurrencySymbol (Map TokenName Integer)
getValue
where normalizeTokenMap :: Map TokenName Integer -> Map TokenName Integer
normalizeTokenMap = [(TokenName, Integer)] -> Map TokenName Integer
forall k v. [(k, v)] -> Map k v
Map.fromList ([(TokenName, Integer)] -> Map TokenName Integer)
-> (Map TokenName Integer -> [(TokenName, Integer)])
-> Map TokenName Integer
-> Map TokenName Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(TokenName, Integer)] -> [(TokenName, Integer)]
forall a. Ord a => [a] -> [a]
sort ([(TokenName, Integer)] -> [(TokenName, Integer)])
-> (Map TokenName Integer -> [(TokenName, Integer)])
-> Map TokenName Integer
-> [(TokenName, Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Integer -> Bool)
-> [(TokenName, Integer)] -> [(TokenName, Integer)]
forall b a. (b -> Bool) -> [(a, b)] -> [(a, b)]
filterRange (Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
/=Integer
0) ([(TokenName, Integer)] -> [(TokenName, Integer)])
-> (Map TokenName Integer -> [(TokenName, Integer)])
-> Map TokenName Integer
-> [(TokenName, Integer)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map TokenName Integer -> [(TokenName, Integer)]
forall k v. Map k v -> [(k, v)]
Map.toList
filterRange :: (b -> Bool) -> [(a, b)] -> [(a, b)]
filterRange b -> Bool
p [(a, b)]
kvs = [(a
k,b
v) | (a
k,b
v) <- [(a, b)]
kvs, b -> Bool
p b
v]
mapRange :: (t -> b) -> [(a, t)] -> [(a, b)]
mapRange t -> b
f [(a, t)]
xys = [(a
x,t -> b
f t
y) | (a
x,t
y) <- [(a, t)]
xys]
sort :: [a] -> [a]
sort [a]
xs = (a -> a -> Ordering) -> [a] -> [a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
Data.List.sortBy a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare [a]
xs
instance Haskell.Eq Value where
== :: Value -> Value -> Bool
(==) = Value -> Value -> Bool
eq
instance Eq Value where
{-# INLINABLE (==) #-}
== :: Value -> Value -> Bool
(==) = Value -> Value -> Bool
eq
instance Haskell.Semigroup Value where
<> :: Value -> Value -> Value
(<>) = (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith Integer -> Integer -> Integer
forall a. AdditiveSemigroup a => a -> a -> a
(+)
instance Semigroup Value where
{-# INLINABLE (<>) #-}
<> :: Value -> Value -> Value
(<>) = (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith Integer -> Integer -> Integer
forall a. AdditiveSemigroup a => a -> a -> a
(+)
instance Haskell.Monoid Value where
mempty :: Value
mempty = Map CurrencySymbol (Map TokenName Integer) -> Value
Value Map CurrencySymbol (Map TokenName Integer)
forall k v. Map k v
Map.empty
instance Monoid Value where
{-# INLINABLE mempty #-}
mempty :: Value
mempty = Map CurrencySymbol (Map TokenName Integer) -> Value
Value Map CurrencySymbol (Map TokenName Integer)
forall k v. Map k v
Map.empty
instance Group Value where
{-# INLINABLE inv #-}
inv :: Value -> Value
inv = Integer -> Value -> Value
forall s v. Module s v => s -> v -> v
scale @Integer @Value (-Integer
1)
deriving via (Additive Value) instance AdditiveSemigroup Value
deriving via (Additive Value) instance AdditiveMonoid Value
deriving via (Additive Value) instance AdditiveGroup Value
instance Module Integer Value where
{-# INLINABLE scale #-}
scale :: Integer -> Value -> Value
scale Integer
i (Value Map CurrencySymbol (Map TokenName Integer)
xs) = Map CurrencySymbol (Map TokenName Integer) -> Value
Value ((Map TokenName Integer -> Map TokenName Integer)
-> Map CurrencySymbol (Map TokenName Integer)
-> Map CurrencySymbol (Map TokenName Integer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Integer -> Integer)
-> Map TokenName Integer -> Map TokenName Integer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Integer
i' -> Integer
i Integer -> Integer -> Integer
forall a. MultiplicativeSemigroup a => a -> a -> a
* Integer
i')) Map CurrencySymbol (Map TokenName Integer)
xs)
instance JoinSemiLattice Value where
{-# INLINABLE (\/) #-}
\/ :: Value -> Value -> Value
(\/) = (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
Ord.max
instance MeetSemiLattice Value where
{-# INLINABLE (/\) #-}
/\ :: Value -> Value -> Value
(/\) = (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a
Ord.min
{-# INLINABLE valueOf #-}
valueOf :: Value -> CurrencySymbol -> TokenName -> Integer
valueOf :: Value -> CurrencySymbol -> TokenName -> Integer
valueOf (Value Map CurrencySymbol (Map TokenName Integer)
mp) CurrencySymbol
cur TokenName
tn =
case CurrencySymbol
-> Map CurrencySymbol (Map TokenName Integer)
-> Maybe (Map TokenName Integer)
forall k v. Eq k => k -> Map k v -> Maybe v
Map.lookup CurrencySymbol
cur Map CurrencySymbol (Map TokenName Integer)
mp of
Maybe (Map TokenName Integer)
Nothing -> Integer
0 :: Integer
Just Map TokenName Integer
i -> case TokenName -> Map TokenName Integer -> Maybe Integer
forall k v. Eq k => k -> Map k v -> Maybe v
Map.lookup TokenName
tn Map TokenName Integer
i of
Maybe Integer
Nothing -> Integer
0
Just Integer
v -> Integer
v
{-# INLINABLE symbols #-}
symbols :: Value -> [CurrencySymbol]
symbols :: Value -> [CurrencySymbol]
symbols (Value Map CurrencySymbol (Map TokenName Integer)
mp) = Map CurrencySymbol (Map TokenName Integer) -> [CurrencySymbol]
forall k v. Map k v -> [k]
Map.keys Map CurrencySymbol (Map TokenName Integer)
mp
{-# INLINABLE singleton #-}
singleton :: CurrencySymbol -> TokenName -> Integer -> Value
singleton :: CurrencySymbol -> TokenName -> Integer -> Value
singleton CurrencySymbol
c TokenName
tn Integer
i = Map CurrencySymbol (Map TokenName Integer) -> Value
Value (CurrencySymbol
-> Map TokenName Integer
-> Map CurrencySymbol (Map TokenName Integer)
forall k v. k -> v -> Map k v
Map.singleton CurrencySymbol
c (TokenName -> Integer -> Map TokenName Integer
forall k v. k -> v -> Map k v
Map.singleton TokenName
tn Integer
i))
{-# INLINABLE assetClassValue #-}
assetClassValue :: AssetClass -> Integer -> Value
assetClassValue :: AssetClass -> Integer -> Value
assetClassValue (AssetClass (CurrencySymbol
c, TokenName
t)) Integer
i = CurrencySymbol -> TokenName -> Integer -> Value
singleton CurrencySymbol
c TokenName
t Integer
i
{-# INLINABLE assetClassValueOf #-}
assetClassValueOf :: Value -> AssetClass -> Integer
assetClassValueOf :: Value -> AssetClass -> Integer
assetClassValueOf Value
v (AssetClass (CurrencySymbol
c, TokenName
t)) = Value -> CurrencySymbol -> TokenName -> Integer
valueOf Value
v CurrencySymbol
c TokenName
t
{-# INLINABLE unionVal #-}
unionVal :: Value -> Value -> Map.Map CurrencySymbol (Map.Map TokenName (These Integer Integer))
unionVal :: Value
-> Value
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
unionVal (Value Map CurrencySymbol (Map TokenName Integer)
l) (Value Map CurrencySymbol (Map TokenName Integer)
r) =
let
combined :: Map
CurrencySymbol
(These (Map TokenName Integer) (Map TokenName Integer))
combined = Map CurrencySymbol (Map TokenName Integer)
-> Map CurrencySymbol (Map TokenName Integer)
-> Map
CurrencySymbol
(These (Map TokenName Integer) (Map TokenName Integer))
forall k v r. Eq k => Map k v -> Map k r -> Map k (These v r)
Map.union Map CurrencySymbol (Map TokenName Integer)
l Map CurrencySymbol (Map TokenName Integer)
r
unThese :: These (Map k v) (Map k r) -> Map k (These v r)
unThese These (Map k v) (Map k r)
k = case These (Map k v) (Map k r)
k of
This Map k v
a -> v -> These v r
forall a b. a -> These a b
This (v -> These v r) -> Map k v -> Map k (These v r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map k v
a
That Map k r
b -> r -> These v r
forall a b. b -> These a b
That (r -> These v r) -> Map k r -> Map k (These v r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map k r
b
These Map k v
a Map k r
b -> Map k v -> Map k r -> Map k (These v r)
forall k v r. Eq k => Map k v -> Map k r -> Map k (These v r)
Map.union Map k v
a Map k r
b
in These (Map TokenName Integer) (Map TokenName Integer)
-> Map TokenName (These Integer Integer)
forall k v r.
Eq k =>
These (Map k v) (Map k r) -> Map k (These v r)
unThese (These (Map TokenName Integer) (Map TokenName Integer)
-> Map TokenName (These Integer Integer))
-> Map
CurrencySymbol
(These (Map TokenName Integer) (Map TokenName Integer))
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map
CurrencySymbol
(These (Map TokenName Integer) (Map TokenName Integer))
combined
{-# INLINABLE unionWith #-}
unionWith :: (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith :: (Integer -> Integer -> Integer) -> Value -> Value -> Value
unionWith Integer -> Integer -> Integer
f Value
ls Value
rs =
let
combined :: Map CurrencySymbol (Map TokenName (These Integer Integer))
combined = Value
-> Value
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
unionVal Value
ls Value
rs
unThese :: These Integer Integer -> Integer
unThese These Integer Integer
k' = case These Integer Integer
k' of
This Integer
a -> Integer -> Integer -> Integer
f Integer
a Integer
0
That Integer
b -> Integer -> Integer -> Integer
f Integer
0 Integer
b
These Integer
a Integer
b -> Integer -> Integer -> Integer
f Integer
a Integer
b
in Map CurrencySymbol (Map TokenName Integer) -> Value
Value ((Map TokenName (These Integer Integer) -> Map TokenName Integer)
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
-> Map CurrencySymbol (Map TokenName Integer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((These Integer Integer -> Integer)
-> Map TokenName (These Integer Integer) -> Map TokenName Integer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap These Integer Integer -> Integer
unThese) Map CurrencySymbol (Map TokenName (These Integer Integer))
combined)
{-# INLINABLE flattenValue #-}
flattenValue :: Value -> [(CurrencySymbol, TokenName, Integer)]
flattenValue :: Value -> [(CurrencySymbol, TokenName, Integer)]
flattenValue Value
v = [(CurrencySymbol, TokenName, Integer)]
-> [(CurrencySymbol, Map TokenName Integer)]
-> [(CurrencySymbol, TokenName, Integer)]
forall c a b.
(Eq c, Num c) =>
[(a, b, c)] -> [(a, Map b c)] -> [(a, b, c)]
goOuter [] (Map CurrencySymbol (Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)]
forall k v. Map k v -> [(k, v)]
Map.toList (Map CurrencySymbol (Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)])
-> Map CurrencySymbol (Map TokenName Integer)
-> [(CurrencySymbol, Map TokenName Integer)]
forall a b. (a -> b) -> a -> b
$ Value -> Map CurrencySymbol (Map TokenName Integer)
getValue Value
v)
where
goOuter :: [(a, b, c)] -> [(a, Map b c)] -> [(a, b, c)]
goOuter [(a, b, c)]
acc [] = [(a, b, c)]
acc
goOuter [(a, b, c)]
acc ((a
cs, Map b c
m) : [(a, Map b c)]
tl) = [(a, b, c)] -> [(a, Map b c)] -> [(a, b, c)]
goOuter (a -> [(a, b, c)] -> [(b, c)] -> [(a, b, c)]
forall c a b.
(Eq c, Num c) =>
a -> [(a, b, c)] -> [(b, c)] -> [(a, b, c)]
goInner a
cs [(a, b, c)]
acc (Map b c -> [(b, c)]
forall k v. Map k v -> [(k, v)]
Map.toList Map b c
m)) [(a, Map b c)]
tl
goInner :: a -> [(a, b, c)] -> [(b, c)] -> [(a, b, c)]
goInner a
_ [(a, b, c)]
acc [] = [(a, b, c)]
acc
goInner a
cs [(a, b, c)]
acc ((b
tn, c
a) : [(b, c)]
tl)
| c
a c -> c -> Bool
forall a. Eq a => a -> a -> Bool
/= c
0 = a -> [(a, b, c)] -> [(b, c)] -> [(a, b, c)]
goInner a
cs ((a
cs, b
tn, c
a) (a, b, c) -> [(a, b, c)] -> [(a, b, c)]
forall a. a -> [a] -> [a]
: [(a, b, c)]
acc) [(b, c)]
tl
| Bool
otherwise = a -> [(a, b, c)] -> [(b, c)] -> [(a, b, c)]
goInner a
cs [(a, b, c)]
acc [(b, c)]
tl
{-# INLINABLE isZero #-}
isZero :: Value -> Bool
isZero :: Value -> Bool
isZero (Value Map CurrencySymbol (Map TokenName Integer)
xs) = (Map TokenName Integer -> Bool)
-> Map CurrencySymbol (Map TokenName Integer) -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Map.all ((Integer -> Bool) -> Map TokenName Integer -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Map.all (\Integer
i -> Integer
0 Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer
i)) Map CurrencySymbol (Map TokenName Integer)
xs
{-# INLINABLE checkPred #-}
checkPred :: (These Integer Integer -> Bool) -> Value -> Value -> Bool
checkPred :: (These Integer Integer -> Bool) -> Value -> Value -> Bool
checkPred These Integer Integer -> Bool
f Value
l Value
r =
let
inner :: Map.Map TokenName (These Integer Integer) -> Bool
inner :: Map TokenName (These Integer Integer) -> Bool
inner = (These Integer Integer -> Bool)
-> Map TokenName (These Integer Integer) -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Map.all These Integer Integer -> Bool
f
in
(Map TokenName (These Integer Integer) -> Bool)
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
-> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
Map.all Map TokenName (These Integer Integer) -> Bool
inner (Value
-> Value
-> Map CurrencySymbol (Map TokenName (These Integer Integer))
unionVal Value
l Value
r)
{-# INLINABLE checkBinRel #-}
checkBinRel :: (Integer -> Integer -> Bool) -> Value -> Value -> Bool
checkBinRel :: (Integer -> Integer -> Bool) -> Value -> Value -> Bool
checkBinRel Integer -> Integer -> Bool
f Value
l Value
r =
let
unThese :: These Integer Integer -> Bool
unThese These Integer Integer
k' = case These Integer Integer
k' of
This Integer
a -> Integer -> Integer -> Bool
f Integer
a Integer
0
That Integer
b -> Integer -> Integer -> Bool
f Integer
0 Integer
b
These Integer
a Integer
b -> Integer -> Integer -> Bool
f Integer
a Integer
b
in (These Integer Integer -> Bool) -> Value -> Value -> Bool
checkPred These Integer Integer -> Bool
unThese Value
l Value
r
{-# INLINABLE eq #-}
eq :: Value -> Value -> Bool
eq :: Value -> Value -> Bool
eq = (Integer -> Integer -> Bool) -> Value -> Value -> Bool
checkBinRel Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(==)
{-# INLINABLE geq #-}
geq :: Value -> Value -> Bool
geq :: Value -> Value -> Bool
geq = (Integer -> Integer -> Bool) -> Value -> Value -> Bool
checkBinRel Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=)
{-# INLINABLE leq #-}
leq :: Value -> Value -> Bool
leq :: Value -> Value -> Bool
leq = (Integer -> Integer -> Bool) -> Value -> Value -> Bool
checkBinRel Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<=)
{-# INLINABLE gt #-}
gt :: Value -> Value -> Bool
gt :: Value -> Value -> Bool
gt Value
l Value
r = Value -> Value -> Bool
geq Value
l Value
r Bool -> Bool -> Bool
&& Bool -> Bool
not (Value -> Value -> Bool
eq Value
l Value
r)
{-# INLINABLE lt #-}
lt :: Value -> Value -> Bool
lt :: Value -> Value -> Bool
lt Value
l Value
r = Value -> Value -> Bool
leq Value
l Value
r Bool -> Bool -> Bool
&& Bool -> Bool
not (Value -> Value -> Bool
eq Value
l Value
r)
{-# INLINABLE split #-}
split :: Value -> (Value, Value)
split :: Value -> (Value, Value)
split (Value Map CurrencySymbol (Map TokenName Integer)
mp) = (Value -> Value
forall a. AdditiveGroup a => a -> a
negate (Map CurrencySymbol (Map TokenName Integer) -> Value
Value Map CurrencySymbol (Map TokenName Integer)
neg), Map CurrencySymbol (Map TokenName Integer) -> Value
Value Map CurrencySymbol (Map TokenName Integer)
pos) where
(Map CurrencySymbol (Map TokenName Integer)
neg, Map CurrencySymbol (Map TokenName Integer)
pos) = (Map TokenName Integer
-> These (Map TokenName Integer) (Map TokenName Integer))
-> Map CurrencySymbol (Map TokenName Integer)
-> (Map CurrencySymbol (Map TokenName Integer),
Map CurrencySymbol (Map TokenName Integer))
forall v a b k. (v -> These a b) -> Map k v -> (Map k a, Map k b)
Map.mapThese Map TokenName Integer
-> These (Map TokenName Integer) (Map TokenName Integer)
splitIntl Map CurrencySymbol (Map TokenName Integer)
mp
splitIntl :: Map.Map TokenName Integer -> These (Map.Map TokenName Integer) (Map.Map TokenName Integer)
splitIntl :: Map TokenName Integer
-> These (Map TokenName Integer) (Map TokenName Integer)
splitIntl Map TokenName Integer
mp' = Map TokenName Integer
-> Map TokenName Integer
-> These (Map TokenName Integer) (Map TokenName Integer)
forall a b. a -> b -> These a b
These Map TokenName Integer
l Map TokenName Integer
r where
(Map TokenName Integer
l, Map TokenName Integer
r) = (Integer -> These Integer Integer)
-> Map TokenName Integer
-> (Map TokenName Integer, Map TokenName Integer)
forall v a b k. (v -> These a b) -> Map k v -> (Map k a, Map k b)
Map.mapThese (\Integer
i -> if Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
0 then Integer -> These Integer Integer
forall a b. a -> These a b
This Integer
i else Integer -> These Integer Integer
forall a b. b -> These a b
That Integer
i) Map TokenName Integer
mp'
makeLift ''CurrencySymbol
makeLift ''TokenName
makeLift ''AssetClass
makeLift ''Value