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
- mint :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint
- burn :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint
- addMint :: TxSkelMints -> Mint -> TxSkelMints
- addMints :: TxSkelMints -> [Mint] -> TxSkelMints
- txSkelMintsToList :: TxSkelMints -> [Mint]
- 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.Cooked Methods prettyCooked :: Mint -> DocCooked Source # prettyCookedOpt :: PrettyCookedOpts -> Mint -> DocCooked Source # |
mint :: ToVersioned MintingPolicy a => a -> TxSkelRedeemer -> TokenName -> Integer -> Mint Source #
Additional helper to build some Mint
in the usual minting case where 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
addMint :: TxSkelMints -> Mint -> TxSkelMints Source #
Add a new entry to a TxSkelMints
. There are a few wrinkles:
- If for a given policy, redeemer, and token name, there are
n
tokens in the argumentTxSkelMints
, and you add-n
tokens, the corresponding entry in the "inner map" of the policy will disappear (obviously, because all of its values have to be non-zero). If that also means that the inner map becomes empty, the policy will disappear from theTxSkelMints
altogether. - If a policy is already present on the argument
TxSkelMints
with a redeemera
, and you add a mint with a different redeemerb
, the old redeemer is thrown away. The values associated with the token names of that policy are added as described above, though. This means that any pre-existing values will be minted with a new redeemer.
addMints :: TxSkelMints -> [Mint] -> TxSkelMints Source #
Adds a list of Mint
to a TxSkelMints
, by iterating over the list
and using addMint
txSkelMintsToList :: TxSkelMints -> [Mint] Source #
Convert from TxSkelMints
to a list of Mint
txSkelMintsFromList :: [Mint] -> TxSkelMints Source #
A smart constructor for TxSkelMints
txSkelMintsValue :: TxSkelMints -> Value Source #
The value described by 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 # |