Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cooked.Skeleton.Mint
Contents
Synopsis
- type TxSkelMints = Map (Versioned MintingPolicy) (TxSkelRedeemer, NEMap TokenName (NonZero Integer))
- addToTxSkelMints :: (Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer) -> TxSkelMints -> TxSkelMints
- txSkelMintsToList :: TxSkelMints -> [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)]
- txSkelMintsFromList :: [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)] -> TxSkelMints
- txSkelMintsFromList' :: [(Versioned MintingPolicy, TxSkelRedeemer, [(TokenName, Integer)])] -> 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
.
addToTxSkelMints :: (Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer) -> TxSkelMints -> 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.
If, for some reason, you really want to generate a TxSkelMints
that has
both a negative and a positive entry of the same asset class and redeemer,
you'll have to do so manually. Note, however, that even if you do so, NO
VALIDATOR OR MINTING POLICY WILL EVER GET TO SEE A TRANSACTION WITH SUCH
CONFLICTING INFORMATION. This is not a design decision/limitation of
cooked-validators: The Cardano API TxBodyContent
type, that we're
translating everything into eventually, stores minting information as a
minted value together with a map from policy IDs to witnesses (which
represent the used redeemers). That means that we can only store _one_
redeemer per minting policy, and no conflicting mints of the same asset
class, since they'll just cancel.
txSkelMintsToList :: TxSkelMints -> [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)] Source #
Convert from TxSkelMints
to a list of tuples describing eveything that's
being minted.
txSkelMintsFromList :: [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)] -> TxSkelMints Source #
Smart constructor for TxSkelMints
. This function relies on
addToTxSkelMints
. So, some non-empty lists (where all amounts for a given
asset class an redeemer add up to zero) might be translated into the empty
TxSkelMints
.
txSkelMintsFromList' :: [(Versioned MintingPolicy, TxSkelRedeemer, [(TokenName, Integer)])] -> TxSkelMints Source #
Another smart constructor for TxSkelMints
, where the redeemer and minting
policies are not duplicated.
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 # |