cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Governance.Anchor

Description

Off-chain governance metadata locations and hashes. Validate external text and bytes once, then assemble Anchor values with its total constructor. Locations are not fetched or checked for URI syntax.

import qualified Cometa.Governance.Anchor as Anchor

attach :: Anchor.Url -> Anchor.DataHash -> Anchor.Anchor
attach = Anchor.Anchor
Synopsis

Documentation

data Url Source #

Metadata location containing 1 through 128 UTF-8 bytes and no NUL. No URI syntax, network reachability, or payload validation is implied. Equality and ordering compare text. Show is diagnostic.

Instances

Instances details
Show Url Source # 
Instance details

Defined in Cometa.Internal.Governance

Methods

showsPrec :: Int -> Url -> ShowS #

show :: Url -> String #

showList :: [Url] -> ShowS #

Eq Url Source # 
Instance details

Defined in Cometa.Internal.Governance

Methods

(==) :: Url -> Url -> Bool #

(/=) :: Url -> Url -> Bool #

Ord Url Source # 
Instance details

Defined in Cometa.Internal.Governance

Methods

compare :: Url -> Url -> Ordering #

(<) :: Url -> Url -> Bool #

(<=) :: Url -> Url -> Bool #

(>) :: Url -> Url -> Bool #

(>=) :: Url -> Url -> Bool #

max :: Url -> Url -> Url #

min :: Url -> Url -> Url #

mkUrl :: Text -> Either Error Url Source #

Validate 1 through 128 UTF-8 bytes and absence of NUL. Bad length returns InvalidAnchorUrlLength; NUL returns InvalidAnchorUrl. No URI parsing or network request occurs.

urlText :: Url -> Text Source #

Exact validated location text.

data DataHash Source #

An exact 32-byte BLAKE2b-256 digest of off-chain metadata bytes. Importing bytes does not verify metadata. Equality and ordering compare bytes.

Instances

Instances details
Show DataHash Source # 
Instance details

Defined in Cometa.Internal.Governance

Eq DataHash Source # 
Instance details

Defined in Cometa.Internal.Governance

Ord DataHash Source # 
Instance details

Defined in Cometa.Internal.Governance

dataHashFromBytes :: ByteString -> Either Error DataHash Source #

Import exactly 32 bytes without hashing. Another length returns InvalidAnchorDataHashLength with the actual byte count.

dataHashBytes :: DataHash -> ByteString Source #

Exact expected payload hash bytes.

hashData :: ByteString -> IO (Either Error DataHash) Source #

Hash the exact off-chain payload with BLAKE2b-256. Empty input returns NativeError with the native out-of-bounds-memory-read code, matching the BLAKE2b boundary. Native allocation or hashing failures also return NativeError. No JSON parsing or normalization occurs.

data Anchor Source #

A metadata location and the expected hash of its payload. Assembly is total because both components are validated. A location does not authenticate data unless the retrieved bytes are checked against the hash.

Constructors

Anchor 

Fields

  • url :: !Url

    Off-chain metadata location.

  • dataHash :: !DataHash

    Expected digest of the exact off-chain payload bytes.

Instances

Instances details
Show Anchor Source # 
Instance details

Defined in Cometa.Internal.Governance

Eq Anchor Source # 
Instance details

Defined in Cometa.Internal.Governance

Methods

(==) :: Anchor -> Anchor -> Bool #

(/=) :: Anchor -> Anchor -> Bool #

Ord Anchor Source # 
Instance details

Defined in Cometa.Internal.Governance

encodeCbor :: Anchor -> ByteString Source #

Fresh definite CBOR [URL text, hash bytes]. Re-encoding imported semantic data may change its containing transaction's encoding; preserve the original enclosing CBOR when identity matters.

decodeCbor :: ByteString -> Either Error Anchor Source #

Decode one complete anchor, accepting definite or indefinite arrays and nonminimal lengths. URL validation, the exact 32-byte hash and array arity are enforced; invalid input or trailing bytes returns InvalidGovernanceCbor. This returns semantic data, not an encoding-preserving wrapper.