singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.Blueprint.Schema

Description

The CIP-57 schema model behind Blueprint: the Blueprint, Validator, Schema and Constructor types with their Aeson parsers, and validateData for checking Data values against a declared schema.

This is the schema-and-validation owner extracted from Singular.Registry.Blueprint; the public module re-exports it and is its only intended consumer surface.

Synopsis

Schema types

data Blueprint Source #

A parsed CIP-57 blueprint.

Constructors

Blueprint 

Fields

Instances

Instances details
FromJSON Blueprint Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

parseJSON :: Value -> Parser Blueprint

parseJSONList :: Value -> Parser [Blueprint]

omittedField :: Maybe Blueprint

Show Blueprint Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

showsPrec :: Int -> Blueprint -> ShowS Source #

show :: Blueprint -> String Source #

showList :: [Blueprint] -> ShowS Source #

Eq Blueprint Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

(==) :: Blueprint -> Blueprint -> Bool Source #

(/=) :: Blueprint -> Blueprint -> Bool Source #

data Validator Source #

A validator entry in the blueprint.

Constructors

Validator 

Fields

  • vTitle :: Text

    Human-readable validator name

  • vDatum :: Maybe Schema

    Datum schema, absent for minting validators

  • vRedeemer :: Schema

    Redeemer schema

  • vHash :: Text

    Hex-encoded script hash (28 bytes)

  • vCompiledCode :: Maybe Text

    Hex-encoded double-CBOR PlutusV3 script

  • vParameters :: Int

    How many parameters this validator applies. A blueprint omits the array entirely for a parameterless validator, so an absent parameters key reads as zero. This is what makes a parameterless policy's compiled hash its policy id, with no applied hash to derive, so a consumer that wants to state it should READ it here rather than write the number down.

Instances

Instances details
FromJSON Validator Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

parseJSON :: Value -> Parser Validator

parseJSONList :: Value -> Parser [Validator]

omittedField :: Maybe Validator

Show Validator Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

showsPrec :: Int -> Validator -> ShowS Source #

show :: Validator -> String Source #

showList :: [Validator] -> ShowS Source #

Eq Validator Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

(==) :: Validator -> Validator -> Bool Source #

(/=) :: Validator -> Validator -> Bool Source #

data Schema Source #

CIP-57 schema for a Plutus data type.

Constructors

SBytes
{"dataType": "bytes"}
SInteger
{"dataType": "integer"}
SList Schema

{"dataType": "list", "items": schema} — a homogeneous list of any length.

STuple [Schema]

{"dataType": "list", "items": [schema, ...]} — Aiken's FIXED TUPLE (#157 request-destination-binding): an ARRAY of positional item schemas. On the wire it is a Plutus List of exactly that arity, each element of its own declared type, which is what distinguishes it from SList and why it cannot share that case: a homogeneous rule would accept a three-element pair.

SConstructors [Constructor]
{"anyOf": [...constructors...]}
SRef Text
{"$ref": "#definitions..."}

Instances

Instances details
FromJSON Schema Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

parseJSON :: Value -> Parser Schema

parseJSONList :: Value -> Parser [Schema]

omittedField :: Maybe Schema

Show Schema Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

showsPrec :: Int -> Schema -> ShowS Source #

show :: Schema -> String Source #

showList :: [Schema] -> ShowS Source #

Eq Schema Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

(==) :: Schema -> Schema -> Bool Source #

(/=) :: Schema -> Schema -> Bool Source #

data Constructor Source #

A single constructor alternative in a schema.

Constructors

Constructor 

Fields

  • conIndex :: Integer

    Constructor tag (matches Aiken's Constr index)

  • conFields :: [Schema]

    Schemas for each positional field

Instances

Instances details
FromJSON Constructor Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

parseJSON :: Value -> Parser Constructor

parseJSONList :: Value -> Parser [Constructor]

omittedField :: Maybe Constructor

Show Constructor Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

showsPrec :: Int -> Constructor -> ShowS Source #

show :: Constructor -> String Source #

showList :: [Constructor] -> ShowS Source #

Eq Constructor Source # 
Instance details

Defined in Singular.Registry.Blueprint.Schema

Methods

(==) :: Constructor -> Constructor -> Bool Source #

(/=) :: Constructor -> Constructor -> Bool Source #

Validation

validateData Source #

Arguments

:: Map Text Schema

Named definitions for $ref resolution

-> Schema

Schema to validate against

-> Data

Value to validate

-> Bool 

Validate a Data value against a Schema, resolving $ref through the definitions map.