cardano-api:internal
Safe HaskellNone
LanguageHaskell2010

Cardano.Api.TxMetadata

Description

Metadata embedded in transactions

Synopsis

Types

newtype TxMetadata Source #

Instances

Instances details
Monoid TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Semigroup TxMetadata Source #

Merge metadata maps. When there are clashing entries the left hand side takes precedence.

Instance details

Defined in Cardano.Api.TxMetadata

Show TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

HasTypeProxy TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Associated Types

data AsType TxMetadata 
Instance details

Defined in Cardano.Api.TxMetadata

SerialiseAsCBOR TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Eq TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

data AsType TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Class

Constructing metadata

metaTextChunks :: Text -> TxMetadataValue Source #

Create a TxMetadataValue from a Text as a list of chunks of an acceptable size.

metaBytesChunks :: ByteString -> TxMetadataValue Source #

Create a TxMetadataValue from a ByteString as a list of chunks of an accaptable size.

Validating metadata

validateTxMetadata :: TxMetadata -> Either [(Word64, TxMetadataRangeError)] () Source #

Validate transaction metadata. This is for use with existing constructed metadata values, e.g. constructed manually or decoded from CBOR directly.

data TxMetadataRangeError Source #

An error in transaction metadata due to an out-of-range value.

Constructors

TxMetadataNumberOutOfRange !Integer

The number is outside the maximum range of -2^64-1 .. 2^64-1.

TxMetadataTextTooLong !Int

The length of a text string metadatum value exceeds the maximum of 64 bytes as UTF8.

TxMetadataBytesTooLong !Int

The length of a byte string metadatum value exceeds the maximum of 64 bytes.

Instances

Instances details
Data TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataRangeError -> c TxMetadataRangeError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataRangeError Source #

toConstr :: TxMetadataRangeError -> Constr Source #

dataTypeOf :: TxMetadataRangeError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataRangeError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataRangeError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataRangeError -> TxMetadataRangeError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataRangeError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataRangeError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataRangeError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataRangeError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataRangeError -> m TxMetadataRangeError Source #

Show TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Error TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Eq TxMetadataRangeError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Conversion to/from JSON

data TxMetadataJsonSchema Source #

Tx metadata is similar to JSON but not exactly the same. It has some deliberate limitations such as no support for floating point numbers or special forms for null or boolean values. It also has limitations on the length of strings. On the other hand, unlike JSON, it distinguishes between byte strings and text strings. It also supports any value as map keys rather than just string.

We provide two different mappings between tx metadata and JSON, useful for different purposes:

  1. A mapping that allows almost any JSON value to be converted into tx metadata. This does not require a specific JSON schema for the input. It does not expose the full representation capability of tx metadata.
  2. A mapping that exposes the full representation capability of tx metadata, but relies on a specific JSON schema for the input JSON.

In the "no schema" mapping, the idea is that (almost) any JSON can be turned into tx metadata and then converted back, without loss. That is, we can round-trip the JSON.

The subset of JSON supported is all JSON except: * No null or bool values * No floating point, only integers in the range of a 64bit signed integer * A limitation on string lengths

The approach for this mapping is to use whichever representation as tx metadata is most compact. In particular:

  • JSON lists and maps represented as CBOR lists and maps
  • JSON strings represented as CBOR strings
  • JSON hex strings with "0x" prefix represented as CBOR byte strings
  • JSON integer numbers represented as CBOR signed or unsigned numbers
  • JSON maps with string keys that parse as numbers or hex byte strings, represented as CBOR map keys that are actually numbers or byte strings.

The string length limit depends on whether the hex string representation is used or not. For text strings the limit is 64 bytes for the UTF8 representation of the text string. For byte strings the limit is 64 bytes for the raw byte form (ie not the input hex, but after hex decoding).

In the "detailed schema" mapping, the idea is that we expose the full representation capability of the tx metadata in the form of a JSON schema. This means the full representation is available and can be controlled precisely. It also means any tx metadata can be converted into the JSON and back without loss. That is we can round-trip the tx metadata via the JSON and also round-trip schema-compliant JSON via tx metadata.

Constructors

TxMetadataJsonNoSchema

Use the "no schema" mapping between JSON and tx metadata as described above.

TxMetadataJsonDetailedSchema

Use the "detailed schema" mapping between JSON and tx metadata as described above.

metadataFromJson :: TxMetadataJsonSchema -> Value -> Either TxMetadataJsonError TxMetadata Source #

Convert a value from JSON into tx metadata, using the given choice of mapping between JSON and tx metadata.

This may fail with a conversion error if the JSON is outside the supported subset for the chosen mapping. See TxMetadataJsonSchema for the details.

metadataToJson :: TxMetadataJsonSchema -> TxMetadata -> Value Source #

Convert a tx metadata value into JSON , using the given choice of mapping between JSON and tx metadata.

This conversion is total but is not necessarily invertible. See TxMetadataJsonSchema for the details.

data TxMetadataJsonError Source #

Instances

Instances details
Data TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataJsonError -> c TxMetadataJsonError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataJsonError Source #

toConstr :: TxMetadataJsonError -> Constr Source #

dataTypeOf :: TxMetadataJsonError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataJsonError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataJsonError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataJsonError -> TxMetadataJsonError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataJsonError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataJsonError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonError -> m TxMetadataJsonError Source #

Show TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Error TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Eq TxMetadataJsonError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

data TxMetadataJsonSchemaError Source #

Instances

Instances details
Data TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TxMetadataJsonSchemaError -> c TxMetadataJsonSchemaError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TxMetadataJsonSchemaError Source #

toConstr :: TxMetadataJsonSchemaError -> Constr Source #

dataTypeOf :: TxMetadataJsonSchemaError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TxMetadataJsonSchemaError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TxMetadataJsonSchemaError) Source #

gmapT :: (forall b. Data b => b -> b) -> TxMetadataJsonSchemaError -> TxMetadataJsonSchemaError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonSchemaError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TxMetadataJsonSchemaError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TxMetadataJsonSchemaError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TxMetadataJsonSchemaError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TxMetadataJsonSchemaError -> m TxMetadataJsonSchemaError Source #

Show TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Error TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Eq TxMetadataJsonSchemaError Source # 
Instance details

Defined in Cardano.Api.TxMetadata

Internal conversion functions

Shared parsing utils

parseAll :: Parser a -> Text -> Maybe a Source #

Data family instances

data family AsType t Source #

A family of singleton types used in this API to indicate which type to use where it would otherwise be ambiguous or merely unclear.

Values of this type are passed to deserialisation functions for example.

Instances

Instances details
data AsType AddressAny Source # 
Instance details

Defined in Cardano.Api.Address

data AsType ByronAddr Source # 
Instance details

Defined in Cardano.Api.Address

data AsType ShelleyAddr Source # 
Instance details

Defined in Cardano.Api.Address

data AsType StakeAddress Source # 
Instance details

Defined in Cardano.Api.Address

data AsType BlockHeader Source # 
Instance details

Defined in Cardano.Api.Block

data AsType DRepMetadata Source # 
Instance details

Defined in Cardano.Api.DRepMetadata

data AsType AllegraEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType AlonzoEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType BabbageEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType ByronEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType ConwayEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType MaryEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType ShelleyEra Source # 
Instance details

Defined in Cardano.Api.Eras.Core

data AsType GovernancePoll Source # 
Instance details

Defined in Cardano.Api.Governance.Poll

data AsType GovernancePollAnswer Source # 
Instance details

Defined in Cardano.Api.Governance.Poll

data AsType ByronKey Source # 
Instance details

Defined in Cardano.Api.Keys.Byron

data AsType ByronKeyLegacy Source # 
Instance details

Defined in Cardano.Api.Keys.Byron

data AsType KesKey Source # 
Instance details

Defined in Cardano.Api.Keys.Praos

data AsType VrfKey Source # 
Instance details

Defined in Cardano.Api.Keys.Praos

data AsType CommitteeColdExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType CommitteeColdKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType CommitteeHotExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType CommitteeHotKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType DRepExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType DRepKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType GenesisDelegateExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType GenesisDelegateKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType GenesisExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType GenesisKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType GenesisUTxOKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType PaymentExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType PaymentKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType StakeExtendedKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType StakeKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType StakePoolKey Source # 
Instance details

Defined in Cardano.Api.Keys.Shelley

data AsType OperationalCertificate Source # 
Instance details

Defined in Cardano.Api.OperationalCertificate

data AsType OperationalCertificateIssueCounter Source # 
Instance details

Defined in Cardano.Api.OperationalCertificate

data AsType PraosNonce Source # 
Instance details

Defined in Cardano.Api.ProtocolParameters

data AsType UpdateProposal Source # 
Instance details

Defined in Cardano.Api.ProtocolParameters

data AsType PlutusScriptV1 Source # 
Instance details

Defined in Cardano.Api.Script

data AsType PlutusScriptV2 Source # 
Instance details

Defined in Cardano.Api.Script

data AsType PlutusScriptV3 Source # 
Instance details

Defined in Cardano.Api.Script

data AsType ScriptHash Source # 
Instance details

Defined in Cardano.Api.Script

data AsType ScriptInAnyLang Source # 
Instance details

Defined in Cardano.Api.Script

data AsType SimpleScript' Source # 
Instance details

Defined in Cardano.Api.Script

data AsType HashableScriptData Source # 
Instance details

Defined in Cardano.Api.ScriptData

data AsType ScriptData Source # 
Instance details

Defined in Cardano.Api.ScriptData

data AsType TextEnvelope Source # 
Instance details

Defined in Cardano.Api.SerialiseTextEnvelope

data AsType ByronUpdateProposal Source # 
Instance details

Defined in Cardano.Api.SpecialByron

data AsType ByronVote Source # 
Instance details

Defined in Cardano.Api.SpecialByron

data AsType StakePoolMetadata Source # 
Instance details

Defined in Cardano.Api.StakePoolMetadata

data AsType TxId Source # 
Instance details

Defined in Cardano.Api.TxIn

data AsType TxMetadata Source # 
Instance details

Defined in Cardano.Api.TxMetadata

data AsType AssetName Source # 
Instance details

Defined in Cardano.Api.Value

data AsType PolicyId Source # 
Instance details

Defined in Cardano.Api.Value

data AsType (Address addrtype) Source # 
Instance details

Defined in Cardano.Api.Address

data AsType (Address addrtype) = AsAddress (AsType addrtype)
data AsType (AddressInEra era) Source # 
Instance details

Defined in Cardano.Api.Address

data AsType (Certificate era) Source # 
Instance details

Defined in Cardano.Api.Certificate

data AsType (Proposal era) Source # 
Instance details

Defined in Cardano.Api.Governance.Actions.ProposalProcedure

data AsType (VotingProcedure era) Source # 
Instance details

Defined in Cardano.Api.Governance.Actions.VotingProcedure

data AsType (VotingProcedures era) Source # 
Instance details

Defined in Cardano.Api.Governance.Actions.VotingProcedure

data AsType (Hash a) Source # 
Instance details

Defined in Cardano.Api.Hash

data AsType (Hash a) = AsHash (AsType a)
data AsType (SigningKey a) Source # 
Instance details

Defined in Cardano.Api.Keys.Class

data AsType (VerificationKey a) Source # 
Instance details

Defined in Cardano.Api.Keys.Class

data AsType (PlutusScript lang) Source # 
Instance details

Defined in Cardano.Api.Script

data AsType (Script lang) Source # 
Instance details

Defined in Cardano.Api.Script

data AsType (Script lang) = AsScript (AsType lang)
data AsType (ScriptInEra era) Source # 
Instance details

Defined in Cardano.Api.Script

data AsType (KeyWitness era) Source # 
Instance details

Defined in Cardano.Api.Tx.Sign

data AsType (Tx era) Source # 
Instance details

Defined in Cardano.Api.Tx.Sign

data AsType (Tx era) = AsTx (AsType era)
data AsType (TxBody era) Source # 
Instance details

Defined in Cardano.Api.Tx.Sign

data AsType (TxBody era) = AsTxBody (AsType era)