cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Transaction.Deferred

Description

Pure queries of the current builder draft for deferred redeemers. Compose required indices, inspect selected inputs, then supply an explicit script-data encoder to redeemer. Queries run again whenever the builder invokes the callback; positions are specific to that draft, not the final signed body.

import qualified Cometa.PlutusData as Data
import qualified Cometa.Transaction.Deferred as Deferred

spendingRedeemer reference =
  Deferred.redeemer (Data.Integer . toInteger) (Deferred.inputIndex reference)
Synopsis

Documentation

data Query a Source #

A read-only draft query with explicit expected failure. Functor, Applicative and Monad share the same immutable draft and selected-input snapshot throughout a run and stop at the first Left. No native or network effects occur. The constructor is hidden; use the queries and fromEither.

Instances

Instances details
Applicative Query Source # 
Instance details

Defined in Cometa.Transaction.Deferred

Methods

pure :: a -> Query a #

(<*>) :: Query (a -> b) -> Query a -> Query b #

liftA2 :: (a -> b -> c) -> Query a -> Query b -> Query c #

(*>) :: Query a -> Query b -> Query b #

(<*) :: Query a -> Query b -> Query a #

Functor Query Source # 
Instance details

Defined in Cometa.Transaction.Deferred

Methods

fmap :: (a -> b) -> Query a -> Query b #

(<$) :: a -> Query b -> Query a #

Monad Query Source # 
Instance details

Defined in Cometa.Transaction.Deferred

Methods

(>>=) :: Query a -> (a -> Query b) -> Query b #

(>>) :: Query a -> Query b -> Query b #

return :: a -> Query a #

draft :: Query Transaction Source #

The current callback draft. Inspect it with the ordinary pure transaction observers. Subsequent balancing may change its body and indices.

selectedInputs :: Query [Utxo] Source #

The exact selected-input list supplied to this callback, retaining order. This is not a network query and need not include reference inputs. run does not validate or reorder an independently supplied snapshot.

fromEither :: Either Error a -> Query a Source #

Lift existing pure validation. A Left stops subsequent query steps.

run :: Query a -> Transaction -> [Utxo] -> Either Error a Source #

Evaluate against one draft and selected-input snapshot. Useful for testing a query before installing it in a plan. Inputs remain unchanged.

inputIndex :: Input -> Query Word64 Source #

Required spending-input position in hash-byte then numeric-index order. Duplicates use their first position. Absence returns InvalidBuildingRequest.

referenceInputIndex :: Input -> Query Word64 Source #

Required reference-input position in the same order as inputIndex. Absence returns InvalidBuildingRequest.

mintPolicyIndex :: PolicyId -> Query Word64 Source #

Required mint-policy position in ascending policy-hash order. Empty and zero-quantity imported policies count. Absence returns InvalidBuildingRequest.

withdrawalIndex :: RewardAddress -> Query Word64 Source #

Required withdrawal position in ledger reward-account order, as documented by findWithdrawal. Absence returns InvalidBuildingRequest.

voteIndex :: Voter -> Query Word64 Source #

Required voter position in ledger role and credential order, independent of the number of action votes. Absence returns InvalidBuildingRequest.

proposalIndex :: Proposal -> Query Word64 Source #

Required proposal position in insertion order, comparing canonical encodings and using the first duplicate. Absence returns InvalidBuildingRequest.

redeemerIndex :: RedeemerId -> Query Word64 Source #

Required rank among redeemers ordered by purpose and purpose index. This is not the authorized body-item index. Absence returns InvalidBuildingRequest.

outputIndex :: Output -> Query Word64 Source #

Unique output with equal semantic fields, including exact inline datum bytes. Creation order determines the index. Missing or multiple equal outputs return InvalidBuildingRequest; no first-match choice is made.

outputIndexWhere :: (Output -> Bool) -> Query Word64 Source #

Unique output satisfying a pure predicate, in creation order. No match or multiple matches return distinct InvalidBuildingRequest diagnostics.

redeemer :: (a -> PlutusData) -> Query a -> DeferredRedeemer Source #

Turn a query into the existing plan callback using an explicit application data encoder. Encoding uses fromData; the query's first failure is propagated unchanged. Repeated callbacks rerun the query against each draft.

encodedRedeemer :: Query EncodedPlutusData -> DeferredRedeemer Source #

Turn exact validated script data into the existing plan callback without re-encoding its CBOR. Compatible with top-level and subtransaction plan callbacks; both receive the builder's Transaction draft. Pure index queries inspect the supplied draft's top-level body and do not descend into nested subtransactions. Use a raw callback for other contextual policies.