Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cooked.Skeleton.Mint
Contents
Description
This module exposes the minting constructs used in a
TxSkel
and their associated utilities.
Synopsis
- type TxSkelMints = Map (Versioned MintingPolicy) (TxSkelRedeemer, NEMap TokenName (NonZero Integer))
- data Mint where
- Mint :: ToVersioned MintingPolicy a => {..} -> Mint
- mintRedeemerL :: Lens' Mint TxSkelRedeemer
- mintTokensL :: Lens' Mint [(TokenName, Integer)]
- mint :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint
- burn :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint
- txSkelMintsValueG :: Getter TxSkelMints Value
- txSkelMintsListI :: Iso' TxSkelMints [Mint]
- mintVersionedScriptL :: Lens' Mint (Versioned Script)
- txSkelMintsAssetClassAmountL :: ToVersioned MintingPolicy mp => mp -> TokenName -> Lens' TxSkelMints (Maybe TxSkelRedeemer, Integer)
- txSkelMintsFromList :: [Mint] -> TxSkelMints
- txSkelMintsValue :: TxSkelMints -> Value
Documentation
type TxSkelMints = Map (Versioned MintingPolicy) (TxSkelRedeemer, NEMap TokenName (NonZero Integer)) 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.
You'll probably not construct this by hand, but use txSkelMintsFromList
.
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 # |
mintRedeemerL :: Lens' Mint TxSkelRedeemer 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
mint :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint Source #
Builds some Mint
when a single type of token is minted for a given MP
burn :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint Source #
Similar to mint
but deducing the tokens instead
txSkelMintsValueG :: Getter TxSkelMints Value Source #
The value described by a TxSkelMints
txSkelMintsListI :: Iso' TxSkelMints [Mint] Source #
Seeing a TxSkelMints
as a list of Mint
mintVersionedScriptL :: Lens' Mint (Versioned Script) Source #
A lens to set or get the versioned script of a Mint
txSkelMintsAssetClassAmountL :: ToVersioned MintingPolicy 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
.
txSkelMintsFromList :: [Mint] -> TxSkelMints Source #
This builds a TxSkelMints
from a list of Mint
, which should be the main
way of declaring minted values in a TxSkel
.
txSkelMintsValue :: TxSkelMints -> Value Source #
This retrieves the Value
from a TxSkelMints
Orphan instances
Monoid TxSkelMints Source # | |
Methods mempty :: TxSkelMints # mappend :: TxSkelMints -> TxSkelMints -> TxSkelMints # mconcat :: [TxSkelMints] -> TxSkelMints # | |
Semigroup TxSkelMints Source # | Combining Map.fromList [(pol, (red, NEMap.fromList [(tName, 1)]))] and Map.fromList [(pol, (red', NEMap.fromList [(tName, -1)]))] will combine to become the empty In every case, if you add mints with a different redeemer for the same policy, the redeemer used in the right argument takes precedence. |
Methods (<>) :: TxSkelMints -> TxSkelMints -> TxSkelMints # sconcat :: NonEmpty TxSkelMints -> TxSkelMints # stimes :: Integral b => b -> TxSkelMints -> TxSkelMints # |