| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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
- data Url
- mkUrl :: Text -> Either Error Url
- urlText :: Url -> Text
- data DataHash
- dataHashFromBytes :: ByteString -> Either Error DataHash
- dataHashBytes :: DataHash -> ByteString
- hashData :: ByteString -> IO (Either Error DataHash)
- data Anchor = Anchor {}
- encodeCbor :: Anchor -> ByteString
- decodeCbor :: ByteString -> Either Error Anchor
Documentation
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.
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.
An exact 32-byte BLAKE2b-256 digest of off-chain metadata bytes. Importing bytes does not verify metadata. Equality and ordering compare bytes.
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.
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 | |
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.