| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
PlutusLedgerApi.V1.Data.Value
Description
Functions for working with Value.
Synopsis
- newtype CurrencySymbol = CurrencySymbol {}
- currencySymbol :: ByteString -> CurrencySymbol
- adaSymbol :: CurrencySymbol
- newtype TokenName = TokenName {}
- tokenName :: ByteString -> TokenName
- toString :: TokenName -> String
- adaToken :: TokenName
- newtype AssetClass = AssetClass {}
- assetClass :: CurrencySymbol -> TokenName -> AssetClass
- assetClassValue :: AssetClass -> Integer -> Value
- assetClassValueOf :: Value -> AssetClass -> Integer
- newtype Value = Value {}
- singleton :: CurrencySymbol -> TokenName -> Integer -> Value
- valueOf :: Value -> CurrencySymbol -> TokenName -> Integer
- withCurrencySymbol :: CurrencySymbol -> Value -> a -> (Map TokenName Integer -> a) -> a
- currencySymbolValueOf :: Value -> CurrencySymbol -> Integer
- lovelaceValue :: Lovelace -> Value
- lovelaceValueOf :: Value -> Lovelace
- scale :: Module s v => s -> v -> v
- symbols :: Value -> List CurrencySymbol
- geq :: Value -> Value -> Bool
- gt :: Value -> Value -> Bool
- leq :: Value -> Value -> Bool
- lt :: Value -> Value -> Bool
- isZero :: Value -> Bool
- split :: Value -> (Value, Value)
- unionWith :: (Integer -> Integer -> Integer) -> Value -> Value -> Value
- flattenValue :: Value -> [(CurrencySymbol, TokenName, Integer)]
- newtype Lovelace = Lovelace {}
Currency symbols
newtype CurrencySymbol Source #
ByteString representing the currency, hashed with BLAKE2b-224.
It is empty for Ada, 28 bytes for MintingPolicyHash.
Forms an AssetClass along with TokenName.
A Value is a map from CurrencySymbol's to a map from TokenName to an Integer.
This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification. -- editorconfig-checker-disable-file
Constructors
| CurrencySymbol | |
Fields | |
Instances
currencySymbol :: ByteString -> CurrencySymbol Source #
Creates CurrencySymbol from raw ByteString.
adaSymbol :: CurrencySymbol Source #
The CurrencySymbol of the Ada currency.
Token names
ByteString of a name of a token.
Shown as hex-encoded bytes.
Should be no longer than 32 bytes, empty for Ada.
Forms an AssetClass along with a CurrencySymbol.
This is a simple type without any validation, use with caution. You may want to add checks for its invariants. See the Shelley ledger specification. -- editorconfig-checker-disable-file
Constructors
| TokenName | |
Fields | |
Instances
| Data TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.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 # | |||||
| IsString TokenName Source # | UTF-8 encoding. Doesn't verify length. | ||||
Defined in PlutusLedgerApi.V1.Data.Value Methods fromString :: String -> TokenName Source # | |||||
| Generic TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
| |||||
| Show TokenName Source # | |||||
| NFData TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Eq TokenName Source # | |||||
| Ord TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| HasBlueprintDefinition TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
Methods definitionId :: DefinitionId | |||||
| Eq TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| FromData TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| ToData TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods toBuiltinData :: TokenName -> BuiltinData # | |||||
| UnsafeFromData TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| Ord TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Pretty TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| HasBlueprintSchema TokenName referencedTypes Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods schema :: Schema referencedTypes | |||||
| Lift DefaultUni TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Typeable DefaultUni TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| type Rep TokenName Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value type Rep TokenName = D1 ('MetaData "TokenName" "PlutusLedgerApi.V1.Data.Value" "plutus-ledger-api-1.60.0.0-G1HmqwHNllaA7AnJNjAfhP" 'True) (C1 ('MetaCons "TokenName" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTokenName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString))) | |||||
| type Unroll TokenName Source # | |||||
tokenName :: ByteString -> TokenName Source #
Creates TokenName from raw ByteString.
toString :: TokenName -> String Source #
Turn a TokenName to a UTF-8 string when possible, or a hex 0x-prefixed string otherwise.
Asset classes
newtype AssetClass Source #
An asset class, identified by a CurrencySymbol and a TokenName.
Constructors
| AssetClass | |
Fields | |
Instances
| Data AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.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 # | |||||
| Generic AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
| |||||
| Show AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| NFData AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods rnf :: AssetClass -> () Source # | |||||
| Eq AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods (==) :: AssetClass -> AssetClass -> Bool Source # (/=) :: AssetClass -> AssetClass -> Bool Source # | |||||
| Ord AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods compare :: AssetClass -> AssetClass -> Ordering Source # (<) :: AssetClass -> AssetClass -> Bool Source # (<=) :: AssetClass -> AssetClass -> Bool Source # (>) :: AssetClass -> AssetClass -> Bool Source # (>=) :: AssetClass -> AssetClass -> Bool Source # max :: AssetClass -> AssetClass -> AssetClass Source # min :: AssetClass -> AssetClass -> AssetClass Source # | |||||
| HasBlueprintDefinition AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
Methods definitionId :: DefinitionId | |||||
| Eq AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods (==) :: AssetClass -> AssetClass -> Bool | |||||
| FromData AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| ToData AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods toBuiltinData :: AssetClass -> BuiltinData # | |||||
| UnsafeFromData AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| Ord AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods compare :: AssetClass -> AssetClass -> Ordering (<) :: AssetClass -> AssetClass -> Bool (<=) :: AssetClass -> AssetClass -> Bool (>) :: AssetClass -> AssetClass -> Bool (>=) :: AssetClass -> AssetClass -> Bool max :: AssetClass -> AssetClass -> AssetClass min :: AssetClass -> AssetClass -> AssetClass | |||||
| Pretty AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| HasBlueprintSchema AssetClass referencedTypes Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods schema :: Schema referencedTypes | |||||
| Lift DefaultUni AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods lift :: AssetClass -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) | |||||
| Typeable DefaultUni AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods typeRep :: Proxy AssetClass -> RTCompile DefaultUni fun (Type TyName DefaultUni ()) | |||||
| type Rep AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value type Rep AssetClass = D1 ('MetaData "AssetClass" "PlutusLedgerApi.V1.Data.Value" "plutus-ledger-api-1.60.0.0-G1HmqwHNllaA7AnJNjAfhP" 'True) (C1 ('MetaCons "AssetClass" 'PrefixI 'True) (S1 ('MetaSel ('Just "unAssetClass") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (CurrencySymbol, TokenName)))) | |||||
| type Unroll AssetClass Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value type Unroll AssetClass = Insert AssetClass (GUnroll (IfStuckRep (RepIsStuckError AssetClass :: Type -> Type) (Rep AssetClass))) | |||||
assetClass :: CurrencySymbol -> TokenName -> AssetClass Source #
The curried version of AssetClass constructor
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
The Value type represents a collection of amounts of different currencies.
We can think of Value as a vector space whose dimensions are currencies.
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.
There is no 'Ord Value' instance since Value is only a partial order, so compare can't
do the right thing in some cases.
Instances
| Monoid Value Source # | |||||
| Semigroup Value Source # | |||||
| Generic Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
| |||||
| Show Value Source # | |||||
| Eq Value Source # | |||||
| HasBlueprintDefinition Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
Methods definitionId :: DefinitionId | |||||
| Eq Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| FromData Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods fromBuiltinData :: BuiltinData -> Maybe Value # | |||||
| ToData Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods toBuiltinData :: Value -> BuiltinData # | |||||
| UnsafeFromData Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| JoinSemiLattice Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| MeetSemiLattice Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Group Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Monoid Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| AdditiveGroup Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| AdditiveMonoid Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| AdditiveSemigroup Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Semigroup Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Pretty Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| HasBlueprintSchema Value referencedTypes Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods schema :: Schema referencedTypes | |||||
| Lift DefaultUni Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Module Integer Value Source # | |||||
| Typeable DefaultUni Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| type Rep Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value type Rep Value = D1 ('MetaData "Value" "PlutusLedgerApi.V1.Data.Value" "plutus-ledger-api-1.60.0.0-G1HmqwHNllaA7AnJNjAfhP" 'True) (C1 ('MetaCons "Value" 'PrefixI 'True) (S1 ('MetaSel ('Just "getValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map CurrencySymbol (Map TokenName Integer))))) | |||||
| type Unroll Value Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
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.
Assumes that the underlying map doesn't contain duplicate keys.
withCurrencySymbol :: CurrencySymbol -> Value -> a -> (Map TokenName Integer -> a) -> a Source #
Apply a continuation function to the token quantities of the given currency symbol in the value or return a default value if the currency symbol is not present in the value.
currencySymbolValueOf :: Value -> CurrencySymbol -> Integer Source #
Get the total value of the currency symbol in the Value map.
Assumes that the underlying map doesn't contain duplicate keys.
Note that each token of the currency symbol may have a value that is positive, zero or negative.
symbols :: Value -> List CurrencySymbol Source #
The list of CurrencySymbols of a Value.
Partial order operations
gt :: Value -> Value -> Bool Source #
Check whether one Value is strictly greater than another.
This is *not* a pointwise operation. gt l r means geq l r && not (eq l r).
lt :: Value -> Value -> Bool Source #
Check whether one Value is strictly less than another.
This is *not* a pointwise operation. lt l r means leq l r && not (eq l r).
Etc.
unionWith :: (Integer -> Integer -> Integer) -> Value -> Value -> Value Source #
Combine two Value maps with the argument function.
Assumes the well-definedness of the two maps.
flattenValue :: Value -> [(CurrencySymbol, TokenName, Integer)] Source #
Constructors
| Lovelace | |
Fields | |
Instances
| Enum Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods succ :: Lovelace -> Lovelace Source # pred :: Lovelace -> Lovelace Source # toEnum :: Int -> Lovelace Source # fromEnum :: Lovelace -> Int Source # enumFrom :: Lovelace -> [Lovelace] Source # enumFromThen :: Lovelace -> Lovelace -> [Lovelace] Source # enumFromTo :: Lovelace -> Lovelace -> [Lovelace] Source # enumFromThenTo :: Lovelace -> Lovelace -> Lovelace -> [Lovelace] Source # | |||||
| Generic Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
| |||||
| Num Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods (+) :: Lovelace -> Lovelace -> Lovelace Source # (-) :: Lovelace -> Lovelace -> Lovelace Source # (*) :: Lovelace -> Lovelace -> Lovelace Source # negate :: Lovelace -> Lovelace Source # abs :: Lovelace -> Lovelace Source # signum :: Lovelace -> Lovelace Source # fromInteger :: Integer -> Lovelace Source # | |||||
| Real Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods toRational :: Lovelace -> Rational Source # | |||||
| Show Lovelace Source # | |||||
| Eq Lovelace Source # | |||||
| Ord Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| HasBlueprintDefinition Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Associated Types
Methods definitionId :: DefinitionId | |||||
| Eq Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| FromData Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods fromBuiltinData :: BuiltinData -> Maybe Lovelace # | |||||
| ToData Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods toBuiltinData :: Lovelace -> BuiltinData # | |||||
| UnsafeFromData Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value Methods | |||||
| AdditiveGroup Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| AdditiveMonoid Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| AdditiveSemigroup Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Ord Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Show Lovelace Source # | |||||
| Pretty Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Lift DefaultUni Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| Typeable DefaultUni Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| type Rep Lovelace Source # | |||||
Defined in PlutusLedgerApi.V1.Data.Value | |||||
| type Unroll Lovelace Source # | |||||