singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.Application

Description

A registry pins one application policy at boot (#157 genesis-policy-pins). This module carries what the registry needs to know of an application without naming any: a name for receipts and refusals, the executable that folds its terminations, how the policy is fixed, and the decoder and holding rules. Each executable composes its value and hands it to the library.

The pin has four forms: a hash given as input (a registry booted for an application whose script does not depend on the registry identity), a blueprint validator title applied to the registry identity (the state policy then the token name), a blueprint validator title pinned as compiled (the parameterless form the tests use; production registries are always identity-scoped), or read from the state datum of a registry that already exists. applyPin derives the pinned bytes and codes for the first three; the fourth needs the datum, so only resolveRegistry passes it after reading the datum, and configForApplication refuses it by name.

The retained holding rules identify and decode live holdings for read-only and recovery adapters. They do not construct a release or a registry fold.

Synopsis

The pin

data ApplicationPin Source #

How the registry's application policy is fixed.

Constructors

PinByHash ShortByteString

A 28-byte policy hash given as input

PinByScript Text

The blueprint validator title, applied to the registry identity

PinAsCompiled Text

The blueprint validator title, pinned as compiled: the parameterless form the tests use, never a production registry

PinFromState

Read from the state datum of the registry being attached to

Instances

Instances details
Show ApplicationPin Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: ApplicationPin -> String Source #

showList :: [ApplicationPin] -> ShowS Source #

Eq ApplicationPin Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

The value

data Application Source #

What the registry knows of an application: a name for receipts and refusals, the executable that folds its terminations, how the policy is fixed, and the decoder and holding rules. The neutral value carries none of the last three; a named value carries all of them.

Constructors

Application 

Fields

Instances

Instances details
Show Application Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: Application -> String Source #

showList :: [Application] -> ShowS Source #

Eq Application Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

neutralApplication :: Application Source #

The value singular folds with: no name, no executable, no decoder, no holding rules; the pin is read from the state datum.

hashPinnedApplication :: ShortByteString -> Application Source #

The neutral value with the pin fixed to the given 28-byte policy hash.

The concrete parts

data DecodedHolding Source #

What the registry knows of a holding: the datum it carries and what the application protects in it. The open datum fills this from the envelope (control + payload); a future application fills it from its own datum. The library never names either.

Constructors

DecodedHolding 

Fields

  • dhDatumData :: Data

    The full datum, as data

  • dhDatumCbor :: ByteString

    Its CBOR, as the ledger hashes it

  • dhDatumHash :: ByteString

    Its BLAKE2b-256, as requests and journals name it

  • dhKey :: ByteString

    The key the holding belongs to

  • dhDeposit :: Integer

    The protected deposit, in lovelace

  • dhController :: ByteString

    The controller's payment key hash

  • dhPayload :: Data

    The payload the application leaves unread by the registry

  • dhDatumJson :: Value

    The datum as detailed-schema JSON (for receipts)

Instances

Instances details
Show DecodedHolding Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: DecodedHolding -> String Source #

showList :: [DecodedHolding] -> ShowS Source #

Eq DecodedHolding Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

newtype Decoder Source #

How the application reads a datum: into a holding view, or a named reason.

Constructors

Decoder 

Fields

Instances

Instances details
Show Decoder Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: Decoder -> String Source #

showList :: [Decoder] -> ShowS Source #

Eq Decoder Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

data HoldingRules Source #

How the application holds keys: what the registry needs to fold without naming the application. Absent on the neutral value; the open datum fills every field from the envelope and release.

Constructors

HoldingRules 

Fields

  • hrFindHoldings :: CageConfig -> TokenId -> ByteString -> [(TxIn, TxOut ConwayEra)] -> [((TxIn, TxOut ConwayEra), DecodedHolding)]

    This registry's holdings of a key among the outputs at the application address (a foreign envelope is not one of them)

  • hrLiveOutputFor :: CageConfig -> TokenId -> ByteString -> [(TxIn, TxOut ConwayEra)] -> Either Text ((TxIn, TxOut ConwayEra), DecodedHolding)

    The key's one live holding, or why there is none (foreign or duplicate)

  • hrRequiresToken :: Bool

    Whether the rule counts an output as a holding of a key only when the output holds that key's active witness token. A reader may then ask the provider who holds the token and judge those outputs alone. A rule that can accept an output without the token says False, and the reader judges every output at the application address, as it always did.

Instances

Instances details
Show HoldingRules Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: HoldingRules -> String Source #

showList :: [HoldingRules] -> ShowS Source #

Eq HoldingRules Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

Generic datum bytes, hashes and JSON (no application named)

datumCbor :: Data -> ByteString Source #

The CBOR of a datum, by the same builtin a script's serialise_data runs. Generic: the library names no application to name it.

datumHash :: Data -> ByteString Source #

The BLAKE2b-256 of a datum's CBOR: the datum hash a request names. Generic: the same bytes envelopeHash hashes, so an application datum hash equals its envelope hash byte for byte.

txOutDatum :: TxOut ConwayEra -> Maybe (ByteString, ByteString) Source #

An output's inline datum, as bytes and hash, when it carries one.

datumToJson :: Data -> Value Source #

The detailed-schema JSON of a datum, naming no application. Byte-identical to the open datum's dataToJson on the same datum.

datumFromJson :: Value -> Either String Data Source #

A datum from its detailed-schema JSON, or where it is wrong. Byte-identical to the open datum's dataFromJson on the same JSON.

Deriving from a pin

applyPin Source #

Arguments

:: ApplicationPin 
-> ByteString

The registry identity: state policy then state token name

-> ApplicationCodes

The application and witness codes as the blueprint carries them

-> (ShortByteString, ApplicationCodes) 

The pinned policy bytes and the codes as the registry runs them, for a pin that carries its own derivation. PinFromState needs the state datum, which this function is never given, so it is refused by name; resolveRegistry reads the datum first and passes its pin as PinByHash.

What was compared

data ApplicationPinStanding Source #

What a resolution knows of the application pin. A form that carries a script, a compiled script or a hash is compared with the registry's datum; the pin read from the state datum is the datum's own and is compared with nothing.

Constructors

ApplicationPinCompared

The application derived its pin and the datum's pin equals it

ApplicationPinNotChecked

The pin was taken from the datum: no blueprint was asked

Instances

Instances details
Show ApplicationPinStanding Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

show :: ApplicationPinStanding -> String Source #

showList :: [ApplicationPinStanding] -> ShowS Source #

Eq ApplicationPinStanding Source # 
Instance details

Defined in Singular.Registry.Application

Methods

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

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

applicationPinStanding :: ApplicationPin -> ApplicationPinStanding Source #

The standing of the application pin for a pin form: every form that knows its own script is compared, only the pin read from state is not.

renderApplicationPinStanding :: ApplicationPinStanding -> Text Source #

The standing as receipts and the registry page spell it.