singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.State.Fold

Description

Anyone may fold the acceptable pending requests of a registry. The folder reads its public state and trie history, skips individually unfoldable requests and keeps the first foldable request per key in take order. A registration proves its key absent and mints its token into the committed holding; a termination proves its key active and burns its token. The batch consumes the requests and their approvals, continues the state and writes the new root. The booker contributes only the public request: no file, key or local record.

What a pending request is, how it is spent and how its approval is burned belong to the application. The application hands the builder those three things; the builder owns everything the state validator decides.

Synopsis

Documentation

data Registration Source #

What the fold needs to know of a pending registration, as the application publishes it in the registration's datum.

Constructors

Registration 

Fields

Instances

Instances details
Show Registration Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: Registration -> String Source #

showList :: [Registration] -> ShowS Source #

Eq Registration Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

data Request Source #

An application request, decoded from public data.

Instances

Instances details
Show Request Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: Request -> String Source #

showList :: [Request] -> ShowS Source #

Eq Request Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

requestKey :: Request -> ByteString Source #

data Folded Source #

A request being folded, with a holding output only for registration.

Constructors

Folded 

Fields

Instances

Instances details
Show Folded Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: Folded -> String Source #

showList :: [Folded] -> ShowS Source #

Eq Folded Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

data Application Source #

What the application contributes to a fold.

Constructors

Application 

Fields

  • appPolicy :: PolicyID

    The policy of the approvals

  • appDecode :: RegistryIdentity -> [ByteString] -> TxOut ConwayEra -> Maybe Request

    The public decoding of a pending request at the application's script

  • appIsConfiguration :: TxOut ConwayEra -> Bool

    Whether an output is the configuration of a registry the application holds, not a request. Discovery neither folds nor reports such an output.

  • appReferences :: [(TxIn, TxOut ConwayEra)]

    The outputs that carry its code, already checked, when it is referenced

  • appFold :: [Folded] -> Program ()

    Spend the pending registrations into their holdings, burn their approvals and make the application's code available to the transaction

data PendingRequest Source #

A request and its exact output, authenticated from public chain data.

Constructors

PendingRequest 

Fields

  • pendingRef :: TxIn

    The output the fold must spend, once.

  • pendingOutput :: TxOut ConwayEra

    Its complete value and datum as served by the provider.

  • pendingRequest :: Request

    Its decoded registry, key, kind and registration holding requirements.

  • pendingApproval :: AssetName

    The authenticated approval held by that same output.

Instances

Instances details
Show PendingRequest Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: PendingRequest -> String Source #

showList :: [PendingRequest] -> ShowS Source #

Eq PendingRequest Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

data SkippedHolder Source #

A holder omitted from an automatic fold, with its public reference and reason.

Constructors

SkippedHolder 

Fields

Instances

Instances details
Show SkippedHolder Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: SkippedHolder -> String Source #

showList :: [SkippedHolder] -> ShowS Source #

Eq SkippedHolder Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

data SkipReason Source #

Why an approval holder is omitted from an automatic fold.

Instances

Instances details
Show SkipReason Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: SkipReason -> String Source #

showList :: [SkipReason] -> ShowS Source #

Eq SkipReason Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

discoverPending :: Session NoWitness IO -> Application -> RegistryIdentity -> [ByteString] -> IO ([PendingRequest], [SkippedHolder]) Source #

Find requests using one complete policy query. The caller supplies keys from the registry's public replay; neither a wallet nor a local booking record participates. An output the application names as its configuration is in neither list. A failed read is thrown with its provider evidence intact.

data FoldResult Source #

The actual built batch and the complete discovery accounting.

Constructors

FoldResult 

Fields

Instances

Instances details
Show FoldResult Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: FoldResult -> String Source #

showList :: [FoldResult] -> ShowS Source #

Eq FoldResult Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

data FoldFailure Source #

A refusal, retaining complete discovery accounting when it was observed.

Constructors

FoldFailure 

Fields

Instances

Instances details
Show FoldFailure Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

show :: FoldFailure -> String Source #

showList :: [FoldFailure] -> ShowS Source #

Eq FoldFailure Source # 
Instance details

Defined in Singular.State.Fold

Methods

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

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

pendingTake :: PendingRequest -> Coin Source #

The folder's take from the observed request, matching natural subtraction.

buildFold :: Session NoWitness IO -> StateScript -> Application -> RegistryIdentity -> [TxIn] -> Addr -> Maybe Word32 -> IO (Either Refusal FoldResult) Source #

Discover and build the greatest fitting prefix, optionally capped. A nonempty named batch is built as named, without a cap or trimming. Automatic selection first skips individually unfoldable requests, then later foldable requests for an already selected key. Capacity alone permits a shorter prefix; other construction and public-read failures retain their own identity.

attemptFold :: Session NoWitness IO -> StateScript -> Application -> RegistryIdentity -> [TxIn] -> Addr -> Maybe Word32 -> IO (Either FoldFailure FoldResult) Source #

Build with the same rules as buildFold, retaining observed holders even when nothing is eligible or a later build refuses. Failed reads still throw.

buildRegistrationFold :: Session NoWitness IO -> StateScript -> Application -> RegistryIdentity -> [TxIn] -> Addr -> IO (Either Refusal ConwayTx) Source #

Fold named requests, or discover them from approvals when none is named. The payer funds the transaction and keeps what each registration holds above its deposit and what each termination holds in full.

foldedRequests :: ConwayTx -> [(TxIn, ByteString)] Source #

Requests named by the fold redeemer of a built transaction.