plutarch
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Builtin.Value

Description

Since: 1.14.0

Synopsis

Type

newtype PBuiltinValue (s :: S) Source #

A builtin Plutus Value.

Since: 1.14.0

Constructors

PBuiltinValue (Term s POpaque) 

Instances

Instances details
PIsData PBuiltinValue Source #

Since: 1.14.0

Instance details

Defined in Plutarch.Internal.IsData

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PBuiltinValue) -> Term s PBuiltinValue Source #

pdataImpl :: forall (s :: S). Term s PBuiltinValue -> Term s PData Source #

PLiftable PBuiltinValue Source # 
Instance details

Defined in Plutarch.Internal.Lift

PlutusType PBuiltinValue Source #

Since: 1.14.0

Instance details

Defined in Plutarch.Internal.PlutusType

Associated Types

type PInner PBuiltinValue :: S -> Type Source #

Methods

pcon' :: forall (s :: S). PBuiltinValue s -> Term s (PInner PBuiltinValue) Source #

pmatch' :: forall (s :: S) (b :: S -> Type). Term s (PInner PBuiltinValue) -> (PBuiltinValue s -> Term s b) -> Term s b Source #

Generic (PBuiltinValue s) Source # 
Instance details

Defined in Plutarch.Builtin.Value

Associated Types

type Rep (PBuiltinValue s) :: Type -> Type Source #

Generic (PBuiltinValue s) Source # 
Instance details

Defined in Plutarch.Builtin.Value

Associated Types

type Code (PBuiltinValue s) :: [[Type]]

Methods

from :: PBuiltinValue s -> Rep (PBuiltinValue s)

to :: Rep (PBuiltinValue s) -> PBuiltinValue s

type AsHaskell PBuiltinValue Source #

Since: 1.14.0

Instance details

Defined in Plutarch.Internal.Lift

type PlutusRepr PBuiltinValue Source # 
Instance details

Defined in Plutarch.Internal.Lift

type PInner PBuiltinValue Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

type Rep (PBuiltinValue s) Source #

Since: 1.14.0

Instance details

Defined in Plutarch.Builtin.Value

type Rep (PBuiltinValue s) = D1 ('MetaData "PBuiltinValue" "Plutarch.Builtin.Value" "plutarch-1.14.0-DxKJeQlSo9oLhPFmYEjfmO" 'True) (C1 ('MetaCons "PBuiltinValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s POpaque))))
type Code (PBuiltinValue s) Source #

Since: 1.14.0

Instance details

Defined in Plutarch.Builtin.Value

type Code (PBuiltinValue s) = GCode (PBuiltinValue s)

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 new PBuiltinValue will have the given currency-token name entry deleted;
  • If the argument PBuiltinValue is empty, the new PBuiltinValue will be a singleton containing the given currency-token name entry with the given (nonzero) amount.
  • If the argument PBuiltinValue already contains the given currency-token name entry, the new PBuiltinValue will have that currency-token name entry replaced with the given (nonzero) amount.
  • Otherwise, the new PBuiltinValue will 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 #

pvalueContains x y is true when, for any currency-token name entry in y, 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