plutus-ledger-api-0.1.0.0: Interface to the Plutus ledger for the Cardano ledger.
Safe HaskellNone
LanguageHaskell2010

Plutus.V1.Ledger.Value

Description

Functions for working with Value.

Synopsis

Currency symbols

newtype CurrencySymbol Source #

Instances

Instances details
Eq CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Data CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CurrencySymbol -> c CurrencySymbol Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CurrencySymbol Source #

toConstr :: CurrencySymbol -> Constr Source #

dataTypeOf :: CurrencySymbol -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CurrencySymbol) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CurrencySymbol) Source #

gmapT :: (forall b. Data b => b -> b) -> CurrencySymbol -> CurrencySymbol Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CurrencySymbol -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CurrencySymbol -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CurrencySymbol -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CurrencySymbol -> m CurrencySymbol Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CurrencySymbol -> m CurrencySymbol Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CurrencySymbol -> m CurrencySymbol Source #

Ord CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Show CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

IsString CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Generic CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Associated Types

type Rep CurrencySymbol :: Type -> Type Source #

Hashable CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToJSON CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToJSONKey CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromJSON CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromJSONKey CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

NFData CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

rnf :: CurrencySymbol -> () Source #

Pretty CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToData CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromData CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

UnsafeFromData CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Ord CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Eq CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Serialise CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Lift DefaultUni CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Typeable DefaultUni CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep CurrencySymbol Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep CurrencySymbol = D1 ('MetaData "CurrencySymbol" "Plutus.V1.Ledger.Value" "plutus-ledger-api-0.1.0.0-IbK28KjUdN8ImADQNdWygO" 'True) (C1 ('MetaCons "CurrencySymbol" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCurrencySymbol") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString)))

mpsSymbol :: MintingPolicyHash -> CurrencySymbol Source #

The currency symbol of a monetay policy hash

currencyMPSHash :: CurrencySymbol -> MintingPolicyHash Source #

The minting policy hash of a currency symbol

Token names

newtype TokenName Source #

ByteString of a name of a token, shown as UTF-8 string when possible

Constructors

TokenName 

Instances

Instances details
Eq TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Data TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TokenName -> c TokenName Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TokenName Source #

toConstr :: TokenName -> Constr Source #

dataTypeOf :: TokenName -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TokenName) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenName) Source #

gmapT :: (forall b. Data b => b -> b) -> TokenName -> TokenName Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TokenName -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TokenName -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TokenName -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TokenName -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TokenName -> m TokenName Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TokenName -> m TokenName Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TokenName -> m TokenName Source #

Ord TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Show TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

IsString TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Generic TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Associated Types

type Rep TokenName :: Type -> Type Source #

Hashable TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToJSON TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromJSON TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

NFData TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

rnf :: TokenName -> () Source #

Pretty TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

pretty :: TokenName -> Doc ann Source #

prettyList :: [TokenName] -> Doc ann Source #

ToData TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromData TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

UnsafeFromData TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Ord TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Eq TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Serialise TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Lift DefaultUni TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Typeable DefaultUni TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep TokenName Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep TokenName = D1 ('MetaData "TokenName" "Plutus.V1.Ledger.Value" "plutus-ledger-api-0.1.0.0-IbK28KjUdN8ImADQNdWygO" 'True) (C1 ('MetaCons "TokenName" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTokenName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString)))

tokenName :: ByteString -> TokenName Source #

Creates TokenName from raw ByteString.

Asset classes

newtype AssetClass Source #

An asset class, identified by currency symbol and token name.

Constructors

AssetClass 

Instances

Instances details
Eq AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Data AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AssetClass -> c AssetClass Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AssetClass Source #

toConstr :: AssetClass -> Constr Source #

dataTypeOf :: AssetClass -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AssetClass) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AssetClass) Source #

gmapT :: (forall b. Data b => b -> b) -> AssetClass -> AssetClass Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AssetClass -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AssetClass -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> AssetClass -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AssetClass -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AssetClass -> m AssetClass Source #

Ord AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Show AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Generic AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Associated Types

type Rep AssetClass :: Type -> Type Source #

Hashable AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToJSON AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromJSON AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

NFData AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

rnf :: AssetClass -> () Source #

Pretty AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToData AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromData AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

UnsafeFromData AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Ord AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Eq AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Serialise AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Lift DefaultUni AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Typeable DefaultUni AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep AssetClass Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep AssetClass = D1 ('MetaData "AssetClass" "Plutus.V1.Ledger.Value" "plutus-ledger-api-0.1.0.0-IbK28KjUdN8ImADQNdWygO" 'True) (C1 ('MetaCons "AssetClass" 'PrefixI 'True) (S1 ('MetaSel ('Just "unAssetClass") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CurrencySymbol, TokenName))))

assetClassValue :: AssetClass -> Integer -> Value Source #

A Value containing the given amount of the asset class.

assetClassValueOf :: Value -> AssetClass -> Integer Source #

Get the quantity of the given AssetClass class in the Value.

Value

newtype Value Source #

A cryptocurrency value. This is a map from CurrencySymbols to a quantity of that currency.

Operations on currencies are usually implemented pointwise. That is, we apply the operation to the quantities for each currency in turn. So when we add two Values the resulting Value has, for each currency, the sum of the quantities of that particular currency in the argument Value. The effect of this is that the currencies in the Value are "independent", and are operated on separately.

Whenever we need to get the quantity of a currency in a Value where there is no explicit quantity of that currency in the Value, then the quantity is taken to be zero.

See note [Currencies] for more details.

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(==) :: Value -> Value -> Bool Source #

(/=) :: Value -> Value -> Bool Source #

Data Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value Source #

toConstr :: Value -> Constr Source #

dataTypeOf :: Value -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) Source #

gmapT :: (forall b. Data b => b -> b) -> Value -> Value Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

Show Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Generic Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Associated Types

type Rep Value :: Type -> Type Source #

Methods

from :: Value -> Rep Value x Source #

to :: Rep Value x -> Value Source #

Semigroup Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Monoid Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Hashable Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

ToJSON Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromJSON Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

NFData Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

rnf :: Value -> () Source #

Pretty Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

pretty :: Value -> Doc ann Source #

prettyList :: [Value] -> Doc ann Source #

ToData Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

FromData Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

UnsafeFromData Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

JoinSemiLattice Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(\/) :: Value -> Value -> Value Source #

MeetSemiLattice Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(/\) :: Value -> Value -> Value Source #

AdditiveSemigroup Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(+) :: Value -> Value -> Value Source #

AdditiveMonoid Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

zero :: Value Source #

AdditiveGroup Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(-) :: Value -> Value -> Value Source #

Monoid Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

mempty :: Value Source #

Group Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

inv :: Value -> Value Source #

Semigroup Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(<>) :: Value -> Value -> Value Source #

Eq Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

(==) :: Value -> Value -> Bool Source #

Serialise Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Module Integer Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Methods

scale :: Integer -> Value -> Value Source #

Lift DefaultUni Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

Typeable DefaultUni Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep Value Source # 
Instance details

Defined in Plutus.V1.Ledger.Value

type Rep Value = D1 ('MetaData "Value" "Plutus.V1.Ledger.Value" "plutus-ledger-api-0.1.0.0-IbK28KjUdN8ImADQNdWygO" 'True) (C1 ('MetaCons "Value" 'PrefixI 'True) (S1 ('MetaSel ('Just "getValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map CurrencySymbol (Map TokenName Integer)))))

singleton :: CurrencySymbol -> TokenName -> Integer -> Value Source #

Make a Value containing only the given quantity of the given currency.

valueOf :: Value -> CurrencySymbol -> TokenName -> Integer Source #

Get the quantity of the given currency in the Value.

scale :: Module s v => s -> v -> v Source #

Partial order operations

geq :: Value -> Value -> Bool Source #

Check whether one Value is greater than or equal to another. See Value for an explanation of how operations on Values work.

gt :: Value -> Value -> Bool Source #

Check whether one Value is strictly greater than another. See Value for an explanation of how operations on Values work.

leq :: Value -> Value -> Bool Source #

Check whether one Value is less than or equal to another. See Value for an explanation of how operations on Values work.

lt :: Value -> Value -> Bool Source #

Check whether one Value is strictly less than another. See Value for an explanation of how operations on Values work.

Etc.

isZero :: Value -> Bool Source #

Check whether a Value is zero.

split :: Value -> (Value, Value) Source #

Split a value into its positive and negative parts. The first element of the tuple contains the negative parts of the value, the second element contains the positive parts.

negate (fst (split a)) plus (snd (split a)) == a

flattenValue :: Value -> [(CurrencySymbol, TokenName, Integer)] Source #

Convert a value to a simple list, keeping only the non-zero amounts.

Orphan instances

(Hashable k, Hashable v) => Hashable (Map k v) Source # 
Instance details

Methods

hashWithSalt :: Int -> Map k v -> Int Source #

hash :: Map k v -> Int Source #

(ToJSON v, ToJSON k) => ToJSON (Map k v) Source # 
Instance details

(FromJSON v, FromJSON k) => FromJSON (Map k v) Source # 
Instance details

(Serialise k, Serialise v) => Serialise (Map k v) Source # 
Instance details