| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Singular.Registry.Blueprint
Description
Minimal CIP-57 Plutus blueprint parser and validator.
Loads a plutus.json blueprint file produced by the
Aiken compiler, extracts type schemas and script
hashes, and validates Data values
against the declared schemas.
The blueprint also carries optional compiledCode
fields (hex-encoded double-CBOR PlutusV3 scripts).
extractCompiledCode decodes these into
ShortByteString suitable for PlutusBinary.
The state script is parameterized by
previousPolicies (a predecessor-policy allowlist)
via applyPreviousPolicies; the request script is
parameterized by (statePolicyId, cageToken) via
applyRequestParams.
This module is the public compatibility facade: it holds no
implementations of its own and re-exports the focused owners
Singular.Registry.Blueprint.Schema (schema and validation),
Singular.Registry.Blueprint.Params (parameter application) and
Singular.Registry.Blueprint.Load (loading and code selection).
Synopsis
- data Blueprint = Blueprint {
- validators :: [Validator]
- definitions :: Map Text Schema
- data Validator = Validator {
- vTitle :: Text
- vDatum :: Maybe Schema
- vRedeemer :: Schema
- vHash :: Text
- vCompiledCode :: Maybe Text
- vParameters :: Int
- data Schema
- = SBytes
- | SInteger
- | SList Schema
- | STuple [Schema]
- | SConstructors [Constructor]
- | SRef Text
- data Constructor = Constructor {}
- loadBlueprint :: FilePath -> IO (Either String Blueprint)
- data ApplicationCodes = ApplicationCodes {
- ncApplication :: ShortByteString
- ncWitness :: ShortByteString
- validateData :: Map Text Schema -> Schema -> Data -> Bool
- extractScriptHash :: Text -> Blueprint -> Maybe Text
- extractCompiledCode :: Text -> Blueprint -> Maybe ShortByteString
- applyDataParam :: Data -> ShortByteString -> ShortByteString
- applyIntParam :: Integer -> ShortByteString -> ShortByteString
- applyBytesParam :: ByteString -> ShortByteString -> ShortByteString
- applyOutputRef :: OnChainTxOutRef -> ShortByteString -> ShortByteString
- applyPreviousPolicies :: [ByteString] -> ShortByteString -> ShortByteString
- applyRequestParams :: ByteString -> OnChainTokenId -> ShortByteString -> ShortByteString
Schema types
A parsed CIP-57 blueprint.
Constructors
| Blueprint | |
Fields
| |
Instances
| FromJSON Blueprint Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Show Blueprint Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Eq Blueprint Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
A validator entry in the blueprint.
Constructors
| Validator | |
Fields
| |
Instances
| FromJSON Validator Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Show Validator Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Eq Validator Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
CIP-57 schema for a Plutus data type.
Constructors
| SBytes | {"dataType": "bytes"} |
| SInteger | {"dataType": "integer"} |
| SList Schema |
|
| STuple [Schema] |
|
| SConstructors [Constructor] | {"anyOf": [...constructors...]} |
| SRef Text | {"$ref": "#definitions..."} |
Instances
| FromJSON Schema Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Show Schema Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
| Eq Schema Source # | |
Defined in Singular.Registry.Blueprint.Schema | |
data Constructor Source #
A single constructor alternative in a schema.
Constructors
| Constructor | |
Instances
| FromJSON Constructor Source # | |
Defined in Singular.Registry.Blueprint.Schema Methods parseJSON :: Value -> Parser Constructor parseJSONList :: Value -> Parser [Constructor] omittedField :: Maybe Constructor | |
| Show Constructor Source # | |
Defined in Singular.Registry.Blueprint.Schema Methods showsPrec :: Int -> Constructor -> ShowS Source # show :: Constructor -> String Source # showList :: [Constructor] -> ShowS Source # | |
| Eq Constructor Source # | |
Defined in Singular.Registry.Blueprint.Schema Methods (==) :: Constructor -> Constructor -> Bool Source # (/=) :: Constructor -> Constructor -> Bool Source # | |
Loading
Arguments
| :: FilePath | Path to the |
| -> IO (Either String Blueprint) |
Load and parse a CIP-57 blueprint from a file path.
Supplied application and token-policy code
data ApplicationCodes Source #
Supplied application and active-token-policy code for the shared identity adapters. The caller chooses the application; no application is built into the registry library.
Constructors
| ApplicationCodes | |
Fields
| |
Validation
Arguments
| :: Map Text Schema | Named definitions for |
| -> Schema | Schema to validate against |
| -> Data | Value to validate |
| -> Bool |
Validate a Data value against a Schema,
resolving $ref through the definitions map.
Script hash extraction
Arguments
| :: Text | Title prefix to match |
| -> Blueprint | Blueprint to search |
| -> Maybe Text |
Find the first validator whose title starts with the given prefix and return its hash.
Compiled code extraction
Arguments
| :: Text | Title prefix to match |
| -> Blueprint | Blueprint to search |
| -> Maybe ShortByteString |
Find the first validator whose title starts with
the given prefix and return its compiled script
bytes as a ShortByteString. The hex-encoded
compiledCode is decoded to raw bytes suitable
for PlutusBinary.
Parameter application
Arguments
| :: Data | Encoded parameter value |
| -> ShortByteString | Flat-encoded UPLC program |
| -> ShortByteString |
Apply a Data parameter to a UPLC script.
The blueprint's compiledCode is a flat-encoded
UPLC program that expects one parameter. This
function applies the supplied Data value to that
parameter slot, producing the final script bytes.
Arguments
| :: Integer | Encoded integer parameter |
| -> ShortByteString | Flat-encoded UPLC program |
| -> ShortByteString |
Apply an integer parameter to a UPLC script.
`witness(kind, registry)` (#157 mint-matches-edge-deltas) takes its kind as a plain integer, and
the deployment applies it three times. Wrapping the Data encoding here
keeps the Data vocabulary inside this module, where the rest
of the blueprint's encoding already lives.
Arguments
| :: ByteString | Encoded bytes parameter |
| -> ShortByteString | Flat-encoded UPLC program |
| -> ShortByteString |
Apply a raw bytes parameter to a UPLC script.
Arguments
| :: OnChainTxOutRef | Output reference to apply as the seed parameter |
| -> ShortByteString | Flat-encoded UPLC program |
| -> ShortByteString |
Apply an OnChainTxOutRef parameter to a UPLC
script. Wraps applyDataParam with the canonical
Constr 0 [bytes, integer] encoding produced by the
'ToData OnChainTxOutRef' instance — matching what the
on-chain validator's parameter slot expects when the
Aiken validator is parameterized by an
OutputReference.
applyPreviousPolicies Source #
Arguments
| :: [ByteString] | Predecessor policy-id bytes (28 bytes each); |
| -> ShortByteString | Flat-encoded raw state UPLC program |
| -> ShortByteString |
Apply the state validator's previousPolicies
allowlist parameter. The on-chain parameter type is
List<PolicyId>, encoded as
List [B pid0, B pid1, …] (an empty List [] for a
genesis cage, which makes migration into it
impossible).
Arguments
| :: ByteString | State policy id bytes |
| -> OnChainTokenId | Cage token asset name |
| -> ShortByteString | Flat-encoded request UPLC program |
| -> ShortByteString |
Apply request-validator parameters in source
order: statePolicyId first, then cageTokenName.