| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Plutarch.Builtin.Value
Description
Since: 1.14.0
Synopsis
- newtype PBuiltinValue (s :: S) = PBuiltinValue (Term s POpaque)
- pinsertCoin :: forall (s :: S). Term s (PByteString :--> (PByteString :--> (PInteger :--> (PBuiltinValue :--> PBuiltinValue))))
- plookupCoin :: forall (s :: S). Term s (PByteString :--> (PByteString :--> (PBuiltinValue :--> PInteger)))
- punionValue :: forall (s :: S). Term s (PBuiltinValue :--> (PBuiltinValue :--> PBuiltinValue))
- pvalueContains :: forall (s :: S). Term s (PBuiltinValue :--> (PBuiltinValue :--> PBool))
- pvalueData :: forall (s :: S). Term s (PBuiltinValue :--> PData)
- punValueData :: forall (s :: S). Term s (PData :--> PBuiltinValue)
- pscaleValue :: forall (s :: S). Term s (PInteger :--> (PBuiltinValue :--> PBuiltinValue))
Type
newtype PBuiltinValue (s :: S) Source #
A builtin Plutus Value.
Since: 1.14.0
Constructors
| PBuiltinValue (Term s POpaque) |
Instances
Functions
pinsertCoin :: forall (s :: S). Term s (PByteString :--> (PByteString :--> (PInteger :--> (PBuiltinValue :--> PBuiltinValue)))) Source #
Given a currency, a token name, an amount, an an existing PBuiltinValue,
produce a new PBuiltinValue, identical to the argument PBuiltinValue,
except as follows:
- If the amount is
0, the newPBuiltinValuewill have the given currency-token name entry deleted; - If the argument
PBuiltinValueis empty, the newPBuiltinValuewill be a singleton containing the given currency-token name entry with the given (nonzero) amount. - If the argument
PBuiltinValuealready contains the given currency-token name entry, the newPBuiltinValuewill have that currency-token name entry replaced with the given (nonzero) amount. - Otherwise, the new
PBuiltinValuewill contain a new currency-token name entry, with the given (nonzero) amount.
Important note
If given a currency name, or a token name, that isn't valid, this will error.
Since: 1.14.0
plookupCoin :: forall (s :: S). Term s (PByteString :--> (PByteString :--> (PBuiltinValue :--> PInteger))) Source #
Given a currency, a token name, and a PBuiltinValue, return the amount
associated with the given currency-token name entry. If there is no such
entry, the result is 0.
Important note
If given a currency name, or token name, that isn't valid, this will produce
0.
Since: 1.14.0
punionValue :: forall (s :: S). Term s (PBuiltinValue :--> (PBuiltinValue :--> PBuiltinValue)) Source #
Given two PBuiltinValues, constructs their union. More specifically, for
every currency-token name entry in either argument, the result will contain a
currency-token name entry as well. If the entry is in one argument, it will
be copied as-is; otherwise, the amounts will be combined from both maps using
addition.
Important note
PBuiltinValues cannot store amounts outside of the range of a 128-bit
signed integer. If any amount produced by this operation would fall outside
of this range, this function will error.
Since: 1.14.0
pvalueContains :: forall (s :: S). Term s (PBuiltinValue :--> (PBuiltinValue :--> PBool)) Source #
is true when, for any currency-token name entry in
pvalueContains x yy, the amount associated with that entry in x is not smaller.
Important note
Neither argument can contain any negative entries. If either argument has a negative entry, this will error.
Since: 1.14.0
pvalueData :: forall (s :: S). Term s (PBuiltinValue :--> PData) Source #
Converts a PBuiltinValue into its Data encoding.
Since: 1.14.0
punValueData :: forall (s :: S). Term s (PData :--> PBuiltinValue) Source #
Converts a valid Data encoding of a PBuiltinValue into the
PBuiltinValue it represents, and errors otherwise.
Since: 1.14.0
pscaleValue :: forall (s :: S). Term s (PInteger :--> (PBuiltinValue :--> PBuiltinValue)) Source #
Given a PBuiltinValue and a scalar, produce a new PBuiltinValue with
all amounts multiplied by that scalar. Note that if the scalar is 0, then
the result will be an empty PBuiltinValue.
Since: 1.14.0