singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.TxBuilder.Update.Context

Description

Everything a fold must know or prepare before it can decide anything: the registry context a caller hands in (and its empty value), the staterequestfee queries that find the fold's inputs, the ordered speculative proofs through the trie, the state continuation output and its script, the validity upper slot, and the completion of a partly empty context from the provider.

This module owns no duty decisions and no transaction assembly; see Singular.Registry.TxBuilder.Update.Duties and Singular.Registry.TxBuilder.Update.Build. The public surface stays Singular.Registry.TxBuilder.Update, which re-exports the context types unchanged (#267).

Synopsis

Documentation

data RegistryContext Source #

What a fold needs in hand to discharge the obligations: the three token policies' scripts by kind, the cage script (custody spends run it), and the UTxOs sitting at the cage address (custody lives among them). A delivered output's datum is the one its request carries (#419), so nothing beyond the chain is in hand.

Constructors

RegistryContext 

Fields

  • rcWitnessScripts :: Map Integer (Script ConwayEra)
     
  • rcCageScript :: Maybe (Script ConwayEra)
     
  • rcCageUtxos :: [(TxIn, TxOut ConwayEra)]
     
  • rcAllowInadmissible :: Bool

    Build a fold even when a request takes no admissible edge, so a row that exists to watch the chain REFUSE one can produce the transaction it submits. An honest builder leaves this off and fails early, naming the request.

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

    #177 I177-BUILDER: the candidate inputs a burn may be sourced from — the outputs that actually HOLD registry witnesses. A retirement or an active deletion destroys an asset it does not create, so the fold has to consume the holder's own UTxO; with nothing in this inventory the builder fails naming the key rather than emitting a mint the cage refuses `token-missing`. Left empty, the builder queries the fold's own wallet address.

  • rcHolderReleases :: Map TxIn HolderRelease

    #299: holders that sit at an application script rather than a key. A burn sourced from one of them spends it with the application's own witness instead of as a plain input, and the application's release is owed to its recipient together with every other obligation of the fold to that key. Empty for key-held witnesses.

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

    Outputs carrying the fold's scripts as reference scripts. The state validator alone is fifteen kilobytes, so a fold that attaches it, the request script and a token policy does not fit in a transaction; with references every purpose resolves through them instead.

data HolderRelease Source #

How an application-held burn source is spent, and what its spend releases (#299): the redeemer and script that witness the spend, and the lovelace owed to the recipient's key because the holder is released.

Constructors

HolderRelease 

Fields

  • hrRedeemer :: Data
     
  • hrScript :: Script ConwayEra
     
  • hrRecipient :: ByteString

    The payment key hash the release is owed to

  • hrReleased :: Integer

    Lovelace owed to it, over every other obligation to that key

Instances

Instances details
Show HolderRelease Source # 
Instance details

Defined in Singular.Registry.TxBuilder.Update.Context

Methods

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

show :: HolderRelease -> String Source #

showList :: [HolderRelease] -> ShowS Source #

Eq HolderRelease Source # 
Instance details

Defined in Singular.Registry.TxBuilder.Update.Context

Methods

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

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

emptyRegistryContext :: RegistryContext Source #

The context a fold of tree edges needs beyond the registry's own configuration: the three token policies' scripts and the cage script that custody spends run. A delivered output's datum is the one its request carries.

emptyRegistryContext carries none of it, which is right for a caller that folds only rejections — and refuses loudly, naming the missing script, for one that folds an edge without it.

completeContext :: CageConfig -> Session NoWitness IO -> Addr -> Script ConwayEra -> RegistryContext -> IO RegistryContext Source #

Complete a context the caller left partly empty: the cage's own UTxOs and the fold's holder inventory are queried from the provider when the caller did not supply them, and the cage script defaults to the one this build's own state continuation runs. The caller-supplied value always wins; only an omission triggers a query (#267: moved verbatim from the facade's inline completion).

queryContext :: Maybe (NonEmpty TxIn) -> CageConfig -> Session NoWitness IO -> TokenId -> Addr -> IO ((TxIn, TxOut ConwayEra), [(TxIn, TxOut ConwayEra)], (TxIn, TxOut ConwayEra), PParams ConwayEra) Source #

Query cage UTxOs, find the state and request UTxOs, pick a fee-paying wallet UTxO.

The pending-request query takes the chosen set: folding every pending request (absent selection) still refuses an empty pending set with the long-standing generic error, while folding a chosen set returns whatever is pending (possibly none) so the caller can name every chosen reference that is not among them, at every live pending-set size including zero.

computeProofs :: TrieManager IO -> TokenId -> [(TxIn, TxOut ConwayEra)] -> IO ([[ProofStep]], Root) Source #

Run speculative trie operations to compute proofs and the new root hash.

prepareState :: CageConfig -> TxOut ConwayEra -> Root -> (OnChainTokenState, TxOut ConwayEra, Script ConwayEra) Source #

Extract old state, build new state output, cage script, and owner key hash.

computeUpperSlot :: Session NoWitness IO -> OnChainTokenState -> [(TxIn, TxOut ConwayEra)] -> IO SlotNo Source #

Compute the validity upper slot.