| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.Skeleton.Mint
Description
This module exposes the minting constructs used in a
TxSkel and their associated utilities. To mint or burn
tokens in a skeleton, the usual way is to invoke txSkelMints =
txSkelMintsFromList [mint script redeemer token quantity, burn ...]
Synopsis
- data Mint where
- data TxSkelMints
- mintRedeemedScriptL :: Lens' Mint (User 'IsScript 'Redemption)
- mintTokensL :: Lens' Mint [(TokenName, Integer)]
- mintCurrencySymbolG :: Getter Mint CurrencySymbol
- txSkelMintsListI :: Iso' TxSkelMints [Mint]
- txSkelMintsAssetClassAmountL :: (ToVScript mp, Typeable mp) => mp -> TokenName -> Lens' TxSkelMints (Maybe TxSkelRedeemer, Integer)
- txSkelMintsAssetClassesG :: Getter TxSkelMints [(VScript, TokenName)]
- txSkelMintsPolicyTokensL :: (ToVScript mp, Typeable mp) => mp -> Lens' TxSkelMints (Maybe (TxSkelRedeemer, Map TokenName Integer))
- mint :: (ToVScript script, Typeable script, RedeemerConstrs red) => script -> red -> TokenName -> Integer -> Mint
- burn :: (ToVScript script, Typeable script, RedeemerConstrs red) => script -> red -> TokenName -> Integer -> Mint
- txSkelMintsFromList :: [Mint] -> TxSkelMints
Data types
A description of a new entry to be added in a TxSkelMints. The users
should be using lists of those (using txSkelMintsFromList) instead of
building a TxSkelMints directly.
Constructors
| Mint | |
Fields
| |
Instances
| PrettyCooked Mint Source # | Prints a minting specification Example: > #abcdef - Redeemer: red - Reference script at: txOutRef - Foo: 500 - Bar: 1000 |
Defined in Cooked.Pretty.Skeleton Methods prettyCookedOpt :: PrettyCookedOpts -> Mint -> DocCooked Source # prettyCooked :: Mint -> DocCooked Source # | |
data TxSkelMints Source #
A description of what a transaction mints. For every policy, there can only
be one TxSkelRedeemer, and if there is, there must be some token names, each
with a non-zero amount of tokens. This invariant is guaranteed because the
raw constructor is not exposed, and functions working around it preserve it.
To build a TxSkelMints, use txSkelMintsFromList.
Instances
Optics
mintRedeemedScriptL :: Lens' Mint (User 'IsScript 'Redemption) Source #
A lens to set or get the redeemer of a Mint
mintTokensL :: Lens' Mint [(TokenName, Integer)] Source #
A lens to set or get the token list of a Mint
mintCurrencySymbolG :: Getter Mint CurrencySymbol Source #
Returns the currency symbol associated with a Mint
txSkelMintsListI :: Iso' TxSkelMints [Mint] Source #
Seeing a TxSkelMints as a list of Mint
txSkelMintsAssetClassAmountL :: (ToVScript mp, Typeable mp) => mp -> TokenName -> Lens' TxSkelMints (Maybe TxSkelRedeemer, Integer) Source #
Sets or gets the amount of tokens minted for a certain asset class,
represented by a token name and a versioned minting policy. This removes the
appropriate entries (the token entry, and possible the mp entry if it would
leave it empty) when setting the amount to 0. This function is very similar
to valueAssetClassAmountL but it also involves the
TxSkelRedeemer associated with the minting policy.
This Lens is quite involved and is the main way to build TxSkelMints
iteratively from a list of Mint (see txSkelMintsListI). If you're looking
for simpler optics working in a TxSkelMints, consider using ix mp % _1
for instance to modify an existing redeemer, or ix mp % _2 % ix tk to
modify a token amount. Another option is to use the optics working on Mint
and combining them with txSkelMintsListI.
txSkelMintsAssetClassesG :: Getter TxSkelMints [(VScript, TokenName)] Source #
The list of assets classes contained in this TxSkelMints
txSkelMintsPolicyTokensL :: (ToVScript mp, Typeable mp) => mp -> Lens' TxSkelMints (Maybe (TxSkelRedeemer, Map TokenName Integer)) Source #
Focuses on the submap for a given minting policy, following the same rules
as txSkelMintsAssetClassAmountL when setting a new submap.
Smart constructors
mint :: (ToVScript script, Typeable script, RedeemerConstrs red) => script -> red -> TokenName -> Integer -> Mint Source #
Builds some Mint when a single type of token is minted for a given MP
burn :: (ToVScript script, Typeable script, RedeemerConstrs red) => script -> red -> TokenName -> Integer -> Mint Source #
Similar to mint but deducing the tokens instead
txSkelMintsFromList :: [Mint] -> TxSkelMints Source #
Builds a TxSkelMints from a list of Mint. This is equivalent to calling
review txSkelMintsListI