Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbabb1d
commit d659990
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
-- Prevent unboxing, which the plugin can't deal with | ||
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-} | ||
{-# OPTIONS_GHC -fno-spec-constr #-} | ||
{-# OPTIONS_GHC -fno-specialise #-} | ||
|
||
-- | Functions for working with 'Value'. | ||
module Plutus.V2.Ledger.Value( | ||
-- ** Currency symbols | ||
CurrencySymbol(..) | ||
, currencySymbol | ||
, mpsSymbol | ||
, currencyMPSHash | ||
-- ** Token names | ||
, TokenName(..) | ||
, tokenName | ||
, toString | ||
-- * Asset classes | ||
, AssetClass(..) | ||
, assetClass | ||
, assetClassValue | ||
, assetClassValueOf | ||
-- ** Value | ||
, Value(..) | ||
, singleton | ||
, valueOf | ||
, currencyValueOf | ||
, scale | ||
, symbols | ||
-- * Partial order operations | ||
, geq | ||
, gt | ||
, leq | ||
, lt | ||
-- * Etc. | ||
, isZero | ||
, split | ||
, unionWith | ||
, flattenValue | ||
) where | ||
|
||
import Plutus.V1.Ledger.Value | ||
import PlutusTx.AssocMap qualified as Map | ||
import PlutusTx.Maybe | ||
import PlutusTx.Monoid | ||
|
||
{-# INLINABLE currencyValueOf #-} | ||
-- | Get the quantities of just the given 'CurrencySymbol' in the 'Value'. | ||
currencyValueOf :: Value -> CurrencySymbol -> Value | ||
currencyValueOf (Value m) c = case Map.lookup c m of | ||
Nothing -> mempty | ||
Just t -> Value (Map.singleton c t) |