| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Encoding.Collections
Description
Standalone CBOR for native collection shapes. Association lists retain explicit zero and repeated keys, unlike normalized asset bundles. All codecs sort stably by encoded key byte length then lexicographic bytes. Equal keys keep their relative order. These are semantic encodings, not original bytes.
import qualified Cometa.Encoding.Collections as Collections emptyWithdrawals = Collections.encodeWithdrawalsCbor []
Synopsis
- encodeAssetNamesCbor :: [(AssetName, Integer)] -> Either Error ByteString
- decodeAssetNamesCbor :: ByteString -> Either Error [(AssetName, Integer)]
- encodeWithdrawalsCbor :: [(RewardAddress, Word64)] -> ByteString
- decodeWithdrawalsCbor :: ByteString -> Either Error [(RewardAddress, Word64)]
- encodeHashesCbor :: [Blake2bHash] -> ByteString
- encodeHashesCborWith :: SetEncoding -> [Blake2bHash] -> ByteString
- decodeHashesCbor :: ByteString -> Either Error [Blake2bHash]
Documentation
encodeAssetNamesCbor :: [(AssetName, Integer)] -> Either Error ByteString Source #
Encode one policy's asset-name quantities. Zero and duplicate entries are
retained, including empty names. Quantities must fit signed 64 bits;
otherwise return InvalidValueQuantity. Empty input encodes an empty map.
decodeAssetNamesCbor :: ByteString -> Either Error [(AssetName, Integer)] Source #
Decode a complete definite or indefinite asset-name map, retaining zero and
duplicate entries. Names must contain at most 32 bytes and quantities must fit
signed 64 bits. Malformed maps return InvalidValueCbor.
encodeWithdrawalsCbor :: [(RewardAddress, Word64)] -> ByteString Source #
Encode reward accounts and unsigned lovelace amounts. Zero and duplicate entries are retained; empty input is an empty map, not absent withdrawals. Amounts span the full unsigned 64-bit range, independent of builder limits.
decodeWithdrawalsCbor :: ByteString -> Either Error [(RewardAddress, Word64)] Source #
Decode a complete definite or indefinite withdrawal map, including empty
maps, zero and duplicate entries. Keys must be exact reward-account bytes;
negative or oversized amounts and malformed keys return InvalidTransactionCbor.
encodeHashesCbor :: [Blake2bHash] -> ByteString Source #
Encode variable-length nonempty digests as a tag-258 array. Despite the native name “hash set”, duplicate digests are retained. Empty input is valid.
encodeHashesCborWith :: SetEncoding -> [Blake2bHash] -> ByteString Source #
Choose whether a freshly encoded digest array carries tag 258. Ordering
and duplicate retention match encodeHashesCbor.
decodeHashesCbor :: ByteString -> Either Error [Blake2bHash] Source #
Decode a complete definite or indefinite digest array, optionally tagged
258. Each digest must be a definite-length nonempty byte string, matching
the native hash reader; hash lengths may differ. Duplicate hashes
survive decoding. Wrong tags, empty hashes and malformed input return
InvalidHashCbor. The tag is not retained by this semantic decoder.