cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

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 types

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

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

Instances details
Monoid DoubleSatDelta Source # 
Instance details

Defined in Cooked.Attack.DoubleSat

Monoid TxSkelMints Source # 
Instance details

Defined in Cooked.Skeleton.Mint

Semigroup DoubleSatDelta Source # 
Instance details

Defined in Cooked.Attack.DoubleSat

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

Defined in Cooked.Skeleton.Mint

Show TxSkelMints Source # 
Instance details

Defined in Cooked.Skeleton.Mint

Eq TxSkelMints Source # 
Instance details

Defined in Cooked.Skeleton.Mint

ToValue TxSkelMints Source # 
Instance details

Defined in Cooked.Skeleton.Mint

Methods

toValue :: TxSkelMints -> Value #

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

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

Orphan instances

IsString TokenName Source #

Conveniency instance to be able to use Strings as TokenName, which used to be present in plutus-ledger-api.

Instance details