atlas-cardano-0.6.2: Application backend for Plutus smart contracts on Cardano
Copyright(c) 2024 GYELD GMBH
LicenseApache 2.0
Maintainer[email protected]
Stabilitydevelop
Safe HaskellSafe-Inferred
LanguageGHC2021

GeniusYield.Types.TxMetadata

Description

Transaction metadata types and functions for working with transaction metadata.

Synopsis

Documentation

constructTxMetadataMap ∷ [(GYTxMetadataValue, GYTxMetadataValue)] → GYTxMetadataValue #

Construct a GYTxMetadataValue from a list of key-value pairs.

constructTxMetadataNumberIntegerMaybe GYTxMetadataValue #

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

constructTxMetadataBytesByteStringMaybe GYTxMetadataValue #

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

constructTxMetadataTextTextMaybe GYTxMetadataValue #

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

constructTxMetadataBytesChunksByteStringGYTxMetadataValue #

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.

constructTxMetadataTextChunksTextGYTxMetadataValue #

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 ∷ (GYTxMetadataValueGYTxMetadataValueGYTxMetadataValue) → GYTxMetadataGYTxMetadataGYTxMetadata #

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

metadataMsgTextMaybe 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?"])])])