atlas-cardano
Copyright(c) 2024 GYELD GMBH
LicenseApache 2.0
Maintainer[email protected]
Stabilitydevelop
Safe HaskellNone
LanguageGHC2021

GeniusYield.Types.TxMetadata

Description

Transaction metadata types and functions for working with transaction metadata.

Synopsis

Documentation

constructTxMetadataNumber :: Integer -> Maybe GYTxMetadataValue #

Construct a GYTxMetadataValue from an Integer. Returning Nothing if the given Integer is not in the range -(2^64-1) .. 2^64-1.

constructTxMetadataBytes :: ByteString -> Maybe GYTxMetadataValue #

Construct a GYTxMetadataValue from a ByteString. Returning Nothing if the given ByteString is longer than 64 bytes.

constructTxMetadataText :: Text -> Maybe GYTxMetadataValue #

Construct a GYTxMetadataValue from a Text. Returning Nothing if the given Text is longer than 64 bytes when UTF-8 encoded.

constructTxMetadataBytesChunks :: ByteString -> GYTxMetadataValue #

Construct a GYTxMetadataValue from a ByteString as a list of chunks (bytestrings) of acceptable sizes, splitting at 64th byte as maximum length allowed is 64 bytes.

constructTxMetadataTextChunks :: Text -> GYTxMetadataValue #

Construct a GYTxMetadataValue from a Text as a list of chunks (strings) of acceptable sizes. Note that maximum length allowed is 64 bytes, when given string is UTF-8 encoded. Splitting is slightly involved here as single character (in a text string) may be represented by multiple bytes in UTF-8 encoding, and hence, we split if adding the byte representation of the char exceeds the 64 byte limit.

mergeTxMetadata :: (GYTxMetadataValue -> GYTxMetadataValue -> GYTxMetadataValue) -> GYTxMetadata -> GYTxMetadata -> GYTxMetadata #

Merge two GYTxMetadatas, controlling how to handle the respective GYTxMetadataValues in case of label collision.

metadataMsg :: Text -> Maybe GYTxMetadata #

Adds a single message (comment/memo) as transaction metadata following CIP 020 specification.

See metadataMsgs for examples.

metadataMsgs :: [Text] -> Maybe GYTxMetadata #

Adds multiple messages (comments/memos) as transaction metadata following CIP 020 specification.

>>> metadataMsgs ["Hello, World!", "This is a test message."]
Just (fromList [(674,GYTxMetaMap [(GYTxMetaText "msg",GYTxMetaList [GYTxMetaText "Hello, World!",GYTxMetaText "This is a test message."])])])
>>> metadataMsgs [""]
Nothing
>>> metadataMsgs []
Nothing
>>> metadataMsgs ["Hello, World!", "This one is a reaaaaaaaally long message, so long that it exceeds the 64 byte limit, so it will be split into multiple chunks.", "do you see that?"]
Just (fromList [(674,GYTxMetaMap [(GYTxMetaText "msg",GYTxMetaList [GYTxMetaText "Hello, World!",GYTxMetaText "This one is a reaaaaaaaally long message, so long that it exceed",GYTxMetaText "s the 64 byte limit, so it will be split into multiple chunks.",GYTxMetaText "do you see that?"])])])