Cardano.MultiAsset

Handling multi-asset values.

type alias MultiAsset int =
BytesMap PolicyId (BytesMap AssetName int)

Type alias for handling multi-asset values.

This type should maintain some invariants by construction. In particular, it should never contain a zero quantity of a particular token.

TODO: make sure the previous statement stays true by construction. This would require an opaque type for MultiAsset.

Phantom type for 28-bytes policy id. This is a Blacke2b-224 hash.

Phantom type for asset names. This is a free-form bytes array of length <= 32 bytes.

isEmpty : MultiAsset a -> Bool

Check if the [MultiAsset] contains no token.

get : Bytes PolicyId -> Bytes AssetName -> MultiAsset a -> Maybe a

Retrieve the amount of a given token.

empty : MultiAsset a

Create an empty [MultiAsset].

onlyToken : Bytes PolicyId -> Bytes AssetName -> int -> MultiAsset int

Create a singleton [MultiAsset].

normalize : (int -> Bool) -> MultiAsset int -> MultiAsset int

Remove assets with 0 amounts.

mintAdd : MultiAsset Integer -> MultiAsset Integer -> MultiAsset Integer

Add together two mint values.

-> { minted : BytesMap AssetName Natural
, burned : BytesMap AssetName Natural
}

Compute a mint balance.

map2 : (a -> a -> b) -> a -> MultiAsset a -> MultiAsset a -> MultiAsset b

Apply a function for each token pair of two [MultiAsset]. Absent tokens in one [MultiAsset] are replaced by the default value.

split : MultiAsset a -> List ( Bytes PolicyId, Bytes AssetName, a )

Split a [MultiAsset] into a list of each individual asset (policyId, assetName, amount).

coinsToCbor : MultiAsset Natural -> Encoder

CBOR encoder for [MultiAsset] coins.

mintToCbor : MultiAsset Integer -> Encoder

CBOR encoder for [MultiAsset] mints.

coinsFromCbor : Decoder (MultiAsset Natural)

CBOR decoder for [MultiAsset] coins.

mintFromCbor : Decoder (MultiAsset Integer)

CBOR decoder for [MultiAsset] mints.

toMultilineString : (a -> String) -> MultiAsset a -> List String

Helper function to display MultiAsset.