Handling Cardano values.
Empty [Value] with 0 ada and no token.
Create a [Value] just containing Ada lovelaces.
Create a [Value] just from some token amount.
Add the values of two UTxOs together.
Add some tokens to another [Value].
subtract the second value from the first one: (v1 - v2).
It’s a saturating difference, so if the second value is bigger than the first, the difference is clamped to 0.
The resulting [Value] is not normalized by default. So the result may contain assets with 0 amounts. To remove all 0 amount assets, call [normalize] on the substraction result.
Check that some value contains at least some minimum value.
onlyLovelace Natural.two
|> atLeast (onlyLovelace Natural.one)
--> True
Sum the values of all tokens.
Remove 0 amounts in non-ada assets.
Compare by amount of a given token.
CBOR encoder for [Value].
CBOR decoder for [Value].
Helper function to display a Value
.
A multi-asset output Value. Contains tokens indexed by policy id and asset name.
This type maintains some invariants by construction. In particular, a Value will never contain a zero quantity of a particular token.
TODO: make sure the previous statement stays true by construction. That would require an opaque type and some property tests.