cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Skeleton.Mint

Description

This module exposes the minting constructs used in a TxSkel and their associated utilities.

Synopsis

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.

data Mint where Source #

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

Instances details
PrettyCooked Mint Source #

Prints a minting specification

Example: > #abcdef - Redeemer: red - Reference script at: txOutRef - Foo: 500 - Bar: 1000

Instance details

Defined in Cooked.Pretty.Skeleton

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

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 # 
Instance details

Semigroup TxSkelMints Source #

Combining TxSkelMints in a sensible way. In particular, this means that

Map.fromList [(pol, (red, NEMap.fromList [(tName, 1)]))]

and

Map.fromList [(pol, (red', NEMap.fromList [(tName, -1)]))]

will combine to become the empty TxSkelMints

In every case, if you add mints with a different redeemer for the same policy, the redeemer used in the right argument takes precedence.

Instance details